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/twl4030.h>
24 #include <linux/regulator/machine.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>
35 #include <plat/board.h>
37 #include <plat/common.h>
39 #include <plat/gpmc.h>
40 #include <plat/display.h>
42 #include <plat/control.h>
43 #include <plat/gpmc-smc91x.h>
46 #include "sdram-qimonda-hyb18m512160af-6.h"
47 #include "mmc-twl4030.h"
49 #define CONFIG_DISABLE_HFCLK 1
51 #define SDP3430_TS_GPIO_IRQ_SDPV1 3
52 #define SDP3430_TS_GPIO_IRQ_SDPV2 2
54 #define ENABLE_VAUX3_DEDICATED 0x03
55 #define ENABLE_VAUX3_DEV_GRP 0x20
57 #define TWL4030_MSECURE_GPIO 22
59 static int board_keymap[] = {
93 static struct matrix_keymap_data board_map_data = {
94 .keymap = board_keymap,
95 .keymap_size = ARRAY_SIZE(board_keymap),
98 static struct twl4030_keypad_data sdp3430_kp_data = {
99 .keymap_data = &board_map_data,
105 static int ts_gpio; /* Needed for ads7846_get_pendown_state */
108 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
110 * @return - void. If request gpio fails then Flag KERN_ERR.
112 static void ads7846_dev_init(void)
114 if (gpio_request(ts_gpio, "ADS7846 pendown") < 0) {
115 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
119 gpio_direction_input(ts_gpio);
121 omap_set_gpio_debounce(ts_gpio, 1);
122 omap_set_gpio_debounce_time(ts_gpio, 0xa);
125 static int ads7846_get_pendown_state(void)
127 return !gpio_get_value(ts_gpio);
130 static struct ads7846_platform_data tsc2046_config __initdata = {
131 .get_pendown_state = ads7846_get_pendown_state,
136 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
138 .single_channel = 1, /* 0: slave, 1: master */
141 static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
144 * TSC2046 operates at a max freqency of 2MHz, so
145 * operate slightly below at 1.5MHz
147 .modalias = "ads7846",
150 .max_speed_hz = 1500000,
151 .controller_data = &tsc2046_mcspi_config,
153 .platform_data = &tsc2046_config,
158 #define SDP3430_LCD_PANEL_BACKLIGHT_GPIO 8
159 #define SDP3430_LCD_PANEL_ENABLE_GPIO 5
161 static unsigned backlight_gpio;
162 static unsigned enable_gpio;
163 static int lcd_enabled;
164 static int dvi_enabled;
166 static void __init sdp3430_display_init(void)
170 enable_gpio = SDP3430_LCD_PANEL_ENABLE_GPIO;
171 backlight_gpio = SDP3430_LCD_PANEL_BACKLIGHT_GPIO;
173 r = gpio_request(enable_gpio, "LCD reset");
175 printk(KERN_ERR "failed to get LCD reset GPIO\n");
179 r = gpio_request(backlight_gpio, "LCD Backlight");
181 printk(KERN_ERR "failed to get LCD backlight GPIO\n");
185 gpio_direction_output(enable_gpio, 0);
186 gpio_direction_output(backlight_gpio, 0);
190 gpio_free(enable_gpio);
195 static int sdp3430_panel_enable_lcd(struct omap_dss_device *dssdev)
198 printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
202 gpio_direction_output(enable_gpio, 1);
203 gpio_direction_output(backlight_gpio, 1);
210 static void sdp3430_panel_disable_lcd(struct omap_dss_device *dssdev)
214 gpio_direction_output(enable_gpio, 0);
215 gpio_direction_output(backlight_gpio, 0);
218 static int sdp3430_panel_enable_dvi(struct omap_dss_device *dssdev)
221 printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
230 static void sdp3430_panel_disable_dvi(struct omap_dss_device *dssdev)
235 static int sdp3430_panel_enable_tv(struct omap_dss_device *dssdev)
240 static void sdp3430_panel_disable_tv(struct omap_dss_device *dssdev)
245 static struct omap_dss_device sdp3430_lcd_device = {
247 .driver_name = "sharp_ls_panel",
248 .type = OMAP_DISPLAY_TYPE_DPI,
249 .phy.dpi.data_lines = 16,
250 .platform_enable = sdp3430_panel_enable_lcd,
251 .platform_disable = sdp3430_panel_disable_lcd,
254 static struct omap_dss_device sdp3430_dvi_device = {
256 .driver_name = "generic_panel",
257 .type = OMAP_DISPLAY_TYPE_DPI,
258 .phy.dpi.data_lines = 24,
259 .platform_enable = sdp3430_panel_enable_dvi,
260 .platform_disable = sdp3430_panel_disable_dvi,
263 static struct omap_dss_device sdp3430_tv_device = {
265 .driver_name = "venc",
266 .type = OMAP_DISPLAY_TYPE_VENC,
267 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
268 .platform_enable = sdp3430_panel_enable_tv,
269 .platform_disable = sdp3430_panel_disable_tv,
273 static struct omap_dss_device *sdp3430_dss_devices[] = {
279 static struct omap_dss_board_info sdp3430_dss_data = {
280 .num_devices = ARRAY_SIZE(sdp3430_dss_devices),
281 .devices = sdp3430_dss_devices,
282 .default_device = &sdp3430_lcd_device,
285 static struct platform_device sdp3430_dss_device = {
289 .platform_data = &sdp3430_dss_data,
293 static struct regulator_consumer_supply sdp3430_vdda_dac_supply = {
294 .supply = "vdda_dac",
295 .dev = &sdp3430_dss_device.dev,
298 static struct platform_device *sdp3430_devices[] __initdata = {
302 static struct omap_board_config_kernel sdp3430_config[] __initdata = {
305 static void __init omap_3430sdp_init_irq(void)
307 omap_board_config = sdp3430_config;
308 omap_board_config_size = ARRAY_SIZE(sdp3430_config);
309 omap2_init_common_hw(hyb18m512160af6_sdrc_params, NULL);
314 static int sdp3430_batt_table[] = {
316 30800, 29500, 28300, 27100,
317 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
318 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
319 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
320 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
321 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
322 4040, 3910, 3790, 3670, 3550
325 static struct twl4030_bci_platform_data sdp3430_bci_data = {
326 .battery_tmp_tbl = sdp3430_batt_table,
327 .tblsize = ARRAY_SIZE(sdp3430_batt_table),
330 static struct twl4030_hsmmc_info mmc[] = {
333 /* 8 bits (default) requires S6.3 == ON,
334 * so the SIM card isn't used; else 4 bits.
347 static struct regulator_consumer_supply sdp3430_vmmc1_supply = {
351 static struct regulator_consumer_supply sdp3430_vsim_supply = {
352 .supply = "vmmc_aux",
355 static struct regulator_consumer_supply sdp3430_vmmc2_supply = {
359 static int sdp3430_twl_gpio_setup(struct device *dev,
360 unsigned gpio, unsigned ngpio)
362 /* gpio + 0 is "mmc0_cd" (input/IRQ),
363 * gpio + 1 is "mmc1_cd" (input/IRQ)
365 mmc[0].gpio_cd = gpio + 0;
366 mmc[1].gpio_cd = gpio + 1;
367 twl4030_mmc_init(mmc);
369 /* link regulators to MMC adapters ... we "know" the
370 * regulators will be set up only *after* we return.
372 sdp3430_vmmc1_supply.dev = mmc[0].dev;
373 sdp3430_vsim_supply.dev = mmc[0].dev;
374 sdp3430_vmmc2_supply.dev = mmc[1].dev;
376 /* gpio + 7 is "sub_lcd_en_bkl" (output/PWM1) */
377 gpio_request(gpio + 7, "sub_lcd_en_bkl");
378 gpio_direction_output(gpio + 7, 0);
380 /* gpio + 15 is "sub_lcd_nRST" (output) */
381 gpio_request(gpio + 15, "sub_lcd_nRST");
382 gpio_direction_output(gpio + 15, 0);
387 static struct twl4030_gpio_platform_data sdp3430_gpio_data = {
388 .gpio_base = OMAP_MAX_GPIO_LINES,
389 .irq_base = TWL4030_GPIO_IRQ_BASE,
390 .irq_end = TWL4030_GPIO_IRQ_END,
391 .pulldowns = BIT(2) | BIT(6) | BIT(8) | BIT(13)
393 .setup = sdp3430_twl_gpio_setup,
396 static struct twl4030_usb_data sdp3430_usb_data = {
397 .usb_mode = T2_USB_MODE_ULPI,
400 static struct twl4030_madc_platform_data sdp3430_madc_data = {
405 * Apply all the fixed voltages since most versions of U-Boot
406 * don't bother with that initialization.
409 /* VAUX1 for mainboard (irda and sub-lcd) */
410 static struct regulator_init_data sdp3430_vaux1 = {
415 .valid_modes_mask = REGULATOR_MODE_NORMAL
416 | REGULATOR_MODE_STANDBY,
417 .valid_ops_mask = REGULATOR_CHANGE_MODE
418 | REGULATOR_CHANGE_STATUS,
422 /* VAUX2 for camera module */
423 static struct regulator_init_data sdp3430_vaux2 = {
428 .valid_modes_mask = REGULATOR_MODE_NORMAL
429 | REGULATOR_MODE_STANDBY,
430 .valid_ops_mask = REGULATOR_CHANGE_MODE
431 | REGULATOR_CHANGE_STATUS,
435 /* VAUX3 for LCD board */
436 static struct regulator_init_data sdp3430_vaux3 = {
441 .valid_modes_mask = REGULATOR_MODE_NORMAL
442 | REGULATOR_MODE_STANDBY,
443 .valid_ops_mask = REGULATOR_CHANGE_MODE
444 | REGULATOR_CHANGE_STATUS,
448 /* VAUX4 for OMAP VDD_CSI2 (camera) */
449 static struct regulator_init_data sdp3430_vaux4 = {
454 .valid_modes_mask = REGULATOR_MODE_NORMAL
455 | REGULATOR_MODE_STANDBY,
456 .valid_ops_mask = REGULATOR_CHANGE_MODE
457 | REGULATOR_CHANGE_STATUS,
461 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
462 static struct regulator_init_data sdp3430_vmmc1 = {
466 .valid_modes_mask = REGULATOR_MODE_NORMAL
467 | REGULATOR_MODE_STANDBY,
468 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
469 | REGULATOR_CHANGE_MODE
470 | REGULATOR_CHANGE_STATUS,
472 .num_consumer_supplies = 1,
473 .consumer_supplies = &sdp3430_vmmc1_supply,
476 /* VMMC2 for MMC2 card */
477 static struct regulator_init_data sdp3430_vmmc2 = {
482 .valid_modes_mask = REGULATOR_MODE_NORMAL
483 | REGULATOR_MODE_STANDBY,
484 .valid_ops_mask = REGULATOR_CHANGE_MODE
485 | REGULATOR_CHANGE_STATUS,
487 .num_consumer_supplies = 1,
488 .consumer_supplies = &sdp3430_vmmc2_supply,
491 /* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
492 static struct regulator_init_data sdp3430_vsim = {
496 .valid_modes_mask = REGULATOR_MODE_NORMAL
497 | REGULATOR_MODE_STANDBY,
498 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
499 | REGULATOR_CHANGE_MODE
500 | REGULATOR_CHANGE_STATUS,
502 .num_consumer_supplies = 1,
503 .consumer_supplies = &sdp3430_vsim_supply,
506 /* VDAC for DSS driving S-Video */
507 static struct regulator_init_data sdp3430_vdac = {
512 .valid_modes_mask = REGULATOR_MODE_NORMAL
513 | REGULATOR_MODE_STANDBY,
514 .valid_ops_mask = REGULATOR_CHANGE_MODE
515 | REGULATOR_CHANGE_STATUS,
517 .num_consumer_supplies = 1,
518 .consumer_supplies = &sdp3430_vdda_dac_supply,
521 /* VPLL2 for digital video outputs */
522 static struct regulator_consumer_supply sdp3430_vpll2_supplies[] = {
525 .dev = &sdp3430_lcd_device.dev,
528 .supply = "vdds_dsi",
529 .dev = &sdp3430_dss_device.dev,
533 static struct regulator_init_data sdp3430_vpll2 = {
539 .valid_modes_mask = REGULATOR_MODE_NORMAL
540 | REGULATOR_MODE_STANDBY,
541 .valid_ops_mask = REGULATOR_CHANGE_MODE
542 | REGULATOR_CHANGE_STATUS,
544 .num_consumer_supplies = ARRAY_SIZE(sdp3430_vpll2_supplies),
545 .consumer_supplies = sdp3430_vpll2_supplies,
548 static struct twl4030_codec_audio_data sdp3430_audio = {
549 .audio_mclk = 26000000,
552 static struct twl4030_codec_data sdp3430_codec = {
553 .audio_mclk = 26000000,
554 .audio = &sdp3430_audio,
557 static struct twl4030_platform_data sdp3430_twldata = {
558 .irq_base = TWL4030_IRQ_BASE,
559 .irq_end = TWL4030_IRQ_END,
561 /* platform_data for children goes here */
562 .bci = &sdp3430_bci_data,
563 .gpio = &sdp3430_gpio_data,
564 .madc = &sdp3430_madc_data,
565 .keypad = &sdp3430_kp_data,
566 .usb = &sdp3430_usb_data,
567 .codec = &sdp3430_codec,
569 .vaux1 = &sdp3430_vaux1,
570 .vaux2 = &sdp3430_vaux2,
571 .vaux3 = &sdp3430_vaux3,
572 .vaux4 = &sdp3430_vaux4,
573 .vmmc1 = &sdp3430_vmmc1,
574 .vmmc2 = &sdp3430_vmmc2,
575 .vsim = &sdp3430_vsim,
576 .vdac = &sdp3430_vdac,
577 .vpll2 = &sdp3430_vpll2,
580 static struct i2c_board_info __initdata sdp3430_i2c_boardinfo[] = {
582 I2C_BOARD_INFO("twl4030", 0x48),
583 .flags = I2C_CLIENT_WAKE,
584 .irq = INT_34XX_SYS_NIRQ,
585 .platform_data = &sdp3430_twldata,
589 static int __init omap3430_i2c_init(void)
591 /* i2c1 for PMIC only */
592 omap_register_i2c_bus(1, 2600, sdp3430_i2c_boardinfo,
593 ARRAY_SIZE(sdp3430_i2c_boardinfo));
594 /* i2c2 on camera connector (for sensor control) and optional isp1301 */
595 omap_register_i2c_bus(2, 400, NULL, 0);
596 /* i2c3 on display connector (for DVI, tfp410) */
597 omap_register_i2c_bus(3, 400, NULL, 0);
601 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
603 static struct omap_smc91x_platform_data board_smc91x_data = {
605 .flags = GPMC_MUX_ADD_DATA | GPMC_TIMINGS_SMC91C96 |
606 IORESOURCE_IRQ_LOWLEVEL,
609 static void __init board_smc91x_init(void)
611 if (omap_rev() > OMAP3430_REV_ES1_0)
612 board_smc91x_data.gpio_irq = 6;
614 board_smc91x_data.gpio_irq = 29;
616 gpmc_smc91x_init(&board_smc91x_data);
621 static inline void board_smc91x_init(void)
627 static void enable_board_wakeup_source(void)
629 /* T2 interrupt line (keypad) */
630 omap_mux_init_signal("sys_nirq",
631 OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
634 static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
636 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
637 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
638 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
641 .reset_gpio_port[0] = 57,
642 .reset_gpio_port[1] = 61,
643 .reset_gpio_port[2] = -EINVAL
646 #ifdef CONFIG_OMAP_MUX
647 static struct omap_board_mux board_mux[] __initdata = {
648 { .reg_offset = OMAP_MUX_TERMINATOR },
651 #define board_mux NULL
654 static void __init omap_3430sdp_init(void)
656 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
658 platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
659 if (omap_rev() > OMAP3430_REV_ES1_0)
660 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV2;
662 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV1;
663 sdp3430_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
664 spi_register_board_info(sdp3430_spi_board_info,
665 ARRAY_SIZE(sdp3430_spi_board_info));
670 sdp3430_display_init();
671 enable_board_wakeup_source();
672 usb_ehci_init(&ehci_pdata);
675 static void __init omap_3430sdp_map_io(void)
677 omap2_set_globals_343x();
678 omap2_map_common_io();
681 MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
682 /* Maintainer: Syed Khasim - Texas Instruments Inc */
683 .phys_io = 0x48000000,
684 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
685 .boot_params = 0x80000100,
686 .map_io = omap_3430sdp_map_io,
687 .init_irq = omap_3430sdp_init_irq,
688 .init_machine = omap_3430sdp_init,
689 .timer = &omap_timer,