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