OMAP3 SRF: Fix crash on non-3430SDP platforms with DVFS/CPUFreq
[linux-ginger.git] / arch / arm / mach-omap2 / board-omap3evm.c
blob756ee5f4211a97fc84f7e17f2985c15595dd0ec4
1 /*
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>
26 #include <linux/spi/spi.h>
27 #include <linux/spi/ads7846.h>
28 #include <linux/i2c/twl4030.h>
29 #include <linux/usb/otg.h>
31 #include <linux/regulator/machine.h>
33 #include <mach/hardware.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
38 #include <plat/board.h>
39 #include <plat/mux.h>
40 #include <plat/usb.h>
41 #include <plat/common.h>
42 #include <plat/mcspi.h>
44 #include "sdram-micron-mt46h32m32lf-6.h"
45 #include "mmc-twl4030.h"
47 #define OMAP3_EVM_TS_GPIO 175
49 #define OMAP3EVM_ETHR_START 0x2c000000
50 #define OMAP3EVM_ETHR_SIZE 1024
51 #define OMAP3EVM_ETHR_GPIO_IRQ 176
52 #define OMAP3EVM_SMC911X_CS 5
54 static struct resource omap3evm_smc911x_resources[] = {
55 [0] = {
56 .start = OMAP3EVM_ETHR_START,
57 .end = (OMAP3EVM_ETHR_START + OMAP3EVM_ETHR_SIZE - 1),
58 .flags = IORESOURCE_MEM,
60 [1] = {
61 .start = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
62 .end = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
63 .flags = IORESOURCE_IRQ,
67 static struct platform_device omap3evm_smc911x_device = {
68 .name = "smc911x",
69 .id = -1,
70 .num_resources = ARRAY_SIZE(omap3evm_smc911x_resources),
71 .resource = &omap3evm_smc911x_resources[0],
74 static inline void __init omap3evm_init_smc911x(void)
76 int eth_cs;
77 struct clk *l3ck;
78 unsigned int rate;
80 eth_cs = OMAP3EVM_SMC911X_CS;
82 l3ck = clk_get(NULL, "l3_ck");
83 if (IS_ERR(l3ck))
84 rate = 100000000;
85 else
86 rate = clk_get_rate(l3ck);
88 if (gpio_request(OMAP3EVM_ETHR_GPIO_IRQ, "SMC911x irq") < 0) {
89 printk(KERN_ERR "Failed to request GPIO%d for smc911x IRQ\n",
90 OMAP3EVM_ETHR_GPIO_IRQ);
91 return;
94 gpio_direction_input(OMAP3EVM_ETHR_GPIO_IRQ);
97 static struct regulator_consumer_supply omap3evm_vmmc1_supply = {
98 .supply = "vmmc",
101 static struct regulator_consumer_supply omap3evm_vsim_supply = {
102 .supply = "vmmc_aux",
105 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
106 static struct regulator_init_data omap3evm_vmmc1 = {
107 .constraints = {
108 .min_uV = 1850000,
109 .max_uV = 3150000,
110 .valid_modes_mask = REGULATOR_MODE_NORMAL
111 | REGULATOR_MODE_STANDBY,
112 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
113 | REGULATOR_CHANGE_MODE
114 | REGULATOR_CHANGE_STATUS,
116 .num_consumer_supplies = 1,
117 .consumer_supplies = &omap3evm_vmmc1_supply,
120 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
121 static struct regulator_init_data omap3evm_vsim = {
122 .constraints = {
123 .min_uV = 1800000,
124 .max_uV = 3000000,
125 .valid_modes_mask = REGULATOR_MODE_NORMAL
126 | REGULATOR_MODE_STANDBY,
127 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
128 | REGULATOR_CHANGE_MODE
129 | REGULATOR_CHANGE_STATUS,
131 .num_consumer_supplies = 1,
132 .consumer_supplies = &omap3evm_vsim_supply,
135 static struct twl4030_hsmmc_info mmc[] = {
137 .mmc = 1,
138 .wires = 4,
139 .gpio_cd = -EINVAL,
140 .gpio_wp = 63,
142 {} /* Terminator */
145 static struct gpio_led gpio_leds[] = {
147 .name = "omap3evm::ledb",
148 /* normally not visible (board underside) */
149 .default_trigger = "default-on",
150 .gpio = -EINVAL, /* gets replaced */
151 .active_low = true,
155 static struct gpio_led_platform_data gpio_led_info = {
156 .leds = gpio_leds,
157 .num_leds = ARRAY_SIZE(gpio_leds),
160 static struct platform_device leds_gpio = {
161 .name = "leds-gpio",
162 .id = -1,
163 .dev = {
164 .platform_data = &gpio_led_info,
169 static int omap3evm_twl_gpio_setup(struct device *dev,
170 unsigned gpio, unsigned ngpio)
172 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
173 omap_cfg_reg(L8_34XX_GPIO63);
174 mmc[0].gpio_cd = gpio + 0;
175 twl4030_mmc_init(mmc);
177 /* link regulators to MMC adapters */
178 omap3evm_vmmc1_supply.dev = mmc[0].dev;
179 omap3evm_vsim_supply.dev = mmc[0].dev;
182 * Most GPIOs are for USB OTG. Some are mostly sent to
183 * the P2 connector; notably LEDA for the LCD backlight.
186 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
187 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
189 platform_device_register(&leds_gpio);
191 return 0;
194 static struct twl4030_gpio_platform_data omap3evm_gpio_data = {
195 .gpio_base = OMAP_MAX_GPIO_LINES,
196 .irq_base = TWL4030_GPIO_IRQ_BASE,
197 .irq_end = TWL4030_GPIO_IRQ_END,
198 .use_leds = true,
199 .setup = omap3evm_twl_gpio_setup,
202 static struct twl4030_usb_data omap3evm_usb_data = {
203 .usb_mode = T2_USB_MODE_ULPI,
206 static int board_keymap[] = {
207 KEY(0, 0, KEY_LEFT),
208 KEY(0, 1, KEY_RIGHT),
209 KEY(0, 2, KEY_A),
210 KEY(0, 3, KEY_B),
211 KEY(1, 0, KEY_DOWN),
212 KEY(1, 1, KEY_UP),
213 KEY(1, 2, KEY_E),
214 KEY(1, 3, KEY_F),
215 KEY(2, 0, KEY_ENTER),
216 KEY(2, 1, KEY_I),
217 KEY(2, 2, KEY_J),
218 KEY(2, 3, KEY_K),
219 KEY(3, 0, KEY_M),
220 KEY(3, 1, KEY_N),
221 KEY(3, 2, KEY_O),
222 KEY(3, 3, KEY_P)
225 static struct matrix_keymap_data board_map_data = {
226 .keymap = board_keymap,
227 .keymap_size = ARRAY_SIZE(board_keymap),
230 static struct twl4030_keypad_data omap3evm_kp_data = {
231 .keymap_data = &board_map_data,
232 .rows = 4,
233 .cols = 4,
234 .rep = 1,
237 static struct twl4030_madc_platform_data omap3evm_madc_data = {
238 .irq_line = 1,
241 static struct twl4030_platform_data omap3evm_twldata = {
242 .irq_base = TWL4030_IRQ_BASE,
243 .irq_end = TWL4030_IRQ_END,
245 /* platform_data for children goes here */
246 .keypad = &omap3evm_kp_data,
247 .madc = &omap3evm_madc_data,
248 .usb = &omap3evm_usb_data,
249 .gpio = &omap3evm_gpio_data,
250 .vmmc1 = &omap3evm_vmmc1,
251 .vsim = &omap3evm_vsim,
254 static struct i2c_board_info __initdata omap3evm_i2c_boardinfo[] = {
256 I2C_BOARD_INFO("twl4030", 0x48),
257 .flags = I2C_CLIENT_WAKE,
258 .irq = INT_34XX_SYS_NIRQ,
259 .platform_data = &omap3evm_twldata,
263 static int __init omap3_evm_i2c_init(void)
265 omap_register_i2c_bus(1, 2600, omap3evm_i2c_boardinfo,
266 ARRAY_SIZE(omap3evm_i2c_boardinfo));
267 omap_register_i2c_bus(2, 400, NULL, 0);
268 omap_register_i2c_bus(3, 400, NULL, 0);
269 return 0;
272 static struct platform_device omap3_evm_lcd_device = {
273 .name = "omap3evm_lcd",
274 .id = -1,
277 static struct omap_lcd_config omap3_evm_lcd_config __initdata = {
278 .ctrl_name = "internal",
281 static void ads7846_dev_init(void)
283 if (gpio_request(OMAP3_EVM_TS_GPIO, "ADS7846 pendown") < 0)
284 printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
286 gpio_direction_input(OMAP3_EVM_TS_GPIO);
288 omap_set_gpio_debounce(OMAP3_EVM_TS_GPIO, 1);
289 omap_set_gpio_debounce_time(OMAP3_EVM_TS_GPIO, 0xa);
292 static int ads7846_get_pendown_state(void)
294 return !gpio_get_value(OMAP3_EVM_TS_GPIO);
297 struct ads7846_platform_data ads7846_config = {
298 .x_max = 0x0fff,
299 .y_max = 0x0fff,
300 .x_plate_ohms = 180,
301 .pressure_max = 255,
302 .debounce_max = 10,
303 .debounce_tol = 3,
304 .debounce_rep = 1,
305 .get_pendown_state = ads7846_get_pendown_state,
306 .keep_vref_on = 1,
307 .settle_delay_usecs = 150,
310 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
311 .turbo_mode = 0,
312 .single_channel = 1, /* 0: slave, 1: master */
315 struct spi_board_info omap3evm_spi_board_info[] = {
316 [0] = {
317 .modalias = "ads7846",
318 .bus_num = 1,
319 .chip_select = 0,
320 .max_speed_hz = 1500000,
321 .controller_data = &ads7846_mcspi_config,
322 .irq = OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO),
323 .platform_data = &ads7846_config,
327 static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
328 { OMAP_TAG_LCD, &omap3_evm_lcd_config },
331 static void __init omap3_evm_init_irq(void)
333 omap_board_config = omap3_evm_config;
334 omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
335 omap2_init_common_hw(mt46h32m32lf6_sdrc_params, NULL, NULL, NULL, NULL);
336 omap_init_irq();
337 omap_gpio_init();
338 omap3evm_init_smc911x();
341 static struct platform_device *omap3_evm_devices[] __initdata = {
342 &omap3_evm_lcd_device,
343 &omap3evm_smc911x_device,
346 static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
348 .port_mode[0] = EHCI_HCD_OMAP_MODE_UNKNOWN,
349 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
350 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
352 .phy_reset = true,
353 .reset_gpio_port[0] = -EINVAL,
354 .reset_gpio_port[1] = 135,
355 .reset_gpio_port[2] = -EINVAL
358 static void __init omap3_evm_init(void)
360 omap3_evm_i2c_init();
362 platform_add_devices(omap3_evm_devices, ARRAY_SIZE(omap3_evm_devices));
364 spi_register_board_info(omap3evm_spi_board_info,
365 ARRAY_SIZE(omap3evm_spi_board_info));
367 omap_serial_init();
368 #ifdef CONFIG_NOP_USB_XCEIV
369 /* OMAP3EVM uses ISP1504 phy and so register nop transceiver */
370 usb_nop_xceiv_register();
371 #endif
372 usb_musb_init();
373 /* Setup EHCI phy reset padconfig */
374 omap_cfg_reg(AF4_34XX_GPIO135_OUT);
375 usb_ehci_init(&ehci_pdata);
376 ads7846_dev_init();
379 static void __init omap3_evm_map_io(void)
381 omap2_set_globals_343x();
382 omap2_map_common_io();
385 MACHINE_START(OMAP3EVM, "OMAP3 EVM")
386 /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
387 .phys_io = 0x48000000,
388 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
389 .boot_params = 0x80000100,
390 .map_io = omap3_evm_map_io,
391 .init_irq = omap3_evm_init_irq,
392 .init_machine = omap3_evm_init,
393 .timer = &omap_timer,
394 MACHINE_END