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