davinci: da850/omap-l138: unlock PLL registers during init
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-omap2 / board-3430sdp.c
blobc90b0d0b1927e58911dad6d7bfe593b712323557
1 /*
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/input/matrix_keypad.h>
21 #include <linux/spi/spi.h>
22 #include <linux/spi/ads7846.h>
23 #include <linux/i2c/twl.h>
24 #include <linux/regulator/machine.h>
25 #include <linux/io.h>
26 #include <linux/gpio.h>
28 #include <mach/hardware.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
33 #include <plat/mcspi.h>
34 #include <plat/board.h>
35 #include <plat/usb.h>
36 #include <plat/common.h>
37 #include <plat/dma.h>
38 #include <plat/gpmc.h>
39 #include <plat/display.h>
41 #include <plat/control.h>
42 #include <plat/gpmc-smc91x.h>
44 #include "mux.h"
45 #include "sdram-qimonda-hyb18m512160af-6.h"
46 #include "mmc-twl4030.h"
48 #define CONFIG_DISABLE_HFCLK 1
50 #define SDP3430_TS_GPIO_IRQ_SDPV1 3
51 #define SDP3430_TS_GPIO_IRQ_SDPV2 2
53 #define ENABLE_VAUX3_DEDICATED 0x03
54 #define ENABLE_VAUX3_DEV_GRP 0x20
56 #define TWL4030_MSECURE_GPIO 22
58 static int board_keymap[] = {
59 KEY(0, 0, KEY_LEFT),
60 KEY(0, 1, KEY_RIGHT),
61 KEY(0, 2, KEY_A),
62 KEY(0, 3, KEY_B),
63 KEY(0, 4, KEY_C),
64 KEY(1, 0, KEY_DOWN),
65 KEY(1, 1, KEY_UP),
66 KEY(1, 2, KEY_E),
67 KEY(1, 3, KEY_F),
68 KEY(1, 4, KEY_G),
69 KEY(2, 0, KEY_ENTER),
70 KEY(2, 1, KEY_I),
71 KEY(2, 2, KEY_J),
72 KEY(2, 3, KEY_K),
73 KEY(2, 4, KEY_3),
74 KEY(3, 0, KEY_M),
75 KEY(3, 1, KEY_N),
76 KEY(3, 2, KEY_O),
77 KEY(3, 3, KEY_P),
78 KEY(3, 4, KEY_Q),
79 KEY(4, 0, KEY_R),
80 KEY(4, 1, KEY_4),
81 KEY(4, 2, KEY_T),
82 KEY(4, 3, KEY_U),
83 KEY(4, 4, KEY_D),
84 KEY(5, 0, KEY_V),
85 KEY(5, 1, KEY_W),
86 KEY(5, 2, KEY_L),
87 KEY(5, 3, KEY_S),
88 KEY(5, 4, KEY_H),
92 static struct matrix_keymap_data board_map_data = {
93 .keymap = board_keymap,
94 .keymap_size = ARRAY_SIZE(board_keymap),
97 static struct twl4030_keypad_data sdp3430_kp_data = {
98 .keymap_data = &board_map_data,
99 .rows = 5,
100 .cols = 6,
101 .rep = 1,
104 static int ts_gpio; /* Needed for ads7846_get_pendown_state */
107 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
109 * @return - void. If request gpio fails then Flag KERN_ERR.
111 static void ads7846_dev_init(void)
113 if (gpio_request(ts_gpio, "ADS7846 pendown") < 0) {
114 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
115 return;
118 gpio_direction_input(ts_gpio);
120 omap_set_gpio_debounce(ts_gpio, 1);
121 omap_set_gpio_debounce_time(ts_gpio, 0xa);
124 static int ads7846_get_pendown_state(void)
126 return !gpio_get_value(ts_gpio);
129 static struct ads7846_platform_data tsc2046_config __initdata = {
130 .get_pendown_state = ads7846_get_pendown_state,
131 .keep_vref_on = 1,
135 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
136 .turbo_mode = 0,
137 .single_channel = 1, /* 0: slave, 1: master */
140 static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
141 [0] = {
143 * TSC2046 operates at a max freqency of 2MHz, so
144 * operate slightly below at 1.5MHz
146 .modalias = "ads7846",
147 .bus_num = 1,
148 .chip_select = 0,
149 .max_speed_hz = 1500000,
150 .controller_data = &tsc2046_mcspi_config,
151 .irq = 0,
152 .platform_data = &tsc2046_config,
157 #define SDP3430_LCD_PANEL_BACKLIGHT_GPIO 8
158 #define SDP3430_LCD_PANEL_ENABLE_GPIO 5
160 static unsigned backlight_gpio;
161 static unsigned enable_gpio;
162 static int lcd_enabled;
163 static int dvi_enabled;
165 static void __init sdp3430_display_init(void)
167 int r;
169 enable_gpio = SDP3430_LCD_PANEL_ENABLE_GPIO;
170 backlight_gpio = SDP3430_LCD_PANEL_BACKLIGHT_GPIO;
172 r = gpio_request(enable_gpio, "LCD reset");
173 if (r) {
174 printk(KERN_ERR "failed to get LCD reset GPIO\n");
175 goto err0;
178 r = gpio_request(backlight_gpio, "LCD Backlight");
179 if (r) {
180 printk(KERN_ERR "failed to get LCD backlight GPIO\n");
181 goto err1;
184 gpio_direction_output(enable_gpio, 0);
185 gpio_direction_output(backlight_gpio, 0);
187 return;
188 err1:
189 gpio_free(enable_gpio);
190 err0:
191 return;
194 static int sdp3430_panel_enable_lcd(struct omap_dss_device *dssdev)
196 if (dvi_enabled) {
197 printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
198 return -EINVAL;
201 gpio_direction_output(enable_gpio, 1);
202 gpio_direction_output(backlight_gpio, 1);
204 lcd_enabled = 1;
206 return 0;
209 static void sdp3430_panel_disable_lcd(struct omap_dss_device *dssdev)
211 lcd_enabled = 0;
213 gpio_direction_output(enable_gpio, 0);
214 gpio_direction_output(backlight_gpio, 0);
217 static int sdp3430_panel_enable_dvi(struct omap_dss_device *dssdev)
219 if (lcd_enabled) {
220 printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
221 return -EINVAL;
224 dvi_enabled = 1;
226 return 0;
229 static void sdp3430_panel_disable_dvi(struct omap_dss_device *dssdev)
231 dvi_enabled = 0;
234 static int sdp3430_panel_enable_tv(struct omap_dss_device *dssdev)
236 return 0;
239 static void sdp3430_panel_disable_tv(struct omap_dss_device *dssdev)
244 static struct omap_dss_device sdp3430_lcd_device = {
245 .name = "lcd",
246 .driver_name = "sharp_ls_panel",
247 .type = OMAP_DISPLAY_TYPE_DPI,
248 .phy.dpi.data_lines = 16,
249 .platform_enable = sdp3430_panel_enable_lcd,
250 .platform_disable = sdp3430_panel_disable_lcd,
253 static struct omap_dss_device sdp3430_dvi_device = {
254 .name = "dvi",
255 .driver_name = "generic_panel",
256 .type = OMAP_DISPLAY_TYPE_DPI,
257 .phy.dpi.data_lines = 24,
258 .platform_enable = sdp3430_panel_enable_dvi,
259 .platform_disable = sdp3430_panel_disable_dvi,
262 static struct omap_dss_device sdp3430_tv_device = {
263 .name = "tv",
264 .driver_name = "venc",
265 .type = OMAP_DISPLAY_TYPE_VENC,
266 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
267 .platform_enable = sdp3430_panel_enable_tv,
268 .platform_disable = sdp3430_panel_disable_tv,
272 static struct omap_dss_device *sdp3430_dss_devices[] = {
273 &sdp3430_lcd_device,
274 &sdp3430_dvi_device,
275 &sdp3430_tv_device,
278 static struct omap_dss_board_info sdp3430_dss_data = {
279 .num_devices = ARRAY_SIZE(sdp3430_dss_devices),
280 .devices = sdp3430_dss_devices,
281 .default_device = &sdp3430_lcd_device,
284 static struct platform_device sdp3430_dss_device = {
285 .name = "omapdss",
286 .id = -1,
287 .dev = {
288 .platform_data = &sdp3430_dss_data,
292 static struct regulator_consumer_supply sdp3430_vdda_dac_supply = {
293 .supply = "vdda_dac",
294 .dev = &sdp3430_dss_device.dev,
297 static struct platform_device *sdp3430_devices[] __initdata = {
298 &sdp3430_dss_device,
301 static struct omap_board_config_kernel sdp3430_config[] __initdata = {
304 static void __init omap_3430sdp_init_irq(void)
306 omap_board_config = sdp3430_config;
307 omap_board_config_size = ARRAY_SIZE(sdp3430_config);
308 omap2_init_common_hw(hyb18m512160af6_sdrc_params, NULL);
309 omap_init_irq();
310 omap_gpio_init();
313 static int sdp3430_batt_table[] = {
314 /* 0 C*/
315 30800, 29500, 28300, 27100,
316 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
317 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
318 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
319 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
320 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
321 4040, 3910, 3790, 3670, 3550
324 static struct twl4030_bci_platform_data sdp3430_bci_data = {
325 .battery_tmp_tbl = sdp3430_batt_table,
326 .tblsize = ARRAY_SIZE(sdp3430_batt_table),
329 static struct twl4030_hsmmc_info mmc[] = {
331 .mmc = 1,
332 /* 8 bits (default) requires S6.3 == ON,
333 * so the SIM card isn't used; else 4 bits.
335 .wires = 8,
336 .gpio_wp = 4,
339 .mmc = 2,
340 .wires = 8,
341 .gpio_wp = 7,
343 {} /* Terminator */
346 static struct regulator_consumer_supply sdp3430_vmmc1_supply = {
347 .supply = "vmmc",
350 static struct regulator_consumer_supply sdp3430_vsim_supply = {
351 .supply = "vmmc_aux",
354 static struct regulator_consumer_supply sdp3430_vmmc2_supply = {
355 .supply = "vmmc",
358 static int sdp3430_twl_gpio_setup(struct device *dev,
359 unsigned gpio, unsigned ngpio)
361 /* gpio + 0 is "mmc0_cd" (input/IRQ),
362 * gpio + 1 is "mmc1_cd" (input/IRQ)
364 mmc[0].gpio_cd = gpio + 0;
365 mmc[1].gpio_cd = gpio + 1;
366 twl4030_mmc_init(mmc);
368 /* link regulators to MMC adapters ... we "know" the
369 * regulators will be set up only *after* we return.
371 sdp3430_vmmc1_supply.dev = mmc[0].dev;
372 sdp3430_vsim_supply.dev = mmc[0].dev;
373 sdp3430_vmmc2_supply.dev = mmc[1].dev;
375 /* gpio + 7 is "sub_lcd_en_bkl" (output/PWM1) */
376 gpio_request(gpio + 7, "sub_lcd_en_bkl");
377 gpio_direction_output(gpio + 7, 0);
379 /* gpio + 15 is "sub_lcd_nRST" (output) */
380 gpio_request(gpio + 15, "sub_lcd_nRST");
381 gpio_direction_output(gpio + 15, 0);
383 return 0;
386 static struct twl4030_gpio_platform_data sdp3430_gpio_data = {
387 .gpio_base = OMAP_MAX_GPIO_LINES,
388 .irq_base = TWL4030_GPIO_IRQ_BASE,
389 .irq_end = TWL4030_GPIO_IRQ_END,
390 .pulldowns = BIT(2) | BIT(6) | BIT(8) | BIT(13)
391 | BIT(16) | BIT(17),
392 .setup = sdp3430_twl_gpio_setup,
395 static struct twl4030_usb_data sdp3430_usb_data = {
396 .usb_mode = T2_USB_MODE_ULPI,
399 static struct twl4030_madc_platform_data sdp3430_madc_data = {
400 .irq_line = 1,
404 * Apply all the fixed voltages since most versions of U-Boot
405 * don't bother with that initialization.
408 /* VAUX1 for mainboard (irda and sub-lcd) */
409 static struct regulator_init_data sdp3430_vaux1 = {
410 .constraints = {
411 .min_uV = 2800000,
412 .max_uV = 2800000,
413 .apply_uV = true,
414 .valid_modes_mask = REGULATOR_MODE_NORMAL
415 | REGULATOR_MODE_STANDBY,
416 .valid_ops_mask = REGULATOR_CHANGE_MODE
417 | REGULATOR_CHANGE_STATUS,
421 /* VAUX2 for camera module */
422 static struct regulator_init_data sdp3430_vaux2 = {
423 .constraints = {
424 .min_uV = 2800000,
425 .max_uV = 2800000,
426 .apply_uV = true,
427 .valid_modes_mask = REGULATOR_MODE_NORMAL
428 | REGULATOR_MODE_STANDBY,
429 .valid_ops_mask = REGULATOR_CHANGE_MODE
430 | REGULATOR_CHANGE_STATUS,
434 /* VAUX3 for LCD board */
435 static struct regulator_init_data sdp3430_vaux3 = {
436 .constraints = {
437 .min_uV = 2800000,
438 .max_uV = 2800000,
439 .apply_uV = true,
440 .valid_modes_mask = REGULATOR_MODE_NORMAL
441 | REGULATOR_MODE_STANDBY,
442 .valid_ops_mask = REGULATOR_CHANGE_MODE
443 | REGULATOR_CHANGE_STATUS,
447 /* VAUX4 for OMAP VDD_CSI2 (camera) */
448 static struct regulator_init_data sdp3430_vaux4 = {
449 .constraints = {
450 .min_uV = 1800000,
451 .max_uV = 1800000,
452 .apply_uV = true,
453 .valid_modes_mask = REGULATOR_MODE_NORMAL
454 | REGULATOR_MODE_STANDBY,
455 .valid_ops_mask = REGULATOR_CHANGE_MODE
456 | REGULATOR_CHANGE_STATUS,
460 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
461 static struct regulator_init_data sdp3430_vmmc1 = {
462 .constraints = {
463 .min_uV = 1850000,
464 .max_uV = 3150000,
465 .valid_modes_mask = REGULATOR_MODE_NORMAL
466 | REGULATOR_MODE_STANDBY,
467 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
468 | REGULATOR_CHANGE_MODE
469 | REGULATOR_CHANGE_STATUS,
471 .num_consumer_supplies = 1,
472 .consumer_supplies = &sdp3430_vmmc1_supply,
475 /* VMMC2 for MMC2 card */
476 static struct regulator_init_data sdp3430_vmmc2 = {
477 .constraints = {
478 .min_uV = 1850000,
479 .max_uV = 1850000,
480 .apply_uV = true,
481 .valid_modes_mask = REGULATOR_MODE_NORMAL
482 | REGULATOR_MODE_STANDBY,
483 .valid_ops_mask = REGULATOR_CHANGE_MODE
484 | REGULATOR_CHANGE_STATUS,
486 .num_consumer_supplies = 1,
487 .consumer_supplies = &sdp3430_vmmc2_supply,
490 /* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
491 static struct regulator_init_data sdp3430_vsim = {
492 .constraints = {
493 .min_uV = 1800000,
494 .max_uV = 3000000,
495 .valid_modes_mask = REGULATOR_MODE_NORMAL
496 | REGULATOR_MODE_STANDBY,
497 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
498 | REGULATOR_CHANGE_MODE
499 | REGULATOR_CHANGE_STATUS,
501 .num_consumer_supplies = 1,
502 .consumer_supplies = &sdp3430_vsim_supply,
505 /* VDAC for DSS driving S-Video */
506 static struct regulator_init_data sdp3430_vdac = {
507 .constraints = {
508 .min_uV = 1800000,
509 .max_uV = 1800000,
510 .apply_uV = true,
511 .valid_modes_mask = REGULATOR_MODE_NORMAL
512 | REGULATOR_MODE_STANDBY,
513 .valid_ops_mask = REGULATOR_CHANGE_MODE
514 | REGULATOR_CHANGE_STATUS,
516 .num_consumer_supplies = 1,
517 .consumer_supplies = &sdp3430_vdda_dac_supply,
520 /* VPLL2 for digital video outputs */
521 static struct regulator_consumer_supply sdp3430_vpll2_supplies[] = {
523 .supply = "vdvi",
524 .dev = &sdp3430_lcd_device.dev,
527 .supply = "vdds_dsi",
528 .dev = &sdp3430_dss_device.dev,
532 static struct regulator_init_data sdp3430_vpll2 = {
533 .constraints = {
534 .name = "VDVI",
535 .min_uV = 1800000,
536 .max_uV = 1800000,
537 .apply_uV = true,
538 .valid_modes_mask = REGULATOR_MODE_NORMAL
539 | REGULATOR_MODE_STANDBY,
540 .valid_ops_mask = REGULATOR_CHANGE_MODE
541 | REGULATOR_CHANGE_STATUS,
543 .num_consumer_supplies = ARRAY_SIZE(sdp3430_vpll2_supplies),
544 .consumer_supplies = sdp3430_vpll2_supplies,
547 static struct twl4030_codec_audio_data sdp3430_audio = {
548 .audio_mclk = 26000000,
551 static struct twl4030_codec_data sdp3430_codec = {
552 .audio_mclk = 26000000,
553 .audio = &sdp3430_audio,
556 static struct twl4030_platform_data sdp3430_twldata = {
557 .irq_base = TWL4030_IRQ_BASE,
558 .irq_end = TWL4030_IRQ_END,
560 /* platform_data for children goes here */
561 .bci = &sdp3430_bci_data,
562 .gpio = &sdp3430_gpio_data,
563 .madc = &sdp3430_madc_data,
564 .keypad = &sdp3430_kp_data,
565 .usb = &sdp3430_usb_data,
566 .codec = &sdp3430_codec,
568 .vaux1 = &sdp3430_vaux1,
569 .vaux2 = &sdp3430_vaux2,
570 .vaux3 = &sdp3430_vaux3,
571 .vaux4 = &sdp3430_vaux4,
572 .vmmc1 = &sdp3430_vmmc1,
573 .vmmc2 = &sdp3430_vmmc2,
574 .vsim = &sdp3430_vsim,
575 .vdac = &sdp3430_vdac,
576 .vpll2 = &sdp3430_vpll2,
579 static struct i2c_board_info __initdata sdp3430_i2c_boardinfo[] = {
581 I2C_BOARD_INFO("twl4030", 0x48),
582 .flags = I2C_CLIENT_WAKE,
583 .irq = INT_34XX_SYS_NIRQ,
584 .platform_data = &sdp3430_twldata,
588 static int __init omap3430_i2c_init(void)
590 /* i2c1 for PMIC only */
591 omap_register_i2c_bus(1, 2600, sdp3430_i2c_boardinfo,
592 ARRAY_SIZE(sdp3430_i2c_boardinfo));
593 /* i2c2 on camera connector (for sensor control) and optional isp1301 */
594 omap_register_i2c_bus(2, 400, NULL, 0);
595 /* i2c3 on display connector (for DVI, tfp410) */
596 omap_register_i2c_bus(3, 400, NULL, 0);
597 return 0;
600 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
602 static struct omap_smc91x_platform_data board_smc91x_data = {
603 .cs = 3,
604 .flags = GPMC_MUX_ADD_DATA | GPMC_TIMINGS_SMC91C96 |
605 IORESOURCE_IRQ_LOWLEVEL,
608 static void __init board_smc91x_init(void)
610 if (omap_rev() > OMAP3430_REV_ES1_0)
611 board_smc91x_data.gpio_irq = 6;
612 else
613 board_smc91x_data.gpio_irq = 29;
615 gpmc_smc91x_init(&board_smc91x_data);
618 #else
620 static inline void board_smc91x_init(void)
624 #endif
626 static void enable_board_wakeup_source(void)
628 /* T2 interrupt line (keypad) */
629 omap_mux_init_signal("sys_nirq",
630 OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
633 static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
635 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
636 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
637 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
639 .phy_reset = true,
640 .reset_gpio_port[0] = 57,
641 .reset_gpio_port[1] = 61,
642 .reset_gpio_port[2] = -EINVAL
645 #ifdef CONFIG_OMAP_MUX
646 static struct omap_board_mux board_mux[] __initdata = {
647 { .reg_offset = OMAP_MUX_TERMINATOR },
649 #else
650 #define board_mux NULL
651 #endif
653 static void __init omap_3430sdp_init(void)
655 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
656 omap3430_i2c_init();
657 platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
658 if (omap_rev() > OMAP3430_REV_ES1_0)
659 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV2;
660 else
661 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV1;
662 sdp3430_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
663 spi_register_board_info(sdp3430_spi_board_info,
664 ARRAY_SIZE(sdp3430_spi_board_info));
665 ads7846_dev_init();
666 omap_serial_init();
667 usb_musb_init();
668 board_smc91x_init();
669 sdp3430_display_init();
670 enable_board_wakeup_source();
671 usb_ehci_init(&ehci_pdata);
674 static void __init omap_3430sdp_map_io(void)
676 omap2_set_globals_343x();
677 omap2_map_common_io();
680 MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
681 /* Maintainer: Syed Khasim - Texas Instruments Inc */
682 .phys_io = 0x48000000,
683 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
684 .boot_params = 0x80000100,
685 .map_io = omap_3430sdp_map_io,
686 .init_irq = omap_3430sdp_init_irq,
687 .init_machine = omap_3430sdp_init,
688 .timer = &omap_timer,
689 MACHINE_END