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