Blackfin: drop all simple-gpio 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_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
692 static struct platform_device bfin_fb_device = {
693         .name = "bf537-lq035",
694 };
695 #endif
696
697 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
698 static struct resource bfin_uart_resources[] = {
699 #ifdef CONFIG_SERIAL_BFIN_UART0
700         {
701                 .start = 0xFFC00400,
702                 .end = 0xFFC004FF,
703                 .flags = IORESOURCE_MEM,
704         },
705 #endif
706 #ifdef CONFIG_SERIAL_BFIN_UART1
707         {
708                 .start = 0xFFC02000,
709                 .end = 0xFFC020FF,
710                 .flags = IORESOURCE_MEM,
711         },
712 #endif
713 };
714
715 static struct platform_device bfin_uart_device = {
716         .name = "bfin-uart",
717         .id = 1,
718         .num_resources = ARRAY_SIZE(bfin_uart_resources),
719         .resource = bfin_uart_resources,
720 };
721 #endif
722
723 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
724 #ifdef CONFIG_BFIN_SIR0
725 static struct resource bfin_sir0_resources[] = {
726         {
727                 .start = 0xFFC00400,
728                 .end = 0xFFC004FF,
729                 .flags = IORESOURCE_MEM,
730         },
731         {
732                 .start = IRQ_UART0_RX,
733                 .end = IRQ_UART0_RX+1,
734                 .flags = IORESOURCE_IRQ,
735         },
736         {
737                 .start = CH_UART0_RX,
738                 .end = CH_UART0_RX+1,
739                 .flags = IORESOURCE_DMA,
740         },
741 };
742
743 static struct platform_device bfin_sir0_device = {
744         .name = "bfin_sir",
745         .id = 0,
746         .num_resources = ARRAY_SIZE(bfin_sir0_resources),
747         .resource = bfin_sir0_resources,
748 };
749 #endif
750 #ifdef CONFIG_BFIN_SIR1
751 static struct resource bfin_sir1_resources[] = {
752         {
753                 .start = 0xFFC02000,
754                 .end = 0xFFC020FF,
755                 .flags = IORESOURCE_MEM,
756         },
757         {
758                 .start = IRQ_UART1_RX,
759                 .end = IRQ_UART1_RX+1,
760                 .flags = IORESOURCE_IRQ,
761         },
762         {
763                 .start = CH_UART1_RX,
764                 .end = CH_UART1_RX+1,
765                 .flags = IORESOURCE_DMA,
766         },
767 };
768
769 static struct platform_device bfin_sir1_device = {
770         .name = "bfin_sir",
771         .id = 1,
772         .num_resources = ARRAY_SIZE(bfin_sir1_resources),
773         .resource = bfin_sir1_resources,
774 };
775 #endif
776 #endif
777
778 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
779 static struct resource bfin_twi0_resource[] = {
780         [0] = {
781                 .start = TWI0_REGBASE,
782                 .end   = TWI0_REGBASE,
783                 .flags = IORESOURCE_MEM,
784         },
785         [1] = {
786                 .start = IRQ_TWI,
787                 .end   = IRQ_TWI,
788                 .flags = IORESOURCE_IRQ,
789         },
790 };
791
792 static struct platform_device i2c_bfin_twi_device = {
793         .name = "i2c-bfin-twi",
794         .id = 0,
795         .num_resources = ARRAY_SIZE(bfin_twi0_resource),
796         .resource = bfin_twi0_resource,
797 };
798 #endif
799
800 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
801 #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
802         {
803                 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
804         },
805 #endif
806 #if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
807         {
808                 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
809                 .irq = IRQ_PF8,
810         },
811 #endif
812 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
813         {
814                 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
815         },
816 #endif
817 };
818
819 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
820 static struct platform_device bfin_sport0_uart_device = {
821         .name = "bfin-sport-uart",
822         .id = 0,
823 };
824
825 static struct platform_device bfin_sport1_uart_device = {
826         .name = "bfin-sport-uart",
827         .id = 1,
828 };
829 #endif
830
831 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
832 #include <linux/input.h>
833 #include <linux/gpio_keys.h>
834
835 static struct gpio_keys_button bfin_gpio_keys_table[] = {
836         {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
837         {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
838 };
839
840 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
841         .buttons        = bfin_gpio_keys_table,
842         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
843 };
844
845 static struct platform_device bfin_device_gpiokeys = {
846         .name      = "gpio-keys",
847         .dev = {
848                 .platform_data = &bfin_gpio_keys_data,
849         },
850 };
851 #endif
852
853 #if defined(CONFIG_JOYSTICK_BFIN_ROTARY) || defined(CONFIG_JOYSTICK_BFIN_ROTARY_MODULE)
854 #include <linux/input.h>
855 #include <asm/bfin_rotary.h>
856
857 static struct bfin_rotary_platform_data bfin_rotary_data = {
858         /*.rotary_up_key     = KEY_UP,*/
859         /*.rotary_down_key   = KEY_DOWN,*/
860         .rotary_rel_code   = REL_WHEEL,
861         .rotary_button_key = KEY_ENTER,
862         .debounce          = 10,        /* 0..17 */
863         .mode              = ROT_QUAD_ENC | ROT_DEBE,
864 };
865
866 static struct resource bfin_rotary_resources[] = {
867         {
868                 .start = IRQ_CNT,
869                 .end = IRQ_CNT,
870                 .flags = IORESOURCE_IRQ,
871         },
872 };
873
874 static struct platform_device bfin_rotary_device = {
875         .name           = "bfin-rotary",
876         .id             = -1,
877         .num_resources  = ARRAY_SIZE(bfin_rotary_resources),
878         .resource       = bfin_rotary_resources,
879         .dev            = {
880                 .platform_data = &bfin_rotary_data,
881         },
882 };
883 #endif
884
885 static const unsigned int cclk_vlev_datasheet[] =
886 {
887         VRPAIR(VLEV_100, 400000000),
888         VRPAIR(VLEV_105, 426000000),
889         VRPAIR(VLEV_110, 500000000),
890         VRPAIR(VLEV_115, 533000000),
891         VRPAIR(VLEV_120, 600000000),
892 };
893
894 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
895         .tuple_tab = cclk_vlev_datasheet,
896         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
897         .vr_settling_time = 25 /* us */,
898 };
899
900 static struct platform_device bfin_dpmc = {
901         .name = "bfin dpmc",
902         .dev = {
903                 .platform_data = &bfin_dmpc_vreg_data,
904         },
905 };
906
907 static struct platform_device *stamp_devices[] __initdata = {
908
909         &bfin_dpmc,
910
911 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
912         &bf5xx_nand_device,
913 #endif
914
915 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
916         &bfin_pcmcia_cf_device,
917 #endif
918
919 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
920         &rtc_device,
921 #endif
922
923 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
924         &sl811_hcd_device,
925 #endif
926
927 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
928         &isp1362_hcd_device,
929 #endif
930
931 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
932         &bfin_isp1760_device,
933 #endif
934
935 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
936         &musb_device,
937 #endif
938
939 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
940         &smc91x_device,
941 #endif
942
943 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
944         &dm9000_device,
945 #endif
946
947 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
948         &bfin_mii_bus,
949         &bfin_mac_device,
950 #endif
951
952 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
953         &net2272_bfin_device,
954 #endif
955
956 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
957         &bfin_spi0_device,
958 #endif
959
960 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
961         &bfin_fb_device,
962 #endif
963
964 #if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
965         &bf52x_t350mcqb_device,
966 #endif
967
968 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
969         &bfin_uart_device,
970 #endif
971
972 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
973 #ifdef CONFIG_BFIN_SIR0
974         &bfin_sir0_device,
975 #endif
976 #ifdef CONFIG_BFIN_SIR1
977         &bfin_sir1_device,
978 #endif
979 #endif
980
981 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
982         &i2c_bfin_twi_device,
983 #endif
984
985 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
986         &bfin_sport0_uart_device,
987         &bfin_sport1_uart_device,
988 #endif
989
990 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
991         &bfin_device_gpiokeys,
992 #endif
993
994 #if defined(CONFIG_JOYSTICK_BFIN_ROTARY) || defined(CONFIG_JOYSTICK_BFIN_ROTARY_MODULE)
995         &bfin_rotary_device,
996 #endif
997
998 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
999         &ezkit_flash_device,
1000 #endif
1001 };
1002
1003 static int __init ezkit_init(void)
1004 {
1005         printk(KERN_INFO "%s(): registering device resources\n", __func__);
1006         i2c_register_board_info(0, bfin_i2c_board_info,
1007                                 ARRAY_SIZE(bfin_i2c_board_info));
1008         platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
1009         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
1010         return 0;
1011 }
1012
1013 arch_initcall(ezkit_init);
1014
1015 void native_machine_restart(char *cmd)
1016 {
1017         /* workaround reboot hang when booting from SPI */
1018         if ((bfin_read_SYSCR() & 0x7) == 0x3)
1019                 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
1020 }
1021
1022 void bfin_get_ether_addr(char *addr)
1023 {
1024         /* the MAC is stored in OTP memory page 0xDF */
1025         u32 ret;
1026         u64 otp_mac;
1027         u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
1028
1029         ret = otp_read(0xDF, 0x00, &otp_mac);
1030         if (!(ret & 0x1)) {
1031                 char *otp_mac_p = (char *)&otp_mac;
1032                 for (ret = 0; ret < 6; ++ret)
1033                         addr[ret] = otp_mac_p[5 - ret];
1034         }
1035 }
1036 EXPORT_SYMBOL(bfin_get_ether_addr);