blob: 0e6369583958934f188d9701f7e4dcf074523c3d [file] [log] [blame]
Syed Mohammed Khasim6fdc29e2009-03-23 18:38:16 -07001/*
2 * linux/arch/arm/mach-omap2/board-3430sdp.c
3 *
4 * Copyright (C) 2007 Texas Instruments
5 *
6 * Modified from mach-omap2/board-generic.c
7 *
8 * Initial code: Syed Mohammed Khasim
9 *
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.
13 */
14
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>
24#include <linux/io.h>
25#include <linux/gpio.h>
26
27#include <mach/hardware.h>
28#include <asm/mach-types.h>
29#include <asm/mach/arch.h>
30#include <asm/mach/map.h>
31
32#include <mach/mcspi.h>
33#include <mach/mux.h>
34#include <mach/board.h>
35#include <mach/usb.h>
36#include <mach/common.h>
37#include <mach/dma.h>
38#include <mach/gpmc.h>
39
40#include <mach/control.h>
41#include <mach/keypad.h>
Tony Lindgren1a48e152009-05-28 13:23:52 -070042#include <mach/gpmc-smc91x.h>
Syed Mohammed Khasim6fdc29e2009-03-23 18:38:16 -070043
44#include "mmc-twl4030.h"
45
46#define CONFIG_DISABLE_HFCLK 1
47
Syed Mohammed Khasim6fdc29e2009-03-23 18:38:16 -070048#define SDP3430_TS_GPIO_IRQ_SDPV1 3
49#define SDP3430_TS_GPIO_IRQ_SDPV2 2
50
51#define ENABLE_VAUX3_DEDICATED 0x03
52#define ENABLE_VAUX3_DEV_GRP 0x20
53
54#define TWL4030_MSECURE_GPIO 22
55
Syed Mohammed Khasim6fdc29e2009-03-23 18:38:16 -070056static int sdp3430_keymap[] = {
57 KEY(0, 0, KEY_LEFT),
58 KEY(0, 1, KEY_RIGHT),
59 KEY(0, 2, KEY_A),
60 KEY(0, 3, KEY_B),
61 KEY(0, 4, KEY_C),
62 KEY(1, 0, KEY_DOWN),
63 KEY(1, 1, KEY_UP),
64 KEY(1, 2, KEY_E),
65 KEY(1, 3, KEY_F),
66 KEY(1, 4, KEY_G),
67 KEY(2, 0, KEY_ENTER),
68 KEY(2, 1, KEY_I),
69 KEY(2, 2, KEY_J),
70 KEY(2, 3, KEY_K),
71 KEY(2, 4, KEY_3),
72 KEY(3, 0, KEY_M),
73 KEY(3, 1, KEY_N),
74 KEY(3, 2, KEY_O),
75 KEY(3, 3, KEY_P),
76 KEY(3, 4, KEY_Q),
77 KEY(4, 0, KEY_R),
78 KEY(4, 1, KEY_4),
79 KEY(4, 2, KEY_T),
80 KEY(4, 3, KEY_U),
81 KEY(4, 4, KEY_D),
82 KEY(5, 0, KEY_V),
83 KEY(5, 1, KEY_W),
84 KEY(5, 2, KEY_L),
85 KEY(5, 3, KEY_S),
86 KEY(5, 4, KEY_H),
87 0
88};
89
90static struct twl4030_keypad_data sdp3430_kp_data = {
91 .rows = 5,
92 .cols = 6,
93 .keymap = sdp3430_keymap,
94 .keymapsize = ARRAY_SIZE(sdp3430_keymap),
95 .rep = 1,
96};
97
98static int ts_gpio; /* Needed for ads7846_get_pendown_state */
99
100/**
101 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
102 *
103 * @return - void. If request gpio fails then Flag KERN_ERR.
104 */
105static void ads7846_dev_init(void)
106{
107 if (gpio_request(ts_gpio, "ADS7846 pendown") < 0) {
108 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
109 return;
110 }
111
112 gpio_direction_input(ts_gpio);
113
114 omap_set_gpio_debounce(ts_gpio, 1);
115 omap_set_gpio_debounce_time(ts_gpio, 0xa);
116}
117
118static int ads7846_get_pendown_state(void)
119{
120 return !gpio_get_value(ts_gpio);
121}
122
123static struct ads7846_platform_data tsc2046_config __initdata = {
124 .get_pendown_state = ads7846_get_pendown_state,
125 .keep_vref_on = 1,
126};
127
128
129static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
130 .turbo_mode = 0,
131 .single_channel = 1, /* 0: slave, 1: master */
132};
133
134static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
135 [0] = {
136 /*
137 * TSC2046 operates at a max freqency of 2MHz, so
138 * operate slightly below at 1.5MHz
139 */
140 .modalias = "ads7846",
141 .bus_num = 1,
142 .chip_select = 0,
143 .max_speed_hz = 1500000,
144 .controller_data = &tsc2046_mcspi_config,
145 .irq = 0,
146 .platform_data = &tsc2046_config,
147 },
148};
149
150static struct platform_device sdp3430_lcd_device = {
151 .name = "sdp2430_lcd",
152 .id = -1,
153};
154
155static struct regulator_consumer_supply sdp3430_vdac_supply = {
156 .supply = "vdac",
157 .dev = &sdp3430_lcd_device.dev,
158};
159
160static struct regulator_consumer_supply sdp3430_vdvi_supply = {
161 .supply = "vdvi",
162 .dev = &sdp3430_lcd_device.dev,
163};
164
165static struct platform_device *sdp3430_devices[] __initdata = {
Syed Mohammed Khasim6fdc29e2009-03-23 18:38:16 -0700166 &sdp3430_lcd_device,
167};
168
Syed Mohammed Khasim6fdc29e2009-03-23 18:38:16 -0700169static void __init omap_3430sdp_init_irq(void)
170{
Tony Lindgren2f3ec502009-03-16 15:28:42 -0700171 omap2_init_common_hw(NULL);
Syed Mohammed Khasim6fdc29e2009-03-23 18:38:16 -0700172 omap_init_irq();
173 omap_gpio_init();
Syed Mohammed Khasim6fdc29e2009-03-23 18:38:16 -0700174}
175
176static struct omap_uart_config sdp3430_uart_config __initdata = {
177 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
178};
179
180static struct omap_lcd_config sdp3430_lcd_config __initdata = {
181 .ctrl_name = "internal",
182};
183
184static struct omap_board_config_kernel sdp3430_config[] __initdata = {
185 { OMAP_TAG_UART, &sdp3430_uart_config },
186 { OMAP_TAG_LCD, &sdp3430_lcd_config },
187};
188
189static int sdp3430_batt_table[] = {
190/* 0 C*/
19130800, 29500, 28300, 27100,
19226000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
19317200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
19411600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
1958020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
1965640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
1974040, 3910, 3790, 3670, 3550
198};
199
200static struct twl4030_bci_platform_data sdp3430_bci_data = {
201 .battery_tmp_tbl = sdp3430_batt_table,
202 .tblsize = ARRAY_SIZE(sdp3430_batt_table),
203};
204
205static struct twl4030_hsmmc_info mmc[] = {
206 {
207 .mmc = 1,
208 /* 8 bits (default) requires S6.3 == ON,
209 * so the SIM card isn't used; else 4 bits.
210 */
211 .wires = 8,
212 .gpio_wp = 4,
213 },
214 {
215 .mmc = 2,
216 .wires = 8,
217 .gpio_wp = 7,
218 },
219 {} /* Terminator */
220};
221
222static struct regulator_consumer_supply sdp3430_vmmc1_supply = {
223 .supply = "vmmc",
224};
225
226static struct regulator_consumer_supply sdp3430_vsim_supply = {
227 .supply = "vmmc_aux",
228};
229
230static struct regulator_consumer_supply sdp3430_vmmc2_supply = {
231 .supply = "vmmc",
232};
233
234static int sdp3430_twl_gpio_setup(struct device *dev,
235 unsigned gpio, unsigned ngpio)
236{
237 /* gpio + 0 is "mmc0_cd" (input/IRQ),
238 * gpio + 1 is "mmc1_cd" (input/IRQ)
239 */
240 mmc[0].gpio_cd = gpio + 0;
241 mmc[1].gpio_cd = gpio + 1;
242 twl4030_mmc_init(mmc);
243
244 /* link regulators to MMC adapters ... we "know" the
245 * regulators will be set up only *after* we return.
246 */
247 sdp3430_vmmc1_supply.dev = mmc[0].dev;
248 sdp3430_vsim_supply.dev = mmc[0].dev;
249 sdp3430_vmmc2_supply.dev = mmc[1].dev;
250
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);
254
255 /* gpio + 15 is "sub_lcd_nRST" (output) */
256 gpio_request(gpio + 15, "sub_lcd_nRST");
257 gpio_direction_output(gpio + 15, 0);
258
259 return 0;
260}
261
262static 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,
269};
270
271static struct twl4030_usb_data sdp3430_usb_data = {
272 .usb_mode = T2_USB_MODE_ULPI,
273};
274
275static struct twl4030_madc_platform_data sdp3430_madc_data = {
276 .irq_line = 1,
277};
278
279/*
280 * Apply all the fixed voltages since most versions of U-Boot
281 * don't bother with that initialization.
282 */
283
284/* VAUX1 for mainboard (irda and sub-lcd) */
285static struct regulator_init_data sdp3430_vaux1 = {
286 .constraints = {
287 .min_uV = 2800000,
288 .max_uV = 2800000,
289 .apply_uV = true,
290 .valid_modes_mask = REGULATOR_MODE_NORMAL
291 | REGULATOR_MODE_STANDBY,
292 .valid_ops_mask = REGULATOR_CHANGE_MODE
293 | REGULATOR_CHANGE_STATUS,
294 },
295};
296
297/* VAUX2 for camera module */
298static struct regulator_init_data sdp3430_vaux2 = {
299 .constraints = {
300 .min_uV = 2800000,
301 .max_uV = 2800000,
302 .apply_uV = true,
303 .valid_modes_mask = REGULATOR_MODE_NORMAL
304 | REGULATOR_MODE_STANDBY,
305 .valid_ops_mask = REGULATOR_CHANGE_MODE
306 | REGULATOR_CHANGE_STATUS,
307 },
308};
309
310/* VAUX3 for LCD board */
311static struct regulator_init_data sdp3430_vaux3 = {
312 .constraints = {
313 .min_uV = 2800000,
314 .max_uV = 2800000,
315 .apply_uV = true,
316 .valid_modes_mask = REGULATOR_MODE_NORMAL
317 | REGULATOR_MODE_STANDBY,
318 .valid_ops_mask = REGULATOR_CHANGE_MODE
319 | REGULATOR_CHANGE_STATUS,
320 },
321};
322
323/* VAUX4 for OMAP VDD_CSI2 (camera) */
324static struct regulator_init_data sdp3430_vaux4 = {
325 .constraints = {
326 .min_uV = 1800000,
327 .max_uV = 1800000,
328 .apply_uV = true,
329 .valid_modes_mask = REGULATOR_MODE_NORMAL
330 | REGULATOR_MODE_STANDBY,
331 .valid_ops_mask = REGULATOR_CHANGE_MODE
332 | REGULATOR_CHANGE_STATUS,
333 },
334};
335
336/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
337static struct regulator_init_data sdp3430_vmmc1 = {
338 .constraints = {
339 .min_uV = 1850000,
340 .max_uV = 3150000,
341 .valid_modes_mask = REGULATOR_MODE_NORMAL
342 | REGULATOR_MODE_STANDBY,
343 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
344 | REGULATOR_CHANGE_MODE
345 | REGULATOR_CHANGE_STATUS,
346 },
347 .num_consumer_supplies = 1,
348 .consumer_supplies = &sdp3430_vmmc1_supply,
349};
350
351/* VMMC2 for MMC2 card */
352static struct regulator_init_data sdp3430_vmmc2 = {
353 .constraints = {
354 .min_uV = 1850000,
355 .max_uV = 1850000,
356 .apply_uV = true,
357 .valid_modes_mask = REGULATOR_MODE_NORMAL
358 | REGULATOR_MODE_STANDBY,
359 .valid_ops_mask = REGULATOR_CHANGE_MODE
360 | REGULATOR_CHANGE_STATUS,
361 },
362 .num_consumer_supplies = 1,
363 .consumer_supplies = &sdp3430_vmmc2_supply,
364};
365
366/* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
367static struct regulator_init_data sdp3430_vsim = {
368 .constraints = {
369 .min_uV = 1800000,
370 .max_uV = 3000000,
371 .valid_modes_mask = REGULATOR_MODE_NORMAL
372 | REGULATOR_MODE_STANDBY,
373 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
374 | REGULATOR_CHANGE_MODE
375 | REGULATOR_CHANGE_STATUS,
376 },
377 .num_consumer_supplies = 1,
378 .consumer_supplies = &sdp3430_vsim_supply,
379};
380
381/* VDAC for DSS driving S-Video */
382static struct regulator_init_data sdp3430_vdac = {
383 .constraints = {
384 .min_uV = 1800000,
385 .max_uV = 1800000,
386 .apply_uV = true,
387 .valid_modes_mask = REGULATOR_MODE_NORMAL
388 | REGULATOR_MODE_STANDBY,
389 .valid_ops_mask = REGULATOR_CHANGE_MODE
390 | REGULATOR_CHANGE_STATUS,
391 },
392 .num_consumer_supplies = 1,
393 .consumer_supplies = &sdp3430_vdac_supply,
394};
395
396/* VPLL2 for digital video outputs */
397static struct regulator_init_data sdp3430_vpll2 = {
398 .constraints = {
399 .name = "VDVI",
400 .min_uV = 1800000,
401 .max_uV = 1800000,
402 .valid_modes_mask = REGULATOR_MODE_NORMAL
403 | REGULATOR_MODE_STANDBY,
404 .valid_ops_mask = REGULATOR_CHANGE_MODE
405 | REGULATOR_CHANGE_STATUS,
406 },
407 .num_consumer_supplies = 1,
408 .consumer_supplies = &sdp3430_vdvi_supply,
409};
410
411static struct twl4030_platform_data sdp3430_twldata = {
412 .irq_base = TWL4030_IRQ_BASE,
413 .irq_end = TWL4030_IRQ_END,
414
415 /* platform_data for children goes here */
416 .bci = &sdp3430_bci_data,
417 .gpio = &sdp3430_gpio_data,
418 .madc = &sdp3430_madc_data,
419 .keypad = &sdp3430_kp_data,
420 .usb = &sdp3430_usb_data,
421
422 .vaux1 = &sdp3430_vaux1,
423 .vaux2 = &sdp3430_vaux2,
424 .vaux3 = &sdp3430_vaux3,
425 .vaux4 = &sdp3430_vaux4,
426 .vmmc1 = &sdp3430_vmmc1,
427 .vmmc2 = &sdp3430_vmmc2,
428 .vsim = &sdp3430_vsim,
429 .vdac = &sdp3430_vdac,
430 .vpll2 = &sdp3430_vpll2,
431};
432
433static struct i2c_board_info __initdata sdp3430_i2c_boardinfo[] = {
434 {
435 I2C_BOARD_INFO("twl4030", 0x48),
436 .flags = I2C_CLIENT_WAKE,
437 .irq = INT_34XX_SYS_NIRQ,
438 .platform_data = &sdp3430_twldata,
439 },
440};
441
442static int __init omap3430_i2c_init(void)
443{
444 /* i2c1 for PMIC only */
445 omap_register_i2c_bus(1, 2600, sdp3430_i2c_boardinfo,
446 ARRAY_SIZE(sdp3430_i2c_boardinfo));
447 /* i2c2 on camera connector (for sensor control) and optional isp1301 */
448 omap_register_i2c_bus(2, 400, NULL, 0);
449 /* i2c3 on display connector (for DVI, tfp410) */
450 omap_register_i2c_bus(3, 400, NULL, 0);
451 return 0;
452}
453
Tony Lindgren1a48e152009-05-28 13:23:52 -0700454#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
455
456static struct omap_smc91x_platform_data board_smc91x_data = {
457 .cs = 3,
458 .flags = GPMC_MUX_ADD_DATA | GPMC_TIMINGS_SMC91C96 |
459 IORESOURCE_IRQ_LOWLEVEL,
460};
461
462static void __init board_smc91x_init(void)
463{
464 if (omap_rev() > OMAP3430_REV_ES1_0)
465 board_smc91x_data.gpio_irq = 6;
466 else
467 board_smc91x_data.gpio_irq = 29;
468
469 gpmc_smc91x_init(&board_smc91x_data);
470}
471
472#else
473
474static inline void board_smc91x_init(void)
475{
476}
477
478#endif
479
Syed Mohammed Khasim6fdc29e2009-03-23 18:38:16 -0700480static void __init omap_3430sdp_init(void)
481{
482 omap3430_i2c_init();
483 platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
484 omap_board_config = sdp3430_config;
485 omap_board_config_size = ARRAY_SIZE(sdp3430_config);
486 if (omap_rev() > OMAP3430_REV_ES1_0)
487 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV2;
488 else
489 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV1;
490 sdp3430_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
491 spi_register_board_info(sdp3430_spi_board_info,
492 ARRAY_SIZE(sdp3430_spi_board_info));
493 ads7846_dev_init();
494 omap_serial_init();
495 usb_musb_init();
Tony Lindgren1a48e152009-05-28 13:23:52 -0700496 board_smc91x_init();
Syed Mohammed Khasim6fdc29e2009-03-23 18:38:16 -0700497}
498
499static void __init omap_3430sdp_map_io(void)
500{
501 omap2_set_globals_343x();
502 omap2_map_common_io();
503}
504
505MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
506 /* Maintainer: Syed Khasim - Texas Instruments Inc */
507 .phys_io = 0x48000000,
508 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
509 .boot_params = 0x80000100,
510 .map_io = omap_3430sdp_map_io,
511 .init_irq = omap_3430sdp_init_irq,
512 .init_machine = omap_3430sdp_init,
513 .timer = &omap_timer,
514MACHINE_END