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>
46 #include "sdram-micron-mt46h32m32lf-6.h"
47 #include "mmc-twl4030.h"
49 #define OMAP3_EVM_TS_GPIO 175
50 #define OMAP3_EVM_EHCI_VBUS 22
51 #define OMAP3_EVM_EHCI_SELECT 61
53 #define OMAP3EVM_ETHR_START 0x2c000000
54 #define OMAP3EVM_ETHR_SIZE 1024
55 #define OMAP3EVM_ETHR_ID_REV 0x50
56 #define OMAP3EVM_ETHR_GPIO_IRQ 176
57 #define OMAP3EVM_SMSC911X_CS 5
59 static u8 omap3_evm_version
;
61 u8
get_omap3_evm_rev(void)
63 return omap3_evm_version
;
65 EXPORT_SYMBOL(get_omap3_evm_rev
);
67 static void __init
omap3_evm_get_revision(void)
72 /* Ethernet PHY ID is stored at ID_REV register */
73 ioaddr
= ioremap_nocache(OMAP3EVM_ETHR_START
, SZ_1K
);
76 smsc_id
= readl(ioaddr
+ OMAP3EVM_ETHR_ID_REV
) & 0xFFFF0000;
82 omap3_evm_version
= OMAP3EVM_BOARD_GEN_1
;
87 omap3_evm_version
= OMAP3EVM_BOARD_GEN_2
;
91 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
92 static struct resource omap3evm_smsc911x_resources
[] = {
94 .start
= OMAP3EVM_ETHR_START
,
95 .end
= (OMAP3EVM_ETHR_START
+ OMAP3EVM_ETHR_SIZE
- 1),
96 .flags
= IORESOURCE_MEM
,
99 .start
= OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ
),
100 .end
= OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ
),
101 .flags
= (IORESOURCE_IRQ
| IRQF_TRIGGER_LOW
),
105 static struct smsc911x_platform_config smsc911x_config
= {
106 .phy_interface
= PHY_INTERFACE_MODE_MII
,
107 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_LOW
,
108 .irq_type
= SMSC911X_IRQ_TYPE_OPEN_DRAIN
,
109 .flags
= (SMSC911X_USE_32BIT
| SMSC911X_SAVE_MAC_ADDRESS
),
112 static struct platform_device omap3evm_smsc911x_device
= {
115 .num_resources
= ARRAY_SIZE(omap3evm_smsc911x_resources
),
116 .resource
= &omap3evm_smsc911x_resources
[0],
118 .platform_data
= &smsc911x_config
,
122 static inline void __init
omap3evm_init_smsc911x(void)
128 eth_cs
= OMAP3EVM_SMSC911X_CS
;
130 l3ck
= clk_get(NULL
, "l3_ck");
134 rate
= clk_get_rate(l3ck
);
136 if (gpio_request(OMAP3EVM_ETHR_GPIO_IRQ
, "SMSC911x irq") < 0) {
137 printk(KERN_ERR
"Failed to request GPIO%d for smsc911x IRQ\n",
138 OMAP3EVM_ETHR_GPIO_IRQ
);
142 gpio_direction_input(OMAP3EVM_ETHR_GPIO_IRQ
);
143 platform_device_register(&omap3evm_smsc911x_device
);
147 static inline void __init
omap3evm_init_smsc911x(void) { return; }
150 static struct regulator_consumer_supply omap3evm_vmmc1_supply
= {
154 static struct regulator_consumer_supply omap3evm_vsim_supply
= {
155 .supply
= "vmmc_aux",
158 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
159 static struct regulator_init_data omap3evm_vmmc1
= {
163 .valid_modes_mask
= REGULATOR_MODE_NORMAL
164 | REGULATOR_MODE_STANDBY
,
165 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
166 | REGULATOR_CHANGE_MODE
167 | REGULATOR_CHANGE_STATUS
,
169 .num_consumer_supplies
= 1,
170 .consumer_supplies
= &omap3evm_vmmc1_supply
,
173 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
174 static struct regulator_init_data omap3evm_vsim
= {
178 .valid_modes_mask
= REGULATOR_MODE_NORMAL
179 | REGULATOR_MODE_STANDBY
,
180 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
181 | REGULATOR_CHANGE_MODE
182 | REGULATOR_CHANGE_STATUS
,
184 .num_consumer_supplies
= 1,
185 .consumer_supplies
= &omap3evm_vsim_supply
,
188 static struct twl4030_hsmmc_info mmc
[] = {
198 static struct gpio_led gpio_leds
[] = {
200 .name
= "omap3evm::ledb",
201 /* normally not visible (board underside) */
202 .default_trigger
= "default-on",
203 .gpio
= -EINVAL
, /* gets replaced */
208 static struct gpio_led_platform_data gpio_led_info
= {
210 .num_leds
= ARRAY_SIZE(gpio_leds
),
213 static struct platform_device leds_gpio
= {
217 .platform_data
= &gpio_led_info
,
222 static int omap3evm_twl_gpio_setup(struct device
*dev
,
223 unsigned gpio
, unsigned ngpio
)
225 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
226 omap_mux_init_gpio(63, OMAP_PIN_INPUT
);
227 mmc
[0].gpio_cd
= gpio
+ 0;
228 twl4030_mmc_init(mmc
);
230 /* link regulators to MMC adapters */
231 omap3evm_vmmc1_supply
.dev
= mmc
[0].dev
;
232 omap3evm_vsim_supply
.dev
= mmc
[0].dev
;
235 * Most GPIOs are for USB OTG. Some are mostly sent to
236 * the P2 connector; notably LEDA for the LCD backlight.
239 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
240 gpio_leds
[2].gpio
= gpio
+ TWL4030_GPIO_MAX
+ 1;
242 platform_device_register(&leds_gpio
);
247 static struct twl4030_gpio_platform_data omap3evm_gpio_data
= {
248 .gpio_base
= OMAP_MAX_GPIO_LINES
,
249 .irq_base
= TWL4030_GPIO_IRQ_BASE
,
250 .irq_end
= TWL4030_GPIO_IRQ_END
,
252 .setup
= omap3evm_twl_gpio_setup
,
255 static struct twl4030_usb_data omap3evm_usb_data
= {
256 .usb_mode
= T2_USB_MODE_ULPI
,
259 static int board_keymap
[] = {
261 KEY(0, 1, KEY_RIGHT
),
268 KEY(2, 0, KEY_ENTER
),
278 static struct matrix_keymap_data board_map_data
= {
279 .keymap
= board_keymap
,
280 .keymap_size
= ARRAY_SIZE(board_keymap
),
283 static struct twl4030_keypad_data omap3evm_kp_data
= {
284 .keymap_data
= &board_map_data
,
290 static struct twl4030_madc_platform_data omap3evm_madc_data
= {
294 static struct twl4030_codec_audio_data omap3evm_audio_data
= {
295 .audio_mclk
= 26000000,
298 static struct twl4030_codec_data omap3evm_codec_data
= {
299 .audio_mclk
= 26000000,
300 .audio
= &omap3evm_audio_data
,
303 static struct twl4030_platform_data omap3evm_twldata
= {
304 .irq_base
= TWL4030_IRQ_BASE
,
305 .irq_end
= TWL4030_IRQ_END
,
307 /* platform_data for children goes here */
308 .keypad
= &omap3evm_kp_data
,
309 .madc
= &omap3evm_madc_data
,
310 .usb
= &omap3evm_usb_data
,
311 .gpio
= &omap3evm_gpio_data
,
312 .codec
= &omap3evm_codec_data
,
315 static struct i2c_board_info __initdata omap3evm_i2c_boardinfo
[] = {
317 I2C_BOARD_INFO("twl4030", 0x48),
318 .flags
= I2C_CLIENT_WAKE
,
319 .irq
= INT_34XX_SYS_NIRQ
,
320 .platform_data
= &omap3evm_twldata
,
324 static int __init
omap3_evm_i2c_init(void)
327 * REVISIT: These entries can be set in omap3evm_twl_data
328 * after a merge with MFD tree
330 omap3evm_twldata
.vmmc1
= &omap3evm_vmmc1
;
331 omap3evm_twldata
.vsim
= &omap3evm_vsim
;
333 omap_register_i2c_bus(1, 2600, omap3evm_i2c_boardinfo
,
334 ARRAY_SIZE(omap3evm_i2c_boardinfo
));
335 omap_register_i2c_bus(2, 400, NULL
, 0);
336 omap_register_i2c_bus(3, 400, NULL
, 0);
340 static struct platform_device omap3_evm_lcd_device
= {
341 .name
= "omap3evm_lcd",
345 static struct omap_lcd_config omap3_evm_lcd_config __initdata
= {
346 .ctrl_name
= "internal",
349 static void ads7846_dev_init(void)
351 if (gpio_request(OMAP3_EVM_TS_GPIO
, "ADS7846 pendown") < 0)
352 printk(KERN_ERR
"can't get ads7846 pen down GPIO\n");
354 gpio_direction_input(OMAP3_EVM_TS_GPIO
);
356 omap_set_gpio_debounce(OMAP3_EVM_TS_GPIO
, 1);
357 omap_set_gpio_debounce_time(OMAP3_EVM_TS_GPIO
, 0xa);
360 static int ads7846_get_pendown_state(void)
362 return !gpio_get_value(OMAP3_EVM_TS_GPIO
);
365 struct ads7846_platform_data ads7846_config
= {
373 .get_pendown_state
= ads7846_get_pendown_state
,
375 .settle_delay_usecs
= 150,
378 static struct omap2_mcspi_device_config ads7846_mcspi_config
= {
380 .single_channel
= 1, /* 0: slave, 1: master */
383 struct spi_board_info omap3evm_spi_board_info
[] = {
385 .modalias
= "ads7846",
388 .max_speed_hz
= 1500000,
389 .controller_data
= &ads7846_mcspi_config
,
390 .irq
= OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO
),
391 .platform_data
= &ads7846_config
,
395 static struct omap_board_config_kernel omap3_evm_config
[] __initdata
= {
396 { OMAP_TAG_LCD
, &omap3_evm_lcd_config
},
399 static void __init
omap3_evm_init_irq(void)
401 omap_board_config
= omap3_evm_config
;
402 omap_board_config_size
= ARRAY_SIZE(omap3_evm_config
);
403 omap2_init_common_hw(mt46h32m32lf6_sdrc_params
, NULL
);
408 static struct platform_device
*omap3_evm_devices
[] __initdata
= {
409 &omap3_evm_lcd_device
,
412 static struct ehci_hcd_omap_platform_data ehci_pdata __initconst
= {
414 .port_mode
[0] = EHCI_HCD_OMAP_MODE_UNKNOWN
,
415 .port_mode
[1] = EHCI_HCD_OMAP_MODE_PHY
,
416 .port_mode
[2] = EHCI_HCD_OMAP_MODE_UNKNOWN
,
419 /* PHY reset GPIO will be runtime programmed based on EVM version */
420 .reset_gpio_port
[0] = -EINVAL
,
421 .reset_gpio_port
[1] = -EINVAL
,
422 .reset_gpio_port
[2] = -EINVAL
425 #ifdef CONFIG_OMAP_MUX
426 static struct omap_board_mux board_mux
[] __initdata
= {
427 { .reg_offset
= OMAP_MUX_TERMINATOR
},
430 #define board_mux NULL
433 static void __init
omap3_evm_init(void)
435 omap3_evm_get_revision();
436 omap3_mux_init(board_mux
, OMAP_PACKAGE_CBB
);
438 omap3_evm_i2c_init();
440 platform_add_devices(omap3_evm_devices
, ARRAY_SIZE(omap3_evm_devices
));
442 spi_register_board_info(omap3evm_spi_board_info
,
443 ARRAY_SIZE(omap3evm_spi_board_info
));
446 #ifdef CONFIG_NOP_USB_XCEIV
447 /* OMAP3EVM uses ISP1504 phy and so register nop transceiver */
448 usb_nop_xceiv_register();
450 if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2
) {
451 /* enable EHCI VBUS using GPIO22 */
452 omap_mux_init_gpio(22, OMAP_PIN_INPUT_PULLUP
);
453 gpio_request(OMAP3_EVM_EHCI_VBUS
, "enable EHCI VBUS");
454 gpio_direction_output(OMAP3_EVM_EHCI_VBUS
, 0);
455 gpio_set_value(OMAP3_EVM_EHCI_VBUS
, 1);
457 /* Select EHCI port on main board */
458 omap_mux_init_gpio(61, OMAP_PIN_INPUT_PULLUP
);
459 gpio_request(OMAP3_EVM_EHCI_SELECT
, "select EHCI port");
460 gpio_direction_output(OMAP3_EVM_EHCI_SELECT
, 0);
461 gpio_set_value(OMAP3_EVM_EHCI_SELECT
, 0);
463 /* setup EHCI phy reset config */
464 omap_mux_init_gpio(21, OMAP_PIN_INPUT_PULLUP
);
465 ehci_pdata
.reset_gpio_port
[1] = 21;
468 /* setup EHCI phy reset on MDC */
469 omap_mux_init_gpio(135, OMAP_PIN_OUTPUT
);
470 ehci_pdata
.reset_gpio_port
[1] = 135;
473 usb_ehci_init(&ehci_pdata
);
475 omap3evm_init_smsc911x();
478 static void __init
omap3_evm_map_io(void)
480 omap2_set_globals_343x();
481 omap2_map_common_io();
484 MACHINE_START(OMAP3EVM
, "OMAP3 EVM")
485 /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
486 .phys_io
= 0x48000000,
487 .io_pg_offst
= ((0xfa000000) >> 18) & 0xfffc,
488 .boot_params
= 0x80000100,
489 .map_io
= omap3_evm_map_io
,
490 .init_irq
= omap3_evm_init_irq
,
491 .init_machine
= omap3_evm_init
,
492 .timer
= &omap_timer
,