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