beea15041c2e16a1a442add5952b70e8fa156c6c
[safe/jmp/linux-2.6] / arch / blackfin / mach-bf527 / boards / ezkit.c
1 /*
2  * File:         arch/blackfin/mach-bf527/boards/ezkit.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 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
39 #include <linux/usb/isp1362.h>
40 #endif
41 #include <linux/i2c.h>
42 #include <linux/irq.h>
43 #include <linux/interrupt.h>
44 #include <linux/usb/sl811.h>
45 #include <linux/usb/musb.h>
46 #include <asm/dma.h>
47 #include <asm/bfin5xx_spi.h>
48 #include <asm/reboot.h>
49 #include <asm/nand.h>
50 #include <asm/portmux.h>
51 #include <asm/dpmc.h>
52 #include <linux/spi/ad7877.h>
53
54 /*
55  * Name the Board for the /proc/cpuinfo
56  */
57 const char bfin_board_name[] = "ADI BF527-EZKIT";
58
59 /*
60  *  Driver needs to know address, irq and flag pin.
61  */
62
63 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
64 #include <linux/usb/isp1760.h>
65 static struct resource bfin_isp1760_resources[] = {
66         [0] = {
67                 .start  = 0x203C0000,
68                 .end    = 0x203C0000 + 0x000fffff,
69                 .flags  = IORESOURCE_MEM,
70         },
71         [1] = {
72                 .start  = IRQ_PF7,
73                 .end    = IRQ_PF7,
74                 .flags  = IORESOURCE_IRQ,
75         },
76 };
77
78 static struct isp1760_platform_data isp1760_priv = {
79         .is_isp1761 = 0,
80         .port1_disable = 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        = 7,
124         .dma_channels   = 7,
125         .gpio_vrsel     = GPIO_PG13,
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_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
155
156 static struct resource bf52x_t350mcqb_resources[] = {
157         {
158                 .start = IRQ_PPI_ERROR,
159                 .end = IRQ_PPI_ERROR,
160                 .flags = IORESOURCE_IRQ,
161         },
162 };
163
164 static struct platform_device bf52x_t350mcqb_device = {
165         .name           = "bfin-t350mcqb",
166         .id             = -1,
167         .num_resources  = ARRAY_SIZE(bf52x_t350mcqb_resources),
168         .resource       = bf52x_t350mcqb_resources,
169 };
170 #endif
171
172 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
173 static struct mtd_partition ezkit_partitions[] = {
174         {
175                 .name       = "bootloader(nor)",
176                 .size       = 0x40000,
177                 .offset     = 0,
178         }, {
179                 .name       = "linux kernel(nor)",
180                 .size       = 0x1C0000,
181                 .offset     = MTDPART_OFS_APPEND,
182         }, {
183                 .name       = "file system(nor)",
184                 .size       = MTDPART_SIZ_FULL,
185                 .offset     = MTDPART_OFS_APPEND,
186         }
187 };
188
189 static struct physmap_flash_data ezkit_flash_data = {
190         .width      = 2,
191         .parts      = ezkit_partitions,
192         .nr_parts   = ARRAY_SIZE(ezkit_partitions),
193 };
194
195 static struct resource ezkit_flash_resource = {
196         .start = 0x20000000,
197         .end   = 0x203fffff,
198         .flags = IORESOURCE_MEM,
199 };
200
201 static struct platform_device ezkit_flash_device = {
202         .name          = "physmap-flash",
203         .id            = 0,
204         .dev = {
205                 .platform_data = &ezkit_flash_data,
206         },
207         .num_resources = 1,
208         .resource      = &ezkit_flash_resource,
209 };
210 #endif
211
212 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
213 static struct mtd_partition partition_info[] = {
214         {
215                 .name = "linux kernel(nand)",
216                 .offset = 0,
217                 .size = 4 * 1024 * 1024,
218         },
219         {
220                 .name = "file system(nand)",
221                 .offset = MTDPART_OFS_APPEND,
222                 .size = MTDPART_SIZ_FULL,
223         },
224 };
225
226 static struct bf5xx_nand_platform bf5xx_nand_platform = {
227         .page_size = NFC_PG_SIZE_256,
228         .data_width = NFC_NWIDTH_8,
229         .partitions = partition_info,
230         .nr_partitions = ARRAY_SIZE(partition_info),
231         .rd_dly = 3,
232         .wr_dly = 3,
233 };
234
235 static struct resource bf5xx_nand_resources[] = {
236         {
237                 .start = NFC_CTL,
238                 .end = NFC_DATA_RD + 2,
239                 .flags = IORESOURCE_MEM,
240         },
241         {
242                 .start = CH_NFC,
243                 .end = CH_NFC,
244                 .flags = IORESOURCE_IRQ,
245         },
246 };
247
248 static struct platform_device bf5xx_nand_device = {
249         .name = "bf5xx-nand",
250         .id = 0,
251         .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
252         .resource = bf5xx_nand_resources,
253         .dev = {
254                 .platform_data = &bf5xx_nand_platform,
255         },
256 };
257 #endif
258
259 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
260 static struct resource bfin_pcmcia_cf_resources[] = {
261         {
262                 .start = 0x20310000, /* IO PORT */
263                 .end = 0x20312000,
264                 .flags = IORESOURCE_MEM,
265         }, {
266                 .start = 0x20311000, /* Attribute Memory */
267                 .end = 0x20311FFF,
268                 .flags = IORESOURCE_MEM,
269         }, {
270                 .start = IRQ_PF4,
271                 .end = IRQ_PF4,
272                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
273         }, {
274                 .start = 6, /* Card Detect PF6 */
275                 .end = 6,
276                 .flags = IORESOURCE_IRQ,
277         },
278 };
279
280 static struct platform_device bfin_pcmcia_cf_device = {
281         .name = "bfin_cf_pcmcia",
282         .id = -1,
283         .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
284         .resource = bfin_pcmcia_cf_resources,
285 };
286 #endif
287
288 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
289 static struct platform_device rtc_device = {
290         .name = "rtc-bfin",
291         .id   = -1,
292 };
293 #endif
294
295 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
296 static struct resource smc91x_resources[] = {
297         {
298                 .name = "smc91x-regs",
299                 .start = 0x20300300,
300                 .end = 0x20300300 + 16,
301                 .flags = IORESOURCE_MEM,
302         }, {
303
304                 .start = IRQ_PF7,
305                 .end = IRQ_PF7,
306                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
307         },
308 };
309 static struct platform_device smc91x_device = {
310         .name = "smc91x",
311         .id = 0,
312         .num_resources = ARRAY_SIZE(smc91x_resources),
313         .resource = smc91x_resources,
314 };
315 #endif
316
317 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
318 static struct resource dm9000_resources[] = {
319         [0] = {
320                 .start  = 0x203FB800,
321                 .end    = 0x203FB800 + 1,
322                 .flags  = IORESOURCE_MEM,
323         },
324         [1] = {
325                 .start  = 0x203FB800 + 4,
326                 .end    = 0x203FB800 + 5,
327                 .flags  = IORESOURCE_MEM,
328         },
329         [2] = {
330                 .start  = IRQ_PF9,
331                 .end    = IRQ_PF9,
332                 .flags  = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
333         },
334 };
335
336 static struct platform_device dm9000_device = {
337         .name           = "dm9000",
338         .id             = -1,
339         .num_resources  = ARRAY_SIZE(dm9000_resources),
340         .resource       = dm9000_resources,
341 };
342 #endif
343
344 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
345 static struct resource sl811_hcd_resources[] = {
346         {
347                 .start = 0x20340000,
348                 .end = 0x20340000,
349                 .flags = IORESOURCE_MEM,
350         }, {
351                 .start = 0x20340004,
352                 .end = 0x20340004,
353                 .flags = IORESOURCE_MEM,
354         }, {
355                 .start = CONFIG_USB_SL811_BFIN_IRQ,
356                 .end = CONFIG_USB_SL811_BFIN_IRQ,
357                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
358         },
359 };
360
361 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
362 void sl811_port_power(struct device *dev, int is_on)
363 {
364         gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
365         gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
366 }
367 #endif
368
369 static struct sl811_platform_data sl811_priv = {
370         .potpg = 10,
371         .power = 250,       /* == 500mA */
372 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
373         .port_power = &sl811_port_power,
374 #endif
375 };
376
377 static struct platform_device sl811_hcd_device = {
378         .name = "sl811-hcd",
379         .id = 0,
380         .dev = {
381                 .platform_data = &sl811_priv,
382         },
383         .num_resources = ARRAY_SIZE(sl811_hcd_resources),
384         .resource = sl811_hcd_resources,
385 };
386 #endif
387
388 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
389 static struct resource isp1362_hcd_resources[] = {
390         {
391                 .start = 0x20360000,
392                 .end = 0x20360000,
393                 .flags = IORESOURCE_MEM,
394         }, {
395                 .start = 0x20360004,
396                 .end = 0x20360004,
397                 .flags = IORESOURCE_MEM,
398         }, {
399                 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
400                 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
401                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
402         },
403 };
404
405 static struct isp1362_platform_data isp1362_priv = {
406         .sel15Kres = 1,
407         .clknotstop = 0,
408         .oc_enable = 0,
409         .int_act_high = 0,
410         .int_edge_triggered = 0,
411         .remote_wakeup_connected = 0,
412         .no_power_switching = 1,
413         .power_switching_mode = 0,
414 };
415
416 static struct platform_device isp1362_hcd_device = {
417         .name = "isp1362-hcd",
418         .id = 0,
419         .dev = {
420                 .platform_data = &isp1362_priv,
421         },
422         .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
423         .resource = isp1362_hcd_resources,
424 };
425 #endif
426
427 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
428 static struct platform_device bfin_mac_device = {
429         .name = "bfin_mac",
430 };
431 #endif
432
433 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
434 static struct resource net2272_bfin_resources[] = {
435         {
436                 .start = 0x20300000,
437                 .end = 0x20300000 + 0x100,
438                 .flags = IORESOURCE_MEM,
439         }, {
440                 .start = IRQ_PF7,
441                 .end = IRQ_PF7,
442                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
443         },
444 };
445
446 static struct platform_device net2272_bfin_device = {
447         .name = "net2272",
448         .id = -1,
449         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
450         .resource = net2272_bfin_resources,
451 };
452 #endif
453
454 #if defined(CONFIG_MTD_M25P80) \
455         || defined(CONFIG_MTD_M25P80_MODULE)
456 static struct mtd_partition bfin_spi_flash_partitions[] = {
457         {
458                 .name = "bootloader(spi)",
459                 .size = 0x00040000,
460                 .offset = 0,
461                 .mask_flags = MTD_CAP_ROM
462         }, {
463                 .name = "linux kernel(spi)",
464                 .size = MTDPART_SIZ_FULL,
465                 .offset = MTDPART_OFS_APPEND,
466         }
467 };
468
469 static struct flash_platform_data bfin_spi_flash_data = {
470         .name = "m25p80",
471         .parts = bfin_spi_flash_partitions,
472         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
473         .type = "m25p16",
474 };
475
476 /* SPI flash chip (m25p64) */
477 static struct bfin5xx_spi_chip spi_flash_chip_info = {
478         .enable_dma = 0,         /* use dma transfer with this chip*/
479         .bits_per_word = 8,
480 };
481 #endif
482
483 #if defined(CONFIG_SPI_ADC_BF533) \
484         || defined(CONFIG_SPI_ADC_BF533_MODULE)
485 /* SPI ADC chip */
486 static struct bfin5xx_spi_chip spi_adc_chip_info = {
487         .enable_dma = 1,         /* use dma transfer with this chip*/
488         .bits_per_word = 16,
489 };
490 #endif
491
492 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
493         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
494 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
495         .enable_dma = 0,
496         .bits_per_word = 16,
497 };
498 #endif
499
500 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
501 static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
502         .enable_dma = 0,
503         .bits_per_word = 16,
504 };
505 #endif
506
507 #if defined(CONFIG_PBX)
508 static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
509         .ctl_reg        = 0x4, /* send zero */
510         .enable_dma     = 0,
511         .bits_per_word  = 8,
512         .cs_change_per_word = 1,
513 };
514 #endif
515
516 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
517 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
518         .enable_dma = 0,
519         .bits_per_word = 16,
520 };
521
522 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
523         .model                  = 7877,
524         .vref_delay_usecs       = 50,   /* internal, no capacitor */
525         .x_plate_ohms           = 419,
526         .y_plate_ohms           = 486,
527         .pressure_max           = 1000,
528         .pressure_min           = 0,
529         .stopacq_polarity       = 1,
530         .first_conversion_delay = 3,
531         .acquisition_time       = 1,
532         .averaging              = 1,
533         .pen_down_acc_interval  = 1,
534 };
535 #endif
536
537 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
538          && defined(CONFIG_SND_SOC_WM8731_SPI)
539 static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
540         .enable_dma = 0,
541         .bits_per_word = 16,
542 };
543 #endif
544
545 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
546 static struct bfin5xx_spi_chip spidev_chip_info = {
547         .enable_dma = 0,
548         .bits_per_word = 8,
549 };
550 #endif
551
552 static struct spi_board_info bfin_spi_board_info[] __initdata = {
553 #if defined(CONFIG_MTD_M25P80) \
554         || defined(CONFIG_MTD_M25P80_MODULE)
555         {
556                 /* the modalias must be the same as spi device driver name */
557                 .modalias = "m25p80", /* Name of spi_driver for this device */
558                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
559                 .bus_num = 0, /* Framework bus number */
560                 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
561                 .platform_data = &bfin_spi_flash_data,
562                 .controller_data = &spi_flash_chip_info,
563                 .mode = SPI_MODE_3,
564         },
565 #endif
566
567 #if defined(CONFIG_SPI_ADC_BF533) \
568         || defined(CONFIG_SPI_ADC_BF533_MODULE)
569         {
570                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
571                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
572                 .bus_num = 0, /* Framework bus number */
573                 .chip_select = 1, /* Framework chip select. */
574                 .platform_data = NULL, /* No spi_driver specific config */
575                 .controller_data = &spi_adc_chip_info,
576         },
577 #endif
578
579 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
580         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
581         {
582                 .modalias = "ad1836-spi",
583                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
584                 .bus_num = 0,
585                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
586                 .controller_data = &ad1836_spi_chip_info,
587         },
588 #endif
589 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
590         {
591                 .modalias = "ad9960-spi",
592                 .max_speed_hz = 10000000,     /* max spi clock (SCK) speed in HZ */
593                 .bus_num = 0,
594                 .chip_select = 1,
595                 .controller_data = &ad9960_spi_chip_info,
596         },
597 #endif
598 #if defined(CONFIG_PBX)
599         {
600                 .modalias = "fxs-spi",
601                 .max_speed_hz = 12500000,     /* max spi clock (SCK) speed in HZ */
602                 .bus_num = 0,
603                 .chip_select = 8 - CONFIG_J11_JUMPER,
604                 .controller_data = &spi_si3xxx_chip_info,
605                 .mode = SPI_MODE_3,
606         },
607         {
608                 .modalias = "fxo-spi",
609                 .max_speed_hz = 12500000,     /* max spi clock (SCK) speed in HZ */
610                 .bus_num = 0,
611                 .chip_select = 8 - CONFIG_J19_JUMPER,
612                 .controller_data = &spi_si3xxx_chip_info,
613                 .mode = SPI_MODE_3,
614         },
615 #endif
616 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
617         {
618                 .modalias               = "ad7877",
619                 .platform_data          = &bfin_ad7877_ts_info,
620                 .irq                    = IRQ_PF8,
621                 .max_speed_hz   = 12500000,     /* max spi clock (SCK) speed in HZ */
622                 .bus_num        = 0,
623                 .chip_select  = 2,
624                 .controller_data = &spi_ad7877_chip_info,
625         },
626 #endif
627 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
628          && defined(CONFIG_SND_SOC_WM8731_SPI)
629         {
630                 .modalias       = "wm8731",
631                 .max_speed_hz   = 3125000,     /* max spi clock (SCK) speed in HZ */
632                 .bus_num        = 0,
633                 .chip_select    = 5,
634                 .controller_data = &spi_wm8731_chip_info,
635                 .mode = SPI_MODE_0,
636         },
637 #endif
638 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
639         {
640                 .modalias = "spidev",
641                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
642                 .bus_num = 0,
643                 .chip_select = 1,
644                 .controller_data = &spidev_chip_info,
645         },
646 #endif
647 };
648
649 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
650 /* SPI controller data */
651 static struct bfin5xx_spi_master bfin_spi0_info = {
652         .num_chipselect = 8,
653         .enable_dma = 1,  /* master has the ability to do dma transfer */
654         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
655 };
656
657 /* SPI (0) */
658 static struct resource bfin_spi0_resource[] = {
659         [0] = {
660                 .start = SPI0_REGBASE,
661                 .end   = SPI0_REGBASE + 0xFF,
662                 .flags = IORESOURCE_MEM,
663                 },
664         [1] = {
665                 .start = CH_SPI,
666                 .end   = CH_SPI,
667                 .flags = IORESOURCE_IRQ,
668         },
669 };
670
671 static struct platform_device bfin_spi0_device = {
672         .name = "bfin-spi",
673         .id = 0, /* Bus number */
674         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
675         .resource = bfin_spi0_resource,
676         .dev = {
677                 .platform_data = &bfin_spi0_info, /* Passed to driver */
678         },
679 };
680 #endif  /* spi master and devices */
681
682 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
683 static struct platform_device bfin_fb_device = {
684         .name = "bf537-lq035",
685 };
686 #endif
687
688 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
689 static struct platform_device bfin_fb_adv7393_device = {
690         .name = "bfin-adv7393",
691 };
692 #endif
693
694 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
695 static struct resource bfin_uart_resources[] = {
696 #ifdef CONFIG_SERIAL_BFIN_UART0
697         {
698                 .start = 0xFFC00400,
699                 .end = 0xFFC004FF,
700                 .flags = IORESOURCE_MEM,
701         },
702 #endif
703 #ifdef CONFIG_SERIAL_BFIN_UART1
704         {
705                 .start = 0xFFC02000,
706                 .end = 0xFFC020FF,
707                 .flags = IORESOURCE_MEM,
708         },
709 #endif
710 };
711
712 static struct platform_device bfin_uart_device = {
713         .name = "bfin-uart",
714         .id = 1,
715         .num_resources = ARRAY_SIZE(bfin_uart_resources),
716         .resource = bfin_uart_resources,
717 };
718 #endif
719
720 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
721 #ifdef CONFIG_BFIN_SIR0
722 static struct resource bfin_sir0_resources[] = {
723         {
724                 .start = 0xFFC00400,
725                 .end = 0xFFC004FF,
726                 .flags = IORESOURCE_MEM,
727         },
728         {
729                 .start = IRQ_UART0_RX,
730                 .end = IRQ_UART0_RX+1,
731                 .flags = IORESOURCE_IRQ,
732         },
733         {
734                 .start = CH_UART0_RX,
735                 .end = CH_UART0_RX+1,
736                 .flags = IORESOURCE_DMA,
737         },
738 };
739
740 static struct platform_device bfin_sir0_device = {
741         .name = "bfin_sir",
742         .id = 0,
743         .num_resources = ARRAY_SIZE(bfin_sir0_resources),
744         .resource = bfin_sir0_resources,
745 };
746 #endif
747 #ifdef CONFIG_BFIN_SIR1
748 static struct resource bfin_sir1_resources[] = {
749         {
750                 .start = 0xFFC02000,
751                 .end = 0xFFC020FF,
752                 .flags = IORESOURCE_MEM,
753         },
754         {
755                 .start = IRQ_UART1_RX,
756                 .end = IRQ_UART1_RX+1,
757                 .flags = IORESOURCE_IRQ,
758         },
759         {
760                 .start = CH_UART1_RX,
761                 .end = CH_UART1_RX+1,
762                 .flags = IORESOURCE_DMA,
763         },
764 };
765
766 static struct platform_device bfin_sir1_device = {
767         .name = "bfin_sir",
768         .id = 1,
769         .num_resources = ARRAY_SIZE(bfin_sir1_resources),
770         .resource = bfin_sir1_resources,
771 };
772 #endif
773 #endif
774
775 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
776 static struct resource bfin_twi0_resource[] = {
777         [0] = {
778                 .start = TWI0_REGBASE,
779                 .end   = TWI0_REGBASE,
780                 .flags = IORESOURCE_MEM,
781         },
782         [1] = {
783                 .start = IRQ_TWI,
784                 .end   = IRQ_TWI,
785                 .flags = IORESOURCE_IRQ,
786         },
787 };
788
789 static struct platform_device i2c_bfin_twi_device = {
790         .name = "i2c-bfin-twi",
791         .id = 0,
792         .num_resources = ARRAY_SIZE(bfin_twi0_resource),
793         .resource = bfin_twi0_resource,
794 };
795 #endif
796
797 #ifdef CONFIG_I2C_BOARDINFO
798 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
799 #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
800         {
801                 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
802         },
803 #endif
804 #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
805         {
806                 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
807                 .irq = IRQ_PF8,
808         },
809 #endif
810 };
811 #endif
812
813 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
814 static struct platform_device bfin_sport0_uart_device = {
815         .name = "bfin-sport-uart",
816         .id = 0,
817 };
818
819 static struct platform_device bfin_sport1_uart_device = {
820         .name = "bfin-sport-uart",
821         .id = 1,
822 };
823 #endif
824
825 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
826 #include <linux/input.h>
827 #include <linux/gpio_keys.h>
828
829 static struct gpio_keys_button bfin_gpio_keys_table[] = {
830         {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
831         {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
832 };
833
834 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
835         .buttons        = bfin_gpio_keys_table,
836         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
837 };
838
839 static struct platform_device bfin_device_gpiokeys = {
840         .name      = "gpio-keys",
841         .dev = {
842                 .platform_data = &bfin_gpio_keys_data,
843         },
844 };
845 #endif
846
847 #if defined(CONFIG_JOYSTICK_BFIN_ROTARY) || defined(CONFIG_JOYSTICK_BFIN_ROTARY_MODULE)
848 #include <linux/input.h>
849 #include <asm/bfin_rotary.h>
850
851 static struct bfin_rotary_platform_data bfin_rotary_data = {
852         /*.rotary_up_key     = KEY_UP,*/
853         /*.rotary_down_key   = KEY_DOWN,*/
854         .rotary_rel_code   = REL_WHEEL,
855         .rotary_button_key = KEY_ENTER,
856         .debounce          = 10,        /* 0..17 */
857         .mode              = ROT_QUAD_ENC | ROT_DEBE,
858 };
859
860 static struct resource bfin_rotary_resources[] = {
861         {
862                 .start = IRQ_CNT,
863                 .end = IRQ_CNT,
864                 .flags = IORESOURCE_IRQ,
865         },
866 };
867
868 static struct platform_device bfin_rotary_device = {
869         .name           = "bfin-rotary",
870         .id             = -1,
871         .num_resources  = ARRAY_SIZE(bfin_rotary_resources),
872         .resource       = bfin_rotary_resources,
873         .dev            = {
874                 .platform_data = &bfin_rotary_data,
875         },
876 };
877 #endif
878
879 static struct resource bfin_gpios_resources = {
880         .start = 0,
881         .end   = MAX_BLACKFIN_GPIOS - 1,
882         .flags = IORESOURCE_IRQ,
883 };
884
885 static struct platform_device bfin_gpios_device = {
886         .name = "simple-gpio",
887         .id = -1,
888         .num_resources = 1,
889         .resource = &bfin_gpios_resources,
890 };
891
892 static const unsigned int cclk_vlev_datasheet[] =
893 {
894         VRPAIR(VLEV_100, 400000000),
895         VRPAIR(VLEV_105, 426000000),
896         VRPAIR(VLEV_110, 500000000),
897         VRPAIR(VLEV_115, 533000000),
898         VRPAIR(VLEV_120, 600000000),
899 };
900
901 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
902         .tuple_tab = cclk_vlev_datasheet,
903         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
904         .vr_settling_time = 25 /* us */,
905 };
906
907 static struct platform_device bfin_dpmc = {
908         .name = "bfin dpmc",
909         .dev = {
910                 .platform_data = &bfin_dmpc_vreg_data,
911         },
912 };
913
914 static struct platform_device *stamp_devices[] __initdata = {
915
916         &bfin_dpmc,
917
918 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
919         &bf5xx_nand_device,
920 #endif
921
922 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
923         &bfin_pcmcia_cf_device,
924 #endif
925
926 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
927         &rtc_device,
928 #endif
929
930 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
931         &sl811_hcd_device,
932 #endif
933
934 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
935         &isp1362_hcd_device,
936 #endif
937
938 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
939         &bfin_isp1760_device,
940 #endif
941
942 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
943         &musb_device,
944 #endif
945
946 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
947         &smc91x_device,
948 #endif
949
950 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
951         &dm9000_device,
952 #endif
953
954 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
955         &bfin_mac_device,
956 #endif
957
958 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
959         &net2272_bfin_device,
960 #endif
961
962 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
963         &bfin_spi0_device,
964 #endif
965
966 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
967         &bfin_fb_device,
968 #endif
969
970 #if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
971         &bf52x_t350mcqb_device,
972 #endif
973
974 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
975         &bfin_fb_adv7393_device,
976 #endif
977
978 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
979         &bfin_uart_device,
980 #endif
981
982 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
983 #ifdef CONFIG_BFIN_SIR0
984         &bfin_sir0_device,
985 #endif
986 #ifdef CONFIG_BFIN_SIR1
987         &bfin_sir1_device,
988 #endif
989 #endif
990
991 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
992         &i2c_bfin_twi_device,
993 #endif
994
995 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
996         &bfin_sport0_uart_device,
997         &bfin_sport1_uart_device,
998 #endif
999
1000 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
1001         &bfin_device_gpiokeys,
1002 #endif
1003
1004 #if defined(CONFIG_JOYSTICK_BFIN_ROTARY) || defined(CONFIG_JOYSTICK_BFIN_ROTARY_MODULE)
1005         &bfin_rotary_device,
1006 #endif
1007
1008 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
1009         &ezkit_flash_device,
1010 #endif
1011
1012         &bfin_gpios_device,
1013 };
1014
1015 static int __init stamp_init(void)
1016 {
1017         printk(KERN_INFO "%s(): registering device resources\n", __func__);
1018
1019 #ifdef CONFIG_I2C_BOARDINFO
1020         i2c_register_board_info(0, bfin_i2c_board_info,
1021                                 ARRAY_SIZE(bfin_i2c_board_info));
1022 #endif
1023
1024         platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
1025         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
1026         return 0;
1027 }
1028
1029 arch_initcall(stamp_init);
1030
1031 void native_machine_restart(char *cmd)
1032 {
1033         /* workaround reboot hang when booting from SPI */
1034         if ((bfin_read_SYSCR() & 0x7) == 0x3)
1035                 bfin_gpio_reset_spi0_ssel1();
1036 }
1037
1038 void bfin_get_ether_addr(char *addr)
1039 {
1040         /* the MAC is stored in OTP memory page 0xDF */
1041         u32 ret;
1042         u64 otp_mac;
1043         u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
1044
1045         ret = otp_read(0xDF, 0x00, &otp_mac);
1046         if (!(ret & 0x1)) {
1047                 char *otp_mac_p = (char *)&otp_mac;
1048                 for (ret = 0; ret < 6; ++ret)
1049                         addr[ret] = otp_mac_p[5 - ret];
1050         }
1051 }
1052 EXPORT_SYMBOL(bfin_get_ether_addr);