Merge branch 'topic/azt3328' into for-linus
[pandora-kernel.git] / arch / blackfin / mach-bf527 / boards / cm_bf527.c
1 /*
2  * File:         arch/blackfin/mach-bf527/boards/cm-bf527.c
3  * Based on:     arch/blackfin/mach-bf537/boards/stamp.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-2008 Analog Devices Inc.
12  *
13  * Bugs:         Enter bugs at http://blackfin.uclinux.org/
14  *
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 2 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, see the file COPYING, or write
27  * to the Free Software Foundation, Inc.,
28  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
29  */
30
31 #include <linux/device.h>
32 #include <linux/platform_device.h>
33 #include <linux/mtd/mtd.h>
34 #include <linux/mtd/partitions.h>
35 #include <linux/mtd/physmap.h>
36 #include <linux/spi/spi.h>
37 #include <linux/spi/flash.h>
38 #include <linux/etherdevice.h>
39 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
40 #include <linux/usb/isp1362.h>
41 #endif
42 #include <linux/i2c.h>
43 #include <linux/irq.h>
44 #include <linux/interrupt.h>
45 #include <linux/usb/sl811.h>
46 #include <linux/usb/musb.h>
47 #include <asm/dma.h>
48 #include <asm/bfin5xx_spi.h>
49 #include <asm/reboot.h>
50 #include <asm/nand.h>
51 #include <asm/portmux.h>
52 #include <asm/dpmc.h>
53 #include <linux/spi/ad7877.h>
54
55 /*
56  * Name the Board for the /proc/cpuinfo
57  */
58 const char bfin_board_name[] = "Bluetechnix CM-BF527";
59
60 /*
61  *  Driver needs to know address, irq and flag pin.
62  */
63
64 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
65 #include <linux/usb/isp1760.h>
66 static struct resource bfin_isp1760_resources[] = {
67         [0] = {
68                 .start  = 0x203C0000,
69                 .end    = 0x203C0000 + 0x000fffff,
70                 .flags  = IORESOURCE_MEM,
71         },
72         [1] = {
73                 .start  = IRQ_PF7,
74                 .end    = IRQ_PF7,
75                 .flags  = IORESOURCE_IRQ,
76         },
77 };
78
79 static struct isp1760_platform_data isp1760_priv = {
80         .is_isp1761 = 0,
81         .bus_width_16 = 1,
82         .port1_otg = 0,
83         .analog_oc = 0,
84         .dack_polarity_high = 0,
85         .dreq_polarity_high = 0,
86 };
87
88 static struct platform_device bfin_isp1760_device = {
89         .name           = "isp1760-hcd",
90         .id             = 0,
91         .dev = {
92                 .platform_data = &isp1760_priv,
93         },
94         .num_resources  = ARRAY_SIZE(bfin_isp1760_resources),
95         .resource       = bfin_isp1760_resources,
96 };
97 #endif
98
99 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
100 static struct resource musb_resources[] = {
101         [0] = {
102                 .start  = 0xffc03800,
103                 .end    = 0xffc03cff,
104                 .flags  = IORESOURCE_MEM,
105         },
106         [1] = { /* general IRQ */
107                 .start  = IRQ_USB_INT0,
108                 .end    = IRQ_USB_INT0,
109                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
110         },
111         [2] = { /* DMA IRQ */
112                 .start  = IRQ_USB_DMA,
113                 .end    = IRQ_USB_DMA,
114                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
115         },
116 };
117
118 static struct musb_hdrc_config musb_config = {
119         .multipoint     = 0,
120         .dyn_fifo       = 0,
121         .soft_con       = 1,
122         .dma            = 1,
123         .num_eps        = 8,
124         .dma_channels   = 8,
125         .gpio_vrsel     = GPIO_PF11,
126 };
127
128 static struct musb_hdrc_platform_data musb_plat = {
129 #if defined(CONFIG_USB_MUSB_OTG)
130         .mode           = MUSB_OTG,
131 #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
132         .mode           = MUSB_HOST,
133 #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
134         .mode           = MUSB_PERIPHERAL,
135 #endif
136         .config         = &musb_config,
137 };
138
139 static u64 musb_dmamask = ~(u32)0;
140
141 static struct platform_device musb_device = {
142         .name           = "musb_hdrc",
143         .id             = 0,
144         .dev = {
145                 .dma_mask               = &musb_dmamask,
146                 .coherent_dma_mask      = 0xffffffff,
147                 .platform_data          = &musb_plat,
148         },
149         .num_resources  = ARRAY_SIZE(musb_resources),
150         .resource       = musb_resources,
151 };
152 #endif
153
154 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
155 static struct mtd_partition ezkit_partitions[] = {
156         {
157                 .name       = "bootloader(nor)",
158                 .size       = 0x40000,
159                 .offset     = 0,
160         }, {
161                 .name       = "linux kernel(nor)",
162                 .size       = 0x1C0000,
163                 .offset     = MTDPART_OFS_APPEND,
164         }, {
165                 .name       = "file system(nor)",
166                 .size       = MTDPART_SIZ_FULL,
167                 .offset     = MTDPART_OFS_APPEND,
168         }
169 };
170
171 static struct physmap_flash_data ezkit_flash_data = {
172         .width      = 2,
173         .parts      = ezkit_partitions,
174         .nr_parts   = ARRAY_SIZE(ezkit_partitions),
175 };
176
177 static struct resource ezkit_flash_resource = {
178         .start = 0x20000000,
179         .end   = 0x201fffff,
180         .flags = IORESOURCE_MEM,
181 };
182
183 static struct platform_device ezkit_flash_device = {
184         .name          = "physmap-flash",
185         .id            = 0,
186         .dev = {
187                 .platform_data = &ezkit_flash_data,
188         },
189         .num_resources = 1,
190         .resource      = &ezkit_flash_resource,
191 };
192 #endif
193
194 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
195 static struct mtd_partition partition_info[] = {
196         {
197                 .name = "linux kernel(nand)",
198                 .offset = 0,
199                 .size = 4 * 1024 * 1024,
200         },
201         {
202                 .name = "file system(nand)",
203                 .offset = MTDPART_OFS_APPEND,
204                 .size = MTDPART_SIZ_FULL,
205         },
206 };
207
208 static struct bf5xx_nand_platform bf5xx_nand_platform = {
209         .page_size = NFC_PG_SIZE_256,
210         .data_width = NFC_NWIDTH_8,
211         .partitions = partition_info,
212         .nr_partitions = ARRAY_SIZE(partition_info),
213         .rd_dly = 3,
214         .wr_dly = 3,
215 };
216
217 static struct resource bf5xx_nand_resources[] = {
218         {
219                 .start = NFC_CTL,
220                 .end = NFC_DATA_RD + 2,
221                 .flags = IORESOURCE_MEM,
222         },
223         {
224                 .start = CH_NFC,
225                 .end = CH_NFC,
226                 .flags = IORESOURCE_IRQ,
227         },
228 };
229
230 static struct platform_device bf5xx_nand_device = {
231         .name = "bf5xx-nand",
232         .id = 0,
233         .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
234         .resource = bf5xx_nand_resources,
235         .dev = {
236                 .platform_data = &bf5xx_nand_platform,
237         },
238 };
239 #endif
240
241 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
242 static struct resource bfin_pcmcia_cf_resources[] = {
243         {
244                 .start = 0x20310000, /* IO PORT */
245                 .end = 0x20312000,
246                 .flags = IORESOURCE_MEM,
247         }, {
248                 .start = 0x20311000, /* Attribute Memory */
249                 .end = 0x20311FFF,
250                 .flags = IORESOURCE_MEM,
251         }, {
252                 .start = IRQ_PF4,
253                 .end = IRQ_PF4,
254                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
255         }, {
256                 .start = 6, /* Card Detect PF6 */
257                 .end = 6,
258                 .flags = IORESOURCE_IRQ,
259         },
260 };
261
262 static struct platform_device bfin_pcmcia_cf_device = {
263         .name = "bfin_cf_pcmcia",
264         .id = -1,
265         .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
266         .resource = bfin_pcmcia_cf_resources,
267 };
268 #endif
269
270 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
271 static struct platform_device rtc_device = {
272         .name = "rtc-bfin",
273         .id   = -1,
274 };
275 #endif
276
277 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
278 static struct resource smc91x_resources[] = {
279         {
280                 .name = "smc91x-regs",
281                 .start = 0x20300300,
282                 .end = 0x20300300 + 16,
283                 .flags = IORESOURCE_MEM,
284         }, {
285
286                 .start = IRQ_PF7,
287                 .end = IRQ_PF7,
288                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
289         },
290 };
291 static struct platform_device smc91x_device = {
292         .name = "smc91x",
293         .id = 0,
294         .num_resources = ARRAY_SIZE(smc91x_resources),
295         .resource = smc91x_resources,
296 };
297 #endif
298
299 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
300 static struct resource dm9000_resources[] = {
301         [0] = {
302                 .start  = 0x203FB800,
303                 .end    = 0x203FB800 + 8,
304                 .flags  = IORESOURCE_MEM,
305         },
306         [1] = {
307                 .start  = IRQ_PF9,
308                 .end    = IRQ_PF9,
309                 .flags  = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
310         },
311 };
312
313 static struct platform_device dm9000_device = {
314         .name           = "dm9000",
315         .id             = -1,
316         .num_resources  = ARRAY_SIZE(dm9000_resources),
317         .resource       = dm9000_resources,
318 };
319 #endif
320
321 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
322 static struct resource sl811_hcd_resources[] = {
323         {
324                 .start = 0x20340000,
325                 .end = 0x20340000,
326                 .flags = IORESOURCE_MEM,
327         }, {
328                 .start = 0x20340004,
329                 .end = 0x20340004,
330                 .flags = IORESOURCE_MEM,
331         }, {
332                 .start = CONFIG_USB_SL811_BFIN_IRQ,
333                 .end = CONFIG_USB_SL811_BFIN_IRQ,
334                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
335         },
336 };
337
338 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
339 void sl811_port_power(struct device *dev, int is_on)
340 {
341         gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
342         gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
343 }
344 #endif
345
346 static struct sl811_platform_data sl811_priv = {
347         .potpg = 10,
348         .power = 250,       /* == 500mA */
349 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
350         .port_power = &sl811_port_power,
351 #endif
352 };
353
354 static struct platform_device sl811_hcd_device = {
355         .name = "sl811-hcd",
356         .id = 0,
357         .dev = {
358                 .platform_data = &sl811_priv,
359         },
360         .num_resources = ARRAY_SIZE(sl811_hcd_resources),
361         .resource = sl811_hcd_resources,
362 };
363 #endif
364
365 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
366 static struct resource isp1362_hcd_resources[] = {
367         {
368                 .start = 0x20360000,
369                 .end = 0x20360000,
370                 .flags = IORESOURCE_MEM,
371         }, {
372                 .start = 0x20360004,
373                 .end = 0x20360004,
374                 .flags = IORESOURCE_MEM,
375         }, {
376                 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
377                 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
378                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
379         },
380 };
381
382 static struct isp1362_platform_data isp1362_priv = {
383         .sel15Kres = 1,
384         .clknotstop = 0,
385         .oc_enable = 0,
386         .int_act_high = 0,
387         .int_edge_triggered = 0,
388         .remote_wakeup_connected = 0,
389         .no_power_switching = 1,
390         .power_switching_mode = 0,
391 };
392
393 static struct platform_device isp1362_hcd_device = {
394         .name = "isp1362-hcd",
395         .id = 0,
396         .dev = {
397                 .platform_data = &isp1362_priv,
398         },
399         .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
400         .resource = isp1362_hcd_resources,
401 };
402 #endif
403
404 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
405 static struct platform_device bfin_mii_bus = {
406         .name = "bfin_mii_bus",
407 };
408
409 static struct platform_device bfin_mac_device = {
410         .name = "bfin_mac",
411         .dev.platform_data = &bfin_mii_bus,
412 };
413 #endif
414
415 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
416 static struct resource net2272_bfin_resources[] = {
417         {
418                 .start = 0x20300000,
419                 .end = 0x20300000 + 0x100,
420                 .flags = IORESOURCE_MEM,
421         }, {
422                 .start = IRQ_PF7,
423                 .end = IRQ_PF7,
424                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
425         },
426 };
427
428 static struct platform_device net2272_bfin_device = {
429         .name = "net2272",
430         .id = -1,
431         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
432         .resource = net2272_bfin_resources,
433 };
434 #endif
435
436 #if defined(CONFIG_MTD_M25P80) \
437         || defined(CONFIG_MTD_M25P80_MODULE)
438 static struct mtd_partition bfin_spi_flash_partitions[] = {
439         {
440                 .name = "bootloader(spi)",
441                 .size = 0x00040000,
442                 .offset = 0,
443                 .mask_flags = MTD_CAP_ROM
444         }, {
445                 .name = "linux kernel(spi)",
446                 .size = MTDPART_SIZ_FULL,
447                 .offset = MTDPART_OFS_APPEND,
448         }
449 };
450
451 static struct flash_platform_data bfin_spi_flash_data = {
452         .name = "m25p80",
453         .parts = bfin_spi_flash_partitions,
454         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
455         .type = "m25p16",
456 };
457
458 /* SPI flash chip (m25p64) */
459 static struct bfin5xx_spi_chip spi_flash_chip_info = {
460         .enable_dma = 0,         /* use dma transfer with this chip*/
461         .bits_per_word = 8,
462 };
463 #endif
464
465 #if defined(CONFIG_BFIN_SPI_ADC) \
466         || defined(CONFIG_BFIN_SPI_ADC_MODULE)
467 /* SPI ADC chip */
468 static struct bfin5xx_spi_chip spi_adc_chip_info = {
469         .enable_dma = 1,         /* use dma transfer with this chip*/
470         .bits_per_word = 16,
471 };
472 #endif
473
474 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
475         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
476 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
477         .enable_dma = 0,
478         .bits_per_word = 16,
479 };
480 #endif
481
482 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
483 static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
484         .enable_dma = 0,
485         .bits_per_word = 16,
486 };
487 #endif
488
489 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
490 static struct bfin5xx_spi_chip  mmc_spi_chip_info = {
491         .enable_dma = 0,
492         .bits_per_word = 8,
493 };
494 #endif
495
496 #if defined(CONFIG_PBX)
497 static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
498         .ctl_reg        = 0x4, /* send zero */
499         .enable_dma     = 0,
500         .bits_per_word  = 8,
501         .cs_change_per_word = 1,
502 };
503 #endif
504
505 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
506 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
507         .enable_dma = 0,
508         .bits_per_word = 16,
509 };
510
511 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
512         .model                  = 7877,
513         .vref_delay_usecs       = 50,   /* internal, no capacitor */
514         .x_plate_ohms           = 419,
515         .y_plate_ohms           = 486,
516         .pressure_max           = 1000,
517         .pressure_min           = 0,
518         .stopacq_polarity       = 1,
519         .first_conversion_delay = 3,
520         .acquisition_time       = 1,
521         .averaging              = 1,
522         .pen_down_acc_interval  = 1,
523 };
524 #endif
525
526 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
527          && defined(CONFIG_SND_SOC_WM8731_SPI)
528 static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
529         .enable_dma = 0,
530         .bits_per_word = 16,
531 };
532 #endif
533
534 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
535 static struct bfin5xx_spi_chip spidev_chip_info = {
536         .enable_dma = 0,
537         .bits_per_word = 8,
538 };
539 #endif
540
541 static struct spi_board_info bfin_spi_board_info[] __initdata = {
542 #if defined(CONFIG_MTD_M25P80) \
543         || defined(CONFIG_MTD_M25P80_MODULE)
544         {
545                 /* the modalias must be the same as spi device driver name */
546                 .modalias = "m25p80", /* Name of spi_driver for this device */
547                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
548                 .bus_num = 0, /* Framework bus number */
549                 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
550                 .platform_data = &bfin_spi_flash_data,
551                 .controller_data = &spi_flash_chip_info,
552                 .mode = SPI_MODE_3,
553         },
554 #endif
555
556 #if defined(CONFIG_BFIN_SPI_ADC) \
557         || defined(CONFIG_BFIN_SPI_ADC_MODULE)
558         {
559                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
560                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
561                 .bus_num = 0, /* Framework bus number */
562                 .chip_select = 1, /* Framework chip select. */
563                 .platform_data = NULL, /* No spi_driver specific config */
564                 .controller_data = &spi_adc_chip_info,
565         },
566 #endif
567
568 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
569         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
570         {
571                 .modalias = "ad1836-spi",
572                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
573                 .bus_num = 0,
574                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
575                 .controller_data = &ad1836_spi_chip_info,
576         },
577 #endif
578 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
579         {
580                 .modalias = "ad9960-spi",
581                 .max_speed_hz = 10000000,     /* max spi clock (SCK) speed in HZ */
582                 .bus_num = 0,
583                 .chip_select = 1,
584                 .controller_data = &ad9960_spi_chip_info,
585         },
586 #endif
587 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
588         {
589                 .modalias = "mmc_spi",
590                 .max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
591                 .bus_num = 0,
592                 .chip_select = 5,
593                 .controller_data = &mmc_spi_chip_info,
594                 .mode = SPI_MODE_3,
595         },
596 #endif
597 #if defined(CONFIG_PBX)
598         {
599                 .modalias = "fxs-spi",
600                 .max_speed_hz = 12500000,     /* max spi clock (SCK) speed in HZ */
601                 .bus_num = 0,
602                 .chip_select = 8 - CONFIG_J11_JUMPER,
603                 .controller_data = &spi_si3xxx_chip_info,
604                 .mode = SPI_MODE_3,
605         },
606         {
607                 .modalias = "fxo-spi",
608                 .max_speed_hz = 12500000,     /* max spi clock (SCK) speed in HZ */
609                 .bus_num = 0,
610                 .chip_select = 8 - CONFIG_J19_JUMPER,
611                 .controller_data = &spi_si3xxx_chip_info,
612                 .mode = SPI_MODE_3,
613         },
614 #endif
615 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
616         {
617                 .modalias               = "ad7877",
618                 .platform_data          = &bfin_ad7877_ts_info,
619                 .irq                    = IRQ_PF8,
620                 .max_speed_hz   = 12500000,     /* max spi clock (SCK) speed in HZ */
621                 .bus_num        = 0,
622                 .chip_select  = 2,
623                 .controller_data = &spi_ad7877_chip_info,
624         },
625 #endif
626 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
627          && defined(CONFIG_SND_SOC_WM8731_SPI)
628         {
629                 .modalias       = "wm8731",
630                 .max_speed_hz   = 3125000,     /* max spi clock (SCK) speed in HZ */
631                 .bus_num        = 0,
632                 .chip_select    = 5,
633                 .controller_data = &spi_wm8731_chip_info,
634                 .mode = SPI_MODE_0,
635         },
636 #endif
637 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
638         {
639                 .modalias = "spidev",
640                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
641                 .bus_num = 0,
642                 .chip_select = 1,
643                 .controller_data = &spidev_chip_info,
644         },
645 #endif
646 };
647
648 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
649 /* SPI controller data */
650 static struct bfin5xx_spi_master bfin_spi0_info = {
651         .num_chipselect = 8,
652         .enable_dma = 1,  /* master has the ability to do dma transfer */
653         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
654 };
655
656 /* SPI (0) */
657 static struct resource bfin_spi0_resource[] = {
658         [0] = {
659                 .start = SPI0_REGBASE,
660                 .end   = SPI0_REGBASE + 0xFF,
661                 .flags = IORESOURCE_MEM,
662                 },
663         [1] = {
664                 .start = CH_SPI,
665                 .end   = CH_SPI,
666                 .flags = IORESOURCE_DMA,
667         },
668         [2] = {
669                 .start = IRQ_SPI,
670                 .end   = IRQ_SPI,
671                 .flags = IORESOURCE_IRQ,
672         },
673 };
674
675 static struct platform_device bfin_spi0_device = {
676         .name = "bfin-spi",
677         .id = 0, /* Bus number */
678         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
679         .resource = bfin_spi0_resource,
680         .dev = {
681                 .platform_data = &bfin_spi0_info, /* Passed to driver */
682         },
683 };
684 #endif  /* spi master and devices */
685
686 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
687 static struct platform_device bfin_fb_adv7393_device = {
688         .name = "bfin-adv7393",
689 };
690 #endif
691
692 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
693 static struct resource bfin_uart_resources[] = {
694 #ifdef CONFIG_SERIAL_BFIN_UART0
695         {
696                 .start = 0xFFC00400,
697                 .end = 0xFFC004FF,
698                 .flags = IORESOURCE_MEM,
699         },
700 #endif
701 #ifdef CONFIG_SERIAL_BFIN_UART1
702         {
703                 .start = 0xFFC02000,
704                 .end = 0xFFC020FF,
705                 .flags = IORESOURCE_MEM,
706         },
707 #endif
708 };
709
710 static struct platform_device bfin_uart_device = {
711         .name = "bfin-uart",
712         .id = 1,
713         .num_resources = ARRAY_SIZE(bfin_uart_resources),
714         .resource = bfin_uart_resources,
715 };
716 #endif
717
718 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
719 #ifdef CONFIG_BFIN_SIR0
720 static struct resource bfin_sir0_resources[] = {
721         {
722                 .start = 0xFFC00400,
723                 .end = 0xFFC004FF,
724                 .flags = IORESOURCE_MEM,
725         },
726         {
727                 .start = IRQ_UART0_RX,
728                 .end = IRQ_UART0_RX+1,
729                 .flags = IORESOURCE_IRQ,
730         },
731         {
732                 .start = CH_UART0_RX,
733                 .end = CH_UART0_RX+1,
734                 .flags = IORESOURCE_DMA,
735         },
736 };
737
738 static struct platform_device bfin_sir0_device = {
739         .name = "bfin_sir",
740         .id = 0,
741         .num_resources = ARRAY_SIZE(bfin_sir0_resources),
742         .resource = bfin_sir0_resources,
743 };
744 #endif
745 #ifdef CONFIG_BFIN_SIR1
746 static struct resource bfin_sir1_resources[] = {
747         {
748                 .start = 0xFFC02000,
749                 .end = 0xFFC020FF,
750                 .flags = IORESOURCE_MEM,
751         },
752         {
753                 .start = IRQ_UART1_RX,
754                 .end = IRQ_UART1_RX+1,
755                 .flags = IORESOURCE_IRQ,
756         },
757         {
758                 .start = CH_UART1_RX,
759                 .end = CH_UART1_RX+1,
760                 .flags = IORESOURCE_DMA,
761         },
762 };
763
764 static struct platform_device bfin_sir1_device = {
765         .name = "bfin_sir",
766         .id = 1,
767         .num_resources = ARRAY_SIZE(bfin_sir1_resources),
768         .resource = bfin_sir1_resources,
769 };
770 #endif
771 #endif
772
773 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
774 static struct resource bfin_twi0_resource[] = {
775         [0] = {
776                 .start = TWI0_REGBASE,
777                 .end   = TWI0_REGBASE,
778                 .flags = IORESOURCE_MEM,
779         },
780         [1] = {
781                 .start = IRQ_TWI,
782                 .end   = IRQ_TWI,
783                 .flags = IORESOURCE_IRQ,
784         },
785 };
786
787 static struct platform_device i2c_bfin_twi_device = {
788         .name = "i2c-bfin-twi",
789         .id = 0,
790         .num_resources = ARRAY_SIZE(bfin_twi0_resource),
791         .resource = bfin_twi0_resource,
792 };
793 #endif
794
795 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
796 #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
797         {
798                 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
799                 .type = "pcf8574_lcd",
800         },
801 #endif
802 #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
803         {
804                 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
805                 .type = "pcf8574_keypad",
806                 .irq = IRQ_PF8,
807         },
808 #endif
809 };
810
811 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
812 static struct platform_device bfin_sport0_uart_device = {
813         .name = "bfin-sport-uart",
814         .id = 0,
815 };
816
817 static struct platform_device bfin_sport1_uart_device = {
818         .name = "bfin-sport-uart",
819         .id = 1,
820 };
821 #endif
822
823 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
824 #include <linux/input.h>
825 #include <linux/gpio_keys.h>
826
827 static struct gpio_keys_button bfin_gpio_keys_table[] = {
828         {BTN_0, GPIO_PF14, 1, "gpio-keys: BTN0"},
829 };
830
831 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
832         .buttons        = bfin_gpio_keys_table,
833         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
834 };
835
836 static struct platform_device bfin_device_gpiokeys = {
837         .name      = "gpio-keys",
838         .dev = {
839                 .platform_data = &bfin_gpio_keys_data,
840         },
841 };
842 #endif
843
844 static struct resource bfin_gpios_resources = {
845         .start = 0,
846         .end   = MAX_BLACKFIN_GPIOS - 1,
847         .flags = IORESOURCE_IRQ,
848 };
849
850 static struct platform_device bfin_gpios_device = {
851         .name = "simple-gpio",
852         .id = -1,
853         .num_resources = 1,
854         .resource = &bfin_gpios_resources,
855 };
856
857 static const unsigned int cclk_vlev_datasheet[] =
858 {
859         VRPAIR(VLEV_100, 400000000),
860         VRPAIR(VLEV_105, 426000000),
861         VRPAIR(VLEV_110, 500000000),
862         VRPAIR(VLEV_115, 533000000),
863         VRPAIR(VLEV_120, 600000000),
864 };
865
866 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
867         .tuple_tab = cclk_vlev_datasheet,
868         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
869         .vr_settling_time = 25 /* us */,
870 };
871
872 static struct platform_device bfin_dpmc = {
873         .name = "bfin dpmc",
874         .dev = {
875                 .platform_data = &bfin_dmpc_vreg_data,
876         },
877 };
878
879 static struct platform_device *stamp_devices[] __initdata = {
880
881         &bfin_dpmc,
882
883 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
884         &bf5xx_nand_device,
885 #endif
886
887 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
888         &bfin_pcmcia_cf_device,
889 #endif
890
891 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
892         &rtc_device,
893 #endif
894
895 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
896         &sl811_hcd_device,
897 #endif
898
899 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
900         &isp1362_hcd_device,
901 #endif
902
903 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
904         &bfin_isp1760_device,
905 #endif
906
907 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
908         &musb_device,
909 #endif
910
911 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
912         &smc91x_device,
913 #endif
914
915 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
916         &dm9000_device,
917 #endif
918
919 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
920         &bfin_mii_bus,
921         &bfin_mac_device,
922 #endif
923
924 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
925         &net2272_bfin_device,
926 #endif
927
928 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
929         &bfin_spi0_device,
930 #endif
931
932 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
933         &bfin_fb_adv7393_device,
934 #endif
935
936 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
937         &bfin_uart_device,
938 #endif
939
940 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
941 #ifdef CONFIG_BFIN_SIR0
942         &bfin_sir0_device,
943 #endif
944 #ifdef CONFIG_BFIN_SIR1
945         &bfin_sir1_device,
946 #endif
947 #endif
948
949 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
950         &i2c_bfin_twi_device,
951 #endif
952
953 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
954         &bfin_sport0_uart_device,
955         &bfin_sport1_uart_device,
956 #endif
957
958 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
959         &bfin_device_gpiokeys,
960 #endif
961
962 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
963         &ezkit_flash_device,
964 #endif
965
966         &bfin_gpios_device,
967 };
968
969 static int __init cm_init(void)
970 {
971         printk(KERN_INFO "%s(): registering device resources\n", __func__);
972         i2c_register_board_info(0, bfin_i2c_board_info,
973                                 ARRAY_SIZE(bfin_i2c_board_info));
974         platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
975         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
976         return 0;
977 }
978
979 arch_initcall(cm_init);
980
981 void native_machine_restart(char *cmd)
982 {
983         /* workaround reboot hang when booting from SPI */
984         if ((bfin_read_SYSCR() & 0x7) == 0x3)
985                 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
986 }
987
988 void bfin_get_ether_addr(char *addr)
989 {
990         random_ether_addr(addr);
991         printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
992 }
993 EXPORT_SYMBOL(bfin_get_ether_addr);