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/regulator/machine.h>
26 #include <linux/i2c/twl.h>
27 #include <linux/wl12xx.h>
28 #include <linux/mtd/partitions.h>
29 #include <linux/mtd/nand.h>
30 #include <linux/leds.h>
31 #include <linux/leds_pwm.h>
32 #include <linux/input.h>
33 #include <linux/input/matrix_keypad.h>
34 #include <linux/gpio.h>
35 #include <linux/gpio_keys.h>
36 #include <linux/mmc/host.h>
37 #include <linux/mmc/card.h>
38 #include <linux/regulator/fixed.h>
39 #include <linux/i2c/vsense.h>
41 #include <asm/mach-types.h>
42 #include <asm/mach/arch.h>
43 #include <asm/mach/map.h>
45 #include <plat/board.h>
46 #include <plat/common.h>
47 #include <mach/hardware.h>
48 #include <plat/mcspi.h>
50 #include <video/omapdss.h>
51 #include <plat/nand.h>
54 #include "sdram-micron-mt46h32m32lf-6.h"
56 #include "common-board-devices.h"
58 #define PANDORA_WIFI_IRQ_GPIO 21
59 #define PANDORA_WIFI_NRESET_GPIO 23
60 #define OMAP3_PANDORA_TS_GPIO 94
61 #define PANDORA_EN_USB_5V_GPIO 164
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 = NAND_BUSWIDTH_16,
91 .xfer_type = NAND_OMAP_PREFETCH_DMA,
92 .parts = omap3pandora_nand_partitions,
93 .nr_parts = ARRAY_SIZE(omap3pandora_nand_partitions),
96 static struct gpio_led pandora_gpio_leds[] = {
98 .name = "pandora::sd1",
99 .default_trigger = "mmc0",
102 .name = "pandora::sd2",
103 .default_trigger = "mmc1",
106 .name = "pandora::bluetooth",
109 .name = "pandora::wifi",
114 static struct gpio_led_platform_data pandora_gpio_led_data = {
115 .leds = pandora_gpio_leds,
116 .num_leds = ARRAY_SIZE(pandora_gpio_leds),
119 static struct platform_device pandora_leds_gpio = {
123 .platform_data = &pandora_gpio_led_data,
127 static struct led_pwm pandora_pwm_leds[] = {
129 .name = "pandora::keypad_bl",
130 .pwm_id = 0, /* LEDA */
132 .name = "pandora::power",
133 .pwm_id = 1, /* LEDB */
135 .name = "pandora::charger",
136 .default_trigger = "bq27500-0-charging",
137 .pwm_id = 3, /* PWM1 */
141 static struct led_pwm_platform_data pandora_pwm_led_data = {
142 .leds = pandora_pwm_leds,
143 .num_leds = ARRAY_SIZE(pandora_pwm_leds),
146 static struct platform_device pandora_leds_pwm = {
147 .name = "leds-twl4030-pwm",
150 .platform_data = &pandora_pwm_led_data,
154 static struct platform_device pandora_bl = {
155 .name = "twl4030-pwm0-bl",
159 #define GPIO_BUTTON(gpio_num, ev_type, ev_code, act_low, descr) \
164 .active_low = act_low, \
165 .debounce_interval = 4, \
166 .desc = "btn " descr, \
169 #define GPIO_BUTTON_LOW(gpio_num, event_code, description) \
170 GPIO_BUTTON(gpio_num, EV_KEY, event_code, 1, description)
172 static struct gpio_keys_button pandora_gpio_keys[] = {
173 GPIO_BUTTON_LOW(110, KEY_UP, "up"),
174 GPIO_BUTTON_LOW(103, KEY_DOWN, "down"),
175 GPIO_BUTTON_LOW(96, KEY_LEFT, "left"),
176 GPIO_BUTTON_LOW(98, KEY_RIGHT, "right"),
177 GPIO_BUTTON_LOW(109, KEY_PAGEUP, "game 1"),
178 GPIO_BUTTON_LOW(111, KEY_END, "game 2"),
179 GPIO_BUTTON_LOW(106, KEY_PAGEDOWN, "game 3"),
180 GPIO_BUTTON_LOW(101, KEY_HOME, "game 4"),
181 GPIO_BUTTON_LOW(102, KEY_RIGHTSHIFT, "l"),
182 GPIO_BUTTON_LOW(97, KEY_KPPLUS, "l2"),
183 GPIO_BUTTON_LOW(105, KEY_RIGHTCTRL, "r"),
184 GPIO_BUTTON_LOW(107, KEY_KPMINUS, "r2"),
185 GPIO_BUTTON_LOW(104, KEY_LEFTCTRL, "ctrl"),
186 GPIO_BUTTON_LOW(99, KEY_MENU, "menu"),
187 GPIO_BUTTON_LOW(176, KEY_COFFEE, "hold"),
188 GPIO_BUTTON(100, EV_KEY, KEY_LEFTALT, 0, "alt"),
189 GPIO_BUTTON(108, EV_SW, SW_LID, 1, "lid"),
192 static struct gpio_keys_platform_data pandora_gpio_key_info = {
193 .buttons = pandora_gpio_keys,
194 .nbuttons = ARRAY_SIZE(pandora_gpio_keys),
197 static struct platform_device pandora_keys_gpio = {
201 .platform_data = &pandora_gpio_key_info,
205 /* HACK: this requires patched twl4030_keypad driver */
206 #define FNKEY(row, col, code) KEY((row + 8), col, code)
208 static const uint32_t board_keymap[] = {
221 KEY(1, 5, KEY_SPACE),
222 KEY(2, 0, KEY_BACKSPACE),
248 KEY(7, 0, KEY_ENTER),
251 KEY(7, 3, KEY_LEFTSHIFT),
252 KEY(7, 4, KEY_COMMA),
256 FNKEY(0, 2, KEY_BRIGHTNESSUP),
257 FNKEY(0, 3, KEY_F13), /* apostrophe, differs from Fn-A? */
258 FNKEY(0, 4, KEY_F22),
259 FNKEY(0, 5, KEY_F23),
260 FNKEY(1, 0, KEY_F10),
262 FNKEY(1, 2, KEY_BRIGHTNESSDOWN),
263 FNKEY(1, 3, KEY_GRAVE),
264 FNKEY(1, 4, KEY_F14), /* pipe/bar */
265 FNKEY(1, 5, KEY_TAB),
266 FNKEY(2, 0, KEY_INSERT),
268 FNKEY(2, 2, KEY_F15), /* dash */
269 FNKEY(2, 3, KEY_EQUAL),
270 FNKEY(2, 4, KEY_F16), /* # (pound/hash) */
272 FNKEY(3, 0, KEY_F11),
274 FNKEY(3, 2, KEY_F17), /* ! */
275 FNKEY(3, 3, KEY_KPPLUS),
276 FNKEY(3, 4, KEY_BACKSLASH),
277 FNKEY(4, 0, KEY_F12),
279 FNKEY(4, 2, KEY_RIGHTBRACE),
280 FNKEY(4, 3, KEY_KPMINUS),
281 FNKEY(4, 4, KEY_QUESTION),
282 FNKEY(5, 0, KEY_F18), /* £ (pound) */
284 FNKEY(5, 2, KEY_LEFTBRACE),
285 FNKEY(5, 3, KEY_F19), /* " */
286 FNKEY(5, 4, KEY_SLASH),
287 FNKEY(6, 0, KEY_YEN),
289 FNKEY(6, 2, KEY_F20), /* @ */
290 FNKEY(6, 3, KEY_APOSTROPHE),
291 FNKEY(6, 4, KEY_F21), /* : */
292 FNKEY(7, 0, KEY_ENTER),
294 FNKEY(7, 2, KEY_ESC),
295 FNKEY(7, 3, KEY_CAPSLOCK),
296 FNKEY(7, 4, KEY_SEMICOLON),
299 static struct matrix_keymap_data board_map_data = {
300 .keymap = board_keymap,
301 .keymap_size = ARRAY_SIZE(board_keymap),
304 static struct twl4030_keypad_data pandora_kp_data = {
305 .keymap_data = &board_map_data,
311 static struct omap_dss_device pandora_lcd_device = {
313 .driver_name = "tpo_td043mtea1_panel",
314 .type = OMAP_DISPLAY_TYPE_DPI,
315 .phy.dpi.data_lines = 24,
319 static struct omap_dss_device pandora_tv_device = {
321 .driver_name = "venc",
322 .type = OMAP_DISPLAY_TYPE_VENC,
323 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
326 static struct omap_dss_device *pandora_dss_devices[] = {
331 static struct omap_dss_board_info pandora_dss_data = {
332 .num_devices = ARRAY_SIZE(pandora_dss_devices),
333 .devices = pandora_dss_devices,
334 .default_device = &pandora_lcd_device,
337 static void pandora_wl1251_init_card(struct mmc_card *card)
340 * We have TI wl1251 attached to MMC3. Pass this information to
341 * SDIO core because it can't be probed by normal methods.
343 card->quirks |= MMC_QUIRK_NONSTD_SDIO;
344 card->cccr.wide_bus = 1;
345 card->cis.vendor = 0x104c;
346 card->cis.device = 0x9066;
347 card->cis.blksize = 512;
348 card->cis.max_dtr = 20000000;
351 static struct omap2_hsmmc_info omap3pandora_mmc[] = {
354 .caps = MMC_CAP_4_BIT_DATA,
361 .caps = MMC_CAP_4_BIT_DATA,
369 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
372 .init_card = pandora_wl1251_init_card,
377 static int omap3pandora_twl_gpio_setup(struct device *dev,
378 unsigned gpio, unsigned ngpio)
382 /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
383 omap3pandora_mmc[0].gpio_cd = gpio + 0;
384 omap3pandora_mmc[1].gpio_cd = gpio + 1;
385 omap2_hsmmc_init(omap3pandora_mmc);
387 /* gpio + 13 drives 32kHz buffer for wifi module */
388 gpio_32khz = gpio + 13;
389 ret = gpio_request_one(gpio_32khz, GPIOF_OUT_INIT_HIGH, "wifi 32kHz");
391 pr_err("Cannot get GPIO line %d, ret=%d\n", gpio_32khz, ret);
398 static struct twl4030_gpio_platform_data omap3pandora_gpio_data = {
399 .gpio_base = OMAP_MAX_GPIO_LINES,
400 .irq_base = TWL4030_GPIO_IRQ_BASE,
401 .irq_end = TWL4030_GPIO_IRQ_END,
402 .setup = omap3pandora_twl_gpio_setup,
405 static struct regulator_consumer_supply pandora_vmmc1_supply[] = {
406 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
409 static struct regulator_consumer_supply pandora_vmmc2_supply[] = {
410 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1")
413 static struct regulator_consumer_supply pandora_vmmc3_supply[] = {
414 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.2"),
417 static struct regulator_consumer_supply pandora_vdds_supplies[] = {
418 REGULATOR_SUPPLY("vdds_sdi", "omapdss"),
419 REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
420 REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
423 static struct regulator_consumer_supply pandora_vcc_lcd_supply[] = {
424 REGULATOR_SUPPLY("vcc", "display0"),
427 static struct regulator_consumer_supply pandora_usb_phy_supply[] = {
428 REGULATOR_SUPPLY("hsusb0", "ehci-omap.0"),
431 /* ads7846 on SPI and 2 nub controllers on I2C */
432 static struct regulator_consumer_supply pandora_vaux4_supplies[] = {
433 REGULATOR_SUPPLY("vcc", "spi1.0"),
434 REGULATOR_SUPPLY("vcc", "3-0066"),
435 REGULATOR_SUPPLY("vcc", "3-0067"),
438 static struct regulator_consumer_supply pandora_adac_supply[] = {
439 REGULATOR_SUPPLY("vcc", "soc-audio"),
442 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
443 static struct regulator_init_data pandora_vmmc1 = {
447 .valid_modes_mask = REGULATOR_MODE_NORMAL
448 | REGULATOR_MODE_STANDBY,
449 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
450 | REGULATOR_CHANGE_MODE
451 | REGULATOR_CHANGE_STATUS,
453 .num_consumer_supplies = ARRAY_SIZE(pandora_vmmc1_supply),
454 .consumer_supplies = pandora_vmmc1_supply,
457 /* VMMC2 for MMC2 pins CMD, CLK, DAT0..DAT3 (max 100 mA) */
458 static struct regulator_init_data pandora_vmmc2 = {
462 .valid_modes_mask = REGULATOR_MODE_NORMAL
463 | REGULATOR_MODE_STANDBY,
464 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
465 | REGULATOR_CHANGE_MODE
466 | REGULATOR_CHANGE_STATUS,
468 .num_consumer_supplies = ARRAY_SIZE(pandora_vmmc2_supply),
469 .consumer_supplies = pandora_vmmc2_supply,
473 static struct regulator_init_data pandora_vaux1 = {
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_vcc_lcd_supply),
484 .consumer_supplies = pandora_vcc_lcd_supply,
487 /* VAUX2 for USB host PHY */
488 static struct regulator_init_data pandora_vaux2 = {
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 = ARRAY_SIZE(pandora_usb_phy_supply),
499 .consumer_supplies = pandora_usb_phy_supply,
502 /* VAUX4 for ads7846 and nubs */
503 static struct regulator_init_data pandora_vaux4 = {
508 .valid_modes_mask = REGULATOR_MODE_NORMAL
509 | REGULATOR_MODE_STANDBY,
510 .valid_ops_mask = REGULATOR_CHANGE_MODE
511 | REGULATOR_CHANGE_STATUS,
513 .num_consumer_supplies = ARRAY_SIZE(pandora_vaux4_supplies),
514 .consumer_supplies = pandora_vaux4_supplies,
517 /* VSIM for audio DAC */
518 static struct regulator_init_data pandora_vsim = {
523 .valid_modes_mask = REGULATOR_MODE_NORMAL
524 | REGULATOR_MODE_STANDBY,
525 .valid_ops_mask = REGULATOR_CHANGE_MODE
526 | REGULATOR_CHANGE_STATUS,
528 .num_consumer_supplies = ARRAY_SIZE(pandora_adac_supply),
529 .consumer_supplies = pandora_adac_supply,
532 /* Fixed regulator internal to Wifi module */
533 static struct regulator_init_data pandora_vmmc3 = {
535 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
537 .num_consumer_supplies = ARRAY_SIZE(pandora_vmmc3_supply),
538 .consumer_supplies = pandora_vmmc3_supply,
541 static struct fixed_voltage_config pandora_vwlan = {
542 .supply_name = "vwlan",
543 .microvolts = 1800000, /* 1.8V */
544 .gpio = PANDORA_WIFI_NRESET_GPIO,
545 .startup_delay = 50000, /* 50ms */
547 .enabled_at_boot = 0,
548 .init_data = &pandora_vmmc3,
551 static struct platform_device pandora_vwlan_device = {
552 .name = "reg-fixed-voltage",
555 .platform_data = &pandora_vwlan,
559 static struct twl4030_bci_platform_data pandora_bci_data;
561 static struct twl4030_power_data pandora_power_data = {
565 static struct twl4030_platform_data omap3pandora_twldata = {
566 .gpio = &omap3pandora_gpio_data,
567 .vmmc1 = &pandora_vmmc1,
568 .vmmc2 = &pandora_vmmc2,
569 .vaux1 = &pandora_vaux1,
570 .vaux2 = &pandora_vaux2,
571 .vaux4 = &pandora_vaux4,
572 .vsim = &pandora_vsim,
573 .keypad = &pandora_kp_data,
574 .bci = &pandora_bci_data,
575 .power = &pandora_power_data,
578 static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
580 I2C_BOARD_INFO("tps65950", 0x48),
581 .flags = I2C_CLIENT_WAKE,
582 .irq = INT_34XX_SYS_NIRQ,
583 .platform_data = &omap3pandora_twldata,
587 static struct vsense_platform_data omap3pandora_nub1_data = {
592 static struct vsense_platform_data omap3pandora_nub2_data = {
597 static struct i2c_board_info __initdata omap3pandora_i2c3_boardinfo[] = {
599 I2C_BOARD_INFO("vsense", 0x66),
600 .flags = I2C_CLIENT_WAKE,
601 .platform_data = &omap3pandora_nub1_data,
603 I2C_BOARD_INFO("vsense", 0x67),
604 .flags = I2C_CLIENT_WAKE,
605 .platform_data = &omap3pandora_nub2_data,
607 I2C_BOARD_INFO("bq27500", 0x55),
608 .flags = I2C_CLIENT_WAKE,
612 static int __init omap3pandora_i2c_init(void)
614 omap3_pmic_get_config(&omap3pandora_twldata,
615 TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_AUDIO,
616 TWL_COMMON_REGULATOR_VDAC | TWL_COMMON_REGULATOR_VPLL2);
618 omap3pandora_twldata.vdac->constraints.apply_uV = true;
620 omap3pandora_twldata.vpll2->constraints.apply_uV = true;
621 omap3pandora_twldata.vpll2->num_consumer_supplies =
622 ARRAY_SIZE(pandora_vdds_supplies);
623 omap3pandora_twldata.vpll2->consumer_supplies = pandora_vdds_supplies;
625 omap3_pmic_init("tps65950", &omap3pandora_twldata);
626 /* i2c2 pins are not connected */
627 omap_register_i2c_bus(3, 100, omap3pandora_i2c3_boardinfo,
628 ARRAY_SIZE(omap3pandora_i2c3_boardinfo));
632 static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
634 .modalias = "tpo_td043mtea1_panel_spi",
637 .max_speed_hz = 375000,
638 .platform_data = &pandora_lcd_device,
642 static void __init pandora_wl1251_init(void)
644 struct wl12xx_platform_data pandora_wl1251_pdata;
647 memset(&pandora_wl1251_pdata, 0, sizeof(pandora_wl1251_pdata));
649 ret = gpio_request_one(PANDORA_WIFI_IRQ_GPIO, GPIOF_IN, "wl1251 irq");
653 pandora_wl1251_pdata.irq = gpio_to_irq(PANDORA_WIFI_IRQ_GPIO);
654 if (pandora_wl1251_pdata.irq < 0)
657 pandora_wl1251_pdata.use_eeprom = true;
658 ret = wl12xx_set_platform_data(&pandora_wl1251_pdata);
665 gpio_free(PANDORA_WIFI_IRQ_GPIO);
667 printk(KERN_ERR "wl1251 board initialisation failed\n");
670 static void __init pandora_usb_host_init(void)
674 ret = gpio_request_one(PANDORA_EN_USB_5V_GPIO, GPIOF_OUT_INIT_HIGH,
677 pr_err("Cannot set vbus GPIO, ret=%d\n", ret);
680 static struct platform_device *omap3pandora_devices[] __initdata = {
685 &pandora_vwlan_device,
688 static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
690 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
691 .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
692 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
695 .reset_gpio_port[0] = 16,
696 .reset_gpio_port[1] = -EINVAL,
697 .reset_gpio_port[2] = -EINVAL
700 #ifdef CONFIG_OMAP_MUX
701 static struct omap_board_mux board_mux[] __initdata = {
702 { .reg_offset = OMAP_MUX_TERMINATOR },
706 static void __init omap3pandora_init(void)
708 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
709 pandora_usb_host_init();
710 omap3pandora_i2c_init();
711 pandora_wl1251_init();
712 platform_add_devices(omap3pandora_devices,
713 ARRAY_SIZE(omap3pandora_devices));
714 omap_display_init(&pandora_dss_data);
716 omap_sdrc_init(mt46h32m32lf6_sdrc_params,
717 mt46h32m32lf6_sdrc_params);
718 spi_register_board_info(omap3pandora_spi_board_info,
719 ARRAY_SIZE(omap3pandora_spi_board_info));
720 omap_ads7846_init(1, OMAP3_PANDORA_TS_GPIO, 0, NULL);
721 usbhs_init(&usbhs_bdata);
723 gpmc_nand_init(&pandora_nand_data);
725 /* Ensure SDRC pins are mux'd for self-refresh */
726 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
727 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
730 /* HACK: create it here, so that others don't need to bother */
731 #ifdef CONFIG_PROC_FS
732 #include <linux/proc_fs.h>
734 static int __init proc_pandora_init(void)
736 struct proc_dir_entry *ret;
738 ret = proc_mkdir("pandora", NULL);
743 fs_initcall(proc_pandora_init);
746 MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
747 .atag_offset = 0x100,
748 .reserve = omap_reserve,
749 .map_io = omap3_map_io,
750 .init_early = omap35xx_init_early,
751 .init_irq = omap3_init_irq,
752 .init_machine = omap3pandora_init,
753 .timer = &omap3_timer,