2 * linux/arch/arm/mach-omap2/board-omap3evm.c
4 * Copyright (C) 2008 Guangzhou EMA-Tech
6 * Modified from mach-omap2/board-omap3evm.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>
22 #include <linux/leds.h>
23 #include <linux/gpio.h>
24 #include <linux/input.h>
25 #include <linux/gpio_keys.h>
27 #include <linux/regulator/machine.h>
28 #include <linux/i2c/twl.h>
29 #include <linux/mmc/host.h>
31 #include <mach/hardware.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
35 #include <asm/mach/flash.h>
37 #include <plat/board.h>
38 #include <plat/common.h>
39 #include <plat/gpmc.h>
40 #include <plat/nand.h>
42 #include <plat/display.h>
43 #include <plat/panel-generic-dpi.h>
45 #include <plat/mcspi.h>
46 #include <linux/input/matrix_keypad.h>
47 #include <linux/spi/spi.h>
48 #include <linux/spi/ads7846.h>
49 #include <linux/interrupt.h>
50 #include <linux/smsc911x.h>
51 #include <linux/i2c/at24.h>
53 #include "sdram-micron-mt46h32m32lf-6.h"
58 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
59 #define OMAP3STALKER_ETHR_START 0x2c000000
60 #define OMAP3STALKER_ETHR_SIZE 1024
61 #define OMAP3STALKER_ETHR_GPIO_IRQ 19
62 #define OMAP3STALKER_SMC911X_CS 5
64 static struct resource omap3stalker_smsc911x_resources
[] = {
66 .start
= OMAP3STALKER_ETHR_START
,
68 (OMAP3STALKER_ETHR_START
+ OMAP3STALKER_ETHR_SIZE
- 1),
69 .flags
= IORESOURCE_MEM
,
72 .start
= OMAP_GPIO_IRQ(OMAP3STALKER_ETHR_GPIO_IRQ
),
73 .end
= OMAP_GPIO_IRQ(OMAP3STALKER_ETHR_GPIO_IRQ
),
74 .flags
= (IORESOURCE_IRQ
| IRQF_TRIGGER_LOW
),
78 static struct smsc911x_platform_config smsc911x_config
= {
79 .phy_interface
= PHY_INTERFACE_MODE_MII
,
80 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_LOW
,
81 .irq_type
= SMSC911X_IRQ_TYPE_OPEN_DRAIN
,
82 .flags
= (SMSC911X_USE_32BIT
| SMSC911X_SAVE_MAC_ADDRESS
),
85 static struct platform_device omap3stalker_smsc911x_device
= {
88 .num_resources
= ARRAY_SIZE(omap3stalker_smsc911x_resources
),
89 .resource
= &omap3stalker_smsc911x_resources
[0],
91 .platform_data
= &smsc911x_config
,
95 static inline void __init
omap3stalker_init_eth(void)
101 eth_cs
= OMAP3STALKER_SMC911X_CS
;
103 l3ck
= clk_get(NULL
, "l3_ck");
107 rate
= clk_get_rate(l3ck
);
109 omap_mux_init_gpio(19, OMAP_PIN_INPUT_PULLUP
);
110 if (gpio_request(OMAP3STALKER_ETHR_GPIO_IRQ
, "SMC911x irq") < 0) {
112 "Failed to request GPIO%d for smc911x IRQ\n",
113 OMAP3STALKER_ETHR_GPIO_IRQ
);
117 gpio_direction_input(OMAP3STALKER_ETHR_GPIO_IRQ
);
119 platform_device_register(&omap3stalker_smsc911x_device
);
123 static inline void __init
omap3stalker_init_eth(void)
130 * OMAP3 DSS control signals
133 #define DSS_ENABLE_GPIO 199
134 #define LCD_PANEL_BKLIGHT_GPIO 210
135 #define ENABLE_VPLL2_DEV_GRP 0xE0
137 static int lcd_enabled
;
138 static int dvi_enabled
;
140 static void __init
omap3_stalker_display_init(void)
145 static int omap3_stalker_enable_lcd(struct omap_dss_device
*dssdev
)
148 printk(KERN_ERR
"cannot enable LCD, DVI is enabled\n");
151 gpio_set_value(DSS_ENABLE_GPIO
, 1);
152 gpio_set_value(LCD_PANEL_BKLIGHT_GPIO
, 1);
157 static void omap3_stalker_disable_lcd(struct omap_dss_device
*dssdev
)
159 gpio_set_value(DSS_ENABLE_GPIO
, 0);
160 gpio_set_value(LCD_PANEL_BKLIGHT_GPIO
, 0);
164 static struct panel_generic_dpi_data lcd_panel
= {
166 .platform_enable
= omap3_stalker_enable_lcd
,
167 .platform_disable
= omap3_stalker_disable_lcd
,
170 static struct omap_dss_device omap3_stalker_lcd_device
= {
172 .driver_name
= "generic_dpi_panel",
174 .phy
.dpi
.data_lines
= 24,
175 .type
= OMAP_DISPLAY_TYPE_DPI
,
178 static int omap3_stalker_enable_tv(struct omap_dss_device
*dssdev
)
183 static void omap3_stalker_disable_tv(struct omap_dss_device
*dssdev
)
187 static struct omap_dss_device omap3_stalker_tv_device
= {
189 .driver_name
= "venc",
190 .type
= OMAP_DISPLAY_TYPE_VENC
,
191 #if defined(CONFIG_OMAP2_VENC_OUT_TYPE_SVIDEO)
192 .phy
.venc
.type
= OMAP_DSS_VENC_TYPE_SVIDEO
,
193 #elif defined(CONFIG_OMAP2_VENC_OUT_TYPE_COMPOSITE)
194 .u
.venc
.type
= OMAP_DSS_VENC_TYPE_COMPOSITE
,
196 .platform_enable
= omap3_stalker_enable_tv
,
197 .platform_disable
= omap3_stalker_disable_tv
,
200 static int omap3_stalker_enable_dvi(struct omap_dss_device
*dssdev
)
203 printk(KERN_ERR
"cannot enable DVI, LCD is enabled\n");
206 gpio_set_value(DSS_ENABLE_GPIO
, 1);
211 static void omap3_stalker_disable_dvi(struct omap_dss_device
*dssdev
)
213 gpio_set_value(DSS_ENABLE_GPIO
, 0);
217 static struct panel_generic_dpi_data dvi_panel
= {
219 .platform_enable
= omap3_stalker_enable_dvi
,
220 .platform_disable
= omap3_stalker_disable_dvi
,
223 static struct omap_dss_device omap3_stalker_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
*omap3_stalker_dss_devices
[] = {
232 &omap3_stalker_lcd_device
,
233 &omap3_stalker_tv_device
,
234 &omap3_stalker_dvi_device
,
237 static struct omap_dss_board_info omap3_stalker_dss_data
= {
238 .num_devices
= ARRAY_SIZE(omap3_stalker_dss_devices
),
239 .devices
= omap3_stalker_dss_devices
,
240 .default_device
= &omap3_stalker_dvi_device
,
243 static struct regulator_consumer_supply omap3stalker_vmmc1_supply
= {
247 static struct regulator_consumer_supply omap3stalker_vsim_supply
= {
248 .supply
= "vmmc_aux",
251 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
252 static struct regulator_init_data omap3stalker_vmmc1
= {
256 .valid_modes_mask
= REGULATOR_MODE_NORMAL
257 | REGULATOR_MODE_STANDBY
,
258 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
259 | REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS
,
261 .num_consumer_supplies
= 1,
262 .consumer_supplies
= &omap3stalker_vmmc1_supply
,
265 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
266 static struct regulator_init_data omap3stalker_vsim
= {
270 .valid_modes_mask
= REGULATOR_MODE_NORMAL
271 | REGULATOR_MODE_STANDBY
,
272 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
273 | REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS
,
275 .num_consumer_supplies
= 1,
276 .consumer_supplies
= &omap3stalker_vsim_supply
,
279 static struct omap2_hsmmc_info mmc
[] = {
282 .caps
= MMC_CAP_4_BIT_DATA
,
289 static struct gpio_keys_button gpio_buttons
[] = {
298 static struct gpio_keys_platform_data gpio_key_info
= {
299 .buttons
= gpio_buttons
,
300 .nbuttons
= ARRAY_SIZE(gpio_buttons
),
303 static struct platform_device keys_gpio
= {
307 .platform_data
= &gpio_key_info
,
311 static struct gpio_led gpio_leds
[] = {
313 .name
= "stalker:D8:usr0",
314 .default_trigger
= "default-on",
318 .name
= "stalker:D9:usr1",
319 .default_trigger
= "default-on",
323 .name
= "stalker:D3:mmc0",
324 .gpio
= -EINVAL
, /* gets replaced */
326 .default_trigger
= "mmc0",
329 .name
= "stalker:D4:heartbeat",
330 .gpio
= -EINVAL
, /* gets replaced */
332 .default_trigger
= "heartbeat",
336 static struct gpio_led_platform_data gpio_led_info
= {
338 .num_leds
= ARRAY_SIZE(gpio_leds
),
341 static struct platform_device leds_gpio
= {
345 .platform_data
= &gpio_led_info
,
350 omap3stalker_twl_gpio_setup(struct device
*dev
,
351 unsigned gpio
, unsigned ngpio
)
353 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
354 omap_mux_init_gpio(23, OMAP_PIN_INPUT
);
355 mmc
[0].gpio_cd
= gpio
+ 0;
356 omap2_hsmmc_init(mmc
);
358 /* link regulators to MMC adapters */
359 omap3stalker_vmmc1_supply
.dev
= mmc
[0].dev
;
360 omap3stalker_vsim_supply
.dev
= mmc
[0].dev
;
363 * Most GPIOs are for USB OTG. Some are mostly sent to
364 * the P2 connector; notably LEDA for the LCD backlight.
367 /* TWL4030_GPIO_MAX + 0 == ledA, LCD Backlight control */
368 gpio_request(gpio
+ TWL4030_GPIO_MAX
, "EN_LCD_BKL");
369 gpio_direction_output(gpio
+ TWL4030_GPIO_MAX
, 0);
371 /* gpio + 7 == DVI Enable */
372 gpio_request(gpio
+ 7, "EN_DVI");
373 gpio_direction_output(gpio
+ 7, 0);
375 /* TWL4030_GPIO_MAX + 1 == ledB (out, mmc0) */
376 gpio_leds
[2].gpio
= gpio
+ TWL4030_GPIO_MAX
+ 1;
377 /* GPIO + 13 == ledsync (out, heartbeat) */
378 gpio_leds
[3].gpio
= gpio
+ 13;
380 platform_device_register(&leds_gpio
);
384 static struct twl4030_gpio_platform_data omap3stalker_gpio_data
= {
385 .gpio_base
= OMAP_MAX_GPIO_LINES
,
386 .irq_base
= TWL4030_GPIO_IRQ_BASE
,
387 .irq_end
= TWL4030_GPIO_IRQ_END
,
389 .setup
= omap3stalker_twl_gpio_setup
,
392 static struct twl4030_usb_data omap3stalker_usb_data
= {
393 .usb_mode
= T2_USB_MODE_ULPI
,
396 static uint32_t board_keymap
[] = {
399 KEY(0, 2, KEY_ENTER
),
402 KEY(1, 0, KEY_RIGHT
),
418 static struct matrix_keymap_data board_map_data
= {
419 .keymap
= board_keymap
,
420 .keymap_size
= ARRAY_SIZE(board_keymap
),
423 static struct twl4030_keypad_data omap3stalker_kp_data
= {
424 .keymap_data
= &board_map_data
,
430 static struct twl4030_madc_platform_data omap3stalker_madc_data
= {
434 static struct twl4030_codec_audio_data omap3stalker_audio_data
;
436 static struct twl4030_codec_data omap3stalker_codec_data
= {
437 .audio_mclk
= 26000000,
438 .audio
= &omap3stalker_audio_data
,
441 static struct regulator_consumer_supply omap3_stalker_vdda_dac_supply
=
442 REGULATOR_SUPPLY("vdda_dac", "omapdss_venc");
444 /* VDAC for DSS driving S-Video */
445 static struct regulator_init_data omap3_stalker_vdac
= {
450 .valid_modes_mask
= REGULATOR_MODE_NORMAL
451 | REGULATOR_MODE_STANDBY
,
452 .valid_ops_mask
= REGULATOR_CHANGE_MODE
453 | REGULATOR_CHANGE_STATUS
,
455 .num_consumer_supplies
= 1,
456 .consumer_supplies
= &omap3_stalker_vdda_dac_supply
,
459 /* VPLL2 for digital video outputs */
460 static struct regulator_consumer_supply omap3_stalker_vpll2_supplies
[] = {
461 REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
462 REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi1"),
465 static struct regulator_init_data omap3_stalker_vpll2
= {
471 .valid_modes_mask
= REGULATOR_MODE_NORMAL
472 | REGULATOR_MODE_STANDBY
,
473 .valid_ops_mask
= REGULATOR_CHANGE_MODE
474 | REGULATOR_CHANGE_STATUS
,
476 .num_consumer_supplies
= ARRAY_SIZE(omap3_stalker_vpll2_supplies
),
477 .consumer_supplies
= omap3_stalker_vpll2_supplies
,
480 static struct twl4030_platform_data omap3stalker_twldata
= {
481 .irq_base
= TWL4030_IRQ_BASE
,
482 .irq_end
= TWL4030_IRQ_END
,
484 /* platform_data for children goes here */
485 .keypad
= &omap3stalker_kp_data
,
486 .madc
= &omap3stalker_madc_data
,
487 .usb
= &omap3stalker_usb_data
,
488 .gpio
= &omap3stalker_gpio_data
,
489 .codec
= &omap3stalker_codec_data
,
490 .vdac
= &omap3_stalker_vdac
,
491 .vpll2
= &omap3_stalker_vpll2
,
494 static struct i2c_board_info __initdata omap3stalker_i2c_boardinfo
[] = {
496 I2C_BOARD_INFO("twl4030", 0x48),
497 .flags
= I2C_CLIENT_WAKE
,
498 .irq
= INT_34XX_SYS_NIRQ
,
499 .platform_data
= &omap3stalker_twldata
,
503 static struct at24_platform_data fram_info
= {
504 .byte_len
= (64 * 1024) / 8,
506 .flags
= AT24_FLAG_ADDR16
| AT24_FLAG_IRUGO
,
509 static struct i2c_board_info __initdata omap3stalker_i2c_boardinfo3
[] = {
511 I2C_BOARD_INFO("24c64", 0x50),
512 .flags
= I2C_CLIENT_WAKE
,
513 .platform_data
= &fram_info
,
517 static int __init
omap3_stalker_i2c_init(void)
520 * REVISIT: These entries can be set in omap3evm_twl_data
521 * after a merge with MFD tree
523 omap3stalker_twldata
.vmmc1
= &omap3stalker_vmmc1
;
524 omap3stalker_twldata
.vsim
= &omap3stalker_vsim
;
526 omap_register_i2c_bus(1, 2600, omap3stalker_i2c_boardinfo
,
527 ARRAY_SIZE(omap3stalker_i2c_boardinfo
));
528 omap_register_i2c_bus(2, 400, NULL
, 0);
529 omap_register_i2c_bus(3, 400, omap3stalker_i2c_boardinfo3
,
530 ARRAY_SIZE(omap3stalker_i2c_boardinfo3
));
534 #define OMAP3_STALKER_TS_GPIO 175
535 static void ads7846_dev_init(void)
537 if (gpio_request(OMAP3_STALKER_TS_GPIO
, "ADS7846 pendown") < 0)
538 printk(KERN_ERR
"can't get ads7846 pen down GPIO\n");
540 gpio_direction_input(OMAP3_STALKER_TS_GPIO
);
541 gpio_set_debounce(OMAP3_STALKER_TS_GPIO
, 310);
544 static int ads7846_get_pendown_state(void)
546 return !gpio_get_value(OMAP3_STALKER_TS_GPIO
);
549 static struct ads7846_platform_data ads7846_config
= {
557 .get_pendown_state
= ads7846_get_pendown_state
,
559 .settle_delay_usecs
= 150,
562 static struct omap2_mcspi_device_config ads7846_mcspi_config
= {
564 .single_channel
= 1, /* 0: slave, 1: master */
567 static struct spi_board_info omap3stalker_spi_board_info
[] = {
569 .modalias
= "ads7846",
572 .max_speed_hz
= 1500000,
573 .controller_data
= &ads7846_mcspi_config
,
574 .irq
= OMAP_GPIO_IRQ(OMAP3_STALKER_TS_GPIO
),
575 .platform_data
= &ads7846_config
,
579 static struct omap_board_config_kernel omap3_stalker_config
[] __initdata
= {
582 static void __init
omap3_stalker_init_early(void)
584 omap2_init_common_infrastructure();
585 omap2_init_common_devices(mt46h32m32lf6_sdrc_params
, NULL
);
588 static void __init
omap3_stalker_init_irq(void)
591 #ifdef CONFIG_OMAP_32K_TIMER
592 omap2_gp_clockevent_set_gptimer(12);
596 static struct platform_device
*omap3_stalker_devices
[] __initdata
= {
600 static struct usbhs_omap_board_data usbhs_bdata __initconst
= {
601 .port_mode
[0] = OMAP_USBHS_PORT_MODE_UNUSED
,
602 .port_mode
[1] = OMAP_EHCI_PORT_MODE_PHY
,
603 .port_mode
[2] = OMAP_USBHS_PORT_MODE_UNUSED
,
606 .reset_gpio_port
[0] = -EINVAL
,
607 .reset_gpio_port
[1] = 21,
608 .reset_gpio_port
[2] = -EINVAL
,
611 #ifdef CONFIG_OMAP_MUX
612 static struct omap_board_mux board_mux
[] __initdata
= {
613 OMAP3_MUX(SYS_NIRQ
, OMAP_MUX_MODE0
| OMAP_PIN_INPUT_PULLUP
|
614 OMAP_PIN_OFF_INPUT_PULLUP
| OMAP_PIN_OFF_WAKEUPENABLE
),
615 OMAP3_MUX(MCSPI1_CS1
, OMAP_MUX_MODE4
| OMAP_PIN_INPUT_PULLUP
|
616 OMAP_PIN_OFF_INPUT_PULLUP
| OMAP_PIN_OFF_WAKEUPENABLE
),
617 {.reg_offset
= OMAP_MUX_TERMINATOR
},
621 static struct omap_musb_board_data musb_board_data
= {
622 .interface_type
= MUSB_INTERFACE_ULPI
,
627 static void __init
omap3_stalker_init(void)
629 omap3_mux_init(board_mux
, OMAP_PACKAGE_CUS
);
630 omap_board_config
= omap3_stalker_config
;
631 omap_board_config_size
= ARRAY_SIZE(omap3_stalker_config
);
633 omap3_stalker_i2c_init();
635 platform_add_devices(omap3_stalker_devices
,
636 ARRAY_SIZE(omap3_stalker_devices
));
638 omap_display_init(&omap3_stalker_dss_data
);
639 spi_register_board_info(omap3stalker_spi_board_info
,
640 ARRAY_SIZE(omap3stalker_spi_board_info
));
643 usb_musb_init(&musb_board_data
);
644 usbhs_init(&usbhs_bdata
);
647 omap_mux_init_gpio(21, OMAP_PIN_OUTPUT
);
648 omap_mux_init_gpio(18, OMAP_PIN_INPUT_PULLUP
);
650 omap3stalker_init_eth();
651 omap3_stalker_display_init();
652 /* Ensure SDRC pins are mux'd for self-refresh */
653 omap_mux_init_signal("sdr_cke0", OMAP_PIN_OUTPUT
);
654 omap_mux_init_signal("sdr_cke1", OMAP_PIN_OUTPUT
);
657 MACHINE_START(SBC3530
, "OMAP3 STALKER")
658 /* Maintainer: Jason Lam -lzg@ema-tech.com */
659 .boot_params
= 0x80000100,
660 .map_io
= omap3_map_io
,
661 .init_early
= omap3_stalker_init_early
,
662 .init_irq
= omap3_stalker_init_irq
,
663 .init_machine
= omap3_stalker_init
,
664 .timer
= &omap_timer
,