crypto: omap - Updates omap sham device related platform code
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-omap2 / board-omap3pandora.c
blob4827f4658df391ab3023c25e28d7ca7901628417
1 /*
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
16 * 02110-1301 USA
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>
42 #include <plat/usb.h>
43 #include <plat/display.h>
45 #include "mux.h"
46 #include "sdram-micron-mt46h32m32lf-6.h"
47 #include "hsmmc.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",
58 .gpio = 128,
59 }, {
60 .name = "pandora::sd2",
61 .default_trigger = "mmc1",
62 .gpio = 129,
63 }, {
64 .name = "pandora::bluetooth",
65 .gpio = 158,
66 }, {
67 .name = "pandora::wifi",
68 .gpio = 159,
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 = {
78 .name = "leds-gpio",
79 .id = -1,
80 .dev = {
81 .platform_data = &pandora_gpio_led_data,
85 #define GPIO_BUTTON(gpio_num, ev_type, ev_code, act_low, descr) \
86 { \
87 .gpio = gpio_num, \
88 .type = ev_type, \
89 .code = ev_code, \
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 = {
123 .name = "gpio-keys",
124 .id = -1,
125 .dev = {
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[] = {
138 /* row, col, code */
139 KEY(0, 0, KEY_9),
140 KEY(0, 1, KEY_8),
141 KEY(0, 2, KEY_I),
142 KEY(0, 3, KEY_J),
143 KEY(0, 4, KEY_N),
144 KEY(0, 5, KEY_M),
145 KEY(1, 0, KEY_0),
146 KEY(1, 1, KEY_7),
147 KEY(1, 2, KEY_U),
148 KEY(1, 3, KEY_H),
149 KEY(1, 4, KEY_B),
150 KEY(1, 5, KEY_SPACE),
151 KEY(2, 0, KEY_BACKSPACE),
152 KEY(2, 1, KEY_6),
153 KEY(2, 2, KEY_Y),
154 KEY(2, 3, KEY_G),
155 KEY(2, 4, KEY_V),
156 KEY(2, 5, KEY_FN),
157 KEY(3, 0, KEY_O),
158 KEY(3, 1, KEY_5),
159 KEY(3, 2, KEY_T),
160 KEY(3, 3, KEY_F),
161 KEY(3, 4, KEY_C),
162 KEY(4, 0, KEY_P),
163 KEY(4, 1, KEY_4),
164 KEY(4, 2, KEY_R),
165 KEY(4, 3, KEY_D),
166 KEY(4, 4, KEY_X),
167 KEY(5, 0, KEY_K),
168 KEY(5, 1, KEY_3),
169 KEY(5, 2, KEY_E),
170 KEY(5, 3, KEY_S),
171 KEY(5, 4, KEY_Z),
172 KEY(6, 0, KEY_L),
173 KEY(6, 1, KEY_2),
174 KEY(6, 2, KEY_W),
175 KEY(6, 3, KEY_A),
176 KEY(6, 4, KEY_DOT),
177 KEY(7, 0, KEY_ENTER),
178 KEY(7, 1, KEY_1),
179 KEY(7, 2, KEY_Q),
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,
191 .rows = 8,
192 .cols = 6,
193 .rep = 1,
196 static struct omap_dss_device pandora_lcd_device = {
197 .name = "lcd",
198 .driver_name = "tpo_td043mtea1_panel",
199 .type = OMAP_DISPLAY_TYPE_DPI,
200 .phy.dpi.data_lines = 24,
201 .reset_gpio = 157,
204 static struct omap_dss_device pandora_tv_device = {
205 .name = "tv",
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[] = {
212 &pandora_lcd_device,
213 &pandora_tv_device,
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 = {
223 .name = "omapdss",
224 .id = -1,
225 .dev = {
226 .platform_data = &pandora_dss_data,
230 static struct omap2_hsmmc_info omap3pandora_mmc[] = {
232 .mmc = 1,
233 .wires = 4,
234 .gpio_cd = -EINVAL,
235 .gpio_wp = 126,
236 .ext_clock = 0,
239 .mmc = 2,
240 .wires = 4,
241 .gpio_cd = -EINVAL,
242 .gpio_wp = 127,
243 .ext_clock = 1,
244 .transceiver = true,
247 .mmc = 3,
248 .wires = 4,
249 .gpio_cd = -EINVAL,
250 .gpio_wp = -EINVAL,
252 {} /* Terminator */
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);
263 return 0;
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 = {
305 .constraints = {
306 .min_uV = 1850000,
307 .max_uV = 3150000,
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 = {
320 .constraints = {
321 .min_uV = 1850000,
322 .max_uV = 3150000,
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 = {
335 .constraints = {
336 .min_uV = 1800000,
337 .max_uV = 1800000,
338 .apply_uV = true,
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 = {
350 .constraints = {
351 .min_uV = 1800000,
352 .max_uV = 1800000,
353 .apply_uV = true,
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,
363 /* VAUX1 for LCD */
364 static struct regulator_init_data pandora_vaux1 = {
365 .constraints = {
366 .min_uV = 3000000,
367 .max_uV = 3000000,
368 .apply_uV = true,
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 = {
380 .constraints = {
381 .min_uV = 1800000,
382 .max_uV = 1800000,
383 .apply_uV = true,
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 = {
395 .constraints = {
396 .min_uV = 2800000,
397 .max_uV = 2800000,
398 .apply_uV = true,
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 = {
410 .constraints = {
411 .min_uV = 2800000,
412 .max_uV = 2800000,
413 .apply_uV = true,
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 int __init omap3pandora_i2c_init(void)
464 omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo,
465 ARRAY_SIZE(omap3pandora_i2c_boardinfo));
466 /* i2c2 pins are not connected */
467 omap_register_i2c_bus(3, 100, NULL, 0);
468 return 0;
471 static void __init omap3pandora_ads7846_init(void)
473 int gpio = OMAP3_PANDORA_TS_GPIO;
474 int ret;
476 ret = gpio_request(gpio, "ads7846_pen_down");
477 if (ret < 0) {
478 printk(KERN_ERR "Failed to request GPIO %d for "
479 "ads7846 pen down IRQ\n", gpio);
480 return;
483 gpio_direction_input(gpio);
486 static int ads7846_get_pendown_state(void)
488 return !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
491 static struct ads7846_platform_data ads7846_config = {
492 .x_max = 0x0fff,
493 .y_max = 0x0fff,
494 .x_plate_ohms = 180,
495 .pressure_max = 255,
496 .debounce_max = 10,
497 .debounce_tol = 3,
498 .debounce_rep = 1,
499 .get_pendown_state = ads7846_get_pendown_state,
500 .keep_vref_on = 1,
503 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
504 .turbo_mode = 0,
505 .single_channel = 1, /* 0: slave, 1: master */
508 static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
510 .modalias = "ads7846",
511 .bus_num = 1,
512 .chip_select = 0,
513 .max_speed_hz = 1500000,
514 .controller_data = &ads7846_mcspi_config,
515 .irq = OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO),
516 .platform_data = &ads7846_config,
517 }, {
518 .modalias = "tpo_td043mtea1_panel_spi",
519 .bus_num = 1,
520 .chip_select = 1,
521 .max_speed_hz = 375000,
522 .platform_data = &pandora_lcd_device,
526 static void __init omap3pandora_init_irq(void)
528 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
529 mt46h32m32lf6_sdrc_params);
530 omap_init_irq();
531 omap_gpio_init();
534 static struct platform_device *omap3pandora_devices[] __initdata = {
535 &pandora_leds_gpio,
536 &pandora_keys_gpio,
537 &pandora_dss_device,
540 static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
542 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
543 .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
544 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
546 .phy_reset = true,
547 .reset_gpio_port[0] = 16,
548 .reset_gpio_port[1] = -EINVAL,
549 .reset_gpio_port[2] = -EINVAL
552 #ifdef CONFIG_OMAP_MUX
553 static struct omap_board_mux board_mux[] __initdata = {
554 { .reg_offset = OMAP_MUX_TERMINATOR },
556 #else
557 #define board_mux NULL
558 #endif
560 static struct omap_musb_board_data musb_board_data = {
561 .interface_type = MUSB_INTERFACE_ULPI,
562 .mode = MUSB_OTG,
563 .power = 100,
566 static void __init omap3pandora_init(void)
568 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
569 omap3pandora_i2c_init();
570 platform_add_devices(omap3pandora_devices,
571 ARRAY_SIZE(omap3pandora_devices));
572 omap_serial_init();
573 spi_register_board_info(omap3pandora_spi_board_info,
574 ARRAY_SIZE(omap3pandora_spi_board_info));
575 omap3pandora_ads7846_init();
576 usb_ehci_init(&ehci_pdata);
577 pandora_keys_gpio_init();
578 usb_musb_init(&musb_board_data);
580 /* Ensure SDRC pins are mux'd for self-refresh */
581 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
582 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
585 static void __init omap3pandora_map_io(void)
587 omap2_set_globals_343x();
588 omap34xx_map_common_io();
591 MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
592 .phys_io = 0x48000000,
593 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
594 .boot_params = 0x80000100,
595 .map_io = omap3pandora_map_io,
596 .init_irq = omap3pandora_init_irq,
597 .init_machine = omap3pandora_init,
598 .timer = &omap_timer,
599 MACHINE_END