2 * linux/arch/arm/mach-omap2/board-omap3evm.c
4 * Copyright (C) 2008 Texas Instruments
6 * Modified from mach-omap2/board-3430sdp.c
8 * Initial code: Syed Mohammed Khasim
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/err.h>
20 #include <linux/clk.h>
21 #include <linux/gpio.h>
22 #include <linux/input.h>
23 #include <linux/input/matrix_keypad.h>
24 #include <linux/leds.h>
25 #include <linux/interrupt.h>
27 #include <linux/spi/spi.h>
28 #include <linux/spi/ads7846.h>
29 #include <linux/i2c/twl.h>
30 #include <linux/usb/otg.h>
31 #include <linux/smsc911x.h>
33 #include <linux/regulator/machine.h>
34 #include <linux/mmc/host.h>
36 #include <mach/hardware.h>
37 #include <asm/mach-types.h>
38 #include <asm/mach/arch.h>
39 #include <asm/mach/map.h>
41 #include <plat/board.h>
43 #include <plat/common.h>
44 #include <plat/mcspi.h>
45 #include <plat/display.h>
48 #include "sdram-micron-mt46h32m32lf-6.h"
51 #define OMAP3_EVM_TS_GPIO 175
52 #define OMAP3_EVM_EHCI_VBUS 22
53 #define OMAP3_EVM_EHCI_SELECT 61
55 #define OMAP3EVM_ETHR_START 0x2c000000
56 #define OMAP3EVM_ETHR_SIZE 1024
57 #define OMAP3EVM_ETHR_ID_REV 0x50
58 #define OMAP3EVM_ETHR_GPIO_IRQ 176
59 #define OMAP3EVM_SMSC911X_CS 5
61 static u8 omap3_evm_version
;
63 u8
get_omap3_evm_rev(void)
65 return omap3_evm_version
;
67 EXPORT_SYMBOL(get_omap3_evm_rev
);
69 static void __init
omap3_evm_get_revision(void)
74 /* Ethernet PHY ID is stored at ID_REV register */
75 ioaddr
= ioremap_nocache(OMAP3EVM_ETHR_START
, SZ_1K
);
78 smsc_id
= readl(ioaddr
+ OMAP3EVM_ETHR_ID_REV
) & 0xFFFF0000;
84 omap3_evm_version
= OMAP3EVM_BOARD_GEN_1
;
89 omap3_evm_version
= OMAP3EVM_BOARD_GEN_2
;
93 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
94 static struct resource omap3evm_smsc911x_resources
[] = {
96 .start
= OMAP3EVM_ETHR_START
,
97 .end
= (OMAP3EVM_ETHR_START
+ OMAP3EVM_ETHR_SIZE
- 1),
98 .flags
= IORESOURCE_MEM
,
101 .start
= OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ
),
102 .end
= OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ
),
103 .flags
= (IORESOURCE_IRQ
| IRQF_TRIGGER_LOW
),
107 static struct smsc911x_platform_config smsc911x_config
= {
108 .phy_interface
= PHY_INTERFACE_MODE_MII
,
109 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_LOW
,
110 .irq_type
= SMSC911X_IRQ_TYPE_OPEN_DRAIN
,
111 .flags
= (SMSC911X_USE_32BIT
| SMSC911X_SAVE_MAC_ADDRESS
),
114 static struct platform_device omap3evm_smsc911x_device
= {
117 .num_resources
= ARRAY_SIZE(omap3evm_smsc911x_resources
),
118 .resource
= &omap3evm_smsc911x_resources
[0],
120 .platform_data
= &smsc911x_config
,
124 static inline void __init
omap3evm_init_smsc911x(void)
130 eth_cs
= OMAP3EVM_SMSC911X_CS
;
132 l3ck
= clk_get(NULL
, "l3_ck");
136 rate
= clk_get_rate(l3ck
);
138 if (gpio_request(OMAP3EVM_ETHR_GPIO_IRQ
, "SMSC911x irq") < 0) {
139 printk(KERN_ERR
"Failed to request GPIO%d for smsc911x IRQ\n",
140 OMAP3EVM_ETHR_GPIO_IRQ
);
144 gpio_direction_input(OMAP3EVM_ETHR_GPIO_IRQ
);
145 platform_device_register(&omap3evm_smsc911x_device
);
149 static inline void __init
omap3evm_init_smsc911x(void) { return; }
153 * OMAP3EVM LCD Panel control signals
155 #define OMAP3EVM_LCD_PANEL_LR 2
156 #define OMAP3EVM_LCD_PANEL_UD 3
157 #define OMAP3EVM_LCD_PANEL_INI 152
158 #define OMAP3EVM_LCD_PANEL_ENVDD 153
159 #define OMAP3EVM_LCD_PANEL_QVGA 154
160 #define OMAP3EVM_LCD_PANEL_RESB 155
161 #define OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO 210
162 #define OMAP3EVM_DVI_PANEL_EN_GPIO 199
164 static int lcd_enabled
;
165 static int dvi_enabled
;
167 static void __init
omap3_evm_display_init(void)
171 r
= gpio_request(OMAP3EVM_LCD_PANEL_RESB
, "lcd_panel_resb");
173 printk(KERN_ERR
"failed to get lcd_panel_resb\n");
176 gpio_direction_output(OMAP3EVM_LCD_PANEL_RESB
, 1);
178 r
= gpio_request(OMAP3EVM_LCD_PANEL_INI
, "lcd_panel_ini");
180 printk(KERN_ERR
"failed to get lcd_panel_ini\n");
183 gpio_direction_output(OMAP3EVM_LCD_PANEL_INI
, 1);
185 r
= gpio_request(OMAP3EVM_LCD_PANEL_QVGA
, "lcd_panel_qvga");
187 printk(KERN_ERR
"failed to get lcd_panel_qvga\n");
190 gpio_direction_output(OMAP3EVM_LCD_PANEL_QVGA
, 0);
192 r
= gpio_request(OMAP3EVM_LCD_PANEL_LR
, "lcd_panel_lr");
194 printk(KERN_ERR
"failed to get lcd_panel_lr\n");
197 gpio_direction_output(OMAP3EVM_LCD_PANEL_LR
, 1);
199 r
= gpio_request(OMAP3EVM_LCD_PANEL_UD
, "lcd_panel_ud");
201 printk(KERN_ERR
"failed to get lcd_panel_ud\n");
204 gpio_direction_output(OMAP3EVM_LCD_PANEL_UD
, 1);
206 r
= gpio_request(OMAP3EVM_LCD_PANEL_ENVDD
, "lcd_panel_envdd");
208 printk(KERN_ERR
"failed to get lcd_panel_envdd\n");
211 gpio_direction_output(OMAP3EVM_LCD_PANEL_ENVDD
, 0);
216 gpio_free(OMAP3EVM_LCD_PANEL_UD
);
218 gpio_free(OMAP3EVM_LCD_PANEL_LR
);
220 gpio_free(OMAP3EVM_LCD_PANEL_QVGA
);
222 gpio_free(OMAP3EVM_LCD_PANEL_INI
);
224 gpio_free(OMAP3EVM_LCD_PANEL_RESB
);
228 static int omap3_evm_enable_lcd(struct omap_dss_device
*dssdev
)
231 printk(KERN_ERR
"cannot enable LCD, DVI is enabled\n");
234 gpio_set_value(OMAP3EVM_LCD_PANEL_ENVDD
, 0);
236 if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2
)
237 gpio_set_value(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO
, 0);
239 gpio_set_value(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO
, 1);
245 static void omap3_evm_disable_lcd(struct omap_dss_device
*dssdev
)
247 gpio_set_value(OMAP3EVM_LCD_PANEL_ENVDD
, 1);
249 if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2
)
250 gpio_set_value(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO
, 1);
252 gpio_set_value(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO
, 0);
257 static struct omap_dss_device omap3_evm_lcd_device
= {
259 .driver_name
= "sharp_ls_panel",
260 .type
= OMAP_DISPLAY_TYPE_DPI
,
261 .phy
.dpi
.data_lines
= 18,
262 .platform_enable
= omap3_evm_enable_lcd
,
263 .platform_disable
= omap3_evm_disable_lcd
,
266 static int omap3_evm_enable_tv(struct omap_dss_device
*dssdev
)
271 static void omap3_evm_disable_tv(struct omap_dss_device
*dssdev
)
275 static struct omap_dss_device omap3_evm_tv_device
= {
277 .driver_name
= "venc",
278 .type
= OMAP_DISPLAY_TYPE_VENC
,
279 .phy
.venc
.type
= OMAP_DSS_VENC_TYPE_SVIDEO
,
280 .platform_enable
= omap3_evm_enable_tv
,
281 .platform_disable
= omap3_evm_disable_tv
,
284 static int omap3_evm_enable_dvi(struct omap_dss_device
*dssdev
)
287 printk(KERN_ERR
"cannot enable DVI, LCD is enabled\n");
291 gpio_set_value(OMAP3EVM_DVI_PANEL_EN_GPIO
, 1);
297 static void omap3_evm_disable_dvi(struct omap_dss_device
*dssdev
)
299 gpio_set_value(OMAP3EVM_DVI_PANEL_EN_GPIO
, 0);
304 static struct omap_dss_device omap3_evm_dvi_device
= {
306 .driver_name
= "generic_panel",
307 .type
= OMAP_DISPLAY_TYPE_DPI
,
308 .phy
.dpi
.data_lines
= 24,
309 .platform_enable
= omap3_evm_enable_dvi
,
310 .platform_disable
= omap3_evm_disable_dvi
,
313 static struct omap_dss_device
*omap3_evm_dss_devices
[] = {
314 &omap3_evm_lcd_device
,
315 &omap3_evm_tv_device
,
316 &omap3_evm_dvi_device
,
319 static struct omap_dss_board_info omap3_evm_dss_data
= {
320 .num_devices
= ARRAY_SIZE(omap3_evm_dss_devices
),
321 .devices
= omap3_evm_dss_devices
,
322 .default_device
= &omap3_evm_lcd_device
,
325 static struct platform_device omap3_evm_dss_device
= {
329 .platform_data
= &omap3_evm_dss_data
,
333 static struct regulator_consumer_supply omap3evm_vmmc1_supply
= {
337 static struct regulator_consumer_supply omap3evm_vsim_supply
= {
338 .supply
= "vmmc_aux",
341 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
342 static struct regulator_init_data omap3evm_vmmc1
= {
346 .valid_modes_mask
= REGULATOR_MODE_NORMAL
347 | REGULATOR_MODE_STANDBY
,
348 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
349 | REGULATOR_CHANGE_MODE
350 | REGULATOR_CHANGE_STATUS
,
352 .num_consumer_supplies
= 1,
353 .consumer_supplies
= &omap3evm_vmmc1_supply
,
356 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
357 static struct regulator_init_data omap3evm_vsim
= {
361 .valid_modes_mask
= REGULATOR_MODE_NORMAL
362 | REGULATOR_MODE_STANDBY
,
363 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
364 | REGULATOR_CHANGE_MODE
365 | REGULATOR_CHANGE_STATUS
,
367 .num_consumer_supplies
= 1,
368 .consumer_supplies
= &omap3evm_vsim_supply
,
371 static struct omap2_hsmmc_info mmc
[] = {
374 .caps
= MMC_CAP_4_BIT_DATA
,
381 static struct gpio_led gpio_leds
[] = {
383 .name
= "omap3evm::ledb",
384 /* normally not visible (board underside) */
385 .default_trigger
= "default-on",
386 .gpio
= -EINVAL
, /* gets replaced */
391 static struct gpio_led_platform_data gpio_led_info
= {
393 .num_leds
= ARRAY_SIZE(gpio_leds
),
396 static struct platform_device leds_gpio
= {
400 .platform_data
= &gpio_led_info
,
405 static int omap3evm_twl_gpio_setup(struct device
*dev
,
406 unsigned gpio
, unsigned ngpio
)
408 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
409 omap_mux_init_gpio(63, OMAP_PIN_INPUT
);
410 mmc
[0].gpio_cd
= gpio
+ 0;
411 omap2_hsmmc_init(mmc
);
413 /* link regulators to MMC adapters */
414 omap3evm_vmmc1_supply
.dev
= mmc
[0].dev
;
415 omap3evm_vsim_supply
.dev
= mmc
[0].dev
;
418 * Most GPIOs are for USB OTG. Some are mostly sent to
419 * the P2 connector; notably LEDA for the LCD backlight.
422 /* TWL4030_GPIO_MAX + 0 == ledA, LCD Backlight control */
423 gpio_request(gpio
+ TWL4030_GPIO_MAX
, "EN_LCD_BKL");
424 gpio_direction_output(gpio
+ TWL4030_GPIO_MAX
, 0);
426 /* gpio + 7 == DVI Enable */
427 gpio_request(gpio
+ 7, "EN_DVI");
428 gpio_direction_output(gpio
+ 7, 0);
430 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
431 gpio_leds
[2].gpio
= gpio
+ TWL4030_GPIO_MAX
+ 1;
433 platform_device_register(&leds_gpio
);
438 static struct twl4030_gpio_platform_data omap3evm_gpio_data
= {
439 .gpio_base
= OMAP_MAX_GPIO_LINES
,
440 .irq_base
= TWL4030_GPIO_IRQ_BASE
,
441 .irq_end
= TWL4030_GPIO_IRQ_END
,
443 .setup
= omap3evm_twl_gpio_setup
,
446 static struct twl4030_usb_data omap3evm_usb_data
= {
447 .usb_mode
= T2_USB_MODE_ULPI
,
450 static uint32_t board_keymap
[] = {
453 KEY(0, 2, KEY_ENTER
),
456 KEY(1, 0, KEY_RIGHT
),
472 static struct matrix_keymap_data board_map_data
= {
473 .keymap
= board_keymap
,
474 .keymap_size
= ARRAY_SIZE(board_keymap
),
477 static struct twl4030_keypad_data omap3evm_kp_data
= {
478 .keymap_data
= &board_map_data
,
484 static struct twl4030_madc_platform_data omap3evm_madc_data
= {
488 static struct twl4030_codec_audio_data omap3evm_audio_data
= {
489 .audio_mclk
= 26000000,
492 static struct twl4030_codec_data omap3evm_codec_data
= {
493 .audio_mclk
= 26000000,
494 .audio
= &omap3evm_audio_data
,
497 static struct regulator_consumer_supply omap3_evm_vdda_dac_supply
= {
498 .supply
= "vdda_dac",
499 .dev
= &omap3_evm_dss_device
.dev
,
502 /* VDAC for DSS driving S-Video */
503 static struct regulator_init_data omap3_evm_vdac
= {
508 .valid_modes_mask
= REGULATOR_MODE_NORMAL
509 | REGULATOR_MODE_STANDBY
,
510 .valid_ops_mask
= REGULATOR_CHANGE_MODE
511 | REGULATOR_CHANGE_STATUS
,
513 .num_consumer_supplies
= 1,
514 .consumer_supplies
= &omap3_evm_vdda_dac_supply
,
517 /* VPLL2 for digital video outputs */
518 static struct regulator_consumer_supply omap3_evm_vpll2_supply
=
519 REGULATOR_SUPPLY("vdds_dsi", "omapdss");
521 static struct regulator_init_data omap3_evm_vpll2
= {
526 .valid_modes_mask
= REGULATOR_MODE_NORMAL
527 | REGULATOR_MODE_STANDBY
,
528 .valid_ops_mask
= REGULATOR_CHANGE_MODE
529 | REGULATOR_CHANGE_STATUS
,
531 .num_consumer_supplies
= 1,
532 .consumer_supplies
= &omap3_evm_vpll2_supply
,
535 static struct twl4030_platform_data omap3evm_twldata
= {
536 .irq_base
= TWL4030_IRQ_BASE
,
537 .irq_end
= TWL4030_IRQ_END
,
539 /* platform_data for children goes here */
540 .keypad
= &omap3evm_kp_data
,
541 .madc
= &omap3evm_madc_data
,
542 .usb
= &omap3evm_usb_data
,
543 .gpio
= &omap3evm_gpio_data
,
544 .codec
= &omap3evm_codec_data
,
545 .vdac
= &omap3_evm_vdac
,
546 .vpll2
= &omap3_evm_vpll2
,
549 static struct i2c_board_info __initdata omap3evm_i2c_boardinfo
[] = {
551 I2C_BOARD_INFO("twl4030", 0x48),
552 .flags
= I2C_CLIENT_WAKE
,
553 .irq
= INT_34XX_SYS_NIRQ
,
554 .platform_data
= &omap3evm_twldata
,
558 static int __init
omap3_evm_i2c_init(void)
561 * REVISIT: These entries can be set in omap3evm_twl_data
562 * after a merge with MFD tree
564 omap3evm_twldata
.vmmc1
= &omap3evm_vmmc1
;
565 omap3evm_twldata
.vsim
= &omap3evm_vsim
;
567 omap_register_i2c_bus(1, 2600, omap3evm_i2c_boardinfo
,
568 ARRAY_SIZE(omap3evm_i2c_boardinfo
));
569 omap_register_i2c_bus(2, 400, NULL
, 0);
570 omap_register_i2c_bus(3, 400, NULL
, 0);
574 static void ads7846_dev_init(void)
576 if (gpio_request(OMAP3_EVM_TS_GPIO
, "ADS7846 pendown") < 0)
577 printk(KERN_ERR
"can't get ads7846 pen down GPIO\n");
579 gpio_direction_input(OMAP3_EVM_TS_GPIO
);
580 gpio_set_debounce(OMAP3_EVM_TS_GPIO
, 310);
583 static int ads7846_get_pendown_state(void)
585 return !gpio_get_value(OMAP3_EVM_TS_GPIO
);
588 static struct ads7846_platform_data ads7846_config
= {
596 .get_pendown_state
= ads7846_get_pendown_state
,
598 .settle_delay_usecs
= 150,
602 static struct omap2_mcspi_device_config ads7846_mcspi_config
= {
604 .single_channel
= 1, /* 0: slave, 1: master */
607 static struct spi_board_info omap3evm_spi_board_info
[] = {
609 .modalias
= "ads7846",
612 .max_speed_hz
= 1500000,
613 .controller_data
= &ads7846_mcspi_config
,
614 .irq
= OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO
),
615 .platform_data
= &ads7846_config
,
619 static struct omap_board_config_kernel omap3_evm_config
[] __initdata
= {
622 static void __init
omap3_evm_init_irq(void)
624 omap_board_config
= omap3_evm_config
;
625 omap_board_config_size
= ARRAY_SIZE(omap3_evm_config
);
626 omap2_init_common_hw(mt46h32m32lf6_sdrc_params
, NULL
);
631 static struct platform_device
*omap3_evm_devices
[] __initdata
= {
632 &omap3_evm_dss_device
,
635 static struct ehci_hcd_omap_platform_data ehci_pdata __initdata
= {
637 .port_mode
[0] = EHCI_HCD_OMAP_MODE_UNKNOWN
,
638 .port_mode
[1] = EHCI_HCD_OMAP_MODE_PHY
,
639 .port_mode
[2] = EHCI_HCD_OMAP_MODE_UNKNOWN
,
642 /* PHY reset GPIO will be runtime programmed based on EVM version */
643 .reset_gpio_port
[0] = -EINVAL
,
644 .reset_gpio_port
[1] = -EINVAL
,
645 .reset_gpio_port
[2] = -EINVAL
648 #ifdef CONFIG_OMAP_MUX
649 static struct omap_board_mux board_mux
[] __initdata
= {
650 OMAP3_MUX(SYS_NIRQ
, OMAP_MUX_MODE0
| OMAP_PIN_INPUT_PULLUP
|
651 OMAP_PIN_OFF_INPUT_PULLUP
| OMAP_PIN_OFF_OUTPUT_LOW
|
652 OMAP_PIN_OFF_WAKEUPENABLE
),
653 OMAP3_MUX(MCSPI1_CS1
, OMAP_MUX_MODE4
| OMAP_PIN_INPUT_PULLUP
|
654 OMAP_PIN_OFF_INPUT_PULLUP
| OMAP_PIN_OFF_OUTPUT_LOW
),
655 { .reg_offset
= OMAP_MUX_TERMINATOR
},
658 #define board_mux NULL
661 static struct omap_musb_board_data musb_board_data
= {
662 .interface_type
= MUSB_INTERFACE_ULPI
,
667 static void __init
omap3_evm_init(void)
669 omap3_evm_get_revision();
670 omap3_mux_init(board_mux
, OMAP_PACKAGE_CBB
);
672 omap3_evm_i2c_init();
674 platform_add_devices(omap3_evm_devices
, ARRAY_SIZE(omap3_evm_devices
));
676 spi_register_board_info(omap3evm_spi_board_info
,
677 ARRAY_SIZE(omap3evm_spi_board_info
));
681 /* OMAP3EVM uses ISP1504 phy and so register nop transceiver */
682 usb_nop_xceiv_register();
684 if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2
) {
685 /* enable EHCI VBUS using GPIO22 */
686 omap_mux_init_gpio(22, OMAP_PIN_INPUT_PULLUP
);
687 gpio_request(OMAP3_EVM_EHCI_VBUS
, "enable EHCI VBUS");
688 gpio_direction_output(OMAP3_EVM_EHCI_VBUS
, 0);
689 gpio_set_value(OMAP3_EVM_EHCI_VBUS
, 1);
691 /* Select EHCI port on main board */
692 omap_mux_init_gpio(61, OMAP_PIN_INPUT_PULLUP
);
693 gpio_request(OMAP3_EVM_EHCI_SELECT
, "select EHCI port");
694 gpio_direction_output(OMAP3_EVM_EHCI_SELECT
, 0);
695 gpio_set_value(OMAP3_EVM_EHCI_SELECT
, 0);
697 /* setup EHCI phy reset config */
698 omap_mux_init_gpio(21, OMAP_PIN_INPUT_PULLUP
);
699 ehci_pdata
.reset_gpio_port
[1] = 21;
701 /* EVM REV >= E can supply 500mA with EXTVBUS programming */
702 musb_board_data
.power
= 500;
703 musb_board_data
.extvbus
= 1;
705 /* setup EHCI phy reset on MDC */
706 omap_mux_init_gpio(135, OMAP_PIN_OUTPUT
);
707 ehci_pdata
.reset_gpio_port
[1] = 135;
709 usb_musb_init(&musb_board_data
);
710 usb_ehci_init(&ehci_pdata
);
712 omap3evm_init_smsc911x();
713 omap3_evm_display_init();
716 MACHINE_START(OMAP3EVM
, "OMAP3 EVM")
717 /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
718 .boot_params
= 0x80000100,
719 .map_io
= omap3_map_io
,
720 .reserve
= omap_reserve
,
721 .init_irq
= omap3_evm_init_irq
,
722 .init_machine
= omap3_evm_init
,
723 .timer
= &omap_timer
,