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/spi/spi.h>
21 #include <linux/spi/ads7846.h>
22 #include <linux/i2c/twl4030.h>
23 #include <linux/regulator/machine.h>
25 #include <linux/gpio.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>
34 #include <mach/board.h>
36 #include <mach/common.h>
38 #include <mach/gpmc.h>
40 #include <mach/control.h>
41 #include <mach/keypad.h>
42 #include <mach/gpmc-smc91x.h>
44 #include "sdram-qimonda-hyb18m512160af-6.h"
45 #include "mmc-twl4030.h"
47 #define CONFIG_DISABLE_HFCLK 1
49 #define SDP3430_TS_GPIO_IRQ_SDPV1 3
50 #define SDP3430_TS_GPIO_IRQ_SDPV2 2
52 #define ENABLE_VAUX3_DEDICATED 0x03
53 #define ENABLE_VAUX3_DEV_GRP 0x20
55 #define TWL4030_MSECURE_GPIO 22
57 static int sdp3430_keymap[] = {
91 static struct twl4030_keypad_data sdp3430_kp_data = {
94 .keymap = sdp3430_keymap,
95 .keymapsize = ARRAY_SIZE(sdp3430_keymap),
99 static int ts_gpio; /* Needed for ads7846_get_pendown_state */
102 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
104 * @return - void. If request gpio fails then Flag KERN_ERR.
106 static void ads7846_dev_init(void)
108 if (gpio_request(ts_gpio, "ADS7846 pendown") < 0) {
109 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
113 gpio_direction_input(ts_gpio);
115 omap_set_gpio_debounce(ts_gpio, 1);
116 omap_set_gpio_debounce_time(ts_gpio, 0xa);
119 static int ads7846_get_pendown_state(void)
121 return !gpio_get_value(ts_gpio);
124 static struct ads7846_platform_data tsc2046_config __initdata = {
125 .get_pendown_state = ads7846_get_pendown_state,
130 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
132 .single_channel = 1, /* 0: slave, 1: master */
135 static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
138 * TSC2046 operates at a max freqency of 2MHz, so
139 * operate slightly below at 1.5MHz
141 .modalias = "ads7846",
144 .max_speed_hz = 1500000,
145 .controller_data = &tsc2046_mcspi_config,
147 .platform_data = &tsc2046_config,
151 static struct platform_device sdp3430_lcd_device = {
152 .name = "sdp2430_lcd",
156 static struct regulator_consumer_supply sdp3430_vdac_supply = {
158 .dev = &sdp3430_lcd_device.dev,
161 static struct regulator_consumer_supply sdp3430_vdvi_supply = {
163 .dev = &sdp3430_lcd_device.dev,
166 static struct platform_device *sdp3430_devices[] __initdata = {
170 static struct omap_lcd_config sdp3430_lcd_config __initdata = {
171 .ctrl_name = "internal",
174 static struct omap_board_config_kernel sdp3430_config[] __initdata = {
175 { OMAP_TAG_LCD, &sdp3430_lcd_config },
178 static void __init omap_3430sdp_init_irq(void)
180 omap_board_config = sdp3430_config;
181 omap_board_config_size = ARRAY_SIZE(sdp3430_config);
182 omap2_init_common_hw(hyb18m512160af6_sdrc_params, NULL);
187 static int sdp3430_batt_table[] = {
189 30800, 29500, 28300, 27100,
190 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
191 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
192 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
193 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
194 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
195 4040, 3910, 3790, 3670, 3550
198 static struct twl4030_bci_platform_data sdp3430_bci_data = {
199 .battery_tmp_tbl = sdp3430_batt_table,
200 .tblsize = ARRAY_SIZE(sdp3430_batt_table),
203 static struct twl4030_hsmmc_info mmc[] = {
206 /* 8 bits (default) requires S6.3 == ON,
207 * so the SIM card isn't used; else 4 bits.
220 static struct regulator_consumer_supply sdp3430_vmmc1_supply = {
224 static struct regulator_consumer_supply sdp3430_vsim_supply = {
225 .supply = "vmmc_aux",
228 static struct regulator_consumer_supply sdp3430_vmmc2_supply = {
232 static int sdp3430_twl_gpio_setup(struct device *dev,
233 unsigned gpio, unsigned ngpio)
235 /* gpio + 0 is "mmc0_cd" (input/IRQ),
236 * gpio + 1 is "mmc1_cd" (input/IRQ)
238 mmc[0].gpio_cd = gpio + 0;
239 mmc[1].gpio_cd = gpio + 1;
240 twl4030_mmc_init(mmc);
242 /* link regulators to MMC adapters ... we "know" the
243 * regulators will be set up only *after* we return.
245 sdp3430_vmmc1_supply.dev = mmc[0].dev;
246 sdp3430_vsim_supply.dev = mmc[0].dev;
247 sdp3430_vmmc2_supply.dev = mmc[1].dev;
249 /* gpio + 7 is "sub_lcd_en_bkl" (output/PWM1) */
250 gpio_request(gpio + 7, "sub_lcd_en_bkl");
251 gpio_direction_output(gpio + 7, 0);
253 /* gpio + 15 is "sub_lcd_nRST" (output) */
254 gpio_request(gpio + 15, "sub_lcd_nRST");
255 gpio_direction_output(gpio + 15, 0);
260 static struct twl4030_gpio_platform_data sdp3430_gpio_data = {
261 .gpio_base = OMAP_MAX_GPIO_LINES,
262 .irq_base = TWL4030_GPIO_IRQ_BASE,
263 .irq_end = TWL4030_GPIO_IRQ_END,
264 .pulldowns = BIT(2) | BIT(6) | BIT(8) | BIT(13)
266 .setup = sdp3430_twl_gpio_setup,
269 static struct twl4030_usb_data sdp3430_usb_data = {
270 .usb_mode = T2_USB_MODE_ULPI,
273 static struct twl4030_madc_platform_data sdp3430_madc_data = {
278 * Apply all the fixed voltages since most versions of U-Boot
279 * don't bother with that initialization.
282 /* VAUX1 for mainboard (irda and sub-lcd) */
283 static struct regulator_init_data sdp3430_vaux1 = {
288 .valid_modes_mask = REGULATOR_MODE_NORMAL
289 | REGULATOR_MODE_STANDBY,
290 .valid_ops_mask = REGULATOR_CHANGE_MODE
291 | REGULATOR_CHANGE_STATUS,
295 /* VAUX2 for camera module */
296 static struct regulator_init_data sdp3430_vaux2 = {
301 .valid_modes_mask = REGULATOR_MODE_NORMAL
302 | REGULATOR_MODE_STANDBY,
303 .valid_ops_mask = REGULATOR_CHANGE_MODE
304 | REGULATOR_CHANGE_STATUS,
308 /* VAUX3 for LCD board */
309 static struct regulator_init_data sdp3430_vaux3 = {
314 .valid_modes_mask = REGULATOR_MODE_NORMAL
315 | REGULATOR_MODE_STANDBY,
316 .valid_ops_mask = REGULATOR_CHANGE_MODE
317 | REGULATOR_CHANGE_STATUS,
321 /* VAUX4 for OMAP VDD_CSI2 (camera) */
322 static struct regulator_init_data sdp3430_vaux4 = {
327 .valid_modes_mask = REGULATOR_MODE_NORMAL
328 | REGULATOR_MODE_STANDBY,
329 .valid_ops_mask = REGULATOR_CHANGE_MODE
330 | REGULATOR_CHANGE_STATUS,
334 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
335 static struct regulator_init_data sdp3430_vmmc1 = {
339 .valid_modes_mask = REGULATOR_MODE_NORMAL
340 | REGULATOR_MODE_STANDBY,
341 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
342 | REGULATOR_CHANGE_MODE
343 | REGULATOR_CHANGE_STATUS,
345 .num_consumer_supplies = 1,
346 .consumer_supplies = &sdp3430_vmmc1_supply,
349 /* VMMC2 for MMC2 card */
350 static struct regulator_init_data sdp3430_vmmc2 = {
355 .valid_modes_mask = REGULATOR_MODE_NORMAL
356 | REGULATOR_MODE_STANDBY,
357 .valid_ops_mask = REGULATOR_CHANGE_MODE
358 | REGULATOR_CHANGE_STATUS,
360 .num_consumer_supplies = 1,
361 .consumer_supplies = &sdp3430_vmmc2_supply,
364 /* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
365 static struct regulator_init_data sdp3430_vsim = {
369 .valid_modes_mask = REGULATOR_MODE_NORMAL
370 | REGULATOR_MODE_STANDBY,
371 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
372 | REGULATOR_CHANGE_MODE
373 | REGULATOR_CHANGE_STATUS,
375 .num_consumer_supplies = 1,
376 .consumer_supplies = &sdp3430_vsim_supply,
379 /* VDAC for DSS driving S-Video */
380 static struct regulator_init_data sdp3430_vdac = {
385 .valid_modes_mask = REGULATOR_MODE_NORMAL
386 | REGULATOR_MODE_STANDBY,
387 .valid_ops_mask = REGULATOR_CHANGE_MODE
388 | REGULATOR_CHANGE_STATUS,
390 .num_consumer_supplies = 1,
391 .consumer_supplies = &sdp3430_vdac_supply,
394 /* VPLL2 for digital video outputs */
395 static struct regulator_init_data sdp3430_vpll2 = {
400 .valid_modes_mask = REGULATOR_MODE_NORMAL
401 | REGULATOR_MODE_STANDBY,
402 .valid_ops_mask = REGULATOR_CHANGE_MODE
403 | REGULATOR_CHANGE_STATUS,
405 .num_consumer_supplies = 1,
406 .consumer_supplies = &sdp3430_vdvi_supply,
409 static struct twl4030_platform_data sdp3430_twldata = {
410 .irq_base = TWL4030_IRQ_BASE,
411 .irq_end = TWL4030_IRQ_END,
413 /* platform_data for children goes here */
414 .bci = &sdp3430_bci_data,
415 .gpio = &sdp3430_gpio_data,
416 .madc = &sdp3430_madc_data,
417 .keypad = &sdp3430_kp_data,
418 .usb = &sdp3430_usb_data,
420 .vaux1 = &sdp3430_vaux1,
421 .vaux2 = &sdp3430_vaux2,
422 .vaux3 = &sdp3430_vaux3,
423 .vaux4 = &sdp3430_vaux4,
424 .vmmc1 = &sdp3430_vmmc1,
425 .vmmc2 = &sdp3430_vmmc2,
426 .vsim = &sdp3430_vsim,
427 .vdac = &sdp3430_vdac,
428 .vpll2 = &sdp3430_vpll2,
431 static struct i2c_board_info __initdata sdp3430_i2c_boardinfo[] = {
433 I2C_BOARD_INFO("twl4030", 0x48),
434 .flags = I2C_CLIENT_WAKE,
435 .irq = INT_34XX_SYS_NIRQ,
436 .platform_data = &sdp3430_twldata,
440 static int __init omap3430_i2c_init(void)
442 /* i2c1 for PMIC only */
443 omap_register_i2c_bus(1, 2600, sdp3430_i2c_boardinfo,
444 ARRAY_SIZE(sdp3430_i2c_boardinfo));
445 /* i2c2 on camera connector (for sensor control) and optional isp1301 */
446 omap_register_i2c_bus(2, 400, NULL, 0);
447 /* i2c3 on display connector (for DVI, tfp410) */
448 omap_register_i2c_bus(3, 400, NULL, 0);
452 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
454 static struct omap_smc91x_platform_data board_smc91x_data = {
456 .flags = GPMC_MUX_ADD_DATA | GPMC_TIMINGS_SMC91C96 |
457 IORESOURCE_IRQ_LOWLEVEL,
460 static void __init board_smc91x_init(void)
462 if (omap_rev() > OMAP3430_REV_ES1_0)
463 board_smc91x_data.gpio_irq = 6;
465 board_smc91x_data.gpio_irq = 29;
467 gpmc_smc91x_init(&board_smc91x_data);
472 static inline void board_smc91x_init(void)
478 static void enable_board_wakeup_source(void)
480 omap_cfg_reg(AF26_34XX_SYS_NIRQ); /* T2 interrupt line (keypad) */
483 static void __init omap_3430sdp_init(void)
486 platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
487 if (omap_rev() > OMAP3430_REV_ES1_0)
488 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV2;
490 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV1;
491 sdp3430_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
492 spi_register_board_info(sdp3430_spi_board_info,
493 ARRAY_SIZE(sdp3430_spi_board_info));
498 enable_board_wakeup_source();
501 static void __init omap_3430sdp_map_io(void)
503 omap2_set_globals_343x();
504 omap2_map_common_io();
507 MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
508 /* Maintainer: Syed Khasim - Texas Instruments Inc */
509 .phys_io = 0x48000000,
510 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
511 .boot_params = 0x80000100,
512 .map_io = omap_3430sdp_map_io,
513 .init_irq = omap_3430sdp_init_irq,
514 .init_machine = omap_3430sdp_init,
515 .timer = &omap_timer,