pandora: add backlight platform data
[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/spi/ads7846.h>
26 #include <linux/regulator/machine.h>
27 #include <linux/i2c/twl.h>
28 #include <linux/wl12xx.h>
29 #include <linux/mtd/partitions.h>
30 #include <linux/mtd/nand.h>
31 #include <linux/leds.h>
32 #include <linux/input.h>
33 #include <linux/input/matrix_keypad.h>
34 #include <linux/gpio_keys.h>
35 #include <linux/mmc/host.h>
36 #include <linux/mmc/card.h>
37 #include <linux/regulator/fixed.h>
38 #include <linux/i2c/vsense.h>
39
40 #include <asm/mach-types.h>
41 #include <asm/mach/arch.h>
42 #include <asm/mach/map.h>
43
44 #include <plat/board.h>
45 #include <plat/common.h>
46 #include <mach/gpio.h>
47 #include <mach/hardware.h>
48 #include <plat/mcspi.h>
49 #include <plat/usb.h>
50 #include <plat/display.h>
51 #include <plat/nand.h>
52
53 #include "mux.h"
54 #include "sdram-micron-mt46h32m32lf-6.h"
55 #include "hsmmc.h"
56
57 #define PANDORA_WIFI_IRQ_GPIO           21
58 #define PANDORA_WIFI_NRESET_GPIO        23
59 #define OMAP3_PANDORA_TS_GPIO           94
60
61 #define NAND_BLOCK_SIZE                 SZ_128K
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        = 1,    /* '0' for 8-bit, '1' for 16-bit device */
91         .parts          = omap3pandora_nand_partitions,
92         .nr_parts       = ARRAY_SIZE(omap3pandora_nand_partitions),
93 };
94
95 static struct gpio_led pandora_gpio_leds[] = {
96         {
97                 .name                   = "pandora::sd1",
98                 .default_trigger        = "mmc0",
99                 .gpio                   = 128,
100         }, {
101                 .name                   = "pandora::sd2",
102                 .default_trigger        = "mmc1",
103                 .gpio                   = 129,
104         }, {
105                 .name                   = "pandora::bluetooth",
106                 .gpio                   = 158,
107         }, {
108                 .name                   = "pandora::wifi",
109                 .gpio                   = 159,
110         },
111 };
112
113 static struct gpio_led_platform_data pandora_gpio_led_data = {
114         .leds           = pandora_gpio_leds,
115         .num_leds       = ARRAY_SIZE(pandora_gpio_leds),
116 };
117
118 static struct platform_device pandora_leds_gpio = {
119         .name   = "leds-gpio",
120         .id     = -1,
121         .dev    = {
122                 .platform_data  = &pandora_gpio_led_data,
123         },
124 };
125
126 static struct platform_device pandora_bl = {
127         .name   = "twl4030-pwm0-bl",
128         .id     = -1,
129 };
130
131 #define GPIO_BUTTON(gpio_num, ev_type, ev_code, act_low, descr) \
132 {                                                               \
133         .gpio           = gpio_num,                             \
134         .type           = ev_type,                              \
135         .code           = ev_code,                              \
136         .active_low     = act_low,                              \
137         .debounce_interval = 4,                                 \
138         .desc           = "btn " descr,                         \
139 }
140
141 #define GPIO_BUTTON_LOW(gpio_num, event_code, description)      \
142         GPIO_BUTTON(gpio_num, EV_KEY, event_code, 1, description)
143
144 static struct gpio_keys_button pandora_gpio_keys[] = {
145         GPIO_BUTTON_LOW(110,    KEY_UP,         "up"),
146         GPIO_BUTTON_LOW(103,    KEY_DOWN,       "down"),
147         GPIO_BUTTON_LOW(96,     KEY_LEFT,       "left"),
148         GPIO_BUTTON_LOW(98,     KEY_RIGHT,      "right"),
149         GPIO_BUTTON_LOW(109,    KEY_PAGEUP,     "game 1"),
150         GPIO_BUTTON_LOW(111,    KEY_END,        "game 2"),
151         GPIO_BUTTON_LOW(106,    KEY_PAGEDOWN,   "game 3"),
152         GPIO_BUTTON_LOW(101,    KEY_HOME,       "game 4"),
153         GPIO_BUTTON_LOW(102,    KEY_RIGHTSHIFT, "l"),
154         GPIO_BUTTON_LOW(97,     KEY_KPPLUS,     "l2"),
155         GPIO_BUTTON_LOW(105,    KEY_RIGHTCTRL,  "r"),
156         GPIO_BUTTON_LOW(107,    KEY_KPMINUS,    "r2"),
157         GPIO_BUTTON_LOW(104,    KEY_LEFTCTRL,   "ctrl"),
158         GPIO_BUTTON_LOW(99,     KEY_MENU,       "menu"),
159         GPIO_BUTTON_LOW(176,    KEY_COFFEE,     "hold"),
160         GPIO_BUTTON(100, EV_KEY, KEY_LEFTALT, 0, "alt"),
161         GPIO_BUTTON(108, EV_SW, SW_LID, 1, "lid"),
162 };
163
164 static struct gpio_keys_platform_data pandora_gpio_key_info = {
165         .buttons        = pandora_gpio_keys,
166         .nbuttons       = ARRAY_SIZE(pandora_gpio_keys),
167 };
168
169 static struct platform_device pandora_keys_gpio = {
170         .name   = "gpio-keys",
171         .id     = -1,
172         .dev    = {
173                 .platform_data  = &pandora_gpio_key_info,
174         },
175 };
176
177 static const uint32_t board_keymap[] = {
178         /* row, col, code */
179         KEY(0, 0, KEY_9),
180         KEY(0, 1, KEY_8),
181         KEY(0, 2, KEY_I),
182         KEY(0, 3, KEY_J),
183         KEY(0, 4, KEY_N),
184         KEY(0, 5, KEY_M),
185         KEY(1, 0, KEY_0),
186         KEY(1, 1, KEY_7),
187         KEY(1, 2, KEY_U),
188         KEY(1, 3, KEY_H),
189         KEY(1, 4, KEY_B),
190         KEY(1, 5, KEY_SPACE),
191         KEY(2, 0, KEY_BACKSPACE),
192         KEY(2, 1, KEY_6),
193         KEY(2, 2, KEY_Y),
194         KEY(2, 3, KEY_G),
195         KEY(2, 4, KEY_V),
196         KEY(2, 5, KEY_FN),
197         KEY(3, 0, KEY_O),
198         KEY(3, 1, KEY_5),
199         KEY(3, 2, KEY_T),
200         KEY(3, 3, KEY_F),
201         KEY(3, 4, KEY_C),
202         KEY(4, 0, KEY_P),
203         KEY(4, 1, KEY_4),
204         KEY(4, 2, KEY_R),
205         KEY(4, 3, KEY_D),
206         KEY(4, 4, KEY_X),
207         KEY(5, 0, KEY_K),
208         KEY(5, 1, KEY_3),
209         KEY(5, 2, KEY_E),
210         KEY(5, 3, KEY_S),
211         KEY(5, 4, KEY_Z),
212         KEY(6, 0, KEY_L),
213         KEY(6, 1, KEY_2),
214         KEY(6, 2, KEY_W),
215         KEY(6, 3, KEY_A),
216         KEY(6, 4, KEY_DOT),
217         KEY(7, 0, KEY_ENTER),
218         KEY(7, 1, KEY_1),
219         KEY(7, 2, KEY_Q),
220         KEY(7, 3, KEY_LEFTSHIFT),
221         KEY(7, 4, KEY_COMMA),
222 };
223
224 static struct matrix_keymap_data board_map_data = {
225         .keymap                 = board_keymap,
226         .keymap_size            = ARRAY_SIZE(board_keymap),
227 };
228
229 static struct twl4030_keypad_data pandora_kp_data = {
230         .keymap_data    = &board_map_data,
231         .rows           = 8,
232         .cols           = 6,
233         .rep            = 1,
234 };
235
236 static struct omap_dss_device pandora_lcd_device = {
237         .name                   = "lcd",
238         .driver_name            = "tpo_td043mtea1_panel",
239         .type                   = OMAP_DISPLAY_TYPE_DPI,
240         .phy.dpi.data_lines     = 24,
241         .reset_gpio             = 157,
242 };
243
244 static struct omap_dss_device pandora_tv_device = {
245         .name                   = "tv",
246         .driver_name            = "venc",
247         .type                   = OMAP_DISPLAY_TYPE_VENC,
248         .phy.venc.type          = OMAP_DSS_VENC_TYPE_SVIDEO,
249 };
250
251 static struct omap_dss_device *pandora_dss_devices[] = {
252         &pandora_lcd_device,
253         &pandora_tv_device,
254 };
255
256 static struct omap_dss_board_info pandora_dss_data = {
257         .num_devices    = ARRAY_SIZE(pandora_dss_devices),
258         .devices        = pandora_dss_devices,
259         .default_device = &pandora_lcd_device,
260 };
261
262 static struct platform_device pandora_dss_device = {
263         .name           = "omapdss",
264         .id             = -1,
265         .dev            = {
266                 .platform_data = &pandora_dss_data,
267         },
268 };
269
270 static void pandora_wl1251_init_card(struct mmc_card *card)
271 {
272         /*
273          * We have TI wl1251 attached to MMC3. Pass this information to
274          * SDIO core because it can't be probed by normal methods.
275          */
276         card->quirks |= MMC_QUIRK_NONSTD_SDIO;
277         card->cccr.wide_bus = 1;
278         card->cis.vendor = 0x104c;
279         card->cis.device = 0x9066;
280         card->cis.blksize = 512;
281         card->cis.max_dtr = 20000000;
282 }
283
284 static struct omap2_hsmmc_info omap3pandora_mmc[] = {
285         {
286                 .mmc            = 1,
287                 .caps           = MMC_CAP_4_BIT_DATA,
288                 .gpio_cd        = -EINVAL,
289                 .gpio_wp        = 126,
290                 .ext_clock      = 0,
291         },
292         {
293                 .mmc            = 2,
294                 .caps           = MMC_CAP_4_BIT_DATA,
295                 .gpio_cd        = -EINVAL,
296                 .gpio_wp        = 127,
297                 .ext_clock      = 1,
298                 .transceiver    = true,
299         },
300         {
301                 .mmc            = 3,
302                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
303                 .gpio_cd        = -EINVAL,
304                 .gpio_wp        = -EINVAL,
305                 .init_card      = pandora_wl1251_init_card,
306         },
307         {}      /* Terminator */
308 };
309
310 static int omap3pandora_twl_gpio_setup(struct device *dev,
311                 unsigned gpio, unsigned ngpio)
312 {
313         int ret, gpio_32khz;
314
315         /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
316         omap3pandora_mmc[0].gpio_cd = gpio + 0;
317         omap3pandora_mmc[1].gpio_cd = gpio + 1;
318         omap2_hsmmc_init(omap3pandora_mmc);
319
320         /* gpio + 13 drives 32kHz buffer for wifi module */
321         gpio_32khz = gpio + 13;
322         ret = gpio_request(gpio_32khz, "wifi 32kHz");
323         if (ret < 0) {
324                 pr_err("Cannot get GPIO line %d, ret=%d\n", gpio_32khz, ret);
325                 goto fail;
326         }
327
328         ret = gpio_direction_output(gpio_32khz, 1);
329         if (ret < 0) {
330                 pr_err("Cannot set GPIO line %d, ret=%d\n", gpio_32khz, ret);
331                 goto fail_direction;
332         }
333
334         return 0;
335
336 fail_direction:
337         gpio_free(gpio_32khz);
338 fail:
339         return -ENODEV;
340 }
341
342 static struct twl4030_gpio_platform_data omap3pandora_gpio_data = {
343         .gpio_base      = OMAP_MAX_GPIO_LINES,
344         .irq_base       = TWL4030_GPIO_IRQ_BASE,
345         .irq_end        = TWL4030_GPIO_IRQ_END,
346         .setup          = omap3pandora_twl_gpio_setup,
347 };
348
349 static struct regulator_consumer_supply pandora_vmmc1_supply =
350         REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.0");
351
352 static struct regulator_consumer_supply pandora_vmmc2_supply =
353         REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.1");
354
355 static struct regulator_consumer_supply pandora_vmmc3_supply =
356         REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.2");
357
358 static struct regulator_consumer_supply pandora_vdda_dac_supply =
359         REGULATOR_SUPPLY("vdda_dac", "omapdss");
360
361 static struct regulator_consumer_supply pandora_vdds_supplies[] = {
362         REGULATOR_SUPPLY("vdds_sdi", "omapdss"),
363         REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
364 };
365
366 static struct regulator_consumer_supply pandora_vcc_lcd_supply =
367         REGULATOR_SUPPLY("vcc", "display0");
368
369 static struct regulator_consumer_supply pandora_usb_phy_supply =
370         REGULATOR_SUPPLY("hsusb0", "ehci-omap.0");
371
372 /* ads7846 on SPI and 2 nub controllers on I2C */
373 static struct regulator_consumer_supply pandora_vaux4_supplies[] = {
374         REGULATOR_SUPPLY("vcc", "spi1.0"),
375         REGULATOR_SUPPLY("vcc", "3-0066"),
376         REGULATOR_SUPPLY("vcc", "3-0067"),
377 };
378
379 static struct regulator_consumer_supply pandora_adac_supply =
380         REGULATOR_SUPPLY("vcc", "soc-audio");
381
382 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
383 static struct regulator_init_data pandora_vmmc1 = {
384         .constraints = {
385                 .min_uV                 = 1850000,
386                 .max_uV                 = 3150000,
387                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
388                                         | REGULATOR_MODE_STANDBY,
389                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
390                                         | REGULATOR_CHANGE_MODE
391                                         | REGULATOR_CHANGE_STATUS,
392         },
393         .num_consumer_supplies  = 1,
394         .consumer_supplies      = &pandora_vmmc1_supply,
395 };
396
397 /* VMMC2 for MMC2 pins CMD, CLK, DAT0..DAT3 (max 100 mA) */
398 static struct regulator_init_data pandora_vmmc2 = {
399         .constraints = {
400                 .min_uV                 = 1850000,
401                 .max_uV                 = 3150000,
402                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
403                                         | REGULATOR_MODE_STANDBY,
404                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
405                                         | REGULATOR_CHANGE_MODE
406                                         | REGULATOR_CHANGE_STATUS,
407         },
408         .num_consumer_supplies  = 1,
409         .consumer_supplies      = &pandora_vmmc2_supply,
410 };
411
412 /* VDAC for DSS driving S-Video */
413 static struct regulator_init_data pandora_vdac = {
414         .constraints = {
415                 .min_uV                 = 1800000,
416                 .max_uV                 = 1800000,
417                 .apply_uV               = true,
418                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
419                                         | REGULATOR_MODE_STANDBY,
420                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
421                                         | REGULATOR_CHANGE_STATUS,
422         },
423         .num_consumer_supplies  = 1,
424         .consumer_supplies      = &pandora_vdda_dac_supply,
425 };
426
427 /* VPLL2 for digital video outputs */
428 static struct regulator_init_data pandora_vpll2 = {
429         .constraints = {
430                 .min_uV                 = 1800000,
431                 .max_uV                 = 1800000,
432                 .apply_uV               = true,
433                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
434                                         | REGULATOR_MODE_STANDBY,
435                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
436                                         | REGULATOR_CHANGE_STATUS,
437         },
438         .num_consumer_supplies  = ARRAY_SIZE(pandora_vdds_supplies),
439         .consumer_supplies      = pandora_vdds_supplies,
440 };
441
442 /* VAUX1 for LCD */
443 static struct regulator_init_data pandora_vaux1 = {
444         .constraints = {
445                 .min_uV                 = 3000000,
446                 .max_uV                 = 3000000,
447                 .apply_uV               = true,
448                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
449                                         | REGULATOR_MODE_STANDBY,
450                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
451                                         | REGULATOR_CHANGE_STATUS,
452         },
453         .num_consumer_supplies  = 1,
454         .consumer_supplies      = &pandora_vcc_lcd_supply,
455 };
456
457 /* VAUX2 for USB host PHY */
458 static struct regulator_init_data pandora_vaux2 = {
459         .constraints = {
460                 .min_uV                 = 1800000,
461                 .max_uV                 = 1800000,
462                 .apply_uV               = true,
463                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
464                                         | REGULATOR_MODE_STANDBY,
465                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
466                                         | REGULATOR_CHANGE_STATUS,
467         },
468         .num_consumer_supplies  = 1,
469         .consumer_supplies      = &pandora_usb_phy_supply,
470 };
471
472 /* VAUX4 for ads7846 and nubs */
473 static struct regulator_init_data pandora_vaux4 = {
474         .constraints = {
475                 .min_uV                 = 2800000,
476                 .max_uV                 = 2800000,
477                 .apply_uV               = true,
478                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
479                                         | REGULATOR_MODE_STANDBY,
480                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
481                                         | REGULATOR_CHANGE_STATUS,
482         },
483         .num_consumer_supplies  = ARRAY_SIZE(pandora_vaux4_supplies),
484         .consumer_supplies      = pandora_vaux4_supplies,
485 };
486
487 /* VSIM for audio DAC */
488 static struct regulator_init_data pandora_vsim = {
489         .constraints = {
490                 .min_uV                 = 2800000,
491                 .max_uV                 = 2800000,
492                 .apply_uV               = true,
493                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
494                                         | REGULATOR_MODE_STANDBY,
495                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
496                                         | REGULATOR_CHANGE_STATUS,
497         },
498         .num_consumer_supplies  = 1,
499         .consumer_supplies      = &pandora_adac_supply,
500 };
501
502 /* Fixed regulator internal to Wifi module */
503 static struct regulator_init_data pandora_vmmc3 = {
504         .constraints = {
505                 .valid_ops_mask         = REGULATOR_CHANGE_STATUS,
506         },
507         .num_consumer_supplies  = 1,
508         .consumer_supplies      = &pandora_vmmc3_supply,
509 };
510
511 static struct fixed_voltage_config pandora_vwlan = {
512         .supply_name            = "vwlan",
513         .microvolts             = 1800000, /* 1.8V */
514         .gpio                   = PANDORA_WIFI_NRESET_GPIO,
515         .startup_delay          = 50000, /* 50ms */
516         .enable_high            = 1,
517         .enabled_at_boot        = 0,
518         .init_data              = &pandora_vmmc3,
519 };
520
521 static struct platform_device pandora_vwlan_device = {
522         .name           = "reg-fixed-voltage",
523         .id             = 1,
524         .dev = {
525                 .platform_data = &pandora_vwlan,
526         },
527 };
528
529 static struct twl4030_usb_data omap3pandora_usb_data = {
530         .usb_mode       = T2_USB_MODE_ULPI,
531 };
532
533 static struct twl4030_codec_audio_data omap3pandora_audio_data = {
534         .audio_mclk = 26000000,
535 };
536
537 static struct twl4030_codec_data omap3pandora_codec_data = {
538         .audio_mclk = 26000000,
539         .audio = &omap3pandora_audio_data,
540 };
541
542 static struct twl4030_bci_platform_data pandora_bci_data;
543
544 static struct twl4030_platform_data omap3pandora_twldata = {
545         .irq_base       = TWL4030_IRQ_BASE,
546         .irq_end        = TWL4030_IRQ_END,
547         .gpio           = &omap3pandora_gpio_data,
548         .usb            = &omap3pandora_usb_data,
549         .codec          = &omap3pandora_codec_data,
550         .vmmc1          = &pandora_vmmc1,
551         .vmmc2          = &pandora_vmmc2,
552         .vdac           = &pandora_vdac,
553         .vpll2          = &pandora_vpll2,
554         .vaux1          = &pandora_vaux1,
555         .vaux2          = &pandora_vaux2,
556         .vaux4          = &pandora_vaux4,
557         .vsim           = &pandora_vsim,
558         .keypad         = &pandora_kp_data,
559         .bci            = &pandora_bci_data,
560 };
561
562 static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
563         {
564                 I2C_BOARD_INFO("tps65950", 0x48),
565                 .flags = I2C_CLIENT_WAKE,
566                 .irq = INT_34XX_SYS_NIRQ,
567                 .platform_data = &omap3pandora_twldata,
568         },
569 };
570
571 static struct vsense_platform_data omap3pandora_nub1_data = {
572         .gpio_irq       = 161,
573         .gpio_reset     = 156,
574 };
575
576 static struct vsense_platform_data omap3pandora_nub2_data = {
577         .gpio_irq       = 162,
578         .gpio_reset     = 156,
579 };
580
581 static struct i2c_board_info __initdata omap3pandora_i2c3_boardinfo[] = {
582         {
583                 I2C_BOARD_INFO("vsense", 0x66),
584                 .flags = I2C_CLIENT_WAKE,
585                 .platform_data = &omap3pandora_nub1_data,
586         }, {
587                 I2C_BOARD_INFO("vsense", 0x67),
588                 .flags = I2C_CLIENT_WAKE,
589                 .platform_data = &omap3pandora_nub2_data,
590         }, {
591                 I2C_BOARD_INFO("bq27500", 0x55),
592                 .flags = I2C_CLIENT_WAKE,
593         },
594 };
595
596 static int __init omap3pandora_i2c_init(void)
597 {
598         omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo,
599                         ARRAY_SIZE(omap3pandora_i2c_boardinfo));
600         /* i2c2 pins are not connected */
601         omap_register_i2c_bus(3, 100, omap3pandora_i2c3_boardinfo,
602                         ARRAY_SIZE(omap3pandora_i2c3_boardinfo));
603         return 0;
604 }
605
606 static void __init omap3pandora_ads7846_init(void)
607 {
608         int gpio = OMAP3_PANDORA_TS_GPIO;
609         int ret;
610
611         ret = gpio_request(gpio, "ads7846_pen_down");
612         if (ret < 0) {
613                 printk(KERN_ERR "Failed to request GPIO %d for "
614                                 "ads7846 pen down IRQ\n", gpio);
615                 return;
616         }
617
618         gpio_direction_input(gpio);
619 }
620
621 static int ads7846_get_pendown_state(void)
622 {
623         return !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
624 }
625
626 static struct ads7846_platform_data ads7846_config = {
627         .x_max                  = 0x0fff,
628         .y_max                  = 0x0fff,
629         .x_plate_ohms           = 180,
630         .pressure_max           = 255,
631         .debounce_max           = 10,
632         .debounce_tol           = 3,
633         .debounce_rep           = 1,
634         .get_pendown_state      = ads7846_get_pendown_state,
635         .keep_vref_on           = 1,
636 };
637
638 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
639         .turbo_mode     = 0,
640         .single_channel = 1,    /* 0: slave, 1: master */
641 };
642
643 static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
644         {
645                 .modalias               = "ads7846",
646                 .bus_num                = 1,
647                 .chip_select            = 0,
648                 .max_speed_hz           = 1500000,
649                 .controller_data        = &ads7846_mcspi_config,
650                 .irq                    = OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO),
651                 .platform_data          = &ads7846_config,
652         }, {
653                 .modalias               = "tpo_td043mtea1_panel_spi",
654                 .bus_num                = 1,
655                 .chip_select            = 1,
656                 .max_speed_hz           = 375000,
657                 .platform_data          = &pandora_lcd_device,
658         }
659 };
660
661 static void __init omap3pandora_init_irq(void)
662 {
663         omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
664                              mt46h32m32lf6_sdrc_params);
665         omap_init_irq();
666         omap_gpio_init();
667 }
668
669 static void __init pandora_wl1251_init(void)
670 {
671         struct wl12xx_platform_data pandora_wl1251_pdata;
672         int ret;
673
674         memset(&pandora_wl1251_pdata, 0, sizeof(pandora_wl1251_pdata));
675
676         ret = gpio_request(PANDORA_WIFI_IRQ_GPIO, "wl1251 irq");
677         if (ret < 0)
678                 goto fail;
679
680         ret = gpio_direction_input(PANDORA_WIFI_IRQ_GPIO);
681         if (ret < 0)
682                 goto fail_irq;
683
684         pandora_wl1251_pdata.irq = gpio_to_irq(PANDORA_WIFI_IRQ_GPIO);
685         if (pandora_wl1251_pdata.irq < 0)
686                 goto fail_irq;
687
688         pandora_wl1251_pdata.use_eeprom = true;
689         ret = wl12xx_set_platform_data(&pandora_wl1251_pdata);
690         if (ret < 0)
691                 goto fail_irq;
692
693         return;
694
695 fail_irq:
696         gpio_free(PANDORA_WIFI_IRQ_GPIO);
697 fail:
698         printk(KERN_ERR "wl1251 board initialisation failed\n");
699 }
700
701 static struct platform_device *omap3pandora_devices[] __initdata = {
702         &pandora_leds_gpio,
703         &pandora_bl,
704         &pandora_keys_gpio,
705         &pandora_dss_device,
706         &pandora_vwlan_device,
707 };
708
709 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
710
711         .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
712         .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
713         .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
714
715         .phy_reset  = true,
716         .reset_gpio_port[0]  = 16,
717         .reset_gpio_port[1]  = -EINVAL,
718         .reset_gpio_port[2]  = -EINVAL
719 };
720
721 #ifdef CONFIG_OMAP_MUX
722 static struct omap_board_mux board_mux[] __initdata = {
723         { .reg_offset = OMAP_MUX_TERMINATOR },
724 };
725 #else
726 #define board_mux       NULL
727 #endif
728
729 static struct omap_musb_board_data musb_board_data = {
730         .interface_type         = MUSB_INTERFACE_ULPI,
731         .mode                   = MUSB_OTG,
732         .power                  = 100,
733 };
734
735 static void __init omap3pandora_init(void)
736 {
737         omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
738         omap3pandora_i2c_init();
739         pandora_wl1251_init();
740         platform_add_devices(omap3pandora_devices,
741                         ARRAY_SIZE(omap3pandora_devices));
742         omap_serial_init();
743         spi_register_board_info(omap3pandora_spi_board_info,
744                         ARRAY_SIZE(omap3pandora_spi_board_info));
745         omap3pandora_ads7846_init();
746         usb_ehci_init(&ehci_pdata);
747         usb_musb_init(&musb_board_data);
748         gpmc_nand_init(&pandora_nand_data);
749
750         /* Ensure SDRC pins are mux'd for self-refresh */
751         omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
752         omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
753 }
754
755 /* HACK: create it here, so that others don't need to bother */
756 #ifdef CONFIG_PROC_FS
757 #include <linux/proc_fs.h>
758
759 static int __init proc_pandora_init(void)
760 {
761         struct proc_dir_entry *ret;
762
763         ret = proc_mkdir("pandora", NULL);
764         if (!ret)
765                 return -ENOMEM;
766         return 0;
767 }
768 fs_initcall(proc_pandora_init);
769 #endif
770
771 MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
772         .boot_params    = 0x80000100,
773         .map_io         = omap3_map_io,
774         .reserve        = omap_reserve,
775         .init_irq       = omap3pandora_init_irq,
776         .init_machine   = omap3pandora_init,
777         .timer          = &omap_timer,
778 MACHINE_END