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>
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>
35 #include <plat/board.h>
37 #include <plat/common.h>
39 #include <plat/gpmc.h>
40 #include <plat/clock.h>
42 #include <plat/control.h>
43 #include <plat/gpmc-smc91x.h>
44 #include <plat/omap-pm.h>
46 #include "sdram-qimonda-hyb18m512160af-6.h"
47 #include "mmc-twl4030.h"
51 #define S600M 600000000
52 #define S550M 550000000
53 #define S500M 500000000
54 #define S250M 250000000
55 #define S125M 125000000
58 #define S430M 430000000
59 #define S400M 400000000
60 #define S360M 360000000
61 #define S180M 180000000
66 #define S166M 166000000
68 static struct omap_opp mpu_rate_table
[] = {
71 {S125M
, VDD1_OPP1
, 0x18},
73 {S250M
, VDD1_OPP2
, 0x20},
75 {S500M
, VDD1_OPP3
, 0x30},
77 {S550M
, VDD1_OPP4
, 0x36},
79 {S600M
, VDD1_OPP5
, 0x3C},
82 static struct omap_opp l3_rate_table
[] = {
87 {S83M
, VDD2_OPP2
, 0x20},
89 {S166M
, VDD2_OPP3
, 0x2C},
92 struct omap_opp dsp_rate_table
[] = {
95 {S90M
, VDD1_OPP1
, 0x18},
97 {S180M
, VDD1_OPP2
, 0x20},
99 {S360M
, VDD1_OPP3
, 0x30},
101 {S400M
, VDD1_OPP4
, 0x36},
103 {S430M
, VDD1_OPP5
, 0x3C},
106 #define SDP3430_TS_GPIO_IRQ_SDPV1 3
107 #define SDP3430_TS_GPIO_IRQ_SDPV2 2
109 #define ENABLE_VAUX3_DEDICATED 0x03
110 #define ENABLE_VAUX3_DEV_GRP 0x20
112 #define TWL4030_MSECURE_GPIO 22
114 static int board_keymap
[] = {
116 KEY(0, 1, KEY_RIGHT
),
125 KEY(2, 0, KEY_ENTER
),
148 static struct matrix_keymap_data board_map_data
= {
149 .keymap
= board_keymap
,
150 .keymap_size
= ARRAY_SIZE(board_keymap
),
153 static struct twl4030_keypad_data sdp3430_kp_data
= {
154 .keymap_data
= &board_map_data
,
160 static int ts_gpio
; /* Needed for ads7846_get_pendown_state */
163 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
165 * @return - void. If request gpio fails then Flag KERN_ERR.
167 static void ads7846_dev_init(void)
169 if (gpio_request(ts_gpio
, "ADS7846 pendown") < 0) {
170 printk(KERN_ERR
"can't get ads746 pen down GPIO\n");
174 gpio_direction_input(ts_gpio
);
176 omap_set_gpio_debounce(ts_gpio
, 1);
177 omap_set_gpio_debounce_time(ts_gpio
, 0xa);
180 static int ads7846_get_pendown_state(void)
182 return !gpio_get_value(ts_gpio
);
185 static struct ads7846_platform_data tsc2046_config __initdata
= {
186 .get_pendown_state
= ads7846_get_pendown_state
,
191 static struct omap2_mcspi_device_config tsc2046_mcspi_config
= {
193 .single_channel
= 1, /* 0: slave, 1: master */
196 static struct spi_board_info sdp3430_spi_board_info
[] __initdata
= {
199 * TSC2046 operates at a max freqency of 2MHz, so
200 * operate slightly below at 1.5MHz
202 .modalias
= "ads7846",
205 .max_speed_hz
= 1500000,
206 .controller_data
= &tsc2046_mcspi_config
,
208 .platform_data
= &tsc2046_config
,
212 static struct platform_device sdp3430_lcd_device
= {
213 .name
= "sdp2430_lcd",
217 static struct regulator_consumer_supply sdp3430_vdac_supply
= {
219 .dev
= &sdp3430_lcd_device
.dev
,
222 static struct regulator_consumer_supply sdp3430_vdvi_supply
= {
224 .dev
= &sdp3430_lcd_device
.dev
,
227 static struct platform_device
*sdp3430_devices
[] __initdata
= {
231 static struct omap_lcd_config sdp3430_lcd_config __initdata
= {
232 .ctrl_name
= "internal",
235 static struct omap_board_config_kernel sdp3430_config
[] __initdata
= {
236 { OMAP_TAG_LCD
, &sdp3430_lcd_config
},
239 static void __init
omap_3430sdp_init_irq(void)
241 omap_board_config
= sdp3430_config
;
242 omap_board_config_size
= ARRAY_SIZE(sdp3430_config
);
243 omap2_init_common_hw(hyb18m512160af6_sdrc_params
, NULL
, mpu_rate_table
,
244 dsp_rate_table
, l3_rate_table
);
249 static int sdp3430_batt_table
[] = {
251 30800, 29500, 28300, 27100,
252 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
253 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
254 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
255 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
256 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
257 4040, 3910, 3790, 3670, 3550
260 static struct twl4030_bci_platform_data sdp3430_bci_data
= {
261 .battery_tmp_tbl
= sdp3430_batt_table
,
262 .tblsize
= ARRAY_SIZE(sdp3430_batt_table
),
265 static struct twl4030_hsmmc_info mmc
[] = {
268 /* 8 bits (default) requires S6.3 == ON,
269 * so the SIM card isn't used; else 4 bits.
282 static struct regulator_consumer_supply sdp3430_vmmc1_supply
= {
286 static struct regulator_consumer_supply sdp3430_vsim_supply
= {
287 .supply
= "vmmc_aux",
290 static struct regulator_consumer_supply sdp3430_vmmc2_supply
= {
294 static int sdp3430_twl_gpio_setup(struct device
*dev
,
295 unsigned gpio
, unsigned ngpio
)
297 /* gpio + 0 is "mmc0_cd" (input/IRQ),
298 * gpio + 1 is "mmc1_cd" (input/IRQ)
300 mmc
[0].gpio_cd
= gpio
+ 0;
301 mmc
[1].gpio_cd
= gpio
+ 1;
302 twl4030_mmc_init(mmc
);
304 /* link regulators to MMC adapters ... we "know" the
305 * regulators will be set up only *after* we return.
307 sdp3430_vmmc1_supply
.dev
= mmc
[0].dev
;
308 sdp3430_vsim_supply
.dev
= mmc
[0].dev
;
309 sdp3430_vmmc2_supply
.dev
= mmc
[1].dev
;
311 /* gpio + 7 is "sub_lcd_en_bkl" (output/PWM1) */
312 gpio_request(gpio
+ 7, "sub_lcd_en_bkl");
313 gpio_direction_output(gpio
+ 7, 0);
315 /* gpio + 15 is "sub_lcd_nRST" (output) */
316 gpio_request(gpio
+ 15, "sub_lcd_nRST");
317 gpio_direction_output(gpio
+ 15, 0);
322 static struct twl4030_gpio_platform_data sdp3430_gpio_data
= {
323 .gpio_base
= OMAP_MAX_GPIO_LINES
,
324 .irq_base
= TWL4030_GPIO_IRQ_BASE
,
325 .irq_end
= TWL4030_GPIO_IRQ_END
,
326 .pulldowns
= BIT(2) | BIT(6) | BIT(8) | BIT(13)
328 .setup
= sdp3430_twl_gpio_setup
,
331 static struct twl4030_usb_data sdp3430_usb_data
= {
332 .usb_mode
= T2_USB_MODE_ULPI
,
335 static struct twl4030_madc_platform_data sdp3430_madc_data
= {
340 static struct twl4030_ins __initdata sleep_on_seq
[] = {
341 /* Turn off HFCLKOUT */
342 {MSG_SINGULAR(DEV_GRP_P1
, 0x19, RES_STATE_OFF
), 2},
344 {MSG_SINGULAR(DEV_GRP_P1
, 0xf, RES_STATE_OFF
), 2},
346 {MSG_SINGULAR(DEV_GRP_P1
, 0x10, RES_STATE_OFF
), 2},
348 {MSG_SINGULAR(DEV_GRP_P1
, 0x7, RES_STATE_OFF
), 2},
351 static struct twl4030_script sleep_on_script __initdata
= {
352 .script
= sleep_on_seq
,
353 .size
= ARRAY_SIZE(sleep_on_seq
),
354 .flags
= TWL4030_SLEEP_SCRIPT
,
357 static struct twl4030_ins wakeup_p12_seq
[] __initdata
= {
358 /* Turn on HFCLKOUT */
359 {MSG_SINGULAR(DEV_GRP_P1
, 0x19, RES_STATE_ACTIVE
), 2},
361 {MSG_SINGULAR(DEV_GRP_P1
, 0xf, RES_STATE_ACTIVE
), 2},
363 {MSG_SINGULAR(DEV_GRP_P1
, 0x10, RES_STATE_ACTIVE
), 2},
365 {MSG_SINGULAR(DEV_GRP_P1
, 0x7, RES_STATE_ACTIVE
), 2},
368 static struct twl4030_script wakeup_p12_script __initdata
= {
369 .script
= wakeup_p12_seq
,
370 .size
= ARRAY_SIZE(wakeup_p12_seq
),
371 .flags
= TWL4030_WAKEUP12_SCRIPT
,
374 static struct twl4030_ins wakeup_p3_seq
[] __initdata
= {
375 {MSG_SINGULAR(DEV_GRP_P1
, 0x19, RES_STATE_ACTIVE
), 2},
378 static struct twl4030_script wakeup_p3_script __initdata
= {
379 .script
= wakeup_p3_seq
,
380 .size
= ARRAY_SIZE(wakeup_p3_seq
),
381 .flags
= TWL4030_WAKEUP3_SCRIPT
,
384 static struct twl4030_ins wrst_seq
[] __initdata
= {
387 * Reset VDD1 regulator.
388 * Reset VDD2 regulator.
389 * Reset VPLL1 regulator.
390 * Enable sysclk output.
393 {MSG_SINGULAR(DEV_GRP_NULL
, 0x1b, RES_STATE_OFF
), 2},
394 {MSG_SINGULAR(DEV_GRP_P1
, 0xf, RES_STATE_WRST
), 15},
395 {MSG_SINGULAR(DEV_GRP_P1
, 0x10, RES_STATE_WRST
), 15},
396 {MSG_SINGULAR(DEV_GRP_P1
, 0x7, RES_STATE_WRST
), 0x60},
397 {MSG_SINGULAR(DEV_GRP_P1
, 0x19, RES_STATE_ACTIVE
), 2},
398 {MSG_SINGULAR(DEV_GRP_NULL
, 0x1b, RES_STATE_ACTIVE
), 2},
400 static struct twl4030_script wrst_script __initdata
= {
402 .size
= ARRAY_SIZE(wrst_seq
),
403 .flags
= TWL4030_WRST_SCRIPT
,
406 static struct twl4030_script
*twl4030_scripts
[] __initdata
= {
413 static struct twl4030_resconfig twl4030_rconfig
[] = {
414 { .resource
= RES_HFCLKOUT
, .devgroup
= DEV_GRP_P3
, .type
= -1,
416 { .resource
= RES_VDD1
, .devgroup
= DEV_GRP_P1
, .type
= -1,
418 { .resource
= RES_VDD2
, .devgroup
= DEV_GRP_P1
, .type
= -1,
423 static struct twl4030_power_data sdp3430_t2scripts_data __initdata
= {
424 .scripts
= twl4030_scripts
,
425 .num
= ARRAY_SIZE(twl4030_scripts
),
426 .resource_config
= twl4030_rconfig
,
430 * Apply all the fixed voltages since most versions of U-Boot
431 * don't bother with that initialization.
434 /* VAUX1 for mainboard (irda and sub-lcd) */
435 static struct regulator_init_data sdp3430_vaux1
= {
440 .valid_modes_mask
= REGULATOR_MODE_NORMAL
441 | REGULATOR_MODE_STANDBY
,
442 .valid_ops_mask
= REGULATOR_CHANGE_MODE
443 | REGULATOR_CHANGE_STATUS
,
447 /* VAUX2 for camera module */
448 static struct regulator_init_data sdp3430_vaux2
= {
453 .valid_modes_mask
= REGULATOR_MODE_NORMAL
454 | REGULATOR_MODE_STANDBY
,
455 .valid_ops_mask
= REGULATOR_CHANGE_MODE
456 | REGULATOR_CHANGE_STATUS
,
460 /* VAUX3 for LCD board */
461 static struct regulator_init_data sdp3430_vaux3
= {
466 .valid_modes_mask
= REGULATOR_MODE_NORMAL
467 | REGULATOR_MODE_STANDBY
,
468 .valid_ops_mask
= REGULATOR_CHANGE_MODE
469 | REGULATOR_CHANGE_STATUS
,
473 /* VAUX4 for OMAP VDD_CSI2 (camera) */
474 static struct regulator_init_data sdp3430_vaux4
= {
479 .valid_modes_mask
= REGULATOR_MODE_NORMAL
480 | REGULATOR_MODE_STANDBY
,
481 .valid_ops_mask
= REGULATOR_CHANGE_MODE
482 | REGULATOR_CHANGE_STATUS
,
486 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
487 static struct regulator_init_data sdp3430_vmmc1
= {
491 .valid_modes_mask
= REGULATOR_MODE_NORMAL
492 | REGULATOR_MODE_STANDBY
,
493 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
494 | REGULATOR_CHANGE_MODE
495 | REGULATOR_CHANGE_STATUS
,
497 .num_consumer_supplies
= 1,
498 .consumer_supplies
= &sdp3430_vmmc1_supply
,
501 /* VMMC2 for MMC2 card */
502 static struct regulator_init_data sdp3430_vmmc2
= {
507 .valid_modes_mask
= REGULATOR_MODE_NORMAL
508 | REGULATOR_MODE_STANDBY
,
509 .valid_ops_mask
= REGULATOR_CHANGE_MODE
510 | REGULATOR_CHANGE_STATUS
,
512 .num_consumer_supplies
= 1,
513 .consumer_supplies
= &sdp3430_vmmc2_supply
,
516 /* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
517 static struct regulator_init_data sdp3430_vsim
= {
521 .valid_modes_mask
= REGULATOR_MODE_NORMAL
522 | REGULATOR_MODE_STANDBY
,
523 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
524 | REGULATOR_CHANGE_MODE
525 | REGULATOR_CHANGE_STATUS
,
527 .num_consumer_supplies
= 1,
528 .consumer_supplies
= &sdp3430_vsim_supply
,
531 /* VDAC for DSS driving S-Video */
532 static struct regulator_init_data sdp3430_vdac
= {
537 .valid_modes_mask
= REGULATOR_MODE_NORMAL
538 | REGULATOR_MODE_STANDBY
,
539 .valid_ops_mask
= REGULATOR_CHANGE_MODE
540 | REGULATOR_CHANGE_STATUS
,
542 .num_consumer_supplies
= 1,
543 .consumer_supplies
= &sdp3430_vdac_supply
,
546 /* VPLL2 for digital video outputs */
547 static struct regulator_init_data sdp3430_vpll2
= {
552 .valid_modes_mask
= REGULATOR_MODE_NORMAL
553 | REGULATOR_MODE_STANDBY
,
554 .valid_ops_mask
= REGULATOR_CHANGE_MODE
555 | REGULATOR_CHANGE_STATUS
,
557 .num_consumer_supplies
= 1,
558 .consumer_supplies
= &sdp3430_vdvi_supply
,
561 static struct twl4030_platform_data sdp3430_twldata
= {
562 .irq_base
= TWL4030_IRQ_BASE
,
563 .irq_end
= TWL4030_IRQ_END
,
565 /* platform_data for children goes here */
566 .bci
= &sdp3430_bci_data
,
567 .gpio
= &sdp3430_gpio_data
,
568 .madc
= &sdp3430_madc_data
,
569 .keypad
= &sdp3430_kp_data
,
570 .power
= &sdp3430_t2scripts_data
,
571 .usb
= &sdp3430_usb_data
,
573 .vaux1
= &sdp3430_vaux1
,
574 .vaux2
= &sdp3430_vaux2
,
575 .vaux3
= &sdp3430_vaux3
,
576 .vaux4
= &sdp3430_vaux4
,
577 .vmmc1
= &sdp3430_vmmc1
,
578 .vmmc2
= &sdp3430_vmmc2
,
579 .vsim
= &sdp3430_vsim
,
580 .vdac
= &sdp3430_vdac
,
581 .vpll2
= &sdp3430_vpll2
,
584 static struct i2c_board_info __initdata sdp3430_i2c_boardinfo
[] = {
586 I2C_BOARD_INFO("twl4030", 0x48),
587 .flags
= I2C_CLIENT_WAKE
,
588 .irq
= INT_34XX_SYS_NIRQ
,
589 .platform_data
= &sdp3430_twldata
,
593 static int __init
omap3430_i2c_init(void)
595 /* i2c1 for PMIC only */
596 omap_register_i2c_bus(1, 2600, sdp3430_i2c_boardinfo
,
597 ARRAY_SIZE(sdp3430_i2c_boardinfo
));
598 /* i2c2 on camera connector (for sensor control) and optional isp1301 */
599 omap_register_i2c_bus(2, 400, NULL
, 0);
600 /* i2c3 on display connector (for DVI, tfp410) */
601 omap_register_i2c_bus(3, 400, NULL
, 0);
605 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
607 static struct omap_smc91x_platform_data board_smc91x_data
= {
609 .flags
= GPMC_MUX_ADD_DATA
| GPMC_TIMINGS_SMC91C96
|
610 IORESOURCE_IRQ_LOWLEVEL
,
613 static void __init
board_smc91x_init(void)
615 if (omap_rev() > OMAP3430_REV_ES1_0
)
616 board_smc91x_data
.gpio_irq
= 6;
618 board_smc91x_data
.gpio_irq
= 29;
620 gpmc_smc91x_init(&board_smc91x_data
);
625 static inline void board_smc91x_init(void)
631 static void enable_board_wakeup_source(void)
633 omap_cfg_reg(AF26_34XX_SYS_NIRQ
); /* T2 interrupt line (keypad) */
636 static struct ehci_hcd_omap_platform_data ehci_pdata __initconst
= {
638 .port_mode
[0] = EHCI_HCD_OMAP_MODE_PHY
,
639 .port_mode
[1] = EHCI_HCD_OMAP_MODE_PHY
,
640 .port_mode
[2] = EHCI_HCD_OMAP_MODE_UNKNOWN
,
643 .reset_gpio_port
[0] = 57,
644 .reset_gpio_port
[1] = 61,
645 .reset_gpio_port
[2] = -EINVAL
648 static void __init
omap_3430sdp_init(void)
651 platform_add_devices(sdp3430_devices
, ARRAY_SIZE(sdp3430_devices
));
652 if (omap_rev() > OMAP3430_REV_ES1_0
)
653 ts_gpio
= SDP3430_TS_GPIO_IRQ_SDPV2
;
655 ts_gpio
= SDP3430_TS_GPIO_IRQ_SDPV1
;
656 sdp3430_spi_board_info
[0].irq
= gpio_to_irq(ts_gpio
);
657 spi_register_board_info(sdp3430_spi_board_info
,
658 ARRAY_SIZE(sdp3430_spi_board_info
));
663 enable_board_wakeup_source();
664 usb_ehci_init(&ehci_pdata
);
667 static void __init
omap_3430sdp_map_io(void)
669 omap2_set_globals_343x();
670 omap2_map_common_io();
673 MACHINE_START(OMAP_3430SDP
, "OMAP3430 3430SDP board")
674 /* Maintainer: Syed Khasim - Texas Instruments Inc */
675 .phys_io
= 0x48000000,
676 .io_pg_offst
= ((0xfa000000) >> 18) & 0xfffc,
677 .boot_params
= 0x80000100,
678 .map_io
= omap_3430sdp_map_io
,
679 .init_irq
= omap_3430sdp_init_irq
,
680 .init_machine
= omap_3430sdp_init
,
681 .timer
= &omap_timer
,