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