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/dm9000.h>
54 #include <linux/interrupt.h>
56 #include "sdram-micron-mt46h32m32lf-6.h"
61 #define GPMC_CS0_BASE 0x60
62 #define GPMC_CS_SIZE 0x30
64 #define NAND_BLOCK_SIZE SZ_128K
66 #define OMAP_DM9000_GPIO_IRQ 25
67 #define OMAP3_DEVKIT_TS_GPIO 27
69 static struct mtd_partition devkit8000_nand_partitions
[] = {
70 /* All the partition sizes are listed in terms of NAND block size */
74 .size
= 4 * NAND_BLOCK_SIZE
,
75 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
79 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x80000 */
80 .size
= 15 * NAND_BLOCK_SIZE
,
81 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
85 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x260000 */
86 .size
= 1 * NAND_BLOCK_SIZE
,
90 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x280000 */
91 .size
= 32 * NAND_BLOCK_SIZE
,
94 .name
= "File System",
95 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x680000 */
96 .size
= MTDPART_SIZ_FULL
,
100 static struct omap_nand_platform_data devkit8000_nand_data
= {
101 .options
= NAND_BUSWIDTH_16
,
102 .parts
= devkit8000_nand_partitions
,
103 .nr_parts
= ARRAY_SIZE(devkit8000_nand_partitions
),
104 .dma_channel
= -1, /* disable DMA in OMAP NAND driver */
107 static struct resource devkit8000_nand_resource
= {
108 .flags
= IORESOURCE_MEM
,
111 static struct platform_device devkit8000_nand_device
= {
112 .name
= "omap2-nand",
115 .platform_data
= &devkit8000_nand_data
,
118 .resource
= &devkit8000_nand_resource
,
121 static struct omap2_hsmmc_info mmc
[] = {
129 static struct omap_board_config_kernel devkit8000_config
[] __initdata
= {
132 static int devkit8000_panel_enable_lcd(struct omap_dss_device
*dssdev
)
134 twl_i2c_write_u8(TWL4030_MODULE_GPIO
, 0x80, REG_GPIODATADIR1
);
135 twl_i2c_write_u8(TWL4030_MODULE_LED
, 0x0, 0x0);
140 static void devkit8000_panel_disable_lcd(struct omap_dss_device
*dssdev
)
143 static int devkit8000_panel_enable_dvi(struct omap_dss_device
*dssdev
)
148 static void devkit8000_panel_disable_dvi(struct omap_dss_device
*dssdev
)
152 static int devkit8000_panel_enable_tv(struct omap_dss_device
*dssdev
)
158 static void devkit8000_panel_disable_tv(struct omap_dss_device
*dssdev
)
163 static struct regulator_consumer_supply devkit8000_vmmc1_supply
= {
167 static struct regulator_consumer_supply devkit8000_vsim_supply
= {
168 .supply
= "vmmc_aux",
172 static struct omap_dss_device devkit8000_lcd_device
= {
174 .driver_name
= "innolux_at_panel",
175 .type
= OMAP_DISPLAY_TYPE_DPI
,
176 .phy
.dpi
.data_lines
= 24,
177 .platform_enable
= devkit8000_panel_enable_lcd
,
178 .platform_disable
= devkit8000_panel_disable_lcd
,
180 static struct omap_dss_device devkit8000_dvi_device
= {
182 .driver_name
= "generic_panel",
183 .type
= OMAP_DISPLAY_TYPE_DPI
,
184 .phy
.dpi
.data_lines
= 24,
185 .platform_enable
= devkit8000_panel_enable_dvi
,
186 .platform_disable
= devkit8000_panel_disable_dvi
,
189 static struct omap_dss_device devkit8000_tv_device
= {
191 .driver_name
= "venc",
192 .type
= OMAP_DISPLAY_TYPE_VENC
,
193 .phy
.venc
.type
= OMAP_DSS_VENC_TYPE_SVIDEO
,
194 .platform_enable
= devkit8000_panel_enable_tv
,
195 .platform_disable
= devkit8000_panel_disable_tv
,
199 static struct omap_dss_device
*devkit8000_dss_devices
[] = {
200 &devkit8000_lcd_device
,
201 &devkit8000_dvi_device
,
202 &devkit8000_tv_device
,
205 static struct omap_dss_board_info devkit8000_dss_data
= {
206 .num_devices
= ARRAY_SIZE(devkit8000_dss_devices
),
207 .devices
= devkit8000_dss_devices
,
208 .default_device
= &devkit8000_lcd_device
,
211 static struct platform_device devkit8000_dss_device
= {
215 .platform_data
= &devkit8000_dss_data
,
219 static struct regulator_consumer_supply devkit8000_vdda_dac_supply
= {
220 .supply
= "vdda_dac",
221 .dev
= &devkit8000_dss_device
.dev
,
224 static int board_keymap
[] = {
239 PERSISTENT_KEY(4, 5),
240 KEY(4, 4, KEY_VOLUMEUP
),
241 KEY(5, 5, KEY_VOLUMEDOWN
),
245 static struct matrix_keymap_data board_map_data
= {
246 .keymap
= board_keymap
,
247 .keymap_size
= ARRAY_SIZE(board_keymap
),
250 static struct twl4030_keypad_data devkit8000_kp_data
= {
251 .keymap_data
= &board_map_data
,
257 static struct gpio_led gpio_leds
[];
259 static int devkit8000_twl_gpio_setup(struct device
*dev
,
260 unsigned gpio
, unsigned ngpio
)
262 omap_mux_init_gpio(29, OMAP_PIN_INPUT
);
263 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
264 mmc
[0].gpio_cd
= gpio
+ 0;
265 omap2_hsmmc_init(mmc
);
267 /* link regulators to MMC adapters */
268 devkit8000_vmmc1_supply
.dev
= mmc
[0].dev
;
269 devkit8000_vsim_supply
.dev
= mmc
[0].dev
;
271 /* REVISIT: need ehci-omap hooks for external VBUS
272 * power switch and overcurrent detect
275 gpio_request(gpio
+ 1, "EHCI_nOC");
276 gpio_direction_input(gpio
+ 1);
278 /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
279 gpio_request(gpio
+ TWL4030_GPIO_MAX
, "nEN_USB_PWR");
280 gpio_direction_output(gpio
+ TWL4030_GPIO_MAX
, 1);
282 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
283 gpio_leds
[2].gpio
= gpio
+ TWL4030_GPIO_MAX
+ 1;
288 static struct twl4030_gpio_platform_data devkit8000_gpio_data
= {
289 .gpio_base
= OMAP_MAX_GPIO_LINES
,
290 .irq_base
= TWL4030_GPIO_IRQ_BASE
,
291 .irq_end
= TWL4030_GPIO_IRQ_END
,
294 .pulldowns
= BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
295 | BIT(15) | BIT(16) | BIT(17),
296 .setup
= devkit8000_twl_gpio_setup
,
299 static struct regulator_consumer_supply devkit8000_vpll2_supplies
[] = {
302 .dev
= &devkit8000_lcd_device
.dev
,
305 .supply
= "vdds_dsi",
306 .dev
= &devkit8000_dss_device
.dev
,
310 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
311 static struct regulator_init_data devkit8000_vmmc1
= {
315 .valid_modes_mask
= REGULATOR_MODE_NORMAL
316 | REGULATOR_MODE_STANDBY
,
317 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
318 | REGULATOR_CHANGE_MODE
319 | REGULATOR_CHANGE_STATUS
,
321 .num_consumer_supplies
= 1,
322 .consumer_supplies
= &devkit8000_vmmc1_supply
,
325 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
326 static struct regulator_init_data devkit8000_vsim
= {
330 .valid_modes_mask
= REGULATOR_MODE_NORMAL
331 | REGULATOR_MODE_STANDBY
,
332 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
333 | REGULATOR_CHANGE_MODE
334 | REGULATOR_CHANGE_STATUS
,
336 .num_consumer_supplies
= 1,
337 .consumer_supplies
= &devkit8000_vsim_supply
,
340 /* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */
341 static struct regulator_init_data devkit8000_vdac
= {
345 .valid_modes_mask
= REGULATOR_MODE_NORMAL
346 | REGULATOR_MODE_STANDBY
,
347 .valid_ops_mask
= REGULATOR_CHANGE_MODE
348 | REGULATOR_CHANGE_STATUS
,
350 .num_consumer_supplies
= 1,
351 .consumer_supplies
= &devkit8000_vdda_dac_supply
,
354 /* VPLL2 for digital video outputs */
355 static struct regulator_init_data devkit8000_vpll2
= {
360 .valid_modes_mask
= REGULATOR_MODE_NORMAL
361 | REGULATOR_MODE_STANDBY
,
362 .valid_ops_mask
= REGULATOR_CHANGE_MODE
363 | REGULATOR_CHANGE_STATUS
,
365 .num_consumer_supplies
= ARRAY_SIZE(devkit8000_vpll2_supplies
),
366 .consumer_supplies
= devkit8000_vpll2_supplies
,
369 static struct twl4030_usb_data devkit8000_usb_data
= {
370 .usb_mode
= T2_USB_MODE_ULPI
,
373 static struct twl4030_codec_audio_data devkit8000_audio_data
= {
374 .audio_mclk
= 26000000,
377 static struct twl4030_codec_data devkit8000_codec_data
= {
378 .audio_mclk
= 26000000,
379 .audio
= &devkit8000_audio_data
,
382 static struct twl4030_platform_data devkit8000_twldata
= {
383 .irq_base
= TWL4030_IRQ_BASE
,
384 .irq_end
= TWL4030_IRQ_END
,
386 /* platform_data for children goes here */
387 .usb
= &devkit8000_usb_data
,
388 .gpio
= &devkit8000_gpio_data
,
389 .codec
= &devkit8000_codec_data
,
390 .vmmc1
= &devkit8000_vmmc1
,
391 .vsim
= &devkit8000_vsim
,
392 .vdac
= &devkit8000_vdac
,
393 .vpll2
= &devkit8000_vpll2
,
394 .keypad
= &devkit8000_kp_data
,
397 static struct i2c_board_info __initdata devkit8000_i2c_boardinfo
[] = {
399 I2C_BOARD_INFO("twl4030", 0x48),
400 .flags
= I2C_CLIENT_WAKE
,
401 .irq
= INT_34XX_SYS_NIRQ
,
402 .platform_data
= &devkit8000_twldata
,
406 static int __init
devkit8000_i2c_init(void)
408 omap_register_i2c_bus(1, 2600, devkit8000_i2c_boardinfo
,
409 ARRAY_SIZE(devkit8000_i2c_boardinfo
));
410 /* Bus 3 is attached to the DVI port where devices like the pico DLP
411 * projector don't work reliably with 400kHz */
412 omap_register_i2c_bus(3, 400, NULL
, 0);
416 static struct gpio_led gpio_leds
[] = {
419 .default_trigger
= "heartbeat",
425 .default_trigger
= "mmc0",
431 .default_trigger
= "none",
437 .default_trigger
= "none",
443 static struct gpio_led_platform_data gpio_led_info
= {
445 .num_leds
= ARRAY_SIZE(gpio_leds
),
448 static struct platform_device leds_gpio
= {
452 .platform_data
= &gpio_led_info
,
456 static struct gpio_keys_button gpio_buttons
[] = {
465 static struct gpio_keys_platform_data gpio_key_info
= {
466 .buttons
= gpio_buttons
,
467 .nbuttons
= ARRAY_SIZE(gpio_buttons
),
470 static struct platform_device keys_gpio
= {
474 .platform_data
= &gpio_key_info
,
479 static void __init
devkit8000_init_irq(void)
481 omap_board_config
= devkit8000_config
;
482 omap_board_config_size
= ARRAY_SIZE(devkit8000_config
);
483 omap2_init_common_hw(mt46h32m32lf6_sdrc_params
,
484 mt46h32m32lf6_sdrc_params
);
486 #ifdef CONFIG_OMAP_32K_TIMER
487 omap2_gp_clockevent_set_gptimer(12);
492 static void __init
devkit8000_ads7846_init(void)
494 int gpio
= OMAP3_DEVKIT_TS_GPIO
;
497 ret
= gpio_request(gpio
, "ads7846_pen_down");
499 printk(KERN_ERR
"Failed to request GPIO %d for "
500 "ads7846 pen down IRQ\n", gpio
);
504 gpio_direction_input(gpio
);
507 static int ads7846_get_pendown_state(void)
509 return !gpio_get_value(OMAP3_DEVKIT_TS_GPIO
);
512 static struct ads7846_platform_data ads7846_config
= {
520 .get_pendown_state
= ads7846_get_pendown_state
,
522 .settle_delay_usecs
= 150,
525 static struct omap2_mcspi_device_config ads7846_mcspi_config
= {
527 .single_channel
= 1, /* 0: slave, 1: master */
530 static struct spi_board_info devkit8000_spi_board_info
[] __initdata
= {
532 .modalias
= "ads7846",
535 .max_speed_hz
= 1500000,
536 .controller_data
= &ads7846_mcspi_config
,
537 .irq
= OMAP_GPIO_IRQ(OMAP3_DEVKIT_TS_GPIO
),
538 .platform_data
= &ads7846_config
,
542 #define OMAP_DM9000_BASE 0x2c000000
544 static struct resource omap_dm9000_resources
[] = {
546 .start
= OMAP_DM9000_BASE
,
547 .end
= (OMAP_DM9000_BASE
+ 0x4 - 1),
548 .flags
= IORESOURCE_MEM
,
551 .start
= (OMAP_DM9000_BASE
+ 0x400),
552 .end
= (OMAP_DM9000_BASE
+ 0x400 + 0x4 - 1),
553 .flags
= IORESOURCE_MEM
,
556 .start
= OMAP_GPIO_IRQ(OMAP_DM9000_GPIO_IRQ
),
557 .flags
= IORESOURCE_IRQ
| IRQF_TRIGGER_LOW
,
561 static struct dm9000_plat_data omap_dm9000_platdata
= {
562 .flags
= DM9000_PLATF_16BITONLY
,
565 static struct platform_device omap_dm9000_dev
= {
568 .num_resources
= ARRAY_SIZE(omap_dm9000_resources
),
569 .resource
= omap_dm9000_resources
,
571 .platform_data
= &omap_dm9000_platdata
,
575 static void __init
omap_dm9000_init(void)
577 if (gpio_request(OMAP_DM9000_GPIO_IRQ
, "dm9000 irq") < 0) {
578 printk(KERN_ERR
"Failed to request GPIO%d for dm9000 IRQ\n",
579 OMAP_DM9000_GPIO_IRQ
);
583 gpio_direction_input(OMAP_DM9000_GPIO_IRQ
);
586 static struct platform_device
*devkit8000_devices
[] __initdata
= {
587 &devkit8000_dss_device
,
593 static void __init
devkit8000_flash_init(void)
596 u8 nandcs
= GPMC_CS_NUM
+ 1;
598 u32 gpmc_base_add
= OMAP34XX_GPMC_VIRT
;
600 /* find out the chip-select on which NAND exists */
601 while (cs
< GPMC_CS_NUM
) {
603 ret
= gpmc_cs_read_reg(cs
, GPMC_CS_CONFIG1
);
605 if ((ret
& 0xC00) == 0x800) {
606 printk(KERN_INFO
"Found NAND on CS%d\n", cs
);
607 if (nandcs
> GPMC_CS_NUM
)
613 if (nandcs
> GPMC_CS_NUM
) {
614 printk(KERN_INFO
"NAND: Unable to find configuration "
619 if (nandcs
< GPMC_CS_NUM
) {
620 devkit8000_nand_data
.cs
= nandcs
;
621 devkit8000_nand_data
.gpmc_cs_baseaddr
= (void *)
622 (gpmc_base_add
+ GPMC_CS0_BASE
+ nandcs
* GPMC_CS_SIZE
);
623 devkit8000_nand_data
.gpmc_baseaddr
= (void *)
626 printk(KERN_INFO
"Registering NAND on CS%d\n", nandcs
);
627 if (platform_device_register(&devkit8000_nand_device
) < 0)
628 printk(KERN_ERR
"Unable to register NAND device\n");
632 static struct omap_musb_board_data musb_board_data
= {
633 .interface_type
= MUSB_INTERFACE_ULPI
,
638 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst
= {
640 .port_mode
[0] = EHCI_HCD_OMAP_MODE_PHY
,
641 .port_mode
[1] = EHCI_HCD_OMAP_MODE_UNKNOWN
,
642 .port_mode
[2] = EHCI_HCD_OMAP_MODE_UNKNOWN
,
645 .reset_gpio_port
[0] = -EINVAL
,
646 .reset_gpio_port
[1] = -EINVAL
,
647 .reset_gpio_port
[2] = -EINVAL
650 static void __init
devkit8000_init(void)
656 devkit8000_i2c_init();
657 platform_add_devices(devkit8000_devices
,
658 ARRAY_SIZE(devkit8000_devices
));
659 omap_board_config
= devkit8000_config
;
660 omap_board_config_size
= ARRAY_SIZE(devkit8000_config
);
662 spi_register_board_info(devkit8000_spi_board_info
,
663 ARRAY_SIZE(devkit8000_spi_board_info
));
665 devkit8000_ads7846_init();
667 omap_mux_init_gpio(170, OMAP_PIN_INPUT
);
669 gpio_request(170, "DVI_nPD");
670 /* REVISIT leave DVI powered down until it's needed ... */
671 gpio_direction_output(170, true);
673 usb_musb_init(&musb_board_data
);
674 usb_ehci_init(&ehci_pdata
);
675 devkit8000_flash_init();
677 /* Ensure SDRC pins are mux'd for self-refresh */
678 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT
);
679 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT
);
682 static void __init
devkit8000_map_io(void)
684 omap2_set_globals_343x();
685 omap34xx_map_common_io();
688 MACHINE_START(DEVKIT8000
, "OMAP3 Devkit8000")
689 .phys_io
= 0x48000000,
690 .io_pg_offst
= ((0xd8000000) >> 18) & 0xfffc,
691 .boot_params
= 0x80000100,
692 .map_io
= devkit8000_map_io
,
693 .init_irq
= devkit8000_init_irq
,
694 .init_machine
= devkit8000_init
,
695 .timer
= &omap_timer
,