2 * board-omap3pandora.c (Pandora Handheld Console)
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * version 2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 #include <linux/init.h>
21 #include <linux/kernel.h>
22 #include <linux/platform_device.h>
24 #include <linux/spi/spi.h>
25 #include <linux/spi/ads7846.h>
26 #include <linux/regulator/machine.h>
27 #include <linux/i2c/twl.h>
28 #include <linux/wl12xx.h>
29 #include <linux/mtd/partitions.h>
30 #include <linux/mtd/nand.h>
31 #include <linux/leds.h>
32 #include <linux/input.h>
33 #include <linux/input/matrix_keypad.h>
34 #include <linux/gpio_keys.h>
35 #include <linux/mmc/host.h>
36 #include <linux/mmc/card.h>
37 #include <linux/regulator/fixed.h>
38 #include <linux/i2c/vsense.h>
40 #include <asm/mach-types.h>
41 #include <asm/mach/arch.h>
42 #include <asm/mach/map.h>
44 #include <plat/board.h>
45 #include <plat/common.h>
46 #include <mach/gpio.h>
47 #include <mach/hardware.h>
48 #include <plat/mcspi.h>
50 #include <plat/display.h>
51 #include <plat/nand.h>
54 #include "sdram-micron-mt46h32m32lf-6.h"
57 #define PANDORA_WIFI_IRQ_GPIO 21
58 #define PANDORA_WIFI_NRESET_GPIO 23
59 #define OMAP3_PANDORA_TS_GPIO 94
61 #define NAND_BLOCK_SIZE SZ_128K
63 static struct mtd_partition omap3pandora_nand_partitions[] = {
67 .size = 4 * NAND_BLOCK_SIZE,
68 .mask_flags = MTD_WRITEABLE
71 .offset = MTDPART_OFS_APPEND,
72 .size = 15 * NAND_BLOCK_SIZE,
75 .offset = MTDPART_OFS_APPEND,
76 .size = 1 * NAND_BLOCK_SIZE,
79 .offset = MTDPART_OFS_APPEND,
80 .size = 80 * NAND_BLOCK_SIZE,
83 .offset = MTDPART_OFS_APPEND,
84 .size = MTDPART_SIZ_FULL,
88 static struct omap_nand_platform_data pandora_nand_data = {
90 .devsize = 1, /* '0' for 8-bit, '1' for 16-bit device */
91 .parts = omap3pandora_nand_partitions,
92 .nr_parts = ARRAY_SIZE(omap3pandora_nand_partitions),
95 static struct gpio_led pandora_gpio_leds[] = {
97 .name = "pandora::sd1",
98 .default_trigger = "mmc0",
101 .name = "pandora::sd2",
102 .default_trigger = "mmc1",
105 .name = "pandora::bluetooth",
108 .name = "pandora::wifi",
113 static struct gpio_led_platform_data pandora_gpio_led_data = {
114 .leds = pandora_gpio_leds,
115 .num_leds = ARRAY_SIZE(pandora_gpio_leds),
118 static struct platform_device pandora_leds_gpio = {
122 .platform_data = &pandora_gpio_led_data,
126 static struct platform_device pandora_bl = {
127 .name = "twl4030-pwm0-bl",
131 #define GPIO_BUTTON(gpio_num, ev_type, ev_code, act_low, descr) \
136 .active_low = act_low, \
137 .debounce_interval = 4, \
138 .desc = "btn " descr, \
141 #define GPIO_BUTTON_LOW(gpio_num, event_code, description) \
142 GPIO_BUTTON(gpio_num, EV_KEY, event_code, 1, description)
144 static struct gpio_keys_button pandora_gpio_keys[] = {
145 GPIO_BUTTON_LOW(110, KEY_UP, "up"),
146 GPIO_BUTTON_LOW(103, KEY_DOWN, "down"),
147 GPIO_BUTTON_LOW(96, KEY_LEFT, "left"),
148 GPIO_BUTTON_LOW(98, KEY_RIGHT, "right"),
149 GPIO_BUTTON_LOW(109, KEY_PAGEUP, "game 1"),
150 GPIO_BUTTON_LOW(111, KEY_END, "game 2"),
151 GPIO_BUTTON_LOW(106, KEY_PAGEDOWN, "game 3"),
152 GPIO_BUTTON_LOW(101, KEY_HOME, "game 4"),
153 GPIO_BUTTON_LOW(102, KEY_RIGHTSHIFT, "l"),
154 GPIO_BUTTON_LOW(97, KEY_KPPLUS, "l2"),
155 GPIO_BUTTON_LOW(105, KEY_RIGHTCTRL, "r"),
156 GPIO_BUTTON_LOW(107, KEY_KPMINUS, "r2"),
157 GPIO_BUTTON_LOW(104, KEY_LEFTCTRL, "ctrl"),
158 GPIO_BUTTON_LOW(99, KEY_MENU, "menu"),
159 GPIO_BUTTON_LOW(176, KEY_COFFEE, "hold"),
160 GPIO_BUTTON(100, EV_KEY, KEY_LEFTALT, 0, "alt"),
161 GPIO_BUTTON(108, EV_SW, SW_LID, 1, "lid"),
164 static struct gpio_keys_platform_data pandora_gpio_key_info = {
165 .buttons = pandora_gpio_keys,
166 .nbuttons = ARRAY_SIZE(pandora_gpio_keys),
169 static struct platform_device pandora_keys_gpio = {
173 .platform_data = &pandora_gpio_key_info,
177 static const uint32_t board_keymap[] = {
190 KEY(1, 5, KEY_SPACE),
191 KEY(2, 0, KEY_BACKSPACE),
217 KEY(7, 0, KEY_ENTER),
220 KEY(7, 3, KEY_LEFTSHIFT),
221 KEY(7, 4, KEY_COMMA),
224 static struct matrix_keymap_data board_map_data = {
225 .keymap = board_keymap,
226 .keymap_size = ARRAY_SIZE(board_keymap),
229 static struct twl4030_keypad_data pandora_kp_data = {
230 .keymap_data = &board_map_data,
236 static struct omap_dss_device pandora_lcd_device = {
238 .driver_name = "tpo_td043mtea1_panel",
239 .type = OMAP_DISPLAY_TYPE_DPI,
240 .phy.dpi.data_lines = 24,
244 static struct omap_dss_device pandora_tv_device = {
246 .driver_name = "venc",
247 .type = OMAP_DISPLAY_TYPE_VENC,
248 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
251 static struct omap_dss_device *pandora_dss_devices[] = {
256 static struct omap_dss_board_info pandora_dss_data = {
257 .num_devices = ARRAY_SIZE(pandora_dss_devices),
258 .devices = pandora_dss_devices,
259 .default_device = &pandora_lcd_device,
262 static struct platform_device pandora_dss_device = {
266 .platform_data = &pandora_dss_data,
270 static void pandora_wl1251_init_card(struct mmc_card *card)
273 * We have TI wl1251 attached to MMC3. Pass this information to
274 * SDIO core because it can't be probed by normal methods.
276 card->quirks |= MMC_QUIRK_NONSTD_SDIO;
277 card->cccr.wide_bus = 1;
278 card->cis.vendor = 0x104c;
279 card->cis.device = 0x9066;
280 card->cis.blksize = 512;
281 card->cis.max_dtr = 20000000;
284 static struct omap2_hsmmc_info omap3pandora_mmc[] = {
287 .caps = MMC_CAP_4_BIT_DATA,
294 .caps = MMC_CAP_4_BIT_DATA,
302 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
305 .init_card = pandora_wl1251_init_card,
310 static int omap3pandora_twl_gpio_setup(struct device *dev,
311 unsigned gpio, unsigned ngpio)
315 /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
316 omap3pandora_mmc[0].gpio_cd = gpio + 0;
317 omap3pandora_mmc[1].gpio_cd = gpio + 1;
318 omap2_hsmmc_init(omap3pandora_mmc);
320 /* gpio + 13 drives 32kHz buffer for wifi module */
321 gpio_32khz = gpio + 13;
322 ret = gpio_request(gpio_32khz, "wifi 32kHz");
324 pr_err("Cannot get GPIO line %d, ret=%d\n", gpio_32khz, ret);
328 ret = gpio_direction_output(gpio_32khz, 1);
330 pr_err("Cannot set GPIO line %d, ret=%d\n", gpio_32khz, ret);
337 gpio_free(gpio_32khz);
342 static struct twl4030_gpio_platform_data omap3pandora_gpio_data = {
343 .gpio_base = OMAP_MAX_GPIO_LINES,
344 .irq_base = TWL4030_GPIO_IRQ_BASE,
345 .irq_end = TWL4030_GPIO_IRQ_END,
346 .setup = omap3pandora_twl_gpio_setup,
349 static struct regulator_consumer_supply pandora_vmmc1_supply =
350 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.0");
352 static struct regulator_consumer_supply pandora_vmmc2_supply =
353 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.1");
355 static struct regulator_consumer_supply pandora_vmmc3_supply =
356 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.2");
358 static struct regulator_consumer_supply pandora_vdda_dac_supply =
359 REGULATOR_SUPPLY("vdda_dac", "omapdss");
361 static struct regulator_consumer_supply pandora_vdds_supplies[] = {
362 REGULATOR_SUPPLY("vdds_sdi", "omapdss"),
363 REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
366 static struct regulator_consumer_supply pandora_vcc_lcd_supply =
367 REGULATOR_SUPPLY("vcc", "display0");
369 static struct regulator_consumer_supply pandora_usb_phy_supply =
370 REGULATOR_SUPPLY("hsusb0", "ehci-omap.0");
372 /* ads7846 on SPI and 2 nub controllers on I2C */
373 static struct regulator_consumer_supply pandora_vaux4_supplies[] = {
374 REGULATOR_SUPPLY("vcc", "spi1.0"),
375 REGULATOR_SUPPLY("vcc", "3-0066"),
376 REGULATOR_SUPPLY("vcc", "3-0067"),
379 static struct regulator_consumer_supply pandora_adac_supply =
380 REGULATOR_SUPPLY("vcc", "soc-audio");
382 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
383 static struct regulator_init_data pandora_vmmc1 = {
387 .valid_modes_mask = REGULATOR_MODE_NORMAL
388 | REGULATOR_MODE_STANDBY,
389 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
390 | REGULATOR_CHANGE_MODE
391 | REGULATOR_CHANGE_STATUS,
393 .num_consumer_supplies = 1,
394 .consumer_supplies = &pandora_vmmc1_supply,
397 /* VMMC2 for MMC2 pins CMD, CLK, DAT0..DAT3 (max 100 mA) */
398 static struct regulator_init_data pandora_vmmc2 = {
402 .valid_modes_mask = REGULATOR_MODE_NORMAL
403 | REGULATOR_MODE_STANDBY,
404 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
405 | REGULATOR_CHANGE_MODE
406 | REGULATOR_CHANGE_STATUS,
408 .num_consumer_supplies = 1,
409 .consumer_supplies = &pandora_vmmc2_supply,
412 /* VDAC for DSS driving S-Video */
413 static struct regulator_init_data pandora_vdac = {
418 .valid_modes_mask = REGULATOR_MODE_NORMAL
419 | REGULATOR_MODE_STANDBY,
420 .valid_ops_mask = REGULATOR_CHANGE_MODE
421 | REGULATOR_CHANGE_STATUS,
423 .num_consumer_supplies = 1,
424 .consumer_supplies = &pandora_vdda_dac_supply,
427 /* VPLL2 for digital video outputs */
428 static struct regulator_init_data pandora_vpll2 = {
433 .valid_modes_mask = REGULATOR_MODE_NORMAL
434 | REGULATOR_MODE_STANDBY,
435 .valid_ops_mask = REGULATOR_CHANGE_MODE
436 | REGULATOR_CHANGE_STATUS,
438 .num_consumer_supplies = ARRAY_SIZE(pandora_vdds_supplies),
439 .consumer_supplies = pandora_vdds_supplies,
443 static struct regulator_init_data pandora_vaux1 = {
448 .valid_modes_mask = REGULATOR_MODE_NORMAL
449 | REGULATOR_MODE_STANDBY,
450 .valid_ops_mask = REGULATOR_CHANGE_MODE
451 | REGULATOR_CHANGE_STATUS,
453 .num_consumer_supplies = 1,
454 .consumer_supplies = &pandora_vcc_lcd_supply,
457 /* VAUX2 for USB host PHY */
458 static struct regulator_init_data pandora_vaux2 = {
463 .valid_modes_mask = REGULATOR_MODE_NORMAL
464 | REGULATOR_MODE_STANDBY,
465 .valid_ops_mask = REGULATOR_CHANGE_MODE
466 | REGULATOR_CHANGE_STATUS,
468 .num_consumer_supplies = 1,
469 .consumer_supplies = &pandora_usb_phy_supply,
472 /* VAUX4 for ads7846 and nubs */
473 static struct regulator_init_data pandora_vaux4 = {
478 .valid_modes_mask = REGULATOR_MODE_NORMAL
479 | REGULATOR_MODE_STANDBY,
480 .valid_ops_mask = REGULATOR_CHANGE_MODE
481 | REGULATOR_CHANGE_STATUS,
483 .num_consumer_supplies = ARRAY_SIZE(pandora_vaux4_supplies),
484 .consumer_supplies = pandora_vaux4_supplies,
487 /* VSIM for audio DAC */
488 static struct regulator_init_data pandora_vsim = {
493 .valid_modes_mask = REGULATOR_MODE_NORMAL
494 | REGULATOR_MODE_STANDBY,
495 .valid_ops_mask = REGULATOR_CHANGE_MODE
496 | REGULATOR_CHANGE_STATUS,
498 .num_consumer_supplies = 1,
499 .consumer_supplies = &pandora_adac_supply,
502 /* Fixed regulator internal to Wifi module */
503 static struct regulator_init_data pandora_vmmc3 = {
505 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
507 .num_consumer_supplies = 1,
508 .consumer_supplies = &pandora_vmmc3_supply,
511 static struct fixed_voltage_config pandora_vwlan = {
512 .supply_name = "vwlan",
513 .microvolts = 1800000, /* 1.8V */
514 .gpio = PANDORA_WIFI_NRESET_GPIO,
515 .startup_delay = 50000, /* 50ms */
517 .enabled_at_boot = 0,
518 .init_data = &pandora_vmmc3,
521 static struct platform_device pandora_vwlan_device = {
522 .name = "reg-fixed-voltage",
525 .platform_data = &pandora_vwlan,
529 static struct twl4030_usb_data omap3pandora_usb_data = {
530 .usb_mode = T2_USB_MODE_ULPI,
533 static struct twl4030_codec_audio_data omap3pandora_audio_data = {
534 .audio_mclk = 26000000,
537 static struct twl4030_codec_data omap3pandora_codec_data = {
538 .audio_mclk = 26000000,
539 .audio = &omap3pandora_audio_data,
542 static struct twl4030_bci_platform_data pandora_bci_data;
544 static struct twl4030_platform_data omap3pandora_twldata = {
545 .irq_base = TWL4030_IRQ_BASE,
546 .irq_end = TWL4030_IRQ_END,
547 .gpio = &omap3pandora_gpio_data,
548 .usb = &omap3pandora_usb_data,
549 .codec = &omap3pandora_codec_data,
550 .vmmc1 = &pandora_vmmc1,
551 .vmmc2 = &pandora_vmmc2,
552 .vdac = &pandora_vdac,
553 .vpll2 = &pandora_vpll2,
554 .vaux1 = &pandora_vaux1,
555 .vaux2 = &pandora_vaux2,
556 .vaux4 = &pandora_vaux4,
557 .vsim = &pandora_vsim,
558 .keypad = &pandora_kp_data,
559 .bci = &pandora_bci_data,
562 static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
564 I2C_BOARD_INFO("tps65950", 0x48),
565 .flags = I2C_CLIENT_WAKE,
566 .irq = INT_34XX_SYS_NIRQ,
567 .platform_data = &omap3pandora_twldata,
571 static struct vsense_platform_data omap3pandora_nub1_data = {
576 static struct vsense_platform_data omap3pandora_nub2_data = {
581 static struct i2c_board_info __initdata omap3pandora_i2c3_boardinfo[] = {
583 I2C_BOARD_INFO("vsense", 0x66),
584 .flags = I2C_CLIENT_WAKE,
585 .platform_data = &omap3pandora_nub1_data,
587 I2C_BOARD_INFO("vsense", 0x67),
588 .flags = I2C_CLIENT_WAKE,
589 .platform_data = &omap3pandora_nub2_data,
591 I2C_BOARD_INFO("bq27500", 0x55),
592 .flags = I2C_CLIENT_WAKE,
596 static int __init omap3pandora_i2c_init(void)
598 omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo,
599 ARRAY_SIZE(omap3pandora_i2c_boardinfo));
600 /* i2c2 pins are not connected */
601 omap_register_i2c_bus(3, 100, omap3pandora_i2c3_boardinfo,
602 ARRAY_SIZE(omap3pandora_i2c3_boardinfo));
606 static void __init omap3pandora_ads7846_init(void)
608 int gpio = OMAP3_PANDORA_TS_GPIO;
611 ret = gpio_request(gpio, "ads7846_pen_down");
613 printk(KERN_ERR "Failed to request GPIO %d for "
614 "ads7846 pen down IRQ\n", gpio);
618 gpio_direction_input(gpio);
621 static int ads7846_get_pendown_state(void)
623 return !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
626 static struct ads7846_platform_data ads7846_config = {
634 .get_pendown_state = ads7846_get_pendown_state,
638 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
640 .single_channel = 1, /* 0: slave, 1: master */
643 static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
645 .modalias = "ads7846",
648 .max_speed_hz = 1500000,
649 .controller_data = &ads7846_mcspi_config,
650 .irq = OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO),
651 .platform_data = &ads7846_config,
653 .modalias = "tpo_td043mtea1_panel_spi",
656 .max_speed_hz = 375000,
657 .platform_data = &pandora_lcd_device,
661 static void __init omap3pandora_init_irq(void)
663 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
664 mt46h32m32lf6_sdrc_params);
669 static void __init pandora_wl1251_init(void)
671 struct wl12xx_platform_data pandora_wl1251_pdata;
674 memset(&pandora_wl1251_pdata, 0, sizeof(pandora_wl1251_pdata));
676 ret = gpio_request(PANDORA_WIFI_IRQ_GPIO, "wl1251 irq");
680 ret = gpio_direction_input(PANDORA_WIFI_IRQ_GPIO);
684 pandora_wl1251_pdata.irq = gpio_to_irq(PANDORA_WIFI_IRQ_GPIO);
685 if (pandora_wl1251_pdata.irq < 0)
688 pandora_wl1251_pdata.use_eeprom = true;
689 ret = wl12xx_set_platform_data(&pandora_wl1251_pdata);
696 gpio_free(PANDORA_WIFI_IRQ_GPIO);
698 printk(KERN_ERR "wl1251 board initialisation failed\n");
701 static struct platform_device *omap3pandora_devices[] __initdata = {
706 &pandora_vwlan_device,
709 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
711 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
712 .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
713 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
716 .reset_gpio_port[0] = 16,
717 .reset_gpio_port[1] = -EINVAL,
718 .reset_gpio_port[2] = -EINVAL
721 #ifdef CONFIG_OMAP_MUX
722 static struct omap_board_mux board_mux[] __initdata = {
723 { .reg_offset = OMAP_MUX_TERMINATOR },
726 #define board_mux NULL
729 static struct omap_musb_board_data musb_board_data = {
730 .interface_type = MUSB_INTERFACE_ULPI,
735 static void __init omap3pandora_init(void)
737 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
738 omap3pandora_i2c_init();
739 pandora_wl1251_init();
740 platform_add_devices(omap3pandora_devices,
741 ARRAY_SIZE(omap3pandora_devices));
743 spi_register_board_info(omap3pandora_spi_board_info,
744 ARRAY_SIZE(omap3pandora_spi_board_info));
745 omap3pandora_ads7846_init();
746 usb_ehci_init(&ehci_pdata);
747 usb_musb_init(&musb_board_data);
748 gpmc_nand_init(&pandora_nand_data);
750 /* Ensure SDRC pins are mux'd for self-refresh */
751 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
752 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
755 /* HACK: create it here, so that others don't need to bother */
756 #ifdef CONFIG_PROC_FS
757 #include <linux/proc_fs.h>
759 static int __init proc_pandora_init(void)
761 struct proc_dir_entry *ret;
763 ret = proc_mkdir("pandora", NULL);
768 fs_initcall(proc_pandora_init);
771 MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
772 .boot_params = 0x80000100,
773 .map_io = omap3_map_io,
774 .reserve = omap_reserve,
775 .init_irq = omap3pandora_init_irq,
776 .init_machine = omap3pandora_init,
777 .timer = &omap_timer,