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