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