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