[Blackfin] arch: Encourage users to use the spidev character driver: Provide platform...
[linux-2.6.git] / arch / blackfin / mach-bf527 / boards / ezkit.c
1 /*
2  * File:         arch/blackfin/mach-bf527/boards/ezkit.c
3  * Based on:     arch/blackfin/mach-bf537/boards/stamp.c
4  * Author:       Aidan Williams <aidan@nicta.com.au>
5  *
6  * Created:
7  * Description:
8  *
9  * Modified:
10  *               Copyright 2005 National ICT Australia (NICTA)
11  *               Copyright 2004-2008 Analog Devices Inc.
12  *
13  * Bugs:         Enter bugs at http://blackfin.uclinux.org/
14  *
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 2 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, see the file COPYING, or write
27  * to the Free Software Foundation, Inc.,
28  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
29  */
30
31 #include <linux/device.h>
32 #include <linux/platform_device.h>
33 #include <linux/mtd/mtd.h>
34 #include <linux/mtd/partitions.h>
35 #include <linux/spi/spi.h>
36 #include <linux/spi/flash.h>
37 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
38 #include <linux/usb/isp1362.h>
39 #endif
40 #include <linux/ata_platform.h>
41 #include <linux/irq.h>
42 #include <linux/interrupt.h>
43 #include <linux/usb/sl811.h>
44 #include <linux/usb/musb.h>
45 #include <asm/cplb.h>
46 #include <asm/dma.h>
47 #include <asm/bfin5xx_spi.h>
48 #include <asm/reboot.h>
49 #include <asm/nand.h>
50 #include <asm/portmux.h>
51 #include <linux/spi/ad7877.h>
52
53 /*
54  * Name the Board for the /proc/cpuinfo
55  */
56 const char bfin_board_name[] = "ADDS-BF527-EZKIT";
57
58 /*
59  *  Driver needs to know address, irq and flag pin.
60  */
61
62 #define ISP1761_BASE       0x203C0000
63 #define ISP1761_IRQ        IRQ_PF7
64
65 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
66 static struct resource bfin_isp1761_resources[] = {
67         [0] = {
68                 .name   = "isp1761-regs",
69                 .start  = ISP1761_BASE + 0x00000000,
70                 .end    = ISP1761_BASE + 0x000fffff,
71                 .flags  = IORESOURCE_MEM,
72         },
73         [1] = {
74                 .start  = ISP1761_IRQ,
75                 .end    = ISP1761_IRQ,
76                 .flags  = IORESOURCE_IRQ,
77         },
78 };
79
80 static struct platform_device bfin_isp1761_device = {
81         .name           = "isp1761",
82         .id             = 0,
83         .num_resources  = ARRAY_SIZE(bfin_isp1761_resources),
84         .resource       = bfin_isp1761_resources,
85 };
86
87 static struct platform_device *bfin_isp1761_devices[] = {
88         &bfin_isp1761_device,
89 };
90
91 int __init bfin_isp1761_init(void)
92 {
93         unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
94
95         printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
96         set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING);
97
98         return platform_add_devices(bfin_isp1761_devices, num_devices);
99 }
100
101 void __exit bfin_isp1761_exit(void)
102 {
103         platform_device_unregister(&bfin_isp1761_device);
104 }
105
106 arch_initcall(bfin_isp1761_init);
107 #endif
108
109 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
110 static struct resource musb_resources[] = {
111         [0] = {
112                 .start  = 0xffc03800,
113                 .end    = 0xffc03cff,
114                 .flags  = IORESOURCE_MEM,
115         },
116         [1] = { /* general IRQ */
117                 .start  = IRQ_USB_INT0,
118                 .end    = IRQ_USB_INT0,
119                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
120         },
121         [2] = { /* DMA IRQ */
122                 .start  = IRQ_USB_DMA,
123                 .end    = IRQ_USB_DMA,
124                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
125         },
126 };
127
128 static struct musb_hdrc_platform_data musb_plat = {
129 #if defined(CONFIG_USB_MUSB_OTG)
130         .mode           = MUSB_OTG,
131 #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
132         .mode           = MUSB_HOST,
133 #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
134         .mode           = MUSB_PERIPHERAL,
135 #endif
136         .multipoint     = 0,
137 };
138
139 static u64 musb_dmamask = ~(u32)0;
140
141 static struct platform_device musb_device = {
142         .name           = "musb_hdrc",
143         .id             = 0,
144         .dev = {
145                 .dma_mask               = &musb_dmamask,
146                 .coherent_dma_mask      = 0xffffffff,
147                 .platform_data          = &musb_plat,
148         },
149         .num_resources  = ARRAY_SIZE(musb_resources),
150         .resource       = musb_resources,
151 };
152 #endif
153
154 #if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
155
156 static struct resource bf52x_t350mcqb_resources[] = {
157         {
158                 .start = IRQ_PPI_ERROR,
159                 .end = IRQ_PPI_ERROR,
160                 .flags = IORESOURCE_IRQ,
161         },
162 };
163
164 static struct platform_device bf52x_t350mcqb_device = {
165         .name           = "bfin-t350mcqb",
166         .id             = -1,
167         .num_resources  = ARRAY_SIZE(bf52x_t350mcqb_resources),
168         .resource       = bf52x_t350mcqb_resources,
169 };
170 #endif
171
172 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
173 static struct mtd_partition partition_info[] = {
174         {
175                 .name = "Linux Kernel",
176                 .offset = 0,
177                 .size = 4 * SIZE_1M,
178         },
179         {
180                 .name = "File System",
181                 .offset = 4 * SIZE_1M,
182                 .size = (256 - 4) * SIZE_1M,
183         },
184 };
185
186 static struct bf5xx_nand_platform bf5xx_nand_platform = {
187         .page_size = NFC_PG_SIZE_256,
188         .data_width = NFC_NWIDTH_8,
189         .partitions = partition_info,
190         .nr_partitions = ARRAY_SIZE(partition_info),
191         .rd_dly = 3,
192         .wr_dly = 3,
193 };
194
195 static struct resource bf5xx_nand_resources[] = {
196         {
197                 .start = NFC_CTL,
198                 .end = NFC_DATA_RD + 2,
199                 .flags = IORESOURCE_MEM,
200         },
201         {
202                 .start = CH_NFC,
203                 .end = CH_NFC,
204                 .flags = IORESOURCE_IRQ,
205         },
206 };
207
208 static struct platform_device bf5xx_nand_device = {
209         .name = "bf5xx-nand",
210         .id = 0,
211         .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
212         .resource = bf5xx_nand_resources,
213         .dev = {
214                 .platform_data = &bf5xx_nand_platform,
215         },
216 };
217 #endif
218
219 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
220 static struct resource bfin_pcmcia_cf_resources[] = {
221         {
222                 .start = 0x20310000, /* IO PORT */
223                 .end = 0x20312000,
224                 .flags = IORESOURCE_MEM,
225         }, {
226                 .start = 0x20311000, /* Attribute Memory */
227                 .end = 0x20311FFF,
228                 .flags = IORESOURCE_MEM,
229         }, {
230                 .start = IRQ_PF4,
231                 .end = IRQ_PF4,
232                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
233         }, {
234                 .start = 6, /* Card Detect PF6 */
235                 .end = 6,
236                 .flags = IORESOURCE_IRQ,
237         },
238 };
239
240 static struct platform_device bfin_pcmcia_cf_device = {
241         .name = "bfin_cf_pcmcia",
242         .id = -1,
243         .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
244         .resource = bfin_pcmcia_cf_resources,
245 };
246 #endif
247
248 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
249 static struct platform_device rtc_device = {
250         .name = "rtc-bfin",
251         .id   = -1,
252 };
253 #endif
254
255 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
256 static struct resource smc91x_resources[] = {
257         {
258                 .name = "smc91x-regs",
259                 .start = 0x20300300,
260                 .end = 0x20300300 + 16,
261                 .flags = IORESOURCE_MEM,
262         }, {
263
264                 .start = IRQ_PF7,
265                 .end = IRQ_PF7,
266                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
267         },
268 };
269 static struct platform_device smc91x_device = {
270         .name = "smc91x",
271         .id = 0,
272         .num_resources = ARRAY_SIZE(smc91x_resources),
273         .resource = smc91x_resources,
274 };
275 #endif
276
277 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
278 static struct resource dm9000_resources[] = {
279         [0] = {
280                 .start  = 0x203FB800,
281                 .end    = 0x203FB800 + 8,
282                 .flags  = IORESOURCE_MEM,
283         },
284         [1] = {
285                 .start  = IRQ_PF9,
286                 .end    = IRQ_PF9,
287                 .flags  = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
288         },
289 };
290
291 static struct platform_device dm9000_device = {
292         .name           = "dm9000",
293         .id             = -1,
294         .num_resources  = ARRAY_SIZE(dm9000_resources),
295         .resource       = dm9000_resources,
296 };
297 #endif
298
299 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
300 static struct resource sl811_hcd_resources[] = {
301         {
302                 .start = 0x20340000,
303                 .end = 0x20340000,
304                 .flags = IORESOURCE_MEM,
305         }, {
306                 .start = 0x20340004,
307                 .end = 0x20340004,
308                 .flags = IORESOURCE_MEM,
309         }, {
310                 .start = CONFIG_USB_SL811_BFIN_IRQ,
311                 .end = CONFIG_USB_SL811_BFIN_IRQ,
312                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
313         },
314 };
315
316 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
317 void sl811_port_power(struct device *dev, int is_on)
318 {
319         gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
320         gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
321 }
322 #endif
323
324 static struct sl811_platform_data sl811_priv = {
325         .potpg = 10,
326         .power = 250,       /* == 500mA */
327 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
328         .port_power = &sl811_port_power,
329 #endif
330 };
331
332 static struct platform_device sl811_hcd_device = {
333         .name = "sl811-hcd",
334         .id = 0,
335         .dev = {
336                 .platform_data = &sl811_priv,
337         },
338         .num_resources = ARRAY_SIZE(sl811_hcd_resources),
339         .resource = sl811_hcd_resources,
340 };
341 #endif
342
343 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
344 static struct resource isp1362_hcd_resources[] = {
345         {
346                 .start = 0x20360000,
347                 .end = 0x20360000,
348                 .flags = IORESOURCE_MEM,
349         }, {
350                 .start = 0x20360004,
351                 .end = 0x20360004,
352                 .flags = IORESOURCE_MEM,
353         }, {
354                 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
355                 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
356                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
357         },
358 };
359
360 static struct isp1362_platform_data isp1362_priv = {
361         .sel15Kres = 1,
362         .clknotstop = 0,
363         .oc_enable = 0,
364         .int_act_high = 0,
365         .int_edge_triggered = 0,
366         .remote_wakeup_connected = 0,
367         .no_power_switching = 1,
368         .power_switching_mode = 0,
369 };
370
371 static struct platform_device isp1362_hcd_device = {
372         .name = "isp1362-hcd",
373         .id = 0,
374         .dev = {
375                 .platform_data = &isp1362_priv,
376         },
377         .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
378         .resource = isp1362_hcd_resources,
379 };
380 #endif
381
382 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
383 static struct platform_device bfin_mac_device = {
384         .name = "bfin_mac",
385 };
386 #endif
387
388 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
389 static struct resource net2272_bfin_resources[] = {
390         {
391                 .start = 0x20300000,
392                 .end = 0x20300000 + 0x100,
393                 .flags = IORESOURCE_MEM,
394         }, {
395                 .start = IRQ_PF7,
396                 .end = IRQ_PF7,
397                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
398         },
399 };
400
401 static struct platform_device net2272_bfin_device = {
402         .name = "net2272",
403         .id = -1,
404         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
405         .resource = net2272_bfin_resources,
406 };
407 #endif
408
409 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
410 /* all SPI peripherals info goes here */
411
412 #if defined(CONFIG_MTD_M25P80) \
413         || defined(CONFIG_MTD_M25P80_MODULE)
414 static struct mtd_partition bfin_spi_flash_partitions[] = {
415         {
416                 .name = "bootloader",
417                 .size = 0x00020000,
418                 .offset = 0,
419                 .mask_flags = MTD_CAP_ROM
420         }, {
421                 .name = "kernel",
422                 .size = 0xe0000,
423                 .offset = 0x20000
424         }, {
425                 .name = "file system",
426                 .size = 0x700000,
427                 .offset = 0x00100000,
428         }
429 };
430
431 static struct flash_platform_data bfin_spi_flash_data = {
432         .name = "m25p80",
433         .parts = bfin_spi_flash_partitions,
434         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
435         .type = "m25p64",
436 };
437
438 /* SPI flash chip (m25p64) */
439 static struct bfin5xx_spi_chip spi_flash_chip_info = {
440         .enable_dma = 0,         /* use dma transfer with this chip*/
441         .bits_per_word = 8,
442 };
443 #endif
444
445 #if defined(CONFIG_SPI_ADC_BF533) \
446         || defined(CONFIG_SPI_ADC_BF533_MODULE)
447 /* SPI ADC chip */
448 static struct bfin5xx_spi_chip spi_adc_chip_info = {
449         .enable_dma = 1,         /* use dma transfer with this chip*/
450         .bits_per_word = 16,
451 };
452 #endif
453
454 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
455         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
456 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
457         .enable_dma = 0,
458         .bits_per_word = 16,
459 };
460 #endif
461
462 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
463 static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
464         .enable_dma = 0,
465         .bits_per_word = 16,
466 };
467 #endif
468
469 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
470 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
471         .enable_dma = 1,
472         .bits_per_word = 8,
473 };
474 #endif
475
476 #if defined(CONFIG_PBX)
477 static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
478         .ctl_reg        = 0x4, /* send zero */
479         .enable_dma     = 0,
480         .bits_per_word  = 8,
481         .cs_change_per_word = 1,
482 };
483 #endif
484
485 #if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
486 static struct bfin5xx_spi_chip ad5304_chip_info = {
487         .enable_dma = 0,
488         .bits_per_word = 16,
489 };
490 #endif
491
492 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
493 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
494         .enable_dma = 0,
495         .bits_per_word = 16,
496 };
497
498 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
499         .model                  = 7877,
500         .vref_delay_usecs       = 50,   /* internal, no capacitor */
501         .x_plate_ohms           = 419,
502         .y_plate_ohms           = 486,
503         .pressure_max           = 1000,
504         .pressure_min           = 0,
505         .stopacq_polarity       = 1,
506         .first_conversion_delay = 3,
507         .acquisition_time       = 1,
508         .averaging              = 1,
509         .pen_down_acc_interval  = 1,
510 };
511 #endif
512
513 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
514          && defined(CONFIG_SND_SOC_WM8731_SPI)
515 static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
516         .enable_dma = 0,
517         .bits_per_word = 16,
518 };
519 #endif
520
521 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
522 static struct bfin5xx_spi_chip spidev_chip_info = {
523         .enable_dma = 0,
524         .bits_per_word = 8,
525 };
526 #endif
527
528 static struct spi_board_info bfin_spi_board_info[] __initdata = {
529 #if defined(CONFIG_MTD_M25P80) \
530         || defined(CONFIG_MTD_M25P80_MODULE)
531         {
532                 /* the modalias must be the same as spi device driver name */
533                 .modalias = "m25p80", /* Name of spi_driver for this device */
534                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
535                 .bus_num = 0, /* Framework bus number */
536                 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
537                 .platform_data = &bfin_spi_flash_data,
538                 .controller_data = &spi_flash_chip_info,
539                 .mode = SPI_MODE_3,
540         },
541 #endif
542
543 #if defined(CONFIG_SPI_ADC_BF533) \
544         || defined(CONFIG_SPI_ADC_BF533_MODULE)
545         {
546                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
547                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
548                 .bus_num = 0, /* Framework bus number */
549                 .chip_select = 1, /* Framework chip select. */
550                 .platform_data = NULL, /* No spi_driver specific config */
551                 .controller_data = &spi_adc_chip_info,
552         },
553 #endif
554
555 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
556         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
557         {
558                 .modalias = "ad1836-spi",
559                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
560                 .bus_num = 0,
561                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
562                 .controller_data = &ad1836_spi_chip_info,
563         },
564 #endif
565 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
566         {
567                 .modalias = "ad9960-spi",
568                 .max_speed_hz = 10000000,     /* max spi clock (SCK) speed in HZ */
569                 .bus_num = 0,
570                 .chip_select = 1,
571                 .controller_data = &ad9960_spi_chip_info,
572         },
573 #endif
574 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
575         {
576                 .modalias = "spi_mmc_dummy",
577                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
578                 .bus_num = 0,
579                 .chip_select = 0,
580                 .platform_data = NULL,
581                 .controller_data = &spi_mmc_chip_info,
582                 .mode = SPI_MODE_3,
583         },
584         {
585                 .modalias = "spi_mmc",
586                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
587                 .bus_num = 0,
588                 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
589                 .platform_data = NULL,
590                 .controller_data = &spi_mmc_chip_info,
591                 .mode = SPI_MODE_3,
592         },
593 #endif
594 #if defined(CONFIG_PBX)
595         {
596                 .modalias = "fxs-spi",
597                 .max_speed_hz = 12500000,     /* max spi clock (SCK) speed in HZ */
598                 .bus_num = 0,
599                 .chip_select = 8 - CONFIG_J11_JUMPER,
600                 .controller_data = &spi_si3xxx_chip_info,
601                 .mode = SPI_MODE_3,
602         },
603         {
604                 .modalias = "fxo-spi",
605                 .max_speed_hz = 12500000,     /* max spi clock (SCK) speed in HZ */
606                 .bus_num = 0,
607                 .chip_select = 8 - CONFIG_J19_JUMPER,
608                 .controller_data = &spi_si3xxx_chip_info,
609                 .mode = SPI_MODE_3,
610         },
611 #endif
612 #if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
613         {
614                 .modalias = "ad5304_spi",
615                 .max_speed_hz = 1250000,     /* max spi clock (SCK) speed in HZ */
616                 .bus_num = 0,
617                 .chip_select = 2,
618                 .platform_data = NULL,
619                 .controller_data = &ad5304_chip_info,
620                 .mode = SPI_MODE_2,
621         },
622 #endif
623 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
624         {
625                 .modalias               = "ad7877",
626                 .platform_data          = &bfin_ad7877_ts_info,
627                 .irq                    = IRQ_PF6,
628                 .max_speed_hz   = 12500000,     /* max spi clock (SCK) speed in HZ */
629                 .bus_num        = 0,
630                 .chip_select  = 1,
631                 .controller_data = &spi_ad7877_chip_info,
632         },
633 #endif
634 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
635          && defined(CONFIG_SND_SOC_WM8731_SPI)
636         {
637                 .modalias       = "wm8731",
638                 .max_speed_hz   = 3125000,     /* max spi clock (SCK) speed in HZ */
639                 .bus_num        = 0,
640                 .chip_select    = 5,
641                 .controller_data = &spi_wm8731_chip_info,
642                 .mode = SPI_MODE_0,
643         },
644 #endif
645 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
646         {
647                 .modalias = "spidev",
648                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
649                 .bus_num = 0,
650                 .chip_select = 1,
651                 .controller_data = &spidev_chip_info,
652         },
653 #endif
654 };
655
656 /* SPI controller data */
657 static struct bfin5xx_spi_master bfin_spi0_info = {
658         .num_chipselect = 8,
659         .enable_dma = 1,  /* master has the ability to do dma transfer */
660         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
661 };
662
663 /* SPI (0) */
664 static struct resource bfin_spi0_resource[] = {
665         [0] = {
666                 .start = SPI0_REGBASE,
667                 .end   = SPI0_REGBASE + 0xFF,
668                 .flags = IORESOURCE_MEM,
669                 },
670         [1] = {
671                 .start = CH_SPI,
672                 .end   = CH_SPI,
673                 .flags = IORESOURCE_IRQ,
674         },
675 };
676
677 static struct platform_device bfin_spi0_device = {
678         .name = "bfin-spi",
679         .id = 0, /* Bus number */
680         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
681         .resource = bfin_spi0_resource,
682         .dev = {
683                 .platform_data = &bfin_spi0_info, /* Passed to driver */
684         },
685 };
686 #endif  /* spi master and devices */
687
688 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
689 static struct platform_device bfin_fb_device = {
690         .name = "bf537-lq035",
691 };
692 #endif
693
694 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
695 static struct platform_device bfin_fb_adv7393_device = {
696         .name = "bfin-adv7393",
697 };
698 #endif
699
700 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
701 static struct resource bfin_uart_resources[] = {
702 #ifdef CONFIG_SERIAL_BFIN_UART0
703         {
704                 .start = 0xFFC00400,
705                 .end = 0xFFC004FF,
706                 .flags = IORESOURCE_MEM,
707         },
708 #endif
709 #ifdef CONFIG_SERIAL_BFIN_UART1
710         {
711                 .start = 0xFFC02000,
712                 .end = 0xFFC020FF,
713                 .flags = IORESOURCE_MEM,
714         },
715 #endif
716 };
717
718 static struct platform_device bfin_uart_device = {
719         .name = "bfin-uart",
720         .id = 1,
721         .num_resources = ARRAY_SIZE(bfin_uart_resources),
722         .resource = bfin_uart_resources,
723 };
724 #endif
725
726 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
727 static struct resource bfin_twi0_resource[] = {
728         [0] = {
729                 .start = TWI0_REGBASE,
730                 .end   = TWI0_REGBASE,
731                 .flags = IORESOURCE_MEM,
732         },
733         [1] = {
734                 .start = IRQ_TWI,
735                 .end   = IRQ_TWI,
736                 .flags = IORESOURCE_IRQ,
737         },
738 };
739
740 static struct platform_device i2c_bfin_twi_device = {
741         .name = "i2c-bfin-twi",
742         .id = 0,
743         .num_resources = ARRAY_SIZE(bfin_twi0_resource),
744         .resource = bfin_twi0_resource,
745 };
746 #endif
747
748 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
749 static struct platform_device bfin_sport0_uart_device = {
750         .name = "bfin-sport-uart",
751         .id = 0,
752 };
753
754 static struct platform_device bfin_sport1_uart_device = {
755         .name = "bfin-sport-uart",
756         .id = 1,
757 };
758 #endif
759
760 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
761 #define PATA_INT        55
762
763 static struct pata_platform_info bfin_pata_platform_data = {
764         .ioport_shift = 1,
765         .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
766 };
767
768 static struct resource bfin_pata_resources[] = {
769         {
770                 .start = 0x20314020,
771                 .end = 0x2031403F,
772                 .flags = IORESOURCE_MEM,
773         },
774         {
775                 .start = 0x2031401C,
776                 .end = 0x2031401F,
777                 .flags = IORESOURCE_MEM,
778         },
779         {
780                 .start = PATA_INT,
781                 .end = PATA_INT,
782                 .flags = IORESOURCE_IRQ,
783         },
784 };
785
786 static struct platform_device bfin_pata_device = {
787         .name = "pata_platform",
788         .id = -1,
789         .num_resources = ARRAY_SIZE(bfin_pata_resources),
790         .resource = bfin_pata_resources,
791         .dev = {
792                 .platform_data = &bfin_pata_platform_data,
793         }
794 };
795 #endif
796
797 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
798 #include <linux/input.h>
799 #include <linux/gpio_keys.h>
800
801 static struct gpio_keys_button bfin_gpio_keys_table[] = {
802         {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
803         {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
804 };
805
806 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
807         .buttons        = bfin_gpio_keys_table,
808         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
809 };
810
811 static struct platform_device bfin_device_gpiokeys = {
812         .name      = "gpio-keys",
813         .dev = {
814                 .platform_data = &bfin_gpio_keys_data,
815         },
816 };
817 #endif
818
819 static struct platform_device *stamp_devices[] __initdata = {
820 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
821         &bf5xx_nand_device,
822 #endif
823
824 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
825         &bfin_pcmcia_cf_device,
826 #endif
827
828 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
829         &rtc_device,
830 #endif
831
832 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
833         &sl811_hcd_device,
834 #endif
835
836 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
837         &isp1362_hcd_device,
838 #endif
839
840 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
841         &musb_device,
842 #endif
843
844 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
845         &smc91x_device,
846 #endif
847
848 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
849         &dm9000_device,
850 #endif
851
852 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
853         &bfin_mac_device,
854 #endif
855
856 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
857         &net2272_bfin_device,
858 #endif
859
860 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
861         &bfin_spi0_device,
862 #endif
863
864 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
865         &bfin_fb_device,
866 #endif
867
868 #if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
869         &bf52x_t350mcqb_device,
870 #endif
871
872 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
873         &bfin_fb_adv7393_device,
874 #endif
875
876 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
877         &bfin_uart_device,
878 #endif
879
880 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
881         &i2c_bfin_twi_device,
882 #endif
883
884 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
885         &bfin_sport0_uart_device,
886         &bfin_sport1_uart_device,
887 #endif
888
889 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
890         &bfin_pata_device,
891 #endif
892
893 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
894         &bfin_device_gpiokeys,
895 #endif
896 };
897
898 static int __init stamp_init(void)
899 {
900         printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
901         platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
902 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
903         spi_register_board_info(bfin_spi_board_info,
904                                 ARRAY_SIZE(bfin_spi_board_info));
905 #endif
906
907 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
908         irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
909 #endif
910         return 0;
911 }
912
913 arch_initcall(stamp_init);
914
915 void native_machine_restart(char *cmd)
916 {
917         /* workaround reboot hang when booting from SPI */
918         if ((bfin_read_SYSCR() & 0x7) == 0x3)
919                 bfin_gpio_reset_spi0_ssel1();
920 }
921
922 /*
923  * Currently the MAC address is saved in Flash by U-Boot
924  */
925 #define FLASH_MAC       0x203f0000
926 void bfin_get_ether_addr(char *addr)
927 {
928         *(u32 *)(&(addr[0])) = bfin_read32(FLASH_MAC);
929         *(u16 *)(&(addr[4])) = bfin_read16(FLASH_MAC + 4);
930 }
931 EXPORT_SYMBOL(bfin_get_ether_addr);