1c4f9e236b9fd1b73f37fab53026340cc2f7512d
[safe/jmp/linux-2.6] / arch / blackfin / mach-bf527 / boards / cm_bf527.c
1 /*
2  * Copyright 2004-2009 Analog Devices Inc.
3  *           2008-2009 Bluetechnix
4  *                2005 National ICT Australia (NICTA)
5  *                      Aidan Williams <aidan@nicta.com.au>
6  *
7  * Licensed under the GPL-2 or later.
8  */
9
10 #include <linux/device.h>
11 #include <linux/platform_device.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/mtd/physmap.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/flash.h>
17 #include <linux/etherdevice.h>
18 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
19 #include <linux/usb/isp1362.h>
20 #endif
21 #include <linux/i2c.h>
22 #include <linux/irq.h>
23 #include <linux/interrupt.h>
24 #include <linux/usb/sl811.h>
25 #include <linux/usb/musb.h>
26 #include <asm/dma.h>
27 #include <asm/bfin5xx_spi.h>
28 #include <asm/reboot.h>
29 #include <asm/nand.h>
30 #include <asm/portmux.h>
31 #include <asm/dpmc.h>
32 #include <linux/spi/ad7877.h>
33
34 /*
35  * Name the Board for the /proc/cpuinfo
36  */
37 const char bfin_board_name[] = "Bluetechnix CM-BF527";
38
39 /*
40  *  Driver needs to know address, irq and flag pin.
41  */
42
43 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
44 #include <linux/usb/isp1760.h>
45 static struct resource bfin_isp1760_resources[] = {
46         [0] = {
47                 .start  = 0x203C0000,
48                 .end    = 0x203C0000 + 0x000fffff,
49                 .flags  = IORESOURCE_MEM,
50         },
51         [1] = {
52                 .start  = IRQ_PF7,
53                 .end    = IRQ_PF7,
54                 .flags  = IORESOURCE_IRQ,
55         },
56 };
57
58 static struct isp1760_platform_data isp1760_priv = {
59         .is_isp1761 = 0,
60         .bus_width_16 = 1,
61         .port1_otg = 0,
62         .analog_oc = 0,
63         .dack_polarity_high = 0,
64         .dreq_polarity_high = 0,
65 };
66
67 static struct platform_device bfin_isp1760_device = {
68         .name           = "isp1760-hcd",
69         .id             = 0,
70         .dev = {
71                 .platform_data = &isp1760_priv,
72         },
73         .num_resources  = ARRAY_SIZE(bfin_isp1760_resources),
74         .resource       = bfin_isp1760_resources,
75 };
76 #endif
77
78 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
79 static struct resource musb_resources[] = {
80         [0] = {
81                 .start  = 0xffc03800,
82                 .end    = 0xffc03cff,
83                 .flags  = IORESOURCE_MEM,
84         },
85         [1] = { /* general IRQ */
86                 .start  = IRQ_USB_INT0,
87                 .end    = IRQ_USB_INT0,
88                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
89         },
90         [2] = { /* DMA IRQ */
91                 .start  = IRQ_USB_DMA,
92                 .end    = IRQ_USB_DMA,
93                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
94         },
95 };
96
97 static struct musb_hdrc_config musb_config = {
98         .multipoint     = 0,
99         .dyn_fifo       = 0,
100         .soft_con       = 1,
101         .dma            = 1,
102         .num_eps        = 8,
103         .dma_channels   = 8,
104         .gpio_vrsel     = GPIO_PF11,
105 };
106
107 static struct musb_hdrc_platform_data musb_plat = {
108 #if defined(CONFIG_USB_MUSB_OTG)
109         .mode           = MUSB_OTG,
110 #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
111         .mode           = MUSB_HOST,
112 #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
113         .mode           = MUSB_PERIPHERAL,
114 #endif
115         .config         = &musb_config,
116 };
117
118 static u64 musb_dmamask = ~(u32)0;
119
120 static struct platform_device musb_device = {
121         .name           = "musb_hdrc",
122         .id             = 0,
123         .dev = {
124                 .dma_mask               = &musb_dmamask,
125                 .coherent_dma_mask      = 0xffffffff,
126                 .platform_data          = &musb_plat,
127         },
128         .num_resources  = ARRAY_SIZE(musb_resources),
129         .resource       = musb_resources,
130 };
131 #endif
132
133 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
134 static struct mtd_partition partition_info[] = {
135         {
136                 .name = "linux kernel(nand)",
137                 .offset = 0,
138                 .size = 4 * 1024 * 1024,
139         },
140         {
141                 .name = "file system(nand)",
142                 .offset = MTDPART_OFS_APPEND,
143                 .size = MTDPART_SIZ_FULL,
144         },
145 };
146
147 static struct bf5xx_nand_platform bf5xx_nand_platform = {
148         .page_size = NFC_PG_SIZE_256,
149         .data_width = NFC_NWIDTH_8,
150         .partitions = partition_info,
151         .nr_partitions = ARRAY_SIZE(partition_info),
152         .rd_dly = 3,
153         .wr_dly = 3,
154 };
155
156 static struct resource bf5xx_nand_resources[] = {
157         {
158                 .start = NFC_CTL,
159                 .end = NFC_DATA_RD + 2,
160                 .flags = IORESOURCE_MEM,
161         },
162         {
163                 .start = CH_NFC,
164                 .end = CH_NFC,
165                 .flags = IORESOURCE_IRQ,
166         },
167 };
168
169 static struct platform_device bf5xx_nand_device = {
170         .name = "bf5xx-nand",
171         .id = 0,
172         .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
173         .resource = bf5xx_nand_resources,
174         .dev = {
175                 .platform_data = &bf5xx_nand_platform,
176         },
177 };
178 #endif
179
180 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
181 static struct resource bfin_pcmcia_cf_resources[] = {
182         {
183                 .start = 0x20310000, /* IO PORT */
184                 .end = 0x20312000,
185                 .flags = IORESOURCE_MEM,
186         }, {
187                 .start = 0x20311000, /* Attribute Memory */
188                 .end = 0x20311FFF,
189                 .flags = IORESOURCE_MEM,
190         }, {
191                 .start = IRQ_PF4,
192                 .end = IRQ_PF4,
193                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
194         }, {
195                 .start = 6, /* Card Detect PF6 */
196                 .end = 6,
197                 .flags = IORESOURCE_IRQ,
198         },
199 };
200
201 static struct platform_device bfin_pcmcia_cf_device = {
202         .name = "bfin_cf_pcmcia",
203         .id = -1,
204         .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
205         .resource = bfin_pcmcia_cf_resources,
206 };
207 #endif
208
209 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
210 static struct platform_device rtc_device = {
211         .name = "rtc-bfin",
212         .id   = -1,
213 };
214 #endif
215
216 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
217 #include <linux/smc91x.h>
218
219 static struct smc91x_platdata smc91x_info = {
220         .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
221         .leda = RPC_LED_100_10,
222         .ledb = RPC_LED_TX_RX,
223 };
224
225 static struct resource smc91x_resources[] = {
226         {
227                 .name = "smc91x-regs",
228                 .start = 0x20300300,
229                 .end = 0x20300300 + 16,
230                 .flags = IORESOURCE_MEM,
231         }, {
232
233                 .start = IRQ_PF7,
234                 .end = IRQ_PF7,
235                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
236         },
237 };
238 static struct platform_device smc91x_device = {
239         .name = "smc91x",
240         .id = 0,
241         .num_resources = ARRAY_SIZE(smc91x_resources),
242         .resource = smc91x_resources,
243         .dev    = {
244                 .platform_data  = &smc91x_info,
245         },
246 };
247 #endif
248
249 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
250 static struct resource dm9000_resources[] = {
251         [0] = {
252                 .start  = 0x203FB800,
253                 .end    = 0x203FB800 + 1,
254                 .flags  = IORESOURCE_MEM,
255         },
256         [1] = {
257                 .start  = 0x203FB804,
258                 .end    = 0x203FB804 + 1,
259                 .flags  = IORESOURCE_MEM,
260         },
261         [2] = {
262                 .start  = IRQ_PF9,
263                 .end    = IRQ_PF9,
264                 .flags  = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
265         },
266 };
267
268 static struct platform_device dm9000_device = {
269         .name           = "dm9000",
270         .id             = -1,
271         .num_resources  = ARRAY_SIZE(dm9000_resources),
272         .resource       = dm9000_resources,
273 };
274 #endif
275
276 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
277 static struct resource sl811_hcd_resources[] = {
278         {
279                 .start = 0x20340000,
280                 .end = 0x20340000,
281                 .flags = IORESOURCE_MEM,
282         }, {
283                 .start = 0x20340004,
284                 .end = 0x20340004,
285                 .flags = IORESOURCE_MEM,
286         }, {
287                 .start = CONFIG_USB_SL811_BFIN_IRQ,
288                 .end = CONFIG_USB_SL811_BFIN_IRQ,
289                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
290         },
291 };
292
293 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
294 void sl811_port_power(struct device *dev, int is_on)
295 {
296         gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
297         gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
298 }
299 #endif
300
301 static struct sl811_platform_data sl811_priv = {
302         .potpg = 10,
303         .power = 250,       /* == 500mA */
304 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
305         .port_power = &sl811_port_power,
306 #endif
307 };
308
309 static struct platform_device sl811_hcd_device = {
310         .name = "sl811-hcd",
311         .id = 0,
312         .dev = {
313                 .platform_data = &sl811_priv,
314         },
315         .num_resources = ARRAY_SIZE(sl811_hcd_resources),
316         .resource = sl811_hcd_resources,
317 };
318 #endif
319
320 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
321 static struct resource isp1362_hcd_resources[] = {
322         {
323                 .start = 0x20360000,
324                 .end = 0x20360000,
325                 .flags = IORESOURCE_MEM,
326         }, {
327                 .start = 0x20360004,
328                 .end = 0x20360004,
329                 .flags = IORESOURCE_MEM,
330         }, {
331                 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
332                 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
333                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
334         },
335 };
336
337 static struct isp1362_platform_data isp1362_priv = {
338         .sel15Kres = 1,
339         .clknotstop = 0,
340         .oc_enable = 0,
341         .int_act_high = 0,
342         .int_edge_triggered = 0,
343         .remote_wakeup_connected = 0,
344         .no_power_switching = 1,
345         .power_switching_mode = 0,
346 };
347
348 static struct platform_device isp1362_hcd_device = {
349         .name = "isp1362-hcd",
350         .id = 0,
351         .dev = {
352                 .platform_data = &isp1362_priv,
353         },
354         .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
355         .resource = isp1362_hcd_resources,
356 };
357 #endif
358
359 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
360 static struct platform_device bfin_mii_bus = {
361         .name = "bfin_mii_bus",
362 };
363
364 static struct platform_device bfin_mac_device = {
365         .name = "bfin_mac",
366         .dev.platform_data = &bfin_mii_bus,
367 };
368 #endif
369
370 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
371 static struct resource net2272_bfin_resources[] = {
372         {
373                 .start = 0x20300000,
374                 .end = 0x20300000 + 0x100,
375                 .flags = IORESOURCE_MEM,
376         }, {
377                 .start = IRQ_PF7,
378                 .end = IRQ_PF7,
379                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
380         },
381 };
382
383 static struct platform_device net2272_bfin_device = {
384         .name = "net2272",
385         .id = -1,
386         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
387         .resource = net2272_bfin_resources,
388 };
389 #endif
390
391 #if defined(CONFIG_MTD_M25P80) \
392         || defined(CONFIG_MTD_M25P80_MODULE)
393 static struct mtd_partition bfin_spi_flash_partitions[] = {
394         {
395                 .name = "bootloader(spi)",
396                 .size = 0x00040000,
397                 .offset = 0,
398                 .mask_flags = MTD_CAP_ROM
399         }, {
400                 .name = "linux kernel(spi)",
401                 .size = MTDPART_SIZ_FULL,
402                 .offset = MTDPART_OFS_APPEND,
403         }
404 };
405
406 static struct flash_platform_data bfin_spi_flash_data = {
407         .name = "m25p80",
408         .parts = bfin_spi_flash_partitions,
409         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
410         .type = "m25p16",
411 };
412
413 /* SPI flash chip (m25p64) */
414 static struct bfin5xx_spi_chip spi_flash_chip_info = {
415         .enable_dma = 0,         /* use dma transfer with this chip*/
416         .bits_per_word = 8,
417 };
418 #endif
419
420 #if defined(CONFIG_BFIN_SPI_ADC) \
421         || defined(CONFIG_BFIN_SPI_ADC_MODULE)
422 /* SPI ADC chip */
423 static struct bfin5xx_spi_chip spi_adc_chip_info = {
424         .enable_dma = 1,         /* use dma transfer with this chip*/
425         .bits_per_word = 16,
426 };
427 #endif
428
429 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
430         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
431 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
432         .enable_dma = 0,
433         .bits_per_word = 16,
434 };
435 #endif
436
437 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
438 static struct bfin5xx_spi_chip  mmc_spi_chip_info = {
439         .enable_dma = 0,
440         .bits_per_word = 8,
441 };
442 #endif
443
444 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
445 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
446         .enable_dma = 0,
447         .bits_per_word = 16,
448 };
449
450 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
451         .model                  = 7877,
452         .vref_delay_usecs       = 50,   /* internal, no capacitor */
453         .x_plate_ohms           = 419,
454         .y_plate_ohms           = 486,
455         .pressure_max           = 1000,
456         .pressure_min           = 0,
457         .stopacq_polarity       = 1,
458         .first_conversion_delay = 3,
459         .acquisition_time       = 1,
460         .averaging              = 1,
461         .pen_down_acc_interval  = 1,
462 };
463 #endif
464
465 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
466          && defined(CONFIG_SND_SOC_WM8731_SPI)
467 static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
468         .enable_dma = 0,
469         .bits_per_word = 16,
470 };
471 #endif
472
473 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
474 static struct bfin5xx_spi_chip spidev_chip_info = {
475         .enable_dma = 0,
476         .bits_per_word = 8,
477 };
478 #endif
479
480 static struct spi_board_info bfin_spi_board_info[] __initdata = {
481 #if defined(CONFIG_MTD_M25P80) \
482         || defined(CONFIG_MTD_M25P80_MODULE)
483         {
484                 /* the modalias must be the same as spi device driver name */
485                 .modalias = "m25p80", /* Name of spi_driver for this device */
486                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
487                 .bus_num = 0, /* Framework bus number */
488                 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
489                 .platform_data = &bfin_spi_flash_data,
490                 .controller_data = &spi_flash_chip_info,
491                 .mode = SPI_MODE_3,
492         },
493 #endif
494
495 #if defined(CONFIG_BFIN_SPI_ADC) \
496         || defined(CONFIG_BFIN_SPI_ADC_MODULE)
497         {
498                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
499                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
500                 .bus_num = 0, /* Framework bus number */
501                 .chip_select = 1, /* Framework chip select. */
502                 .platform_data = NULL, /* No spi_driver specific config */
503                 .controller_data = &spi_adc_chip_info,
504         },
505 #endif
506
507 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
508         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
509         {
510                 .modalias = "ad1836",
511                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
512                 .bus_num = 0,
513                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
514                 .controller_data = &ad1836_spi_chip_info,
515         },
516 #endif
517 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
518         {
519                 .modalias = "mmc_spi",
520                 .max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
521                 .bus_num = 0,
522                 .chip_select = 5,
523                 .controller_data = &mmc_spi_chip_info,
524                 .mode = SPI_MODE_3,
525         },
526 #endif
527 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
528         {
529                 .modalias               = "ad7877",
530                 .platform_data          = &bfin_ad7877_ts_info,
531                 .irq                    = IRQ_PF8,
532                 .max_speed_hz   = 12500000,     /* max spi clock (SCK) speed in HZ */
533                 .bus_num        = 0,
534                 .chip_select  = 2,
535                 .controller_data = &spi_ad7877_chip_info,
536         },
537 #endif
538 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
539          && defined(CONFIG_SND_SOC_WM8731_SPI)
540         {
541                 .modalias       = "wm8731",
542                 .max_speed_hz   = 3125000,     /* max spi clock (SCK) speed in HZ */
543                 .bus_num        = 0,
544                 .chip_select    = 5,
545                 .controller_data = &spi_wm8731_chip_info,
546                 .mode = SPI_MODE_0,
547         },
548 #endif
549 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
550         {
551                 .modalias = "spidev",
552                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
553                 .bus_num = 0,
554                 .chip_select = 1,
555                 .controller_data = &spidev_chip_info,
556         },
557 #endif
558 };
559
560 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
561 /* SPI controller data */
562 static struct bfin5xx_spi_master bfin_spi0_info = {
563         .num_chipselect = 8,
564         .enable_dma = 1,  /* master has the ability to do dma transfer */
565         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
566 };
567
568 /* SPI (0) */
569 static struct resource bfin_spi0_resource[] = {
570         [0] = {
571                 .start = SPI0_REGBASE,
572                 .end   = SPI0_REGBASE + 0xFF,
573                 .flags = IORESOURCE_MEM,
574                 },
575         [1] = {
576                 .start = CH_SPI,
577                 .end   = CH_SPI,
578                 .flags = IORESOURCE_DMA,
579         },
580         [2] = {
581                 .start = IRQ_SPI,
582                 .end   = IRQ_SPI,
583                 .flags = IORESOURCE_IRQ,
584         },
585 };
586
587 static struct platform_device bfin_spi0_device = {
588         .name = "bfin-spi",
589         .id = 0, /* Bus number */
590         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
591         .resource = bfin_spi0_resource,
592         .dev = {
593                 .platform_data = &bfin_spi0_info, /* Passed to driver */
594         },
595 };
596 #endif  /* spi master and devices */
597
598 #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
599 static struct mtd_partition cm_partitions[] = {
600         {
601                 .name   = "bootloader(nor)",
602                 .size   = 0x40000,
603                 .offset = 0,
604         }, {
605                 .name   = "linux kernel(nor)",
606                 .size   = 0x100000,
607                 .offset = MTDPART_OFS_APPEND,
608         }, {
609                 .name   = "file system(nor)",
610                 .size   = MTDPART_SIZ_FULL,
611                 .offset = MTDPART_OFS_APPEND,
612         }
613 };
614
615 static struct physmap_flash_data cm_flash_data = {
616         .width    = 2,
617         .parts    = cm_partitions,
618         .nr_parts = ARRAY_SIZE(cm_partitions),
619 };
620
621 static unsigned cm_flash_gpios[] = { GPIO_PH9, GPIO_PG11 };
622
623 static struct resource cm_flash_resource[] = {
624         {
625                 .name  = "cfi_probe",
626                 .start = 0x20000000,
627                 .end   = 0x201fffff,
628                 .flags = IORESOURCE_MEM,
629         }, {
630                 .start = (unsigned long)cm_flash_gpios,
631                 .end   = ARRAY_SIZE(cm_flash_gpios),
632                 .flags = IORESOURCE_IRQ,
633         }
634 };
635
636 static struct platform_device cm_flash_device = {
637         .name          = "gpio-addr-flash",
638         .id            = 0,
639         .dev = {
640                 .platform_data = &cm_flash_data,
641         },
642         .num_resources = ARRAY_SIZE(cm_flash_resource),
643         .resource      = cm_flash_resource,
644 };
645 #endif
646
647 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
648 static struct resource bfin_uart_resources[] = {
649 #ifdef CONFIG_SERIAL_BFIN_UART0
650         {
651                 .start = 0xFFC00400,
652                 .end = 0xFFC004FF,
653                 .flags = IORESOURCE_MEM,
654         },
655 #endif
656 #ifdef CONFIG_SERIAL_BFIN_UART1
657         {
658                 .start = 0xFFC02000,
659                 .end = 0xFFC020FF,
660                 .flags = IORESOURCE_MEM,
661         },
662 #endif
663 };
664
665 static struct platform_device bfin_uart_device = {
666         .name = "bfin-uart",
667         .id = 1,
668         .num_resources = ARRAY_SIZE(bfin_uart_resources),
669         .resource = bfin_uart_resources,
670 };
671 #endif
672
673 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
674 #ifdef CONFIG_BFIN_SIR0
675 static struct resource bfin_sir0_resources[] = {
676         {
677                 .start = 0xFFC00400,
678                 .end = 0xFFC004FF,
679                 .flags = IORESOURCE_MEM,
680         },
681         {
682                 .start = IRQ_UART0_RX,
683                 .end = IRQ_UART0_RX+1,
684                 .flags = IORESOURCE_IRQ,
685         },
686         {
687                 .start = CH_UART0_RX,
688                 .end = CH_UART0_RX+1,
689                 .flags = IORESOURCE_DMA,
690         },
691 };
692
693 static struct platform_device bfin_sir0_device = {
694         .name = "bfin_sir",
695         .id = 0,
696         .num_resources = ARRAY_SIZE(bfin_sir0_resources),
697         .resource = bfin_sir0_resources,
698 };
699 #endif
700 #ifdef CONFIG_BFIN_SIR1
701 static struct resource bfin_sir1_resources[] = {
702         {
703                 .start = 0xFFC02000,
704                 .end = 0xFFC020FF,
705                 .flags = IORESOURCE_MEM,
706         },
707         {
708                 .start = IRQ_UART1_RX,
709                 .end = IRQ_UART1_RX+1,
710                 .flags = IORESOURCE_IRQ,
711         },
712         {
713                 .start = CH_UART1_RX,
714                 .end = CH_UART1_RX+1,
715                 .flags = IORESOURCE_DMA,
716         },
717 };
718
719 static struct platform_device bfin_sir1_device = {
720         .name = "bfin_sir",
721         .id = 1,
722         .num_resources = ARRAY_SIZE(bfin_sir1_resources),
723         .resource = bfin_sir1_resources,
724 };
725 #endif
726 #endif
727
728 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
729 static struct resource bfin_twi0_resource[] = {
730         [0] = {
731                 .start = TWI0_REGBASE,
732                 .end   = TWI0_REGBASE,
733                 .flags = IORESOURCE_MEM,
734         },
735         [1] = {
736                 .start = IRQ_TWI,
737                 .end   = IRQ_TWI,
738                 .flags = IORESOURCE_IRQ,
739         },
740 };
741
742 static struct platform_device i2c_bfin_twi_device = {
743         .name = "i2c-bfin-twi",
744         .id = 0,
745         .num_resources = ARRAY_SIZE(bfin_twi0_resource),
746         .resource = bfin_twi0_resource,
747 };
748 #endif
749
750 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
751 #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
752         {
753                 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
754         },
755 #endif
756 #if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
757         {
758                 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
759                 .irq = IRQ_PF8,
760         },
761 #endif
762 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
763         {
764                 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
765         },
766 #endif
767 };
768
769 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
770 static struct platform_device bfin_sport0_uart_device = {
771         .name = "bfin-sport-uart",
772         .id = 0,
773 };
774
775 static struct platform_device bfin_sport1_uart_device = {
776         .name = "bfin-sport-uart",
777         .id = 1,
778 };
779 #endif
780
781 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
782 #include <linux/input.h>
783 #include <linux/gpio_keys.h>
784
785 static struct gpio_keys_button bfin_gpio_keys_table[] = {
786         {BTN_0, GPIO_PF14, 1, "gpio-keys: BTN0"},
787 };
788
789 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
790         .buttons        = bfin_gpio_keys_table,
791         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
792 };
793
794 static struct platform_device bfin_device_gpiokeys = {
795         .name      = "gpio-keys",
796         .dev = {
797                 .platform_data = &bfin_gpio_keys_data,
798         },
799 };
800 #endif
801
802 static struct resource bfin_gpios_resources = {
803         .start = 0,
804         .end   = MAX_BLACKFIN_GPIOS - 1,
805         .flags = IORESOURCE_IRQ,
806 };
807
808 static struct platform_device bfin_gpios_device = {
809         .name = "simple-gpio",
810         .id = -1,
811         .num_resources = 1,
812         .resource = &bfin_gpios_resources,
813 };
814
815 static const unsigned int cclk_vlev_datasheet[] =
816 {
817         VRPAIR(VLEV_100, 400000000),
818         VRPAIR(VLEV_105, 426000000),
819         VRPAIR(VLEV_110, 500000000),
820         VRPAIR(VLEV_115, 533000000),
821         VRPAIR(VLEV_120, 600000000),
822 };
823
824 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
825         .tuple_tab = cclk_vlev_datasheet,
826         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
827         .vr_settling_time = 25 /* us */,
828 };
829
830 static struct platform_device bfin_dpmc = {
831         .name = "bfin dpmc",
832         .dev = {
833                 .platform_data = &bfin_dmpc_vreg_data,
834         },
835 };
836
837 static struct platform_device *cmbf527_devices[] __initdata = {
838
839         &bfin_dpmc,
840
841 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
842         &bf5xx_nand_device,
843 #endif
844
845 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
846         &bfin_pcmcia_cf_device,
847 #endif
848
849 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
850         &rtc_device,
851 #endif
852
853 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
854         &sl811_hcd_device,
855 #endif
856
857 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
858         &isp1362_hcd_device,
859 #endif
860
861 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
862         &bfin_isp1760_device,
863 #endif
864
865 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
866         &musb_device,
867 #endif
868
869 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
870         &smc91x_device,
871 #endif
872
873 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
874         &dm9000_device,
875 #endif
876
877 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
878         &bfin_mii_bus,
879         &bfin_mac_device,
880 #endif
881
882 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
883         &net2272_bfin_device,
884 #endif
885
886 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
887         &bfin_spi0_device,
888 #endif
889
890 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
891         &bfin_uart_device,
892 #endif
893
894 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
895 #ifdef CONFIG_BFIN_SIR0
896         &bfin_sir0_device,
897 #endif
898 #ifdef CONFIG_BFIN_SIR1
899         &bfin_sir1_device,
900 #endif
901 #endif
902
903 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
904         &i2c_bfin_twi_device,
905 #endif
906
907 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
908         &bfin_sport0_uart_device,
909         &bfin_sport1_uart_device,
910 #endif
911
912 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
913         &bfin_device_gpiokeys,
914 #endif
915
916 #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
917         &cm_flash_device,
918 #endif
919
920         &bfin_gpios_device,
921 };
922
923 static int __init cm_init(void)
924 {
925         printk(KERN_INFO "%s(): registering device resources\n", __func__);
926         i2c_register_board_info(0, bfin_i2c_board_info,
927                                 ARRAY_SIZE(bfin_i2c_board_info));
928         platform_add_devices(cmbf527_devices, ARRAY_SIZE(cmbf527_devices));
929         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
930         return 0;
931 }
932
933 arch_initcall(cm_init);
934
935 void native_machine_restart(char *cmd)
936 {
937         /* workaround reboot hang when booting from SPI */
938         if ((bfin_read_SYSCR() & 0x7) == 0x3)
939                 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
940 }
941
942 void bfin_get_ether_addr(char *addr)
943 {
944         random_ether_addr(addr);
945         printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
946 }
947 EXPORT_SYMBOL(bfin_get_ether_addr);