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/leds.h>
29 #include <linux/input.h>
30 #include <linux/input/matrix_keypad.h>
31 #include <linux/gpio_keys.h>
33 #include <asm/mach-types.h>
34 #include <asm/mach/arch.h>
35 #include <asm/mach/map.h>
37 #include <plat/board.h>
38 #include <plat/common.h>
39 #include <mach/gpio.h>
40 #include <mach/hardware.h>
41 #include <plat/mcspi.h>
43 #include <plat/display.h>
46 #include "sdram-micron-mt46h32m32lf-6.h"
49 #define OMAP3_PANDORA_TS_GPIO 94
51 /* hardware debounce: (value + 1) * 31us */
52 #define GPIO_DEBOUNCE_TIME 127
54 static struct gpio_led pandora_gpio_leds[] = {
56 .name = "pandora::sd1",
57 .default_trigger = "mmc0",
60 .name = "pandora::sd2",
61 .default_trigger = "mmc1",
64 .name = "pandora::bluetooth",
67 .name = "pandora::wifi",
72 static struct gpio_led_platform_data pandora_gpio_led_data = {
73 .leds = pandora_gpio_leds,
74 .num_leds = ARRAY_SIZE(pandora_gpio_leds),
77 static struct platform_device pandora_leds_gpio = {
81 .platform_data = &pandora_gpio_led_data,
85 #define GPIO_BUTTON(gpio_num, ev_type, ev_code, act_low, descr) \
90 .active_low = act_low, \
91 .desc = "btn " descr, \
94 #define GPIO_BUTTON_LOW(gpio_num, event_code, description) \
95 GPIO_BUTTON(gpio_num, EV_KEY, event_code, 1, description)
97 static struct gpio_keys_button pandora_gpio_keys[] = {
98 GPIO_BUTTON_LOW(110, KEY_UP, "up"),
99 GPIO_BUTTON_LOW(103, KEY_DOWN, "down"),
100 GPIO_BUTTON_LOW(96, KEY_LEFT, "left"),
101 GPIO_BUTTON_LOW(98, KEY_RIGHT, "right"),
102 GPIO_BUTTON_LOW(109, KEY_KP1, "game 1"),
103 GPIO_BUTTON_LOW(111, KEY_KP2, "game 2"),
104 GPIO_BUTTON_LOW(106, KEY_KP3, "game 3"),
105 GPIO_BUTTON_LOW(101, KEY_KP4, "game 4"),
106 GPIO_BUTTON_LOW(102, BTN_TL, "l"),
107 GPIO_BUTTON_LOW(97, BTN_TL2, "l2"),
108 GPIO_BUTTON_LOW(105, BTN_TR, "r"),
109 GPIO_BUTTON_LOW(107, BTN_TR2, "r2"),
110 GPIO_BUTTON_LOW(104, KEY_LEFTCTRL, "ctrl"),
111 GPIO_BUTTON_LOW(99, KEY_MENU, "menu"),
112 GPIO_BUTTON_LOW(176, KEY_COFFEE, "hold"),
113 GPIO_BUTTON(100, EV_KEY, KEY_LEFTALT, 0, "alt"),
114 GPIO_BUTTON(108, EV_SW, SW_LID, 1, "lid"),
117 static struct gpio_keys_platform_data pandora_gpio_key_info = {
118 .buttons = pandora_gpio_keys,
119 .nbuttons = ARRAY_SIZE(pandora_gpio_keys),
122 static struct platform_device pandora_keys_gpio = {
126 .platform_data = &pandora_gpio_key_info,
130 static void __init pandora_keys_gpio_init(void)
132 /* set debounce time for GPIO banks 4 and 6 */
133 omap_set_gpio_debounce_time(32 * 3, GPIO_DEBOUNCE_TIME);
134 omap_set_gpio_debounce_time(32 * 5, GPIO_DEBOUNCE_TIME);
137 static int board_keymap[] = {
150 KEY(1, 5, KEY_SPACE),
151 KEY(2, 0, KEY_BACKSPACE),
177 KEY(7, 0, KEY_ENTER),
180 KEY(7, 3, KEY_LEFTSHIFT),
181 KEY(7, 4, KEY_COMMA),
184 static struct matrix_keymap_data board_map_data = {
185 .keymap = board_keymap,
186 .keymap_size = ARRAY_SIZE(board_keymap),
189 static struct twl4030_keypad_data pandora_kp_data = {
190 .keymap_data = &board_map_data,
196 static struct omap_dss_device pandora_lcd_device = {
198 .driver_name = "tpo_td043mtea1_panel",
199 .type = OMAP_DISPLAY_TYPE_DPI,
200 .phy.dpi.data_lines = 24,
204 static struct omap_dss_device pandora_tv_device = {
206 .driver_name = "venc",
207 .type = OMAP_DISPLAY_TYPE_VENC,
208 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
211 static struct omap_dss_device *pandora_dss_devices[] = {
216 static struct omap_dss_board_info pandora_dss_data = {
217 .num_devices = ARRAY_SIZE(pandora_dss_devices),
218 .devices = pandora_dss_devices,
219 .default_device = &pandora_lcd_device,
222 static struct platform_device pandora_dss_device = {
226 .platform_data = &pandora_dss_data,
230 static struct omap2_hsmmc_info omap3pandora_mmc[] = {
255 static int omap3pandora_twl_gpio_setup(struct device *dev,
256 unsigned gpio, unsigned ngpio)
258 /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
259 omap3pandora_mmc[0].gpio_cd = gpio + 0;
260 omap3pandora_mmc[1].gpio_cd = gpio + 1;
261 omap2_hsmmc_init(omap3pandora_mmc);
266 static struct twl4030_gpio_platform_data omap3pandora_gpio_data = {
267 .gpio_base = OMAP_MAX_GPIO_LINES,
268 .irq_base = TWL4030_GPIO_IRQ_BASE,
269 .irq_end = TWL4030_GPIO_IRQ_END,
270 .setup = omap3pandora_twl_gpio_setup,
273 static struct regulator_consumer_supply pandora_vmmc1_supply =
274 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.0");
276 static struct regulator_consumer_supply pandora_vmmc2_supply =
277 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.1");
279 static struct regulator_consumer_supply pandora_vdda_dac_supply =
280 REGULATOR_SUPPLY("vdda_dac", "omapdss");
282 static struct regulator_consumer_supply pandora_vdds_supplies[] = {
283 REGULATOR_SUPPLY("vdds_sdi", "omapdss"),
284 REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
287 static struct regulator_consumer_supply pandora_vcc_lcd_supply =
288 REGULATOR_SUPPLY("vcc", "display0");
290 static struct regulator_consumer_supply pandora_usb_phy_supply =
291 REGULATOR_SUPPLY("hsusb0", "ehci-omap.0");
293 /* ads7846 on SPI and 2 nub controllers on I2C */
294 static struct regulator_consumer_supply pandora_vaux4_supplies[] = {
295 REGULATOR_SUPPLY("vcc", "spi1.0"),
296 REGULATOR_SUPPLY("vcc", "3-0066"),
297 REGULATOR_SUPPLY("vcc", "3-0067"),
300 static struct regulator_consumer_supply pandora_adac_supply =
301 REGULATOR_SUPPLY("vcc", "soc-audio");
303 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
304 static struct regulator_init_data pandora_vmmc1 = {
308 .valid_modes_mask = REGULATOR_MODE_NORMAL
309 | REGULATOR_MODE_STANDBY,
310 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
311 | REGULATOR_CHANGE_MODE
312 | REGULATOR_CHANGE_STATUS,
314 .num_consumer_supplies = 1,
315 .consumer_supplies = &pandora_vmmc1_supply,
318 /* VMMC2 for MMC2 pins CMD, CLK, DAT0..DAT3 (max 100 mA) */
319 static struct regulator_init_data pandora_vmmc2 = {
323 .valid_modes_mask = REGULATOR_MODE_NORMAL
324 | REGULATOR_MODE_STANDBY,
325 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
326 | REGULATOR_CHANGE_MODE
327 | REGULATOR_CHANGE_STATUS,
329 .num_consumer_supplies = 1,
330 .consumer_supplies = &pandora_vmmc2_supply,
333 /* VDAC for DSS driving S-Video */
334 static struct regulator_init_data pandora_vdac = {
339 .valid_modes_mask = REGULATOR_MODE_NORMAL
340 | REGULATOR_MODE_STANDBY,
341 .valid_ops_mask = REGULATOR_CHANGE_MODE
342 | REGULATOR_CHANGE_STATUS,
344 .num_consumer_supplies = 1,
345 .consumer_supplies = &pandora_vdda_dac_supply,
348 /* VPLL2 for digital video outputs */
349 static struct regulator_init_data pandora_vpll2 = {
354 .valid_modes_mask = REGULATOR_MODE_NORMAL
355 | REGULATOR_MODE_STANDBY,
356 .valid_ops_mask = REGULATOR_CHANGE_MODE
357 | REGULATOR_CHANGE_STATUS,
359 .num_consumer_supplies = ARRAY_SIZE(pandora_vdds_supplies),
360 .consumer_supplies = pandora_vdds_supplies,
364 static struct regulator_init_data pandora_vaux1 = {
369 .valid_modes_mask = REGULATOR_MODE_NORMAL
370 | REGULATOR_MODE_STANDBY,
371 .valid_ops_mask = REGULATOR_CHANGE_MODE
372 | REGULATOR_CHANGE_STATUS,
374 .num_consumer_supplies = 1,
375 .consumer_supplies = &pandora_vcc_lcd_supply,
378 /* VAUX2 for USB host PHY */
379 static struct regulator_init_data pandora_vaux2 = {
384 .valid_modes_mask = REGULATOR_MODE_NORMAL
385 | REGULATOR_MODE_STANDBY,
386 .valid_ops_mask = REGULATOR_CHANGE_MODE
387 | REGULATOR_CHANGE_STATUS,
389 .num_consumer_supplies = 1,
390 .consumer_supplies = &pandora_usb_phy_supply,
393 /* VAUX4 for ads7846 and nubs */
394 static struct regulator_init_data pandora_vaux4 = {
399 .valid_modes_mask = REGULATOR_MODE_NORMAL
400 | REGULATOR_MODE_STANDBY,
401 .valid_ops_mask = REGULATOR_CHANGE_MODE
402 | REGULATOR_CHANGE_STATUS,
404 .num_consumer_supplies = ARRAY_SIZE(pandora_vaux4_supplies),
405 .consumer_supplies = pandora_vaux4_supplies,
408 /* VSIM for audio DAC */
409 static struct regulator_init_data pandora_vsim = {
414 .valid_modes_mask = REGULATOR_MODE_NORMAL
415 | REGULATOR_MODE_STANDBY,
416 .valid_ops_mask = REGULATOR_CHANGE_MODE
417 | REGULATOR_CHANGE_STATUS,
419 .num_consumer_supplies = 1,
420 .consumer_supplies = &pandora_adac_supply,
423 static struct twl4030_usb_data omap3pandora_usb_data = {
424 .usb_mode = T2_USB_MODE_ULPI,
427 static struct twl4030_codec_audio_data omap3pandora_audio_data = {
428 .audio_mclk = 26000000,
431 static struct twl4030_codec_data omap3pandora_codec_data = {
432 .audio_mclk = 26000000,
433 .audio = &omap3pandora_audio_data,
436 static struct twl4030_platform_data omap3pandora_twldata = {
437 .irq_base = TWL4030_IRQ_BASE,
438 .irq_end = TWL4030_IRQ_END,
439 .gpio = &omap3pandora_gpio_data,
440 .usb = &omap3pandora_usb_data,
441 .codec = &omap3pandora_codec_data,
442 .vmmc1 = &pandora_vmmc1,
443 .vmmc2 = &pandora_vmmc2,
444 .vdac = &pandora_vdac,
445 .vpll2 = &pandora_vpll2,
446 .vaux1 = &pandora_vaux1,
447 .vaux2 = &pandora_vaux2,
448 .vaux4 = &pandora_vaux4,
449 .vsim = &pandora_vsim,
450 .keypad = &pandora_kp_data,
453 static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
455 I2C_BOARD_INFO("tps65950", 0x48),
456 .flags = I2C_CLIENT_WAKE,
457 .irq = INT_34XX_SYS_NIRQ,
458 .platform_data = &omap3pandora_twldata,
462 static struct i2c_board_info __initdata omap3pandora_i2c3_boardinfo[] = {
464 I2C_BOARD_INFO("bq27500", 0x55),
465 .flags = I2C_CLIENT_WAKE,
469 static int __init omap3pandora_i2c_init(void)
471 omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo,
472 ARRAY_SIZE(omap3pandora_i2c_boardinfo));
473 /* i2c2 pins are not connected */
474 omap_register_i2c_bus(3, 100, omap3pandora_i2c3_boardinfo,
475 ARRAY_SIZE(omap3pandora_i2c3_boardinfo));
479 static void __init omap3pandora_ads7846_init(void)
481 int gpio = OMAP3_PANDORA_TS_GPIO;
484 ret = gpio_request(gpio, "ads7846_pen_down");
486 printk(KERN_ERR "Failed to request GPIO %d for "
487 "ads7846 pen down IRQ\n", gpio);
491 gpio_direction_input(gpio);
494 static int ads7846_get_pendown_state(void)
496 return !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
499 static struct ads7846_platform_data ads7846_config = {
507 .get_pendown_state = ads7846_get_pendown_state,
511 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
513 .single_channel = 1, /* 0: slave, 1: master */
516 static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
518 .modalias = "ads7846",
521 .max_speed_hz = 1500000,
522 .controller_data = &ads7846_mcspi_config,
523 .irq = OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO),
524 .platform_data = &ads7846_config,
526 .modalias = "tpo_td043mtea1_panel_spi",
529 .max_speed_hz = 375000,
530 .platform_data = &pandora_lcd_device,
534 static void __init omap3pandora_init_irq(void)
536 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
537 mt46h32m32lf6_sdrc_params);
542 static struct platform_device *omap3pandora_devices[] __initdata = {
548 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
550 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
551 .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
552 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
555 .reset_gpio_port[0] = 16,
556 .reset_gpio_port[1] = -EINVAL,
557 .reset_gpio_port[2] = -EINVAL
560 #ifdef CONFIG_OMAP_MUX
561 static struct omap_board_mux board_mux[] __initdata = {
562 { .reg_offset = OMAP_MUX_TERMINATOR },
565 #define board_mux NULL
568 static struct omap_musb_board_data musb_board_data = {
569 .interface_type = MUSB_INTERFACE_ULPI,
574 static void __init omap3pandora_init(void)
576 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
577 omap3pandora_i2c_init();
578 platform_add_devices(omap3pandora_devices,
579 ARRAY_SIZE(omap3pandora_devices));
581 spi_register_board_info(omap3pandora_spi_board_info,
582 ARRAY_SIZE(omap3pandora_spi_board_info));
583 omap3pandora_ads7846_init();
584 usb_ehci_init(&ehci_pdata);
585 pandora_keys_gpio_init();
586 usb_musb_init(&musb_board_data);
588 /* Ensure SDRC pins are mux'd for self-refresh */
589 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
590 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
593 static void __init omap3pandora_map_io(void)
595 omap2_set_globals_343x();
596 omap34xx_map_common_io();
599 MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
600 .phys_io = 0x48000000,
601 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
602 .boot_params = 0x80000100,
603 .map_io = omap3pandora_map_io,
604 .init_irq = omap3pandora_init_irq,
605 .init_machine = omap3pandora_init,
606 .timer = &omap_timer,