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