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/err.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>
27 #include <mach/hardware.h>
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
32 #include <mach/mcspi.h>
33 #include <mach/gpio.h>
35 #include <mach/board.h>
37 #include <mach/common.h>
39 #include <mach/gpmc.h>
41 #include <mach/control.h>
43 #include "sdram-qimonda-hyb18m512160af-6.h"
44 #include "mmc-twl4030.h"
46 #define CONFIG_DISABLE_HFCLK 1
48 #define SDP3430_ETHR_START DEBUG_BASE
49 #define SDP3430_ETHR_GPIO_IRQ_SDPV1 29
50 #define SDP3430_ETHR_GPIO_IRQ_SDPV2 6
51 #define SDP3430_SMC91X_CS 3
53 #define SDP3430_TS_GPIO_IRQ_SDPV1 3
54 #define SDP3430_TS_GPIO_IRQ_SDPV2 2
56 #define ENABLE_VAUX3_DEDICATED 0x03
57 #define ENABLE_VAUX3_DEV_GRP 0x20
59 #define ENABLE_VAUX3_DEDICATED 0x03
60 #define ENABLE_VAUX3_DEV_GRP 0x20
62 #define TWL4030_MSECURE_GPIO 22
64 static struct resource sdp3430_smc91x_resources[] = {
66 .flags = IORESOURCE_MEM,
71 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
75 static struct platform_device sdp3430_smc91x_device = {
78 .num_resources = ARRAY_SIZE(sdp3430_smc91x_resources),
79 .resource = sdp3430_smc91x_resources,
82 static int sdp3430_keymap[] = {
116 static struct twl4030_keypad_data sdp3430_kp_data = {
119 .keymap = sdp3430_keymap,
120 .keymapsize = ARRAY_SIZE(sdp3430_keymap),
124 static int ts_gpio; /* Needed for ads7846_get_pendown_state */
126 static int __init msecure_init(void)
130 #ifdef CONFIG_RTC_DRV_TWL4030
131 /* 3430ES2.0 doesn't have msecure/gpio-22 line connected to T2 */
132 if (omap_type() == OMAP2_DEVICE_TYPE_GP &&
133 omap_rev() < OMAP3430_REV_ES2_0) {
134 void __iomem *msecure_pad_config_reg = omap_ctrl_base_get() +
139 ret = gpio_request(TWL4030_MSECURE_GPIO, "msecure");
141 printk(KERN_ERR "msecure_init: can't"
142 "reserve GPIO:%d !\n", TWL4030_MSECURE_GPIO);
146 * TWL4030 will be in secure mode if msecure line from OMAP
147 * is low. Make msecure line high in order to change the
148 * TWL4030 RTC time and calender registers.
150 tmp = __raw_readw(msecure_pad_config_reg);
151 tmp &= 0xF8; /* To enable mux mode 03/04 = GPIO_RTC */
152 tmp |= mux_mask;/* To enable mux mode 03/04 = GPIO_RTC */
153 __raw_writew(tmp, msecure_pad_config_reg);
155 gpio_direction_output(TWL4030_MSECURE_GPIO, 1);
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);
186 * This enable(1)/disable(0) the voltage for TS: uses twl4030 calls
188 static int ads7846_vaux_control(int vaux_cntrl)
192 #ifdef CONFIG_TWL4030_CORE
193 /* check for return value of ldo_use: if success it returns 0 */
194 if (vaux_cntrl == VAUX_ENABLE) {
195 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
196 ENABLE_VAUX3_DEDICATED, TWL4030_VAUX3_DEDICATED))
198 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
199 ENABLE_VAUX3_DEV_GRP, TWL4030_VAUX3_DEV_GRP))
201 } else if (vaux_cntrl == VAUX_DISABLE) {
202 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
203 0x00, TWL4030_VAUX3_DEDICATED))
205 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
206 0x00, TWL4030_VAUX3_DEV_GRP))
215 static struct ads7846_platform_data tsc2046_config __initdata = {
216 .get_pendown_state = ads7846_get_pendown_state,
218 .vaux_control = ads7846_vaux_control,
222 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
224 .single_channel = 1, /* 0: slave, 1: master */
227 static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
230 * TSC2046 operates at a max freqency of 2MHz, so
231 * operate slightly below at 1.5MHz
233 .modalias = "ads7846",
236 .max_speed_hz = 1500000,
237 .controller_data = &tsc2046_mcspi_config,
239 .platform_data = &tsc2046_config,
243 static struct platform_device sdp3430_lcd_device = {
244 .name = "sdp2430_lcd",
248 static struct platform_device *sdp3430_devices[] __initdata = {
249 &sdp3430_smc91x_device,
253 static inline void __init sdp3430_init_smc91x(void)
256 unsigned long cs_mem_base;
259 eth_cs = SDP3430_SMC91X_CS;
261 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
262 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
266 sdp3430_smc91x_resources[0].start = cs_mem_base + 0x300;
267 sdp3430_smc91x_resources[0].end = cs_mem_base + 0x30f;
270 if (omap_rev() > OMAP3430_REV_ES1_0)
271 eth_gpio = SDP3430_ETHR_GPIO_IRQ_SDPV2;
273 eth_gpio = SDP3430_ETHR_GPIO_IRQ_SDPV1;
275 sdp3430_smc91x_resources[1].start = gpio_to_irq(eth_gpio);
277 if (gpio_request(eth_gpio, "SMC91x irq") < 0) {
278 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
282 gpio_direction_input(eth_gpio);
285 static void __init omap_3430sdp_init_irq(void)
287 omap2_init_common_hw(hyb18m512160af6_sdrc_params);
290 sdp3430_init_smc91x();
293 static struct omap_uart_config sdp3430_uart_config __initdata = {
294 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
297 static struct omap_lcd_config sdp3430_lcd_config __initdata = {
298 .ctrl_name = "internal",
301 static struct omap_board_config_kernel sdp3430_config[] __initdata = {
302 { OMAP_TAG_UART, &sdp3430_uart_config },
303 { OMAP_TAG_LCD, &sdp3430_lcd_config },
306 static int sdp3430_batt_table[] = {
308 30800, 29500, 28300, 27100,
309 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
310 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
311 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
312 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
313 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
314 4040, 3910, 3790, 3670, 3550
317 static struct twl4030_bci_platform_data sdp3430_bci_data = {
318 .battery_tmp_tbl = sdp3430_batt_table,
319 .tblsize = ARRAY_SIZE(sdp3430_batt_table),
322 static struct twl4030_hsmmc_info mmc[] = {
325 /* 8 bits (default) requires S6.3 == ON,
326 * so the SIM card isn't used; else 4 bits.
339 static struct regulator_consumer_supply sdp3430_vmmc1_supply = {
343 static struct regulator_consumer_supply sdp3430_vsim_supply = {
344 .supply = "vmmc_aux",
347 static struct regulator_consumer_supply sdp3430_vmmc2_supply = {
351 static int sdp3430_twl_gpio_setup(struct device *dev,
352 unsigned gpio, unsigned ngpio)
354 /* gpio + 0 is "mmc0_cd" (input/IRQ),
355 * gpio + 1 is "mmc1_cd" (input/IRQ)
357 mmc[0].gpio_cd = gpio + 0;
358 mmc[1].gpio_cd = gpio + 1;
359 twl4030_mmc_init(mmc);
361 /* link regulators to MMC adapters ... we "know" the
362 * regulators will be set up only *after* we return.
364 sdp3430_vmmc1_supply.dev = mmc[0].dev;
365 sdp3430_vsim_supply.dev = mmc[0].dev;
366 sdp3430_vmmc2_supply.dev = mmc[1].dev;
368 /* gpio + 7 is "sub_lcd_en_bkl" (output/PWM1) */
369 gpio_request(gpio + 7, "sub_lcd_en_bkl");
370 gpio_direction_output(gpio + 7, 0);
372 /* gpio + 15 is "sub_lcd_nRST" (output) */
373 gpio_request(gpio + 15, "sub_lcd_nRST");
374 gpio_direction_output(gpio + 15, 0);
379 static struct twl4030_gpio_platform_data sdp3430_gpio_data = {
380 .gpio_base = OMAP_MAX_GPIO_LINES,
381 .irq_base = TWL4030_GPIO_IRQ_BASE,
382 .irq_end = TWL4030_GPIO_IRQ_END,
383 .pulldowns = BIT(2) | BIT(6) | BIT(8) | BIT(13)
385 .setup = sdp3430_twl_gpio_setup,
388 static struct twl4030_usb_data sdp3430_usb_data = {
389 .usb_mode = T2_USB_MODE_ULPI,
392 static struct twl4030_madc_platform_data sdp3430_madc_data = {
397 static struct twl4030_ins __initdata sleep_on_seq[] = {
399 * Turn off VDD1 and VDD2.
401 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 4},
402 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2},
403 #ifdef CONFIG_DISABLE_HFCLK
405 * And also turn off the OMAP3 PLLs and the sysclk output.
407 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_OFF), 3},
408 {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_OFF), 3},
412 static struct twl4030_script sleep_on_script __initdata = {
413 .script = sleep_on_seq,
414 .size = ARRAY_SIZE(sleep_on_seq),
415 .flags = TRITON_SLEEP_SCRIPT,
418 static struct twl4030_ins wakeup_seq[] __initdata = {
419 #ifndef CONFIG_DISABLE_HFCLK
421 * Wakeup VDD1 and VDD2.
423 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 4},
424 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 2},
427 * Reenable the OMAP3 PLLs.
428 * Wakeup VDD1 and VDD2.
429 * Reenable sysclk output.
431 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_ACTIVE), 0x30},
432 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 0x30},
433 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 0x37},
434 {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 3},
435 #endif /* #ifndef CONFIG_DISABLE_HFCLK */
438 static struct twl4030_script wakeup_script __initdata = {
439 .script = wakeup_seq,
440 .size = ARRAY_SIZE(wakeup_seq),
441 .flags = TRITON_WAKEUP12_SCRIPT | TRITON_WAKEUP3_SCRIPT,
444 static struct twl4030_ins wrst_seq[] __initdata = {
447 * Reset VDD1 regulator.
448 * Reset VDD2 regulator.
449 * Reset VPLL1 regulator.
450 * Enable sysclk output.
453 {MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_OFF), 2},
454 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_WRST), 15},
455 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_WRST), 15},
456 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_WRST), 0x60},
457 {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2},
458 {MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_ACTIVE), 2},
460 static struct twl4030_script wrst_script __initdata = {
462 .size = ARRAY_SIZE(wakeup_seq),
463 .flags = TRITON_WRST_SCRIPT,
466 static struct twl4030_script *twl4030_scripts[] __initdata = {
472 static struct twl4030_power_data sdp3430_t2scripts_data __initdata = {
473 .scripts = twl4030_scripts,
474 .size = ARRAY_SIZE(twl4030_scripts),
478 * Apply all the fixed voltages since most versions of U-Boot
479 * don't bother with that initialization.
482 /* VAUX1 for mainboard (irda and sub-lcd) */
483 static struct regulator_init_data sdp3430_vaux1 = {
488 .valid_modes_mask = REGULATOR_MODE_NORMAL
489 | REGULATOR_MODE_STANDBY,
490 .valid_ops_mask = REGULATOR_CHANGE_MODE
491 | REGULATOR_CHANGE_STATUS,
495 /* VAUX2 for camera module */
496 static struct regulator_init_data sdp3430_vaux2 = {
501 .valid_modes_mask = REGULATOR_MODE_NORMAL
502 | REGULATOR_MODE_STANDBY,
503 .valid_ops_mask = REGULATOR_CHANGE_MODE
504 | REGULATOR_CHANGE_STATUS,
508 /* VAUX3 for LCD board */
509 static struct regulator_init_data sdp3430_vaux3 = {
514 .valid_modes_mask = REGULATOR_MODE_NORMAL
515 | REGULATOR_MODE_STANDBY,
516 .valid_ops_mask = REGULATOR_CHANGE_MODE
517 | REGULATOR_CHANGE_STATUS,
521 /* VAUX4 for OMAP VDD_CSI2 (camera) */
522 static struct regulator_init_data sdp3430_vaux4 = {
527 .valid_modes_mask = REGULATOR_MODE_NORMAL
528 | REGULATOR_MODE_STANDBY,
529 .valid_ops_mask = REGULATOR_CHANGE_MODE
530 | REGULATOR_CHANGE_STATUS,
534 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
535 static struct regulator_init_data sdp3430_vmmc1 = {
539 .valid_modes_mask = REGULATOR_MODE_NORMAL
540 | REGULATOR_MODE_STANDBY,
541 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
542 | REGULATOR_CHANGE_MODE
543 | REGULATOR_CHANGE_STATUS,
545 .num_consumer_supplies = 1,
546 .consumer_supplies = &sdp3430_vmmc1_supply,
549 /* VMMC2 for MMC2 card */
550 static struct regulator_init_data sdp3430_vmmc2 = {
555 .valid_modes_mask = REGULATOR_MODE_NORMAL
556 | REGULATOR_MODE_STANDBY,
557 .valid_ops_mask = REGULATOR_CHANGE_MODE
558 | REGULATOR_CHANGE_STATUS,
560 .num_consumer_supplies = 1,
561 .consumer_supplies = &sdp3430_vmmc2_supply,
564 /* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
565 static struct regulator_init_data sdp3430_vsim = {
569 .valid_modes_mask = REGULATOR_MODE_NORMAL
570 | REGULATOR_MODE_STANDBY,
571 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
572 | REGULATOR_CHANGE_MODE
573 | REGULATOR_CHANGE_STATUS,
575 .num_consumer_supplies = 1,
576 .consumer_supplies = &sdp3430_vsim_supply,
579 /* VDAC for DSS driving S-Video */
580 static struct regulator_init_data sdp3430_vdac = {
585 .valid_modes_mask = REGULATOR_MODE_NORMAL
586 | REGULATOR_MODE_STANDBY,
587 .valid_ops_mask = REGULATOR_CHANGE_MODE
588 | REGULATOR_CHANGE_STATUS,
592 static struct twl4030_platform_data sdp3430_twldata = {
593 .irq_base = TWL4030_IRQ_BASE,
594 .irq_end = TWL4030_IRQ_END,
596 /* platform_data for children goes here */
597 .bci = &sdp3430_bci_data,
598 .gpio = &sdp3430_gpio_data,
599 .madc = &sdp3430_madc_data,
600 .keypad = &sdp3430_kp_data,
601 .power = &sdp3430_t2scripts_data,
602 .usb = &sdp3430_usb_data,
604 .vaux1 = &sdp3430_vaux1,
605 .vaux2 = &sdp3430_vaux2,
606 .vaux3 = &sdp3430_vaux3,
607 .vaux4 = &sdp3430_vaux4,
608 .vmmc1 = &sdp3430_vmmc1,
609 .vmmc2 = &sdp3430_vmmc2,
610 .vsim = &sdp3430_vsim,
611 .vdac = &sdp3430_vdac,
614 static struct i2c_board_info __initdata sdp3430_i2c_boardinfo[] = {
616 I2C_BOARD_INFO("twl4030", 0x48),
617 .flags = I2C_CLIENT_WAKE,
618 .irq = INT_34XX_SYS_NIRQ,
619 .platform_data = &sdp3430_twldata,
623 static int __init omap3430_i2c_init(void)
625 /* i2c1 for PMIC only */
626 omap_register_i2c_bus(1, 2600, sdp3430_i2c_boardinfo,
627 ARRAY_SIZE(sdp3430_i2c_boardinfo));
628 /* i2c2 on camera connector (for sensor control) and optional isp1301 */
629 omap_register_i2c_bus(2, 400, NULL, 0);
630 /* i2c3 on display connector (for DVI, tfp410) */
631 omap_register_i2c_bus(3, 400, NULL, 0);
635 static void __init omap_3430sdp_init(void)
638 platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
639 omap_board_config = sdp3430_config;
640 omap_board_config_size = ARRAY_SIZE(sdp3430_config);
641 if (omap_rev() > OMAP3430_REV_ES1_0)
642 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV2;
644 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV1;
645 sdp3430_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
646 spi_register_board_info(sdp3430_spi_board_info,
647 ARRAY_SIZE(sdp3430_spi_board_info));
649 sdp3430_flash_init();
656 static void __init omap_3430sdp_map_io(void)
658 omap2_set_globals_343x();
659 omap2_map_common_io();
662 MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
663 /* Maintainer: Syed Khasim - Texas Instruments Inc */
664 .phys_io = 0x48000000,
665 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
666 .boot_params = 0x80000100,
667 .map_io = omap_3430sdp_map_io,
668 .init_irq = omap_3430sdp_init_irq,
669 .init_machine = omap_3430sdp_init,
670 .timer = &omap_timer,