2 * board-overo.c (Gumstix Overo)
4 * Initial code: Steve Sakoman <steve@sakoman.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 #include <linux/clk.h>
23 #include <linux/delay.h>
24 #include <linux/err.h>
25 #include <linux/init.h>
27 #include <linux/kernel.h>
28 #include <linux/platform_device.h>
29 #include <linux/i2c/twl.h>
30 #include <linux/regulator/machine.h>
31 #include <linux/regulator/fixed.h>
32 #include <linux/spi/spi.h>
34 #include <linux/mtd/mtd.h>
35 #include <linux/mtd/nand.h>
36 #include <linux/mtd/partitions.h>
37 #include <linux/mmc/host.h>
39 #include <asm/mach-types.h>
40 #include <asm/mach/arch.h>
41 #include <asm/mach/flash.h>
42 #include <asm/mach/map.h>
44 #include <plat/board.h>
45 #include <plat/common.h>
46 #include <plat/display.h>
47 #include <plat/panel-generic-dpi.h>
48 #include <mach/gpio.h>
49 #include <plat/gpmc.h>
50 #include <mach/hardware.h>
51 #include <plat/nand.h>
52 #include <plat/mcspi.h>
57 #include "sdram-micron-mt46h32m32lf-6.h"
60 #define OVERO_GPIO_BT_XGATE 15
61 #define OVERO_GPIO_W2W_NRESET 16
62 #define OVERO_GPIO_PENDOWN 114
63 #define OVERO_GPIO_BT_NRESET 164
64 #define OVERO_GPIO_USBH_CPEN 168
65 #define OVERO_GPIO_USBH_NRESET 183
67 #define NAND_BLOCK_SIZE SZ_128K
69 #define OVERO_SMSC911X_CS 5
70 #define OVERO_SMSC911X_GPIO 176
71 #define OVERO_SMSC911X2_CS 4
72 #define OVERO_SMSC911X2_GPIO 65
74 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
75 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
77 #include <linux/spi/ads7846.h>
79 static struct omap2_mcspi_device_config ads7846_mcspi_config
= {
81 .single_channel
= 1, /* 0: slave, 1: master */
84 static int ads7846_get_pendown_state(void)
86 return !gpio_get_value(OVERO_GPIO_PENDOWN
);
89 static struct ads7846_platform_data ads7846_config
= {
97 .get_pendown_state
= ads7846_get_pendown_state
,
101 /* fixed regulator for ads7846 */
102 static struct regulator_consumer_supply ads7846_supply
=
103 REGULATOR_SUPPLY("vcc", "spi1.0");
105 static struct regulator_init_data vads7846_regulator
= {
107 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
109 .num_consumer_supplies
= 1,
110 .consumer_supplies
= &ads7846_supply
,
113 static struct fixed_voltage_config vads7846
= {
114 .supply_name
= "vads7846",
115 .microvolts
= 3300000, /* 3.3V */
118 .init_data
= &vads7846_regulator
,
121 static struct platform_device vads7846_device
= {
122 .name
= "reg-fixed-voltage",
125 .platform_data
= &vads7846
,
129 static void __init
overo_ads7846_init(void)
131 if ((gpio_request(OVERO_GPIO_PENDOWN
, "ADS7846_PENDOWN") == 0) &&
132 (gpio_direction_input(OVERO_GPIO_PENDOWN
) == 0)) {
133 gpio_export(OVERO_GPIO_PENDOWN
, 0);
135 printk(KERN_ERR
"could not obtain gpio for ADS7846_PENDOWN\n");
139 platform_device_register(&vads7846_device
);
143 static inline void __init
overo_ads7846_init(void) { return; }
146 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
148 #include <linux/smsc911x.h>
149 #include <plat/gpmc-smsc911x.h>
151 static struct omap_smsc911x_platform_data smsc911x_cfg
= {
153 .cs
= OVERO_SMSC911X_CS
,
154 .gpio_irq
= OVERO_SMSC911X_GPIO
,
155 .gpio_reset
= -EINVAL
,
156 .flags
= SMSC911X_USE_32BIT
,
159 static struct omap_smsc911x_platform_data smsc911x2_cfg
= {
161 .cs
= OVERO_SMSC911X2_CS
,
162 .gpio_irq
= OVERO_SMSC911X2_GPIO
,
163 .gpio_reset
= -EINVAL
,
164 .flags
= SMSC911X_USE_32BIT
,
167 static void __init
overo_init_smsc911x(void)
169 gpmc_smsc911x_init(&smsc911x_cfg
);
170 gpmc_smsc911x_init(&smsc911x2_cfg
);
174 static inline void __init
overo_init_smsc911x(void) { return; }
178 static int lcd_enabled
;
179 static int dvi_enabled
;
181 #define OVERO_GPIO_LCD_EN 144
182 #define OVERO_GPIO_LCD_BL 145
184 static void __init
overo_display_init(void)
186 if ((gpio_request(OVERO_GPIO_LCD_EN
, "OVERO_GPIO_LCD_EN") == 0) &&
187 (gpio_direction_output(OVERO_GPIO_LCD_EN
, 1) == 0))
188 gpio_export(OVERO_GPIO_LCD_EN
, 0);
190 printk(KERN_ERR
"could not obtain gpio for "
191 "OVERO_GPIO_LCD_EN\n");
193 if ((gpio_request(OVERO_GPIO_LCD_BL
, "OVERO_GPIO_LCD_BL") == 0) &&
194 (gpio_direction_output(OVERO_GPIO_LCD_BL
, 1) == 0))
195 gpio_export(OVERO_GPIO_LCD_BL
, 0);
197 printk(KERN_ERR
"could not obtain gpio for "
198 "OVERO_GPIO_LCD_BL\n");
201 static int overo_panel_enable_dvi(struct omap_dss_device
*dssdev
)
204 printk(KERN_ERR
"cannot enable DVI, LCD is enabled\n");
212 static void overo_panel_disable_dvi(struct omap_dss_device
*dssdev
)
217 static struct panel_generic_dpi_data dvi_panel
= {
219 .platform_enable
= overo_panel_enable_dvi
,
220 .platform_disable
= overo_panel_disable_dvi
,
223 static struct omap_dss_device overo_dvi_device
= {
225 .type
= OMAP_DISPLAY_TYPE_DPI
,
226 .driver_name
= "generic_dpi_panel",
228 .phy
.dpi
.data_lines
= 24,
231 static struct omap_dss_device overo_tv_device
= {
233 .driver_name
= "venc",
234 .type
= OMAP_DISPLAY_TYPE_VENC
,
235 .phy
.venc
.type
= OMAP_DSS_VENC_TYPE_SVIDEO
,
238 static int overo_panel_enable_lcd(struct omap_dss_device
*dssdev
)
241 printk(KERN_ERR
"cannot enable LCD, DVI is enabled\n");
245 gpio_set_value(OVERO_GPIO_LCD_EN
, 1);
246 gpio_set_value(OVERO_GPIO_LCD_BL
, 1);
251 static void overo_panel_disable_lcd(struct omap_dss_device
*dssdev
)
253 gpio_set_value(OVERO_GPIO_LCD_EN
, 0);
254 gpio_set_value(OVERO_GPIO_LCD_BL
, 0);
258 static struct panel_generic_dpi_data lcd43_panel
= {
259 .name
= "samsung_lte430wq_f0c",
260 .platform_enable
= overo_panel_enable_lcd
,
261 .platform_disable
= overo_panel_disable_lcd
,
264 static struct omap_dss_device overo_lcd43_device
= {
266 .type
= OMAP_DISPLAY_TYPE_DPI
,
267 .driver_name
= "generic_dpi_panel",
268 .data
= &lcd43_panel
,
269 .phy
.dpi
.data_lines
= 24,
272 #if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \
273 defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)
274 static struct omap_dss_device overo_lcd35_device
= {
275 .type
= OMAP_DISPLAY_TYPE_DPI
,
277 .driver_name
= "lgphilips_lb035q02_panel",
278 .phy
.dpi
.data_lines
= 24,
279 .platform_enable
= overo_panel_enable_lcd
,
280 .platform_disable
= overo_panel_disable_lcd
,
284 static struct omap_dss_device
*overo_dss_devices
[] = {
287 #if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \
288 defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)
294 static struct omap_dss_board_info overo_dss_data
= {
295 .num_devices
= ARRAY_SIZE(overo_dss_devices
),
296 .devices
= overo_dss_devices
,
297 .default_device
= &overo_dvi_device
,
300 static struct regulator_consumer_supply overo_vdda_dac_supply
=
301 REGULATOR_SUPPLY("vdda_dac", "omapdss_venc");
303 static struct regulator_consumer_supply overo_vdds_dsi_supply
[] = {
304 REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
305 REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi1"),
308 static struct mtd_partition overo_nand_partitions
[] = {
311 .offset
= 0, /* Offset = 0x00000 */
312 .size
= 4 * NAND_BLOCK_SIZE
,
313 .mask_flags
= MTD_WRITEABLE
317 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x80000 */
318 .size
= 14 * NAND_BLOCK_SIZE
,
321 .name
= "uboot environment",
322 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x240000 */
323 .size
= 2 * NAND_BLOCK_SIZE
,
327 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x280000 */
328 .size
= 32 * NAND_BLOCK_SIZE
,
332 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x680000 */
333 .size
= MTDPART_SIZ_FULL
,
337 static struct omap_nand_platform_data overo_nand_data
= {
338 .parts
= overo_nand_partitions
,
339 .nr_parts
= ARRAY_SIZE(overo_nand_partitions
),
340 .dma_channel
= -1, /* disable DMA in OMAP NAND driver */
343 static void __init
overo_flash_init(void)
346 u8 nandcs
= GPMC_CS_NUM
+ 1;
348 /* find out the chip-select on which NAND exists */
349 while (cs
< GPMC_CS_NUM
) {
351 ret
= gpmc_cs_read_reg(cs
, GPMC_CS_CONFIG1
);
353 if ((ret
& 0xC00) == 0x800) {
354 printk(KERN_INFO
"Found NAND on CS%d\n", cs
);
355 if (nandcs
> GPMC_CS_NUM
)
361 if (nandcs
> GPMC_CS_NUM
) {
362 printk(KERN_INFO
"NAND: Unable to find configuration "
367 if (nandcs
< GPMC_CS_NUM
) {
368 overo_nand_data
.cs
= nandcs
;
370 printk(KERN_INFO
"Registering NAND on CS%d\n", nandcs
);
371 if (gpmc_nand_init(&overo_nand_data
) < 0)
372 printk(KERN_ERR
"Unable to register NAND device\n");
376 static struct omap2_hsmmc_info mmc
[] = {
379 .caps
= MMC_CAP_4_BIT_DATA
,
385 .caps
= MMC_CAP_4_BIT_DATA
,
389 .ocr_mask
= 0x00100000, /* 3.3V */
394 static struct regulator_consumer_supply overo_vmmc1_supply
= {
398 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
399 #include <linux/leds.h>
401 static struct gpio_led gpio_leds
[] = {
403 .name
= "overo:red:gpio21",
404 .default_trigger
= "heartbeat",
409 .name
= "overo:blue:gpio22",
410 .default_trigger
= "none",
415 .name
= "overo:blue:COM",
416 .default_trigger
= "mmc0",
417 .gpio
= -EINVAL
, /* gets replaced */
422 static struct gpio_led_platform_data gpio_leds_pdata
= {
424 .num_leds
= ARRAY_SIZE(gpio_leds
),
427 static struct platform_device gpio_leds_device
= {
431 .platform_data
= &gpio_leds_pdata
,
435 static void __init
overo_init_led(void)
437 platform_device_register(&gpio_leds_device
);
441 static inline void __init
overo_init_led(void) { return; }
444 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
445 #include <linux/input.h>
446 #include <linux/gpio_keys.h>
448 static struct gpio_keys_button gpio_buttons
[] = {
463 static struct gpio_keys_platform_data gpio_keys_pdata
= {
464 .buttons
= gpio_buttons
,
465 .nbuttons
= ARRAY_SIZE(gpio_buttons
),
468 static struct platform_device gpio_keys_device
= {
472 .platform_data
= &gpio_keys_pdata
,
476 static void __init
overo_init_keys(void)
478 platform_device_register(&gpio_keys_device
);
482 static inline void __init
overo_init_keys(void) { return; }
485 static int overo_twl_gpio_setup(struct device
*dev
,
486 unsigned gpio
, unsigned ngpio
)
488 omap2_hsmmc_init(mmc
);
490 overo_vmmc1_supply
.dev
= mmc
[0].dev
;
492 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
493 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
494 gpio_leds
[2].gpio
= gpio
+ TWL4030_GPIO_MAX
+ 1;
500 static struct twl4030_gpio_platform_data overo_gpio_data
= {
501 .gpio_base
= OMAP_MAX_GPIO_LINES
,
502 .irq_base
= TWL4030_GPIO_IRQ_BASE
,
503 .irq_end
= TWL4030_GPIO_IRQ_END
,
505 .setup
= overo_twl_gpio_setup
,
508 static struct twl4030_usb_data overo_usb_data
= {
509 .usb_mode
= T2_USB_MODE_ULPI
,
512 static struct regulator_init_data overo_vmmc1
= {
516 .valid_modes_mask
= REGULATOR_MODE_NORMAL
517 | REGULATOR_MODE_STANDBY
,
518 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
519 | REGULATOR_CHANGE_MODE
520 | REGULATOR_CHANGE_STATUS
,
522 .num_consumer_supplies
= 1,
523 .consumer_supplies
= &overo_vmmc1_supply
,
526 /* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */
527 static struct regulator_init_data overo_vdac
= {
531 .valid_modes_mask
= REGULATOR_MODE_NORMAL
532 | REGULATOR_MODE_STANDBY
,
533 .valid_ops_mask
= REGULATOR_CHANGE_MODE
534 | REGULATOR_CHANGE_STATUS
,
536 .num_consumer_supplies
= 1,
537 .consumer_supplies
= &overo_vdda_dac_supply
,
540 /* VPLL2 for digital video outputs */
541 static struct regulator_init_data overo_vpll2
= {
546 .valid_modes_mask
= REGULATOR_MODE_NORMAL
547 | REGULATOR_MODE_STANDBY
,
548 .valid_ops_mask
= REGULATOR_CHANGE_MODE
549 | REGULATOR_CHANGE_STATUS
,
551 .num_consumer_supplies
= ARRAY_SIZE(overo_vdds_dsi_supply
),
552 .consumer_supplies
= overo_vdds_dsi_supply
,
555 static struct twl4030_codec_audio_data overo_audio_data
;
557 static struct twl4030_codec_data overo_codec_data
= {
558 .audio_mclk
= 26000000,
559 .audio
= &overo_audio_data
,
562 static struct twl4030_platform_data overo_twldata
= {
563 .irq_base
= TWL4030_IRQ_BASE
,
564 .irq_end
= TWL4030_IRQ_END
,
565 .gpio
= &overo_gpio_data
,
566 .usb
= &overo_usb_data
,
567 .codec
= &overo_codec_data
,
568 .vmmc1
= &overo_vmmc1
,
570 .vpll2
= &overo_vpll2
,
573 static struct i2c_board_info __initdata overo_i2c_boardinfo
[] = {
575 I2C_BOARD_INFO("tps65950", 0x48),
576 .flags
= I2C_CLIENT_WAKE
,
577 .irq
= INT_34XX_SYS_NIRQ
,
578 .platform_data
= &overo_twldata
,
582 static int __init
overo_i2c_init(void)
584 omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo
,
585 ARRAY_SIZE(overo_i2c_boardinfo
));
586 /* i2c2 pins are used for gpio */
587 omap_register_i2c_bus(3, 400, NULL
, 0);
591 static struct spi_board_info overo_spi_board_info
[] __initdata
= {
592 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
593 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
595 .modalias
= "ads7846",
598 .max_speed_hz
= 1500000,
599 .controller_data
= &ads7846_mcspi_config
,
600 .irq
= OMAP_GPIO_IRQ(OVERO_GPIO_PENDOWN
),
601 .platform_data
= &ads7846_config
,
604 #if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \
605 defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)
607 .modalias
= "lgphilips_lb035q02_panel-spi",
610 .max_speed_hz
= 500000,
616 static int __init
overo_spi_init(void)
618 overo_ads7846_init();
619 spi_register_board_info(overo_spi_board_info
,
620 ARRAY_SIZE(overo_spi_board_info
));
624 static void __init
overo_init_early(void)
626 omap2_init_common_infrastructure();
627 omap2_init_common_devices(mt46h32m32lf6_sdrc_params
,
628 mt46h32m32lf6_sdrc_params
);
631 static const struct usbhs_omap_board_data usbhs_bdata __initconst
= {
632 .port_mode
[0] = OMAP_USBHS_PORT_MODE_UNUSED
,
633 .port_mode
[1] = OMAP_EHCI_PORT_MODE_PHY
,
634 .port_mode
[2] = OMAP_USBHS_PORT_MODE_UNUSED
,
636 .reset_gpio_port
[0] = -EINVAL
,
637 .reset_gpio_port
[1] = OVERO_GPIO_USBH_NRESET
,
638 .reset_gpio_port
[2] = -EINVAL
641 #ifdef CONFIG_OMAP_MUX
642 static struct omap_board_mux board_mux
[] __initdata
= {
643 { .reg_offset
= OMAP_MUX_TERMINATOR
},
647 static struct omap_musb_board_data musb_board_data
= {
648 .interface_type
= MUSB_INTERFACE_ULPI
,
653 static void __init
overo_init(void)
655 omap3_mux_init(board_mux
, OMAP_PACKAGE_CBB
);
657 omap_display_init(&overo_dss_data
);
660 usb_musb_init(&musb_board_data
);
661 usbhs_init(&usbhs_bdata
);
663 overo_ads7846_init();
664 overo_init_smsc911x();
665 overo_display_init();
669 /* Ensure SDRC pins are mux'd for self-refresh */
670 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT
);
671 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT
);
673 if ((gpio_request(OVERO_GPIO_W2W_NRESET
,
674 "OVERO_GPIO_W2W_NRESET") == 0) &&
675 (gpio_direction_output(OVERO_GPIO_W2W_NRESET
, 1) == 0)) {
676 gpio_export(OVERO_GPIO_W2W_NRESET
, 0);
677 gpio_set_value(OVERO_GPIO_W2W_NRESET
, 0);
679 gpio_set_value(OVERO_GPIO_W2W_NRESET
, 1);
681 printk(KERN_ERR
"could not obtain gpio for "
682 "OVERO_GPIO_W2W_NRESET\n");
685 if ((gpio_request(OVERO_GPIO_BT_XGATE
, "OVERO_GPIO_BT_XGATE") == 0) &&
686 (gpio_direction_output(OVERO_GPIO_BT_XGATE
, 0) == 0))
687 gpio_export(OVERO_GPIO_BT_XGATE
, 0);
689 printk(KERN_ERR
"could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
691 if ((gpio_request(OVERO_GPIO_BT_NRESET
, "OVERO_GPIO_BT_NRESET") == 0) &&
692 (gpio_direction_output(OVERO_GPIO_BT_NRESET
, 1) == 0)) {
693 gpio_export(OVERO_GPIO_BT_NRESET
, 0);
694 gpio_set_value(OVERO_GPIO_BT_NRESET
, 0);
696 gpio_set_value(OVERO_GPIO_BT_NRESET
, 1);
698 printk(KERN_ERR
"could not obtain gpio for "
699 "OVERO_GPIO_BT_NRESET\n");
702 if ((gpio_request(OVERO_GPIO_USBH_CPEN
, "OVERO_GPIO_USBH_CPEN") == 0) &&
703 (gpio_direction_output(OVERO_GPIO_USBH_CPEN
, 1) == 0))
704 gpio_export(OVERO_GPIO_USBH_CPEN
, 0);
706 printk(KERN_ERR
"could not obtain gpio for "
707 "OVERO_GPIO_USBH_CPEN\n");
710 MACHINE_START(OVERO
, "Gumstix Overo")
711 .boot_params
= 0x80000100,
712 .reserve
= omap_reserve
,
713 .map_io
= omap3_map_io
,
714 .init_early
= overo_init_early
,
715 .init_irq
= omap_init_irq
,
716 .init_machine
= overo_init
,
717 .timer
= &omap_timer
,