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>
35 #include <mach/hardware.h>
36 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
38 #include <asm/mach/map.h>
40 #include <plat/board.h>
42 #include <plat/common.h>
43 #include <plat/mcspi.h>
44 #include <plat/display.h>
47 #include "sdram-micron-mt46h32m32lf-6.h"
50 #define OMAP3_EVM_TS_GPIO 175
51 #define OMAP3_EVM_EHCI_VBUS 22
52 #define OMAP3_EVM_EHCI_SELECT 61
54 #define OMAP3EVM_ETHR_START 0x2c000000
55 #define OMAP3EVM_ETHR_SIZE 1024
56 #define OMAP3EVM_ETHR_ID_REV 0x50
57 #define OMAP3EVM_ETHR_GPIO_IRQ 176
58 #define OMAP3EVM_SMSC911X_CS 5
60 static u8 omap3_evm_version
;
62 u8
get_omap3_evm_rev(void)
64 return omap3_evm_version
;
66 EXPORT_SYMBOL(get_omap3_evm_rev
);
68 static void __init
omap3_evm_get_revision(void)
73 /* Ethernet PHY ID is stored at ID_REV register */
74 ioaddr
= ioremap_nocache(OMAP3EVM_ETHR_START
, SZ_1K
);
77 smsc_id
= readl(ioaddr
+ OMAP3EVM_ETHR_ID_REV
) & 0xFFFF0000;
83 omap3_evm_version
= OMAP3EVM_BOARD_GEN_1
;
88 omap3_evm_version
= OMAP3EVM_BOARD_GEN_2
;
92 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
93 static struct resource omap3evm_smsc911x_resources
[] = {
95 .start
= OMAP3EVM_ETHR_START
,
96 .end
= (OMAP3EVM_ETHR_START
+ OMAP3EVM_ETHR_SIZE
- 1),
97 .flags
= IORESOURCE_MEM
,
100 .start
= OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ
),
101 .end
= OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ
),
102 .flags
= (IORESOURCE_IRQ
| IRQF_TRIGGER_LOW
),
106 static struct smsc911x_platform_config smsc911x_config
= {
107 .phy_interface
= PHY_INTERFACE_MODE_MII
,
108 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_LOW
,
109 .irq_type
= SMSC911X_IRQ_TYPE_OPEN_DRAIN
,
110 .flags
= (SMSC911X_USE_32BIT
| SMSC911X_SAVE_MAC_ADDRESS
),
113 static struct platform_device omap3evm_smsc911x_device
= {
116 .num_resources
= ARRAY_SIZE(omap3evm_smsc911x_resources
),
117 .resource
= &omap3evm_smsc911x_resources
[0],
119 .platform_data
= &smsc911x_config
,
123 static inline void __init
omap3evm_init_smsc911x(void)
129 eth_cs
= OMAP3EVM_SMSC911X_CS
;
131 l3ck
= clk_get(NULL
, "l3_ck");
135 rate
= clk_get_rate(l3ck
);
137 if (gpio_request(OMAP3EVM_ETHR_GPIO_IRQ
, "SMSC911x irq") < 0) {
138 printk(KERN_ERR
"Failed to request GPIO%d for smsc911x IRQ\n",
139 OMAP3EVM_ETHR_GPIO_IRQ
);
143 gpio_direction_input(OMAP3EVM_ETHR_GPIO_IRQ
);
144 platform_device_register(&omap3evm_smsc911x_device
);
148 static inline void __init
omap3evm_init_smsc911x(void) { return; }
152 * OMAP3EVM LCD Panel control signals
154 #define OMAP3EVM_LCD_PANEL_LR 2
155 #define OMAP3EVM_LCD_PANEL_UD 3
156 #define OMAP3EVM_LCD_PANEL_INI 152
157 #define OMAP3EVM_LCD_PANEL_ENVDD 153
158 #define OMAP3EVM_LCD_PANEL_QVGA 154
159 #define OMAP3EVM_LCD_PANEL_RESB 155
160 #define OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO 210
161 #define OMAP3EVM_DVI_PANEL_EN_GPIO 199
163 static int lcd_enabled
;
164 static int dvi_enabled
;
166 static void __init
omap3_evm_display_init(void)
170 r
= gpio_request(OMAP3EVM_LCD_PANEL_RESB
, "lcd_panel_resb");
172 printk(KERN_ERR
"failed to get lcd_panel_resb\n");
175 gpio_direction_output(OMAP3EVM_LCD_PANEL_RESB
, 1);
177 r
= gpio_request(OMAP3EVM_LCD_PANEL_INI
, "lcd_panel_ini");
179 printk(KERN_ERR
"failed to get lcd_panel_ini\n");
182 gpio_direction_output(OMAP3EVM_LCD_PANEL_INI
, 1);
184 r
= gpio_request(OMAP3EVM_LCD_PANEL_QVGA
, "lcd_panel_qvga");
186 printk(KERN_ERR
"failed to get lcd_panel_qvga\n");
189 gpio_direction_output(OMAP3EVM_LCD_PANEL_QVGA
, 0);
191 r
= gpio_request(OMAP3EVM_LCD_PANEL_LR
, "lcd_panel_lr");
193 printk(KERN_ERR
"failed to get lcd_panel_lr\n");
196 gpio_direction_output(OMAP3EVM_LCD_PANEL_LR
, 1);
198 r
= gpio_request(OMAP3EVM_LCD_PANEL_UD
, "lcd_panel_ud");
200 printk(KERN_ERR
"failed to get lcd_panel_ud\n");
203 gpio_direction_output(OMAP3EVM_LCD_PANEL_UD
, 1);
205 r
= gpio_request(OMAP3EVM_LCD_PANEL_ENVDD
, "lcd_panel_envdd");
207 printk(KERN_ERR
"failed to get lcd_panel_envdd\n");
210 gpio_direction_output(OMAP3EVM_LCD_PANEL_ENVDD
, 0);
215 gpio_free(OMAP3EVM_LCD_PANEL_UD
);
217 gpio_free(OMAP3EVM_LCD_PANEL_LR
);
219 gpio_free(OMAP3EVM_LCD_PANEL_QVGA
);
221 gpio_free(OMAP3EVM_LCD_PANEL_INI
);
223 gpio_free(OMAP3EVM_LCD_PANEL_RESB
);
227 static int omap3_evm_enable_lcd(struct omap_dss_device
*dssdev
)
230 printk(KERN_ERR
"cannot enable LCD, DVI is enabled\n");
233 gpio_set_value(OMAP3EVM_LCD_PANEL_ENVDD
, 0);
235 if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2
)
236 gpio_set_value(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO
, 0);
238 gpio_set_value(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO
, 1);
244 static void omap3_evm_disable_lcd(struct omap_dss_device
*dssdev
)
246 gpio_set_value(OMAP3EVM_LCD_PANEL_ENVDD
, 1);
248 if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2
)
249 gpio_set_value(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO
, 1);
251 gpio_set_value(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO
, 0);
256 static struct omap_dss_device omap3_evm_lcd_device
= {
258 .driver_name
= "sharp_ls_panel",
259 .type
= OMAP_DISPLAY_TYPE_DPI
,
260 .phy
.dpi
.data_lines
= 18,
261 .platform_enable
= omap3_evm_enable_lcd
,
262 .platform_disable
= omap3_evm_disable_lcd
,
265 static int omap3_evm_enable_tv(struct omap_dss_device
*dssdev
)
270 static void omap3_evm_disable_tv(struct omap_dss_device
*dssdev
)
274 static struct omap_dss_device omap3_evm_tv_device
= {
276 .driver_name
= "venc",
277 .type
= OMAP_DISPLAY_TYPE_VENC
,
278 .phy
.venc
.type
= OMAP_DSS_VENC_TYPE_SVIDEO
,
279 .platform_enable
= omap3_evm_enable_tv
,
280 .platform_disable
= omap3_evm_disable_tv
,
283 static int omap3_evm_enable_dvi(struct omap_dss_device
*dssdev
)
286 printk(KERN_ERR
"cannot enable DVI, LCD is enabled\n");
290 gpio_set_value(OMAP3EVM_DVI_PANEL_EN_GPIO
, 1);
296 static void omap3_evm_disable_dvi(struct omap_dss_device
*dssdev
)
298 gpio_set_value(OMAP3EVM_DVI_PANEL_EN_GPIO
, 0);
303 static struct omap_dss_device omap3_evm_dvi_device
= {
305 .driver_name
= "generic_panel",
306 .type
= OMAP_DISPLAY_TYPE_DPI
,
307 .phy
.dpi
.data_lines
= 24,
308 .platform_enable
= omap3_evm_enable_dvi
,
309 .platform_disable
= omap3_evm_disable_dvi
,
312 static struct omap_dss_device
*omap3_evm_dss_devices
[] = {
313 &omap3_evm_lcd_device
,
314 &omap3_evm_tv_device
,
315 &omap3_evm_dvi_device
,
318 static struct omap_dss_board_info omap3_evm_dss_data
= {
319 .num_devices
= ARRAY_SIZE(omap3_evm_dss_devices
),
320 .devices
= omap3_evm_dss_devices
,
321 .default_device
= &omap3_evm_lcd_device
,
324 static struct platform_device omap3_evm_dss_device
= {
328 .platform_data
= &omap3_evm_dss_data
,
332 static struct regulator_consumer_supply omap3evm_vmmc1_supply
= {
336 static struct regulator_consumer_supply omap3evm_vsim_supply
= {
337 .supply
= "vmmc_aux",
340 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
341 static struct regulator_init_data omap3evm_vmmc1
= {
345 .valid_modes_mask
= REGULATOR_MODE_NORMAL
346 | REGULATOR_MODE_STANDBY
,
347 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
348 | REGULATOR_CHANGE_MODE
349 | REGULATOR_CHANGE_STATUS
,
351 .num_consumer_supplies
= 1,
352 .consumer_supplies
= &omap3evm_vmmc1_supply
,
355 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
356 static struct regulator_init_data omap3evm_vsim
= {
360 .valid_modes_mask
= REGULATOR_MODE_NORMAL
361 | REGULATOR_MODE_STANDBY
,
362 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
363 | REGULATOR_CHANGE_MODE
364 | REGULATOR_CHANGE_STATUS
,
366 .num_consumer_supplies
= 1,
367 .consumer_supplies
= &omap3evm_vsim_supply
,
370 static struct omap2_hsmmc_info mmc
[] = {
380 static struct gpio_led gpio_leds
[] = {
382 .name
= "omap3evm::ledb",
383 /* normally not visible (board underside) */
384 .default_trigger
= "default-on",
385 .gpio
= -EINVAL
, /* gets replaced */
390 static struct gpio_led_platform_data gpio_led_info
= {
392 .num_leds
= ARRAY_SIZE(gpio_leds
),
395 static struct platform_device leds_gpio
= {
399 .platform_data
= &gpio_led_info
,
404 static int omap3evm_twl_gpio_setup(struct device
*dev
,
405 unsigned gpio
, unsigned ngpio
)
407 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
408 omap_mux_init_gpio(63, OMAP_PIN_INPUT
);
409 mmc
[0].gpio_cd
= gpio
+ 0;
410 omap2_hsmmc_init(mmc
);
412 /* link regulators to MMC adapters */
413 omap3evm_vmmc1_supply
.dev
= mmc
[0].dev
;
414 omap3evm_vsim_supply
.dev
= mmc
[0].dev
;
417 * Most GPIOs are for USB OTG. Some are mostly sent to
418 * the P2 connector; notably LEDA for the LCD backlight.
421 /* TWL4030_GPIO_MAX + 0 == ledA, LCD Backlight control */
422 gpio_request(gpio
+ TWL4030_GPIO_MAX
, "EN_LCD_BKL");
423 gpio_direction_output(gpio
+ TWL4030_GPIO_MAX
, 0);
425 /* gpio + 7 == DVI Enable */
426 gpio_request(gpio
+ 7, "EN_DVI");
427 gpio_direction_output(gpio
+ 7, 0);
429 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
430 gpio_leds
[2].gpio
= gpio
+ TWL4030_GPIO_MAX
+ 1;
432 platform_device_register(&leds_gpio
);
437 static struct twl4030_gpio_platform_data omap3evm_gpio_data
= {
438 .gpio_base
= OMAP_MAX_GPIO_LINES
,
439 .irq_base
= TWL4030_GPIO_IRQ_BASE
,
440 .irq_end
= TWL4030_GPIO_IRQ_END
,
442 .setup
= omap3evm_twl_gpio_setup
,
445 static struct twl4030_usb_data omap3evm_usb_data
= {
446 .usb_mode
= T2_USB_MODE_ULPI
,
449 static int board_keymap
[] = {
452 KEY(0, 2, KEY_ENTER
),
455 KEY(1, 0, KEY_RIGHT
),
471 static struct matrix_keymap_data board_map_data
= {
472 .keymap
= board_keymap
,
473 .keymap_size
= ARRAY_SIZE(board_keymap
),
476 static struct twl4030_keypad_data omap3evm_kp_data
= {
477 .keymap_data
= &board_map_data
,
483 static struct twl4030_madc_platform_data omap3evm_madc_data
= {
487 static struct twl4030_codec_audio_data omap3evm_audio_data
= {
488 .audio_mclk
= 26000000,
491 static struct twl4030_codec_data omap3evm_codec_data
= {
492 .audio_mclk
= 26000000,
493 .audio
= &omap3evm_audio_data
,
496 static struct regulator_consumer_supply omap3_evm_vdda_dac_supply
= {
497 .supply
= "vdda_dac",
498 .dev
= &omap3_evm_dss_device
.dev
,
501 /* VDAC for DSS driving S-Video */
502 static struct regulator_init_data omap3_evm_vdac
= {
507 .valid_modes_mask
= REGULATOR_MODE_NORMAL
508 | REGULATOR_MODE_STANDBY
,
509 .valid_ops_mask
= REGULATOR_CHANGE_MODE
510 | REGULATOR_CHANGE_STATUS
,
512 .num_consumer_supplies
= 1,
513 .consumer_supplies
= &omap3_evm_vdda_dac_supply
,
516 /* VPLL2 for digital video outputs */
517 static struct regulator_consumer_supply omap3_evm_vpll2_supply
=
518 REGULATOR_SUPPLY("vdds_dsi", "omapdss");
520 static struct regulator_init_data omap3_evm_vpll2
= {
525 .valid_modes_mask
= REGULATOR_MODE_NORMAL
526 | REGULATOR_MODE_STANDBY
,
527 .valid_ops_mask
= REGULATOR_CHANGE_MODE
528 | REGULATOR_CHANGE_STATUS
,
530 .num_consumer_supplies
= 1,
531 .consumer_supplies
= &omap3_evm_vpll2_supply
,
534 static struct twl4030_platform_data omap3evm_twldata
= {
535 .irq_base
= TWL4030_IRQ_BASE
,
536 .irq_end
= TWL4030_IRQ_END
,
538 /* platform_data for children goes here */
539 .keypad
= &omap3evm_kp_data
,
540 .madc
= &omap3evm_madc_data
,
541 .usb
= &omap3evm_usb_data
,
542 .gpio
= &omap3evm_gpio_data
,
543 .codec
= &omap3evm_codec_data
,
544 .vdac
= &omap3_evm_vdac
,
545 .vpll2
= &omap3_evm_vpll2
,
548 static struct i2c_board_info __initdata omap3evm_i2c_boardinfo
[] = {
550 I2C_BOARD_INFO("twl4030", 0x48),
551 .flags
= I2C_CLIENT_WAKE
,
552 .irq
= INT_34XX_SYS_NIRQ
,
553 .platform_data
= &omap3evm_twldata
,
557 static int __init
omap3_evm_i2c_init(void)
560 * REVISIT: These entries can be set in omap3evm_twl_data
561 * after a merge with MFD tree
563 omap3evm_twldata
.vmmc1
= &omap3evm_vmmc1
;
564 omap3evm_twldata
.vsim
= &omap3evm_vsim
;
566 omap_register_i2c_bus(1, 2600, omap3evm_i2c_boardinfo
,
567 ARRAY_SIZE(omap3evm_i2c_boardinfo
));
568 omap_register_i2c_bus(2, 400, NULL
, 0);
569 omap_register_i2c_bus(3, 400, NULL
, 0);
573 static void ads7846_dev_init(void)
575 if (gpio_request(OMAP3_EVM_TS_GPIO
, "ADS7846 pendown") < 0)
576 printk(KERN_ERR
"can't get ads7846 pen down GPIO\n");
578 gpio_direction_input(OMAP3_EVM_TS_GPIO
);
579 gpio_set_debounce(OMAP3_EVM_TS_GPIO
, 310);
582 static int ads7846_get_pendown_state(void)
584 return !gpio_get_value(OMAP3_EVM_TS_GPIO
);
587 struct ads7846_platform_data ads7846_config
= {
595 .get_pendown_state
= ads7846_get_pendown_state
,
597 .settle_delay_usecs
= 150,
601 static struct omap2_mcspi_device_config ads7846_mcspi_config
= {
603 .single_channel
= 1, /* 0: slave, 1: master */
606 struct spi_board_info omap3evm_spi_board_info
[] = {
608 .modalias
= "ads7846",
611 .max_speed_hz
= 1500000,
612 .controller_data
= &ads7846_mcspi_config
,
613 .irq
= OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO
),
614 .platform_data
= &ads7846_config
,
618 static struct omap_board_config_kernel omap3_evm_config
[] __initdata
= {
621 static void __init
omap3_evm_init_irq(void)
623 omap_board_config
= omap3_evm_config
;
624 omap_board_config_size
= ARRAY_SIZE(omap3_evm_config
);
625 omap2_init_common_hw(mt46h32m32lf6_sdrc_params
, NULL
);
630 static struct platform_device
*omap3_evm_devices
[] __initdata
= {
631 &omap3_evm_dss_device
,
634 static struct ehci_hcd_omap_platform_data ehci_pdata __initdata
= {
636 .port_mode
[0] = EHCI_HCD_OMAP_MODE_UNKNOWN
,
637 .port_mode
[1] = EHCI_HCD_OMAP_MODE_PHY
,
638 .port_mode
[2] = EHCI_HCD_OMAP_MODE_UNKNOWN
,
641 /* PHY reset GPIO will be runtime programmed based on EVM version */
642 .reset_gpio_port
[0] = -EINVAL
,
643 .reset_gpio_port
[1] = -EINVAL
,
644 .reset_gpio_port
[2] = -EINVAL
647 #ifdef CONFIG_OMAP_MUX
648 static struct omap_board_mux board_mux
[] __initdata
= {
649 OMAP3_MUX(SYS_NIRQ
, OMAP_MUX_MODE0
| OMAP_PIN_INPUT_PULLUP
|
650 OMAP_PIN_OFF_INPUT_PULLUP
| OMAP_PIN_OFF_OUTPUT_LOW
|
651 OMAP_PIN_OFF_WAKEUPENABLE
),
652 OMAP3_MUX(MCSPI1_CS1
, OMAP_MUX_MODE4
| OMAP_PIN_INPUT_PULLUP
|
653 OMAP_PIN_OFF_INPUT_PULLUP
| OMAP_PIN_OFF_OUTPUT_LOW
),
654 { .reg_offset
= OMAP_MUX_TERMINATOR
},
657 #define board_mux NULL
660 static struct omap_musb_board_data musb_board_data
= {
661 .interface_type
= MUSB_INTERFACE_ULPI
,
666 static void __init
omap3_evm_init(void)
668 omap3_evm_get_revision();
669 omap3_mux_init(board_mux
, OMAP_PACKAGE_CBB
);
671 omap3_evm_i2c_init();
673 platform_add_devices(omap3_evm_devices
, ARRAY_SIZE(omap3_evm_devices
));
675 spi_register_board_info(omap3evm_spi_board_info
,
676 ARRAY_SIZE(omap3evm_spi_board_info
));
680 /* OMAP3EVM uses ISP1504 phy and so register nop transceiver */
681 usb_nop_xceiv_register();
683 if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2
) {
684 /* enable EHCI VBUS using GPIO22 */
685 omap_mux_init_gpio(22, OMAP_PIN_INPUT_PULLUP
);
686 gpio_request(OMAP3_EVM_EHCI_VBUS
, "enable EHCI VBUS");
687 gpio_direction_output(OMAP3_EVM_EHCI_VBUS
, 0);
688 gpio_set_value(OMAP3_EVM_EHCI_VBUS
, 1);
690 /* Select EHCI port on main board */
691 omap_mux_init_gpio(61, OMAP_PIN_INPUT_PULLUP
);
692 gpio_request(OMAP3_EVM_EHCI_SELECT
, "select EHCI port");
693 gpio_direction_output(OMAP3_EVM_EHCI_SELECT
, 0);
694 gpio_set_value(OMAP3_EVM_EHCI_SELECT
, 0);
696 /* setup EHCI phy reset config */
697 omap_mux_init_gpio(21, OMAP_PIN_INPUT_PULLUP
);
698 ehci_pdata
.reset_gpio_port
[1] = 21;
700 /* EVM REV >= E can supply 500mA with EXTVBUS programming */
701 musb_board_data
.power
= 500;
702 musb_board_data
.extvbus
= 1;
704 /* setup EHCI phy reset on MDC */
705 omap_mux_init_gpio(135, OMAP_PIN_OUTPUT
);
706 ehci_pdata
.reset_gpio_port
[1] = 135;
708 usb_musb_init(&musb_board_data
);
709 usb_ehci_init(&ehci_pdata
);
711 omap3evm_init_smsc911x();
712 omap3_evm_display_init();
715 MACHINE_START(OMAP3EVM
, "OMAP3 EVM")
716 /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
717 .phys_io
= 0x48000000,
718 .io_pg_offst
= ((0xfa000000) >> 18) & 0xfffc,
719 .boot_params
= 0x80000100,
720 .map_io
= omap3_map_io
,
721 .reserve
= omap_reserve
,
722 .init_irq
= omap3_evm_init_irq
,
723 .init_machine
= omap3_evm_init
,
724 .timer
= &omap_timer
,