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