Merge branch 'for-paul' of git://gitorious.org/linux-omap-dss2/linux
[linux-3.10.git] / arch / arm / mach-omap2 / board-overo.c
1 /*
2  * board-overo.c (Gumstix Overo)
3  *
4  * Initial code: Steve Sakoman <steve@sakoman.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * version 2 as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18  * 02110-1301 USA
19  *
20  */
21
22 #include <linux/clk.h>
23 #include <linux/delay.h>
24 #include <linux/err.h>
25 #include <linux/init.h>
26 #include <linux/io.h>
27 #include <linux/kernel.h>
28 #include <linux/platform_device.h>
29 #include <linux/i2c/twl.h>
30 #include <linux/regulator/machine.h>
31 #include <linux/regulator/fixed.h>
32 #include <linux/spi/spi.h>
33
34 #include <linux/mtd/mtd.h>
35 #include <linux/mtd/nand.h>
36 #include <linux/mtd/partitions.h>
37 #include <linux/mmc/host.h>
38
39 #include <asm/mach-types.h>
40 #include <asm/mach/arch.h>
41 #include <asm/mach/flash.h>
42 #include <asm/mach/map.h>
43
44 #include <plat/board.h>
45 #include <plat/common.h>
46 #include <plat/display.h>
47 #include <plat/panel-generic-dpi.h>
48 #include <mach/gpio.h>
49 #include <plat/gpmc.h>
50 #include <mach/hardware.h>
51 #include <plat/nand.h>
52 #include <plat/mcspi.h>
53 #include <plat/mux.h>
54 #include <plat/usb.h>
55
56 #include "mux.h"
57 #include "sdram-micron-mt46h32m32lf-6.h"
58 #include "hsmmc.h"
59
60 #define OVERO_GPIO_BT_XGATE     15
61 #define OVERO_GPIO_W2W_NRESET   16
62 #define OVERO_GPIO_PENDOWN      114
63 #define OVERO_GPIO_BT_NRESET    164
64 #define OVERO_GPIO_USBH_CPEN    168
65 #define OVERO_GPIO_USBH_NRESET  183
66
67 #define NAND_BLOCK_SIZE SZ_128K
68
69 #define OVERO_SMSC911X_CS      5
70 #define OVERO_SMSC911X_GPIO    176
71 #define OVERO_SMSC911X2_CS     4
72 #define OVERO_SMSC911X2_GPIO   65
73
74 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
75         defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
76
77 #include <linux/spi/ads7846.h>
78
79 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
80         .turbo_mode     = 0,
81         .single_channel = 1,    /* 0: slave, 1: master */
82 };
83
84 static int ads7846_get_pendown_state(void)
85 {
86         return !gpio_get_value(OVERO_GPIO_PENDOWN);
87 }
88
89 static struct ads7846_platform_data ads7846_config = {
90         .x_max                  = 0x0fff,
91         .y_max                  = 0x0fff,
92         .x_plate_ohms           = 180,
93         .pressure_max           = 255,
94         .debounce_max           = 10,
95         .debounce_tol           = 3,
96         .debounce_rep           = 1,
97         .get_pendown_state      = ads7846_get_pendown_state,
98         .keep_vref_on           = 1,
99 };
100
101 /* fixed regulator for ads7846 */
102 static struct regulator_consumer_supply ads7846_supply =
103         REGULATOR_SUPPLY("vcc", "spi1.0");
104
105 static struct regulator_init_data vads7846_regulator = {
106         .constraints = {
107                 .valid_ops_mask         = REGULATOR_CHANGE_STATUS,
108         },
109         .num_consumer_supplies  = 1,
110         .consumer_supplies      = &ads7846_supply,
111 };
112
113 static struct fixed_voltage_config vads7846 = {
114         .supply_name            = "vads7846",
115         .microvolts             = 3300000, /* 3.3V */
116         .gpio                   = -EINVAL,
117         .startup_delay          = 0,
118         .init_data              = &vads7846_regulator,
119 };
120
121 static struct platform_device vads7846_device = {
122         .name           = "reg-fixed-voltage",
123         .id             = 1,
124         .dev = {
125                 .platform_data = &vads7846,
126         },
127 };
128
129 static void __init overo_ads7846_init(void)
130 {
131         if ((gpio_request(OVERO_GPIO_PENDOWN, "ADS7846_PENDOWN") == 0) &&
132             (gpio_direction_input(OVERO_GPIO_PENDOWN) == 0)) {
133                 gpio_export(OVERO_GPIO_PENDOWN, 0);
134         } else {
135                 printk(KERN_ERR "could not obtain gpio for ADS7846_PENDOWN\n");
136                 return;
137         }
138
139         platform_device_register(&vads7846_device);
140 }
141
142 #else
143 static inline void __init overo_ads7846_init(void) { return; }
144 #endif
145
146 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
147
148 #include <linux/smsc911x.h>
149
150 static struct resource overo_smsc911x_resources[] = {
151         {
152                 .name   = "smsc911x-memory",
153                 .flags  = IORESOURCE_MEM,
154         },
155         {
156                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
157         },
158 };
159
160 static struct resource overo_smsc911x2_resources[] = {
161         {
162                 .name   = "smsc911x2-memory",
163                 .flags  = IORESOURCE_MEM,
164         },
165         {
166                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
167         },
168 };
169
170 static struct smsc911x_platform_config overo_smsc911x_config = {
171         .irq_polarity   = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
172         .irq_type       = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
173         .flags          = SMSC911X_USE_32BIT ,
174         .phy_interface  = PHY_INTERFACE_MODE_MII,
175 };
176
177 static struct platform_device overo_smsc911x_device = {
178         .name           = "smsc911x",
179         .id             = 0,
180         .num_resources  = ARRAY_SIZE(overo_smsc911x_resources),
181         .resource       = overo_smsc911x_resources,
182         .dev            = {
183                 .platform_data = &overo_smsc911x_config,
184         },
185 };
186
187 static struct platform_device overo_smsc911x2_device = {
188         .name           = "smsc911x",
189         .id             = 1,
190         .num_resources  = ARRAY_SIZE(overo_smsc911x2_resources),
191         .resource       = overo_smsc911x2_resources,
192         .dev            = {
193                 .platform_data = &overo_smsc911x_config,
194         },
195 };
196
197 static struct platform_device *smsc911x_devices[] = {
198         &overo_smsc911x_device,
199         &overo_smsc911x2_device,
200 };
201
202 static inline void __init overo_init_smsc911x(void)
203 {
204         unsigned long cs_mem_base, cs_mem_base2;
205
206         /* set up first smsc911x chip */
207
208         if (gpmc_cs_request(OVERO_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) {
209                 printk(KERN_ERR "Failed request for GPMC mem for smsc911x\n");
210                 return;
211         }
212
213         overo_smsc911x_resources[0].start = cs_mem_base + 0x0;
214         overo_smsc911x_resources[0].end   = cs_mem_base + 0xff;
215
216         if ((gpio_request(OVERO_SMSC911X_GPIO, "SMSC911X IRQ") == 0) &&
217             (gpio_direction_input(OVERO_SMSC911X_GPIO) == 0)) {
218                 gpio_export(OVERO_SMSC911X_GPIO, 0);
219         } else {
220                 printk(KERN_ERR "could not obtain gpio for SMSC911X IRQ\n");
221                 return;
222         }
223
224         overo_smsc911x_resources[1].start = OMAP_GPIO_IRQ(OVERO_SMSC911X_GPIO);
225         overo_smsc911x_resources[1].end   = 0;
226
227         /* set up second smsc911x chip */
228
229         if (gpmc_cs_request(OVERO_SMSC911X2_CS, SZ_16M, &cs_mem_base2) < 0) {
230                 printk(KERN_ERR "Failed request for GPMC mem for smsc911x2\n");
231                 return;
232         }
233
234         overo_smsc911x2_resources[0].start = cs_mem_base2 + 0x0;
235         overo_smsc911x2_resources[0].end   = cs_mem_base2 + 0xff;
236
237         if ((gpio_request(OVERO_SMSC911X2_GPIO, "SMSC911X2 IRQ") == 0) &&
238             (gpio_direction_input(OVERO_SMSC911X2_GPIO) == 0)) {
239                 gpio_export(OVERO_SMSC911X2_GPIO, 0);
240         } else {
241                 printk(KERN_ERR "could not obtain gpio for SMSC911X2 IRQ\n");
242                 return;
243         }
244
245         overo_smsc911x2_resources[1].start = OMAP_GPIO_IRQ(OVERO_SMSC911X2_GPIO);
246         overo_smsc911x2_resources[1].end   = 0;
247
248         platform_add_devices(smsc911x_devices, ARRAY_SIZE(smsc911x_devices));
249 }
250
251 #else
252 static inline void __init overo_init_smsc911x(void) { return; }
253 #endif
254
255 /* DSS */
256 static int lcd_enabled;
257 static int dvi_enabled;
258
259 #define OVERO_GPIO_LCD_EN 144
260 #define OVERO_GPIO_LCD_BL 145
261
262 static void __init overo_display_init(void)
263 {
264         if ((gpio_request(OVERO_GPIO_LCD_EN, "OVERO_GPIO_LCD_EN") == 0) &&
265             (gpio_direction_output(OVERO_GPIO_LCD_EN, 1) == 0))
266                 gpio_export(OVERO_GPIO_LCD_EN, 0);
267         else
268                 printk(KERN_ERR "could not obtain gpio for "
269                                         "OVERO_GPIO_LCD_EN\n");
270
271         if ((gpio_request(OVERO_GPIO_LCD_BL, "OVERO_GPIO_LCD_BL") == 0) &&
272             (gpio_direction_output(OVERO_GPIO_LCD_BL, 1) == 0))
273                 gpio_export(OVERO_GPIO_LCD_BL, 0);
274         else
275                 printk(KERN_ERR "could not obtain gpio for "
276                                         "OVERO_GPIO_LCD_BL\n");
277 }
278
279 static int overo_panel_enable_dvi(struct omap_dss_device *dssdev)
280 {
281         if (lcd_enabled) {
282                 printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
283                 return -EINVAL;
284         }
285         dvi_enabled = 1;
286
287         return 0;
288 }
289
290 static void overo_panel_disable_dvi(struct omap_dss_device *dssdev)
291 {
292         dvi_enabled = 0;
293 }
294
295 static struct panel_generic_dpi_data dvi_panel = {
296         .name                   = "generic",
297         .platform_enable        = overo_panel_enable_dvi,
298         .platform_disable       = overo_panel_disable_dvi,
299 };
300
301 static struct omap_dss_device overo_dvi_device = {
302         .name                   = "dvi",
303         .type                   = OMAP_DISPLAY_TYPE_DPI,
304         .driver_name            = "generic_dpi_panel",
305         .data                   = &dvi_panel,
306         .phy.dpi.data_lines     = 24,
307 };
308
309 static struct omap_dss_device overo_tv_device = {
310         .name = "tv",
311         .driver_name = "venc",
312         .type = OMAP_DISPLAY_TYPE_VENC,
313         .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
314 };
315
316 static int overo_panel_enable_lcd(struct omap_dss_device *dssdev)
317 {
318         if (dvi_enabled) {
319                 printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
320                 return -EINVAL;
321         }
322
323         gpio_set_value(OVERO_GPIO_LCD_EN, 1);
324         gpio_set_value(OVERO_GPIO_LCD_BL, 1);
325         lcd_enabled = 1;
326         return 0;
327 }
328
329 static void overo_panel_disable_lcd(struct omap_dss_device *dssdev)
330 {
331         gpio_set_value(OVERO_GPIO_LCD_EN, 0);
332         gpio_set_value(OVERO_GPIO_LCD_BL, 0);
333         lcd_enabled = 0;
334 }
335
336 static struct panel_generic_dpi_data lcd43_panel = {
337         .name                   = "samsung_lte430wq_f0c",
338         .platform_enable        = overo_panel_enable_lcd,
339         .platform_disable       = overo_panel_disable_lcd,
340 };
341
342 static struct omap_dss_device overo_lcd43_device = {
343         .name                   = "lcd43",
344         .type                   = OMAP_DISPLAY_TYPE_DPI,
345         .driver_name            = "generic_dpi_panel",
346         .data                   = &lcd43_panel,
347         .phy.dpi.data_lines     = 24,
348 };
349
350 #if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \
351         defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)
352 static struct omap_dss_device overo_lcd35_device = {
353         .type                   = OMAP_DISPLAY_TYPE_DPI,
354         .name                   = "lcd35",
355         .driver_name            = "lgphilips_lb035q02_panel",
356         .phy.dpi.data_lines     = 24,
357         .platform_enable        = overo_panel_enable_lcd,
358         .platform_disable       = overo_panel_disable_lcd,
359 };
360 #endif
361
362 static struct omap_dss_device *overo_dss_devices[] = {
363         &overo_dvi_device,
364         &overo_tv_device,
365 #if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \
366         defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)
367         &overo_lcd35_device,
368 #endif
369         &overo_lcd43_device,
370 };
371
372 static struct omap_dss_board_info overo_dss_data = {
373         .num_devices    = ARRAY_SIZE(overo_dss_devices),
374         .devices        = overo_dss_devices,
375         .default_device = &overo_dvi_device,
376 };
377
378 static struct regulator_consumer_supply overo_vdda_dac_supply =
379         REGULATOR_SUPPLY("vdda_dac", "omapdss_venc");
380
381 static struct regulator_consumer_supply overo_vdds_dsi_supply[] = {
382         REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
383         REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi1"),
384 };
385
386 static struct mtd_partition overo_nand_partitions[] = {
387         {
388                 .name           = "xloader",
389                 .offset         = 0,                    /* Offset = 0x00000 */
390                 .size           = 4 * NAND_BLOCK_SIZE,
391                 .mask_flags     = MTD_WRITEABLE
392         },
393         {
394                 .name           = "uboot",
395                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x80000 */
396                 .size           = 14 * NAND_BLOCK_SIZE,
397         },
398         {
399                 .name           = "uboot environment",
400                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x240000 */
401                 .size           = 2 * NAND_BLOCK_SIZE,
402         },
403         {
404                 .name           = "linux",
405                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x280000 */
406                 .size           = 32 * NAND_BLOCK_SIZE,
407         },
408         {
409                 .name           = "rootfs",
410                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x680000 */
411                 .size           = MTDPART_SIZ_FULL,
412         },
413 };
414
415 static struct omap_nand_platform_data overo_nand_data = {
416         .parts = overo_nand_partitions,
417         .nr_parts = ARRAY_SIZE(overo_nand_partitions),
418         .dma_channel = -1,      /* disable DMA in OMAP NAND driver */
419 };
420
421 static void __init overo_flash_init(void)
422 {
423         u8 cs = 0;
424         u8 nandcs = GPMC_CS_NUM + 1;
425
426         /* find out the chip-select on which NAND exists */
427         while (cs < GPMC_CS_NUM) {
428                 u32 ret = 0;
429                 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
430
431                 if ((ret & 0xC00) == 0x800) {
432                         printk(KERN_INFO "Found NAND on CS%d\n", cs);
433                         if (nandcs > GPMC_CS_NUM)
434                                 nandcs = cs;
435                 }
436                 cs++;
437         }
438
439         if (nandcs > GPMC_CS_NUM) {
440                 printk(KERN_INFO "NAND: Unable to find configuration "
441                                  "in GPMC\n ");
442                 return;
443         }
444
445         if (nandcs < GPMC_CS_NUM) {
446                 overo_nand_data.cs = nandcs;
447
448                 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
449                 if (gpmc_nand_init(&overo_nand_data) < 0)
450                         printk(KERN_ERR "Unable to register NAND device\n");
451         }
452 }
453
454 static struct omap2_hsmmc_info mmc[] = {
455         {
456                 .mmc            = 1,
457                 .caps           = MMC_CAP_4_BIT_DATA,
458                 .gpio_cd        = -EINVAL,
459                 .gpio_wp        = -EINVAL,
460         },
461         {
462                 .mmc            = 2,
463                 .caps           = MMC_CAP_4_BIT_DATA,
464                 .gpio_cd        = -EINVAL,
465                 .gpio_wp        = -EINVAL,
466                 .transceiver    = true,
467                 .ocr_mask       = 0x00100000,   /* 3.3V */
468         },
469         {}      /* Terminator */
470 };
471
472 static struct regulator_consumer_supply overo_vmmc1_supply = {
473         .supply                 = "vmmc",
474 };
475
476 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
477 #include <linux/leds.h>
478
479 static struct gpio_led gpio_leds[] = {
480         {
481                 .name                   = "overo:red:gpio21",
482                 .default_trigger        = "heartbeat",
483                 .gpio                   = 21,
484                 .active_low             = true,
485         },
486         {
487                 .name                   = "overo:blue:gpio22",
488                 .default_trigger        = "none",
489                 .gpio                   = 22,
490                 .active_low             = true,
491         },
492         {
493                 .name                   = "overo:blue:COM",
494                 .default_trigger        = "mmc0",
495                 .gpio                   = -EINVAL,      /* gets replaced */
496                 .active_low             = true,
497         },
498 };
499
500 static struct gpio_led_platform_data gpio_leds_pdata = {
501         .leds           = gpio_leds,
502         .num_leds       = ARRAY_SIZE(gpio_leds),
503 };
504
505 static struct platform_device gpio_leds_device = {
506         .name   = "leds-gpio",
507         .id     = -1,
508         .dev    = {
509                 .platform_data  = &gpio_leds_pdata,
510         },
511 };
512
513 static void __init overo_init_led(void)
514 {
515         platform_device_register(&gpio_leds_device);
516 }
517
518 #else
519 static inline void __init overo_init_led(void) { return; }
520 #endif
521
522 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
523 #include <linux/input.h>
524 #include <linux/gpio_keys.h>
525
526 static struct gpio_keys_button gpio_buttons[] = {
527         {
528                 .code                   = BTN_0,
529                 .gpio                   = 23,
530                 .desc                   = "button0",
531                 .wakeup                 = 1,
532         },
533         {
534                 .code                   = BTN_1,
535                 .gpio                   = 14,
536                 .desc                   = "button1",
537                 .wakeup                 = 1,
538         },
539 };
540
541 static struct gpio_keys_platform_data gpio_keys_pdata = {
542         .buttons        = gpio_buttons,
543         .nbuttons       = ARRAY_SIZE(gpio_buttons),
544 };
545
546 static struct platform_device gpio_keys_device = {
547         .name   = "gpio-keys",
548         .id     = -1,
549         .dev    = {
550                 .platform_data  = &gpio_keys_pdata,
551         },
552 };
553
554 static void __init overo_init_keys(void)
555 {
556         platform_device_register(&gpio_keys_device);
557 }
558
559 #else
560 static inline void __init overo_init_keys(void) { return; }
561 #endif
562
563 static int overo_twl_gpio_setup(struct device *dev,
564                 unsigned gpio, unsigned ngpio)
565 {
566         omap2_hsmmc_init(mmc);
567
568         overo_vmmc1_supply.dev = mmc[0].dev;
569
570 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
571         /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
572         gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
573 #endif
574
575         return 0;
576 }
577
578 static struct twl4030_gpio_platform_data overo_gpio_data = {
579         .gpio_base      = OMAP_MAX_GPIO_LINES,
580         .irq_base       = TWL4030_GPIO_IRQ_BASE,
581         .irq_end        = TWL4030_GPIO_IRQ_END,
582         .use_leds       = true,
583         .setup          = overo_twl_gpio_setup,
584 };
585
586 static struct twl4030_usb_data overo_usb_data = {
587         .usb_mode       = T2_USB_MODE_ULPI,
588 };
589
590 static struct regulator_init_data overo_vmmc1 = {
591         .constraints = {
592                 .min_uV                 = 1850000,
593                 .max_uV                 = 3150000,
594                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
595                                         | REGULATOR_MODE_STANDBY,
596                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
597                                         | REGULATOR_CHANGE_MODE
598                                         | REGULATOR_CHANGE_STATUS,
599         },
600         .num_consumer_supplies  = 1,
601         .consumer_supplies      = &overo_vmmc1_supply,
602 };
603
604 /* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */
605 static struct regulator_init_data overo_vdac = {
606         .constraints = {
607                 .min_uV                 = 1800000,
608                 .max_uV                 = 1800000,
609                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
610                                         | REGULATOR_MODE_STANDBY,
611                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
612                                         | REGULATOR_CHANGE_STATUS,
613         },
614         .num_consumer_supplies  = 1,
615         .consumer_supplies      = &overo_vdda_dac_supply,
616 };
617
618 /* VPLL2 for digital video outputs */
619 static struct regulator_init_data overo_vpll2 = {
620         .constraints = {
621                 .name                   = "VDVI",
622                 .min_uV                 = 1800000,
623                 .max_uV                 = 1800000,
624                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
625                                         | REGULATOR_MODE_STANDBY,
626                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
627                                         | REGULATOR_CHANGE_STATUS,
628         },
629         .num_consumer_supplies  = ARRAY_SIZE(overo_vdds_dsi_supply),
630         .consumer_supplies      = overo_vdds_dsi_supply,
631 };
632
633 static struct twl4030_codec_audio_data overo_audio_data;
634
635 static struct twl4030_codec_data overo_codec_data = {
636         .audio_mclk = 26000000,
637         .audio = &overo_audio_data,
638 };
639
640 static struct twl4030_platform_data overo_twldata = {
641         .irq_base       = TWL4030_IRQ_BASE,
642         .irq_end        = TWL4030_IRQ_END,
643         .gpio           = &overo_gpio_data,
644         .usb            = &overo_usb_data,
645         .codec          = &overo_codec_data,
646         .vmmc1          = &overo_vmmc1,
647         .vdac           = &overo_vdac,
648         .vpll2          = &overo_vpll2,
649 };
650
651 static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
652         {
653                 I2C_BOARD_INFO("tps65950", 0x48),
654                 .flags = I2C_CLIENT_WAKE,
655                 .irq = INT_34XX_SYS_NIRQ,
656                 .platform_data = &overo_twldata,
657         },
658 };
659
660 static int __init overo_i2c_init(void)
661 {
662         omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo,
663                         ARRAY_SIZE(overo_i2c_boardinfo));
664         /* i2c2 pins are used for gpio */
665         omap_register_i2c_bus(3, 400, NULL, 0);
666         return 0;
667 }
668
669 static struct spi_board_info overo_spi_board_info[] __initdata = {
670 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
671         defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
672         {
673                 .modalias               = "ads7846",
674                 .bus_num                = 1,
675                 .chip_select            = 0,
676                 .max_speed_hz           = 1500000,
677                 .controller_data        = &ads7846_mcspi_config,
678                 .irq                    = OMAP_GPIO_IRQ(OVERO_GPIO_PENDOWN),
679                 .platform_data          = &ads7846_config,
680         },
681 #endif
682 #if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \
683         defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)
684         {
685                 .modalias               = "lgphilips_lb035q02_panel-spi",
686                 .bus_num                = 1,
687                 .chip_select            = 1,
688                 .max_speed_hz           = 500000,
689                 .mode                   = SPI_MODE_3,
690         },
691 #endif
692 };
693
694 static int __init overo_spi_init(void)
695 {
696         overo_ads7846_init();
697         spi_register_board_info(overo_spi_board_info,
698                         ARRAY_SIZE(overo_spi_board_info));
699         return 0;
700 }
701
702 static void __init overo_init_early(void)
703 {
704         omap2_init_common_infrastructure();
705         omap2_init_common_devices(mt46h32m32lf6_sdrc_params,
706                                   mt46h32m32lf6_sdrc_params);
707 }
708
709 static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
710         .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
711         .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
712         .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
713         .phy_reset  = true,
714         .reset_gpio_port[0]  = -EINVAL,
715         .reset_gpio_port[1]  = OVERO_GPIO_USBH_NRESET,
716         .reset_gpio_port[2]  = -EINVAL
717 };
718
719 #ifdef CONFIG_OMAP_MUX
720 static struct omap_board_mux board_mux[] __initdata = {
721         { .reg_offset = OMAP_MUX_TERMINATOR },
722 };
723 #endif
724
725 static struct omap_musb_board_data musb_board_data = {
726         .interface_type         = MUSB_INTERFACE_ULPI,
727         .mode                   = MUSB_OTG,
728         .power                  = 100,
729 };
730
731 static void __init overo_init(void)
732 {
733         omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
734         overo_i2c_init();
735         omap_display_init(&overo_dss_data);
736         omap_serial_init();
737         overo_flash_init();
738         usb_musb_init(&musb_board_data);
739         usbhs_init(&usbhs_bdata);
740         overo_spi_init();
741         overo_ads7846_init();
742         overo_init_smsc911x();
743         overo_display_init();
744         overo_init_led();
745         overo_init_keys();
746
747         /* Ensure SDRC pins are mux'd for self-refresh */
748         omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
749         omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
750
751         if ((gpio_request(OVERO_GPIO_W2W_NRESET,
752                           "OVERO_GPIO_W2W_NRESET") == 0) &&
753             (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) {
754                 gpio_export(OVERO_GPIO_W2W_NRESET, 0);
755                 gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);
756                 udelay(10);
757                 gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
758         } else {
759                 printk(KERN_ERR "could not obtain gpio for "
760                                         "OVERO_GPIO_W2W_NRESET\n");
761         }
762
763         if ((gpio_request(OVERO_GPIO_BT_XGATE, "OVERO_GPIO_BT_XGATE") == 0) &&
764             (gpio_direction_output(OVERO_GPIO_BT_XGATE, 0) == 0))
765                 gpio_export(OVERO_GPIO_BT_XGATE, 0);
766         else
767                 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
768
769         if ((gpio_request(OVERO_GPIO_BT_NRESET, "OVERO_GPIO_BT_NRESET") == 0) &&
770             (gpio_direction_output(OVERO_GPIO_BT_NRESET, 1) == 0)) {
771                 gpio_export(OVERO_GPIO_BT_NRESET, 0);
772                 gpio_set_value(OVERO_GPIO_BT_NRESET, 0);
773                 mdelay(6);
774                 gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
775         } else {
776                 printk(KERN_ERR "could not obtain gpio for "
777                                         "OVERO_GPIO_BT_NRESET\n");
778         }
779
780         if ((gpio_request(OVERO_GPIO_USBH_CPEN, "OVERO_GPIO_USBH_CPEN") == 0) &&
781             (gpio_direction_output(OVERO_GPIO_USBH_CPEN, 1) == 0))
782                 gpio_export(OVERO_GPIO_USBH_CPEN, 0);
783         else
784                 printk(KERN_ERR "could not obtain gpio for "
785                                         "OVERO_GPIO_USBH_CPEN\n");
786 }
787
788 MACHINE_START(OVERO, "Gumstix Overo")
789         .boot_params    = 0x80000100,
790         .reserve        = omap_reserve,
791         .map_io         = omap3_map_io,
792         .init_early     = overo_init_early,
793         .init_irq       = omap_init_irq,
794         .init_machine   = overo_init,
795         .timer          = &omap_timer,
796 MACHINE_END