2 * board-devkit8000.c - TimLL Devkit8000
4 * Copyright (C) 2009 Kim Botherway
5 * Copyright (C) 2010 Thomas Weber
7 * Modified from mach-omap2/board-omap3beagle.c
9 * Initial code: Syed Mohammed Khasim
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/delay.h>
20 #include <linux/err.h>
21 #include <linux/clk.h>
23 #include <linux/leds.h>
24 #include <linux/gpio.h>
25 #include <linux/input.h>
26 #include <linux/gpio_keys.h>
28 #include <linux/mtd/mtd.h>
29 #include <linux/mtd/partitions.h>
30 #include <linux/mtd/nand.h>
32 #include <linux/regulator/machine.h>
33 #include <linux/i2c/twl.h>
35 #include <mach/hardware.h>
36 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
38 #include <asm/mach/map.h>
39 #include <asm/mach/flash.h>
41 #include <plat/board.h>
42 #include <plat/common.h>
43 #include <plat/gpmc.h>
44 #include <plat/nand.h>
46 #include <plat/timer-gp.h>
47 #include <plat/display.h>
49 #include <plat/mcspi.h>
50 #include <linux/input/matrix_keypad.h>
51 #include <linux/spi/spi.h>
52 #include <linux/spi/ads7846.h>
53 #include <linux/usb/otg.h>
54 #include <linux/dm9000.h>
55 #include <linux/interrupt.h>
57 #include "sdram-micron-mt46h32m32lf-6.h"
62 #define GPMC_CS0_BASE 0x60
63 #define GPMC_CS_SIZE 0x30
65 #define NAND_BLOCK_SIZE SZ_128K
67 #define OMAP_DM9000_GPIO_IRQ 25
68 #define OMAP3_DEVKIT_TS_GPIO 27
70 static struct mtd_partition devkit8000_nand_partitions[] = {
71 /* All the partition sizes are listed in terms of NAND block size */
75 .size = 4 * NAND_BLOCK_SIZE,
76 .mask_flags = MTD_WRITEABLE, /* force read-only */
80 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
81 .size = 15 * NAND_BLOCK_SIZE,
82 .mask_flags = MTD_WRITEABLE, /* force read-only */
86 .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
87 .size = 1 * NAND_BLOCK_SIZE,
91 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
92 .size = 32 * NAND_BLOCK_SIZE,
95 .name = "File System",
96 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
97 .size = MTDPART_SIZ_FULL,
101 static struct omap_nand_platform_data devkit8000_nand_data = {
102 .options = NAND_BUSWIDTH_16,
103 .parts = devkit8000_nand_partitions,
104 .nr_parts = ARRAY_SIZE(devkit8000_nand_partitions),
105 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
108 static struct resource devkit8000_nand_resource = {
109 .flags = IORESOURCE_MEM,
112 static struct platform_device devkit8000_nand_device = {
113 .name = "omap2-nand",
116 .platform_data = &devkit8000_nand_data,
119 .resource = &devkit8000_nand_resource,
122 static struct omap2_hsmmc_info mmc[] = {
130 static struct omap_board_config_kernel devkit8000_config[] __initdata = {
133 static int devkit8000_panel_enable_lcd(struct omap_dss_device *dssdev)
135 twl_i2c_write_u8(TWL4030_MODULE_GPIO, 0x80, REG_GPIODATADIR1);
136 twl_i2c_write_u8(TWL4030_MODULE_LED, 0x0, 0x0);
141 static void devkit8000_panel_disable_lcd(struct omap_dss_device *dssdev)
144 static int devkit8000_panel_enable_dvi(struct omap_dss_device *dssdev)
149 static void devkit8000_panel_disable_dvi(struct omap_dss_device *dssdev)
153 static int devkit8000_panel_enable_tv(struct omap_dss_device *dssdev)
159 static void devkit8000_panel_disable_tv(struct omap_dss_device *dssdev)
164 static struct regulator_consumer_supply devkit8000_vmmc1_supply = {
168 static struct regulator_consumer_supply devkit8000_vsim_supply = {
169 .supply = "vmmc_aux",
173 static struct omap_dss_device devkit8000_lcd_device = {
175 .driver_name = "innolux_at_panel",
176 .type = OMAP_DISPLAY_TYPE_DPI,
177 .phy.dpi.data_lines = 24,
178 .platform_enable = devkit8000_panel_enable_lcd,
179 .platform_disable = devkit8000_panel_disable_lcd,
181 static struct omap_dss_device devkit8000_dvi_device = {
183 .driver_name = "generic_panel",
184 .type = OMAP_DISPLAY_TYPE_DPI,
185 .phy.dpi.data_lines = 24,
186 .platform_enable = devkit8000_panel_enable_dvi,
187 .platform_disable = devkit8000_panel_disable_dvi,
190 static struct omap_dss_device devkit8000_tv_device = {
192 .driver_name = "venc",
193 .type = OMAP_DISPLAY_TYPE_VENC,
194 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
195 .platform_enable = devkit8000_panel_enable_tv,
196 .platform_disable = devkit8000_panel_disable_tv,
200 static struct omap_dss_device *devkit8000_dss_devices[] = {
201 &devkit8000_lcd_device,
202 &devkit8000_dvi_device,
203 &devkit8000_tv_device,
206 static struct omap_dss_board_info devkit8000_dss_data = {
207 .num_devices = ARRAY_SIZE(devkit8000_dss_devices),
208 .devices = devkit8000_dss_devices,
209 .default_device = &devkit8000_lcd_device,
212 static struct platform_device devkit8000_dss_device = {
216 .platform_data = &devkit8000_dss_data,
220 static struct regulator_consumer_supply devkit8000_vdda_dac_supply = {
221 .supply = "vdda_dac",
222 .dev = &devkit8000_dss_device.dev,
225 static int board_keymap[] = {
240 PERSISTENT_KEY(4, 5),
241 KEY(4, 4, KEY_VOLUMEUP),
242 KEY(5, 5, KEY_VOLUMEDOWN),
246 static struct matrix_keymap_data board_map_data = {
247 .keymap = board_keymap,
248 .keymap_size = ARRAY_SIZE(board_keymap),
251 static struct twl4030_keypad_data devkit8000_kp_data = {
252 .keymap_data = &board_map_data,
258 static struct gpio_led gpio_leds[];
260 static int devkit8000_twl_gpio_setup(struct device *dev,
261 unsigned gpio, unsigned ngpio)
263 omap_mux_init_gpio(29, OMAP_PIN_INPUT);
264 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
265 mmc[0].gpio_cd = gpio + 0;
266 omap2_hsmmc_init(mmc);
268 /* link regulators to MMC adapters */
269 devkit8000_vmmc1_supply.dev = mmc[0].dev;
270 devkit8000_vsim_supply.dev = mmc[0].dev;
272 /* REVISIT: need ehci-omap hooks for external VBUS
273 * power switch and overcurrent detect
276 gpio_request(gpio + 1, "EHCI_nOC");
277 gpio_direction_input(gpio + 1);
279 /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
280 gpio_request(gpio + TWL4030_GPIO_MAX, "nEN_USB_PWR");
281 gpio_direction_output(gpio + TWL4030_GPIO_MAX, 1);
283 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
284 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
289 static struct twl4030_gpio_platform_data devkit8000_gpio_data = {
290 .gpio_base = OMAP_MAX_GPIO_LINES,
291 .irq_base = TWL4030_GPIO_IRQ_BASE,
292 .irq_end = TWL4030_GPIO_IRQ_END,
295 .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
296 | BIT(15) | BIT(16) | BIT(17),
297 .setup = devkit8000_twl_gpio_setup,
300 static struct regulator_consumer_supply devkit8000_vpll2_supplies[] = {
303 .dev = &devkit8000_lcd_device.dev,
306 .supply = "vdss_dsi",
307 .dev = &devkit8000_dss_device.dev,
311 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
312 static struct regulator_init_data devkit8000_vmmc1 = {
316 .valid_modes_mask = REGULATOR_MODE_NORMAL
317 | REGULATOR_MODE_STANDBY,
318 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
319 | REGULATOR_CHANGE_MODE
320 | REGULATOR_CHANGE_STATUS,
322 .num_consumer_supplies = 1,
323 .consumer_supplies = &devkit8000_vmmc1_supply,
326 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
327 static struct regulator_init_data devkit8000_vsim = {
331 .valid_modes_mask = REGULATOR_MODE_NORMAL
332 | REGULATOR_MODE_STANDBY,
333 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
334 | REGULATOR_CHANGE_MODE
335 | REGULATOR_CHANGE_STATUS,
337 .num_consumer_supplies = 1,
338 .consumer_supplies = &devkit8000_vsim_supply,
341 /* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */
342 static struct regulator_init_data devkit8000_vdac = {
346 .valid_modes_mask = REGULATOR_MODE_NORMAL
347 | REGULATOR_MODE_STANDBY,
348 .valid_ops_mask = REGULATOR_CHANGE_MODE
349 | REGULATOR_CHANGE_STATUS,
351 .num_consumer_supplies = 1,
352 .consumer_supplies = &devkit8000_vdda_dac_supply,
355 /* VPLL2 for digital video outputs */
356 static struct regulator_init_data devkit8000_vpll2 = {
361 .valid_modes_mask = REGULATOR_MODE_NORMAL
362 | REGULATOR_MODE_STANDBY,
363 .valid_ops_mask = REGULATOR_CHANGE_MODE
364 | REGULATOR_CHANGE_STATUS,
366 .num_consumer_supplies = ARRAY_SIZE(devkit8000_vpll2_supplies),
367 .consumer_supplies = devkit8000_vpll2_supplies,
370 static struct twl4030_usb_data devkit8000_usb_data = {
371 .usb_mode = T2_USB_MODE_ULPI,
374 static struct twl4030_codec_audio_data devkit8000_audio_data = {
375 .audio_mclk = 26000000,
378 static struct twl4030_codec_data devkit8000_codec_data = {
379 .audio_mclk = 26000000,
380 .audio = &devkit8000_audio_data,
383 static struct twl4030_platform_data devkit8000_twldata = {
384 .irq_base = TWL4030_IRQ_BASE,
385 .irq_end = TWL4030_IRQ_END,
387 /* platform_data for children goes here */
388 .usb = &devkit8000_usb_data,
389 .gpio = &devkit8000_gpio_data,
390 .codec = &devkit8000_codec_data,
391 .vmmc1 = &devkit8000_vmmc1,
392 .vsim = &devkit8000_vsim,
393 .vdac = &devkit8000_vdac,
394 .vpll2 = &devkit8000_vpll2,
395 .keypad = &devkit8000_kp_data,
398 static struct i2c_board_info __initdata devkit8000_i2c_boardinfo[] = {
400 I2C_BOARD_INFO("twl4030", 0x48),
401 .flags = I2C_CLIENT_WAKE,
402 .irq = INT_34XX_SYS_NIRQ,
403 .platform_data = &devkit8000_twldata,
407 static int __init devkit8000_i2c_init(void)
409 omap_register_i2c_bus(1, 2600, devkit8000_i2c_boardinfo,
410 ARRAY_SIZE(devkit8000_i2c_boardinfo));
411 /* Bus 3 is attached to the DVI port where devices like the pico DLP
412 * projector don't work reliably with 400kHz */
413 omap_register_i2c_bus(3, 400, NULL, 0);
417 static struct gpio_led gpio_leds[] = {
420 .default_trigger = "heartbeat",
426 .default_trigger = "mmc0",
432 .default_trigger = "none",
438 .default_trigger = "none",
444 static struct gpio_led_platform_data gpio_led_info = {
446 .num_leds = ARRAY_SIZE(gpio_leds),
449 static struct platform_device leds_gpio = {
453 .platform_data = &gpio_led_info,
457 static struct gpio_keys_button gpio_buttons[] = {
466 static struct gpio_keys_platform_data gpio_key_info = {
467 .buttons = gpio_buttons,
468 .nbuttons = ARRAY_SIZE(gpio_buttons),
471 static struct platform_device keys_gpio = {
475 .platform_data = &gpio_key_info,
480 static void __init devkit8000_init_irq(void)
482 omap_board_config = devkit8000_config;
483 omap_board_config_size = ARRAY_SIZE(devkit8000_config);
484 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
485 mt46h32m32lf6_sdrc_params);
487 #ifdef CONFIG_OMAP_32K_TIMER
488 omap2_gp_clockevent_set_gptimer(12);
493 static void __init devkit8000_ads7846_init(void)
495 int gpio = OMAP3_DEVKIT_TS_GPIO;
498 ret = gpio_request(gpio, "ads7846_pen_down");
500 printk(KERN_ERR "Failed to request GPIO %d for "
501 "ads7846 pen down IRQ\n", gpio);
505 gpio_direction_input(gpio);
508 static int ads7846_get_pendown_state(void)
510 return !gpio_get_value(OMAP3_DEVKIT_TS_GPIO);
513 static struct ads7846_platform_data ads7846_config = {
521 .get_pendown_state = ads7846_get_pendown_state,
523 .settle_delay_usecs = 150,
526 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
528 .single_channel = 1, /* 0: slave, 1: master */
531 static struct spi_board_info devkit8000_spi_board_info[] __initdata = {
533 .modalias = "ads7846",
536 .max_speed_hz = 1500000,
537 .controller_data = &ads7846_mcspi_config,
538 .irq = OMAP_GPIO_IRQ(OMAP3_DEVKIT_TS_GPIO),
539 .platform_data = &ads7846_config,
543 #define OMAP_DM9000_BASE 0x2c000000
545 static struct resource omap_dm9000_resources[] = {
547 .start = OMAP_DM9000_BASE,
548 .end = (OMAP_DM9000_BASE + 0x4 - 1),
549 .flags = IORESOURCE_MEM,
552 .start = (OMAP_DM9000_BASE + 0x400),
553 .end = (OMAP_DM9000_BASE + 0x400 + 0x4 - 1),
554 .flags = IORESOURCE_MEM,
557 .start = OMAP_GPIO_IRQ(OMAP_DM9000_GPIO_IRQ),
558 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
562 static struct dm9000_plat_data omap_dm9000_platdata = {
563 .flags = DM9000_PLATF_16BITONLY,
566 static struct platform_device omap_dm9000_dev = {
569 .num_resources = ARRAY_SIZE(omap_dm9000_resources),
570 .resource = omap_dm9000_resources,
572 .platform_data = &omap_dm9000_platdata,
576 static void __init omap_dm9000_init(void)
578 if (gpio_request(OMAP_DM9000_GPIO_IRQ, "dm9000 irq") < 0) {
579 printk(KERN_ERR "Failed to request GPIO%d for dm9000 IRQ\n",
580 OMAP_DM9000_GPIO_IRQ);
584 gpio_direction_input(OMAP_DM9000_GPIO_IRQ);
587 static struct platform_device *devkit8000_devices[] __initdata = {
588 &devkit8000_dss_device,
594 static void __init devkit8000_flash_init(void)
597 u8 nandcs = GPMC_CS_NUM + 1;
599 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
601 /* find out the chip-select on which NAND exists */
602 while (cs < GPMC_CS_NUM) {
604 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
606 if ((ret & 0xC00) == 0x800) {
607 printk(KERN_INFO "Found NAND on CS%d\n", cs);
608 if (nandcs > GPMC_CS_NUM)
614 if (nandcs > GPMC_CS_NUM) {
615 printk(KERN_INFO "NAND: Unable to find configuration "
620 if (nandcs < GPMC_CS_NUM) {
621 devkit8000_nand_data.cs = nandcs;
622 devkit8000_nand_data.gpmc_cs_baseaddr = (void *)
623 (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
624 devkit8000_nand_data.gpmc_baseaddr = (void *)
627 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
628 if (platform_device_register(&devkit8000_nand_device) < 0)
629 printk(KERN_ERR "Unable to register NAND device\n");
633 static struct omap_musb_board_data musb_board_data = {
634 .interface_type = MUSB_INTERFACE_ULPI,
639 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
641 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
642 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
643 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
646 .reset_gpio_port[0] = -EINVAL,
647 .reset_gpio_port[1] = 147,
648 .reset_gpio_port[2] = -EINVAL
651 static void __init devkit8000_init(void)
653 devkit8000_i2c_init();
654 platform_add_devices(devkit8000_devices,
655 ARRAY_SIZE(devkit8000_devices));
656 omap_board_config = devkit8000_config;
657 omap_board_config_size = ARRAY_SIZE(devkit8000_config);
659 spi_register_board_info(devkit8000_spi_board_info,
660 ARRAY_SIZE(devkit8000_spi_board_info));
666 devkit8000_ads7846_init();
668 omap_mux_init_gpio(170, OMAP_PIN_INPUT);
670 gpio_request(170, "DVI_nPD");
671 /* REVISIT leave DVI powered down until it's needed ... */
672 gpio_direction_output(170, true);
674 usb_musb_init(&musb_board_data);
675 usb_ehci_init(&ehci_pdata);
676 devkit8000_flash_init();
678 /* Ensure SDRC pins are mux'd for self-refresh */
679 omap_mux_init_signal("sdr_cke0", OMAP_PIN_OUTPUT);
680 omap_mux_init_signal("sdr_cke1", OMAP_PIN_OUTPUT);
683 static void __init devkit8000_map_io(void)
685 omap2_set_globals_343x();
686 omap34xx_map_common_io();
689 MACHINE_START(DEVKIT8000, "OMAP3 Devkit8000")
690 .phys_io = 0x48000000,
691 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
692 .boot_params = 0x80000100,
693 .map_io = devkit8000_map_io,
694 .init_irq = devkit8000_init_irq,
695 .init_machine = devkit8000_init,
696 .timer = &omap_timer,