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