Merge branch 'linus' into x86/mm
[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 <linux/spi/mmc_spi.h>
50 #include <asm/dma.h>
51 #include <asm/bfin5xx_spi.h>
52 #include <asm/reboot.h>
53 #include <asm/portmux.h>
54 #include <asm/dpmc.h>
55
56 /*
57  * Name the Board for the /proc/cpuinfo
58  */
59 const char bfin_board_name[] = "ADI BF537-STAMP";
60
61 /*
62  *  Driver needs to know address, irq and flag pin.
63  */
64
65 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
66 #include <linux/usb/isp1760.h>
67 static struct resource bfin_isp1760_resources[] = {
68         [0] = {
69                 .start  = 0x203C0000,
70                 .end    = 0x203C0000 + 0x000fffff,
71                 .flags  = IORESOURCE_MEM,
72         },
73         [1] = {
74                 .start  = IRQ_PF7,
75                 .end    = IRQ_PF7,
76                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
77         },
78 };
79
80 static struct isp1760_platform_data isp1760_priv = {
81         .is_isp1761 = 0,
82         .port1_disable = 0,
83         .bus_width_16 = 1,
84         .port1_otg = 0,
85         .analog_oc = 0,
86         .dack_polarity_high = 0,
87         .dreq_polarity_high = 0,
88 };
89
90 static struct platform_device bfin_isp1760_device = {
91         .name           = "isp1760-hcd",
92         .id             = 0,
93         .dev = {
94                 .platform_data = &isp1760_priv,
95         },
96         .num_resources  = ARRAY_SIZE(bfin_isp1760_resources),
97         .resource       = bfin_isp1760_resources,
98 };
99 #endif
100
101 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
102 #include <linux/input.h>
103 #include <linux/gpio_keys.h>
104
105 static struct gpio_keys_button bfin_gpio_keys_table[] = {
106         {BTN_0, GPIO_PF2, 1, "gpio-keys: BTN0"},
107         {BTN_1, GPIO_PF3, 1, "gpio-keys: BTN1"},
108         {BTN_2, GPIO_PF4, 1, "gpio-keys: BTN2"},
109         {BTN_3, GPIO_PF5, 1, "gpio-keys: BTN3"},
110 };
111
112 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
113         .buttons        = bfin_gpio_keys_table,
114         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
115 };
116
117 static struct platform_device bfin_device_gpiokeys = {
118         .name      = "gpio-keys",
119         .dev = {
120                 .platform_data = &bfin_gpio_keys_data,
121         },
122 };
123 #endif
124
125 static struct resource bfin_gpios_resources = {
126         .start = 0,
127         .end   = MAX_BLACKFIN_GPIOS - 1,
128         .flags = IORESOURCE_IRQ,
129 };
130
131 static struct platform_device bfin_gpios_device = {
132         .name = "simple-gpio",
133         .id = -1,
134         .num_resources = 1,
135         .resource = &bfin_gpios_resources,
136 };
137
138 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
139 static struct resource bfin_pcmcia_cf_resources[] = {
140         {
141                 .start = 0x20310000, /* IO PORT */
142                 .end = 0x20312000,
143                 .flags = IORESOURCE_MEM,
144         }, {
145                 .start = 0x20311000, /* Attribute Memory */
146                 .end = 0x20311FFF,
147                 .flags = IORESOURCE_MEM,
148         }, {
149                 .start = IRQ_PF4,
150                 .end = IRQ_PF4,
151                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
152         }, {
153                 .start = 6, /* Card Detect PF6 */
154                 .end = 6,
155                 .flags = IORESOURCE_IRQ,
156         },
157 };
158
159 static struct platform_device bfin_pcmcia_cf_device = {
160         .name = "bfin_cf_pcmcia",
161         .id = -1,
162         .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
163         .resource = bfin_pcmcia_cf_resources,
164 };
165 #endif
166
167 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
168 static struct platform_device rtc_device = {
169         .name = "rtc-bfin",
170         .id   = -1,
171 };
172 #endif
173
174 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
175 static struct resource smc91x_resources[] = {
176         {
177                 .name = "smc91x-regs",
178                 .start = 0x20300300,
179                 .end = 0x20300300 + 16,
180                 .flags = IORESOURCE_MEM,
181         }, {
182
183                 .start = IRQ_PF7,
184                 .end = IRQ_PF7,
185                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
186         },
187 };
188 static struct platform_device smc91x_device = {
189         .name = "smc91x",
190         .id = 0,
191         .num_resources = ARRAY_SIZE(smc91x_resources),
192         .resource = smc91x_resources,
193 };
194 #endif
195
196 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
197 static struct resource dm9000_resources[] = {
198         [0] = {
199                 .start  = 0x203FB800,
200                 .end    = 0x203FB800 + 8,
201                 .flags  = IORESOURCE_MEM,
202         },
203         [1] = {
204                 .start  = IRQ_PF9,
205                 .end    = IRQ_PF9,
206                 .flags  = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
207         },
208 };
209
210 static struct platform_device dm9000_device = {
211         .name           = "dm9000",
212         .id             = -1,
213         .num_resources  = ARRAY_SIZE(dm9000_resources),
214         .resource       = dm9000_resources,
215 };
216 #endif
217
218 #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
219 static struct resource ax88180_resources[] = {
220         [0] = {
221                 .start  = 0x20300000,
222                 .end    = 0x20300000 + 0x8000,
223                 .flags  = IORESOURCE_MEM,
224         },
225         [1] = {
226                 .start  = IRQ_PF7,
227                 .end    = IRQ_PF7,
228                 .flags  = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
229         },
230 };
231
232 static struct platform_device ax88180_device = {
233         .name           = "ax88180",
234         .id             = -1,
235         .num_resources  = ARRAY_SIZE(ax88180_resources),
236         .resource       = ax88180_resources,
237 };
238 #endif
239
240 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
241 static struct resource sl811_hcd_resources[] = {
242         {
243                 .start = 0x20340000,
244                 .end = 0x20340000,
245                 .flags = IORESOURCE_MEM,
246         }, {
247                 .start = 0x20340004,
248                 .end = 0x20340004,
249                 .flags = IORESOURCE_MEM,
250         }, {
251                 .start = CONFIG_USB_SL811_BFIN_IRQ,
252                 .end = CONFIG_USB_SL811_BFIN_IRQ,
253                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
254         },
255 };
256
257 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
258 void sl811_port_power(struct device *dev, int is_on)
259 {
260         gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
261         gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
262 }
263 #endif
264
265 static struct sl811_platform_data sl811_priv = {
266         .potpg = 10,
267         .power = 250,       /* == 500mA */
268 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
269         .port_power = &sl811_port_power,
270 #endif
271 };
272
273 static struct platform_device sl811_hcd_device = {
274         .name = "sl811-hcd",
275         .id = 0,
276         .dev = {
277                 .platform_data = &sl811_priv,
278         },
279         .num_resources = ARRAY_SIZE(sl811_hcd_resources),
280         .resource = sl811_hcd_resources,
281 };
282 #endif
283
284 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
285 static struct resource isp1362_hcd_resources[] = {
286         {
287                 .start = 0x20360000,
288                 .end = 0x20360000,
289                 .flags = IORESOURCE_MEM,
290         }, {
291                 .start = 0x20360004,
292                 .end = 0x20360004,
293                 .flags = IORESOURCE_MEM,
294         }, {
295                 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
296                 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
297                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
298         },
299 };
300
301 static struct isp1362_platform_data isp1362_priv = {
302         .sel15Kres = 1,
303         .clknotstop = 0,
304         .oc_enable = 0,
305         .int_act_high = 0,
306         .int_edge_triggered = 0,
307         .remote_wakeup_connected = 0,
308         .no_power_switching = 1,
309         .power_switching_mode = 0,
310 };
311
312 static struct platform_device isp1362_hcd_device = {
313         .name = "isp1362-hcd",
314         .id = 0,
315         .dev = {
316                 .platform_data = &isp1362_priv,
317         },
318         .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
319         .resource = isp1362_hcd_resources,
320 };
321 #endif
322
323 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
324 static struct platform_device bfin_mii_bus = {
325         .name = "bfin_mii_bus",
326 };
327
328 static struct platform_device bfin_mac_device = {
329         .name = "bfin_mac",
330         .dev.platform_data = &bfin_mii_bus,
331 };
332 #endif
333
334 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
335 static struct resource net2272_bfin_resources[] = {
336         {
337                 .start = 0x20300000,
338                 .end = 0x20300000 + 0x100,
339                 .flags = IORESOURCE_MEM,
340         }, {
341                 .start = IRQ_PF7,
342                 .end = IRQ_PF7,
343                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
344         },
345 };
346
347 static struct platform_device net2272_bfin_device = {
348         .name = "net2272",
349         .id = -1,
350         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
351         .resource = net2272_bfin_resources,
352 };
353 #endif
354
355 #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
356 #ifdef CONFIG_MTD_PARTITIONS
357 const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
358
359 static struct mtd_partition bfin_plat_nand_partitions[] = {
360         {
361                 .name   = "linux kernel(nand)",
362                 .size   = 0x400000,
363                 .offset = 0,
364         }, {
365                 .name   = "file system(nand)",
366                 .size   = MTDPART_SIZ_FULL,
367                 .offset = MTDPART_OFS_APPEND,
368         },
369 };
370 #endif
371
372 #define BFIN_NAND_PLAT_CLE 2
373 #define BFIN_NAND_PLAT_ALE 1
374 static void bfin_plat_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
375 {
376         struct nand_chip *this = mtd->priv;
377
378         if (cmd == NAND_CMD_NONE)
379                 return;
380
381         if (ctrl & NAND_CLE)
382                 writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_CLE));
383         else
384                 writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_ALE));
385 }
386
387 #define BFIN_NAND_PLAT_READY GPIO_PF3
388 static int bfin_plat_nand_dev_ready(struct mtd_info *mtd)
389 {
390         return gpio_get_value(BFIN_NAND_PLAT_READY);
391 }
392
393 static struct platform_nand_data bfin_plat_nand_data = {
394         .chip = {
395                 .chip_delay = 30,
396 #ifdef CONFIG_MTD_PARTITIONS
397                 .part_probe_types = part_probes,
398                 .partitions = bfin_plat_nand_partitions,
399                 .nr_partitions = ARRAY_SIZE(bfin_plat_nand_partitions),
400 #endif
401         },
402         .ctrl = {
403                 .cmd_ctrl  = bfin_plat_nand_cmd_ctrl,
404                 .dev_ready = bfin_plat_nand_dev_ready,
405         },
406 };
407
408 #define MAX(x, y) (x > y ? x : y)
409 static struct resource bfin_plat_nand_resources = {
410         .start = 0x20212000,
411         .end   = 0x20212000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)),
412         .flags = IORESOURCE_IO,
413 };
414
415 static struct platform_device bfin_async_nand_device = {
416         .name = "gen_nand",
417         .id = -1,
418         .num_resources = 1,
419         .resource = &bfin_plat_nand_resources,
420         .dev = {
421                 .platform_data = &bfin_plat_nand_data,
422         },
423 };
424
425 static void bfin_plat_nand_init(void)
426 {
427         gpio_request(BFIN_NAND_PLAT_READY, "bfin_nand_plat");
428 }
429 #else
430 static void bfin_plat_nand_init(void) {}
431 #endif
432
433 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
434 static struct mtd_partition stamp_partitions[] = {
435         {
436                 .name       = "bootloader(nor)",
437                 .size       = 0x40000,
438                 .offset     = 0,
439         }, {
440                 .name       = "linux kernel(nor)",
441                 .size       = 0x180000,
442                 .offset     = MTDPART_OFS_APPEND,
443         }, {
444                 .name       = "file system(nor)",
445                 .size       = 0x400000 - 0x40000 - 0x180000 - 0x10000,
446                 .offset     = MTDPART_OFS_APPEND,
447         }, {
448                 .name       = "MAC Address(nor)",
449                 .size       = MTDPART_SIZ_FULL,
450                 .offset     = 0x3F0000,
451                 .mask_flags = MTD_WRITEABLE,
452         }
453 };
454
455 static struct physmap_flash_data stamp_flash_data = {
456         .width      = 2,
457         .parts      = stamp_partitions,
458         .nr_parts   = ARRAY_SIZE(stamp_partitions),
459 };
460
461 static struct resource stamp_flash_resource = {
462         .start = 0x20000000,
463         .end   = 0x203fffff,
464         .flags = IORESOURCE_MEM,
465 };
466
467 static struct platform_device stamp_flash_device = {
468         .name          = "physmap-flash",
469         .id            = 0,
470         .dev = {
471                 .platform_data = &stamp_flash_data,
472         },
473         .num_resources = 1,
474         .resource      = &stamp_flash_resource,
475 };
476 #endif
477
478 #if defined(CONFIG_MTD_M25P80) \
479         || defined(CONFIG_MTD_M25P80_MODULE)
480 static struct mtd_partition bfin_spi_flash_partitions[] = {
481         {
482                 .name = "bootloader(spi)",
483                 .size = 0x00040000,
484                 .offset = 0,
485                 .mask_flags = MTD_CAP_ROM
486         }, {
487                 .name = "linux kernel(spi)",
488                 .size = 0x180000,
489                 .offset = MTDPART_OFS_APPEND,
490         }, {
491                 .name = "file system(spi)",
492                 .size = MTDPART_SIZ_FULL,
493                 .offset = MTDPART_OFS_APPEND,
494         }
495 };
496
497 static struct flash_platform_data bfin_spi_flash_data = {
498         .name = "m25p80",
499         .parts = bfin_spi_flash_partitions,
500         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
501         /* .type = "m25p64", */
502 };
503
504 /* SPI flash chip (m25p64) */
505 static struct bfin5xx_spi_chip spi_flash_chip_info = {
506         .enable_dma = 0,         /* use dma transfer with this chip*/
507         .bits_per_word = 8,
508 };
509 #endif
510
511 #if defined(CONFIG_SPI_ADC_BF533) \
512         || defined(CONFIG_SPI_ADC_BF533_MODULE)
513 /* SPI ADC chip */
514 static struct bfin5xx_spi_chip spi_adc_chip_info = {
515         .enable_dma = 1,         /* use dma transfer with this chip*/
516         .bits_per_word = 16,
517 };
518 #endif
519
520 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
521         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
522 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
523         .enable_dma = 0,
524         .bits_per_word = 16,
525 };
526 #endif
527
528 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
529 static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
530         .enable_dma = 0,
531         .bits_per_word = 16,
532 };
533 #endif
534
535 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
536 #define MMC_SPI_CARD_DETECT_INT IRQ_PF5
537
538 static int bfin_mmc_spi_init(struct device *dev,
539         irqreturn_t (*detect_int)(int, void *), void *data)
540 {
541         return request_irq(MMC_SPI_CARD_DETECT_INT, detect_int,
542                 IRQF_TRIGGER_FALLING, "mmc-spi-detect", data);
543 }
544
545 static void bfin_mmc_spi_exit(struct device *dev, void *data)
546 {
547         free_irq(MMC_SPI_CARD_DETECT_INT, data);
548 }
549
550 static struct mmc_spi_platform_data bfin_mmc_spi_pdata = {
551         .init = bfin_mmc_spi_init,
552         .exit = bfin_mmc_spi_exit,
553         .detect_delay = 100, /* msecs */
554 };
555
556 static struct bfin5xx_spi_chip  mmc_spi_chip_info = {
557         .enable_dma = 0,
558         .bits_per_word = 8,
559 };
560 #endif
561
562 #if defined(CONFIG_PBX)
563 static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
564         .ctl_reg        = 0x4, /* send zero */
565         .enable_dma     = 0,
566         .bits_per_word  = 8,
567         .cs_change_per_word = 1,
568 };
569 #endif
570
571 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
572 #include <linux/spi/ad7877.h>
573 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
574         .enable_dma = 0,
575         .bits_per_word = 16,
576 };
577
578 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
579         .model                  = 7877,
580         .vref_delay_usecs       = 50,   /* internal, no capacitor */
581         .x_plate_ohms           = 419,
582         .y_plate_ohms           = 486,
583         .pressure_max           = 1000,
584         .pressure_min           = 0,
585         .stopacq_polarity       = 1,
586         .first_conversion_delay = 3,
587         .acquisition_time       = 1,
588         .averaging              = 1,
589         .pen_down_acc_interval  = 1,
590 };
591 #endif
592
593 #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
594 #include <linux/spi/ad7879.h>
595 static const struct ad7879_platform_data bfin_ad7879_ts_info = {
596         .model                  = 7879, /* Model = AD7879 */
597         .x_plate_ohms           = 620,  /* 620 Ohm from the touch datasheet */
598         .pressure_max           = 10000,
599         .pressure_min           = 0,
600         .first_conversion_delay = 3,    /* wait 512us before do a first conversion */
601         .acquisition_time       = 1,    /* 4us acquisition time per sample */
602         .median                 = 2,    /* do 8 measurements */
603         .averaging              = 1,    /* take the average of 4 middle samples */
604         .pen_down_acc_interval  = 255,  /* 9.4 ms */
605         .gpio_output            = 1,    /* configure AUX/VBAT/GPIO as GPIO output */
606         .gpio_default           = 1,    /* During initialization set GPIO = HIGH */
607 };
608 #endif
609
610 #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
611 static struct bfin5xx_spi_chip spi_ad7879_chip_info = {
612         .enable_dma = 0,
613         .bits_per_word = 16,
614 };
615 #endif
616
617 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
618 static struct bfin5xx_spi_chip spidev_chip_info = {
619         .enable_dma = 0,
620         .bits_per_word = 8,
621 };
622 #endif
623
624 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
625 static struct bfin5xx_spi_chip lq035q1_spi_chip_info = {
626         .enable_dma     = 0,
627         .bits_per_word  = 8,
628 };
629 #endif
630
631 #if defined(CONFIG_ENC28J60) || defined(CONFIG_ENC28J60_MODULE)
632 static struct bfin5xx_spi_chip enc28j60_spi_chip_info = {
633         .enable_dma     = 1,
634         .bits_per_word  = 8,
635         .cs_gpio = GPIO_PF10,
636 };
637 #endif
638
639 #if defined(CONFIG_MTD_DATAFLASH) \
640         || defined(CONFIG_MTD_DATAFLASH_MODULE)
641
642 static struct mtd_partition bfin_spi_dataflash_partitions[] = {
643         {
644                 .name = "bootloader(spi)",
645                 .size = 0x00040000,
646                 .offset = 0,
647                 .mask_flags = MTD_CAP_ROM
648         }, {
649                 .name = "linux kernel(spi)",
650                 .size = 0x180000,
651                 .offset = MTDPART_OFS_APPEND,
652         }, {
653                 .name = "file system(spi)",
654                 .size = MTDPART_SIZ_FULL,
655                 .offset = MTDPART_OFS_APPEND,
656         }
657 };
658
659 static struct flash_platform_data bfin_spi_dataflash_data = {
660         .name = "SPI Dataflash",
661         .parts = bfin_spi_dataflash_partitions,
662         .nr_parts = ARRAY_SIZE(bfin_spi_dataflash_partitions),
663 };
664
665 /* DataFlash chip */
666 static struct bfin5xx_spi_chip data_flash_chip_info = {
667         .enable_dma = 0,         /* use dma transfer with this chip*/
668         .bits_per_word = 8,
669 };
670 #endif
671
672 static struct spi_board_info bfin_spi_board_info[] __initdata = {
673 #if defined(CONFIG_MTD_M25P80) \
674         || defined(CONFIG_MTD_M25P80_MODULE)
675         {
676                 /* the modalias must be the same as spi device driver name */
677                 .modalias = "m25p80", /* Name of spi_driver for this device */
678                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
679                 .bus_num = 0, /* Framework bus number */
680                 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
681                 .platform_data = &bfin_spi_flash_data,
682                 .controller_data = &spi_flash_chip_info,
683                 .mode = SPI_MODE_3,
684         },
685 #endif
686 #if defined(CONFIG_MTD_DATAFLASH) \
687         || defined(CONFIG_MTD_DATAFLASH_MODULE)
688         {       /* DataFlash chip */
689                 .modalias = "mtd_dataflash",
690                 .max_speed_hz = 33250000,     /* max spi clock (SCK) speed in HZ */
691                 .bus_num = 0, /* Framework bus number */
692                 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
693                 .platform_data = &bfin_spi_dataflash_data,
694                 .controller_data = &data_flash_chip_info,
695                 .mode = SPI_MODE_3,
696         },
697 #endif
698 #if defined(CONFIG_SPI_ADC_BF533) \
699         || defined(CONFIG_SPI_ADC_BF533_MODULE)
700         {
701                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
702                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
703                 .bus_num = 0, /* Framework bus number */
704                 .chip_select = 1, /* Framework chip select. */
705                 .platform_data = NULL, /* No spi_driver specific config */
706                 .controller_data = &spi_adc_chip_info,
707         },
708 #endif
709
710 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
711         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
712         {
713                 .modalias = "ad1836-spi",
714                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
715                 .bus_num = 0,
716                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
717                 .controller_data = &ad1836_spi_chip_info,
718         },
719 #endif
720 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
721         {
722                 .modalias = "ad9960-spi",
723                 .max_speed_hz = 10000000,     /* max spi clock (SCK) speed in HZ */
724                 .bus_num = 0,
725                 .chip_select = 1,
726                 .controller_data = &ad9960_spi_chip_info,
727         },
728 #endif
729 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
730         {
731                 .modalias = "mmc_spi",
732                 .max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
733                 .bus_num = 0,
734                 .chip_select = 4,
735                 .platform_data = &bfin_mmc_spi_pdata,
736                 .controller_data = &mmc_spi_chip_info,
737                 .mode = SPI_MODE_3,
738         },
739 #endif
740 #if defined(CONFIG_PBX)
741         {
742                 .modalias = "fxs-spi",
743                 .max_speed_hz = 12500000,     /* max spi clock (SCK) speed in HZ */
744                 .bus_num = 0,
745                 .chip_select = 8 - CONFIG_J11_JUMPER,
746                 .controller_data = &spi_si3xxx_chip_info,
747                 .mode = SPI_MODE_3,
748         },
749         {
750                 .modalias = "fxo-spi",
751                 .max_speed_hz = 12500000,     /* max spi clock (SCK) speed in HZ */
752                 .bus_num = 0,
753                 .chip_select = 8 - CONFIG_J19_JUMPER,
754                 .controller_data = &spi_si3xxx_chip_info,
755                 .mode = SPI_MODE_3,
756         },
757 #endif
758 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
759         {
760                 .modalias               = "ad7877",
761                 .platform_data          = &bfin_ad7877_ts_info,
762                 .irq                    = IRQ_PF6,
763                 .max_speed_hz   = 12500000,     /* max spi clock (SCK) speed in HZ */
764                 .bus_num        = 0,
765                 .chip_select  = 1,
766                 .controller_data = &spi_ad7877_chip_info,
767         },
768 #endif
769 #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
770         {
771                 .modalias = "ad7879",
772                 .platform_data = &bfin_ad7879_ts_info,
773                 .irq = IRQ_PF7,
774                 .max_speed_hz = 5000000,     /* max spi clock (SCK) speed in HZ */
775                 .bus_num = 0,
776                 .chip_select = 1,
777                 .controller_data = &spi_ad7879_chip_info,
778                 .mode = SPI_CPHA | SPI_CPOL,
779         },
780 #endif
781 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
782         {
783                 .modalias = "spidev",
784                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
785                 .bus_num = 0,
786                 .chip_select = 1,
787                 .controller_data = &spidev_chip_info,
788         },
789 #endif
790 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
791         {
792                 .modalias = "bfin-lq035q1-spi",
793                 .max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
794                 .bus_num = 0,
795                 .chip_select = 2,
796                 .controller_data = &lq035q1_spi_chip_info,
797                 .mode = SPI_CPHA | SPI_CPOL,
798         },
799 #endif
800 #if defined(CONFIG_ENC28J60) || defined(CONFIG_ENC28J60_MODULE)
801         {
802                 .modalias = "enc28j60",
803                 .max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
804                 .irq = IRQ_PF6,
805                 .bus_num = 0,
806                 .chip_select = 0,       /* GPIO controlled SSEL */
807                 .controller_data = &enc28j60_spi_chip_info,
808                 .mode = SPI_MODE_0,
809         },
810 #endif
811 };
812
813 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
814 /* SPI controller data */
815 static struct bfin5xx_spi_master bfin_spi0_info = {
816         .num_chipselect = 8,
817         .enable_dma = 1,  /* master has the ability to do dma transfer */
818         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
819 };
820
821 /* SPI (0) */
822 static struct resource bfin_spi0_resource[] = {
823         [0] = {
824                 .start = SPI0_REGBASE,
825                 .end   = SPI0_REGBASE + 0xFF,
826                 .flags = IORESOURCE_MEM,
827                 },
828         [1] = {
829                 .start = CH_SPI,
830                 .end   = CH_SPI,
831                 .flags = IORESOURCE_IRQ,
832         },
833 };
834
835 static struct platform_device bfin_spi0_device = {
836         .name = "bfin-spi",
837         .id = 0, /* Bus number */
838         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
839         .resource = bfin_spi0_resource,
840         .dev = {
841                 .platform_data = &bfin_spi0_info, /* Passed to driver */
842         },
843 };
844 #endif  /* spi master and devices */
845
846 #if defined(CONFIG_SPI_BFIN_SPORT) || defined(CONFIG_SPI_BFIN_SPORT_MODULE)
847
848 /* SPORT SPI controller data */
849 static struct bfin5xx_spi_master bfin_sport_spi0_info = {
850         .num_chipselect = 1, /* master only supports one device */
851         .enable_dma = 0,  /* master don't support DMA */
852         .pin_req = {P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_DRPRI,
853                 P_SPORT0_RSCLK, P_SPORT0_TFS, P_SPORT0_RFS, 0},
854 };
855
856 static struct resource bfin_sport_spi0_resource[] = {
857         [0] = {
858                 .start = SPORT0_TCR1,
859                 .end   = SPORT0_TCR1 + 0xFF,
860                 .flags = IORESOURCE_MEM,
861                 },
862         [1] = {
863                 .start = IRQ_SPORT0_ERROR,
864                 .end   = IRQ_SPORT0_ERROR,
865                 .flags = IORESOURCE_IRQ,
866                 },
867 };
868
869 static struct platform_device bfin_sport_spi0_device = {
870         .name = "bfin-sport-spi",
871         .id = 1, /* Bus number */
872         .num_resources = ARRAY_SIZE(bfin_sport_spi0_resource),
873         .resource = bfin_sport_spi0_resource,
874         .dev = {
875                 .platform_data = &bfin_sport_spi0_info, /* Passed to driver */
876         },
877 };
878
879 static struct bfin5xx_spi_master bfin_sport_spi1_info = {
880         .num_chipselect = 1, /* master only supports one device */
881         .enable_dma = 0,  /* master don't support DMA */
882         .pin_req = {P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_DRPRI,
883                 P_SPORT1_RSCLK, P_SPORT1_TFS, P_SPORT1_RFS, 0},
884 };
885
886 static struct resource bfin_sport_spi1_resource[] = {
887         [0] = {
888                 .start = SPORT1_TCR1,
889                 .end   = SPORT1_TCR1 + 0xFF,
890                 .flags = IORESOURCE_MEM,
891                 },
892         [1] = {
893                 .start = IRQ_SPORT1_ERROR,
894                 .end   = IRQ_SPORT1_ERROR,
895                 .flags = IORESOURCE_IRQ,
896                 },
897 };
898
899 static struct platform_device bfin_sport_spi1_device = {
900         .name = "bfin-sport-spi",
901         .id = 2, /* Bus number */
902         .num_resources = ARRAY_SIZE(bfin_sport_spi1_resource),
903         .resource = bfin_sport_spi1_resource,
904         .dev = {
905                 .platform_data = &bfin_sport_spi1_info, /* Passed to driver */
906         },
907 };
908
909 #endif  /* sport spi master and devices */
910
911 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
912 static struct platform_device bfin_fb_device = {
913         .name = "bf537-lq035",
914 };
915 #endif
916
917 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
918 static struct platform_device bfin_fb_adv7393_device = {
919         .name = "bfin-adv7393",
920 };
921 #endif
922
923 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
924 #include <asm/bfin-lq035q1.h>
925
926 static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
927         .mode =         LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
928         .use_bl =       0,      /* let something else control the LCD Blacklight */
929         .gpio_bl =      GPIO_PF7,
930 };
931
932 static struct resource bfin_lq035q1_resources[] = {
933         {
934                 .start = IRQ_PPI_ERROR,
935                 .end = IRQ_PPI_ERROR,
936                 .flags = IORESOURCE_IRQ,
937         },
938 };
939
940 static struct platform_device bfin_lq035q1_device = {
941         .name           = "bfin-lq035q1",
942         .id             = -1,
943         .num_resources  = ARRAY_SIZE(bfin_lq035q1_resources),
944         .resource       = bfin_lq035q1_resources,
945         .dev            = {
946                 .platform_data = &bfin_lq035q1_data,
947         },
948 };
949 #endif
950
951 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
952 static struct resource bfin_uart_resources[] = {
953 #ifdef CONFIG_SERIAL_BFIN_UART0
954         {
955                 .start = 0xFFC00400,
956                 .end = 0xFFC004FF,
957                 .flags = IORESOURCE_MEM,
958         },
959 #endif
960 #ifdef CONFIG_SERIAL_BFIN_UART1
961         {
962                 .start = 0xFFC02000,
963                 .end = 0xFFC020FF,
964                 .flags = IORESOURCE_MEM,
965         },
966 #endif
967 };
968
969 static struct platform_device bfin_uart_device = {
970         .name = "bfin-uart",
971         .id = 1,
972         .num_resources = ARRAY_SIZE(bfin_uart_resources),
973         .resource = bfin_uart_resources,
974 };
975 #endif
976
977 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
978 #ifdef CONFIG_BFIN_SIR0
979 static struct resource bfin_sir0_resources[] = {
980         {
981                 .start = 0xFFC00400,
982                 .end = 0xFFC004FF,
983                 .flags = IORESOURCE_MEM,
984         },
985         {
986                 .start = IRQ_UART0_RX,
987                 .end = IRQ_UART0_RX+1,
988                 .flags = IORESOURCE_IRQ,
989         },
990         {
991                 .start = CH_UART0_RX,
992                 .end = CH_UART0_RX+1,
993                 .flags = IORESOURCE_DMA,
994         },
995 };
996
997 static struct platform_device bfin_sir0_device = {
998         .name = "bfin_sir",
999         .id = 0,
1000         .num_resources = ARRAY_SIZE(bfin_sir0_resources),
1001         .resource = bfin_sir0_resources,
1002 };
1003 #endif
1004 #ifdef CONFIG_BFIN_SIR1
1005 static struct resource bfin_sir1_resources[] = {
1006         {
1007                 .start = 0xFFC02000,
1008                 .end = 0xFFC020FF,
1009                 .flags = IORESOURCE_MEM,
1010         },
1011         {
1012                 .start = IRQ_UART1_RX,
1013                 .end = IRQ_UART1_RX+1,
1014                 .flags = IORESOURCE_IRQ,
1015         },
1016         {
1017                 .start = CH_UART1_RX,
1018                 .end = CH_UART1_RX+1,
1019                 .flags = IORESOURCE_DMA,
1020         },
1021 };
1022
1023 static struct platform_device bfin_sir1_device = {
1024         .name = "bfin_sir",
1025         .id = 1,
1026         .num_resources = ARRAY_SIZE(bfin_sir1_resources),
1027         .resource = bfin_sir1_resources,
1028 };
1029 #endif
1030 #endif
1031
1032 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
1033 static struct resource bfin_twi0_resource[] = {
1034         [0] = {
1035                 .start = TWI0_REGBASE,
1036                 .end   = TWI0_REGBASE,
1037                 .flags = IORESOURCE_MEM,
1038         },
1039         [1] = {
1040                 .start = IRQ_TWI,
1041                 .end   = IRQ_TWI,
1042                 .flags = IORESOURCE_IRQ,
1043         },
1044 };
1045
1046 static struct platform_device i2c_bfin_twi_device = {
1047         .name = "i2c-bfin-twi",
1048         .id = 0,
1049         .num_resources = ARRAY_SIZE(bfin_twi0_resource),
1050         .resource = bfin_twi0_resource,
1051 };
1052 #endif
1053
1054 #if defined(CONFIG_KEYBOARD_ADP5588) || defined(CONFIG_KEYBOARD_ADP5588_MODULE)
1055 #include <linux/input.h>
1056 #include <linux/i2c/adp5588_keys.h>
1057 static const unsigned short adp5588_keymap[ADP5588_KEYMAPSIZE] = {
1058         [0]      = KEY_GRAVE,
1059         [1]      = KEY_1,
1060         [2]      = KEY_2,
1061         [3]      = KEY_3,
1062         [4]      = KEY_4,
1063         [5]      = KEY_5,
1064         [6]      = KEY_6,
1065         [7]      = KEY_7,
1066         [8]      = KEY_8,
1067         [9]      = KEY_9,
1068         [10]     = KEY_0,
1069         [11]     = KEY_MINUS,
1070         [12]     = KEY_EQUAL,
1071         [13]     = KEY_BACKSLASH,
1072         [15]     = KEY_KP0,
1073         [16]     = KEY_Q,
1074         [17]     = KEY_W,
1075         [18]     = KEY_E,
1076         [19]     = KEY_R,
1077         [20]     = KEY_T,
1078         [21]     = KEY_Y,
1079         [22]     = KEY_U,
1080         [23]     = KEY_I,
1081         [24]     = KEY_O,
1082         [25]     = KEY_P,
1083         [26]     = KEY_LEFTBRACE,
1084         [27]     = KEY_RIGHTBRACE,
1085         [29]     = KEY_KP1,
1086         [30]     = KEY_KP2,
1087         [31]     = KEY_KP3,
1088         [32]     = KEY_A,
1089         [33]     = KEY_S,
1090         [34]     = KEY_D,
1091         [35]     = KEY_F,
1092         [36]     = KEY_G,
1093         [37]     = KEY_H,
1094         [38]     = KEY_J,
1095         [39]     = KEY_K,
1096         [40]     = KEY_L,
1097         [41]     = KEY_SEMICOLON,
1098         [42]     = KEY_APOSTROPHE,
1099         [43]     = KEY_BACKSLASH,
1100         [45]     = KEY_KP4,
1101         [46]     = KEY_KP5,
1102         [47]     = KEY_KP6,
1103         [48]     = KEY_102ND,
1104         [49]     = KEY_Z,
1105         [50]     = KEY_X,
1106         [51]     = KEY_C,
1107         [52]     = KEY_V,
1108         [53]     = KEY_B,
1109         [54]     = KEY_N,
1110         [55]     = KEY_M,
1111         [56]     = KEY_COMMA,
1112         [57]     = KEY_DOT,
1113         [58]     = KEY_SLASH,
1114         [60]     = KEY_KPDOT,
1115         [61]     = KEY_KP7,
1116         [62]     = KEY_KP8,
1117         [63]     = KEY_KP9,
1118         [64]     = KEY_SPACE,
1119         [65]     = KEY_BACKSPACE,
1120         [66]     = KEY_TAB,
1121         [67]     = KEY_KPENTER,
1122         [68]     = KEY_ENTER,
1123         [69]     = KEY_ESC,
1124         [70]     = KEY_DELETE,
1125         [74]     = KEY_KPMINUS,
1126         [76]     = KEY_UP,
1127         [77]     = KEY_DOWN,
1128         [78]     = KEY_RIGHT,
1129         [79]     = KEY_LEFT,
1130 };
1131
1132 static struct adp5588_kpad_platform_data adp5588_kpad_data = {
1133         .rows           = 8,
1134         .cols           = 10,
1135         .keymap         = adp5588_keymap,
1136         .keymapsize     = ARRAY_SIZE(adp5588_keymap),
1137         .repeat         = 0,
1138 };
1139 #endif
1140
1141 #if defined(CONFIG_PMIC_ADP5520) || defined(CONFIG_PMIC_ADP5520_MODULE)
1142 #include <linux/mfd/adp5520.h>
1143
1144         /*
1145          *  ADP5520/5501 Backlight Data
1146          */
1147
1148 static struct adp5520_backlight_platfrom_data adp5520_backlight_data = {
1149         .fade_in                = FADE_T_1200ms,
1150         .fade_out               = FADE_T_1200ms,
1151         .fade_led_law           = BL_LAW_LINEAR,
1152         .en_ambl_sens           = 1,
1153         .abml_filt              = BL_AMBL_FILT_640ms,
1154         .l1_daylight_max        = BL_CUR_mA(15),
1155         .l1_daylight_dim        = BL_CUR_mA(0),
1156         .l2_office_max          = BL_CUR_mA(7),
1157         .l2_office_dim          = BL_CUR_mA(0),
1158         .l3_dark_max            = BL_CUR_mA(3),
1159         .l3_dark_dim            = BL_CUR_mA(0),
1160         .l2_trip                = L2_COMP_CURR_uA(700),
1161         .l2_hyst                = L2_COMP_CURR_uA(50),
1162         .l3_trip                = L3_COMP_CURR_uA(80),
1163         .l3_hyst                = L3_COMP_CURR_uA(20),
1164 };
1165
1166         /*
1167          *  ADP5520/5501 LEDs Data
1168          */
1169
1170 #include <linux/leds.h>
1171
1172 static struct led_info adp5520_leds[] = {
1173         {
1174                 .name = "adp5520-led1",
1175                 .default_trigger = "none",
1176                 .flags = FLAG_ID_ADP5520_LED1_ADP5501_LED0 | LED_OFFT_600ms,
1177         },
1178 #ifdef ADP5520_EN_ALL_LEDS
1179         {
1180                 .name = "adp5520-led2",
1181                 .default_trigger = "none",
1182                 .flags = FLAG_ID_ADP5520_LED2_ADP5501_LED1,
1183         },
1184         {
1185                 .name = "adp5520-led3",
1186                 .default_trigger = "none",
1187                 .flags = FLAG_ID_ADP5520_LED3_ADP5501_LED2,
1188         },
1189 #endif
1190 };
1191
1192 static struct adp5520_leds_platfrom_data adp5520_leds_data = {
1193         .num_leds = ARRAY_SIZE(adp5520_leds),
1194         .leds = adp5520_leds,
1195         .fade_in = FADE_T_600ms,
1196         .fade_out = FADE_T_600ms,
1197         .led_on_time = LED_ONT_600ms,
1198 };
1199
1200         /*
1201          *  ADP5520 GPIO Data
1202          */
1203
1204 static struct adp5520_gpio_platfrom_data adp5520_gpio_data = {
1205         .gpio_start = 50,
1206         .gpio_en_mask = GPIO_C1 | GPIO_C2 | GPIO_R2,
1207         .gpio_pullup_mask = GPIO_C1 | GPIO_C2 | GPIO_R2,
1208 };
1209
1210         /*
1211          *  ADP5520 Keypad Data
1212          */
1213
1214 #include <linux/input.h>
1215 static const unsigned short adp5520_keymap[ADP5520_KEYMAPSIZE] = {
1216         [KEY(0, 0)]     = KEY_GRAVE,
1217         [KEY(0, 1)]     = KEY_1,
1218         [KEY(0, 2)]     = KEY_2,
1219         [KEY(0, 3)]     = KEY_3,
1220         [KEY(1, 0)]     = KEY_4,
1221         [KEY(1, 1)]     = KEY_5,
1222         [KEY(1, 2)]     = KEY_6,
1223         [KEY(1, 3)]     = KEY_7,
1224         [KEY(2, 0)]     = KEY_8,
1225         [KEY(2, 1)]     = KEY_9,
1226         [KEY(2, 2)]     = KEY_0,
1227         [KEY(2, 3)]     = KEY_MINUS,
1228         [KEY(3, 0)]     = KEY_EQUAL,
1229         [KEY(3, 1)]     = KEY_BACKSLASH,
1230         [KEY(3, 2)]     = KEY_BACKSPACE,
1231         [KEY(3, 3)]     = KEY_ENTER,
1232 };
1233
1234 static struct adp5520_keys_platfrom_data adp5520_keys_data = {
1235         .rows_en_mask   = ROW_R3 | ROW_R2 | ROW_R1 | ROW_R0,
1236         .cols_en_mask   = COL_C3 | COL_C2 | COL_C1 | COL_C0,
1237         .keymap         = adp5520_keymap,
1238         .keymapsize     = ARRAY_SIZE(adp5520_keymap),
1239         .repeat         = 0,
1240 };
1241
1242         /*
1243          *  ADP5520/5501 Multifuction Device Init Data
1244          */
1245
1246 static struct adp5520_subdev_info adp5520_subdevs[] = {
1247         {
1248                 .name = "adp5520-backlight",
1249                 .id = ID_ADP5520,
1250                 .platform_data = &adp5520_backlight_data,
1251         },
1252         {
1253                 .name = "adp5520-led",
1254                 .id = ID_ADP5520,
1255                 .platform_data = &adp5520_leds_data,
1256         },
1257         {
1258                 .name = "adp5520-gpio",
1259                 .id = ID_ADP5520,
1260                 .platform_data = &adp5520_gpio_data,
1261         },
1262         {
1263                 .name = "adp5520-keys",
1264                 .id = ID_ADP5520,
1265                 .platform_data = &adp5520_keys_data,
1266         },
1267 };
1268
1269 static struct adp5520_platform_data adp5520_pdev_data = {
1270         .num_subdevs = ARRAY_SIZE(adp5520_subdevs),
1271         .subdevs = adp5520_subdevs,
1272 };
1273
1274 #endif
1275
1276 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
1277 #if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE)
1278         {
1279                 I2C_BOARD_INFO("ad7142_joystick", 0x2C),
1280                 .irq = IRQ_PF5,
1281         },
1282 #endif
1283 #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
1284         {
1285                 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
1286         },
1287 #endif
1288 #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
1289         {
1290                 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
1291                 .irq = IRQ_PG6,
1292         },
1293 #endif
1294 #if defined(CONFIG_TOUCHSCREEN_AD7879_I2C) || defined(CONFIG_TOUCHSCREEN_AD7879_I2C_MODULE)
1295         {
1296                 I2C_BOARD_INFO("ad7879", 0x2F),
1297                 .irq = IRQ_PG5,
1298                 .platform_data = (void *)&bfin_ad7879_ts_info,
1299         },
1300 #endif
1301 #if defined(CONFIG_KEYBOARD_ADP5588) || defined(CONFIG_KEYBOARD_ADP5588_MODULE)
1302         {
1303                 I2C_BOARD_INFO("adp5588-keys", 0x34),
1304                 .irq = IRQ_PG0,
1305                 .platform_data = (void *)&adp5588_kpad_data,
1306         },
1307 #endif
1308 #if defined(CONFIG_PMIC_ADP5520) || defined(CONFIG_PMIC_ADP5520_MODULE)
1309         {
1310                 I2C_BOARD_INFO("pmic-adp5520", 0x32),
1311                 .irq = IRQ_PF7,
1312                 .platform_data = (void *)&adp5520_pdev_data,
1313         },
1314 #endif
1315 };
1316
1317 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
1318 static struct platform_device bfin_sport0_uart_device = {
1319         .name = "bfin-sport-uart",
1320         .id = 0,
1321 };
1322
1323 static struct platform_device bfin_sport1_uart_device = {
1324         .name = "bfin-sport-uart",
1325         .id = 1,
1326 };
1327 #endif
1328
1329 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
1330 #define CF_IDE_NAND_CARD_USE_HDD_INTERFACE
1331 /* #define CF_IDE_NAND_CARD_USE_CF_IN_COMMON_MEMORY_MODE */
1332
1333 #ifdef CF_IDE_NAND_CARD_USE_HDD_INTERFACE
1334 #define PATA_INT        IRQ_PF5
1335 static struct pata_platform_info bfin_pata_platform_data = {
1336         .ioport_shift = 1,
1337         .irq_flags = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
1338 };
1339
1340 static struct resource bfin_pata_resources[] = {
1341         {
1342                 .start = 0x20314020,
1343                 .end = 0x2031403F,
1344                 .flags = IORESOURCE_MEM,
1345         },
1346         {
1347                 .start = 0x2031401C,
1348                 .end = 0x2031401F,
1349                 .flags = IORESOURCE_MEM,
1350         },
1351         {
1352                 .start = PATA_INT,
1353                 .end = PATA_INT,
1354                 .flags = IORESOURCE_IRQ,
1355         },
1356 };
1357 #elif defined(CF_IDE_NAND_CARD_USE_CF_IN_COMMON_MEMORY_MODE)
1358 static struct pata_platform_info bfin_pata_platform_data = {
1359         .ioport_shift = 0,
1360 };
1361
1362 static struct resource bfin_pata_resources[] = {
1363         {
1364                 .start = 0x20211820,
1365                 .end = 0x2021183F,
1366                 .flags = IORESOURCE_MEM,
1367         },
1368         {
1369                 .start = 0x2021181C,
1370                 .end = 0x2021181F,
1371                 .flags = IORESOURCE_MEM,
1372         },
1373 };
1374 #endif
1375
1376 static struct platform_device bfin_pata_device = {
1377         .name = "pata_platform",
1378         .id = -1,
1379         .num_resources = ARRAY_SIZE(bfin_pata_resources),
1380         .resource = bfin_pata_resources,
1381         .dev = {
1382                 .platform_data = &bfin_pata_platform_data,
1383         }
1384 };
1385 #endif
1386
1387 static const unsigned int cclk_vlev_datasheet[] =
1388 {
1389         VRPAIR(VLEV_085, 250000000),
1390         VRPAIR(VLEV_090, 376000000),
1391         VRPAIR(VLEV_095, 426000000),
1392         VRPAIR(VLEV_100, 426000000),
1393         VRPAIR(VLEV_105, 476000000),
1394         VRPAIR(VLEV_110, 476000000),
1395         VRPAIR(VLEV_115, 476000000),
1396         VRPAIR(VLEV_120, 500000000),
1397         VRPAIR(VLEV_125, 533000000),
1398         VRPAIR(VLEV_130, 600000000),
1399 };
1400
1401 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
1402         .tuple_tab = cclk_vlev_datasheet,
1403         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
1404         .vr_settling_time = 25 /* us */,
1405 };
1406
1407 static struct platform_device bfin_dpmc = {
1408         .name = "bfin dpmc",
1409         .dev = {
1410                 .platform_data = &bfin_dmpc_vreg_data,
1411         },
1412 };
1413
1414 static struct platform_device *stamp_devices[] __initdata = {
1415
1416         &bfin_dpmc,
1417
1418 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
1419         &bfin_pcmcia_cf_device,
1420 #endif
1421
1422 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
1423         &rtc_device,
1424 #endif
1425
1426 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
1427         &sl811_hcd_device,
1428 #endif
1429
1430 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
1431         &isp1362_hcd_device,
1432 #endif
1433
1434 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
1435         &bfin_isp1760_device,
1436 #endif
1437
1438 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
1439         &smc91x_device,
1440 #endif
1441
1442 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
1443         &dm9000_device,
1444 #endif
1445
1446 #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
1447         &ax88180_device,
1448 #endif
1449
1450 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
1451         &bfin_mii_bus,
1452         &bfin_mac_device,
1453 #endif
1454
1455 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
1456         &net2272_bfin_device,
1457 #endif
1458
1459 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
1460         &bfin_spi0_device,
1461 #endif
1462
1463 #if defined(CONFIG_SPI_BFIN_SPORT) || defined(CONFIG_SPI_BFIN_SPORT_MODULE)
1464         &bfin_sport_spi0_device,
1465         &bfin_sport_spi1_device,
1466 #endif
1467
1468 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
1469         &bfin_fb_device,
1470 #endif
1471
1472 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
1473         &bfin_lq035q1_device,
1474 #endif
1475
1476 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
1477         &bfin_fb_adv7393_device,
1478 #endif
1479
1480 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
1481         &bfin_uart_device,
1482 #endif
1483
1484 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
1485 #ifdef CONFIG_BFIN_SIR0
1486         &bfin_sir0_device,
1487 #endif
1488 #ifdef CONFIG_BFIN_SIR1
1489         &bfin_sir1_device,
1490 #endif
1491 #endif
1492
1493 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
1494         &i2c_bfin_twi_device,
1495 #endif
1496
1497 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
1498         &bfin_sport0_uart_device,
1499         &bfin_sport1_uart_device,
1500 #endif
1501
1502 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
1503         &bfin_pata_device,
1504 #endif
1505
1506 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
1507         &bfin_device_gpiokeys,
1508 #endif
1509
1510         &bfin_gpios_device,
1511
1512 #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
1513         &bfin_async_nand_device,
1514 #endif
1515
1516 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
1517         &stamp_flash_device,
1518 #endif
1519 };
1520
1521 static int __init stamp_init(void)
1522 {
1523         printk(KERN_INFO "%s(): registering device resources\n", __func__);
1524         i2c_register_board_info(0, bfin_i2c_board_info,
1525                                 ARRAY_SIZE(bfin_i2c_board_info));
1526         bfin_plat_nand_init();
1527         platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
1528         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
1529
1530 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
1531         irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
1532 #endif
1533
1534         return 0;
1535 }
1536
1537 arch_initcall(stamp_init);
1538
1539 void native_machine_restart(char *cmd)
1540 {
1541         /* workaround reboot hang when booting from SPI */
1542         if ((bfin_read_SYSCR() & 0x7) == 0x3)
1543                 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
1544 }
1545
1546 /*
1547  * Currently the MAC address is saved in Flash by U-Boot
1548  */
1549 #define FLASH_MAC       0x203f0000
1550 void bfin_get_ether_addr(char *addr)
1551 {
1552         *(u32 *)(&(addr[0])) = bfin_read32(FLASH_MAC);
1553         *(u16 *)(&(addr[4])) = bfin_read16(FLASH_MAC + 4);
1554 }
1555 EXPORT_SYMBOL(bfin_get_ether_addr);