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/leds.h>
30 #include <linux/input.h>
31 #include <linux/input/matrix_keypad.h>
32 #include <linux/gpio_keys.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
38 #include <plat/board.h>
39 #include <plat/common.h>
40 #include <mach/gpio.h>
41 #include <mach/hardware.h>
42 #include <plat/mcspi.h>
44 #include <plat/display.h>
47 #include "sdram-micron-mt46h32m32lf-6.h"
50 #define OMAP3_PANDORA_TS_GPIO 94
52 /* hardware debounce: (value + 1) * 31us */
53 #define GPIO_DEBOUNCE_TIME 127
55 static struct gpio_led pandora_gpio_leds
[] = {
57 .name
= "pandora::sd1",
58 .default_trigger
= "mmc0",
61 .name
= "pandora::sd2",
62 .default_trigger
= "mmc1",
65 .name
= "pandora::bluetooth",
68 .name
= "pandora::wifi",
73 static struct gpio_led_platform_data pandora_gpio_led_data
= {
74 .leds
= pandora_gpio_leds
,
75 .num_leds
= ARRAY_SIZE(pandora_gpio_leds
),
78 static struct platform_device pandora_leds_gpio
= {
82 .platform_data
= &pandora_gpio_led_data
,
86 #define GPIO_BUTTON(gpio_num, ev_type, ev_code, act_low, descr) \
91 .active_low = act_low, \
92 .desc = "btn " descr, \
95 #define GPIO_BUTTON_LOW(gpio_num, event_code, description) \
96 GPIO_BUTTON(gpio_num, EV_KEY, event_code, 1, description)
98 static struct gpio_keys_button pandora_gpio_keys
[] = {
99 GPIO_BUTTON_LOW(110, KEY_UP
, "up"),
100 GPIO_BUTTON_LOW(103, KEY_DOWN
, "down"),
101 GPIO_BUTTON_LOW(96, KEY_LEFT
, "left"),
102 GPIO_BUTTON_LOW(98, KEY_RIGHT
, "right"),
103 GPIO_BUTTON_LOW(109, KEY_KP1
, "game 1"),
104 GPIO_BUTTON_LOW(111, KEY_KP2
, "game 2"),
105 GPIO_BUTTON_LOW(106, KEY_KP3
, "game 3"),
106 GPIO_BUTTON_LOW(101, KEY_KP4
, "game 4"),
107 GPIO_BUTTON_LOW(102, BTN_TL
, "l"),
108 GPIO_BUTTON_LOW(97, BTN_TL2
, "l2"),
109 GPIO_BUTTON_LOW(105, BTN_TR
, "r"),
110 GPIO_BUTTON_LOW(107, BTN_TR2
, "r2"),
111 GPIO_BUTTON_LOW(104, KEY_LEFTCTRL
, "ctrl"),
112 GPIO_BUTTON_LOW(99, KEY_MENU
, "menu"),
113 GPIO_BUTTON_LOW(176, KEY_COFFEE
, "hold"),
114 GPIO_BUTTON(100, EV_KEY
, KEY_LEFTALT
, 0, "alt"),
115 GPIO_BUTTON(108, EV_SW
, SW_LID
, 1, "lid"),
118 static struct gpio_keys_platform_data pandora_gpio_key_info
= {
119 .buttons
= pandora_gpio_keys
,
120 .nbuttons
= ARRAY_SIZE(pandora_gpio_keys
),
123 static struct platform_device pandora_keys_gpio
= {
127 .platform_data
= &pandora_gpio_key_info
,
131 static void __init
pandora_keys_gpio_init(void)
133 /* set debounce time for GPIO banks 4 and 6 */
134 gpio_set_debounce(32 * 3, GPIO_DEBOUNCE_TIME
);
135 gpio_set_debounce(32 * 5, GPIO_DEBOUNCE_TIME
);
138 static int board_keymap
[] = {
151 KEY(1, 5, KEY_SPACE
),
152 KEY(2, 0, KEY_BACKSPACE
),
178 KEY(7, 0, KEY_ENTER
),
181 KEY(7, 3, KEY_LEFTSHIFT
),
182 KEY(7, 4, KEY_COMMA
),
185 static struct matrix_keymap_data board_map_data
= {
186 .keymap
= board_keymap
,
187 .keymap_size
= ARRAY_SIZE(board_keymap
),
190 static struct twl4030_keypad_data pandora_kp_data
= {
191 .keymap_data
= &board_map_data
,
197 static struct omap_dss_device pandora_lcd_device
= {
199 .driver_name
= "tpo_td043mtea1_panel",
200 .type
= OMAP_DISPLAY_TYPE_DPI
,
201 .phy
.dpi
.data_lines
= 24,
205 static struct omap_dss_device pandora_tv_device
= {
207 .driver_name
= "venc",
208 .type
= OMAP_DISPLAY_TYPE_VENC
,
209 .phy
.venc
.type
= OMAP_DSS_VENC_TYPE_SVIDEO
,
212 static struct omap_dss_device
*pandora_dss_devices
[] = {
217 static struct omap_dss_board_info pandora_dss_data
= {
218 .num_devices
= ARRAY_SIZE(pandora_dss_devices
),
219 .devices
= pandora_dss_devices
,
220 .default_device
= &pandora_lcd_device
,
223 static struct platform_device pandora_dss_device
= {
227 .platform_data
= &pandora_dss_data
,
231 static struct omap2_hsmmc_info omap3pandora_mmc
[] = {
256 static int omap3pandora_twl_gpio_setup(struct device
*dev
,
257 unsigned gpio
, unsigned ngpio
)
259 /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
260 omap3pandora_mmc
[0].gpio_cd
= gpio
+ 0;
261 omap3pandora_mmc
[1].gpio_cd
= gpio
+ 1;
262 omap2_hsmmc_init(omap3pandora_mmc
);
267 static struct twl4030_gpio_platform_data omap3pandora_gpio_data
= {
268 .gpio_base
= OMAP_MAX_GPIO_LINES
,
269 .irq_base
= TWL4030_GPIO_IRQ_BASE
,
270 .irq_end
= TWL4030_GPIO_IRQ_END
,
271 .setup
= omap3pandora_twl_gpio_setup
,
274 static struct regulator_consumer_supply pandora_vmmc1_supply
=
275 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.0");
277 static struct regulator_consumer_supply pandora_vmmc2_supply
=
278 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.1");
280 static struct regulator_consumer_supply pandora_vdda_dac_supply
=
281 REGULATOR_SUPPLY("vdda_dac", "omapdss");
283 static struct regulator_consumer_supply pandora_vdds_supplies
[] = {
284 REGULATOR_SUPPLY("vdds_sdi", "omapdss"),
285 REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
288 static struct regulator_consumer_supply pandora_vcc_lcd_supply
=
289 REGULATOR_SUPPLY("vcc", "display0");
291 static struct regulator_consumer_supply pandora_usb_phy_supply
=
292 REGULATOR_SUPPLY("hsusb0", "ehci-omap.0");
294 /* ads7846 on SPI and 2 nub controllers on I2C */
295 static struct regulator_consumer_supply pandora_vaux4_supplies
[] = {
296 REGULATOR_SUPPLY("vcc", "spi1.0"),
297 REGULATOR_SUPPLY("vcc", "3-0066"),
298 REGULATOR_SUPPLY("vcc", "3-0067"),
301 static struct regulator_consumer_supply pandora_adac_supply
=
302 REGULATOR_SUPPLY("vcc", "soc-audio");
304 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
305 static struct regulator_init_data pandora_vmmc1
= {
309 .valid_modes_mask
= REGULATOR_MODE_NORMAL
310 | REGULATOR_MODE_STANDBY
,
311 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
312 | REGULATOR_CHANGE_MODE
313 | REGULATOR_CHANGE_STATUS
,
315 .num_consumer_supplies
= 1,
316 .consumer_supplies
= &pandora_vmmc1_supply
,
319 /* VMMC2 for MMC2 pins CMD, CLK, DAT0..DAT3 (max 100 mA) */
320 static struct regulator_init_data pandora_vmmc2
= {
324 .valid_modes_mask
= REGULATOR_MODE_NORMAL
325 | REGULATOR_MODE_STANDBY
,
326 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
327 | REGULATOR_CHANGE_MODE
328 | REGULATOR_CHANGE_STATUS
,
330 .num_consumer_supplies
= 1,
331 .consumer_supplies
= &pandora_vmmc2_supply
,
334 /* VDAC for DSS driving S-Video */
335 static struct regulator_init_data pandora_vdac
= {
340 .valid_modes_mask
= REGULATOR_MODE_NORMAL
341 | REGULATOR_MODE_STANDBY
,
342 .valid_ops_mask
= REGULATOR_CHANGE_MODE
343 | REGULATOR_CHANGE_STATUS
,
345 .num_consumer_supplies
= 1,
346 .consumer_supplies
= &pandora_vdda_dac_supply
,
349 /* VPLL2 for digital video outputs */
350 static struct regulator_init_data pandora_vpll2
= {
355 .valid_modes_mask
= REGULATOR_MODE_NORMAL
356 | REGULATOR_MODE_STANDBY
,
357 .valid_ops_mask
= REGULATOR_CHANGE_MODE
358 | REGULATOR_CHANGE_STATUS
,
360 .num_consumer_supplies
= ARRAY_SIZE(pandora_vdds_supplies
),
361 .consumer_supplies
= pandora_vdds_supplies
,
365 static struct regulator_init_data pandora_vaux1
= {
370 .valid_modes_mask
= REGULATOR_MODE_NORMAL
371 | REGULATOR_MODE_STANDBY
,
372 .valid_ops_mask
= REGULATOR_CHANGE_MODE
373 | REGULATOR_CHANGE_STATUS
,
375 .num_consumer_supplies
= 1,
376 .consumer_supplies
= &pandora_vcc_lcd_supply
,
379 /* VAUX2 for USB host PHY */
380 static struct regulator_init_data pandora_vaux2
= {
385 .valid_modes_mask
= REGULATOR_MODE_NORMAL
386 | REGULATOR_MODE_STANDBY
,
387 .valid_ops_mask
= REGULATOR_CHANGE_MODE
388 | REGULATOR_CHANGE_STATUS
,
390 .num_consumer_supplies
= 1,
391 .consumer_supplies
= &pandora_usb_phy_supply
,
394 /* VAUX4 for ads7846 and nubs */
395 static struct regulator_init_data pandora_vaux4
= {
400 .valid_modes_mask
= REGULATOR_MODE_NORMAL
401 | REGULATOR_MODE_STANDBY
,
402 .valid_ops_mask
= REGULATOR_CHANGE_MODE
403 | REGULATOR_CHANGE_STATUS
,
405 .num_consumer_supplies
= ARRAY_SIZE(pandora_vaux4_supplies
),
406 .consumer_supplies
= pandora_vaux4_supplies
,
409 /* VSIM for audio DAC */
410 static struct regulator_init_data pandora_vsim
= {
415 .valid_modes_mask
= REGULATOR_MODE_NORMAL
416 | REGULATOR_MODE_STANDBY
,
417 .valid_ops_mask
= REGULATOR_CHANGE_MODE
418 | REGULATOR_CHANGE_STATUS
,
420 .num_consumer_supplies
= 1,
421 .consumer_supplies
= &pandora_adac_supply
,
424 static struct twl4030_usb_data omap3pandora_usb_data
= {
425 .usb_mode
= T2_USB_MODE_ULPI
,
428 static struct twl4030_codec_audio_data omap3pandora_audio_data
= {
429 .audio_mclk
= 26000000,
432 static struct twl4030_codec_data omap3pandora_codec_data
= {
433 .audio_mclk
= 26000000,
434 .audio
= &omap3pandora_audio_data
,
437 static struct twl4030_platform_data omap3pandora_twldata
= {
438 .irq_base
= TWL4030_IRQ_BASE
,
439 .irq_end
= TWL4030_IRQ_END
,
440 .gpio
= &omap3pandora_gpio_data
,
441 .usb
= &omap3pandora_usb_data
,
442 .codec
= &omap3pandora_codec_data
,
443 .vmmc1
= &pandora_vmmc1
,
444 .vmmc2
= &pandora_vmmc2
,
445 .vdac
= &pandora_vdac
,
446 .vpll2
= &pandora_vpll2
,
447 .vaux1
= &pandora_vaux1
,
448 .vaux2
= &pandora_vaux2
,
449 .vaux4
= &pandora_vaux4
,
450 .vsim
= &pandora_vsim
,
451 .keypad
= &pandora_kp_data
,
454 static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo
[] = {
456 I2C_BOARD_INFO("tps65950", 0x48),
457 .flags
= I2C_CLIENT_WAKE
,
458 .irq
= INT_34XX_SYS_NIRQ
,
459 .platform_data
= &omap3pandora_twldata
,
463 static struct i2c_board_info __initdata omap3pandora_i2c3_boardinfo
[] = {
465 I2C_BOARD_INFO("bq27500", 0x55),
466 .flags
= I2C_CLIENT_WAKE
,
470 static int __init
omap3pandora_i2c_init(void)
472 omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo
,
473 ARRAY_SIZE(omap3pandora_i2c_boardinfo
));
474 /* i2c2 pins are not connected */
475 omap_register_i2c_bus(3, 100, omap3pandora_i2c3_boardinfo
,
476 ARRAY_SIZE(omap3pandora_i2c3_boardinfo
));
480 static void __init
omap3pandora_ads7846_init(void)
482 int gpio
= OMAP3_PANDORA_TS_GPIO
;
485 ret
= gpio_request(gpio
, "ads7846_pen_down");
487 printk(KERN_ERR
"Failed to request GPIO %d for "
488 "ads7846 pen down IRQ\n", gpio
);
492 gpio_direction_input(gpio
);
495 static int ads7846_get_pendown_state(void)
497 return !gpio_get_value(OMAP3_PANDORA_TS_GPIO
);
500 static struct ads7846_platform_data ads7846_config
= {
508 .get_pendown_state
= ads7846_get_pendown_state
,
512 static struct omap2_mcspi_device_config ads7846_mcspi_config
= {
514 .single_channel
= 1, /* 0: slave, 1: master */
517 static struct spi_board_info omap3pandora_spi_board_info
[] __initdata
= {
519 .modalias
= "ads7846",
522 .max_speed_hz
= 1500000,
523 .controller_data
= &ads7846_mcspi_config
,
524 .irq
= OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO
),
525 .platform_data
= &ads7846_config
,
527 .modalias
= "tpo_td043mtea1_panel_spi",
530 .max_speed_hz
= 375000,
531 .platform_data
= &pandora_lcd_device
,
535 static void __init
omap3pandora_init_irq(void)
537 omap2_init_common_hw(mt46h32m32lf6_sdrc_params
,
538 mt46h32m32lf6_sdrc_params
);
543 static struct platform_device
*omap3pandora_devices
[] __initdata
= {
549 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst
= {
551 .port_mode
[0] = EHCI_HCD_OMAP_MODE_PHY
,
552 .port_mode
[1] = EHCI_HCD_OMAP_MODE_UNKNOWN
,
553 .port_mode
[2] = EHCI_HCD_OMAP_MODE_UNKNOWN
,
556 .reset_gpio_port
[0] = 16,
557 .reset_gpio_port
[1] = -EINVAL
,
558 .reset_gpio_port
[2] = -EINVAL
561 #ifdef CONFIG_OMAP_MUX
562 static struct omap_board_mux board_mux
[] __initdata
= {
563 { .reg_offset
= OMAP_MUX_TERMINATOR
},
566 #define board_mux NULL
569 static struct omap_musb_board_data musb_board_data
= {
570 .interface_type
= MUSB_INTERFACE_ULPI
,
575 static void __init
omap3pandora_init(void)
577 omap3_mux_init(board_mux
, OMAP_PACKAGE_CBB
);
578 omap3pandora_i2c_init();
579 platform_add_devices(omap3pandora_devices
,
580 ARRAY_SIZE(omap3pandora_devices
));
582 spi_register_board_info(omap3pandora_spi_board_info
,
583 ARRAY_SIZE(omap3pandora_spi_board_info
));
584 omap3pandora_ads7846_init();
585 usb_ehci_init(&ehci_pdata
);
586 pandora_keys_gpio_init();
587 usb_musb_init(&musb_board_data
);
589 /* Ensure SDRC pins are mux'd for self-refresh */
590 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT
);
591 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT
);
594 static void __init
omap3pandora_map_io(void)
596 omap2_set_globals_343x();
597 omap34xx_map_common_io();
600 MACHINE_START(OMAP3_PANDORA
, "Pandora Handheld Console")
601 .phys_io
= 0x48000000,
602 .io_pg_offst
= ((0xfa000000) >> 18) & 0xfffc,
603 .boot_params
= 0x80000100,
604 .map_io
= omap3pandora_map_io
,
605 .reserve
= omap_reserve
,
606 .init_irq
= omap3pandora_init_irq
,
607 .init_machine
= omap3pandora_init
,
608 .timer
= &omap_timer
,