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