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>
46 #include <plat/panel-generic-dpi.h>
49 #include "sdram-micron-mt46h32m32lf-6.h"
52 #define OMAP3_EVM_TS_GPIO 175
53 #define OMAP3_EVM_EHCI_VBUS 22
54 #define OMAP3_EVM_EHCI_SELECT 61
56 #define OMAP3EVM_ETHR_START 0x2c000000
57 #define OMAP3EVM_ETHR_SIZE 1024
58 #define OMAP3EVM_ETHR_ID_REV 0x50
59 #define OMAP3EVM_ETHR_GPIO_IRQ 176
60 #define OMAP3EVM_SMSC911X_CS 5
62 static u8 omap3_evm_version;
64 u8 get_omap3_evm_rev(void)
66 return omap3_evm_version;
68 EXPORT_SYMBOL(get_omap3_evm_rev);
70 static void __init omap3_evm_get_revision(void)
75 /* Ethernet PHY ID is stored at ID_REV register */
76 ioaddr = ioremap_nocache(OMAP3EVM_ETHR_START, SZ_1K);
79 smsc_id = readl(ioaddr + OMAP3EVM_ETHR_ID_REV) & 0xFFFF0000;
85 omap3_evm_version = OMAP3EVM_BOARD_GEN_1;
90 omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
94 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
95 static struct resource omap3evm_smsc911x_resources[] = {
97 .start = OMAP3EVM_ETHR_START,
98 .end = (OMAP3EVM_ETHR_START + OMAP3EVM_ETHR_SIZE - 1),
99 .flags = IORESOURCE_MEM,
102 .start = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
103 .end = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
104 .flags = (IORESOURCE_IRQ | IRQF_TRIGGER_LOW),
108 static struct smsc911x_platform_config smsc911x_config = {
109 .phy_interface = PHY_INTERFACE_MODE_MII,
110 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
111 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
112 .flags = (SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS),
115 static struct platform_device omap3evm_smsc911x_device = {
118 .num_resources = ARRAY_SIZE(omap3evm_smsc911x_resources),
119 .resource = &omap3evm_smsc911x_resources[0],
121 .platform_data = &smsc911x_config,
125 static inline void __init omap3evm_init_smsc911x(void)
131 eth_cs = OMAP3EVM_SMSC911X_CS;
133 l3ck = clk_get(NULL, "l3_ck");
137 rate = clk_get_rate(l3ck);
139 if (gpio_request(OMAP3EVM_ETHR_GPIO_IRQ, "SMSC911x irq") < 0) {
140 printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
141 OMAP3EVM_ETHR_GPIO_IRQ);
145 gpio_direction_input(OMAP3EVM_ETHR_GPIO_IRQ);
146 platform_device_register(&omap3evm_smsc911x_device);
150 static inline void __init omap3evm_init_smsc911x(void) { return; }
154 * OMAP3EVM LCD Panel control signals
156 #define OMAP3EVM_LCD_PANEL_LR 2
157 #define OMAP3EVM_LCD_PANEL_UD 3
158 #define OMAP3EVM_LCD_PANEL_INI 152
159 #define OMAP3EVM_LCD_PANEL_ENVDD 153
160 #define OMAP3EVM_LCD_PANEL_QVGA 154
161 #define OMAP3EVM_LCD_PANEL_RESB 155
162 #define OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO 210
163 #define OMAP3EVM_DVI_PANEL_EN_GPIO 199
165 static int lcd_enabled;
166 static int dvi_enabled;
168 static void __init omap3_evm_display_init(void)
172 r = gpio_request(OMAP3EVM_LCD_PANEL_RESB, "lcd_panel_resb");
174 printk(KERN_ERR "failed to get lcd_panel_resb\n");
177 gpio_direction_output(OMAP3EVM_LCD_PANEL_RESB, 1);
179 r = gpio_request(OMAP3EVM_LCD_PANEL_INI, "lcd_panel_ini");
181 printk(KERN_ERR "failed to get lcd_panel_ini\n");
184 gpio_direction_output(OMAP3EVM_LCD_PANEL_INI, 1);
186 r = gpio_request(OMAP3EVM_LCD_PANEL_QVGA, "lcd_panel_qvga");
188 printk(KERN_ERR "failed to get lcd_panel_qvga\n");
191 gpio_direction_output(OMAP3EVM_LCD_PANEL_QVGA, 0);
193 r = gpio_request(OMAP3EVM_LCD_PANEL_LR, "lcd_panel_lr");
195 printk(KERN_ERR "failed to get lcd_panel_lr\n");
198 gpio_direction_output(OMAP3EVM_LCD_PANEL_LR, 1);
200 r = gpio_request(OMAP3EVM_LCD_PANEL_UD, "lcd_panel_ud");
202 printk(KERN_ERR "failed to get lcd_panel_ud\n");
205 gpio_direction_output(OMAP3EVM_LCD_PANEL_UD, 1);
207 r = gpio_request(OMAP3EVM_LCD_PANEL_ENVDD, "lcd_panel_envdd");
209 printk(KERN_ERR "failed to get lcd_panel_envdd\n");
212 gpio_direction_output(OMAP3EVM_LCD_PANEL_ENVDD, 0);
217 gpio_free(OMAP3EVM_LCD_PANEL_UD);
219 gpio_free(OMAP3EVM_LCD_PANEL_LR);
221 gpio_free(OMAP3EVM_LCD_PANEL_QVGA);
223 gpio_free(OMAP3EVM_LCD_PANEL_INI);
225 gpio_free(OMAP3EVM_LCD_PANEL_RESB);
229 static int omap3_evm_enable_lcd(struct omap_dss_device *dssdev)
232 printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
235 gpio_set_value(OMAP3EVM_LCD_PANEL_ENVDD, 0);
237 if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2)
238 gpio_set_value(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO, 0);
240 gpio_set_value(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO, 1);
246 static void omap3_evm_disable_lcd(struct omap_dss_device *dssdev)
248 gpio_set_value(OMAP3EVM_LCD_PANEL_ENVDD, 1);
250 if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2)
251 gpio_set_value(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO, 1);
253 gpio_set_value(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO, 0);
258 static struct omap_dss_device omap3_evm_lcd_device = {
260 .driver_name = "sharp_ls_panel",
261 .type = OMAP_DISPLAY_TYPE_DPI,
262 .phy.dpi.data_lines = 18,
263 .platform_enable = omap3_evm_enable_lcd,
264 .platform_disable = omap3_evm_disable_lcd,
267 static int omap3_evm_enable_tv(struct omap_dss_device *dssdev)
272 static void omap3_evm_disable_tv(struct omap_dss_device *dssdev)
276 static struct omap_dss_device omap3_evm_tv_device = {
278 .driver_name = "venc",
279 .type = OMAP_DISPLAY_TYPE_VENC,
280 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
281 .platform_enable = omap3_evm_enable_tv,
282 .platform_disable = omap3_evm_disable_tv,
285 static int omap3_evm_enable_dvi(struct omap_dss_device *dssdev)
288 printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
292 gpio_set_value(OMAP3EVM_DVI_PANEL_EN_GPIO, 1);
298 static void omap3_evm_disable_dvi(struct omap_dss_device *dssdev)
300 gpio_set_value(OMAP3EVM_DVI_PANEL_EN_GPIO, 0);
305 static struct panel_generic_dpi_data dvi_panel = {
307 .platform_enable = omap3_evm_enable_dvi,
308 .platform_disable = omap3_evm_disable_dvi,
311 static struct omap_dss_device omap3_evm_dvi_device = {
313 .type = OMAP_DISPLAY_TYPE_DPI,
314 .driver_name = "generic_dpi_panel",
316 .phy.dpi.data_lines = 24,
319 static struct omap_dss_device *omap3_evm_dss_devices[] = {
320 &omap3_evm_lcd_device,
321 &omap3_evm_tv_device,
322 &omap3_evm_dvi_device,
325 static struct omap_dss_board_info omap3_evm_dss_data = {
326 .num_devices = ARRAY_SIZE(omap3_evm_dss_devices),
327 .devices = omap3_evm_dss_devices,
328 .default_device = &omap3_evm_lcd_device,
331 static struct platform_device omap3_evm_dss_device = {
335 .platform_data = &omap3_evm_dss_data,
339 static struct regulator_consumer_supply omap3evm_vmmc1_supply = {
343 static struct regulator_consumer_supply omap3evm_vsim_supply = {
344 .supply = "vmmc_aux",
347 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
348 static struct regulator_init_data omap3evm_vmmc1 = {
352 .valid_modes_mask = REGULATOR_MODE_NORMAL
353 | REGULATOR_MODE_STANDBY,
354 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
355 | REGULATOR_CHANGE_MODE
356 | REGULATOR_CHANGE_STATUS,
358 .num_consumer_supplies = 1,
359 .consumer_supplies = &omap3evm_vmmc1_supply,
362 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
363 static struct regulator_init_data omap3evm_vsim = {
367 .valid_modes_mask = REGULATOR_MODE_NORMAL
368 | REGULATOR_MODE_STANDBY,
369 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
370 | REGULATOR_CHANGE_MODE
371 | REGULATOR_CHANGE_STATUS,
373 .num_consumer_supplies = 1,
374 .consumer_supplies = &omap3evm_vsim_supply,
377 static struct omap2_hsmmc_info mmc[] = {
380 .caps = MMC_CAP_4_BIT_DATA,
387 static struct gpio_led gpio_leds[] = {
389 .name = "omap3evm::ledb",
390 /* normally not visible (board underside) */
391 .default_trigger = "default-on",
392 .gpio = -EINVAL, /* gets replaced */
397 static struct gpio_led_platform_data gpio_led_info = {
399 .num_leds = ARRAY_SIZE(gpio_leds),
402 static struct platform_device leds_gpio = {
406 .platform_data = &gpio_led_info,
411 static int omap3evm_twl_gpio_setup(struct device *dev,
412 unsigned gpio, unsigned ngpio)
414 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
415 omap_mux_init_gpio(63, OMAP_PIN_INPUT);
416 mmc[0].gpio_cd = gpio + 0;
417 omap2_hsmmc_init(mmc);
419 /* link regulators to MMC adapters */
420 omap3evm_vmmc1_supply.dev = mmc[0].dev;
421 omap3evm_vsim_supply.dev = mmc[0].dev;
424 * Most GPIOs are for USB OTG. Some are mostly sent to
425 * the P2 connector; notably LEDA for the LCD backlight.
428 /* TWL4030_GPIO_MAX + 0 == ledA, LCD Backlight control */
429 gpio_request(gpio + TWL4030_GPIO_MAX, "EN_LCD_BKL");
430 gpio_direction_output(gpio + TWL4030_GPIO_MAX, 0);
432 /* gpio + 7 == DVI Enable */
433 gpio_request(gpio + 7, "EN_DVI");
434 gpio_direction_output(gpio + 7, 0);
436 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
437 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
439 platform_device_register(&leds_gpio);
444 static struct twl4030_gpio_platform_data omap3evm_gpio_data = {
445 .gpio_base = OMAP_MAX_GPIO_LINES,
446 .irq_base = TWL4030_GPIO_IRQ_BASE,
447 .irq_end = TWL4030_GPIO_IRQ_END,
449 .setup = omap3evm_twl_gpio_setup,
452 static struct twl4030_usb_data omap3evm_usb_data = {
453 .usb_mode = T2_USB_MODE_ULPI,
456 static uint32_t board_keymap[] = {
459 KEY(0, 2, KEY_ENTER),
462 KEY(1, 0, KEY_RIGHT),
478 static struct matrix_keymap_data board_map_data = {
479 .keymap = board_keymap,
480 .keymap_size = ARRAY_SIZE(board_keymap),
483 static struct twl4030_keypad_data omap3evm_kp_data = {
484 .keymap_data = &board_map_data,
490 static struct twl4030_madc_platform_data omap3evm_madc_data = {
494 static struct twl4030_codec_audio_data omap3evm_audio_data = {
495 .audio_mclk = 26000000,
498 static struct twl4030_codec_data omap3evm_codec_data = {
499 .audio_mclk = 26000000,
500 .audio = &omap3evm_audio_data,
503 static struct regulator_consumer_supply omap3_evm_vdda_dac_supply =
504 REGULATOR_SUPPLY("vdda_dac", "omapdss");
506 /* VDAC for DSS driving S-Video */
507 static struct regulator_init_data omap3_evm_vdac = {
512 .valid_modes_mask = REGULATOR_MODE_NORMAL
513 | REGULATOR_MODE_STANDBY,
514 .valid_ops_mask = REGULATOR_CHANGE_MODE
515 | REGULATOR_CHANGE_STATUS,
517 .num_consumer_supplies = 1,
518 .consumer_supplies = &omap3_evm_vdda_dac_supply,
521 /* VPLL2 for digital video outputs */
522 static struct regulator_consumer_supply omap3_evm_vpll2_supply =
523 REGULATOR_SUPPLY("vdds_dsi", "omapdss");
525 static struct regulator_init_data omap3_evm_vpll2 = {
530 .valid_modes_mask = REGULATOR_MODE_NORMAL
531 | REGULATOR_MODE_STANDBY,
532 .valid_ops_mask = REGULATOR_CHANGE_MODE
533 | REGULATOR_CHANGE_STATUS,
535 .num_consumer_supplies = 1,
536 .consumer_supplies = &omap3_evm_vpll2_supply,
539 static struct twl4030_platform_data omap3evm_twldata = {
540 .irq_base = TWL4030_IRQ_BASE,
541 .irq_end = TWL4030_IRQ_END,
543 /* platform_data for children goes here */
544 .keypad = &omap3evm_kp_data,
545 .madc = &omap3evm_madc_data,
546 .usb = &omap3evm_usb_data,
547 .gpio = &omap3evm_gpio_data,
548 .codec = &omap3evm_codec_data,
549 .vdac = &omap3_evm_vdac,
550 .vpll2 = &omap3_evm_vpll2,
553 static struct i2c_board_info __initdata omap3evm_i2c_boardinfo[] = {
555 I2C_BOARD_INFO("twl4030", 0x48),
556 .flags = I2C_CLIENT_WAKE,
557 .irq = INT_34XX_SYS_NIRQ,
558 .platform_data = &omap3evm_twldata,
562 static int __init omap3_evm_i2c_init(void)
565 * REVISIT: These entries can be set in omap3evm_twl_data
566 * after a merge with MFD tree
568 omap3evm_twldata.vmmc1 = &omap3evm_vmmc1;
569 omap3evm_twldata.vsim = &omap3evm_vsim;
571 omap_register_i2c_bus(1, 2600, omap3evm_i2c_boardinfo,
572 ARRAY_SIZE(omap3evm_i2c_boardinfo));
573 omap_register_i2c_bus(2, 400, NULL, 0);
574 omap_register_i2c_bus(3, 400, NULL, 0);
578 static void ads7846_dev_init(void)
580 if (gpio_request(OMAP3_EVM_TS_GPIO, "ADS7846 pendown") < 0)
581 printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
583 gpio_direction_input(OMAP3_EVM_TS_GPIO);
584 gpio_set_debounce(OMAP3_EVM_TS_GPIO, 310);
587 static int ads7846_get_pendown_state(void)
589 return !gpio_get_value(OMAP3_EVM_TS_GPIO);
592 static struct ads7846_platform_data ads7846_config = {
600 .get_pendown_state = ads7846_get_pendown_state,
602 .settle_delay_usecs = 150,
606 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
608 .single_channel = 1, /* 0: slave, 1: master */
611 static struct spi_board_info omap3evm_spi_board_info[] = {
613 .modalias = "ads7846",
616 .max_speed_hz = 1500000,
617 .controller_data = &ads7846_mcspi_config,
618 .irq = OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO),
619 .platform_data = &ads7846_config,
623 static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
626 static void __init omap3_evm_init_early(void)
628 omap_board_config = omap3_evm_config;
629 omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
630 omap2_init_common_infrastructure();
631 omap2_init_common_devices(mt46h32m32lf6_sdrc_params, NULL);
634 static struct platform_device *omap3_evm_devices[] __initdata = {
635 &omap3_evm_dss_device,
638 static struct ehci_hcd_omap_platform_data ehci_pdata __initdata = {
640 .port_mode[0] = EHCI_HCD_OMAP_MODE_UNKNOWN,
641 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
642 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
645 /* PHY reset GPIO will be runtime programmed based on EVM version */
646 .reset_gpio_port[0] = -EINVAL,
647 .reset_gpio_port[1] = -EINVAL,
648 .reset_gpio_port[2] = -EINVAL
651 #ifdef CONFIG_OMAP_MUX
652 static struct omap_board_mux board_mux[] __initdata = {
653 OMAP3_MUX(SYS_NIRQ, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP |
654 OMAP_PIN_OFF_INPUT_PULLUP | OMAP_PIN_OFF_OUTPUT_LOW |
655 OMAP_PIN_OFF_WAKEUPENABLE),
656 OMAP3_MUX(MCSPI1_CS1, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP |
657 OMAP_PIN_OFF_INPUT_PULLUP | OMAP_PIN_OFF_OUTPUT_LOW),
658 { .reg_offset = OMAP_MUX_TERMINATOR },
662 static struct omap_musb_board_data musb_board_data = {
663 .interface_type = MUSB_INTERFACE_ULPI,
668 static void __init omap3_evm_init(void)
670 omap3_evm_get_revision();
671 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
673 omap3_evm_i2c_init();
675 platform_add_devices(omap3_evm_devices, ARRAY_SIZE(omap3_evm_devices));
677 spi_register_board_info(omap3evm_spi_board_info,
678 ARRAY_SIZE(omap3evm_spi_board_info));
682 /* OMAP3EVM uses ISP1504 phy and so register nop transceiver */
683 usb_nop_xceiv_register();
685 if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2) {
686 /* enable EHCI VBUS using GPIO22 */
687 omap_mux_init_gpio(22, OMAP_PIN_INPUT_PULLUP);
688 gpio_request(OMAP3_EVM_EHCI_VBUS, "enable EHCI VBUS");
689 gpio_direction_output(OMAP3_EVM_EHCI_VBUS, 0);
690 gpio_set_value(OMAP3_EVM_EHCI_VBUS, 1);
692 /* Select EHCI port on main board */
693 omap_mux_init_gpio(61, OMAP_PIN_INPUT_PULLUP);
694 gpio_request(OMAP3_EVM_EHCI_SELECT, "select EHCI port");
695 gpio_direction_output(OMAP3_EVM_EHCI_SELECT, 0);
696 gpio_set_value(OMAP3_EVM_EHCI_SELECT, 0);
698 /* setup EHCI phy reset config */
699 omap_mux_init_gpio(21, OMAP_PIN_INPUT_PULLUP);
700 ehci_pdata.reset_gpio_port[1] = 21;
702 /* EVM REV >= E can supply 500mA with EXTVBUS programming */
703 musb_board_data.power = 500;
704 musb_board_data.extvbus = 1;
706 /* setup EHCI phy reset on MDC */
707 omap_mux_init_gpio(135, OMAP_PIN_OUTPUT);
708 ehci_pdata.reset_gpio_port[1] = 135;
710 usb_musb_init(&musb_board_data);
711 usb_ehci_init(&ehci_pdata);
713 omap3evm_init_smsc911x();
714 omap3_evm_display_init();
717 MACHINE_START(OMAP3EVM, "OMAP3 EVM")
718 /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
719 .boot_params = 0x80000100,
720 .reserve = omap_reserve,
721 .map_io = omap3_map_io,
722 .init_early = omap3_evm_init_early,
723 .init_irq = omap_init_irq,
724 .init_machine = omap3_evm_init,
725 .timer = &omap_timer,