Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/kyle/parisc-2.6
[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         },
86         [2] = { /* DMA IRQ */
87                 .start  = IRQ_USB_DMA,
88                 .end    = IRQ_USB_DMA,
89                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
90         },
91 };
92
93 static struct musb_hdrc_config musb_config = {
94         .multipoint     = 0,
95         .dyn_fifo       = 0,
96         .soft_con       = 1,
97         .dma            = 1,
98         .num_eps        = 8,
99         .dma_channels   = 8,
100         .gpio_vrsel     = GPIO_PF11,
101         /* Some custom boards need to be active low, just set it to "0"
102          * if it is the case.
103          */
104         .gpio_vrsel_active      = 1,
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_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
277 static struct platform_device bfin_mii_bus = {
278         .name = "bfin_mii_bus",
279 };
280
281 static struct platform_device bfin_mac_device = {
282         .name = "bfin_mac",
283         .dev.platform_data = &bfin_mii_bus,
284 };
285 #endif
286
287 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
288 static struct resource net2272_bfin_resources[] = {
289         {
290                 .start = 0x20300000,
291                 .end = 0x20300000 + 0x100,
292                 .flags = IORESOURCE_MEM,
293         }, {
294                 .start = IRQ_PF7,
295                 .end = IRQ_PF7,
296                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
297         },
298 };
299
300 static struct platform_device net2272_bfin_device = {
301         .name = "net2272",
302         .id = -1,
303         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
304         .resource = net2272_bfin_resources,
305 };
306 #endif
307
308 #if defined(CONFIG_MTD_M25P80) \
309         || defined(CONFIG_MTD_M25P80_MODULE)
310 static struct mtd_partition bfin_spi_flash_partitions[] = {
311         {
312                 .name = "bootloader(spi)",
313                 .size = 0x00040000,
314                 .offset = 0,
315                 .mask_flags = MTD_CAP_ROM
316         }, {
317                 .name = "linux kernel(spi)",
318                 .size = MTDPART_SIZ_FULL,
319                 .offset = MTDPART_OFS_APPEND,
320         }
321 };
322
323 static struct flash_platform_data bfin_spi_flash_data = {
324         .name = "m25p80",
325         .parts = bfin_spi_flash_partitions,
326         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
327         .type = "m25p16",
328 };
329
330 /* SPI flash chip (m25p64) */
331 static struct bfin5xx_spi_chip spi_flash_chip_info = {
332         .enable_dma = 0,         /* use dma transfer with this chip*/
333         .bits_per_word = 8,
334 };
335 #endif
336
337 #if defined(CONFIG_BFIN_SPI_ADC) \
338         || defined(CONFIG_BFIN_SPI_ADC_MODULE)
339 /* SPI ADC chip */
340 static struct bfin5xx_spi_chip spi_adc_chip_info = {
341         .enable_dma = 1,         /* use dma transfer with this chip*/
342         .bits_per_word = 16,
343 };
344 #endif
345
346 #if defined(CONFIG_SND_BLACKFIN_AD183X) \
347         || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE)
348 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
349         .enable_dma = 0,
350         .bits_per_word = 16,
351 };
352 #endif
353
354 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
355 static struct bfin5xx_spi_chip  mmc_spi_chip_info = {
356         .enable_dma = 0,
357         .bits_per_word = 8,
358 };
359 #endif
360
361 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
362 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
363         .enable_dma = 0,
364         .bits_per_word = 16,
365 };
366
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 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
383          && defined(CONFIG_SND_SOC_WM8731_SPI)
384 static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
385         .enable_dma = 0,
386         .bits_per_word = 16,
387 };
388 #endif
389
390 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
391 static struct bfin5xx_spi_chip spidev_chip_info = {
392         .enable_dma = 0,
393         .bits_per_word = 8,
394 };
395 #endif
396
397 static struct spi_board_info bfin_spi_board_info[] __initdata = {
398 #if defined(CONFIG_MTD_M25P80) \
399         || defined(CONFIG_MTD_M25P80_MODULE)
400         {
401                 /* the modalias must be the same as spi device driver name */
402                 .modalias = "m25p80", /* Name of spi_driver for this device */
403                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
404                 .bus_num = 0, /* Framework bus number */
405                 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
406                 .platform_data = &bfin_spi_flash_data,
407                 .controller_data = &spi_flash_chip_info,
408                 .mode = SPI_MODE_3,
409         },
410 #endif
411
412 #if defined(CONFIG_BFIN_SPI_ADC) \
413         || defined(CONFIG_BFIN_SPI_ADC_MODULE)
414         {
415                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
416                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
417                 .bus_num = 0, /* Framework bus number */
418                 .chip_select = 1, /* Framework chip select. */
419                 .platform_data = NULL, /* No spi_driver specific config */
420                 .controller_data = &spi_adc_chip_info,
421         },
422 #endif
423
424 #if defined(CONFIG_SND_BLACKFIN_AD183X) \
425         || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE)
426         {
427                 .modalias = "ad1836",
428                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
429                 .bus_num = 0,
430                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
431                 .controller_data = &ad1836_spi_chip_info,
432         },
433 #endif
434 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
435         {
436                 .modalias = "mmc_spi",
437                 .max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
438                 .bus_num = 0,
439                 .chip_select = 5,
440                 .controller_data = &mmc_spi_chip_info,
441                 .mode = SPI_MODE_3,
442         },
443 #endif
444 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
445         {
446                 .modalias               = "ad7877",
447                 .platform_data          = &bfin_ad7877_ts_info,
448                 .irq                    = IRQ_PF8,
449                 .max_speed_hz   = 12500000,     /* max spi clock (SCK) speed in HZ */
450                 .bus_num        = 0,
451                 .chip_select  = 2,
452                 .controller_data = &spi_ad7877_chip_info,
453         },
454 #endif
455 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
456          && defined(CONFIG_SND_SOC_WM8731_SPI)
457         {
458                 .modalias       = "wm8731",
459                 .max_speed_hz   = 3125000,     /* max spi clock (SCK) speed in HZ */
460                 .bus_num        = 0,
461                 .chip_select    = 5,
462                 .controller_data = &spi_wm8731_chip_info,
463                 .mode = SPI_MODE_0,
464         },
465 #endif
466 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
467         {
468                 .modalias = "spidev",
469                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
470                 .bus_num = 0,
471                 .chip_select = 1,
472                 .controller_data = &spidev_chip_info,
473         },
474 #endif
475 };
476
477 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
478 /* SPI controller data */
479 static struct bfin5xx_spi_master bfin_spi0_info = {
480         .num_chipselect = 8,
481         .enable_dma = 1,  /* master has the ability to do dma transfer */
482         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
483 };
484
485 /* SPI (0) */
486 static struct resource bfin_spi0_resource[] = {
487         [0] = {
488                 .start = SPI0_REGBASE,
489                 .end   = SPI0_REGBASE + 0xFF,
490                 .flags = IORESOURCE_MEM,
491                 },
492         [1] = {
493                 .start = CH_SPI,
494                 .end   = CH_SPI,
495                 .flags = IORESOURCE_DMA,
496         },
497         [2] = {
498                 .start = IRQ_SPI,
499                 .end   = IRQ_SPI,
500                 .flags = IORESOURCE_IRQ,
501         },
502 };
503
504 static struct platform_device bfin_spi0_device = {
505         .name = "bfin-spi",
506         .id = 0, /* Bus number */
507         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
508         .resource = bfin_spi0_resource,
509         .dev = {
510                 .platform_data = &bfin_spi0_info, /* Passed to driver */
511         },
512 };
513 #endif  /* spi master and devices */
514
515 #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
516 static struct mtd_partition cm_partitions[] = {
517         {
518                 .name   = "bootloader(nor)",
519                 .size   = 0x40000,
520                 .offset = 0,
521         }, {
522                 .name   = "linux kernel(nor)",
523                 .size   = 0x100000,
524                 .offset = MTDPART_OFS_APPEND,
525         }, {
526                 .name   = "file system(nor)",
527                 .size   = MTDPART_SIZ_FULL,
528                 .offset = MTDPART_OFS_APPEND,
529         }
530 };
531
532 static struct physmap_flash_data cm_flash_data = {
533         .width    = 2,
534         .parts    = cm_partitions,
535         .nr_parts = ARRAY_SIZE(cm_partitions),
536 };
537
538 static unsigned cm_flash_gpios[] = { GPIO_PH9, GPIO_PG11 };
539
540 static struct resource cm_flash_resource[] = {
541         {
542                 .name  = "cfi_probe",
543                 .start = 0x20000000,
544                 .end   = 0x201fffff,
545                 .flags = IORESOURCE_MEM,
546         }, {
547                 .start = (unsigned long)cm_flash_gpios,
548                 .end   = ARRAY_SIZE(cm_flash_gpios),
549                 .flags = IORESOURCE_IRQ,
550         }
551 };
552
553 static struct platform_device cm_flash_device = {
554         .name          = "gpio-addr-flash",
555         .id            = 0,
556         .dev = {
557                 .platform_data = &cm_flash_data,
558         },
559         .num_resources = ARRAY_SIZE(cm_flash_resource),
560         .resource      = cm_flash_resource,
561 };
562 #endif
563
564 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
565 #ifdef CONFIG_SERIAL_BFIN_UART0
566 static struct resource bfin_uart0_resources[] = {
567         {
568                 .start = UART0_THR,
569                 .end = UART0_GCTL+2,
570                 .flags = IORESOURCE_MEM,
571         },
572         {
573                 .start = IRQ_UART0_RX,
574                 .end = IRQ_UART0_RX+1,
575                 .flags = IORESOURCE_IRQ,
576         },
577         {
578                 .start = IRQ_UART0_ERROR,
579                 .end = IRQ_UART0_ERROR,
580                 .flags = IORESOURCE_IRQ,
581         },
582         {
583                 .start = CH_UART0_TX,
584                 .end = CH_UART0_TX,
585                 .flags = IORESOURCE_DMA,
586         },
587         {
588                 .start = CH_UART0_RX,
589                 .end = CH_UART0_RX,
590                 .flags = IORESOURCE_DMA,
591         },
592 };
593
594 unsigned short bfin_uart0_peripherals[] = {
595         P_UART0_TX, P_UART0_RX, 0
596 };
597
598 static struct platform_device bfin_uart0_device = {
599         .name = "bfin-uart",
600         .id = 0,
601         .num_resources = ARRAY_SIZE(bfin_uart0_resources),
602         .resource = bfin_uart0_resources,
603         .dev = {
604                 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
605         },
606 };
607 #endif
608 #ifdef CONFIG_SERIAL_BFIN_UART1
609 static struct resource bfin_uart1_resources[] = {
610         {
611                 .start = UART1_THR,
612                 .end = UART1_GCTL+2,
613                 .flags = IORESOURCE_MEM,
614         },
615         {
616                 .start = IRQ_UART1_RX,
617                 .end = IRQ_UART1_RX+1,
618                 .flags = IORESOURCE_IRQ,
619         },
620         {
621                 .start = IRQ_UART1_ERROR,
622                 .end = IRQ_UART1_ERROR,
623                 .flags = IORESOURCE_IRQ,
624         },
625         {
626                 .start = CH_UART1_TX,
627                 .end = CH_UART1_TX,
628                 .flags = IORESOURCE_DMA,
629         },
630         {
631                 .start = CH_UART1_RX,
632                 .end = CH_UART1_RX,
633                 .flags = IORESOURCE_DMA,
634         },
635 #ifdef CONFIG_BFIN_UART1_CTSRTS
636         {       /* CTS pin */
637                 .start = GPIO_PF9,
638                 .end = GPIO_PF9,
639                 .flags = IORESOURCE_IO,
640         },
641         {       /* RTS pin */
642                 .start = GPIO_PF10,
643                 .end = GPIO_PF10,
644                 .flags = IORESOURCE_IO,
645         },
646 #endif
647 };
648
649 unsigned short bfin_uart1_peripherals[] = {
650         P_UART1_TX, P_UART1_RX, 0
651 };
652
653 static struct platform_device bfin_uart1_device = {
654         .name = "bfin-uart",
655         .id = 1,
656         .num_resources = ARRAY_SIZE(bfin_uart1_resources),
657         .resource = bfin_uart1_resources,
658         .dev = {
659                 .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
660         },
661 };
662 #endif
663 #endif
664
665 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
666 #ifdef CONFIG_BFIN_SIR0
667 static struct resource bfin_sir0_resources[] = {
668         {
669                 .start = 0xFFC00400,
670                 .end = 0xFFC004FF,
671                 .flags = IORESOURCE_MEM,
672         },
673         {
674                 .start = IRQ_UART0_RX,
675                 .end = IRQ_UART0_RX+1,
676                 .flags = IORESOURCE_IRQ,
677         },
678         {
679                 .start = CH_UART0_RX,
680                 .end = CH_UART0_RX+1,
681                 .flags = IORESOURCE_DMA,
682         },
683 };
684
685 static struct platform_device bfin_sir0_device = {
686         .name = "bfin_sir",
687         .id = 0,
688         .num_resources = ARRAY_SIZE(bfin_sir0_resources),
689         .resource = bfin_sir0_resources,
690 };
691 #endif
692 #ifdef CONFIG_BFIN_SIR1
693 static struct resource bfin_sir1_resources[] = {
694         {
695                 .start = 0xFFC02000,
696                 .end = 0xFFC020FF,
697                 .flags = IORESOURCE_MEM,
698         },
699         {
700                 .start = IRQ_UART1_RX,
701                 .end = IRQ_UART1_RX+1,
702                 .flags = IORESOURCE_IRQ,
703         },
704         {
705                 .start = CH_UART1_RX,
706                 .end = CH_UART1_RX+1,
707                 .flags = IORESOURCE_DMA,
708         },
709 };
710
711 static struct platform_device bfin_sir1_device = {
712         .name = "bfin_sir",
713         .id = 1,
714         .num_resources = ARRAY_SIZE(bfin_sir1_resources),
715         .resource = bfin_sir1_resources,
716 };
717 #endif
718 #endif
719
720 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
721 static struct resource bfin_twi0_resource[] = {
722         [0] = {
723                 .start = TWI0_REGBASE,
724                 .end   = TWI0_REGBASE,
725                 .flags = IORESOURCE_MEM,
726         },
727         [1] = {
728                 .start = IRQ_TWI,
729                 .end   = IRQ_TWI,
730                 .flags = IORESOURCE_IRQ,
731         },
732 };
733
734 static struct platform_device i2c_bfin_twi_device = {
735         .name = "i2c-bfin-twi",
736         .id = 0,
737         .num_resources = ARRAY_SIZE(bfin_twi0_resource),
738         .resource = bfin_twi0_resource,
739 };
740 #endif
741
742 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
743 #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
744         {
745                 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
746         },
747 #endif
748 #if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
749         {
750                 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
751                 .irq = IRQ_PF8,
752         },
753 #endif
754 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
755         {
756                 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
757         },
758 #endif
759 };
760
761 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
762 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
763 static struct resource bfin_sport0_uart_resources[] = {
764         {
765                 .start = SPORT0_TCR1,
766                 .end = SPORT0_MRCS3+4,
767                 .flags = IORESOURCE_MEM,
768         },
769         {
770                 .start = IRQ_SPORT0_RX,
771                 .end = IRQ_SPORT0_RX+1,
772                 .flags = IORESOURCE_IRQ,
773         },
774         {
775                 .start = IRQ_SPORT0_ERROR,
776                 .end = IRQ_SPORT0_ERROR,
777                 .flags = IORESOURCE_IRQ,
778         },
779 };
780
781 unsigned short bfin_sport0_peripherals[] = {
782         P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
783         P_SPORT0_DRPRI, P_SPORT0_RSCLK, P_SPORT0_DRSEC, P_SPORT0_DTSEC, 0
784 };
785
786 static struct platform_device bfin_sport0_uart_device = {
787         .name = "bfin-sport-uart",
788         .id = 0,
789         .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
790         .resource = bfin_sport0_uart_resources,
791         .dev = {
792                 .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
793         },
794 };
795 #endif
796 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
797 static struct resource bfin_sport1_uart_resources[] = {
798         {
799                 .start = SPORT1_TCR1,
800                 .end = SPORT1_MRCS3+4,
801                 .flags = IORESOURCE_MEM,
802         },
803         {
804                 .start = IRQ_SPORT1_RX,
805                 .end = IRQ_SPORT1_RX+1,
806                 .flags = IORESOURCE_IRQ,
807         },
808         {
809                 .start = IRQ_SPORT1_ERROR,
810                 .end = IRQ_SPORT1_ERROR,
811                 .flags = IORESOURCE_IRQ,
812         },
813 };
814
815 unsigned short bfin_sport1_peripherals[] = {
816         P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
817         P_SPORT1_DRPRI, P_SPORT1_RSCLK, P_SPORT1_DRSEC, P_SPORT1_DTSEC, 0
818 };
819
820 static struct platform_device bfin_sport1_uart_device = {
821         .name = "bfin-sport-uart",
822         .id = 1,
823         .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
824         .resource = bfin_sport1_uart_resources,
825         .dev = {
826                 .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
827         },
828 };
829 #endif
830 #endif
831
832 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
833 #include <linux/input.h>
834 #include <linux/gpio_keys.h>
835
836 static struct gpio_keys_button bfin_gpio_keys_table[] = {
837         {BTN_0, GPIO_PF14, 1, "gpio-keys: BTN0"},
838 };
839
840 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
841         .buttons        = bfin_gpio_keys_table,
842         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
843 };
844
845 static struct platform_device bfin_device_gpiokeys = {
846         .name      = "gpio-keys",
847         .dev = {
848                 .platform_data = &bfin_gpio_keys_data,
849         },
850 };
851 #endif
852
853 static const unsigned int cclk_vlev_datasheet[] =
854 {
855         VRPAIR(VLEV_100, 400000000),
856         VRPAIR(VLEV_105, 426000000),
857         VRPAIR(VLEV_110, 500000000),
858         VRPAIR(VLEV_115, 533000000),
859         VRPAIR(VLEV_120, 600000000),
860 };
861
862 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
863         .tuple_tab = cclk_vlev_datasheet,
864         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
865         .vr_settling_time = 25 /* us */,
866 };
867
868 static struct platform_device bfin_dpmc = {
869         .name = "bfin dpmc",
870         .dev = {
871                 .platform_data = &bfin_dmpc_vreg_data,
872         },
873 };
874
875 static struct platform_device *cmbf527_devices[] __initdata = {
876
877         &bfin_dpmc,
878
879 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
880         &bf5xx_nand_device,
881 #endif
882
883 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
884         &bfin_pcmcia_cf_device,
885 #endif
886
887 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
888         &rtc_device,
889 #endif
890
891 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
892         &bfin_isp1760_device,
893 #endif
894
895 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
896         &musb_device,
897 #endif
898
899 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
900         &smc91x_device,
901 #endif
902
903 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
904         &dm9000_device,
905 #endif
906
907 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
908         &bfin_mii_bus,
909         &bfin_mac_device,
910 #endif
911
912 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
913         &net2272_bfin_device,
914 #endif
915
916 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
917         &bfin_spi0_device,
918 #endif
919
920 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
921 #ifdef CONFIG_SERIAL_BFIN_UART0
922         &bfin_uart0_device,
923 #endif
924 #ifdef CONFIG_SERIAL_BFIN_UART1
925         &bfin_uart1_device,
926 #endif
927 #endif
928
929 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
930 #ifdef CONFIG_BFIN_SIR0
931         &bfin_sir0_device,
932 #endif
933 #ifdef CONFIG_BFIN_SIR1
934         &bfin_sir1_device,
935 #endif
936 #endif
937
938 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
939         &i2c_bfin_twi_device,
940 #endif
941
942 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
943 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
944         &bfin_sport0_uart_device,
945 #endif
946 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
947         &bfin_sport1_uart_device,
948 #endif
949 #endif
950
951 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
952         &bfin_device_gpiokeys,
953 #endif
954
955 #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
956         &cm_flash_device,
957 #endif
958 };
959
960 static int __init cm_init(void)
961 {
962         printk(KERN_INFO "%s(): registering device resources\n", __func__);
963         i2c_register_board_info(0, bfin_i2c_board_info,
964                                 ARRAY_SIZE(bfin_i2c_board_info));
965         platform_add_devices(cmbf527_devices, ARRAY_SIZE(cmbf527_devices));
966         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
967         return 0;
968 }
969
970 arch_initcall(cm_init);
971
972 static struct platform_device *cmbf527_early_devices[] __initdata = {
973 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
974 #ifdef CONFIG_SERIAL_BFIN_UART0
975         &bfin_uart0_device,
976 #endif
977 #ifdef CONFIG_SERIAL_BFIN_UART1
978         &bfin_uart1_device,
979 #endif
980 #endif
981
982 #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
983 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
984         &bfin_sport0_uart_device,
985 #endif
986 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
987         &bfin_sport1_uart_device,
988 #endif
989 #endif
990 };
991
992 void __init native_machine_early_platform_add_devices(void)
993 {
994         printk(KERN_INFO "register early platform devices\n");
995         early_platform_add_devices(cmbf527_early_devices,
996                 ARRAY_SIZE(cmbf527_early_devices));
997 }
998
999 void native_machine_restart(char *cmd)
1000 {
1001         /* workaround reboot hang when booting from SPI */
1002         if ((bfin_read_SYSCR() & 0x7) == 0x3)
1003                 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
1004 }
1005
1006 void bfin_get_ether_addr(char *addr)
1007 {
1008         random_ether_addr(addr);
1009         printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
1010 }
1011 EXPORT_SYMBOL(bfin_get_ether_addr);