Merge branch 'stable-3.2' into pandora-3.2
[pandora-kernel.git] / arch / arm / mach-omap2 / board-omap3pandora.c
1 /*
2  * board-omap3pandora.c (Pandora Handheld Console)
3  *
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.
7  *
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.
12  *
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
17  *
18  */
19
20 #include <linux/init.h>
21 #include <linux/kernel.h>
22 #include <linux/platform_device.h>
23
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>
40
41 #include <asm/mach-types.h>
42 #include <asm/mach/arch.h>
43 #include <asm/mach/map.h>
44
45 #include <plat/board.h>
46 #include <plat/common.h>
47 #include <mach/hardware.h>
48 #include <plat/mcspi.h>
49 #include <plat/usb.h>
50 #include <video/omapdss.h>
51 #include <plat/nand.h>
52
53 #include "mux.h"
54 #include "sdram-micron-mt46h32m32lf-6.h"
55 #include "sdram-micron-mt29c4g96mazapcjg-5.h"
56 #include "hsmmc.h"
57 #include "common-board-devices.h"
58
59 #define PANDORA_WIFI_IRQ_GPIO           21
60 #define PANDORA_WIFI_NRESET_GPIO        23
61 #define OMAP3_PANDORA_TS_GPIO           94
62 #define PANDORA_EN_USB_5V_GPIO          164
63
64 static struct mtd_partition omap3pandora_nand_partitions[] = {
65         {
66                 .name           = "xloader",
67                 .offset         = 0,
68                 .size           = 4 * NAND_BLOCK_SIZE,
69                 .mask_flags     = MTD_WRITEABLE
70         }, {
71                 .name           = "uboot",
72                 .offset         = MTDPART_OFS_APPEND,
73                 .size           = 15 * NAND_BLOCK_SIZE,
74         }, {
75                 .name           = "uboot-env",
76                 .offset         = MTDPART_OFS_APPEND,
77                 .size           = 1 * NAND_BLOCK_SIZE,
78         }, {
79                 .name           = "boot",
80                 .offset         = MTDPART_OFS_APPEND,
81                 .size           = 80 * NAND_BLOCK_SIZE,
82         }, {
83                 .name           = "rootfs",
84                 .offset         = MTDPART_OFS_APPEND,
85                 .size           = MTDPART_SIZ_FULL,
86         },
87 };
88
89 static struct omap_nand_platform_data pandora_nand_data = {
90         .cs             = 0,
91         .devsize        = NAND_BUSWIDTH_16,
92         .xfer_type      = NAND_OMAP_PREFETCH_DMA,
93         .parts          = omap3pandora_nand_partitions,
94         .nr_parts       = ARRAY_SIZE(omap3pandora_nand_partitions),
95 };
96
97 static struct gpio_led pandora_gpio_leds[] = {
98         {
99                 .name                   = "pandora::sd1",
100                 .default_trigger        = "mmc0",
101                 .gpio                   = 128,
102         }, {
103                 .name                   = "pandora::sd2",
104                 .default_trigger        = "mmc1",
105                 .gpio                   = 129,
106         }, {
107                 .name                   = "pandora::bluetooth",
108                 .gpio                   = 158,
109         }, {
110                 .name                   = "pandora::wifi",
111                 .gpio                   = 159,
112         },
113 };
114
115 static struct gpio_led_platform_data pandora_gpio_led_data = {
116         .leds           = pandora_gpio_leds,
117         .num_leds       = ARRAY_SIZE(pandora_gpio_leds),
118 };
119
120 static struct platform_device pandora_leds_gpio = {
121         .name   = "leds-gpio",
122         .id     = -1,
123         .dev    = {
124                 .platform_data  = &pandora_gpio_led_data,
125         },
126 };
127
128 static struct led_pwm pandora_pwm_leds[] = {
129         {
130                 .name                   = "pandora::keypad_bl",
131                 .pwm_id                 = 0, /* LEDA */
132         }, {
133                 .name                   = "pandora::power",
134                 .default_trigger        = "default-on",
135                 .pwm_id                 = 1, /* LEDB */
136         }, {
137                 .name                   = "pandora::charger",
138                 .default_trigger        = "bq27500-0-charging",
139                 .pwm_id                 = 3, /* PWM1 */
140         }
141 };
142
143 static struct led_pwm_platform_data pandora_pwm_led_data = {
144         .leds           = pandora_pwm_leds,
145         .num_leds       = ARRAY_SIZE(pandora_pwm_leds),
146 };
147
148 static struct platform_device pandora_leds_pwm = {
149         .name   = "leds-twl4030-pwm",
150         .id     = -1,
151         .dev    = {
152                 .platform_data  = &pandora_pwm_led_data,
153         },
154 };
155
156 static struct platform_device pandora_bl = {
157         .name   = "pandora-backlight",
158         .id     = -1,
159 };
160
161 #define GPIO_BUTTON(gpio_num, ev_type, ev_code, act_low, descr) \
162 {                                                               \
163         .gpio           = gpio_num,                             \
164         .type           = ev_type,                              \
165         .code           = ev_code,                              \
166         .active_low     = act_low,                              \
167         .debounce_interval = 4,                                 \
168         .desc           = "btn " descr,                         \
169 }
170
171 #define GPIO_BUTTON_LOW(gpio_num, event_code, description)      \
172         GPIO_BUTTON(gpio_num, EV_KEY, event_code, 1, description)
173
174 static struct gpio_keys_button pandora_gpio_keys[] = {
175         GPIO_BUTTON_LOW(110,    KEY_UP,         "up"),
176         GPIO_BUTTON_LOW(103,    KEY_DOWN,       "down"),
177         GPIO_BUTTON_LOW(96,     KEY_LEFT,       "left"),
178         GPIO_BUTTON_LOW(98,     KEY_RIGHT,      "right"),
179         GPIO_BUTTON_LOW(109,    KEY_PAGEUP,     "game 1"),
180         GPIO_BUTTON_LOW(111,    KEY_END,        "game 2"),
181         GPIO_BUTTON_LOW(106,    KEY_PAGEDOWN,   "game 3"),
182         GPIO_BUTTON_LOW(101,    KEY_HOME,       "game 4"),
183         GPIO_BUTTON_LOW(102,    KEY_RIGHTSHIFT, "l"),
184         GPIO_BUTTON_LOW(97,     KEY_KPPLUS,     "l2"),
185         GPIO_BUTTON_LOW(105,    KEY_RIGHTCTRL,  "r"),
186         GPIO_BUTTON_LOW(107,    KEY_KPMINUS,    "r2"),
187         GPIO_BUTTON_LOW(104,    KEY_LEFTCTRL,   "ctrl"),
188         GPIO_BUTTON_LOW(99,     KEY_MENU,       "menu"),
189         GPIO_BUTTON_LOW(176,    KEY_COFFEE,     "hold"),
190         GPIO_BUTTON(100, EV_KEY, KEY_LEFTALT, 0, "alt"),
191         GPIO_BUTTON(108, EV_SW, SW_LID, 1, "lid"),
192 };
193
194 static struct gpio_keys_platform_data pandora_gpio_key_info = {
195         .buttons        = pandora_gpio_keys,
196         .nbuttons       = ARRAY_SIZE(pandora_gpio_keys),
197 };
198
199 static struct platform_device pandora_keys_gpio = {
200         .name   = "gpio-keys",
201         .id     = -1,
202         .dev    = {
203                 .platform_data  = &pandora_gpio_key_info,
204         },
205 };
206
207 /* HACK: this requires patched twl4030_keypad driver */
208 #define FNKEY(row, col, code) KEY((row + 8), col, code)
209
210 static const uint32_t board_keymap[] = {
211         /* row, col, code */
212         KEY(0, 0, KEY_9),
213         KEY(0, 1, KEY_8),
214         KEY(0, 2, KEY_I),
215         KEY(0, 3, KEY_J),
216         KEY(0, 4, KEY_N),
217         KEY(0, 5, KEY_M),
218         KEY(1, 0, KEY_0),
219         KEY(1, 1, KEY_7),
220         KEY(1, 2, KEY_U),
221         KEY(1, 3, KEY_H),
222         KEY(1, 4, KEY_B),
223         KEY(1, 5, KEY_SPACE),
224         KEY(2, 0, KEY_BACKSPACE),
225         KEY(2, 1, KEY_6),
226         KEY(2, 2, KEY_Y),
227         KEY(2, 3, KEY_G),
228         KEY(2, 4, KEY_V),
229         KEY(2, 5, KEY_FN),
230         KEY(3, 0, KEY_O),
231         KEY(3, 1, KEY_5),
232         KEY(3, 2, KEY_T),
233         KEY(3, 3, KEY_F),
234         KEY(3, 4, KEY_C),
235         KEY(4, 0, KEY_P),
236         KEY(4, 1, KEY_4),
237         KEY(4, 2, KEY_R),
238         KEY(4, 3, KEY_D),
239         KEY(4, 4, KEY_X),
240         KEY(5, 0, KEY_K),
241         KEY(5, 1, KEY_3),
242         KEY(5, 2, KEY_E),
243         KEY(5, 3, KEY_S),
244         KEY(5, 4, KEY_Z),
245         KEY(6, 0, KEY_L),
246         KEY(6, 1, KEY_2),
247         KEY(6, 2, KEY_W),
248         KEY(6, 3, KEY_A),
249         KEY(6, 4, KEY_DOT),
250         KEY(7, 0, KEY_ENTER),
251         KEY(7, 1, KEY_1),
252         KEY(7, 2, KEY_Q),
253         KEY(7, 3, KEY_LEFTSHIFT),
254         KEY(7, 4, KEY_COMMA),
255         /* Fn keys */
256         FNKEY(0, 0, KEY_F9),
257         FNKEY(0, 1, KEY_F8),
258         FNKEY(0, 2, KEY_BRIGHTNESSUP),
259         FNKEY(0, 3, KEY_F13),           /* apostrophe, differs from Fn-A? */
260         FNKEY(0, 4, KEY_F22),
261         FNKEY(0, 5, KEY_F23),
262         FNKEY(1, 0, KEY_F10),
263         FNKEY(1, 1, KEY_F7),
264         FNKEY(1, 2, KEY_BRIGHTNESSDOWN),
265         FNKEY(1, 3, KEY_GRAVE),
266         FNKEY(1, 4, KEY_F14),           /* pipe/bar */
267         FNKEY(1, 5, KEY_TAB),
268         FNKEY(2, 0, KEY_INSERT),
269         FNKEY(2, 1, KEY_F6),
270         FNKEY(2, 2, KEY_F15),           /* dash */
271         FNKEY(2, 3, KEY_EQUAL),
272         FNKEY(2, 4, KEY_F16),           /* # (pound/hash) */
273         FNKEY(2, 5, KEY_FN),
274         FNKEY(3, 0, KEY_F11),
275         FNKEY(3, 1, KEY_F5),
276         FNKEY(3, 2, KEY_F17),           /* ! */
277         FNKEY(3, 3, KEY_KPPLUS),
278         FNKEY(3, 4, KEY_BACKSLASH),
279         FNKEY(4, 0, KEY_F12),
280         FNKEY(4, 1, KEY_F4),
281         FNKEY(4, 2, KEY_RIGHTBRACE),
282         FNKEY(4, 3, KEY_KPMINUS),
283         FNKEY(4, 4, KEY_QUESTION),
284         FNKEY(5, 0, KEY_F18),           /* Â£ (pound) */
285         FNKEY(5, 1, KEY_F3),
286         FNKEY(5, 2, KEY_LEFTBRACE),
287         FNKEY(5, 3, KEY_F19),           /* " */
288         FNKEY(5, 4, KEY_SLASH),
289         FNKEY(6, 0, KEY_YEN),
290         FNKEY(6, 1, KEY_F2),
291         FNKEY(6, 2, KEY_F20),           /* @ */
292         FNKEY(6, 3, KEY_APOSTROPHE),
293         FNKEY(6, 4, KEY_F21),           /* : */
294         FNKEY(7, 0, KEY_ENTER),
295         FNKEY(7, 1, KEY_F1),
296         FNKEY(7, 2, KEY_ESC),
297         FNKEY(7, 3, KEY_CAPSLOCK),
298         FNKEY(7, 4, KEY_SEMICOLON),
299 };
300
301 static struct matrix_keymap_data board_map_data = {
302         .keymap                 = board_keymap,
303         .keymap_size            = ARRAY_SIZE(board_keymap),
304 };
305
306 static struct twl4030_keypad_data pandora_kp_data = {
307         .keymap_data    = &board_map_data,
308         .rows           = 8,
309         .cols           = 6,
310         .rep            = 1,
311 };
312
313 static struct omap_dss_device pandora_lcd_device = {
314         .name                   = "lcd",
315         .driver_name            = "tpo_td043mtea1_panel",
316         .type                   = OMAP_DISPLAY_TYPE_DPI,
317         .phy.dpi.data_lines     = 24,
318         .reset_gpio             = 157,
319 };
320
321 static struct omap_dss_device pandora_tv_device = {
322         .name                   = "tv",
323         .driver_name            = "venc",
324         .type                   = OMAP_DISPLAY_TYPE_VENC,
325         .phy.venc.type          = OMAP_DSS_VENC_TYPE_SVIDEO,
326 };
327
328 static struct omap_dss_device *pandora_dss_devices[] = {
329         &pandora_lcd_device,
330         &pandora_tv_device,
331 };
332
333 static struct omap_dss_board_info pandora_dss_data = {
334         .num_devices    = ARRAY_SIZE(pandora_dss_devices),
335         .devices        = pandora_dss_devices,
336         .default_device = &pandora_lcd_device,
337 };
338
339 static void pandora_wl1251_init_card(struct mmc_card *card)
340 {
341         /*
342          * We have TI wl1251 attached to MMC3. Pass this information to
343          * SDIO core because it can't be probed by normal methods.
344          */
345         card->quirks |= MMC_QUIRK_NONSTD_SDIO;
346         card->cccr.wide_bus = 1;
347         card->cis.vendor = 0x104c;
348         card->cis.device = 0x9066;
349         card->cis.blksize = 512;
350         card->cis.max_dtr = 20000000;
351 }
352
353 static struct omap2_hsmmc_info omap3pandora_mmc[] = {
354         {
355                 .mmc            = 1,
356                 .caps           = MMC_CAP_4_BIT_DATA,
357                 .gpio_cd        = -EINVAL,
358                 //.gpio_wp      = 126,
359                 .gpio_wp        = -EINVAL,
360                 .ext_clock      = 0,
361         },
362         {
363                 .mmc            = 2,
364                 .caps           = MMC_CAP_4_BIT_DATA,
365                 .gpio_cd        = -EINVAL,
366                 //.gpio_wp      = 127,
367                 .gpio_wp        = -EINVAL,
368                 .ext_clock      = 1,
369                 .transceiver    = true,
370         },
371         {
372                 .mmc            = 3,
373                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
374                 .gpio_cd        = -EINVAL,
375                 .gpio_wp        = -EINVAL,
376                 .init_card      = pandora_wl1251_init_card,
377         },
378         {}      /* Terminator */
379 };
380
381 static int omap3pandora_twl_gpio_setup(struct device *dev,
382                 unsigned gpio, unsigned ngpio)
383 {
384         int ret, gpio_32khz;
385
386         /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
387         omap3pandora_mmc[0].gpio_cd = gpio + 0;
388         omap3pandora_mmc[1].gpio_cd = gpio + 1;
389         omap2_hsmmc_init(omap3pandora_mmc);
390
391         /* gpio + 13 drives 32kHz buffer for wifi module */
392         gpio_32khz = gpio + 13;
393         ret = gpio_request_one(gpio_32khz, GPIOF_OUT_INIT_HIGH, "wifi 32kHz");
394         if (ret < 0) {
395                 pr_err("Cannot get GPIO line %d, ret=%d\n", gpio_32khz, ret);
396                 return -ENODEV;
397         }
398
399         return 0;
400 }
401
402 static struct twl4030_gpio_platform_data omap3pandora_gpio_data = {
403         .gpio_base      = OMAP_MAX_GPIO_LINES,
404         .irq_base       = TWL4030_GPIO_IRQ_BASE,
405         .irq_end        = TWL4030_GPIO_IRQ_END,
406         .setup          = omap3pandora_twl_gpio_setup,
407 };
408
409 static struct regulator_consumer_supply pandora_vmmc1_supply[] = {
410         REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
411 };
412
413 static struct regulator_consumer_supply pandora_vmmc2_supply[] = {
414         REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1")
415 };
416
417 static struct regulator_consumer_supply pandora_vmmc3_supply[] = {
418         REGULATOR_SUPPLY("vmmc", "omap_hsmmc.2"),
419 };
420
421 static struct regulator_consumer_supply pandora_vdds_supplies[] = {
422         REGULATOR_SUPPLY("vdds_sdi", "omapdss"),
423         REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
424         REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
425 };
426
427 static struct regulator_consumer_supply pandora_vcc_lcd_supply[] = {
428         REGULATOR_SUPPLY("vcc", "display0"),
429 };
430
431 static struct regulator_consumer_supply pandora_usb_phy_supply[] = {
432         REGULATOR_SUPPLY("hsusb1", "ehci-omap.0"),
433 };
434
435 /* ads7846 on SPI and 2 nub controllers on I2C */
436 static struct regulator_consumer_supply pandora_vaux4_supplies[] = {
437         REGULATOR_SUPPLY("vcc", "spi1.0"),
438         REGULATOR_SUPPLY("vcc", "3-0066"),
439         REGULATOR_SUPPLY("vcc", "3-0067"),
440 };
441
442 static struct regulator_consumer_supply pandora_adac_supply[] = {
443         REGULATOR_SUPPLY("vcc", "soc-audio"),
444         REGULATOR_SUPPLY("lidsw", NULL),
445 };
446
447 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
448 static struct regulator_init_data pandora_vmmc1 = {
449         .constraints = {
450                 .min_uV                 = 1850000,
451                 .max_uV                 = 3150000,
452                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
453                                         | REGULATOR_MODE_STANDBY,
454                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
455                                         | REGULATOR_CHANGE_MODE
456                                         | REGULATOR_CHANGE_STATUS,
457         },
458         .num_consumer_supplies  = ARRAY_SIZE(pandora_vmmc1_supply),
459         .consumer_supplies      = pandora_vmmc1_supply,
460 };
461
462 /* VMMC2 for MMC2 pins CMD, CLK, DAT0..DAT3 (max 100 mA) */
463 static struct regulator_init_data pandora_vmmc2 = {
464         .constraints = {
465                 .min_uV                 = 1850000,
466                 .max_uV                 = 3150000,
467                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
468                                         | REGULATOR_MODE_STANDBY,
469                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
470                                         | REGULATOR_CHANGE_MODE
471                                         | REGULATOR_CHANGE_STATUS,
472         },
473         .num_consumer_supplies  = ARRAY_SIZE(pandora_vmmc2_supply),
474         .consumer_supplies      = pandora_vmmc2_supply,
475 };
476
477 /* VAUX1 for LCD */
478 static struct regulator_init_data pandora_vaux1 = {
479         .constraints = {
480                 .min_uV                 = 3000000,
481                 .max_uV                 = 3000000,
482                 .apply_uV               = true,
483                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
484                                         | REGULATOR_MODE_STANDBY,
485                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
486                                         | REGULATOR_CHANGE_STATUS,
487         },
488         .num_consumer_supplies  = ARRAY_SIZE(pandora_vcc_lcd_supply),
489         .consumer_supplies      = pandora_vcc_lcd_supply,
490 };
491
492 /* VAUX2 for USB host PHY */
493 static struct regulator_init_data pandora_vaux2 = {
494         .constraints = {
495                 .min_uV                 = 1800000,
496                 .max_uV                 = 1800000,
497                 .apply_uV               = true,
498                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
499                                         | REGULATOR_MODE_STANDBY,
500                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
501                                         | REGULATOR_CHANGE_STATUS,
502         },
503         .num_consumer_supplies  = ARRAY_SIZE(pandora_usb_phy_supply),
504         .consumer_supplies      = pandora_usb_phy_supply,
505 };
506
507 /* VAUX4 for ads7846 and nubs */
508 static struct regulator_init_data pandora_vaux4 = {
509         .constraints = {
510                 .min_uV                 = 2800000,
511                 .max_uV                 = 2800000,
512                 .apply_uV               = true,
513                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
514                                         | REGULATOR_MODE_STANDBY,
515                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
516                                         | REGULATOR_CHANGE_STATUS,
517         },
518         .num_consumer_supplies  = ARRAY_SIZE(pandora_vaux4_supplies),
519         .consumer_supplies      = pandora_vaux4_supplies,
520 };
521
522 /* VSIM for audio DAC */
523 static struct regulator_init_data pandora_vsim = {
524         .constraints = {
525                 .min_uV                 = 2800000,
526                 .max_uV                 = 2800000,
527                 .apply_uV               = true,
528                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
529                                         | REGULATOR_MODE_STANDBY,
530                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
531                                         | REGULATOR_CHANGE_STATUS,
532         },
533         .num_consumer_supplies  = ARRAY_SIZE(pandora_adac_supply),
534         .consumer_supplies      = pandora_adac_supply,
535 };
536
537 /* Fixed regulator internal to Wifi module */
538 static struct regulator_init_data pandora_vmmc3 = {
539         .constraints = {
540                 .valid_ops_mask         = REGULATOR_CHANGE_STATUS,
541         },
542         .num_consumer_supplies  = ARRAY_SIZE(pandora_vmmc3_supply),
543         .consumer_supplies      = pandora_vmmc3_supply,
544 };
545
546 static struct fixed_voltage_config pandora_vwlan = {
547         .supply_name            = "vwlan",
548         .microvolts             = 1800000, /* 1.8V */
549         .gpio                   = PANDORA_WIFI_NRESET_GPIO,
550         .startup_delay          = 50000, /* 50ms */
551         .enable_high            = 1,
552         .enabled_at_boot        = 0,
553         .init_data              = &pandora_vmmc3,
554 };
555
556 static struct platform_device pandora_vwlan_device = {
557         .name           = "reg-fixed-voltage",
558         .id             = 1,
559         .dev = {
560                 .platform_data = &pandora_vwlan,
561         },
562 };
563
564 static char *pandora_power_supplied_to[] = {
565         "bq27500-0",
566 };
567
568 static struct twl4030_bci_platform_data pandora_bci_data = {
569         .supplied_to            = pandora_power_supplied_to,
570         .num_supplicants        = ARRAY_SIZE(pandora_power_supplied_to),
571 };
572
573 static struct twl4030_power_data pandora_power_data = {
574         .use_poweroff   = 1,
575 };
576
577 static struct twl4030_platform_data omap3pandora_twldata = {
578         .gpio           = &omap3pandora_gpio_data,
579         .vmmc1          = &pandora_vmmc1,
580         .vmmc2          = &pandora_vmmc2,
581         .vaux1          = &pandora_vaux1,
582         .vaux2          = &pandora_vaux2,
583         .vaux4          = &pandora_vaux4,
584         .vsim           = &pandora_vsim,
585         .keypad         = &pandora_kp_data,
586         .bci            = &pandora_bci_data,
587         .power          = &pandora_power_data,
588 };
589
590 static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
591         {
592                 I2C_BOARD_INFO("tps65950", 0x48),
593                 .flags = I2C_CLIENT_WAKE,
594                 .irq = INT_34XX_SYS_NIRQ,
595                 .platform_data = &omap3pandora_twldata,
596         },
597 };
598
599 static struct vsense_platform_data omap3pandora_nub1_data = {
600         .gpio_irq       = 161,
601         .gpio_reset     = 156,
602 };
603
604 static struct vsense_platform_data omap3pandora_nub2_data = {
605         .gpio_irq       = 162,
606         .gpio_reset     = 156,
607 };
608
609 static struct i2c_board_info __initdata omap3pandora_i2c3_boardinfo[] = {
610         {
611                 I2C_BOARD_INFO("vsense", 0x66),
612                 .flags = I2C_CLIENT_WAKE,
613                 .platform_data = &omap3pandora_nub1_data,
614         }, {
615                 I2C_BOARD_INFO("vsense", 0x67),
616                 .flags = I2C_CLIENT_WAKE,
617                 .platform_data = &omap3pandora_nub2_data,
618         }, {
619                 I2C_BOARD_INFO("bq27500", 0x55),
620                 .flags = I2C_CLIENT_WAKE,
621         },
622 };
623
624 static int __init omap3pandora_i2c_init(void)
625 {
626         omap3_pmic_get_config(&omap3pandora_twldata,
627                         TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_AUDIO,
628                         TWL_COMMON_REGULATOR_VDAC | TWL_COMMON_REGULATOR_VPLL2);
629
630         omap3pandora_twldata.vdac->constraints.apply_uV = true;
631
632         omap3pandora_twldata.vpll2->constraints.apply_uV = true;
633         omap3pandora_twldata.vpll2->num_consumer_supplies =
634                                         ARRAY_SIZE(pandora_vdds_supplies);
635         omap3pandora_twldata.vpll2->consumer_supplies = pandora_vdds_supplies;
636
637         omap3_pmic_init("tps65950", &omap3pandora_twldata);
638         /* i2c2 pins are not connected */
639         omap_register_i2c_bus(3, 100, omap3pandora_i2c3_boardinfo,
640                         ARRAY_SIZE(omap3pandora_i2c3_boardinfo));
641         return 0;
642 }
643
644 static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
645         {
646                 .modalias               = "tpo_td043mtea1_panel_spi",
647                 .bus_num                = 1,
648                 .chip_select            = 1,
649                 .max_speed_hz           = 375000,
650                 .platform_data          = &pandora_lcd_device,
651         }
652 };
653
654 static void __init pandora_wl1251_init(void)
655 {
656         struct wl12xx_platform_data pandora_wl1251_pdata;
657         int ret;
658
659         memset(&pandora_wl1251_pdata, 0, sizeof(pandora_wl1251_pdata));
660
661         ret = gpio_request_one(PANDORA_WIFI_IRQ_GPIO, GPIOF_IN, "wl1251 irq");
662         if (ret < 0)
663                 goto fail;
664
665         pandora_wl1251_pdata.irq = gpio_to_irq(PANDORA_WIFI_IRQ_GPIO);
666         if (pandora_wl1251_pdata.irq < 0)
667                 goto fail_irq;
668
669         pandora_wl1251_pdata.use_eeprom = true;
670         ret = wl12xx_set_platform_data(&pandora_wl1251_pdata);
671         if (ret < 0)
672                 goto fail_irq;
673
674         return;
675
676 fail_irq:
677         gpio_free(PANDORA_WIFI_IRQ_GPIO);
678 fail:
679         printk(KERN_ERR "wl1251 board initialisation failed\n");
680 }
681
682 static void __init pandora_usb_host_init(void)
683 {
684         int ret;
685
686         ret = gpio_request_one(PANDORA_EN_USB_5V_GPIO, GPIOF_OUT_INIT_HIGH,
687                 "ehci vbus");
688         if (ret < 0)
689                 pr_err("Cannot set vbus GPIO, ret=%d\n", ret);
690 }
691
692 static struct platform_device *omap3pandora_devices[] __initdata = {
693         &pandora_leds_gpio,
694         &pandora_leds_pwm,
695         &pandora_bl,
696         &pandora_keys_gpio,
697         &pandora_vwlan_device,
698 };
699
700 static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
701
702         .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
703         .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
704         .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
705
706         .phy_reset  = true,
707         .reset_gpio_port[0]  = -EINVAL,
708         .reset_gpio_port[1]  = 16,
709         .reset_gpio_port[2]  = -EINVAL
710 };
711
712 #ifdef CONFIG_OMAP_MUX
713 static struct omap_board_mux board_mux[] __initdata = {
714         /* enable wakeup for pandora button (GPIO99) */
715         OMAP3_MUX(CAM_D0, OMAP_INPUT_EN | OMAP_WAKEUP_EN | OMAP_MUX_MODE4),
716         { .reg_offset = OMAP_MUX_TERMINATOR },
717 };
718 #endif
719
720 static struct regulator *lid_switch_power;
721
722 #ifdef CONFIG_PM_SLEEP
723 static int pandora_pm_suspend(struct device *dev)
724 {
725         if (!IS_ERR_OR_NULL(lid_switch_power))
726                 regulator_disable(lid_switch_power);
727
728         return 0;
729 }
730
731 static int pandora_pm_resume(struct device *dev)
732 {
733         if (!IS_ERR_OR_NULL(lid_switch_power))
734                 regulator_enable(lid_switch_power);
735
736         return 0;
737 }
738 #endif
739
740 static SIMPLE_DEV_PM_OPS(pandora_pm, pandora_pm_suspend, pandora_pm_resume);
741
742 static int __devinit pandora_pm_probe(struct platform_device *pdev)
743 {
744         lid_switch_power = regulator_get(NULL, "lidsw");
745         if (!IS_ERR(lid_switch_power))
746                 regulator_enable(lid_switch_power);
747
748         return 0;
749 }
750
751 static struct platform_driver pandora_pm_driver = {
752         .probe          = pandora_pm_probe,
753         .driver         = {
754                 .name   = "pandora-pm",
755                 .pm     = &pandora_pm,
756         },
757 };
758
759 static struct platform_device pandora_pm_dev = {
760         .name   = "pandora-pm",
761         .id     = -1,
762 };
763
764 static int __init pandora_pm_drv_reg(void)
765 {
766         platform_device_register(&pandora_pm_dev);
767         return platform_driver_register(&pandora_pm_driver);
768 }
769 late_initcall(pandora_pm_drv_reg);
770
771 static void __init omap3pandora_init(void)
772 {
773         struct omap_sdrc_params *sdrc_params;
774
775         omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
776         pandora_usb_host_init();
777         omap3pandora_i2c_init();
778         pandora_wl1251_init();
779         platform_add_devices(omap3pandora_devices,
780                         ARRAY_SIZE(omap3pandora_devices));
781         omap_display_init(&pandora_dss_data);
782         omap_serial_init();
783
784         sdrc_params = mt46h32m32lf6_sdrc_params;
785         if (cpu_is_omap3630() || omap_rev() >= OMAP3430_REV_ES3_0)
786                 sdrc_params = mt29c4g96mazapcjg5_sdrc_params;
787         omap_sdrc_init(sdrc_params, sdrc_params);
788
789         spi_register_board_info(omap3pandora_spi_board_info,
790                         ARRAY_SIZE(omap3pandora_spi_board_info));
791         omap_ads7846_init(1, OMAP3_PANDORA_TS_GPIO, 0, NULL);
792         usbhs_init(&usbhs_bdata);
793         usb_musb_init(NULL);
794         gpmc_nand_init(&pandora_nand_data);
795
796         /* Ensure SDRC pins are mux'd for self-refresh */
797         omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
798         omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
799 }
800
801 /* HACK: create it here, so that others don't need to bother */
802 #ifdef CONFIG_PROC_FS
803 #include <linux/proc_fs.h>
804
805 static int __init proc_pandora_init(void)
806 {
807         struct proc_dir_entry *ret;
808
809         ret = proc_mkdir("pandora", NULL);
810         if (!ret)
811                 return -ENOMEM;
812         return 0;
813 }
814 fs_initcall(proc_pandora_init);
815 #endif
816
817 MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
818         .atag_offset    = 0x100,
819         .reserve        = omap_reserve,
820         .map_io         = omap3_map_io,
821         .init_early     = omap35xx_init_early,
822         .init_irq       = omap3_init_irq,
823         .init_machine   = omap3pandora_init,
824         .timer          = &omap3_timer,
825 MACHINE_END