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