Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[pandora-kernel.git] / arch / blackfin / mach-bf527 / boards / ezkit.c
1 /*
2  * File:         arch/blackfin/mach-bf527/boards/ezkit.c
3  * Based on:     arch/blackfin/mach-bf537/boards/stamp.c
4  * Author:       Aidan Williams <aidan@nicta.com.au>
5  *
6  * Created:
7  * Description:
8  *
9  * Modified:
10  *               Copyright 2005 National ICT Australia (NICTA)
11  *               Copyright 2004-2008 Analog Devices Inc.
12  *
13  * Bugs:         Enter bugs at http://blackfin.uclinux.org/
14  *
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 2 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, see the file COPYING, or write
27  * to the Free Software Foundation, Inc.,
28  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
29  */
30
31 #include <linux/device.h>
32 #include <linux/platform_device.h>
33 #include <linux/mtd/mtd.h>
34 #include <linux/mtd/partitions.h>
35 #include <linux/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/ata_platform.h>
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[] = "ADDS-BF527-EZKIT";
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_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
160
161 static struct resource bf52x_t350mcqb_resources[] = {
162         {
163                 .start = IRQ_PPI_ERROR,
164                 .end = IRQ_PPI_ERROR,
165                 .flags = IORESOURCE_IRQ,
166         },
167 };
168
169 static struct platform_device bf52x_t350mcqb_device = {
170         .name           = "bfin-t350mcqb",
171         .id             = -1,
172         .num_resources  = ARRAY_SIZE(bf52x_t350mcqb_resources),
173         .resource       = bf52x_t350mcqb_resources,
174 };
175 #endif
176
177 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
178 static struct mtd_partition ezkit_partitions[] = {
179         {
180                 .name       = "Bootloader",
181                 .size       = 0x40000,
182                 .offset     = 0,
183         }, {
184                 .name       = "Kernel",
185                 .size       = 0x1C0000,
186                 .offset     = MTDPART_OFS_APPEND,
187         }, {
188                 .name       = "RootFS",
189                 .size       = MTDPART_SIZ_FULL,
190                 .offset     = MTDPART_OFS_APPEND,
191         }
192 };
193
194 static struct physmap_flash_data ezkit_flash_data = {
195         .width      = 2,
196         .parts      = ezkit_partitions,
197         .nr_parts   = ARRAY_SIZE(ezkit_partitions),
198 };
199
200 static struct resource ezkit_flash_resource = {
201         .start = 0x20000000,
202         .end   = 0x203fffff,
203         .flags = IORESOURCE_MEM,
204 };
205
206 static struct platform_device ezkit_flash_device = {
207         .name          = "physmap-flash",
208         .id            = 0,
209         .dev = {
210                 .platform_data = &ezkit_flash_data,
211         },
212         .num_resources = 1,
213         .resource      = &ezkit_flash_resource,
214 };
215 #endif
216
217 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
218 static struct mtd_partition partition_info[] = {
219         {
220                 .name = "Linux Kernel",
221                 .offset = 0,
222                 .size = 4 * SIZE_1M,
223         },
224         {
225                 .name = "File System",
226                 .offset = MTDPART_OFS_APPEND,
227                 .size = MTDPART_SIZ_FULL,
228         },
229 };
230
231 static struct bf5xx_nand_platform bf5xx_nand_platform = {
232         .page_size = NFC_PG_SIZE_256,
233         .data_width = NFC_NWIDTH_8,
234         .partitions = partition_info,
235         .nr_partitions = ARRAY_SIZE(partition_info),
236         .rd_dly = 3,
237         .wr_dly = 3,
238 };
239
240 static struct resource bf5xx_nand_resources[] = {
241         {
242                 .start = NFC_CTL,
243                 .end = NFC_DATA_RD + 2,
244                 .flags = IORESOURCE_MEM,
245         },
246         {
247                 .start = CH_NFC,
248                 .end = CH_NFC,
249                 .flags = IORESOURCE_IRQ,
250         },
251 };
252
253 static struct platform_device bf5xx_nand_device = {
254         .name = "bf5xx-nand",
255         .id = 0,
256         .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
257         .resource = bf5xx_nand_resources,
258         .dev = {
259                 .platform_data = &bf5xx_nand_platform,
260         },
261 };
262 #endif
263
264 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
265 static struct resource bfin_pcmcia_cf_resources[] = {
266         {
267                 .start = 0x20310000, /* IO PORT */
268                 .end = 0x20312000,
269                 .flags = IORESOURCE_MEM,
270         }, {
271                 .start = 0x20311000, /* Attribute Memory */
272                 .end = 0x20311FFF,
273                 .flags = IORESOURCE_MEM,
274         }, {
275                 .start = IRQ_PF4,
276                 .end = IRQ_PF4,
277                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
278         }, {
279                 .start = 6, /* Card Detect PF6 */
280                 .end = 6,
281                 .flags = IORESOURCE_IRQ,
282         },
283 };
284
285 static struct platform_device bfin_pcmcia_cf_device = {
286         .name = "bfin_cf_pcmcia",
287         .id = -1,
288         .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
289         .resource = bfin_pcmcia_cf_resources,
290 };
291 #endif
292
293 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
294 static struct platform_device rtc_device = {
295         .name = "rtc-bfin",
296         .id   = -1,
297 };
298 #endif
299
300 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
301 static struct resource smc91x_resources[] = {
302         {
303                 .name = "smc91x-regs",
304                 .start = 0x20300300,
305                 .end = 0x20300300 + 16,
306                 .flags = IORESOURCE_MEM,
307         }, {
308
309                 .start = IRQ_PF7,
310                 .end = IRQ_PF7,
311                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
312         },
313 };
314 static struct platform_device smc91x_device = {
315         .name = "smc91x",
316         .id = 0,
317         .num_resources = ARRAY_SIZE(smc91x_resources),
318         .resource = smc91x_resources,
319 };
320 #endif
321
322 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
323 static struct resource dm9000_resources[] = {
324         [0] = {
325                 .start  = 0x203FB800,
326                 .end    = 0x203FB800 + 1,
327                 .flags  = IORESOURCE_MEM,
328         },
329         [1] = {
330                 .start  = 0x203FB800 + 4,
331                 .end    = 0x203FB800 + 5,
332                 .flags  = IORESOURCE_MEM,
333         },
334         [2] = {
335                 .start  = IRQ_PF9,
336                 .end    = IRQ_PF9,
337                 .flags  = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
338         },
339 };
340
341 static struct platform_device dm9000_device = {
342         .name           = "dm9000",
343         .id             = -1,
344         .num_resources  = ARRAY_SIZE(dm9000_resources),
345         .resource       = dm9000_resources,
346 };
347 #endif
348
349 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
350 static struct resource sl811_hcd_resources[] = {
351         {
352                 .start = 0x20340000,
353                 .end = 0x20340000,
354                 .flags = IORESOURCE_MEM,
355         }, {
356                 .start = 0x20340004,
357                 .end = 0x20340004,
358                 .flags = IORESOURCE_MEM,
359         }, {
360                 .start = CONFIG_USB_SL811_BFIN_IRQ,
361                 .end = CONFIG_USB_SL811_BFIN_IRQ,
362                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
363         },
364 };
365
366 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
367 void sl811_port_power(struct device *dev, int is_on)
368 {
369         gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
370         gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
371 }
372 #endif
373
374 static struct sl811_platform_data sl811_priv = {
375         .potpg = 10,
376         .power = 250,       /* == 500mA */
377 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
378         .port_power = &sl811_port_power,
379 #endif
380 };
381
382 static struct platform_device sl811_hcd_device = {
383         .name = "sl811-hcd",
384         .id = 0,
385         .dev = {
386                 .platform_data = &sl811_priv,
387         },
388         .num_resources = ARRAY_SIZE(sl811_hcd_resources),
389         .resource = sl811_hcd_resources,
390 };
391 #endif
392
393 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
394 static struct resource isp1362_hcd_resources[] = {
395         {
396                 .start = 0x20360000,
397                 .end = 0x20360000,
398                 .flags = IORESOURCE_MEM,
399         }, {
400                 .start = 0x20360004,
401                 .end = 0x20360004,
402                 .flags = IORESOURCE_MEM,
403         }, {
404                 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
405                 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
406                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
407         },
408 };
409
410 static struct isp1362_platform_data isp1362_priv = {
411         .sel15Kres = 1,
412         .clknotstop = 0,
413         .oc_enable = 0,
414         .int_act_high = 0,
415         .int_edge_triggered = 0,
416         .remote_wakeup_connected = 0,
417         .no_power_switching = 1,
418         .power_switching_mode = 0,
419 };
420
421 static struct platform_device isp1362_hcd_device = {
422         .name = "isp1362-hcd",
423         .id = 0,
424         .dev = {
425                 .platform_data = &isp1362_priv,
426         },
427         .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
428         .resource = isp1362_hcd_resources,
429 };
430 #endif
431
432 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
433 static struct platform_device bfin_mac_device = {
434         .name = "bfin_mac",
435 };
436 #endif
437
438 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
439 static struct resource net2272_bfin_resources[] = {
440         {
441                 .start = 0x20300000,
442                 .end = 0x20300000 + 0x100,
443                 .flags = IORESOURCE_MEM,
444         }, {
445                 .start = IRQ_PF7,
446                 .end = IRQ_PF7,
447                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
448         },
449 };
450
451 static struct platform_device net2272_bfin_device = {
452         .name = "net2272",
453         .id = -1,
454         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
455         .resource = net2272_bfin_resources,
456 };
457 #endif
458
459 #if defined(CONFIG_MTD_M25P80) \
460         || defined(CONFIG_MTD_M25P80_MODULE)
461 static struct mtd_partition bfin_spi_flash_partitions[] = {
462         {
463                 .name = "bootloader",
464                 .size = 0x00040000,
465                 .offset = 0,
466                 .mask_flags = MTD_CAP_ROM
467         }, {
468                 .name = "linux kernel",
469                 .size = MTDPART_SIZ_FULL,
470                 .offset = MTDPART_OFS_APPEND,
471         }
472 };
473
474 static struct flash_platform_data bfin_spi_flash_data = {
475         .name = "m25p80",
476         .parts = bfin_spi_flash_partitions,
477         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
478         .type = "m25p16",
479 };
480
481 /* SPI flash chip (m25p64) */
482 static struct bfin5xx_spi_chip spi_flash_chip_info = {
483         .enable_dma = 0,         /* use dma transfer with this chip*/
484         .bits_per_word = 8,
485 };
486 #endif
487
488 #if defined(CONFIG_SPI_ADC_BF533) \
489         || defined(CONFIG_SPI_ADC_BF533_MODULE)
490 /* SPI ADC chip */
491 static struct bfin5xx_spi_chip spi_adc_chip_info = {
492         .enable_dma = 1,         /* use dma transfer with this chip*/
493         .bits_per_word = 16,
494 };
495 #endif
496
497 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
498         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
499 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
500         .enable_dma = 0,
501         .bits_per_word = 16,
502 };
503 #endif
504
505 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
506 static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
507         .enable_dma = 0,
508         .bits_per_word = 16,
509 };
510 #endif
511
512 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
513 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
514         .enable_dma = 1,
515         .bits_per_word = 8,
516 };
517 #endif
518
519 #if defined(CONFIG_PBX)
520 static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
521         .ctl_reg        = 0x4, /* send zero */
522         .enable_dma     = 0,
523         .bits_per_word  = 8,
524         .cs_change_per_word = 1,
525 };
526 #endif
527
528 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
529 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
530         .enable_dma = 0,
531         .bits_per_word = 16,
532 };
533
534 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
535         .model                  = 7877,
536         .vref_delay_usecs       = 50,   /* internal, no capacitor */
537         .x_plate_ohms           = 419,
538         .y_plate_ohms           = 486,
539         .pressure_max           = 1000,
540         .pressure_min           = 0,
541         .stopacq_polarity       = 1,
542         .first_conversion_delay = 3,
543         .acquisition_time       = 1,
544         .averaging              = 1,
545         .pen_down_acc_interval  = 1,
546 };
547 #endif
548
549 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
550          && defined(CONFIG_SND_SOC_WM8731_SPI)
551 static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
552         .enable_dma = 0,
553         .bits_per_word = 16,
554 };
555 #endif
556
557 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
558 static struct bfin5xx_spi_chip spidev_chip_info = {
559         .enable_dma = 0,
560         .bits_per_word = 8,
561 };
562 #endif
563
564 static struct spi_board_info bfin_spi_board_info[] __initdata = {
565 #if defined(CONFIG_MTD_M25P80) \
566         || defined(CONFIG_MTD_M25P80_MODULE)
567         {
568                 /* the modalias must be the same as spi device driver name */
569                 .modalias = "m25p80", /* Name of spi_driver for this device */
570                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
571                 .bus_num = 0, /* Framework bus number */
572                 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
573                 .platform_data = &bfin_spi_flash_data,
574                 .controller_data = &spi_flash_chip_info,
575                 .mode = SPI_MODE_3,
576         },
577 #endif
578
579 #if defined(CONFIG_SPI_ADC_BF533) \
580         || defined(CONFIG_SPI_ADC_BF533_MODULE)
581         {
582                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
583                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
584                 .bus_num = 0, /* Framework bus number */
585                 .chip_select = 1, /* Framework chip select. */
586                 .platform_data = NULL, /* No spi_driver specific config */
587                 .controller_data = &spi_adc_chip_info,
588         },
589 #endif
590
591 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
592         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
593         {
594                 .modalias = "ad1836-spi",
595                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
596                 .bus_num = 0,
597                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
598                 .controller_data = &ad1836_spi_chip_info,
599         },
600 #endif
601 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
602         {
603                 .modalias = "ad9960-spi",
604                 .max_speed_hz = 10000000,     /* max spi clock (SCK) speed in HZ */
605                 .bus_num = 0,
606                 .chip_select = 1,
607                 .controller_data = &ad9960_spi_chip_info,
608         },
609 #endif
610 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
611         {
612                 .modalias = "spi_mmc_dummy",
613                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
614                 .bus_num = 0,
615                 .chip_select = 0,
616                 .platform_data = NULL,
617                 .controller_data = &spi_mmc_chip_info,
618                 .mode = SPI_MODE_3,
619         },
620         {
621                 .modalias = "spi_mmc",
622                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
623                 .bus_num = 0,
624                 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
625                 .platform_data = NULL,
626                 .controller_data = &spi_mmc_chip_info,
627                 .mode = SPI_MODE_3,
628         },
629 #endif
630 #if defined(CONFIG_PBX)
631         {
632                 .modalias = "fxs-spi",
633                 .max_speed_hz = 12500000,     /* max spi clock (SCK) speed in HZ */
634                 .bus_num = 0,
635                 .chip_select = 8 - CONFIG_J11_JUMPER,
636                 .controller_data = &spi_si3xxx_chip_info,
637                 .mode = SPI_MODE_3,
638         },
639         {
640                 .modalias = "fxo-spi",
641                 .max_speed_hz = 12500000,     /* max spi clock (SCK) speed in HZ */
642                 .bus_num = 0,
643                 .chip_select = 8 - CONFIG_J19_JUMPER,
644                 .controller_data = &spi_si3xxx_chip_info,
645                 .mode = SPI_MODE_3,
646         },
647 #endif
648 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
649         {
650                 .modalias               = "ad7877",
651                 .platform_data          = &bfin_ad7877_ts_info,
652                 .irq                    = IRQ_PF8,
653                 .max_speed_hz   = 12500000,     /* max spi clock (SCK) speed in HZ */
654                 .bus_num        = 0,
655                 .chip_select  = 2,
656                 .controller_data = &spi_ad7877_chip_info,
657         },
658 #endif
659 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
660          && defined(CONFIG_SND_SOC_WM8731_SPI)
661         {
662                 .modalias       = "wm8731",
663                 .max_speed_hz   = 3125000,     /* max spi clock (SCK) speed in HZ */
664                 .bus_num        = 0,
665                 .chip_select    = 5,
666                 .controller_data = &spi_wm8731_chip_info,
667                 .mode = SPI_MODE_0,
668         },
669 #endif
670 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
671         {
672                 .modalias = "spidev",
673                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
674                 .bus_num = 0,
675                 .chip_select = 1,
676                 .controller_data = &spidev_chip_info,
677         },
678 #endif
679 };
680
681 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
682 /* SPI controller data */
683 static struct bfin5xx_spi_master bfin_spi0_info = {
684         .num_chipselect = 8,
685         .enable_dma = 1,  /* master has the ability to do dma transfer */
686         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
687 };
688
689 /* SPI (0) */
690 static struct resource bfin_spi0_resource[] = {
691         [0] = {
692                 .start = SPI0_REGBASE,
693                 .end   = SPI0_REGBASE + 0xFF,
694                 .flags = IORESOURCE_MEM,
695                 },
696         [1] = {
697                 .start = CH_SPI,
698                 .end   = CH_SPI,
699                 .flags = IORESOURCE_IRQ,
700         },
701 };
702
703 static struct platform_device bfin_spi0_device = {
704         .name = "bfin-spi",
705         .id = 0, /* Bus number */
706         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
707         .resource = bfin_spi0_resource,
708         .dev = {
709                 .platform_data = &bfin_spi0_info, /* Passed to driver */
710         },
711 };
712 #endif  /* spi master and devices */
713
714 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
715 static struct platform_device bfin_fb_device = {
716         .name = "bf537-lq035",
717 };
718 #endif
719
720 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
721 static struct platform_device bfin_fb_adv7393_device = {
722         .name = "bfin-adv7393",
723 };
724 #endif
725
726 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
727 static struct resource bfin_uart_resources[] = {
728 #ifdef CONFIG_SERIAL_BFIN_UART0
729         {
730                 .start = 0xFFC00400,
731                 .end = 0xFFC004FF,
732                 .flags = IORESOURCE_MEM,
733         },
734 #endif
735 #ifdef CONFIG_SERIAL_BFIN_UART1
736         {
737                 .start = 0xFFC02000,
738                 .end = 0xFFC020FF,
739                 .flags = IORESOURCE_MEM,
740         },
741 #endif
742 };
743
744 static struct platform_device bfin_uart_device = {
745         .name = "bfin-uart",
746         .id = 1,
747         .num_resources = ARRAY_SIZE(bfin_uart_resources),
748         .resource = bfin_uart_resources,
749 };
750 #endif
751
752 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
753 static struct resource bfin_sir_resources[] = {
754 #ifdef CONFIG_BFIN_SIR0
755         {
756                 .start = 0xFFC00400,
757                 .end = 0xFFC004FF,
758                 .flags = IORESOURCE_MEM,
759         },
760 #endif
761 #ifdef CONFIG_BFIN_SIR1
762         {
763                 .start = 0xFFC02000,
764                 .end = 0xFFC020FF,
765                 .flags = IORESOURCE_MEM,
766         },
767 #endif
768 };
769
770 static struct platform_device bfin_sir_device = {
771         .name = "bfin_sir",
772         .id = 0,
773         .num_resources = ARRAY_SIZE(bfin_sir_resources),
774         .resource = bfin_sir_resources,
775 };
776 #endif
777
778 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
779 static struct resource bfin_twi0_resource[] = {
780         [0] = {
781                 .start = TWI0_REGBASE,
782                 .end   = TWI0_REGBASE,
783                 .flags = IORESOURCE_MEM,
784         },
785         [1] = {
786                 .start = IRQ_TWI,
787                 .end   = IRQ_TWI,
788                 .flags = IORESOURCE_IRQ,
789         },
790 };
791
792 static struct platform_device i2c_bfin_twi_device = {
793         .name = "i2c-bfin-twi",
794         .id = 0,
795         .num_resources = ARRAY_SIZE(bfin_twi0_resource),
796         .resource = bfin_twi0_resource,
797 };
798 #endif
799
800 #ifdef CONFIG_I2C_BOARDINFO
801 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
802 #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
803         {
804                 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
805         },
806 #endif
807 #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
808         {
809                 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
810                 .irq = IRQ_PF8,
811         },
812 #endif
813 };
814 #endif
815
816 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
817 static struct platform_device bfin_sport0_uart_device = {
818         .name = "bfin-sport-uart",
819         .id = 0,
820 };
821
822 static struct platform_device bfin_sport1_uart_device = {
823         .name = "bfin-sport-uart",
824         .id = 1,
825 };
826 #endif
827
828 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
829 #define PATA_INT        55
830
831 static struct pata_platform_info bfin_pata_platform_data = {
832         .ioport_shift = 1,
833         .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
834 };
835
836 static struct resource bfin_pata_resources[] = {
837         {
838                 .start = 0x20314020,
839                 .end = 0x2031403F,
840                 .flags = IORESOURCE_MEM,
841         },
842         {
843                 .start = 0x2031401C,
844                 .end = 0x2031401F,
845                 .flags = IORESOURCE_MEM,
846         },
847         {
848                 .start = PATA_INT,
849                 .end = PATA_INT,
850                 .flags = IORESOURCE_IRQ,
851         },
852 };
853
854 static struct platform_device bfin_pata_device = {
855         .name = "pata_platform",
856         .id = -1,
857         .num_resources = ARRAY_SIZE(bfin_pata_resources),
858         .resource = bfin_pata_resources,
859         .dev = {
860                 .platform_data = &bfin_pata_platform_data,
861         }
862 };
863 #endif
864
865 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
866 #include <linux/input.h>
867 #include <linux/gpio_keys.h>
868
869 static struct gpio_keys_button bfin_gpio_keys_table[] = {
870         {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
871         {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
872 };
873
874 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
875         .buttons        = bfin_gpio_keys_table,
876         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
877 };
878
879 static struct platform_device bfin_device_gpiokeys = {
880         .name      = "gpio-keys",
881         .dev = {
882                 .platform_data = &bfin_gpio_keys_data,
883         },
884 };
885 #endif
886
887 static struct resource bfin_gpios_resources = {
888         .start = 0,
889         .end   = MAX_BLACKFIN_GPIOS - 1,
890         .flags = IORESOURCE_IRQ,
891 };
892
893 static struct platform_device bfin_gpios_device = {
894         .name = "simple-gpio",
895         .id = -1,
896         .num_resources = 1,
897         .resource = &bfin_gpios_resources,
898 };
899
900 static const unsigned int cclk_vlev_datasheet[] =
901 {
902         VRPAIR(VLEV_100, 400000000),
903         VRPAIR(VLEV_105, 426000000),
904         VRPAIR(VLEV_110, 500000000),
905         VRPAIR(VLEV_115, 533000000),
906         VRPAIR(VLEV_120, 600000000),
907 };
908
909 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
910         .tuple_tab = cclk_vlev_datasheet,
911         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
912         .vr_settling_time = 25 /* us */,
913 };
914
915 static struct platform_device bfin_dpmc = {
916         .name = "bfin dpmc",
917         .dev = {
918                 .platform_data = &bfin_dmpc_vreg_data,
919         },
920 };
921
922 static struct platform_device *stamp_devices[] __initdata = {
923
924         &bfin_dpmc,
925
926 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
927         &bf5xx_nand_device,
928 #endif
929
930 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
931         &bfin_pcmcia_cf_device,
932 #endif
933
934 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
935         &rtc_device,
936 #endif
937
938 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
939         &sl811_hcd_device,
940 #endif
941
942 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
943         &isp1362_hcd_device,
944 #endif
945
946 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
947         &musb_device,
948 #endif
949
950 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
951         &smc91x_device,
952 #endif
953
954 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
955         &dm9000_device,
956 #endif
957
958 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
959         &bfin_mac_device,
960 #endif
961
962 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
963         &net2272_bfin_device,
964 #endif
965
966 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
967         &bfin_spi0_device,
968 #endif
969
970 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
971         &bfin_fb_device,
972 #endif
973
974 #if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
975         &bf52x_t350mcqb_device,
976 #endif
977
978 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
979         &bfin_fb_adv7393_device,
980 #endif
981
982 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
983         &bfin_uart_device,
984 #endif
985
986 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
987         &bfin_sir_device,
988 #endif
989
990 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
991         &i2c_bfin_twi_device,
992 #endif
993
994 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
995         &bfin_sport0_uart_device,
996         &bfin_sport1_uart_device,
997 #endif
998
999 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
1000         &bfin_pata_device,
1001 #endif
1002
1003 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
1004         &bfin_device_gpiokeys,
1005 #endif
1006
1007 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
1008         &ezkit_flash_device,
1009 #endif
1010
1011         &bfin_gpios_device,
1012 };
1013
1014 static int __init stamp_init(void)
1015 {
1016         printk(KERN_INFO "%s(): registering device resources\n", __func__);
1017
1018 #ifdef CONFIG_I2C_BOARDINFO
1019         i2c_register_board_info(0, bfin_i2c_board_info,
1020                                 ARRAY_SIZE(bfin_i2c_board_info));
1021 #endif
1022
1023         platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
1024         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
1025
1026 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
1027         irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
1028 #endif
1029         return 0;
1030 }
1031
1032 arch_initcall(stamp_init);
1033
1034 void native_machine_restart(char *cmd)
1035 {
1036         /* workaround reboot hang when booting from SPI */
1037         if ((bfin_read_SYSCR() & 0x7) == 0x3)
1038                 bfin_gpio_reset_spi0_ssel1();
1039 }
1040
1041 void bfin_get_ether_addr(char *addr)
1042 {
1043         /* the MAC is stored in OTP memory page 0xDF */
1044         u32 ret;
1045         u64 otp_mac;
1046         u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
1047
1048         ret = otp_read(0xDF, 0x00, &otp_mac);
1049         if (!(ret & 0x1)) {
1050                 char *otp_mac_p = (char *)&otp_mac;
1051                 for (ret = 0; ret < 6; ++ret)
1052                         addr[ret] = otp_mac_p[5 - ret];
1053         }
1054 }
1055 EXPORT_SYMBOL(bfin_get_ether_addr);