OMAP: Configure audio_mclk for twl4030-codec MFD
[deliverable/linux.git] / arch / arm / mach-omap2 / board-3430sdp.c
CommitLineData
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>
6135434a 20#include <linux/input/matrix_keypad.h>
6fdc29e2
SMK
21#include <linux/spi/spi.h>
22#include <linux/spi/ads7846.h>
23#include <linux/i2c/twl4030.h>
24#include <linux/regulator/machine.h>
25#include <linux/io.h>
26#include <linux/gpio.h>
27
28#include <mach/hardware.h>
29#include <asm/mach-types.h>
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32
ce491cf8
TL
33#include <plat/mcspi.h>
34#include <plat/mux.h>
35#include <plat/board.h>
36#include <plat/usb.h>
37#include <plat/common.h>
38#include <plat/dma.h>
39#include <plat/gpmc.h>
6fdc29e2 40
ce491cf8 41#include <plat/control.h>
ce491cf8 42#include <plat/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
4f543332 57static int board_keymap[] = {
6fdc29e2
SMK
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
4f543332
TL
91static struct matrix_keymap_data board_map_data = {
92 .keymap = board_keymap,
93 .keymap_size = ARRAY_SIZE(board_keymap),
94};
95
6fdc29e2 96static struct twl4030_keypad_data sdp3430_kp_data = {
4f543332 97 .keymap_data = &board_map_data,
6fdc29e2
SMK
98 .rows = 5,
99 .cols = 6,
6fdc29e2
SMK
100 .rep = 1,
101};
102
103static int ts_gpio; /* Needed for ads7846_get_pendown_state */
104
105/**
106 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
107 *
108 * @return - void. If request gpio fails then Flag KERN_ERR.
109 */
110static void ads7846_dev_init(void)
111{
112 if (gpio_request(ts_gpio, "ADS7846 pendown") < 0) {
113 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
114 return;
115 }
116
117 gpio_direction_input(ts_gpio);
118
119 omap_set_gpio_debounce(ts_gpio, 1);
120 omap_set_gpio_debounce_time(ts_gpio, 0xa);
121}
122
123static int ads7846_get_pendown_state(void)
124{
125 return !gpio_get_value(ts_gpio);
126}
127
128static struct ads7846_platform_data tsc2046_config __initdata = {
129 .get_pendown_state = ads7846_get_pendown_state,
130 .keep_vref_on = 1,
131};
132
133
134static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
135 .turbo_mode = 0,
136 .single_channel = 1, /* 0: slave, 1: master */
137};
138
139static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
140 [0] = {
141 /*
142 * TSC2046 operates at a max freqency of 2MHz, so
143 * operate slightly below at 1.5MHz
144 */
145 .modalias = "ads7846",
146 .bus_num = 1,
147 .chip_select = 0,
148 .max_speed_hz = 1500000,
149 .controller_data = &tsc2046_mcspi_config,
150 .irq = 0,
151 .platform_data = &tsc2046_config,
152 },
153};
154
155static struct platform_device sdp3430_lcd_device = {
156 .name = "sdp2430_lcd",
157 .id = -1,
158};
159
160static struct regulator_consumer_supply sdp3430_vdac_supply = {
161 .supply = "vdac",
162 .dev = &sdp3430_lcd_device.dev,
163};
164
165static struct regulator_consumer_supply sdp3430_vdvi_supply = {
166 .supply = "vdvi",
167 .dev = &sdp3430_lcd_device.dev,
168};
169
170static struct platform_device *sdp3430_devices[] __initdata = {
6fdc29e2
SMK
171 &sdp3430_lcd_device,
172};
173
6fdc29e2
SMK
174static struct omap_lcd_config sdp3430_lcd_config __initdata = {
175 .ctrl_name = "internal",
176};
177
178static struct omap_board_config_kernel sdp3430_config[] __initdata = {
6fdc29e2
SMK
179 { OMAP_TAG_LCD, &sdp3430_lcd_config },
180};
181
b3c6df3a
PW
182static void __init omap_3430sdp_init_irq(void)
183{
184 omap_board_config = sdp3430_config;
185 omap_board_config_size = ARRAY_SIZE(sdp3430_config);
186 omap2_init_common_hw(hyb18m512160af6_sdrc_params, NULL);
187 omap_init_irq();
188 omap_gpio_init();
189}
190
6fdc29e2
SMK
191static int sdp3430_batt_table[] = {
192/* 0 C*/
19330800, 29500, 28300, 27100,
19426000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
19517200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
19611600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
1978020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
1985640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
1994040, 3910, 3790, 3670, 3550
200};
201
202static struct twl4030_bci_platform_data sdp3430_bci_data = {
203 .battery_tmp_tbl = sdp3430_batt_table,
204 .tblsize = ARRAY_SIZE(sdp3430_batt_table),
205};
206
207static struct twl4030_hsmmc_info mmc[] = {
208 {
209 .mmc = 1,
210 /* 8 bits (default) requires S6.3 == ON,
211 * so the SIM card isn't used; else 4 bits.
212 */
213 .wires = 8,
214 .gpio_wp = 4,
215 },
216 {
217 .mmc = 2,
218 .wires = 8,
219 .gpio_wp = 7,
220 },
221 {} /* Terminator */
222};
223
224static struct regulator_consumer_supply sdp3430_vmmc1_supply = {
225 .supply = "vmmc",
226};
227
228static struct regulator_consumer_supply sdp3430_vsim_supply = {
229 .supply = "vmmc_aux",
230};
231
232static struct regulator_consumer_supply sdp3430_vmmc2_supply = {
233 .supply = "vmmc",
234};
235
236static int sdp3430_twl_gpio_setup(struct device *dev,
237 unsigned gpio, unsigned ngpio)
238{
239 /* gpio + 0 is "mmc0_cd" (input/IRQ),
240 * gpio + 1 is "mmc1_cd" (input/IRQ)
241 */
242 mmc[0].gpio_cd = gpio + 0;
243 mmc[1].gpio_cd = gpio + 1;
244 twl4030_mmc_init(mmc);
245
246 /* link regulators to MMC adapters ... we "know" the
247 * regulators will be set up only *after* we return.
248 */
249 sdp3430_vmmc1_supply.dev = mmc[0].dev;
250 sdp3430_vsim_supply.dev = mmc[0].dev;
251 sdp3430_vmmc2_supply.dev = mmc[1].dev;
252
253 /* gpio + 7 is "sub_lcd_en_bkl" (output/PWM1) */
254 gpio_request(gpio + 7, "sub_lcd_en_bkl");
255 gpio_direction_output(gpio + 7, 0);
256
257 /* gpio + 15 is "sub_lcd_nRST" (output) */
258 gpio_request(gpio + 15, "sub_lcd_nRST");
259 gpio_direction_output(gpio + 15, 0);
260
261 return 0;
262}
263
264static struct twl4030_gpio_platform_data sdp3430_gpio_data = {
265 .gpio_base = OMAP_MAX_GPIO_LINES,
266 .irq_base = TWL4030_GPIO_IRQ_BASE,
267 .irq_end = TWL4030_GPIO_IRQ_END,
268 .pulldowns = BIT(2) | BIT(6) | BIT(8) | BIT(13)
269 | BIT(16) | BIT(17),
270 .setup = sdp3430_twl_gpio_setup,
271};
272
273static struct twl4030_usb_data sdp3430_usb_data = {
274 .usb_mode = T2_USB_MODE_ULPI,
275};
276
277static struct twl4030_madc_platform_data sdp3430_madc_data = {
278 .irq_line = 1,
279};
280
281/*
282 * Apply all the fixed voltages since most versions of U-Boot
283 * don't bother with that initialization.
284 */
285
286/* VAUX1 for mainboard (irda and sub-lcd) */
287static struct regulator_init_data sdp3430_vaux1 = {
288 .constraints = {
289 .min_uV = 2800000,
290 .max_uV = 2800000,
291 .apply_uV = true,
292 .valid_modes_mask = REGULATOR_MODE_NORMAL
293 | REGULATOR_MODE_STANDBY,
294 .valid_ops_mask = REGULATOR_CHANGE_MODE
295 | REGULATOR_CHANGE_STATUS,
296 },
297};
298
299/* VAUX2 for camera module */
300static struct regulator_init_data sdp3430_vaux2 = {
301 .constraints = {
302 .min_uV = 2800000,
303 .max_uV = 2800000,
304 .apply_uV = true,
305 .valid_modes_mask = REGULATOR_MODE_NORMAL
306 | REGULATOR_MODE_STANDBY,
307 .valid_ops_mask = REGULATOR_CHANGE_MODE
308 | REGULATOR_CHANGE_STATUS,
309 },
310};
311
312/* VAUX3 for LCD board */
313static struct regulator_init_data sdp3430_vaux3 = {
314 .constraints = {
315 .min_uV = 2800000,
316 .max_uV = 2800000,
317 .apply_uV = true,
318 .valid_modes_mask = REGULATOR_MODE_NORMAL
319 | REGULATOR_MODE_STANDBY,
320 .valid_ops_mask = REGULATOR_CHANGE_MODE
321 | REGULATOR_CHANGE_STATUS,
322 },
323};
324
325/* VAUX4 for OMAP VDD_CSI2 (camera) */
326static struct regulator_init_data sdp3430_vaux4 = {
327 .constraints = {
328 .min_uV = 1800000,
329 .max_uV = 1800000,
330 .apply_uV = true,
331 .valid_modes_mask = REGULATOR_MODE_NORMAL
332 | REGULATOR_MODE_STANDBY,
333 .valid_ops_mask = REGULATOR_CHANGE_MODE
334 | REGULATOR_CHANGE_STATUS,
335 },
336};
337
338/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
339static struct regulator_init_data sdp3430_vmmc1 = {
340 .constraints = {
341 .min_uV = 1850000,
342 .max_uV = 3150000,
343 .valid_modes_mask = REGULATOR_MODE_NORMAL
344 | REGULATOR_MODE_STANDBY,
345 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
346 | REGULATOR_CHANGE_MODE
347 | REGULATOR_CHANGE_STATUS,
348 },
349 .num_consumer_supplies = 1,
350 .consumer_supplies = &sdp3430_vmmc1_supply,
351};
352
353/* VMMC2 for MMC2 card */
354static struct regulator_init_data sdp3430_vmmc2 = {
355 .constraints = {
356 .min_uV = 1850000,
357 .max_uV = 1850000,
358 .apply_uV = true,
359 .valid_modes_mask = REGULATOR_MODE_NORMAL
360 | REGULATOR_MODE_STANDBY,
361 .valid_ops_mask = REGULATOR_CHANGE_MODE
362 | REGULATOR_CHANGE_STATUS,
363 },
364 .num_consumer_supplies = 1,
365 .consumer_supplies = &sdp3430_vmmc2_supply,
366};
367
368/* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
369static struct regulator_init_data sdp3430_vsim = {
370 .constraints = {
371 .min_uV = 1800000,
372 .max_uV = 3000000,
373 .valid_modes_mask = REGULATOR_MODE_NORMAL
374 | REGULATOR_MODE_STANDBY,
375 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
376 | REGULATOR_CHANGE_MODE
377 | REGULATOR_CHANGE_STATUS,
378 },
379 .num_consumer_supplies = 1,
380 .consumer_supplies = &sdp3430_vsim_supply,
381};
382
383/* VDAC for DSS driving S-Video */
384static struct regulator_init_data sdp3430_vdac = {
385 .constraints = {
386 .min_uV = 1800000,
387 .max_uV = 1800000,
388 .apply_uV = true,
389 .valid_modes_mask = REGULATOR_MODE_NORMAL
390 | REGULATOR_MODE_STANDBY,
391 .valid_ops_mask = REGULATOR_CHANGE_MODE
392 | REGULATOR_CHANGE_STATUS,
393 },
394 .num_consumer_supplies = 1,
395 .consumer_supplies = &sdp3430_vdac_supply,
396};
397
398/* VPLL2 for digital video outputs */
399static struct regulator_init_data sdp3430_vpll2 = {
400 .constraints = {
401 .name = "VDVI",
402 .min_uV = 1800000,
403 .max_uV = 1800000,
404 .valid_modes_mask = REGULATOR_MODE_NORMAL
405 | REGULATOR_MODE_STANDBY,
406 .valid_ops_mask = REGULATOR_CHANGE_MODE
407 | REGULATOR_CHANGE_STATUS,
408 },
409 .num_consumer_supplies = 1,
410 .consumer_supplies = &sdp3430_vdvi_supply,
411};
412
e86fa0b4
PU
413static struct twl4030_codec_audio_data sdp3430_audio = {
414 .audio_mclk = 26000000,
415};
416
417static struct twl4030_codec_data sdp3430_codec = {
6df74efb 418 .audio_mclk = 26000000,
e86fa0b4
PU
419 .audio = &sdp3430_audio,
420};
421
6fdc29e2
SMK
422static struct twl4030_platform_data sdp3430_twldata = {
423 .irq_base = TWL4030_IRQ_BASE,
424 .irq_end = TWL4030_IRQ_END,
425
426 /* platform_data for children goes here */
427 .bci = &sdp3430_bci_data,
428 .gpio = &sdp3430_gpio_data,
429 .madc = &sdp3430_madc_data,
430 .keypad = &sdp3430_kp_data,
431 .usb = &sdp3430_usb_data,
e86fa0b4 432 .codec = &sdp3430_codec,
6fdc29e2
SMK
433
434 .vaux1 = &sdp3430_vaux1,
435 .vaux2 = &sdp3430_vaux2,
436 .vaux3 = &sdp3430_vaux3,
437 .vaux4 = &sdp3430_vaux4,
438 .vmmc1 = &sdp3430_vmmc1,
439 .vmmc2 = &sdp3430_vmmc2,
440 .vsim = &sdp3430_vsim,
441 .vdac = &sdp3430_vdac,
442 .vpll2 = &sdp3430_vpll2,
443};
444
445static struct i2c_board_info __initdata sdp3430_i2c_boardinfo[] = {
446 {
447 I2C_BOARD_INFO("twl4030", 0x48),
448 .flags = I2C_CLIENT_WAKE,
449 .irq = INT_34XX_SYS_NIRQ,
450 .platform_data = &sdp3430_twldata,
451 },
452};
453
454static int __init omap3430_i2c_init(void)
455{
456 /* i2c1 for PMIC only */
457 omap_register_i2c_bus(1, 2600, sdp3430_i2c_boardinfo,
458 ARRAY_SIZE(sdp3430_i2c_boardinfo));
459 /* i2c2 on camera connector (for sensor control) and optional isp1301 */
460 omap_register_i2c_bus(2, 400, NULL, 0);
461 /* i2c3 on display connector (for DVI, tfp410) */
462 omap_register_i2c_bus(3, 400, NULL, 0);
463 return 0;
464}
465
1a48e157
TL
466#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
467
468static struct omap_smc91x_platform_data board_smc91x_data = {
469 .cs = 3,
470 .flags = GPMC_MUX_ADD_DATA | GPMC_TIMINGS_SMC91C96 |
471 IORESOURCE_IRQ_LOWLEVEL,
472};
473
474static void __init board_smc91x_init(void)
475{
476 if (omap_rev() > OMAP3430_REV_ES1_0)
477 board_smc91x_data.gpio_irq = 6;
478 else
479 board_smc91x_data.gpio_irq = 29;
480
481 gpmc_smc91x_init(&board_smc91x_data);
482}
483
484#else
485
486static inline void board_smc91x_init(void)
487{
488}
489
490#endif
491
5110b298
RT
492static void enable_board_wakeup_source(void)
493{
494 omap_cfg_reg(AF26_34XX_SYS_NIRQ); /* T2 interrupt line (keypad) */
495}
496
6fdc29e2
SMK
497static void __init omap_3430sdp_init(void)
498{
499 omap3430_i2c_init();
500 platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
6fdc29e2
SMK
501 if (omap_rev() > OMAP3430_REV_ES1_0)
502 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV2;
503 else
504 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV1;
505 sdp3430_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
506 spi_register_board_info(sdp3430_spi_board_info,
507 ARRAY_SIZE(sdp3430_spi_board_info));
508 ads7846_dev_init();
509 omap_serial_init();
510 usb_musb_init();
1a48e157 511 board_smc91x_init();
5110b298 512 enable_board_wakeup_source();
6fdc29e2
SMK
513}
514
515static void __init omap_3430sdp_map_io(void)
516{
517 omap2_set_globals_343x();
518 omap2_map_common_io();
519}
520
521MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
522 /* Maintainer: Syed Khasim - Texas Instruments Inc */
523 .phys_io = 0x48000000,
b4224b23 524 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
6fdc29e2
SMK
525 .boot_params = 0x80000100,
526 .map_io = omap_3430sdp_map_io,
527 .init_irq = omap_3430sdp_init_irq,
528 .init_machine = omap_3430sdp_init,
529 .timer = &omap_timer,
530MACHINE_END
This page took 0.141894 seconds and 5 git commands to generate.