OMAP3: SR: Reset voltage level on SR disable
[linux-ginger.git] / arch / arm / mach-omap2 / board-3430sdp.c
blob710b258610612b8bf571f109946997983a505a9c
1 /*
2 * linux/arch/arm/mach-omap2/board-3430sdp.c
4 * Copyright (C) 2007 Texas Instruments
6 * Modified from mach-omap2/board-generic.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/input.h>
20 #include <linux/input/matrix_keypad.h>
21 #include <linux/spi/spi.h>
22 #include <linux/spi/ads7846.h>
23 #include <linux/i2c/twl4030.h>
24 #include <linux/regulator/machine.h>
25 #include <linux/io.h>
26 #include <linux/gpio.h>
28 #include <mach/hardware.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
33 #include <plat/mcspi.h>
34 #include <plat/mux.h>
35 #include <plat/board.h>
36 #include <plat/usb.h>
37 #include <plat/common.h>
38 #include <plat/dma.h>
39 #include <plat/gpmc.h>
41 #include <plat/control.h>
42 #include <plat/gpmc-smc91x.h>
44 #include "sdram-qimonda-hyb18m512160af-6.h"
45 #include "mmc-twl4030.h"
47 #define SDP3430_TS_GPIO_IRQ_SDPV1 3
48 #define SDP3430_TS_GPIO_IRQ_SDPV2 2
50 #define ENABLE_VAUX3_DEDICATED 0x03
51 #define ENABLE_VAUX3_DEV_GRP 0x20
53 #define TWL4030_MSECURE_GPIO 22
55 static int board_keymap[] = {
56 KEY(0, 0, KEY_LEFT),
57 KEY(0, 1, KEY_RIGHT),
58 KEY(0, 2, KEY_A),
59 KEY(0, 3, KEY_B),
60 KEY(0, 4, KEY_C),
61 KEY(1, 0, KEY_DOWN),
62 KEY(1, 1, KEY_UP),
63 KEY(1, 2, KEY_E),
64 KEY(1, 3, KEY_F),
65 KEY(1, 4, KEY_G),
66 KEY(2, 0, KEY_ENTER),
67 KEY(2, 1, KEY_I),
68 KEY(2, 2, KEY_J),
69 KEY(2, 3, KEY_K),
70 KEY(2, 4, KEY_3),
71 KEY(3, 0, KEY_M),
72 KEY(3, 1, KEY_N),
73 KEY(3, 2, KEY_O),
74 KEY(3, 3, KEY_P),
75 KEY(3, 4, KEY_Q),
76 KEY(4, 0, KEY_R),
77 KEY(4, 1, KEY_4),
78 KEY(4, 2, KEY_T),
79 KEY(4, 3, KEY_U),
80 KEY(4, 4, KEY_D),
81 KEY(5, 0, KEY_V),
82 KEY(5, 1, KEY_W),
83 KEY(5, 2, KEY_L),
84 KEY(5, 3, KEY_S),
85 KEY(5, 4, KEY_H),
89 static struct matrix_keymap_data board_map_data = {
90 .keymap = board_keymap,
91 .keymap_size = ARRAY_SIZE(board_keymap),
94 static struct twl4030_keypad_data sdp3430_kp_data = {
95 .keymap_data = &board_map_data,
96 .rows = 5,
97 .cols = 6,
98 .rep = 1,
101 static int ts_gpio; /* Needed for ads7846_get_pendown_state */
104 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
106 * @return - void. If request gpio fails then Flag KERN_ERR.
108 static void ads7846_dev_init(void)
110 if (gpio_request(ts_gpio, "ADS7846 pendown") < 0) {
111 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
112 return;
115 gpio_direction_input(ts_gpio);
117 omap_set_gpio_debounce(ts_gpio, 1);
118 omap_set_gpio_debounce_time(ts_gpio, 0xa);
121 static int ads7846_get_pendown_state(void)
123 return !gpio_get_value(ts_gpio);
126 static struct ads7846_platform_data tsc2046_config __initdata = {
127 .get_pendown_state = ads7846_get_pendown_state,
128 .keep_vref_on = 1,
132 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
133 .turbo_mode = 0,
134 .single_channel = 1, /* 0: slave, 1: master */
137 static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
138 [0] = {
140 * TSC2046 operates at a max freqency of 2MHz, so
141 * operate slightly below at 1.5MHz
143 .modalias = "ads7846",
144 .bus_num = 1,
145 .chip_select = 0,
146 .max_speed_hz = 1500000,
147 .controller_data = &tsc2046_mcspi_config,
148 .irq = 0,
149 .platform_data = &tsc2046_config,
153 static struct platform_device sdp3430_lcd_device = {
154 .name = "sdp2430_lcd",
155 .id = -1,
158 static struct regulator_consumer_supply sdp3430_vdac_supply = {
159 .supply = "vdac",
160 .dev = &sdp3430_lcd_device.dev,
163 static struct regulator_consumer_supply sdp3430_vdvi_supply = {
164 .supply = "vdvi",
165 .dev = &sdp3430_lcd_device.dev,
168 static struct platform_device *sdp3430_devices[] __initdata = {
169 &sdp3430_lcd_device,
172 static struct omap_lcd_config sdp3430_lcd_config __initdata = {
173 .ctrl_name = "internal",
176 static struct omap_board_config_kernel sdp3430_config[] __initdata = {
177 { OMAP_TAG_LCD, &sdp3430_lcd_config },
180 static void __init omap_3430sdp_init_irq(void)
182 omap_board_config = sdp3430_config;
183 omap_board_config_size = ARRAY_SIZE(sdp3430_config);
184 omap2_init_common_hw(hyb18m512160af6_sdrc_params, NULL);
185 omap_init_irq();
186 omap_gpio_init();
189 static int sdp3430_batt_table[] = {
190 /* 0 C*/
191 30800, 29500, 28300, 27100,
192 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
193 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
194 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
195 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
196 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
197 4040, 3910, 3790, 3670, 3550
200 static struct twl4030_bci_platform_data sdp3430_bci_data = {
201 .battery_tmp_tbl = sdp3430_batt_table,
202 .tblsize = ARRAY_SIZE(sdp3430_batt_table),
205 static struct twl4030_hsmmc_info mmc[] = {
207 .mmc = 1,
208 /* 8 bits (default) requires S6.3 == ON,
209 * so the SIM card isn't used; else 4 bits.
211 .wires = 8,
212 .gpio_wp = 4,
215 .mmc = 2,
216 .wires = 8,
217 .gpio_wp = 7,
219 {} /* Terminator */
222 static struct regulator_consumer_supply sdp3430_vmmc1_supply = {
223 .supply = "vmmc",
226 static struct regulator_consumer_supply sdp3430_vsim_supply = {
227 .supply = "vmmc_aux",
230 static struct regulator_consumer_supply sdp3430_vmmc2_supply = {
231 .supply = "vmmc",
234 static int sdp3430_twl_gpio_setup(struct device *dev,
235 unsigned gpio, unsigned ngpio)
237 /* gpio + 0 is "mmc0_cd" (input/IRQ),
238 * gpio + 1 is "mmc1_cd" (input/IRQ)
240 mmc[0].gpio_cd = gpio + 0;
241 mmc[1].gpio_cd = gpio + 1;
242 twl4030_mmc_init(mmc);
244 /* link regulators to MMC adapters ... we "know" the
245 * regulators will be set up only *after* we return.
247 sdp3430_vmmc1_supply.dev = mmc[0].dev;
248 sdp3430_vsim_supply.dev = mmc[0].dev;
249 sdp3430_vmmc2_supply.dev = mmc[1].dev;
251 /* gpio + 7 is "sub_lcd_en_bkl" (output/PWM1) */
252 gpio_request(gpio + 7, "sub_lcd_en_bkl");
253 gpio_direction_output(gpio + 7, 0);
255 /* gpio + 15 is "sub_lcd_nRST" (output) */
256 gpio_request(gpio + 15, "sub_lcd_nRST");
257 gpio_direction_output(gpio + 15, 0);
259 return 0;
262 static struct twl4030_gpio_platform_data sdp3430_gpio_data = {
263 .gpio_base = OMAP_MAX_GPIO_LINES,
264 .irq_base = TWL4030_GPIO_IRQ_BASE,
265 .irq_end = TWL4030_GPIO_IRQ_END,
266 .pulldowns = BIT(2) | BIT(6) | BIT(8) | BIT(13)
267 | BIT(16) | BIT(17),
268 .setup = sdp3430_twl_gpio_setup,
271 static struct twl4030_usb_data sdp3430_usb_data = {
272 .usb_mode = T2_USB_MODE_ULPI,
275 static struct twl4030_madc_platform_data sdp3430_madc_data = {
276 .irq_line = 1,
280 static struct twl4030_ins __initdata sleep_on_seq[] = {
281 /* Turn off HFCLKOUT */
282 {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_OFF), 2},
283 /* Turn OFF VDD1 */
284 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 2},
285 /* Turn OFF VDD2 */
286 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2},
287 /* Turn OFF VPLL1 */
288 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_OFF), 2},
291 static struct twl4030_script sleep_on_script __initdata = {
292 .script = sleep_on_seq,
293 .size = ARRAY_SIZE(sleep_on_seq),
294 .flags = TWL4030_SLEEP_SCRIPT,
297 static struct twl4030_ins wakeup_p12_seq[] __initdata = {
298 /* Turn on HFCLKOUT */
299 {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2},
300 /* Turn ON VDD1 */
301 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 2},
302 /* Turn ON VDD2 */
303 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 2},
304 /* Turn ON VPLL1 */
305 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_ACTIVE), 2},
308 static struct twl4030_script wakeup_p12_script __initdata = {
309 .script = wakeup_p12_seq,
310 .size = ARRAY_SIZE(wakeup_p12_seq),
311 .flags = TWL4030_WAKEUP12_SCRIPT,
314 static struct twl4030_ins wakeup_p3_seq[] __initdata = {
315 {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2},
318 static struct twl4030_script wakeup_p3_script __initdata = {
319 .script = wakeup_p3_seq,
320 .size = ARRAY_SIZE(wakeup_p3_seq),
321 .flags = TWL4030_WAKEUP3_SCRIPT,
324 static struct twl4030_ins wrst_seq[] __initdata = {
326 * Reset twl4030.
327 * Reset VDD1 regulator.
328 * Reset VDD2 regulator.
329 * Reset VPLL1 regulator.
330 * Enable sysclk output.
331 * Reenable twl4030.
333 {MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_OFF), 2},
334 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_WRST), 15},
335 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_WRST), 15},
336 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_WRST), 0x60},
337 {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2},
338 {MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_ACTIVE), 2},
340 static struct twl4030_script wrst_script __initdata = {
341 .script = wrst_seq,
342 .size = ARRAY_SIZE(wrst_seq),
343 .flags = TWL4030_WRST_SCRIPT,
346 static struct twl4030_script *twl4030_scripts[] __initdata = {
347 &sleep_on_script,
348 &wakeup_p12_script,
349 &wakeup_p3_script,
350 &wrst_script,
353 static struct twl4030_resconfig twl4030_rconfig[] = {
354 { .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3, .type = -1,
355 .type2 = -1 },
356 { .resource = RES_VDD1, .devgroup = DEV_GRP_P1, .type = -1,
357 .type2 = -1 },
358 { .resource = RES_VDD2, .devgroup = DEV_GRP_P1, .type = -1,
359 .type2 = -1 },
360 { 0, 0},
363 static struct twl4030_power_data sdp3430_t2scripts_data __initdata = {
364 .scripts = twl4030_scripts,
365 .num = ARRAY_SIZE(twl4030_scripts),
366 .resource_config = twl4030_rconfig,
370 * Apply all the fixed voltages since most versions of U-Boot
371 * don't bother with that initialization.
374 /* VAUX1 for mainboard (irda and sub-lcd) */
375 static struct regulator_init_data sdp3430_vaux1 = {
376 .constraints = {
377 .min_uV = 2800000,
378 .max_uV = 2800000,
379 .apply_uV = true,
380 .valid_modes_mask = REGULATOR_MODE_NORMAL
381 | REGULATOR_MODE_STANDBY,
382 .valid_ops_mask = REGULATOR_CHANGE_MODE
383 | REGULATOR_CHANGE_STATUS,
387 /* VAUX2 for camera module */
388 static struct regulator_init_data sdp3430_vaux2 = {
389 .constraints = {
390 .min_uV = 2800000,
391 .max_uV = 2800000,
392 .apply_uV = true,
393 .valid_modes_mask = REGULATOR_MODE_NORMAL
394 | REGULATOR_MODE_STANDBY,
395 .valid_ops_mask = REGULATOR_CHANGE_MODE
396 | REGULATOR_CHANGE_STATUS,
400 /* VAUX3 for LCD board */
401 static struct regulator_init_data sdp3430_vaux3 = {
402 .constraints = {
403 .min_uV = 2800000,
404 .max_uV = 2800000,
405 .apply_uV = true,
406 .valid_modes_mask = REGULATOR_MODE_NORMAL
407 | REGULATOR_MODE_STANDBY,
408 .valid_ops_mask = REGULATOR_CHANGE_MODE
409 | REGULATOR_CHANGE_STATUS,
413 /* VAUX4 for OMAP VDD_CSI2 (camera) */
414 static struct regulator_init_data sdp3430_vaux4 = {
415 .constraints = {
416 .min_uV = 1800000,
417 .max_uV = 1800000,
418 .apply_uV = true,
419 .valid_modes_mask = REGULATOR_MODE_NORMAL
420 | REGULATOR_MODE_STANDBY,
421 .valid_ops_mask = REGULATOR_CHANGE_MODE
422 | REGULATOR_CHANGE_STATUS,
426 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
427 static struct regulator_init_data sdp3430_vmmc1 = {
428 .constraints = {
429 .min_uV = 1850000,
430 .max_uV = 3150000,
431 .valid_modes_mask = REGULATOR_MODE_NORMAL
432 | REGULATOR_MODE_STANDBY,
433 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
434 | REGULATOR_CHANGE_MODE
435 | REGULATOR_CHANGE_STATUS,
437 .num_consumer_supplies = 1,
438 .consumer_supplies = &sdp3430_vmmc1_supply,
441 /* VMMC2 for MMC2 card */
442 static struct regulator_init_data sdp3430_vmmc2 = {
443 .constraints = {
444 .min_uV = 1850000,
445 .max_uV = 1850000,
446 .apply_uV = true,
447 .valid_modes_mask = REGULATOR_MODE_NORMAL
448 | REGULATOR_MODE_STANDBY,
449 .valid_ops_mask = REGULATOR_CHANGE_MODE
450 | REGULATOR_CHANGE_STATUS,
452 .num_consumer_supplies = 1,
453 .consumer_supplies = &sdp3430_vmmc2_supply,
456 /* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
457 static struct regulator_init_data sdp3430_vsim = {
458 .constraints = {
459 .min_uV = 1800000,
460 .max_uV = 3000000,
461 .valid_modes_mask = REGULATOR_MODE_NORMAL
462 | REGULATOR_MODE_STANDBY,
463 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
464 | REGULATOR_CHANGE_MODE
465 | REGULATOR_CHANGE_STATUS,
467 .num_consumer_supplies = 1,
468 .consumer_supplies = &sdp3430_vsim_supply,
471 /* VDAC for DSS driving S-Video */
472 static struct regulator_init_data sdp3430_vdac = {
473 .constraints = {
474 .min_uV = 1800000,
475 .max_uV = 1800000,
476 .apply_uV = true,
477 .valid_modes_mask = REGULATOR_MODE_NORMAL
478 | REGULATOR_MODE_STANDBY,
479 .valid_ops_mask = REGULATOR_CHANGE_MODE
480 | REGULATOR_CHANGE_STATUS,
482 .num_consumer_supplies = 1,
483 .consumer_supplies = &sdp3430_vdac_supply,
486 /* VPLL2 for digital video outputs */
487 static struct regulator_init_data sdp3430_vpll2 = {
488 .constraints = {
489 .name = "VDVI",
490 .min_uV = 1800000,
491 .max_uV = 1800000,
492 .valid_modes_mask = REGULATOR_MODE_NORMAL
493 | REGULATOR_MODE_STANDBY,
494 .valid_ops_mask = REGULATOR_CHANGE_MODE
495 | REGULATOR_CHANGE_STATUS,
497 .num_consumer_supplies = 1,
498 .consumer_supplies = &sdp3430_vdvi_supply,
501 static struct twl4030_platform_data sdp3430_twldata = {
502 .irq_base = TWL4030_IRQ_BASE,
503 .irq_end = TWL4030_IRQ_END,
505 /* platform_data for children goes here */
506 .bci = &sdp3430_bci_data,
507 .gpio = &sdp3430_gpio_data,
508 .madc = &sdp3430_madc_data,
509 .keypad = &sdp3430_kp_data,
510 .power = &sdp3430_t2scripts_data,
511 .usb = &sdp3430_usb_data,
513 .vaux1 = &sdp3430_vaux1,
514 .vaux2 = &sdp3430_vaux2,
515 .vaux3 = &sdp3430_vaux3,
516 .vaux4 = &sdp3430_vaux4,
517 .vmmc1 = &sdp3430_vmmc1,
518 .vmmc2 = &sdp3430_vmmc2,
519 .vsim = &sdp3430_vsim,
520 .vdac = &sdp3430_vdac,
521 .vpll2 = &sdp3430_vpll2,
524 static struct i2c_board_info __initdata sdp3430_i2c_boardinfo[] = {
526 I2C_BOARD_INFO("twl4030", 0x48),
527 .flags = I2C_CLIENT_WAKE,
528 .irq = INT_34XX_SYS_NIRQ,
529 .platform_data = &sdp3430_twldata,
533 static int __init omap3430_i2c_init(void)
535 /* i2c1 for PMIC only */
536 omap_register_i2c_bus(1, 2600, sdp3430_i2c_boardinfo,
537 ARRAY_SIZE(sdp3430_i2c_boardinfo));
538 /* i2c2 on camera connector (for sensor control) and optional isp1301 */
539 omap_register_i2c_bus(2, 400, NULL, 0);
540 /* i2c3 on display connector (for DVI, tfp410) */
541 omap_register_i2c_bus(3, 400, NULL, 0);
542 return 0;
545 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
547 static struct omap_smc91x_platform_data board_smc91x_data = {
548 .cs = 3,
549 .flags = GPMC_MUX_ADD_DATA | GPMC_TIMINGS_SMC91C96 |
550 IORESOURCE_IRQ_LOWLEVEL,
553 static void __init board_smc91x_init(void)
555 if (omap_rev() > OMAP3430_REV_ES1_0)
556 board_smc91x_data.gpio_irq = 6;
557 else
558 board_smc91x_data.gpio_irq = 29;
560 gpmc_smc91x_init(&board_smc91x_data);
563 #else
565 static inline void board_smc91x_init(void)
569 #endif
571 static void enable_board_wakeup_source(void)
573 omap_cfg_reg(AF26_34XX_SYS_NIRQ); /* T2 interrupt line (keypad) */
576 static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
578 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
579 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
580 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
582 .phy_reset = true,
583 .reset_gpio_port[0] = 57,
584 .reset_gpio_port[1] = 61,
585 .reset_gpio_port[2] = -EINVAL
588 static void __init omap_3430sdp_init(void)
590 omap3430_i2c_init();
591 platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
592 if (omap_rev() > OMAP3430_REV_ES1_0)
593 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV2;
594 else
595 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV1;
596 sdp3430_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
597 spi_register_board_info(sdp3430_spi_board_info,
598 ARRAY_SIZE(sdp3430_spi_board_info));
599 ads7846_dev_init();
600 omap_serial_init();
601 usb_musb_init();
602 board_smc91x_init();
603 enable_board_wakeup_source();
604 usb_ehci_init(&ehci_pdata);
607 static void __init omap_3430sdp_map_io(void)
609 omap2_set_globals_343x();
610 omap2_map_common_io();
613 MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
614 /* Maintainer: Syed Khasim - Texas Instruments Inc */
615 .phys_io = 0x48000000,
616 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
617 .boot_params = 0x80000100,
618 .map_io = omap_3430sdp_map_io,
619 .init_irq = omap_3430sdp_init_irq,
620 .init_machine = omap_3430sdp_init,
621 .timer = &omap_timer,
622 MACHINE_END