Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[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/kernel.h>
33 #include <linux/platform_device.h>
34 #include <linux/mtd/mtd.h>
35 #include <linux/mtd/nand.h>
36 #include <linux/mtd/partitions.h>
37 #include <linux/mtd/plat-ram.h>
38 #include <linux/mtd/physmap.h>
39 #include <linux/spi/spi.h>
40 #include <linux/spi/flash.h>
41 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
42 #include <linux/usb/isp1362.h>
43 #endif
44 #include <linux/ata_platform.h>
45 #include <linux/irq.h>
46 #include <linux/interrupt.h>
47 #include <linux/i2c.h>
48 #include <linux/usb/sl811.h>
49 #include <asm/dma.h>
50 #include <asm/bfin5xx_spi.h>
51 #include <asm/reboot.h>
52 #include <asm/portmux.h>
53 #include <asm/dpmc.h>
54
55 /*
56  * Name the Board for the /proc/cpuinfo
57  */
58 const char bfin_board_name[] = "ADDS-BF537-STAMP";
59
60 /*
61  *  Driver needs to know address, irq and flag pin.
62  */
63
64 #define ISP1761_BASE       0x203C0000
65 #define ISP1761_IRQ        IRQ_PF7
66
67 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
68 static struct resource bfin_isp1761_resources[] = {
69         [0] = {
70                 .name   = "isp1761-regs",
71                 .start  = ISP1761_BASE + 0x00000000,
72                 .end    = ISP1761_BASE + 0x000fffff,
73                 .flags  = IORESOURCE_MEM,
74         },
75         [1] = {
76                 .start  = ISP1761_IRQ,
77                 .end    = ISP1761_IRQ,
78                 .flags  = IORESOURCE_IRQ,
79         },
80 };
81
82 static struct platform_device bfin_isp1761_device = {
83         .name           = "isp1761",
84         .id             = 0,
85         .num_resources  = ARRAY_SIZE(bfin_isp1761_resources),
86         .resource       = bfin_isp1761_resources,
87 };
88
89 static struct platform_device *bfin_isp1761_devices[] = {
90         &bfin_isp1761_device,
91 };
92
93 int __init bfin_isp1761_init(void)
94 {
95         unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
96
97         printk(KERN_INFO "%s(): registering device resources\n", __func__);
98         set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING);
99
100         return platform_add_devices(bfin_isp1761_devices, num_devices);
101 }
102
103 void __exit bfin_isp1761_exit(void)
104 {
105         platform_device_unregister(&bfin_isp1761_device);
106 }
107
108 arch_initcall(bfin_isp1761_init);
109 #endif
110
111 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
112 #include <linux/input.h>
113 #include <linux/gpio_keys.h>
114
115 static struct gpio_keys_button bfin_gpio_keys_table[] = {
116         {BTN_0, GPIO_PF2, 1, "gpio-keys: BTN0"},
117         {BTN_1, GPIO_PF3, 1, "gpio-keys: BTN1"},
118         {BTN_2, GPIO_PF4, 1, "gpio-keys: BTN2"},
119         {BTN_3, GPIO_PF5, 1, "gpio-keys: BTN3"},
120 };
121
122 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
123         .buttons        = bfin_gpio_keys_table,
124         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
125 };
126
127 static struct platform_device bfin_device_gpiokeys = {
128         .name      = "gpio-keys",
129         .dev = {
130                 .platform_data = &bfin_gpio_keys_data,
131         },
132 };
133 #endif
134
135 static struct resource bfin_gpios_resources = {
136         .start = 0,
137         .end   = MAX_BLACKFIN_GPIOS - 1,
138         .flags = IORESOURCE_IRQ,
139 };
140
141 static struct platform_device bfin_gpios_device = {
142         .name = "simple-gpio",
143         .id = -1,
144         .num_resources = 1,
145         .resource = &bfin_gpios_resources,
146 };
147
148 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
149 static struct resource bfin_pcmcia_cf_resources[] = {
150         {
151                 .start = 0x20310000, /* IO PORT */
152                 .end = 0x20312000,
153                 .flags = IORESOURCE_MEM,
154         }, {
155                 .start = 0x20311000, /* Attribute Memory */
156                 .end = 0x20311FFF,
157                 .flags = IORESOURCE_MEM,
158         }, {
159                 .start = IRQ_PF4,
160                 .end = IRQ_PF4,
161                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
162         }, {
163                 .start = 6, /* Card Detect PF6 */
164                 .end = 6,
165                 .flags = IORESOURCE_IRQ,
166         },
167 };
168
169 static struct platform_device bfin_pcmcia_cf_device = {
170         .name = "bfin_cf_pcmcia",
171         .id = -1,
172         .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
173         .resource = bfin_pcmcia_cf_resources,
174 };
175 #endif
176
177 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
178 static struct platform_device rtc_device = {
179         .name = "rtc-bfin",
180         .id   = -1,
181 };
182 #endif
183
184 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
185 static struct resource smc91x_resources[] = {
186         {
187                 .name = "smc91x-regs",
188                 .start = 0x20300300,
189                 .end = 0x20300300 + 16,
190                 .flags = IORESOURCE_MEM,
191         }, {
192
193                 .start = IRQ_PF7,
194                 .end = IRQ_PF7,
195                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
196         },
197 };
198 static struct platform_device smc91x_device = {
199         .name = "smc91x",
200         .id = 0,
201         .num_resources = ARRAY_SIZE(smc91x_resources),
202         .resource = smc91x_resources,
203 };
204 #endif
205
206 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
207 static struct resource dm9000_resources[] = {
208         [0] = {
209                 .start  = 0x203FB800,
210                 .end    = 0x203FB800 + 8,
211                 .flags  = IORESOURCE_MEM,
212         },
213         [1] = {
214                 .start  = IRQ_PF9,
215                 .end    = IRQ_PF9,
216                 .flags  = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
217         },
218 };
219
220 static struct platform_device dm9000_device = {
221         .name           = "dm9000",
222         .id             = -1,
223         .num_resources  = ARRAY_SIZE(dm9000_resources),
224         .resource       = dm9000_resources,
225 };
226 #endif
227
228 #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
229 static struct resource ax88180_resources[] = {
230         [0] = {
231                 .start  = 0x20300000,
232                 .end    = 0x20300000 + 0x8000,
233                 .flags  = IORESOURCE_MEM,
234         },
235         [1] = {
236                 .start  = IRQ_PF7,
237                 .end    = IRQ_PF7,
238                 .flags  = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
239         },
240 };
241
242 static struct platform_device ax88180_device = {
243         .name           = "ax88180",
244         .id             = -1,
245         .num_resources  = ARRAY_SIZE(ax88180_resources),
246         .resource       = ax88180_resources,
247 };
248 #endif
249
250 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
251 static struct resource sl811_hcd_resources[] = {
252         {
253                 .start = 0x20340000,
254                 .end = 0x20340000,
255                 .flags = IORESOURCE_MEM,
256         }, {
257                 .start = 0x20340004,
258                 .end = 0x20340004,
259                 .flags = IORESOURCE_MEM,
260         }, {
261                 .start = CONFIG_USB_SL811_BFIN_IRQ,
262                 .end = CONFIG_USB_SL811_BFIN_IRQ,
263                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
264         },
265 };
266
267 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
268 void sl811_port_power(struct device *dev, int is_on)
269 {
270         gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
271         gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
272 }
273 #endif
274
275 static struct sl811_platform_data sl811_priv = {
276         .potpg = 10,
277         .power = 250,       /* == 500mA */
278 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
279         .port_power = &sl811_port_power,
280 #endif
281 };
282
283 static struct platform_device sl811_hcd_device = {
284         .name = "sl811-hcd",
285         .id = 0,
286         .dev = {
287                 .platform_data = &sl811_priv,
288         },
289         .num_resources = ARRAY_SIZE(sl811_hcd_resources),
290         .resource = sl811_hcd_resources,
291 };
292 #endif
293
294 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
295 static struct resource isp1362_hcd_resources[] = {
296         {
297                 .start = 0x20360000,
298                 .end = 0x20360000,
299                 .flags = IORESOURCE_MEM,
300         }, {
301                 .start = 0x20360004,
302                 .end = 0x20360004,
303                 .flags = IORESOURCE_MEM,
304         }, {
305                 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
306                 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
307                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
308         },
309 };
310
311 static struct isp1362_platform_data isp1362_priv = {
312         .sel15Kres = 1,
313         .clknotstop = 0,
314         .oc_enable = 0,
315         .int_act_high = 0,
316         .int_edge_triggered = 0,
317         .remote_wakeup_connected = 0,
318         .no_power_switching = 1,
319         .power_switching_mode = 0,
320 };
321
322 static struct platform_device isp1362_hcd_device = {
323         .name = "isp1362-hcd",
324         .id = 0,
325         .dev = {
326                 .platform_data = &isp1362_priv,
327         },
328         .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
329         .resource = isp1362_hcd_resources,
330 };
331 #endif
332
333 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
334 static struct platform_device bfin_mac_device = {
335         .name = "bfin_mac",
336 };
337 #endif
338
339 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
340 static struct resource net2272_bfin_resources[] = {
341         {
342                 .start = 0x20300000,
343                 .end = 0x20300000 + 0x100,
344                 .flags = IORESOURCE_MEM,
345         }, {
346                 .start = IRQ_PF7,
347                 .end = IRQ_PF7,
348                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
349         },
350 };
351
352 static struct platform_device net2272_bfin_device = {
353         .name = "net2272",
354         .id = -1,
355         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
356         .resource = net2272_bfin_resources,
357 };
358 #endif
359
360 #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
361 #ifdef CONFIG_MTD_PARTITIONS
362 const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
363
364 static struct mtd_partition bfin_plat_nand_partitions[] = {
365         {
366                 .name   = "linux kernel(nand)",
367                 .size   = 0x400000,
368                 .offset = 0,
369         }, {
370                 .name   = "file system(nand)",
371                 .size   = MTDPART_SIZ_FULL,
372                 .offset = MTDPART_OFS_APPEND,
373         },
374 };
375 #endif
376
377 #define BFIN_NAND_PLAT_CLE 2
378 #define BFIN_NAND_PLAT_ALE 1
379 static void bfin_plat_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
380 {
381         struct nand_chip *this = mtd->priv;
382
383         if (cmd == NAND_CMD_NONE)
384                 return;
385
386         if (ctrl & NAND_CLE)
387                 writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_CLE));
388         else
389                 writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_ALE));
390 }
391
392 #define BFIN_NAND_PLAT_READY GPIO_PF3
393 static int bfin_plat_nand_dev_ready(struct mtd_info *mtd)
394 {
395         return gpio_get_value(BFIN_NAND_PLAT_READY);
396 }
397
398 static struct platform_nand_data bfin_plat_nand_data = {
399         .chip = {
400                 .chip_delay = 30,
401 #ifdef CONFIG_MTD_PARTITIONS
402                 .part_probe_types = part_probes,
403                 .partitions = bfin_plat_nand_partitions,
404                 .nr_partitions = ARRAY_SIZE(bfin_plat_nand_partitions),
405 #endif
406         },
407         .ctrl = {
408                 .cmd_ctrl  = bfin_plat_nand_cmd_ctrl,
409                 .dev_ready = bfin_plat_nand_dev_ready,
410         },
411 };
412
413 #define MAX(x, y) (x > y ? x : y)
414 static struct resource bfin_plat_nand_resources = {
415         .start = 0x20212000,
416         .end   = 0x20212000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)),
417         .flags = IORESOURCE_IO,
418 };
419
420 static struct platform_device bfin_async_nand_device = {
421         .name = "gen_nand",
422         .id = -1,
423         .num_resources = 1,
424         .resource = &bfin_plat_nand_resources,
425         .dev = {
426                 .platform_data = &bfin_plat_nand_data,
427         },
428 };
429
430 static void bfin_plat_nand_init(void)
431 {
432         gpio_request(BFIN_NAND_PLAT_READY, "bfin_nand_plat");
433 }
434 #else
435 static void bfin_plat_nand_init(void) {}
436 #endif
437
438 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
439 static struct mtd_partition stamp_partitions[] = {
440         {
441                 .name       = "bootloader(nor)",
442                 .size       = 0x40000,
443                 .offset     = 0,
444         }, {
445                 .name       = "linux kernel(nor)",
446                 .size       = 0xE0000,
447                 .offset     = MTDPART_OFS_APPEND,
448         }, {
449                 .name       = "file system(nor)",
450                 .size       = 0x400000 - 0x40000 - 0xE0000 - 0x10000,
451                 .offset     = MTDPART_OFS_APPEND,
452         }, {
453                 .name       = "MAC Address(nor)",
454                 .size       = MTDPART_SIZ_FULL,
455                 .offset     = 0x3F0000,
456                 .mask_flags = MTD_WRITEABLE,
457         }
458 };
459
460 static struct physmap_flash_data stamp_flash_data = {
461         .width      = 2,
462         .parts      = stamp_partitions,
463         .nr_parts   = ARRAY_SIZE(stamp_partitions),
464 };
465
466 static struct resource stamp_flash_resource = {
467         .start = 0x20000000,
468         .end   = 0x203fffff,
469         .flags = IORESOURCE_MEM,
470 };
471
472 static struct platform_device stamp_flash_device = {
473         .name          = "physmap-flash",
474         .id            = 0,
475         .dev = {
476                 .platform_data = &stamp_flash_data,
477         },
478         .num_resources = 1,
479         .resource      = &stamp_flash_resource,
480 };
481 #endif
482
483 #if defined(CONFIG_MTD_M25P80) \
484         || defined(CONFIG_MTD_M25P80_MODULE)
485 static struct mtd_partition bfin_spi_flash_partitions[] = {
486         {
487                 .name = "bootloader(spi)",
488                 .size = 0x00040000,
489                 .offset = 0,
490                 .mask_flags = MTD_CAP_ROM
491         }, {
492                 .name = "linux kernel(spi)",
493                 .size = 0xe0000,
494                 .offset = MTDPART_OFS_APPEND,
495         }, {
496                 .name = "file system(spi)",
497                 .size = MTDPART_SIZ_FULL,
498                 .offset = MTDPART_OFS_APPEND,
499         }
500 };
501
502 static struct flash_platform_data bfin_spi_flash_data = {
503         .name = "m25p80",
504         .parts = bfin_spi_flash_partitions,
505         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
506         .type = "m25p64",
507 };
508
509 /* SPI flash chip (m25p64) */
510 static struct bfin5xx_spi_chip spi_flash_chip_info = {
511         .enable_dma = 0,         /* use dma transfer with this chip*/
512         .bits_per_word = 8,
513 };
514 #endif
515
516 #if defined(CONFIG_SPI_ADC_BF533) \
517         || defined(CONFIG_SPI_ADC_BF533_MODULE)
518 /* SPI ADC chip */
519 static struct bfin5xx_spi_chip spi_adc_chip_info = {
520         .enable_dma = 1,         /* use dma transfer with this chip*/
521         .bits_per_word = 16,
522 };
523 #endif
524
525 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
526         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
527 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
528         .enable_dma = 0,
529         .bits_per_word = 16,
530 };
531 #endif
532
533 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
534 static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
535         .enable_dma = 0,
536         .bits_per_word = 16,
537 };
538 #endif
539
540 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
541 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
542         .enable_dma = 1,
543         .bits_per_word = 8,
544 };
545 #endif
546
547 #if defined(CONFIG_PBX)
548 static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
549         .ctl_reg        = 0x4, /* send zero */
550         .enable_dma     = 0,
551         .bits_per_word  = 8,
552         .cs_change_per_word = 1,
553 };
554 #endif
555
556 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
557 #include <linux/spi/ad7877.h>
558 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
559         .enable_dma = 0,
560         .bits_per_word = 16,
561 };
562
563 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
564         .model                  = 7877,
565         .vref_delay_usecs       = 50,   /* internal, no capacitor */
566         .x_plate_ohms           = 419,
567         .y_plate_ohms           = 486,
568         .pressure_max           = 1000,
569         .pressure_min           = 0,
570         .stopacq_polarity       = 1,
571         .first_conversion_delay = 3,
572         .acquisition_time       = 1,
573         .averaging              = 1,
574         .pen_down_acc_interval  = 1,
575 };
576 #endif
577
578 #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
579 #include <linux/spi/ad7879.h>
580 static struct bfin5xx_spi_chip spi_ad7879_chip_info = {
581         .enable_dma = 0,
582         .bits_per_word = 16,
583 };
584
585 static const struct ad7879_platform_data bfin_ad7879_ts_info = {
586         .model                  = 7879, /* Model = AD7879 */
587         .x_plate_ohms           = 620,  /* 620 Ohm from the touch datasheet */
588         .pressure_max           = 10000,
589         .pressure_min           = 0,
590         .first_conversion_delay = 3,    /* wait 512us before do a first conversion */
591         .acquisition_time       = 1,    /* 4us acquisition time per sample */
592         .median                 = 2,    /* do 8 measurements */
593         .averaging              = 1,    /* take the average of 4 middle samples */
594         .pen_down_acc_interval  = 255,  /* 9.4 ms */
595         .gpio_output            = 1,    /* configure AUX/VBAT/GPIO as GPIO output */
596         .gpio_default           = 1,    /* During initialization set GPIO = HIGH */
597 };
598 #endif
599
600 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
601 static struct bfin5xx_spi_chip spidev_chip_info = {
602         .enable_dma = 0,
603         .bits_per_word = 8,
604 };
605 #endif
606
607 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
608 static struct bfin5xx_spi_chip lq035q1_spi_chip_info = {
609         .enable_dma     = 0,
610         .bits_per_word  = 8,
611 };
612 #endif
613
614 #if defined(CONFIG_MTD_DATAFLASH) \
615         || defined(CONFIG_MTD_DATAFLASH_MODULE)
616
617 static struct mtd_partition bfin_spi_dataflash_partitions[] = {
618         {
619                 .name = "bootloader(spi)",
620                 .size = 0x00040000,
621                 .offset = 0,
622                 .mask_flags = MTD_CAP_ROM
623         }, {
624                 .name = "linux kernel(spi)",
625                 .size = 0xe0000,
626                 .offset = MTDPART_OFS_APPEND,
627         }, {
628                 .name = "file system(spi)",
629                 .size = MTDPART_SIZ_FULL,
630                 .offset = MTDPART_OFS_APPEND,
631         }
632 };
633
634 static struct flash_platform_data bfin_spi_dataflash_data = {
635         .name = "SPI Dataflash",
636         .parts = bfin_spi_dataflash_partitions,
637         .nr_parts = ARRAY_SIZE(bfin_spi_dataflash_partitions),
638 };
639
640 /* DataFlash chip */
641 static struct bfin5xx_spi_chip data_flash_chip_info = {
642         .enable_dma = 0,         /* use dma transfer with this chip*/
643         .bits_per_word = 8,
644 };
645 #endif
646
647 static struct spi_board_info bfin_spi_board_info[] __initdata = {
648 #if defined(CONFIG_MTD_M25P80) \
649         || defined(CONFIG_MTD_M25P80_MODULE)
650         {
651                 /* the modalias must be the same as spi device driver name */
652                 .modalias = "m25p80", /* Name of spi_driver for this device */
653                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
654                 .bus_num = 0, /* Framework bus number */
655                 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
656                 .platform_data = &bfin_spi_flash_data,
657                 .controller_data = &spi_flash_chip_info,
658                 .mode = SPI_MODE_3,
659         },
660 #endif
661 #if defined(CONFIG_MTD_DATAFLASH) \
662         || defined(CONFIG_MTD_DATAFLASH_MODULE)
663         {       /* DataFlash chip */
664                 .modalias = "mtd_dataflash",
665                 .max_speed_hz = 33250000,     /* max spi clock (SCK) speed in HZ */
666                 .bus_num = 0, /* Framework bus number */
667                 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
668                 .platform_data = &bfin_spi_dataflash_data,
669                 .controller_data = &data_flash_chip_info,
670                 .mode = SPI_MODE_3,
671         },
672 #endif
673 #if defined(CONFIG_SPI_ADC_BF533) \
674         || defined(CONFIG_SPI_ADC_BF533_MODULE)
675         {
676                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
677                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
678                 .bus_num = 0, /* Framework bus number */
679                 .chip_select = 1, /* Framework chip select. */
680                 .platform_data = NULL, /* No spi_driver specific config */
681                 .controller_data = &spi_adc_chip_info,
682         },
683 #endif
684
685 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
686         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
687         {
688                 .modalias = "ad1836-spi",
689                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
690                 .bus_num = 0,
691                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
692                 .controller_data = &ad1836_spi_chip_info,
693         },
694 #endif
695 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
696         {
697                 .modalias = "ad9960-spi",
698                 .max_speed_hz = 10000000,     /* max spi clock (SCK) speed in HZ */
699                 .bus_num = 0,
700                 .chip_select = 1,
701                 .controller_data = &ad9960_spi_chip_info,
702         },
703 #endif
704 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
705         {
706                 .modalias = "spi_mmc_dummy",
707                 .max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
708                 .bus_num = 0,
709                 .chip_select = 0,
710                 .platform_data = NULL,
711                 .controller_data = &spi_mmc_chip_info,
712                 .mode = SPI_MODE_3,
713         },
714         {
715                 .modalias = "spi_mmc",
716                 .max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
717                 .bus_num = 0,
718                 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
719                 .platform_data = NULL,
720                 .controller_data = &spi_mmc_chip_info,
721                 .mode = SPI_MODE_3,
722         },
723 #endif
724 #if defined(CONFIG_PBX)
725         {
726                 .modalias = "fxs-spi",
727                 .max_speed_hz = 12500000,     /* max spi clock (SCK) speed in HZ */
728                 .bus_num = 0,
729                 .chip_select = 8 - CONFIG_J11_JUMPER,
730                 .controller_data = &spi_si3xxx_chip_info,
731                 .mode = SPI_MODE_3,
732         },
733         {
734                 .modalias = "fxo-spi",
735                 .max_speed_hz = 12500000,     /* max spi clock (SCK) speed in HZ */
736                 .bus_num = 0,
737                 .chip_select = 8 - CONFIG_J19_JUMPER,
738                 .controller_data = &spi_si3xxx_chip_info,
739                 .mode = SPI_MODE_3,
740         },
741 #endif
742 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
743         {
744                 .modalias               = "ad7877",
745                 .platform_data          = &bfin_ad7877_ts_info,
746                 .irq                    = IRQ_PF6,
747                 .max_speed_hz   = 12500000,     /* max spi clock (SCK) speed in HZ */
748                 .bus_num        = 0,
749                 .chip_select  = 1,
750                 .controller_data = &spi_ad7877_chip_info,
751         },
752 #endif
753 #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
754         {
755                 .modalias = "ad7879",
756                 .platform_data = &bfin_ad7879_ts_info,
757                 .irq = IRQ_PF7,
758                 .max_speed_hz = 5000000,     /* max spi clock (SCK) speed in HZ */
759                 .bus_num = 0,
760                 .chip_select = 1,
761                 .controller_data = &spi_ad7879_chip_info,
762                 .mode = SPI_CPHA | SPI_CPOL,
763         },
764 #endif
765 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
766         {
767                 .modalias = "spidev",
768                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
769                 .bus_num = 0,
770                 .chip_select = 1,
771                 .controller_data = &spidev_chip_info,
772         },
773 #endif
774 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
775         {
776                 .modalias = "bfin-lq035q1-spi",
777                 .max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
778                 .bus_num = 0,
779                 .chip_select = 2,
780                 .controller_data = &lq035q1_spi_chip_info,
781                 .mode = SPI_CPHA | SPI_CPOL,
782         },
783 #endif
784 };
785
786 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
787 /* SPI controller data */
788 static struct bfin5xx_spi_master bfin_spi0_info = {
789         .num_chipselect = 8,
790         .enable_dma = 1,  /* master has the ability to do dma transfer */
791         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
792 };
793
794 /* SPI (0) */
795 static struct resource bfin_spi0_resource[] = {
796         [0] = {
797                 .start = SPI0_REGBASE,
798                 .end   = SPI0_REGBASE + 0xFF,
799                 .flags = IORESOURCE_MEM,
800                 },
801         [1] = {
802                 .start = CH_SPI,
803                 .end   = CH_SPI,
804                 .flags = IORESOURCE_IRQ,
805         },
806 };
807
808 static struct platform_device bfin_spi0_device = {
809         .name = "bfin-spi",
810         .id = 0, /* Bus number */
811         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
812         .resource = bfin_spi0_resource,
813         .dev = {
814                 .platform_data = &bfin_spi0_info, /* Passed to driver */
815         },
816 };
817 #endif  /* spi master and devices */
818
819 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
820 static struct platform_device bfin_fb_device = {
821         .name = "bf537-lq035",
822 };
823 #endif
824
825 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
826 static struct platform_device bfin_fb_adv7393_device = {
827         .name = "bfin-adv7393",
828 };
829 #endif
830
831 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
832 #include <asm/bfin-lq035q1.h>
833
834 static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
835         .mode =         LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
836         .use_bl =       0,      /* let something else control the LCD Blacklight */
837         .gpio_bl =      GPIO_PF7,
838 };
839
840 static struct resource bfin_lq035q1_resources[] = {
841         {
842                 .start = IRQ_PPI_ERROR,
843                 .end = IRQ_PPI_ERROR,
844                 .flags = IORESOURCE_IRQ,
845         },
846 };
847
848 static struct platform_device bfin_lq035q1_device = {
849         .name           = "bfin-lq035q1",
850         .id             = -1,
851         .num_resources  = ARRAY_SIZE(bfin_lq035q1_resources),
852         .resource       = bfin_lq035q1_resources,
853         .dev            = {
854                 .platform_data = &bfin_lq035q1_data,
855         },
856 };
857 #endif
858
859 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
860 static struct resource bfin_uart_resources[] = {
861 #ifdef CONFIG_SERIAL_BFIN_UART0
862         {
863                 .start = 0xFFC00400,
864                 .end = 0xFFC004FF,
865                 .flags = IORESOURCE_MEM,
866         },
867 #endif
868 #ifdef CONFIG_SERIAL_BFIN_UART1
869         {
870                 .start = 0xFFC02000,
871                 .end = 0xFFC020FF,
872                 .flags = IORESOURCE_MEM,
873         },
874 #endif
875 };
876
877 static struct platform_device bfin_uart_device = {
878         .name = "bfin-uart",
879         .id = 1,
880         .num_resources = ARRAY_SIZE(bfin_uart_resources),
881         .resource = bfin_uart_resources,
882 };
883 #endif
884
885 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
886 static struct resource bfin_sir_resources[] = {
887 #ifdef CONFIG_BFIN_SIR0
888         {
889                 .start = 0xFFC00400,
890                 .end = 0xFFC004FF,
891                 .flags = IORESOURCE_MEM,
892         },
893 #endif
894 #ifdef CONFIG_BFIN_SIR1
895         {
896                 .start = 0xFFC02000,
897                 .end = 0xFFC020FF,
898                 .flags = IORESOURCE_MEM,
899         },
900 #endif
901 };
902
903 static struct platform_device bfin_sir_device = {
904         .name = "bfin_sir",
905         .id = 0,
906         .num_resources = ARRAY_SIZE(bfin_sir_resources),
907         .resource = bfin_sir_resources,
908 };
909 #endif
910
911 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
912 static struct resource bfin_twi0_resource[] = {
913         [0] = {
914                 .start = TWI0_REGBASE,
915                 .end   = TWI0_REGBASE,
916                 .flags = IORESOURCE_MEM,
917         },
918         [1] = {
919                 .start = IRQ_TWI,
920                 .end   = IRQ_TWI,
921                 .flags = IORESOURCE_IRQ,
922         },
923 };
924
925 static struct platform_device i2c_bfin_twi_device = {
926         .name = "i2c-bfin-twi",
927         .id = 0,
928         .num_resources = ARRAY_SIZE(bfin_twi0_resource),
929         .resource = bfin_twi0_resource,
930 };
931 #endif
932
933 #ifdef CONFIG_I2C_BOARDINFO
934 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
935 #if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE)
936         {
937                 I2C_BOARD_INFO("ad7142_joystick", 0x2C),
938                 .irq = 55,
939         },
940 #endif
941 #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
942         {
943                 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
944         },
945 #endif
946 #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
947         {
948                 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
949                 .irq = 72,
950         },
951 #endif
952 };
953 #endif
954
955 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
956 static struct platform_device bfin_sport0_uart_device = {
957         .name = "bfin-sport-uart",
958         .id = 0,
959 };
960
961 static struct platform_device bfin_sport1_uart_device = {
962         .name = "bfin-sport-uart",
963         .id = 1,
964 };
965 #endif
966
967 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
968 #define PATA_INT        IRQ_PF5
969
970 static struct pata_platform_info bfin_pata_platform_data = {
971         .ioport_shift = 1,
972         .irq_flags = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
973 };
974
975 static struct resource bfin_pata_resources[] = {
976         {
977                 .start = 0x20314020,
978                 .end = 0x2031403F,
979                 .flags = IORESOURCE_MEM,
980         },
981         {
982                 .start = 0x2031401C,
983                 .end = 0x2031401F,
984                 .flags = IORESOURCE_MEM,
985         },
986         {
987                 .start = PATA_INT,
988                 .end = PATA_INT,
989                 .flags = IORESOURCE_IRQ,
990         },
991 };
992
993 static struct platform_device bfin_pata_device = {
994         .name = "pata_platform",
995         .id = -1,
996         .num_resources = ARRAY_SIZE(bfin_pata_resources),
997         .resource = bfin_pata_resources,
998         .dev = {
999                 .platform_data = &bfin_pata_platform_data,
1000         }
1001 };
1002 #endif
1003
1004 static const unsigned int cclk_vlev_datasheet[] =
1005 {
1006         VRPAIR(VLEV_085, 250000000),
1007         VRPAIR(VLEV_090, 376000000),
1008         VRPAIR(VLEV_095, 426000000),
1009         VRPAIR(VLEV_100, 426000000),
1010         VRPAIR(VLEV_105, 476000000),
1011         VRPAIR(VLEV_110, 476000000),
1012         VRPAIR(VLEV_115, 476000000),
1013         VRPAIR(VLEV_120, 500000000),
1014         VRPAIR(VLEV_125, 533000000),
1015         VRPAIR(VLEV_130, 600000000),
1016 };
1017
1018 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
1019         .tuple_tab = cclk_vlev_datasheet,
1020         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
1021         .vr_settling_time = 25 /* us */,
1022 };
1023
1024 static struct platform_device bfin_dpmc = {
1025         .name = "bfin dpmc",
1026         .dev = {
1027                 .platform_data = &bfin_dmpc_vreg_data,
1028         },
1029 };
1030
1031 static struct platform_device *stamp_devices[] __initdata = {
1032
1033         &bfin_dpmc,
1034
1035 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
1036         &bfin_pcmcia_cf_device,
1037 #endif
1038
1039 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
1040         &rtc_device,
1041 #endif
1042
1043 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
1044         &sl811_hcd_device,
1045 #endif
1046
1047 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
1048         &isp1362_hcd_device,
1049 #endif
1050
1051 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
1052         &smc91x_device,
1053 #endif
1054
1055 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
1056         &dm9000_device,
1057 #endif
1058
1059 #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
1060         &ax88180_device,
1061 #endif
1062
1063 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
1064         &bfin_mac_device,
1065 #endif
1066
1067 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
1068         &net2272_bfin_device,
1069 #endif
1070
1071 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
1072         &bfin_spi0_device,
1073 #endif
1074
1075 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
1076         &bfin_fb_device,
1077 #endif
1078
1079 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
1080         &bfin_lq035q1_device,
1081 #endif
1082
1083 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
1084         &bfin_fb_adv7393_device,
1085 #endif
1086
1087 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
1088         &bfin_uart_device,
1089 #endif
1090
1091 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
1092         &bfin_sir_device,
1093 #endif
1094
1095 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
1096         &i2c_bfin_twi_device,
1097 #endif
1098
1099 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
1100         &bfin_sport0_uart_device,
1101         &bfin_sport1_uart_device,
1102 #endif
1103
1104 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
1105         &bfin_pata_device,
1106 #endif
1107
1108 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
1109         &bfin_device_gpiokeys,
1110 #endif
1111
1112         &bfin_gpios_device,
1113
1114 #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
1115         &bfin_async_nand_device,
1116 #endif
1117
1118 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
1119         &stamp_flash_device,
1120 #endif
1121 };
1122
1123 static int __init stamp_init(void)
1124 {
1125         printk(KERN_INFO "%s(): registering device resources\n", __func__);
1126
1127 #ifdef CONFIG_I2C_BOARDINFO
1128         i2c_register_board_info(0, bfin_i2c_board_info,
1129                                 ARRAY_SIZE(bfin_i2c_board_info));
1130 #endif
1131
1132         bfin_plat_nand_init();
1133         platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
1134         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
1135
1136 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
1137         irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
1138 #endif
1139
1140         return 0;
1141 }
1142
1143 arch_initcall(stamp_init);
1144
1145 void native_machine_restart(char *cmd)
1146 {
1147         /* workaround reboot hang when booting from SPI */
1148         if ((bfin_read_SYSCR() & 0x7) == 0x3)
1149                 bfin_gpio_reset_spi0_ssel1();
1150 }
1151
1152 /*
1153  * Currently the MAC address is saved in Flash by U-Boot
1154  */
1155 #define FLASH_MAC       0x203f0000
1156 void bfin_get_ether_addr(char *addr)
1157 {
1158         *(u32 *)(&(addr[0])) = bfin_read32(FLASH_MAC);
1159         *(u16 *)(&(addr[4])) = bfin_read16(FLASH_MAC + 4);
1160 }
1161 EXPORT_SYMBOL(bfin_get_ether_addr);