omap3beagle: camera: Change MT9T111 references to new MT9T112 driver
[beagleboard-validation:linux.git] / arch / arm / mach-omap2 / board-omap3beagle.c
1 /*
2  * linux/arch/arm/mach-omap2/board-omap3beagle.c
3  *
4  * Copyright (C) 2008 Texas Instruments
5  *
6  * Modified from mach-omap2/board-3430sdp.c
7  *
8  * Initial code: Syed Mohammed Khasim
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/err.h>
20 #include <linux/clk.h>
21 #include <linux/io.h>
22 #include <linux/leds.h>
23 #include <linux/gpio.h>
24 #include <linux/irq.h>
25 #include <linux/input.h>
26 #include <linux/gpio_keys.h>
27 #include <linux/spi/spi.h>
28
29 #include <linux/mtd/mtd.h>
30 #include <linux/mtd/partitions.h>
31 #include <linux/mtd/nand.h>
32
33 #include <linux/regulator/machine.h>
34 #include <linux/i2c/twl.h>
35
36 #include <mach/hardware.h>
37 #include <asm/mach-types.h>
38 #include <asm/mach/arch.h>
39 #include <asm/mach/map.h>
40 #include <asm/mach/flash.h>
41
42 #include <plat/board.h>
43 #include <plat/common.h>
44 #include <plat/display.h>
45 #include <plat/gpmc.h>
46 #include <plat/nand.h>
47 #include <plat/usb.h>
48 #include <plat/timer-gp.h>
49 #include <plat/clock.h>
50 #include <plat/omap-pm.h>
51 #include <plat/mcspi.h>
52
53 #include "mux.h"
54 #include "mmc-twl4030.h"
55 #include "pm.h"
56 #include "omap3-opp.h"
57
58 #ifdef CONFIG_PM
59 static struct omap_opp * _omap35x_mpu_rate_table        = omap35x_mpu_rate_table;
60 static struct omap_opp * _omap37x_mpu_rate_table        = omap37x_mpu_rate_table;
61 static struct omap_opp * _omap35x_dsp_rate_table        = omap35x_dsp_rate_table;
62 static struct omap_opp * _omap37x_dsp_rate_table        = omap37x_dsp_rate_table;
63 static struct omap_opp * _omap35x_l3_rate_table         = omap35x_l3_rate_table;
64 static struct omap_opp * _omap37x_l3_rate_table         = omap37x_l3_rate_table;
65 #else   /* CONFIG_PM */
66 static struct omap_opp * _omap35x_mpu_rate_table        = NULL;
67 static struct omap_opp * _omap37x_mpu_rate_table        = NULL;
68 static struct omap_opp * _omap35x_dsp_rate_table        = NULL;
69 static struct omap_opp * _omap37x_dsp_rate_table        = NULL;
70 static struct omap_opp * _omap35x_l3_rate_table         = NULL;
71 static struct omap_opp * _omap37x_l3_rate_table         = NULL;
72 #endif  /* CONFIG_PM */
73
74 #if defined(CONFIG_VIDEO_MT9V113) || defined(CONFIG_VIDEO_MT9V113_MODULE)
75 #include <media/v4l2-int-device.h>
76 #include <media/mt9v113.h>
77 extern struct mt9v113_platform_data mt9v113_pdata;
78 #endif
79
80 #if defined(CONFIG_VIDEO_MT9T112) || defined(CONFIG_VIDEO_MT9T112_MODULE)
81 #include <media/v4l2-int-device.h>
82 #include <media/mt9t112.h>
83 extern struct mt9t112_platform_data mt9t112_pdata;
84 #endif
85
86 #define GPMC_CS0_BASE  0x60
87 #define GPMC_CS_SIZE   0x30
88
89 #define NAND_BLOCK_SIZE         SZ_128K
90
91 char expansionboard_name[16];
92
93 #if defined(CONFIG_ENC28J60) || defined(CONFIG_ENC28J60_MODULE)
94
95 #include <plat/mcspi.h>
96 #include <linux/spi/spi.h>
97
98 #define OMAP3BEAGLE_GPIO_ENC28J60_IRQ 157
99
100 static struct omap2_mcspi_device_config enc28j60_spi_chip_info = {
101         .turbo_mode     = 0,
102         .single_channel = 1,    /* 0: slave, 1: master */
103 };
104
105 static struct spi_board_info omap3beagle_zippy_spi_board_info[] __initdata = {
106         {
107                 .modalias               = "enc28j60",
108                 .bus_num                = 4,
109                 .chip_select            = 0,
110                 .max_speed_hz           = 20000000,
111                 .controller_data        = &enc28j60_spi_chip_info,
112         },
113 };
114
115 static void __init omap3beagle_enc28j60_init(void)
116 {
117         if ((gpio_request(OMAP3BEAGLE_GPIO_ENC28J60_IRQ, "ENC28J60_IRQ") == 0) &&
118             (gpio_direction_input(OMAP3BEAGLE_GPIO_ENC28J60_IRQ) == 0)) {
119                 gpio_export(OMAP3BEAGLE_GPIO_ENC28J60_IRQ, 0);
120                 omap3beagle_zippy_spi_board_info[0].irq = OMAP_GPIO_IRQ(OMAP3BEAGLE_GPIO_ENC28J60_IRQ);
121                 set_irq_type(omap3beagle_zippy_spi_board_info[0].irq, IRQ_TYPE_EDGE_FALLING);
122         } else {
123                 printk(KERN_ERR "could not obtain gpio for ENC28J60_IRQ\n");
124                 return;
125         }
126
127         spi_register_board_info(omap3beagle_zippy_spi_board_info,
128                         ARRAY_SIZE(omap3beagle_zippy_spi_board_info));
129 }
130
131 #else
132 static inline void __init omap3beagle_enc28j60_init(void) { return; }
133 #endif
134
135 #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
136
137 #include <plat/mcspi.h>
138 #include <linux/spi/spi.h>
139
140 #define OMAP3BEAGLE_GPIO_KS8851_IRQ 157
141
142 static struct omap2_mcspi_device_config ks8851_spi_chip_info = {
143         .turbo_mode     = 0,
144         .single_channel = 1,    /* 0: slave, 1: master */
145 };
146
147 static struct spi_board_info omap3beagle_zippy2_spi_board_info[] __initdata = {
148         {
149                 .modalias               = "ks8851",
150                 .bus_num                = 4,
151                 .chip_select            = 0,
152                 .max_speed_hz           = 36000000,
153                 .controller_data        = &ks8851_spi_chip_info,
154         },
155 };
156
157 static void __init omap3beagle_ks8851_init(void)
158 {
159         if ((gpio_request(OMAP3BEAGLE_GPIO_KS8851_IRQ, "KS8851_IRQ") == 0) &&
160             (gpio_direction_input(OMAP3BEAGLE_GPIO_KS8851_IRQ) == 0)) {
161                 gpio_export(OMAP3BEAGLE_GPIO_KS8851_IRQ, 0);
162                 omap3beagle_zippy2_spi_board_info[0].irq        = OMAP_GPIO_IRQ(OMAP3BEAGLE_GPIO_KS8851_IRQ);
163                 set_irq_type(omap3beagle_zippy2_spi_board_info[0].irq, IRQ_TYPE_EDGE_FALLING);
164         } else {
165                 printk(KERN_ERR "could not obtain gpio for KS8851_IRQ\n");
166                 return;
167         }
168
169         spi_register_board_info(omap3beagle_zippy2_spi_board_info,
170                                                         ARRAY_SIZE(omap3beagle_zippy2_spi_board_info));
171 }
172
173 #else
174 static inline void __init omap3beagle_ks8851_init(void) { return; }
175 #endif
176
177 static struct mtd_partition omap3beagle_nand_partitions[] = {
178         /* All the partition sizes are listed in terms of NAND block size */
179         {
180                 .name           = "X-Loader",
181                 .offset         = 0,
182                 .size           = 4 * NAND_BLOCK_SIZE,
183                 .mask_flags     = MTD_WRITEABLE,        /* force read-only */
184         },
185         {
186                 .name           = "U-Boot",
187                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x80000 */
188                 .size           = 15 * NAND_BLOCK_SIZE,
189         },
190         {
191                 .name           = "U-Boot Env",
192                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x260000 */
193                 .size           = 1 * NAND_BLOCK_SIZE,
194         },
195         {
196                 .name           = "Kernel",
197                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x280000 */
198                 .size           = 32 * NAND_BLOCK_SIZE,
199         },
200         {
201                 .name           = "File System",
202                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x680000 */
203                 .size           = MTDPART_SIZ_FULL,
204         },
205 };
206
207 static struct omap_nand_platform_data omap3beagle_nand_data = {
208         .options        = NAND_BUSWIDTH_16,
209         .parts          = omap3beagle_nand_partitions,
210         .nr_parts       = ARRAY_SIZE(omap3beagle_nand_partitions),
211         .dma_channel    = -1,           /* disable DMA in OMAP NAND driver */
212         .nand_setup     = NULL,
213         .dev_ready      = NULL,
214 };
215
216 static struct resource omap3beagle_nand_resource = {
217         .flags          = IORESOURCE_MEM,
218 };
219
220 static struct platform_device omap3beagle_nand_device = {
221         .name           = "omap2-nand",
222         .id             = -1,
223         .dev            = {
224                 .platform_data  = &omap3beagle_nand_data,
225         },
226         .num_resources  = 1,
227         .resource       = &omap3beagle_nand_resource,
228 };
229
230 /* DSS */
231
232 static int beagle_enable_dvi(struct omap_dss_device *dssdev)
233 {
234         if (dssdev->reset_gpio != -1)
235                 gpio_set_value(dssdev->reset_gpio, 1);
236
237         return 0;
238 }
239
240 static void beagle_disable_dvi(struct omap_dss_device *dssdev)
241 {
242         if (dssdev->reset_gpio != -1)
243                 gpio_set_value(dssdev->reset_gpio, 0);
244 }
245
246 static struct omap_dss_device beagle_dvi_device = {
247         .type = OMAP_DISPLAY_TYPE_DPI,
248         .name = "dvi",
249         .driver_name = "generic_panel",
250         .phy.dpi.data_lines = 24,
251         .platform_enable = beagle_enable_dvi,
252         .platform_disable = beagle_disable_dvi,
253 };
254
255 static int beagle_panel_enable_tv(struct omap_dss_device *dssdev)
256 {
257 #define ENABLE_VDAC_DEDICATED           0x03
258 #define ENABLE_VDAC_DEV_GRP             0x20
259
260         twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
261                         ENABLE_VDAC_DEDICATED,
262                         TWL4030_VDAC_DEDICATED);
263         twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
264                         ENABLE_VDAC_DEV_GRP, TWL4030_VDAC_DEV_GRP);
265
266         return 0;
267 }
268
269 static void beagle_panel_disable_tv(struct omap_dss_device *dssdev)
270 {
271         twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x00,
272                         TWL4030_VDAC_DEDICATED);
273         twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x00,
274                         TWL4030_VDAC_DEV_GRP);
275 }
276
277 static struct omap_dss_device beagle_tv_device = {
278         .name = "tv",
279         .driver_name = "venc",
280         .type = OMAP_DISPLAY_TYPE_VENC,
281         .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
282         .platform_enable = beagle_panel_enable_tv,
283         .platform_disable = beagle_panel_disable_tv,
284 };
285
286 static struct omap_dss_device *beagle_dss_devices[] = {
287         &beagle_dvi_device,
288         &beagle_tv_device,
289 };
290
291 static struct omap_dss_board_info beagle_dss_data = {
292         .num_devices = ARRAY_SIZE(beagle_dss_devices),
293         .devices = beagle_dss_devices,
294         .default_device = &beagle_dvi_device,
295 };
296
297 static struct platform_device beagle_dss_device = {
298         .name          = "omapdss",
299         .id            = -1,
300         .dev            = {
301                 .platform_data = &beagle_dss_data,
302         },
303 };
304
305 static struct regulator_consumer_supply beagle_vdac_supply = {
306         .supply         = "vdda_dac",
307         .dev            = &beagle_dss_device.dev,
308 };
309
310 static struct regulator_consumer_supply beagle_vdvi_supply = {
311         .supply         = "vdds_dsi",
312         .dev            = &beagle_dss_device.dev,
313 };
314
315 static void __init beagle_display_init(void)
316 {
317         int r;
318
319         r = gpio_request(beagle_dvi_device.reset_gpio, "DVI reset");
320         if (r < 0) {
321                 printk(KERN_ERR "Unable to get DVI reset GPIO\n");
322                 return;
323         }
324
325         gpio_direction_output(beagle_dvi_device.reset_gpio, 0);
326 }
327
328 #include "sdram-micron-mt46h32m32lf-6.h"
329
330 static struct twl4030_hsmmc_info mmc[] = {
331         {
332                 .mmc            = 1,
333                 .wires          = 8,
334                 .gpio_wp        = 29,
335         },
336         {
337                 .mmc            = 2,
338                 .wires          = 4,
339                 .transceiver    = true,
340                 .ocr_mask       = 0x00100000,   /* 3.3V */
341         },
342         {}      /* Terminator */
343 };
344
345 static struct regulator_consumer_supply beagle_vmmc1_supply = {
346         .supply                 = "vmmc",
347 };
348
349 static struct regulator_consumer_supply beagle_vsim_supply = {
350         .supply                 = "vmmc_aux",
351 };
352
353 static struct gpio_led gpio_leds[];
354
355 static int beagle_twl_gpio_setup(struct device *dev,
356                 unsigned gpio, unsigned ngpio)
357 {
358         if (system_rev >= 0x20 && system_rev <= 0x34301000) {
359                 omap_mux_init_gpio(23, OMAP_PIN_INPUT);
360                 mmc[0].gpio_wp = 23;
361         } else {
362                 omap_mux_init_gpio(29, OMAP_PIN_INPUT);
363         }
364         /* gpio + 0 is "mmc0_cd" (input/IRQ) */
365         mmc[0].gpio_cd = gpio + 0;
366         twl4030_mmc_init(mmc);
367
368         /* link regulators to MMC adapters */
369         beagle_vmmc1_supply.dev = mmc[0].dev;
370         beagle_vsim_supply.dev = mmc[0].dev;
371
372         /* REVISIT: need ehci-omap hooks for external VBUS
373          * power switch and overcurrent detect
374          */
375
376         if (cpu_is_omap3630()) {
377                 /* DVI reset GPIO is different between revisions */     
378                 beagle_dvi_device.reset_gpio = 129;
379
380                 /* Power on DVI, Serial and PWR led */ 
381                 gpio_request(gpio + 1, "nDVI_PWR_EN");
382                 gpio_direction_output(gpio + 1, 0);
383
384                 /* Power on camera interface */
385                 gpio_request(gpio + 2, "CAM_EN");
386                 gpio_direction_output(gpio + 2, 1);
387
388                 /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
389                 gpio_request(gpio + TWL4030_GPIO_MAX, "nEN_USB_PWR");
390                 gpio_direction_output(gpio + TWL4030_GPIO_MAX, 0);
391         }
392         else {
393                 /* DVI reset GPIO is different between revisions */ 
394                 beagle_dvi_device.reset_gpio = 170;
395                                 
396                 gpio_request(gpio + 1, "EHCI_nOC");
397                 gpio_direction_input(gpio + 1);
398
399                 /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
400                 gpio_request(gpio + TWL4030_GPIO_MAX, "nEN_USB_PWR");
401                 gpio_direction_output(gpio + TWL4030_GPIO_MAX, 0);
402         }
403
404
405         /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
406         gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
407
408         return 0;
409 }
410
411 static struct twl4030_gpio_platform_data beagle_gpio_data = {
412         .gpio_base      = OMAP_MAX_GPIO_LINES,
413         .irq_base       = TWL4030_GPIO_IRQ_BASE,
414         .irq_end        = TWL4030_GPIO_IRQ_END,
415         .use_leds       = true,
416         .pullups        = BIT(1),
417         .pulldowns      = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
418                                 | BIT(15) | BIT(16) | BIT(17),
419         .setup          = beagle_twl_gpio_setup,
420 };
421
422
423 static struct platform_device beagle_cam_device = {
424         .name           = "beagle_cam",
425         .id             = -1,
426 };
427
428 static struct regulator_consumer_supply beagle_vaux3_supply = {
429         .supply         = "cam_1v8",
430         .dev            = &beagle_cam_device.dev,
431 };
432
433 static struct regulator_consumer_supply beagle_vaux4_supply = {
434         .supply         = "cam_2v8",
435         .dev            = &beagle_cam_device.dev,
436 };
437
438 /* VAUX3 for CAM_1V8 */
439 static struct regulator_init_data beagle_vaux3 = {
440         .constraints = {
441                 .min_uV                 = 1800000,
442                 .max_uV                 = 1800000,
443                 .apply_uV               = true,
444                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
445                                         | REGULATOR_MODE_STANDBY,
446                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
447                                         | REGULATOR_CHANGE_STATUS,
448         },
449         .num_consumer_supplies  = 1,
450         .consumer_supplies      = &beagle_vaux3_supply,
451 };
452
453 /* VAUX4 for CAM_2V8 */
454 static struct regulator_init_data beagle_vaux4 = {
455         .constraints = {
456                 .min_uV                 = 1800000,
457                 .max_uV                 = 1800000,
458                 .apply_uV               = true,
459                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
460                                         | REGULATOR_MODE_STANDBY,
461                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
462                                         | REGULATOR_CHANGE_STATUS,
463         },
464         .num_consumer_supplies  = 1,
465         .consumer_supplies      = &beagle_vaux4_supply,
466 };
467
468 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
469 static struct regulator_init_data beagle_vmmc1 = {
470         .constraints = {
471                 .min_uV                 = 1850000,
472                 .max_uV                 = 3150000,
473                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
474                                         | REGULATOR_MODE_STANDBY,
475                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
476                                         | REGULATOR_CHANGE_MODE
477                                         | REGULATOR_CHANGE_STATUS,
478         },
479         .num_consumer_supplies  = 1,
480         .consumer_supplies      = &beagle_vmmc1_supply,
481 };
482
483 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
484 static struct regulator_init_data beagle_vsim = {
485         .constraints = {
486                 .min_uV                 = 1800000,
487                 .max_uV                 = 3000000,
488                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
489                                         | REGULATOR_MODE_STANDBY,
490                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
491                                         | REGULATOR_CHANGE_MODE
492                                         | REGULATOR_CHANGE_STATUS,
493         },
494         .num_consumer_supplies  = 1,
495         .consumer_supplies      = &beagle_vsim_supply,
496 };
497
498 /* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */
499 static struct regulator_init_data beagle_vdac = {
500         .constraints = {
501                 .min_uV                 = 1800000,
502                 .max_uV                 = 1800000,
503                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
504                                         | REGULATOR_MODE_STANDBY,
505                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
506                                         | REGULATOR_CHANGE_STATUS,
507         },
508         .num_consumer_supplies  = 1,
509         .consumer_supplies      = &beagle_vdac_supply,
510 };
511
512 /* VPLL2 for digital video outputs */
513 static struct regulator_init_data beagle_vpll2 = {
514         .constraints = {
515                 .name                   = "VDVI",
516                 .min_uV                 = 1800000,
517                 .max_uV                 = 1800000,
518                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
519                                         | REGULATOR_MODE_STANDBY,
520                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
521                                         | REGULATOR_CHANGE_STATUS,
522         },
523         .num_consumer_supplies  = 1,
524         .consumer_supplies      = &beagle_vdvi_supply,
525 };
526
527 static struct twl4030_usb_data beagle_usb_data = {
528         .usb_mode       = T2_USB_MODE_ULPI,
529 };
530
531 static struct twl4030_codec_audio_data beagle_audio_data = {
532         .audio_mclk = 26000000,
533 };
534
535 static struct twl4030_codec_data beagle_codec_data = {
536         .audio_mclk = 26000000,
537         .audio = &beagle_audio_data,
538 };
539
540 static struct twl4030_madc_platform_data beagle_madc_data = {
541         .irq_line       = 1,
542 };
543
544 static struct twl4030_platform_data beagle_twldata = {
545         .irq_base       = TWL4030_IRQ_BASE,
546         .irq_end        = TWL4030_IRQ_END,
547
548         /* platform_data for children goes here */
549         .usb            = &beagle_usb_data,
550         .gpio           = &beagle_gpio_data,
551         .codec          = &beagle_codec_data,
552         .madc           = &beagle_madc_data,
553         .vmmc1          = &beagle_vmmc1,
554         .vsim           = &beagle_vsim,
555         .vdac           = &beagle_vdac,
556         .vpll2          = &beagle_vpll2,
557         .vaux3          = &beagle_vaux3,
558         .vaux4          = &beagle_vaux4,
559 };
560
561 static struct i2c_board_info __initdata beagle_i2c1_boardinfo[] = {
562         {
563                 I2C_BOARD_INFO("twl4030", 0x48),
564                 .flags = I2C_CLIENT_WAKE,
565                 .irq = INT_34XX_SYS_NIRQ,
566                 .platform_data = &beagle_twldata,
567         },
568 };
569
570
571 #if defined(CONFIG_EEPROM_AT24) || defined(CONFIG_EEPROM_AT24_MODULE)
572 #include <linux/i2c/at24.h>
573
574 static struct at24_platform_data m24c01 = {
575                 .byte_len       = SZ_1K / 8,
576                 .page_size      = 16,
577 };
578
579 #if defined(CONFIG_RTC_DRV_DS1307) || \
580         defined(CONFIG_RTC_DRV_DS1307_MODULE)
581
582 static struct i2c_board_info __initdata beagle_zippy_i2c2_boardinfo[] = {
583         {
584                 I2C_BOARD_INFO("ds1307", 0x68),
585         },
586         {
587                 I2C_BOARD_INFO("24c01", 0x50),
588                 .platform_data  = &m24c01,
589         },
590 };
591 #else
592 static struct i2c_board_info __initdata beagle_zippy_i2c2_boardinfo[] = {
593         {
594                 I2C_BOARD_INFO("24c01", 0x50),
595                 .platform_data  = &m24c01,
596         },
597 };
598 #endif
599 #else
600 static struct i2c_board_info __initdata beagle_zippy_i2c2_boardinfo[] = {};
601 #endif
602
603 static struct i2c_board_info __initdata beagle_i2c2_boardinfo[] = {
604 #if defined(CONFIG_VIDEO_MT9V113) || defined(CONFIG_VIDEO_MT9V113_MODULE)
605         {
606                 I2C_BOARD_INFO("mt9v113", MT9V113_I2C_ADDR),
607                 .platform_data  = &mt9v113_pdata,
608         },
609 #endif
610 #if defined(CONFIG_VIDEO_MT9T112) || defined(CONFIG_VIDEO_MT9T112_MODULE)
611         {
612                 I2C_BOARD_INFO("mt9t112", MT9T112_I2C_ADDR),
613                 .platform_data  = &mt9t112_pdata,
614         },
615 #endif
616 };
617
618 static int __init omap3_beagle_i2c_init(void)
619 {
620         omap_register_i2c_bus(1, 2600, beagle_i2c1_boardinfo,
621                         ARRAY_SIZE(beagle_i2c1_boardinfo));
622         if(!strcmp(expansionboard_name, "zippy") || !strcmp(expansionboard_name, "zippy2"))
623         {
624                 printk(KERN_INFO "Beagle expansionboard: registering i2c2 bus for zippy/zippy2\n");
625                 omap_register_i2c_bus(2, 400,  beagle_zippy_i2c2_boardinfo,
626                                 ARRAY_SIZE(beagle_zippy_i2c2_boardinfo));
627         } else
628         {
629                 omap_register_i2c_bus(2, 400,  beagle_i2c2_boardinfo,
630                                 ARRAY_SIZE(beagle_i2c2_boardinfo));
631         }
632         /* Bus 3 is attached to the DVI port where devices like the pico DLP
633          * projector don't work reliably with 400kHz */
634         omap_register_i2c_bus(3, 100, NULL, 0);
635         return 0;
636 }
637
638 static struct gpio_led gpio_leds[] = {
639         {
640                 .name                   = "beagleboard::usr0",
641                 .default_trigger        = "heartbeat",
642                 .gpio                   = 150,
643         },
644         {
645                 .name                   = "beagleboard::usr1",
646                 .default_trigger        = "mmc0",
647                 .gpio                   = 149,
648         },
649         {
650                 .name                   = "beagleboard::pmu_stat",
651                 .gpio                   = -EINVAL,      /* gets replaced */
652                 .active_low             = true,
653         },
654 };
655
656 static struct gpio_led_platform_data gpio_led_info = {
657         .leds           = gpio_leds,
658         .num_leds       = ARRAY_SIZE(gpio_leds),
659 };
660
661 static struct platform_device leds_gpio = {
662         .name   = "leds-gpio",
663         .id     = -1,
664         .dev    = {
665                 .platform_data  = &gpio_led_info,
666         },
667 };
668
669 static struct gpio_keys_button gpio_buttons[] = {
670         {
671                 .code                   = BTN_EXTRA,
672                 .gpio                   = 7,
673                 .desc                   = "user",
674                 .wakeup                 = 1,
675         },
676 };
677
678 static struct gpio_keys_platform_data gpio_key_info = {
679         .buttons        = gpio_buttons,
680         .nbuttons       = ARRAY_SIZE(gpio_buttons),
681 };
682
683 static struct platform_device keys_gpio = {
684         .name   = "gpio-keys",
685         .id     = -1,
686         .dev    = {
687                 .platform_data  = &gpio_key_info,
688         },
689 };
690
691 static struct spi_board_info beaglefpga_mcspi_board_info[] = {
692         // spi 4.0
693         {
694                 .modalias       = "spidev",
695                 .max_speed_hz   = 48000000, //48 Mbps
696                 .bus_num        = 4,
697                 .chip_select    = 0,
698                 .mode = SPI_MODE_1,
699         },
700 };
701
702 static void __init beaglefpga_init_spi(void)
703 {
704         /* hook the spi ports to the spidev driver */
705         spi_register_board_info(beaglefpga_mcspi_board_info,
706                 ARRAY_SIZE(beaglefpga_mcspi_board_info));
707 }
708
709 static void __init omap3_beagle_init_irq(void)
710 {
711         if (cpu_is_omap3630())
712         {
713                 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
714                                         mt46h32m32lf6_sdrc_params,
715                                         _omap37x_mpu_rate_table,
716                                         _omap37x_dsp_rate_table,
717                                         _omap37x_l3_rate_table);
718         }
719         else
720         {
721                 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
722                                         mt46h32m32lf6_sdrc_params,
723                                         _omap35x_mpu_rate_table,
724                                         _omap35x_dsp_rate_table,
725                                         _omap35x_l3_rate_table);
726         }
727         omap_init_irq();
728 #ifdef CONFIG_OMAP_32K_TIMER
729         omap2_gp_clockevent_set_gptimer(12);
730 #endif
731         omap_gpio_init();
732 }
733
734 static struct platform_device *omap3_beagle_devices[] __initdata = {
735         &leds_gpio,
736         &keys_gpio,
737         &beagle_dss_device,
738         &beagle_cam_device,
739 };
740
741 static void __init omap3beagle_flash_init(void)
742 {
743         u8 cs = 0;
744         u8 nandcs = GPMC_CS_NUM + 1;
745
746         u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
747
748         /* find out the chip-select on which NAND exists */
749         while (cs < GPMC_CS_NUM) {
750                 u32 ret = 0;
751                 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
752
753                 if ((ret & 0xC00) == 0x800) {
754                         printk(KERN_INFO "Found NAND on CS%d\n", cs);
755                         if (nandcs > GPMC_CS_NUM)
756                                 nandcs = cs;
757                 }
758                 cs++;
759         }
760
761         if (nandcs > GPMC_CS_NUM) {
762                 printk(KERN_INFO "NAND: Unable to find configuration "
763                                  "in GPMC\n ");
764                 return;
765         }
766
767         if (nandcs < GPMC_CS_NUM) {
768                 omap3beagle_nand_data.cs = nandcs;
769                 omap3beagle_nand_data.gpmc_cs_baseaddr = (void *)
770                         (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
771                 omap3beagle_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
772
773                 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
774                 if (platform_device_register(&omap3beagle_nand_device) < 0)
775                         printk(KERN_ERR "Unable to register NAND device\n");
776         }
777 }
778
779 static struct ehci_hcd_omap_platform_data ehci_pdata __initdata = {
780
781         .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
782         .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
783         .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
784
785         .phy_reset  = true,
786         .reset_gpio_port[0]  = -EINVAL,
787         .reset_gpio_port[1]  = 147,
788         .reset_gpio_port[2]  = -EINVAL
789 };
790
791 #ifdef CONFIG_OMAP_MUX
792 static struct omap_board_mux board_mux[] __initdata = {
793         /* Camera - Parallel Data */
794         OMAP3_MUX(CAM_D0, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
795         OMAP3_MUX(CAM_D1, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
796         OMAP3_MUX(CAM_D2, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
797         OMAP3_MUX(CAM_D3, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
798         OMAP3_MUX(CAM_D4, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
799         OMAP3_MUX(CAM_D5, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
800         OMAP3_MUX(CAM_D6, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
801         OMAP3_MUX(CAM_D7, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
802         OMAP3_MUX(CAM_D8, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
803         OMAP3_MUX(CAM_D9, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
804         OMAP3_MUX(CAM_D10, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
805         OMAP3_MUX(CAM_D11, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
806         OMAP3_MUX(CAM_PCLK, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
807
808         /* Camera - HS/VS signals */
809         OMAP3_MUX(CAM_HS, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
810         OMAP3_MUX(CAM_VS, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
811
812         /* Camera - Reset GPIO 98 */
813         OMAP3_MUX(CAM_FLD, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
814
815         /* Camera - XCLK */
816         OMAP3_MUX(CAM_XCLKA, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT),
817
818         { .reg_offset = OMAP_MUX_TERMINATOR },
819 };
820 #else
821 #define board_mux       NULL
822 #endif
823
824 static int __init expansionboard_setup(char *str)
825 {
826         if (!str)
827                 return -EINVAL;
828         strncpy(expansionboard_name, str, 16);
829         printk(KERN_INFO "Beagle expansionboard: %s\n", expansionboard_name);
830         return 0;
831 }
832
833 static void __init omap3_beagle_init(void)
834 {
835         omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
836         omap3_beagle_i2c_init();
837         platform_add_devices(omap3_beagle_devices,
838                         ARRAY_SIZE(omap3_beagle_devices));
839         omap_serial_init();
840
841 <<<<<<< HEAD
842         if(!strcmp(expansionboard_name, "zippy")) 
843 =======
844         omap_mux_init_gpio(170, OMAP_PIN_INPUT);
845         gpio_request(170, "DVI_nPD");
846         /* REVISIT leave DVI powered down until it's needed ... */
847         gpio_direction_output(170, true);
848
849         if(!strcmp(expansionboard_name, "zippy"))
850 >>>>>>> eed14c9... BeagleXM:Cam: Add support for MT9V113 VGA Sensor
851         {
852                 printk(KERN_INFO "Beagle expansionboard: initializing enc28j60\n");
853                 omap3beagle_enc28j60_init();
854                 printk(KERN_INFO "Beagle expansionboard: assigning GPIO 141 and 162 to MMC1\n");
855                 mmc[1].gpio_wp = 141;
856                 mmc[1].gpio_cd = 162;
857         }
858
859         if(!strcmp(expansionboard_name, "zippy2"))
860         {
861                 printk(KERN_INFO "Beagle expansionboard: initializing ks_8851\n");
862                 omap3beagle_ks8851_init();
863                 printk(KERN_INFO "Beagle expansionboard: assigning GPIO 141 and 162 to MMC1\n");
864                 mmc[1].gpio_wp = 141;
865                 mmc[1].gpio_cd = 162;
866         }
867
868         if(!strcmp(expansionboard_name, "trainer"))
869         {
870                 printk(KERN_INFO "Beagle expansionboard: exporting GPIOs 130-141,162 to userspace\n");
871                 gpio_request(130, "sysfs");
872                 gpio_export(130, 1);
873                 gpio_request(131, "sysfs");
874                 gpio_export(131, 1);
875                 gpio_request(132, "sysfs");
876                 gpio_export(132, 1);
877                 gpio_request(133, "sysfs");
878                 gpio_export(133, 1);
879                 gpio_request(134, "sysfs");
880                 gpio_export(134, 1);
881                 gpio_request(135, "sysfs");
882                 gpio_export(135, 1);
883                 gpio_request(136, "sysfs");
884                 gpio_export(136, 1);
885                 gpio_request(137, "sysfs");
886                 gpio_export(137, 1);
887                 gpio_request(138, "sysfs");
888                 gpio_export(138, 1);
889                 gpio_request(139, "sysfs");
890                 gpio_export(139, 1);
891                 gpio_request(140, "sysfs");
892                 gpio_export(140, 1);
893                 gpio_request(141, "sysfs");
894                 gpio_export(141, 1);
895                 gpio_request(162, "sysfs");
896                 gpio_export(162, 1);
897         }
898
899         if(!strcmp(expansionboard_name, "beaglefpga"))
900         {
901                 printk(KERN_INFO "Beagle expansionboard: Using McSPI for SPI\n");
902                 beaglefpga_init_spi();
903         }
904
905         usb_musb_init();
906         usb_ehci_init(&ehci_pdata);
907         omap3beagle_flash_init();
908
909         /* Ensure SDRC pins are mux'd for self-refresh */
910         omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
911         omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
912
913         beagle_display_init();
914 }
915 static void __init omap3_beagle_map_io(void)
916 {
917         omap2_set_globals_343x();
918         omap2_map_common_io();
919 }
920
921 early_param("buddy", expansionboard_setup);
922
923 MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
924         /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
925         .phys_io        = 0x48000000,
926         .io_pg_offst    = ((0xfa000000) >> 18) & 0xfffc,
927         .boot_params    = 0x80000100,
928         .map_io         = omap3_beagle_map_io,
929         .init_irq       = omap3_beagle_init_irq,
930         .init_machine   = omap3_beagle_init,
931         .timer          = &omap_timer,
932 MACHINE_END