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>
26 #include <linux/gpio.h>
27 #include <linux/mmc/host.h>
29 #include <mach/hardware.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
34 #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/gpmc-smc91x.h>
44 #include "board-flash.h"
46 #include "sdram-qimonda-hyb18m512160af-6.h"
51 #define CONFIG_DISABLE_HFCLK 1
53 #define SDP3430_TS_GPIO_IRQ_SDPV1 3
54 #define SDP3430_TS_GPIO_IRQ_SDPV2 2
56 #define ENABLE_VAUX3_DEDICATED 0x03
57 #define ENABLE_VAUX3_DEV_GRP 0x20
59 #define TWL4030_MSECURE_GPIO 22
61 /* FIXME: These values need to be updated based on more profiling on 3430sdp*/
62 static struct cpuidle_params omap3_cpuidle_params_table[] = {
70 {1, 1500, 1800, 4000},
72 {1, 2500, 7500, 12000},
74 {1, 3000, 8500, 15000},
76 {1, 10000, 30000, 300000},
79 static uint32_t board_keymap[] = {
113 static struct matrix_keymap_data board_map_data = {
114 .keymap = board_keymap,
115 .keymap_size = ARRAY_SIZE(board_keymap),
118 static struct twl4030_keypad_data sdp3430_kp_data = {
119 .keymap_data = &board_map_data,
125 static int ts_gpio; /* Needed for ads7846_get_pendown_state */
128 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
130 * @return - void. If request gpio fails then Flag KERN_ERR.
132 static void ads7846_dev_init(void)
134 if (gpio_request(ts_gpio, "ADS7846 pendown") < 0) {
135 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
139 gpio_direction_input(ts_gpio);
140 gpio_set_debounce(ts_gpio, 310);
143 static int ads7846_get_pendown_state(void)
145 return !gpio_get_value(ts_gpio);
148 static struct ads7846_platform_data tsc2046_config __initdata = {
149 .get_pendown_state = ads7846_get_pendown_state,
155 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
157 .single_channel = 1, /* 0: slave, 1: master */
160 static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
163 * TSC2046 operates at a max freqency of 2MHz, so
164 * operate slightly below at 1.5MHz
166 .modalias = "ads7846",
169 .max_speed_hz = 1500000,
170 .controller_data = &tsc2046_mcspi_config,
172 .platform_data = &tsc2046_config,
177 #define SDP3430_LCD_PANEL_BACKLIGHT_GPIO 8
178 #define SDP3430_LCD_PANEL_ENABLE_GPIO 5
180 static unsigned backlight_gpio;
181 static unsigned enable_gpio;
182 static int lcd_enabled;
183 static int dvi_enabled;
185 static void __init sdp3430_display_init(void)
189 enable_gpio = SDP3430_LCD_PANEL_ENABLE_GPIO;
190 backlight_gpio = SDP3430_LCD_PANEL_BACKLIGHT_GPIO;
192 r = gpio_request(enable_gpio, "LCD reset");
194 printk(KERN_ERR "failed to get LCD reset GPIO\n");
198 r = gpio_request(backlight_gpio, "LCD Backlight");
200 printk(KERN_ERR "failed to get LCD backlight GPIO\n");
204 gpio_direction_output(enable_gpio, 0);
205 gpio_direction_output(backlight_gpio, 0);
209 gpio_free(enable_gpio);
214 static int sdp3430_panel_enable_lcd(struct omap_dss_device *dssdev)
217 printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
221 gpio_direction_output(enable_gpio, 1);
222 gpio_direction_output(backlight_gpio, 1);
229 static void sdp3430_panel_disable_lcd(struct omap_dss_device *dssdev)
233 gpio_direction_output(enable_gpio, 0);
234 gpio_direction_output(backlight_gpio, 0);
237 static int sdp3430_panel_enable_dvi(struct omap_dss_device *dssdev)
240 printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
249 static void sdp3430_panel_disable_dvi(struct omap_dss_device *dssdev)
254 static int sdp3430_panel_enable_tv(struct omap_dss_device *dssdev)
259 static void sdp3430_panel_disable_tv(struct omap_dss_device *dssdev)
264 static struct omap_dss_device sdp3430_lcd_device = {
266 .driver_name = "sharp_ls_panel",
267 .type = OMAP_DISPLAY_TYPE_DPI,
268 .phy.dpi.data_lines = 16,
269 .platform_enable = sdp3430_panel_enable_lcd,
270 .platform_disable = sdp3430_panel_disable_lcd,
273 static struct omap_dss_device sdp3430_dvi_device = {
275 .driver_name = "generic_panel",
276 .type = OMAP_DISPLAY_TYPE_DPI,
277 .phy.dpi.data_lines = 24,
278 .platform_enable = sdp3430_panel_enable_dvi,
279 .platform_disable = sdp3430_panel_disable_dvi,
282 static struct omap_dss_device sdp3430_tv_device = {
284 .driver_name = "venc",
285 .type = OMAP_DISPLAY_TYPE_VENC,
286 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
287 .platform_enable = sdp3430_panel_enable_tv,
288 .platform_disable = sdp3430_panel_disable_tv,
292 static struct omap_dss_device *sdp3430_dss_devices[] = {
298 static struct omap_dss_board_info sdp3430_dss_data = {
299 .num_devices = ARRAY_SIZE(sdp3430_dss_devices),
300 .devices = sdp3430_dss_devices,
301 .default_device = &sdp3430_lcd_device,
304 static struct platform_device sdp3430_dss_device = {
308 .platform_data = &sdp3430_dss_data,
312 static struct regulator_consumer_supply sdp3430_vdda_dac_supply = {
313 .supply = "vdda_dac",
314 .dev = &sdp3430_dss_device.dev,
317 static struct platform_device *sdp3430_devices[] __initdata = {
321 static struct omap_board_config_kernel sdp3430_config[] __initdata = {
324 static void __init omap_3430sdp_init_irq(void)
326 omap_board_config = sdp3430_config;
327 omap_board_config_size = ARRAY_SIZE(sdp3430_config);
328 omap3_pm_init_cpuidle(omap3_cpuidle_params_table);
329 omap2_init_common_hw(hyb18m512160af6_sdrc_params, NULL);
333 static int sdp3430_batt_table[] = {
335 30800, 29500, 28300, 27100,
336 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
337 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
338 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
339 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
340 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
341 4040, 3910, 3790, 3670, 3550
344 static struct twl4030_bci_platform_data sdp3430_bci_data = {
345 .battery_tmp_tbl = sdp3430_batt_table,
346 .tblsize = ARRAY_SIZE(sdp3430_batt_table),
349 static struct omap2_hsmmc_info mmc[] = {
352 /* 8 bits (default) requires S6.3 == ON,
353 * so the SIM card isn't used; else 4 bits.
355 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
360 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
366 static struct regulator_consumer_supply sdp3430_vmmc1_supply = {
370 static struct regulator_consumer_supply sdp3430_vsim_supply = {
371 .supply = "vmmc_aux",
374 static struct regulator_consumer_supply sdp3430_vmmc2_supply = {
378 static int sdp3430_twl_gpio_setup(struct device *dev,
379 unsigned gpio, unsigned ngpio)
381 /* gpio + 0 is "mmc0_cd" (input/IRQ),
382 * gpio + 1 is "mmc1_cd" (input/IRQ)
384 mmc[0].gpio_cd = gpio + 0;
385 mmc[1].gpio_cd = gpio + 1;
386 omap2_hsmmc_init(mmc);
388 /* link regulators to MMC adapters ... we "know" the
389 * regulators will be set up only *after* we return.
391 sdp3430_vmmc1_supply.dev = mmc[0].dev;
392 sdp3430_vsim_supply.dev = mmc[0].dev;
393 sdp3430_vmmc2_supply.dev = mmc[1].dev;
395 /* gpio + 7 is "sub_lcd_en_bkl" (output/PWM1) */
396 gpio_request(gpio + 7, "sub_lcd_en_bkl");
397 gpio_direction_output(gpio + 7, 0);
399 /* gpio + 15 is "sub_lcd_nRST" (output) */
400 gpio_request(gpio + 15, "sub_lcd_nRST");
401 gpio_direction_output(gpio + 15, 0);
406 static struct twl4030_gpio_platform_data sdp3430_gpio_data = {
407 .gpio_base = OMAP_MAX_GPIO_LINES,
408 .irq_base = TWL4030_GPIO_IRQ_BASE,
409 .irq_end = TWL4030_GPIO_IRQ_END,
410 .pulldowns = BIT(2) | BIT(6) | BIT(8) | BIT(13)
412 .setup = sdp3430_twl_gpio_setup,
415 static struct twl4030_usb_data sdp3430_usb_data = {
416 .usb_mode = T2_USB_MODE_ULPI,
419 static struct twl4030_madc_platform_data sdp3430_madc_data = {
424 * Apply all the fixed voltages since most versions of U-Boot
425 * don't bother with that initialization.
428 /* VAUX1 for mainboard (irda and sub-lcd) */
429 static struct regulator_init_data sdp3430_vaux1 = {
434 .valid_modes_mask = REGULATOR_MODE_NORMAL
435 | REGULATOR_MODE_STANDBY,
436 .valid_ops_mask = REGULATOR_CHANGE_MODE
437 | REGULATOR_CHANGE_STATUS,
441 /* VAUX2 for camera module */
442 static struct regulator_init_data sdp3430_vaux2 = {
447 .valid_modes_mask = REGULATOR_MODE_NORMAL
448 | REGULATOR_MODE_STANDBY,
449 .valid_ops_mask = REGULATOR_CHANGE_MODE
450 | REGULATOR_CHANGE_STATUS,
454 /* VAUX3 for LCD board */
455 static struct regulator_init_data sdp3430_vaux3 = {
460 .valid_modes_mask = REGULATOR_MODE_NORMAL
461 | REGULATOR_MODE_STANDBY,
462 .valid_ops_mask = REGULATOR_CHANGE_MODE
463 | REGULATOR_CHANGE_STATUS,
467 /* VAUX4 for OMAP VDD_CSI2 (camera) */
468 static struct regulator_init_data sdp3430_vaux4 = {
473 .valid_modes_mask = REGULATOR_MODE_NORMAL
474 | REGULATOR_MODE_STANDBY,
475 .valid_ops_mask = REGULATOR_CHANGE_MODE
476 | REGULATOR_CHANGE_STATUS,
480 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
481 static struct regulator_init_data sdp3430_vmmc1 = {
485 .valid_modes_mask = REGULATOR_MODE_NORMAL
486 | REGULATOR_MODE_STANDBY,
487 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
488 | REGULATOR_CHANGE_MODE
489 | REGULATOR_CHANGE_STATUS,
491 .num_consumer_supplies = 1,
492 .consumer_supplies = &sdp3430_vmmc1_supply,
495 /* VMMC2 for MMC2 card */
496 static struct regulator_init_data sdp3430_vmmc2 = {
501 .valid_modes_mask = REGULATOR_MODE_NORMAL
502 | REGULATOR_MODE_STANDBY,
503 .valid_ops_mask = REGULATOR_CHANGE_MODE
504 | REGULATOR_CHANGE_STATUS,
506 .num_consumer_supplies = 1,
507 .consumer_supplies = &sdp3430_vmmc2_supply,
510 /* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
511 static struct regulator_init_data sdp3430_vsim = {
515 .valid_modes_mask = REGULATOR_MODE_NORMAL
516 | REGULATOR_MODE_STANDBY,
517 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
518 | REGULATOR_CHANGE_MODE
519 | REGULATOR_CHANGE_STATUS,
521 .num_consumer_supplies = 1,
522 .consumer_supplies = &sdp3430_vsim_supply,
525 /* VDAC for DSS driving S-Video */
526 static struct regulator_init_data sdp3430_vdac = {
531 .valid_modes_mask = REGULATOR_MODE_NORMAL
532 | REGULATOR_MODE_STANDBY,
533 .valid_ops_mask = REGULATOR_CHANGE_MODE
534 | REGULATOR_CHANGE_STATUS,
536 .num_consumer_supplies = 1,
537 .consumer_supplies = &sdp3430_vdda_dac_supply,
540 /* VPLL2 for digital video outputs */
541 static struct regulator_consumer_supply sdp3430_vpll2_supplies[] = {
543 .supply = "vdds_dsi",
544 .dev = &sdp3430_dss_device.dev,
548 static struct regulator_init_data sdp3430_vpll2 = {
554 .valid_modes_mask = REGULATOR_MODE_NORMAL
555 | REGULATOR_MODE_STANDBY,
556 .valid_ops_mask = REGULATOR_CHANGE_MODE
557 | REGULATOR_CHANGE_STATUS,
559 .num_consumer_supplies = ARRAY_SIZE(sdp3430_vpll2_supplies),
560 .consumer_supplies = sdp3430_vpll2_supplies,
563 static struct twl4030_codec_audio_data sdp3430_audio = {
564 .audio_mclk = 26000000,
567 static struct twl4030_codec_data sdp3430_codec = {
568 .audio_mclk = 26000000,
569 .audio = &sdp3430_audio,
572 static struct twl4030_platform_data sdp3430_twldata = {
573 .irq_base = TWL4030_IRQ_BASE,
574 .irq_end = TWL4030_IRQ_END,
576 /* platform_data for children goes here */
577 .bci = &sdp3430_bci_data,
578 .gpio = &sdp3430_gpio_data,
579 .madc = &sdp3430_madc_data,
580 .keypad = &sdp3430_kp_data,
581 .usb = &sdp3430_usb_data,
582 .codec = &sdp3430_codec,
584 .vaux1 = &sdp3430_vaux1,
585 .vaux2 = &sdp3430_vaux2,
586 .vaux3 = &sdp3430_vaux3,
587 .vaux4 = &sdp3430_vaux4,
588 .vmmc1 = &sdp3430_vmmc1,
589 .vmmc2 = &sdp3430_vmmc2,
590 .vsim = &sdp3430_vsim,
591 .vdac = &sdp3430_vdac,
592 .vpll2 = &sdp3430_vpll2,
595 static struct i2c_board_info __initdata sdp3430_i2c_boardinfo[] = {
597 I2C_BOARD_INFO("twl4030", 0x48),
598 .flags = I2C_CLIENT_WAKE,
599 .irq = INT_34XX_SYS_NIRQ,
600 .platform_data = &sdp3430_twldata,
604 static int __init omap3430_i2c_init(void)
606 /* i2c1 for PMIC only */
607 omap_register_i2c_bus(1, 2600, sdp3430_i2c_boardinfo,
608 ARRAY_SIZE(sdp3430_i2c_boardinfo));
609 /* i2c2 on camera connector (for sensor control) and optional isp1301 */
610 omap_register_i2c_bus(2, 400, NULL, 0);
611 /* i2c3 on display connector (for DVI, tfp410) */
612 omap_register_i2c_bus(3, 400, NULL, 0);
616 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
618 static struct omap_smc91x_platform_data board_smc91x_data = {
620 .flags = GPMC_MUX_ADD_DATA | GPMC_TIMINGS_SMC91C96 |
621 IORESOURCE_IRQ_LOWLEVEL,
624 static void __init board_smc91x_init(void)
626 if (omap_rev() > OMAP3430_REV_ES1_0)
627 board_smc91x_data.gpio_irq = 6;
629 board_smc91x_data.gpio_irq = 29;
631 gpmc_smc91x_init(&board_smc91x_data);
636 static inline void board_smc91x_init(void)
642 static void enable_board_wakeup_source(void)
644 /* T2 interrupt line (keypad) */
645 omap_mux_init_signal("sys_nirq",
646 OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
649 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
651 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
652 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
653 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
656 .reset_gpio_port[0] = 57,
657 .reset_gpio_port[1] = 61,
658 .reset_gpio_port[2] = -EINVAL
661 #ifdef CONFIG_OMAP_MUX
662 static struct omap_board_mux board_mux[] __initdata = {
663 { .reg_offset = OMAP_MUX_TERMINATOR },
668 * SDP3430 V2 Board CS organization
669 * Different from SDP3430 V1. Now 4 switches used to specify CS
671 * See also the Switch S8 settings in the comments.
673 static char chip_sel_3430[][GPMC_CS_NUM] = {
674 {PDC_NOR, PDC_NAND, PDC_ONENAND, DBG_MPDB, 0, 0, 0, 0}, /* S8:1111 */
675 {PDC_ONENAND, PDC_NAND, PDC_NOR, DBG_MPDB, 0, 0, 0, 0}, /* S8:1110 */
676 {PDC_NAND, PDC_ONENAND, PDC_NOR, DBG_MPDB, 0, 0, 0, 0}, /* S8:1101 */
679 static struct mtd_partition sdp_nor_partitions[] = {
680 /* bootloader (U-Boot, etc) in first sector */
682 .name = "Bootloader-NOR",
685 .mask_flags = MTD_WRITEABLE, /* force read-only */
687 /* bootloader params in the next sector */
689 .name = "Params-NOR",
690 .offset = MTDPART_OFS_APPEND,
696 .name = "Kernel-NOR",
697 .offset = MTDPART_OFS_APPEND,
703 .name = "Filesystem-NOR",
704 .offset = MTDPART_OFS_APPEND,
705 .size = MTDPART_SIZ_FULL,
710 static struct mtd_partition sdp_onenand_partitions[] = {
712 .name = "X-Loader-OneNAND",
714 .size = 4 * (64 * 2048),
715 .mask_flags = MTD_WRITEABLE /* force read-only */
718 .name = "U-Boot-OneNAND",
719 .offset = MTDPART_OFS_APPEND,
720 .size = 2 * (64 * 2048),
721 .mask_flags = MTD_WRITEABLE /* force read-only */
724 .name = "U-Boot Environment-OneNAND",
725 .offset = MTDPART_OFS_APPEND,
726 .size = 1 * (64 * 2048),
729 .name = "Kernel-OneNAND",
730 .offset = MTDPART_OFS_APPEND,
731 .size = 16 * (64 * 2048),
734 .name = "File System-OneNAND",
735 .offset = MTDPART_OFS_APPEND,
736 .size = MTDPART_SIZ_FULL,
740 static struct mtd_partition sdp_nand_partitions[] = {
741 /* All the partition sizes are listed in terms of NAND block size */
743 .name = "X-Loader-NAND",
745 .size = 4 * (64 * 2048),
746 .mask_flags = MTD_WRITEABLE, /* force read-only */
749 .name = "U-Boot-NAND",
750 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
751 .size = 10 * (64 * 2048),
752 .mask_flags = MTD_WRITEABLE, /* force read-only */
755 .name = "Boot Env-NAND",
757 .offset = MTDPART_OFS_APPEND, /* Offset = 0x1c0000 */
758 .size = 6 * (64 * 2048),
761 .name = "Kernel-NAND",
762 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
763 .size = 40 * (64 * 2048),
766 .name = "File System - NAND",
767 .size = MTDPART_SIZ_FULL,
768 .offset = MTDPART_OFS_APPEND, /* Offset = 0x780000 */
772 static struct flash_partitions sdp_flash_partitions[] = {
774 .parts = sdp_nor_partitions,
775 .nr_parts = ARRAY_SIZE(sdp_nor_partitions),
778 .parts = sdp_onenand_partitions,
779 .nr_parts = ARRAY_SIZE(sdp_onenand_partitions),
782 .parts = sdp_nand_partitions,
783 .nr_parts = ARRAY_SIZE(sdp_nand_partitions),
787 static struct omap_musb_board_data musb_board_data = {
788 .interface_type = MUSB_INTERFACE_ULPI,
793 static void __init omap_3430sdp_init(void)
795 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
797 platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
798 if (omap_rev() > OMAP3430_REV_ES1_0)
799 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV2;
801 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV1;
802 sdp3430_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
803 spi_register_board_info(sdp3430_spi_board_info,
804 ARRAY_SIZE(sdp3430_spi_board_info));
807 usb_musb_init(&musb_board_data);
809 board_flash_init(sdp_flash_partitions, chip_sel_3430);
810 sdp3430_display_init();
811 enable_board_wakeup_source();
812 usb_ehci_init(&ehci_pdata);
815 MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
816 /* Maintainer: Syed Khasim - Texas Instruments Inc */
817 .boot_params = 0x80000100,
818 .map_io = omap3_map_io,
819 .reserve = omap_reserve,
820 .init_irq = omap_3430sdp_init_irq,
821 .init_machine = omap_3430sdp_init,
822 .timer = &omap_timer,