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>
41 #include <plat/panel-generic-dpi.h>
43 #include <plat/gpmc-smc91x.h>
45 #include "board-flash.h"
47 #include "sdram-qimonda-hyb18m512160af-6.h"
52 #define CONFIG_DISABLE_HFCLK 1
54 #define SDP3430_TS_GPIO_IRQ_SDPV1 3
55 #define SDP3430_TS_GPIO_IRQ_SDPV2 2
57 #define ENABLE_VAUX3_DEDICATED 0x03
58 #define ENABLE_VAUX3_DEV_GRP 0x20
60 #define TWL4030_MSECURE_GPIO 22
62 /* FIXME: These values need to be updated based on more profiling on 3430sdp*/
63 static struct cpuidle_params omap3_cpuidle_params_table[] = {
71 {1, 1500, 1800, 4000},
73 {1, 2500, 7500, 12000},
75 {1, 3000, 8500, 15000},
77 {1, 10000, 30000, 300000},
80 static uint32_t board_keymap[] = {
114 static struct matrix_keymap_data board_map_data = {
115 .keymap = board_keymap,
116 .keymap_size = ARRAY_SIZE(board_keymap),
119 static struct twl4030_keypad_data sdp3430_kp_data = {
120 .keymap_data = &board_map_data,
126 static int ts_gpio; /* Needed for ads7846_get_pendown_state */
129 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
131 * @return - void. If request gpio fails then Flag KERN_ERR.
133 static void ads7846_dev_init(void)
135 if (gpio_request(ts_gpio, "ADS7846 pendown") < 0) {
136 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
140 gpio_direction_input(ts_gpio);
141 gpio_set_debounce(ts_gpio, 310);
144 static int ads7846_get_pendown_state(void)
146 return !gpio_get_value(ts_gpio);
149 static struct ads7846_platform_data tsc2046_config __initdata = {
150 .get_pendown_state = ads7846_get_pendown_state,
156 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
158 .single_channel = 1, /* 0: slave, 1: master */
161 static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
164 * TSC2046 operates at a max freqency of 2MHz, so
165 * operate slightly below at 1.5MHz
167 .modalias = "ads7846",
170 .max_speed_hz = 1500000,
171 .controller_data = &tsc2046_mcspi_config,
173 .platform_data = &tsc2046_config,
178 #define SDP3430_LCD_PANEL_BACKLIGHT_GPIO 8
179 #define SDP3430_LCD_PANEL_ENABLE_GPIO 5
181 static unsigned backlight_gpio;
182 static unsigned enable_gpio;
183 static int lcd_enabled;
184 static int dvi_enabled;
186 static void __init sdp3430_display_init(void)
190 enable_gpio = SDP3430_LCD_PANEL_ENABLE_GPIO;
191 backlight_gpio = SDP3430_LCD_PANEL_BACKLIGHT_GPIO;
193 r = gpio_request(enable_gpio, "LCD reset");
195 printk(KERN_ERR "failed to get LCD reset GPIO\n");
199 r = gpio_request(backlight_gpio, "LCD Backlight");
201 printk(KERN_ERR "failed to get LCD backlight GPIO\n");
205 gpio_direction_output(enable_gpio, 0);
206 gpio_direction_output(backlight_gpio, 0);
210 gpio_free(enable_gpio);
215 static int sdp3430_panel_enable_lcd(struct omap_dss_device *dssdev)
218 printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
222 gpio_direction_output(enable_gpio, 1);
223 gpio_direction_output(backlight_gpio, 1);
230 static void sdp3430_panel_disable_lcd(struct omap_dss_device *dssdev)
234 gpio_direction_output(enable_gpio, 0);
235 gpio_direction_output(backlight_gpio, 0);
238 static int sdp3430_panel_enable_dvi(struct omap_dss_device *dssdev)
241 printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
250 static void sdp3430_panel_disable_dvi(struct omap_dss_device *dssdev)
255 static int sdp3430_panel_enable_tv(struct omap_dss_device *dssdev)
260 static void sdp3430_panel_disable_tv(struct omap_dss_device *dssdev)
265 static struct omap_dss_device sdp3430_lcd_device = {
267 .driver_name = "sharp_ls_panel",
268 .type = OMAP_DISPLAY_TYPE_DPI,
269 .phy.dpi.data_lines = 16,
270 .platform_enable = sdp3430_panel_enable_lcd,
271 .platform_disable = sdp3430_panel_disable_lcd,
274 static struct panel_generic_dpi_data dvi_panel = {
276 .platform_enable = sdp3430_panel_enable_dvi,
277 .platform_disable = sdp3430_panel_disable_dvi,
280 static struct omap_dss_device sdp3430_dvi_device = {
282 .type = OMAP_DISPLAY_TYPE_DPI,
283 .driver_name = "generic_dpi_panel",
285 .phy.dpi.data_lines = 24,
288 static struct omap_dss_device sdp3430_tv_device = {
290 .driver_name = "venc",
291 .type = OMAP_DISPLAY_TYPE_VENC,
292 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
293 .platform_enable = sdp3430_panel_enable_tv,
294 .platform_disable = sdp3430_panel_disable_tv,
298 static struct omap_dss_device *sdp3430_dss_devices[] = {
304 static struct omap_dss_board_info sdp3430_dss_data = {
305 .num_devices = ARRAY_SIZE(sdp3430_dss_devices),
306 .devices = sdp3430_dss_devices,
307 .default_device = &sdp3430_lcd_device,
310 static struct omap_board_config_kernel sdp3430_config[] __initdata = {
313 static void __init omap_3430sdp_init_early(void)
315 omap2_init_common_infrastructure();
316 omap2_init_common_devices(hyb18m512160af6_sdrc_params, NULL);
319 static int sdp3430_batt_table[] = {
321 30800, 29500, 28300, 27100,
322 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
323 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
324 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
325 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
326 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
327 4040, 3910, 3790, 3670, 3550
330 static struct twl4030_bci_platform_data sdp3430_bci_data = {
331 .battery_tmp_tbl = sdp3430_batt_table,
332 .tblsize = ARRAY_SIZE(sdp3430_batt_table),
335 static struct omap2_hsmmc_info mmc[] = {
338 /* 8 bits (default) requires S6.3 == ON,
339 * so the SIM card isn't used; else 4 bits.
341 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
346 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
352 static int sdp3430_twl_gpio_setup(struct device *dev,
353 unsigned gpio, unsigned ngpio)
355 /* gpio + 0 is "mmc0_cd" (input/IRQ),
356 * gpio + 1 is "mmc1_cd" (input/IRQ)
358 mmc[0].gpio_cd = gpio + 0;
359 mmc[1].gpio_cd = gpio + 1;
360 omap2_hsmmc_init(mmc);
362 /* gpio + 7 is "sub_lcd_en_bkl" (output/PWM1) */
363 gpio_request(gpio + 7, "sub_lcd_en_bkl");
364 gpio_direction_output(gpio + 7, 0);
366 /* gpio + 15 is "sub_lcd_nRST" (output) */
367 gpio_request(gpio + 15, "sub_lcd_nRST");
368 gpio_direction_output(gpio + 15, 0);
373 static struct twl4030_gpio_platform_data sdp3430_gpio_data = {
374 .gpio_base = OMAP_MAX_GPIO_LINES,
375 .irq_base = TWL4030_GPIO_IRQ_BASE,
376 .irq_end = TWL4030_GPIO_IRQ_END,
377 .pulldowns = BIT(2) | BIT(6) | BIT(8) | BIT(13)
379 .setup = sdp3430_twl_gpio_setup,
382 static struct twl4030_usb_data sdp3430_usb_data = {
383 .usb_mode = T2_USB_MODE_ULPI,
386 static struct twl4030_madc_platform_data sdp3430_madc_data = {
390 /* regulator consumer mappings */
393 static struct regulator_consumer_supply sdp3430_vaux3_supplies[] = {
394 REGULATOR_SUPPLY("vcc", "spi1.0"),
397 static struct regulator_consumer_supply sdp3430_vdda_dac_supplies[] = {
398 REGULATOR_SUPPLY("vdda_dac", "omapdss_venc"),
401 /* VPLL2 for digital video outputs */
402 static struct regulator_consumer_supply sdp3430_vpll2_supplies[] = {
403 REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
406 static struct regulator_consumer_supply sdp3430_vmmc1_supplies[] = {
407 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
410 static struct regulator_consumer_supply sdp3430_vsim_supplies[] = {
411 REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.0"),
414 static struct regulator_consumer_supply sdp3430_vmmc2_supplies[] = {
415 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
419 * Apply all the fixed voltages since most versions of U-Boot
420 * don't bother with that initialization.
423 /* VAUX1 for mainboard (irda and sub-lcd) */
424 static struct regulator_init_data sdp3430_vaux1 = {
429 .valid_modes_mask = REGULATOR_MODE_NORMAL
430 | REGULATOR_MODE_STANDBY,
431 .valid_ops_mask = REGULATOR_CHANGE_MODE
432 | REGULATOR_CHANGE_STATUS,
436 /* VAUX2 for camera module */
437 static struct regulator_init_data sdp3430_vaux2 = {
442 .valid_modes_mask = REGULATOR_MODE_NORMAL
443 | REGULATOR_MODE_STANDBY,
444 .valid_ops_mask = REGULATOR_CHANGE_MODE
445 | REGULATOR_CHANGE_STATUS,
449 /* VAUX3 for LCD board */
450 static struct regulator_init_data sdp3430_vaux3 = {
455 .valid_modes_mask = REGULATOR_MODE_NORMAL
456 | REGULATOR_MODE_STANDBY,
457 .valid_ops_mask = REGULATOR_CHANGE_MODE
458 | REGULATOR_CHANGE_STATUS,
460 .num_consumer_supplies = ARRAY_SIZE(sdp3430_vaux3_supplies),
461 .consumer_supplies = sdp3430_vaux3_supplies,
464 /* VAUX4 for OMAP VDD_CSI2 (camera) */
465 static struct regulator_init_data sdp3430_vaux4 = {
470 .valid_modes_mask = REGULATOR_MODE_NORMAL
471 | REGULATOR_MODE_STANDBY,
472 .valid_ops_mask = REGULATOR_CHANGE_MODE
473 | REGULATOR_CHANGE_STATUS,
477 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
478 static struct regulator_init_data sdp3430_vmmc1 = {
482 .valid_modes_mask = REGULATOR_MODE_NORMAL
483 | REGULATOR_MODE_STANDBY,
484 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
485 | REGULATOR_CHANGE_MODE
486 | REGULATOR_CHANGE_STATUS,
488 .num_consumer_supplies = ARRAY_SIZE(sdp3430_vmmc1_supplies),
489 .consumer_supplies = sdp3430_vmmc1_supplies,
492 /* VMMC2 for MMC2 card */
493 static struct regulator_init_data sdp3430_vmmc2 = {
498 .valid_modes_mask = REGULATOR_MODE_NORMAL
499 | REGULATOR_MODE_STANDBY,
500 .valid_ops_mask = REGULATOR_CHANGE_MODE
501 | REGULATOR_CHANGE_STATUS,
503 .num_consumer_supplies = ARRAY_SIZE(sdp3430_vmmc2_supplies),
504 .consumer_supplies = sdp3430_vmmc2_supplies,
507 /* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
508 static struct regulator_init_data sdp3430_vsim = {
512 .valid_modes_mask = REGULATOR_MODE_NORMAL
513 | REGULATOR_MODE_STANDBY,
514 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
515 | REGULATOR_CHANGE_MODE
516 | REGULATOR_CHANGE_STATUS,
518 .num_consumer_supplies = ARRAY_SIZE(sdp3430_vsim_supplies),
519 .consumer_supplies = sdp3430_vsim_supplies,
522 /* VDAC for DSS driving S-Video */
523 static struct regulator_init_data sdp3430_vdac = {
528 .valid_modes_mask = REGULATOR_MODE_NORMAL
529 | REGULATOR_MODE_STANDBY,
530 .valid_ops_mask = REGULATOR_CHANGE_MODE
531 | REGULATOR_CHANGE_STATUS,
533 .num_consumer_supplies = ARRAY_SIZE(sdp3430_vdda_dac_supplies),
534 .consumer_supplies = sdp3430_vdda_dac_supplies,
537 static struct regulator_init_data sdp3430_vpll2 = {
543 .valid_modes_mask = REGULATOR_MODE_NORMAL
544 | REGULATOR_MODE_STANDBY,
545 .valid_ops_mask = REGULATOR_CHANGE_MODE
546 | REGULATOR_CHANGE_STATUS,
548 .num_consumer_supplies = ARRAY_SIZE(sdp3430_vpll2_supplies),
549 .consumer_supplies = sdp3430_vpll2_supplies,
552 static struct twl4030_codec_audio_data sdp3430_audio;
554 static struct twl4030_codec_data sdp3430_codec = {
555 .audio_mclk = 26000000,
556 .audio = &sdp3430_audio,
559 static struct twl4030_platform_data sdp3430_twldata = {
560 .irq_base = TWL4030_IRQ_BASE,
561 .irq_end = TWL4030_IRQ_END,
563 /* platform_data for children goes here */
564 .bci = &sdp3430_bci_data,
565 .gpio = &sdp3430_gpio_data,
566 .madc = &sdp3430_madc_data,
567 .keypad = &sdp3430_kp_data,
568 .usb = &sdp3430_usb_data,
569 .codec = &sdp3430_codec,
571 .vaux1 = &sdp3430_vaux1,
572 .vaux2 = &sdp3430_vaux2,
573 .vaux3 = &sdp3430_vaux3,
574 .vaux4 = &sdp3430_vaux4,
575 .vmmc1 = &sdp3430_vmmc1,
576 .vmmc2 = &sdp3430_vmmc2,
577 .vsim = &sdp3430_vsim,
578 .vdac = &sdp3430_vdac,
579 .vpll2 = &sdp3430_vpll2,
582 static struct i2c_board_info __initdata sdp3430_i2c_boardinfo[] = {
584 I2C_BOARD_INFO("twl4030", 0x48),
585 .flags = I2C_CLIENT_WAKE,
586 .irq = INT_34XX_SYS_NIRQ,
587 .platform_data = &sdp3430_twldata,
591 static int __init omap3430_i2c_init(void)
593 /* i2c1 for PMIC only */
594 omap_register_i2c_bus(1, 2600, sdp3430_i2c_boardinfo,
595 ARRAY_SIZE(sdp3430_i2c_boardinfo));
596 /* i2c2 on camera connector (for sensor control) and optional isp1301 */
597 omap_register_i2c_bus(2, 400, NULL, 0);
598 /* i2c3 on display connector (for DVI, tfp410) */
599 omap_register_i2c_bus(3, 400, NULL, 0);
603 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
605 static struct omap_smc91x_platform_data board_smc91x_data = {
607 .flags = GPMC_MUX_ADD_DATA | GPMC_TIMINGS_SMC91C96 |
608 IORESOURCE_IRQ_LOWLEVEL,
611 static void __init board_smc91x_init(void)
613 if (omap_rev() > OMAP3430_REV_ES1_0)
614 board_smc91x_data.gpio_irq = 6;
616 board_smc91x_data.gpio_irq = 29;
618 gpmc_smc91x_init(&board_smc91x_data);
623 static inline void board_smc91x_init(void)
629 static void enable_board_wakeup_source(void)
631 /* T2 interrupt line (keypad) */
632 omap_mux_init_signal("sys_nirq",
633 OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
636 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
638 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
639 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
640 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
643 .reset_gpio_port[0] = 57,
644 .reset_gpio_port[1] = 61,
645 .reset_gpio_port[2] = -EINVAL
648 #ifdef CONFIG_OMAP_MUX
649 static struct omap_board_mux board_mux[] __initdata = {
650 { .reg_offset = OMAP_MUX_TERMINATOR },
655 * SDP3430 V2 Board CS organization
656 * Different from SDP3430 V1. Now 4 switches used to specify CS
658 * See also the Switch S8 settings in the comments.
660 static char chip_sel_3430[][GPMC_CS_NUM] = {
661 {PDC_NOR, PDC_NAND, PDC_ONENAND, DBG_MPDB, 0, 0, 0, 0}, /* S8:1111 */
662 {PDC_ONENAND, PDC_NAND, PDC_NOR, DBG_MPDB, 0, 0, 0, 0}, /* S8:1110 */
663 {PDC_NAND, PDC_ONENAND, PDC_NOR, DBG_MPDB, 0, 0, 0, 0}, /* S8:1101 */
666 static struct mtd_partition sdp_nor_partitions[] = {
667 /* bootloader (U-Boot, etc) in first sector */
669 .name = "Bootloader-NOR",
672 .mask_flags = MTD_WRITEABLE, /* force read-only */
674 /* bootloader params in the next sector */
676 .name = "Params-NOR",
677 .offset = MTDPART_OFS_APPEND,
683 .name = "Kernel-NOR",
684 .offset = MTDPART_OFS_APPEND,
690 .name = "Filesystem-NOR",
691 .offset = MTDPART_OFS_APPEND,
692 .size = MTDPART_SIZ_FULL,
697 static struct mtd_partition sdp_onenand_partitions[] = {
699 .name = "X-Loader-OneNAND",
701 .size = 4 * (64 * 2048),
702 .mask_flags = MTD_WRITEABLE /* force read-only */
705 .name = "U-Boot-OneNAND",
706 .offset = MTDPART_OFS_APPEND,
707 .size = 2 * (64 * 2048),
708 .mask_flags = MTD_WRITEABLE /* force read-only */
711 .name = "U-Boot Environment-OneNAND",
712 .offset = MTDPART_OFS_APPEND,
713 .size = 1 * (64 * 2048),
716 .name = "Kernel-OneNAND",
717 .offset = MTDPART_OFS_APPEND,
718 .size = 16 * (64 * 2048),
721 .name = "File System-OneNAND",
722 .offset = MTDPART_OFS_APPEND,
723 .size = MTDPART_SIZ_FULL,
727 static struct mtd_partition sdp_nand_partitions[] = {
728 /* All the partition sizes are listed in terms of NAND block size */
730 .name = "X-Loader-NAND",
732 .size = 4 * (64 * 2048),
733 .mask_flags = MTD_WRITEABLE, /* force read-only */
736 .name = "U-Boot-NAND",
737 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
738 .size = 10 * (64 * 2048),
739 .mask_flags = MTD_WRITEABLE, /* force read-only */
742 .name = "Boot Env-NAND",
744 .offset = MTDPART_OFS_APPEND, /* Offset = 0x1c0000 */
745 .size = 6 * (64 * 2048),
748 .name = "Kernel-NAND",
749 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
750 .size = 40 * (64 * 2048),
753 .name = "File System - NAND",
754 .size = MTDPART_SIZ_FULL,
755 .offset = MTDPART_OFS_APPEND, /* Offset = 0x780000 */
759 static struct flash_partitions sdp_flash_partitions[] = {
761 .parts = sdp_nor_partitions,
762 .nr_parts = ARRAY_SIZE(sdp_nor_partitions),
765 .parts = sdp_onenand_partitions,
766 .nr_parts = ARRAY_SIZE(sdp_onenand_partitions),
769 .parts = sdp_nand_partitions,
770 .nr_parts = ARRAY_SIZE(sdp_nand_partitions),
774 static struct omap_musb_board_data musb_board_data = {
775 .interface_type = MUSB_INTERFACE_ULPI,
780 static void __init omap_3430sdp_init(void)
782 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
783 omap_board_config = sdp3430_config;
784 omap_board_config_size = ARRAY_SIZE(sdp3430_config);
785 omap3_pm_init_cpuidle(omap3_cpuidle_params_table);
787 omap_display_init(&sdp3430_dss_data);
788 if (omap_rev() > OMAP3430_REV_ES1_0)
789 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV2;
791 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV1;
792 sdp3430_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
793 spi_register_board_info(sdp3430_spi_board_info,
794 ARRAY_SIZE(sdp3430_spi_board_info));
797 usb_musb_init(&musb_board_data);
799 board_flash_init(sdp_flash_partitions, chip_sel_3430, 0);
800 sdp3430_display_init();
801 enable_board_wakeup_source();
802 usb_ehci_init(&ehci_pdata);
805 MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
806 /* Maintainer: Syed Khasim - Texas Instruments Inc */
807 .boot_params = 0x80000100,
808 .reserve = omap_reserve,
809 .map_io = omap3_map_io,
810 .init_early = omap_3430sdp_init_early,
811 .init_irq = omap_init_irq,
812 .init_machine = omap_3430sdp_init,
813 .timer = &omap_timer,