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