Blackfin: bf527-ezkit/bf537-stamp: add example SSM2602 I2C resources
[safe/jmp/linux-2.6] / arch / blackfin / mach-bf527 / boards / ezkit.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/platform_device.h>
11 #include <linux/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
13 #include <linux/mtd/physmap.h>
14 #include <linux/spi/spi.h>
15 #include <linux/spi/flash.h>
16 #include <linux/i2c.h>
17 #include <linux/irq.h>
18 #include <linux/interrupt.h>
19 #include <linux/usb/musb.h>
20 #include <linux/leds.h>
21 #include <linux/input.h>
22 #include <asm/dma.h>
23 #include <asm/bfin5xx_spi.h>
24 #include <asm/reboot.h>
25 #include <asm/nand.h>
26 #include <asm/portmux.h>
27 #include <asm/dpmc.h>
28 #include <linux/spi/ad7877.h>
29
30 /*
31  * Name the Board for the /proc/cpuinfo
32  */
33 #ifdef CONFIG_BFIN527_EZKIT_V2
34 const char bfin_board_name[] = "ADI BF527-EZKIT V2";
35 #else
36 const char bfin_board_name[] = "ADI BF527-EZKIT";
37 #endif
38
39 /*
40  *  Driver needs to know address, irq and flag pin.
41  */
42
43 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
44 #include <linux/usb/isp1760.h>
45 static struct resource bfin_isp1760_resources[] = {
46         [0] = {
47                 .start  = 0x203C0000,
48                 .end    = 0x203C0000 + 0x000fffff,
49                 .flags  = IORESOURCE_MEM,
50         },
51         [1] = {
52                 .start  = IRQ_PF7,
53                 .end    = IRQ_PF7,
54                 .flags  = IORESOURCE_IRQ,
55         },
56 };
57
58 static struct isp1760_platform_data isp1760_priv = {
59         .is_isp1761 = 0,
60         .bus_width_16 = 1,
61         .port1_otg = 0,
62         .analog_oc = 0,
63         .dack_polarity_high = 0,
64         .dreq_polarity_high = 0,
65 };
66
67 static struct platform_device bfin_isp1760_device = {
68         .name           = "isp1760",
69         .id             = 0,
70         .dev = {
71                 .platform_data = &isp1760_priv,
72         },
73         .num_resources  = ARRAY_SIZE(bfin_isp1760_resources),
74         .resource       = bfin_isp1760_resources,
75 };
76 #endif
77
78 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
79 static struct resource musb_resources[] = {
80         [0] = {
81                 .start  = 0xffc03800,
82                 .end    = 0xffc03cff,
83                 .flags  = IORESOURCE_MEM,
84         },
85         [1] = { /* general IRQ */
86                 .start  = IRQ_USB_INT0,
87                 .end    = IRQ_USB_INT0,
88                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
89         },
90         [2] = { /* DMA IRQ */
91                 .start  = IRQ_USB_DMA,
92                 .end    = IRQ_USB_DMA,
93                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
94         },
95 };
96
97 static struct musb_hdrc_config musb_config = {
98         .multipoint     = 0,
99         .dyn_fifo       = 0,
100         .soft_con       = 1,
101         .dma            = 1,
102         .num_eps        = 8,
103         .dma_channels   = 8,
104         .gpio_vrsel     = GPIO_PG13,
105 };
106
107 static struct musb_hdrc_platform_data musb_plat = {
108 #if defined(CONFIG_USB_MUSB_OTG)
109         .mode           = MUSB_OTG,
110 #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
111         .mode           = MUSB_HOST,
112 #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
113         .mode           = MUSB_PERIPHERAL,
114 #endif
115         .config         = &musb_config,
116 };
117
118 static u64 musb_dmamask = ~(u32)0;
119
120 static struct platform_device musb_device = {
121         .name           = "musb_hdrc",
122         .id             = 0,
123         .dev = {
124                 .dma_mask               = &musb_dmamask,
125                 .coherent_dma_mask      = 0xffffffff,
126                 .platform_data          = &musb_plat,
127         },
128         .num_resources  = ARRAY_SIZE(musb_resources),
129         .resource       = musb_resources,
130 };
131 #endif
132
133 #if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
134
135 static struct resource bf52x_t350mcqb_resources[] = {
136         {
137                 .start = IRQ_PPI_ERROR,
138                 .end = IRQ_PPI_ERROR,
139                 .flags = IORESOURCE_IRQ,
140         },
141 };
142
143 static struct platform_device bf52x_t350mcqb_device = {
144         .name           = "bfin-t350mcqb",
145         .id             = -1,
146         .num_resources  = ARRAY_SIZE(bf52x_t350mcqb_resources),
147         .resource       = bf52x_t350mcqb_resources,
148 };
149 #endif
150
151 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
152 #include <asm/bfin-lq035q1.h>
153
154 static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
155         .mode = LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
156         .ppi_mode = USE_RGB565_8_BIT_PPI,
157 };
158
159 static struct resource bfin_lq035q1_resources[] = {
160         {
161                 .start = IRQ_PPI_ERROR,
162                 .end = IRQ_PPI_ERROR,
163                 .flags = IORESOURCE_IRQ,
164         },
165 };
166
167 static struct platform_device bfin_lq035q1_device = {
168         .name           = "bfin-lq035q1",
169         .id             = -1,
170         .num_resources  = ARRAY_SIZE(bfin_lq035q1_resources),
171         .resource       = bfin_lq035q1_resources,
172         .dev            = {
173                 .platform_data = &bfin_lq035q1_data,
174         },
175 };
176 #endif
177
178 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
179 static struct mtd_partition ezkit_partitions[] = {
180         {
181                 .name       = "bootloader(nor)",
182                 .size       = 0x40000,
183                 .offset     = 0,
184         }, {
185                 .name       = "linux kernel(nor)",
186                 .size       = 0x1C0000,
187                 .offset     = MTDPART_OFS_APPEND,
188         }, {
189                 .name       = "file system(nor)",
190                 .size       = MTDPART_SIZ_FULL,
191                 .offset     = MTDPART_OFS_APPEND,
192         }
193 };
194
195 static struct physmap_flash_data ezkit_flash_data = {
196         .width      = 2,
197         .parts      = ezkit_partitions,
198         .nr_parts   = ARRAY_SIZE(ezkit_partitions),
199 };
200
201 static struct resource ezkit_flash_resource = {
202         .start = 0x20000000,
203         .end   = 0x203fffff,
204         .flags = IORESOURCE_MEM,
205 };
206
207 static struct platform_device ezkit_flash_device = {
208         .name          = "physmap-flash",
209         .id            = 0,
210         .dev = {
211                 .platform_data = &ezkit_flash_data,
212         },
213         .num_resources = 1,
214         .resource      = &ezkit_flash_resource,
215 };
216 #endif
217
218 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
219 static struct mtd_partition partition_info[] = {
220         {
221                 .name = "linux kernel(nand)",
222                 .offset = 0,
223                 .size = 4 * 1024 * 1024,
224         },
225         {
226                 .name = "file system(nand)",
227                 .offset = MTDPART_OFS_APPEND,
228                 .size = MTDPART_SIZ_FULL,
229         },
230 };
231
232 static struct bf5xx_nand_platform bf5xx_nand_platform = {
233         .page_size = NFC_PG_SIZE_256,
234         .data_width = NFC_NWIDTH_8,
235         .partitions = partition_info,
236         .nr_partitions = ARRAY_SIZE(partition_info),
237         .rd_dly = 3,
238         .wr_dly = 3,
239 };
240
241 static struct resource bf5xx_nand_resources[] = {
242         {
243                 .start = NFC_CTL,
244                 .end = NFC_DATA_RD + 2,
245                 .flags = IORESOURCE_MEM,
246         },
247         {
248                 .start = CH_NFC,
249                 .end = CH_NFC,
250                 .flags = IORESOURCE_IRQ,
251         },
252 };
253
254 static struct platform_device bf5xx_nand_device = {
255         .name = "bf5xx-nand",
256         .id = 0,
257         .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
258         .resource = bf5xx_nand_resources,
259         .dev = {
260                 .platform_data = &bf5xx_nand_platform,
261         },
262 };
263 #endif
264
265 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
266 static struct resource bfin_pcmcia_cf_resources[] = {
267         {
268                 .start = 0x20310000, /* IO PORT */
269                 .end = 0x20312000,
270                 .flags = IORESOURCE_MEM,
271         }, {
272                 .start = 0x20311000, /* Attribute Memory */
273                 .end = 0x20311FFF,
274                 .flags = IORESOURCE_MEM,
275         }, {
276                 .start = IRQ_PF4,
277                 .end = IRQ_PF4,
278                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
279         }, {
280                 .start = 6, /* Card Detect PF6 */
281                 .end = 6,
282                 .flags = IORESOURCE_IRQ,
283         },
284 };
285
286 static struct platform_device bfin_pcmcia_cf_device = {
287         .name = "bfin_cf_pcmcia",
288         .id = -1,
289         .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
290         .resource = bfin_pcmcia_cf_resources,
291 };
292 #endif
293
294 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
295 static struct platform_device rtc_device = {
296         .name = "rtc-bfin",
297         .id   = -1,
298 };
299 #endif
300
301 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
302 #include <linux/smc91x.h>
303
304 static struct smc91x_platdata smc91x_info = {
305         .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
306         .leda = RPC_LED_100_10,
307         .ledb = RPC_LED_TX_RX,
308 };
309
310 static struct resource smc91x_resources[] = {
311         {
312                 .name = "smc91x-regs",
313                 .start = 0x20300300,
314                 .end = 0x20300300 + 16,
315                 .flags = IORESOURCE_MEM,
316         }, {
317
318                 .start = IRQ_PF7,
319                 .end = IRQ_PF7,
320                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
321         },
322 };
323 static struct platform_device smc91x_device = {
324         .name = "smc91x",
325         .id = 0,
326         .num_resources = ARRAY_SIZE(smc91x_resources),
327         .resource = smc91x_resources,
328         .dev    = {
329                 .platform_data  = &smc91x_info,
330         },
331 };
332 #endif
333
334 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
335 static struct resource dm9000_resources[] = {
336         [0] = {
337                 .start  = 0x203FB800,
338                 .end    = 0x203FB800 + 1,
339                 .flags  = IORESOURCE_MEM,
340         },
341         [1] = {
342                 .start  = 0x203FB800 + 4,
343                 .end    = 0x203FB800 + 5,
344                 .flags  = IORESOURCE_MEM,
345         },
346         [2] = {
347                 .start  = IRQ_PF9,
348                 .end    = IRQ_PF9,
349                 .flags  = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
350         },
351 };
352
353 static struct platform_device dm9000_device = {
354         .name           = "dm9000",
355         .id             = -1,
356         .num_resources  = ARRAY_SIZE(dm9000_resources),
357         .resource       = dm9000_resources,
358 };
359 #endif
360
361 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
362 static struct platform_device bfin_mii_bus = {
363         .name = "bfin_mii_bus",
364 };
365
366 static struct platform_device bfin_mac_device = {
367         .name = "bfin_mac",
368         .dev.platform_data = &bfin_mii_bus,
369 };
370 #endif
371
372 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
373 static struct resource net2272_bfin_resources[] = {
374         {
375                 .start = 0x20300000,
376                 .end = 0x20300000 + 0x100,
377                 .flags = IORESOURCE_MEM,
378         }, {
379                 .start = IRQ_PF7,
380                 .end = IRQ_PF7,
381                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
382         },
383 };
384
385 static struct platform_device net2272_bfin_device = {
386         .name = "net2272",
387         .id = -1,
388         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
389         .resource = net2272_bfin_resources,
390 };
391 #endif
392
393 #if defined(CONFIG_MTD_M25P80) \
394         || defined(CONFIG_MTD_M25P80_MODULE)
395 static struct mtd_partition bfin_spi_flash_partitions[] = {
396         {
397                 .name = "bootloader(spi)",
398                 .size = 0x00040000,
399                 .offset = 0,
400                 .mask_flags = MTD_CAP_ROM
401         }, {
402                 .name = "linux kernel(spi)",
403                 .size = MTDPART_SIZ_FULL,
404                 .offset = MTDPART_OFS_APPEND,
405         }
406 };
407
408 static struct flash_platform_data bfin_spi_flash_data = {
409         .name = "m25p80",
410         .parts = bfin_spi_flash_partitions,
411         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
412         .type = "m25p16",
413 };
414
415 /* SPI flash chip (m25p64) */
416 static struct bfin5xx_spi_chip spi_flash_chip_info = {
417         .enable_dma = 0,         /* use dma transfer with this chip*/
418         .bits_per_word = 8,
419 };
420 #endif
421
422 #if defined(CONFIG_BFIN_SPI_ADC) \
423         || defined(CONFIG_BFIN_SPI_ADC_MODULE)
424 /* SPI ADC chip */
425 static struct bfin5xx_spi_chip spi_adc_chip_info = {
426         .enable_dma = 1,         /* use dma transfer with this chip*/
427         .bits_per_word = 16,
428 };
429 #endif
430
431 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
432         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
433 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
434         .enable_dma = 0,
435         .bits_per_word = 16,
436 };
437 #endif
438
439 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
440 static struct bfin5xx_spi_chip  mmc_spi_chip_info = {
441         .enable_dma = 0,
442         .bits_per_word = 8,
443 };
444 #endif
445
446 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
447 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
448         .enable_dma = 0,
449         .bits_per_word = 16,
450 };
451
452 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
453         .model                  = 7877,
454         .vref_delay_usecs       = 50,   /* internal, no capacitor */
455         .x_plate_ohms           = 419,
456         .y_plate_ohms           = 486,
457         .pressure_max           = 1000,
458         .pressure_min           = 0,
459         .stopacq_polarity       = 1,
460         .first_conversion_delay = 3,
461         .acquisition_time       = 1,
462         .averaging              = 1,
463         .pen_down_acc_interval  = 1,
464 };
465 #endif
466
467 #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
468 #include <linux/spi/ad7879.h>
469 static const struct ad7879_platform_data bfin_ad7879_ts_info = {
470         .model                  = 7879, /* Model = AD7879 */
471         .x_plate_ohms           = 620,  /* 620 Ohm from the touch datasheet */
472         .pressure_max           = 10000,
473         .pressure_min           = 0,
474         .first_conversion_delay = 3,    /* wait 512us before do a first conversion */
475         .acquisition_time       = 1,    /* 4us acquisition time per sample */
476         .median                 = 2,    /* do 8 measurements */
477         .averaging              = 1,    /* take the average of 4 middle samples */
478         .pen_down_acc_interval  = 255,  /* 9.4 ms */
479         .gpio_export            = 0,    /* Export GPIO to gpiolib */
480 };
481 #endif
482
483 #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
484 static struct bfin5xx_spi_chip spi_ad7879_chip_info = {
485         .enable_dma = 0,
486         .bits_per_word = 16,
487 };
488 #endif
489
490 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
491 static struct bfin5xx_spi_chip spidev_chip_info = {
492         .enable_dma = 0,
493         .bits_per_word = 8,
494 };
495 #endif
496
497 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
498 static struct bfin5xx_spi_chip lq035q1_spi_chip_info = {
499         .enable_dma     = 0,
500         .bits_per_word  = 8,
501 };
502 #endif
503
504 static struct spi_board_info bfin_spi_board_info[] __initdata = {
505 #if defined(CONFIG_MTD_M25P80) \
506         || defined(CONFIG_MTD_M25P80_MODULE)
507         {
508                 /* the modalias must be the same as spi device driver name */
509                 .modalias = "m25p80", /* Name of spi_driver for this device */
510                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
511                 .bus_num = 0, /* Framework bus number */
512                 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
513                 .platform_data = &bfin_spi_flash_data,
514                 .controller_data = &spi_flash_chip_info,
515                 .mode = SPI_MODE_3,
516         },
517 #endif
518
519 #if defined(CONFIG_BFIN_SPI_ADC) \
520         || defined(CONFIG_BFIN_SPI_ADC_MODULE)
521         {
522                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
523                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
524                 .bus_num = 0, /* Framework bus number */
525                 .chip_select = 1, /* Framework chip select. */
526                 .platform_data = NULL, /* No spi_driver specific config */
527                 .controller_data = &spi_adc_chip_info,
528         },
529 #endif
530
531 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
532         || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
533         {
534                 .modalias = "ad1836",
535                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
536                 .bus_num = 0,
537                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
538                 .controller_data = &ad1836_spi_chip_info,
539         },
540 #endif
541 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
542         {
543                 .modalias = "mmc_spi",
544                 .max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
545                 .bus_num = 0,
546                 .chip_select = 3,
547                 .controller_data = &mmc_spi_chip_info,
548                 .mode = SPI_MODE_0,
549         },
550 #endif
551
552 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
553         {
554                 .modalias               = "ad7877",
555                 .platform_data          = &bfin_ad7877_ts_info,
556                 .irq                    = IRQ_PF8,
557                 .max_speed_hz   = 12500000,     /* max spi clock (SCK) speed in HZ */
558                 .bus_num        = 0,
559                 .chip_select  = 2,
560                 .controller_data = &spi_ad7877_chip_info,
561         },
562 #endif
563 #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
564         {
565                 .modalias = "ad7879",
566                 .platform_data = &bfin_ad7879_ts_info,
567                 .irq = IRQ_PF8,
568                 .max_speed_hz = 5000000,     /* max spi clock (SCK) speed in HZ */
569                 .bus_num = 0,
570                 .chip_select = 3,
571                 .controller_data = &spi_ad7879_chip_info,
572                 .mode = SPI_CPHA | SPI_CPOL,
573         },
574 #endif
575 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
576         {
577                 .modalias = "spidev",
578                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
579                 .bus_num = 0,
580                 .chip_select = 1,
581                 .controller_data = &spidev_chip_info,
582         },
583 #endif
584 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
585         {
586                 .modalias = "bfin-lq035q1-spi",
587                 .max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
588                 .bus_num = 0,
589                 .chip_select = 7,
590                 .controller_data = &lq035q1_spi_chip_info,
591                 .mode = SPI_CPHA | SPI_CPOL,
592         },
593 #endif
594 };
595
596 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
597 /* SPI controller data */
598 static struct bfin5xx_spi_master bfin_spi0_info = {
599         .num_chipselect = 8,
600         .enable_dma = 1,  /* master has the ability to do dma transfer */
601         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
602 };
603
604 /* SPI (0) */
605 static struct resource bfin_spi0_resource[] = {
606         [0] = {
607                 .start = SPI0_REGBASE,
608                 .end   = SPI0_REGBASE + 0xFF,
609                 .flags = IORESOURCE_MEM,
610                 },
611         [1] = {
612                 .start = CH_SPI,
613                 .end   = CH_SPI,
614                 .flags = IORESOURCE_DMA,
615         },
616         [2] = {
617                 .start = IRQ_SPI,
618                 .end   = IRQ_SPI,
619                 .flags = IORESOURCE_IRQ,
620         },
621 };
622
623 static struct platform_device bfin_spi0_device = {
624         .name = "bfin-spi",
625         .id = 0, /* Bus number */
626         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
627         .resource = bfin_spi0_resource,
628         .dev = {
629                 .platform_data = &bfin_spi0_info, /* Passed to driver */
630         },
631 };
632 #endif  /* spi master and devices */
633
634 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
635 #ifdef CONFIG_SERIAL_BFIN_UART0
636 static struct resource bfin_uart0_resources[] = {
637         {
638                 .start = UART0_THR,
639                 .end = UART0_GCTL+2,
640                 .flags = IORESOURCE_MEM,
641         },
642         {
643                 .start = IRQ_UART0_RX,
644                 .end = IRQ_UART0_RX+1,
645                 .flags = IORESOURCE_IRQ,
646         },
647         {
648                 .start = IRQ_UART0_ERROR,
649                 .end = IRQ_UART0_ERROR,
650                 .flags = IORESOURCE_IRQ,
651         },
652         {
653                 .start = CH_UART0_TX,
654                 .end = CH_UART0_TX,
655                 .flags = IORESOURCE_DMA,
656         },
657         {
658                 .start = CH_UART0_RX,
659                 .end = CH_UART0_RX,
660                 .flags = IORESOURCE_DMA,
661         },
662 };
663
664 unsigned short bfin_uart0_peripherals[] = {
665         P_UART0_TX, P_UART0_RX, 0
666 };
667
668 static struct platform_device bfin_uart0_device = {
669         .name = "bfin-uart",
670         .id = 0,
671         .num_resources = ARRAY_SIZE(bfin_uart0_resources),
672         .resource = bfin_uart0_resources,
673         .dev = {
674                 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
675         },
676 };
677 #endif
678 #ifdef CONFIG_SERIAL_BFIN_UART1
679 static struct resource bfin_uart1_resources[] = {
680         {
681                 .start = UART1_THR,
682                 .end = UART1_GCTL+2,
683                 .flags = IORESOURCE_MEM,
684         },
685         {
686                 .start = IRQ_UART1_RX,
687                 .end = IRQ_UART1_RX+1,
688                 .flags = IORESOURCE_IRQ,
689         },
690         {
691                 .start = IRQ_UART1_ERROR,
692                 .end = IRQ_UART1_ERROR,
693                 .flags = IORESOURCE_IRQ,
694         },
695         {
696                 .start = CH_UART1_TX,
697                 .end = CH_UART1_TX,
698                 .flags = IORESOURCE_DMA,
699         },
700         {
701                 .start = CH_UART1_RX,
702                 .end = CH_UART1_RX,
703                 .flags = IORESOURCE_DMA,
704         },
705 #ifdef CONFIG_BFIN_UART1_CTSRTS
706         {       /* CTS pin */
707                 .start = GPIO_PF9,
708                 .end = GPIO_PF9,
709                 .flags = IORESOURCE_IO,
710         },
711         {       /* RTS pin */
712                 .start = GPIO_PF10,
713                 .end = GPIO_PF10,
714                 .flags = IORESOURCE_IO,
715         },
716 #endif
717 };
718
719 unsigned short bfin_uart1_peripherals[] = {
720         P_UART1_TX, P_UART1_RX, 0
721 };
722
723 static struct platform_device bfin_uart1_device = {
724         .name = "bfin-uart",
725         .id = 1,
726         .num_resources = ARRAY_SIZE(bfin_uart1_resources),
727         .resource = bfin_uart1_resources,
728         .dev = {
729                 .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
730         },
731 };
732 #endif
733 #endif
734
735 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
736 #ifdef CONFIG_BFIN_SIR0
737 static struct resource bfin_sir0_resources[] = {
738         {
739                 .start = 0xFFC00400,
740                 .end = 0xFFC004FF,
741                 .flags = IORESOURCE_MEM,
742         },
743         {
744                 .start = IRQ_UART0_RX,
745                 .end = IRQ_UART0_RX+1,
746                 .flags = IORESOURCE_IRQ,
747         },
748         {
749                 .start = CH_UART0_RX,
750                 .end = CH_UART0_RX+1,
751                 .flags = IORESOURCE_DMA,
752         },
753 };
754
755 static struct platform_device bfin_sir0_device = {
756         .name = "bfin_sir",
757         .id = 0,
758         .num_resources = ARRAY_SIZE(bfin_sir0_resources),
759         .resource = bfin_sir0_resources,
760 };
761 #endif
762 #ifdef CONFIG_BFIN_SIR1
763 static struct resource bfin_sir1_resources[] = {
764         {
765                 .start = 0xFFC02000,
766                 .end = 0xFFC020FF,
767                 .flags = IORESOURCE_MEM,
768         },
769         {
770                 .start = IRQ_UART1_RX,
771                 .end = IRQ_UART1_RX+1,
772                 .flags = IORESOURCE_IRQ,
773         },
774         {
775                 .start = CH_UART1_RX,
776                 .end = CH_UART1_RX+1,
777                 .flags = IORESOURCE_DMA,
778         },
779 };
780
781 static struct platform_device bfin_sir1_device = {
782         .name = "bfin_sir",
783         .id = 1,
784         .num_resources = ARRAY_SIZE(bfin_sir1_resources),
785         .resource = bfin_sir1_resources,
786 };
787 #endif
788 #endif
789
790 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
791 static struct resource bfin_twi0_resource[] = {
792         [0] = {
793                 .start = TWI0_REGBASE,
794                 .end   = TWI0_REGBASE,
795                 .flags = IORESOURCE_MEM,
796         },
797         [1] = {
798                 .start = IRQ_TWI,
799                 .end   = IRQ_TWI,
800                 .flags = IORESOURCE_IRQ,
801         },
802 };
803
804 static struct platform_device i2c_bfin_twi_device = {
805         .name = "i2c-bfin-twi",
806         .id = 0,
807         .num_resources = ARRAY_SIZE(bfin_twi0_resource),
808         .resource = bfin_twi0_resource,
809 };
810 #endif
811
812 #if defined(CONFIG_PMIC_ADP5520) || defined(CONFIG_PMIC_ADP5520_MODULE)
813 #include <linux/mfd/adp5520.h>
814
815         /*
816          *  ADP5520/5501 LEDs Data
817          */
818
819 static struct led_info adp5520_leds[] = {
820         {
821                 .name = "adp5520-led1",
822                 .default_trigger = "none",
823                 .flags = FLAG_ID_ADP5520_LED1_ADP5501_LED0 | ADP5520_LED_OFFT_600ms,
824         },
825 };
826
827 static struct adp5520_leds_platform_data adp5520_leds_data = {
828         .num_leds = ARRAY_SIZE(adp5520_leds),
829         .leds = adp5520_leds,
830         .fade_in = ADP5520_FADE_T_600ms,
831         .fade_out = ADP5520_FADE_T_600ms,
832         .led_on_time = ADP5520_LED_ONT_600ms,
833 };
834
835         /*
836          *  ADP5520 Keypad Data
837          */
838
839 static const unsigned short adp5520_keymap[ADP5520_KEYMAPSIZE] = {
840         [ADP5520_KEY(3, 3)]     = KEY_1,
841         [ADP5520_KEY(2, 3)]     = KEY_2,
842         [ADP5520_KEY(1, 3)]     = KEY_3,
843         [ADP5520_KEY(0, 3)]     = KEY_UP,
844         [ADP5520_KEY(3, 2)]     = KEY_4,
845         [ADP5520_KEY(2, 2)]     = KEY_5,
846         [ADP5520_KEY(1, 2)]     = KEY_6,
847         [ADP5520_KEY(0, 2)]     = KEY_DOWN,
848         [ADP5520_KEY(3, 1)]     = KEY_7,
849         [ADP5520_KEY(2, 1)]     = KEY_8,
850         [ADP5520_KEY(1, 1)]     = KEY_9,
851         [ADP5520_KEY(0, 1)]     = KEY_DOT,
852         [ADP5520_KEY(3, 0)]     = KEY_BACKSPACE,
853         [ADP5520_KEY(2, 0)]     = KEY_0,
854         [ADP5520_KEY(1, 0)]     = KEY_HELP,
855         [ADP5520_KEY(0, 0)]     = KEY_ENTER,
856 };
857
858 static struct adp5520_keys_platform_data adp5520_keys_data = {
859         .rows_en_mask   = ADP5520_ROW_R3 | ADP5520_ROW_R2 | ADP5520_ROW_R1 | ADP5520_ROW_R0,
860         .cols_en_mask   = ADP5520_COL_C3 | ADP5520_COL_C2 | ADP5520_COL_C1 | ADP5520_COL_C0,
861         .keymap         = adp5520_keymap,
862         .keymapsize     = ARRAY_SIZE(adp5520_keymap),
863         .repeat         = 0,
864 };
865
866         /*
867          *  ADP5520/5501 Multifuction Device Init Data
868          */
869
870 static struct adp5520_platform_data adp5520_pdev_data = {
871         .leds = &adp5520_leds_data,
872         .keys = &adp5520_keys_data,
873 };
874
875 #endif
876
877 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
878 #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
879         {
880                 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
881         },
882 #endif
883 #if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
884         {
885                 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
886                 .irq = IRQ_PF8,
887         },
888 #endif
889 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
890         {
891                 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
892         },
893 #endif
894 #if defined(CONFIG_TOUCHSCREEN_AD7879_I2C) || defined(CONFIG_TOUCHSCREEN_AD7879_I2C_MODULE)
895         {
896                 I2C_BOARD_INFO("ad7879", 0x2C),
897                 .irq = IRQ_PF8,
898                 .platform_data = (void *)&bfin_ad7879_ts_info,
899         },
900 #endif
901 #if defined(CONFIG_PMIC_ADP5520) || defined(CONFIG_PMIC_ADP5520_MODULE)
902         {
903                 I2C_BOARD_INFO("pmic-adp5520", 0x32),
904                 .irq = IRQ_PF9,
905                 .platform_data = (void *)&adp5520_pdev_data,
906         },
907 #endif
908 #if defined(CONFIG_SND_SOC_SSM2602) || defined(CONFIG_SND_SOC_SSM2602_MODULE)
909         {
910                 I2C_BOARD_INFO("ssm2602", 0x1b),
911         },
912 #endif
913 };
914
915 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
916 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
917 static struct resource bfin_sport0_uart_resources[] = {
918         {
919                 .start = SPORT0_TCR1,
920                 .end = SPORT0_MRCS3+4,
921                 .flags = IORESOURCE_MEM,
922         },
923         {
924                 .start = IRQ_SPORT0_RX,
925                 .end = IRQ_SPORT0_RX+1,
926                 .flags = IORESOURCE_IRQ,
927         },
928         {
929                 .start = IRQ_SPORT0_ERROR,
930                 .end = IRQ_SPORT0_ERROR,
931                 .flags = IORESOURCE_IRQ,
932         },
933 };
934
935 unsigned short bfin_sport0_peripherals[] = {
936         P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
937         P_SPORT0_DRPRI, P_SPORT0_RSCLK, P_SPORT0_DRSEC, P_SPORT0_DTSEC, 0
938 };
939
940 static struct platform_device bfin_sport0_uart_device = {
941         .name = "bfin-sport-uart",
942         .id = 0,
943         .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
944         .resource = bfin_sport0_uart_resources,
945         .dev = {
946                 .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
947         },
948 };
949 #endif
950 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
951 static struct resource bfin_sport1_uart_resources[] = {
952         {
953                 .start = SPORT1_TCR1,
954                 .end = SPORT1_MRCS3+4,
955                 .flags = IORESOURCE_MEM,
956         },
957         {
958                 .start = IRQ_SPORT1_RX,
959                 .end = IRQ_SPORT1_RX+1,
960                 .flags = IORESOURCE_IRQ,
961         },
962         {
963                 .start = IRQ_SPORT1_ERROR,
964                 .end = IRQ_SPORT1_ERROR,
965                 .flags = IORESOURCE_IRQ,
966         },
967 };
968
969 unsigned short bfin_sport1_peripherals[] = {
970         P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
971         P_SPORT1_DRPRI, P_SPORT1_RSCLK, P_SPORT1_DRSEC, P_SPORT1_DTSEC, 0
972 };
973
974 static struct platform_device bfin_sport1_uart_device = {
975         .name = "bfin-sport-uart",
976         .id = 1,
977         .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
978         .resource = bfin_sport1_uart_resources,
979         .dev = {
980                 .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
981         },
982 };
983 #endif
984 #endif
985
986 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
987 #include <linux/gpio_keys.h>
988
989 static struct gpio_keys_button bfin_gpio_keys_table[] = {
990         {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
991         {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
992 };
993
994 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
995         .buttons        = bfin_gpio_keys_table,
996         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
997 };
998
999 static struct platform_device bfin_device_gpiokeys = {
1000         .name      = "gpio-keys",
1001         .dev = {
1002                 .platform_data = &bfin_gpio_keys_data,
1003         },
1004 };
1005 #endif
1006
1007 #if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE)
1008 #include <asm/bfin_rotary.h>
1009
1010 static struct bfin_rotary_platform_data bfin_rotary_data = {
1011         /*.rotary_up_key     = KEY_UP,*/
1012         /*.rotary_down_key   = KEY_DOWN,*/
1013         .rotary_rel_code   = REL_WHEEL,
1014         .rotary_button_key = KEY_ENTER,
1015         .debounce          = 10,        /* 0..17 */
1016         .mode              = ROT_QUAD_ENC | ROT_DEBE,
1017 };
1018
1019 static struct resource bfin_rotary_resources[] = {
1020         {
1021                 .start = IRQ_CNT,
1022                 .end = IRQ_CNT,
1023                 .flags = IORESOURCE_IRQ,
1024         },
1025 };
1026
1027 static struct platform_device bfin_rotary_device = {
1028         .name           = "bfin-rotary",
1029         .id             = -1,
1030         .num_resources  = ARRAY_SIZE(bfin_rotary_resources),
1031         .resource       = bfin_rotary_resources,
1032         .dev            = {
1033                 .platform_data = &bfin_rotary_data,
1034         },
1035 };
1036 #endif
1037
1038 static const unsigned int cclk_vlev_datasheet[] =
1039 {
1040         VRPAIR(VLEV_100, 400000000),
1041         VRPAIR(VLEV_105, 426000000),
1042         VRPAIR(VLEV_110, 500000000),
1043         VRPAIR(VLEV_115, 533000000),
1044         VRPAIR(VLEV_120, 600000000),
1045 };
1046
1047 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
1048         .tuple_tab = cclk_vlev_datasheet,
1049         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
1050         .vr_settling_time = 25 /* us */,
1051 };
1052
1053 static struct platform_device bfin_dpmc = {
1054         .name = "bfin dpmc",
1055         .dev = {
1056                 .platform_data = &bfin_dmpc_vreg_data,
1057         },
1058 };
1059
1060 static struct platform_device *stamp_devices[] __initdata = {
1061
1062         &bfin_dpmc,
1063
1064 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
1065         &bf5xx_nand_device,
1066 #endif
1067
1068 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
1069         &bfin_pcmcia_cf_device,
1070 #endif
1071
1072 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
1073         &rtc_device,
1074 #endif
1075
1076 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
1077         &bfin_isp1760_device,
1078 #endif
1079
1080 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
1081         &musb_device,
1082 #endif
1083
1084 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
1085         &smc91x_device,
1086 #endif
1087
1088 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
1089         &dm9000_device,
1090 #endif
1091
1092 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
1093         &bfin_mii_bus,
1094         &bfin_mac_device,
1095 #endif
1096
1097 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
1098         &net2272_bfin_device,
1099 #endif
1100
1101 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
1102         &bfin_spi0_device,
1103 #endif
1104
1105 #if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
1106         &bf52x_t350mcqb_device,
1107 #endif
1108
1109 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
1110         &bfin_lq035q1_device,
1111 #endif
1112
1113 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
1114 #ifdef CONFIG_SERIAL_BFIN_UART0
1115         &bfin_uart0_device,
1116 #endif
1117 #ifdef CONFIG_SERIAL_BFIN_UART1
1118         &bfin_uart1_device,
1119 #endif
1120 #endif
1121
1122 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
1123 #ifdef CONFIG_BFIN_SIR0
1124         &bfin_sir0_device,
1125 #endif
1126 #ifdef CONFIG_BFIN_SIR1
1127         &bfin_sir1_device,
1128 #endif
1129 #endif
1130
1131 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
1132         &i2c_bfin_twi_device,
1133 #endif
1134
1135 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
1136 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
1137         &bfin_sport0_uart_device,
1138 #endif
1139 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
1140         &bfin_sport1_uart_device,
1141 #endif
1142 #endif
1143
1144 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
1145         &bfin_device_gpiokeys,
1146 #endif
1147
1148 #if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE)
1149         &bfin_rotary_device,
1150 #endif
1151
1152 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
1153         &ezkit_flash_device,
1154 #endif
1155 };
1156
1157 static int __init ezkit_init(void)
1158 {
1159         printk(KERN_INFO "%s(): registering device resources\n", __func__);
1160         i2c_register_board_info(0, bfin_i2c_board_info,
1161                                 ARRAY_SIZE(bfin_i2c_board_info));
1162         platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
1163         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
1164         return 0;
1165 }
1166
1167 arch_initcall(ezkit_init);
1168
1169 static struct platform_device *ezkit_early_devices[] __initdata = {
1170 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
1171 #ifdef CONFIG_SERIAL_BFIN_UART0
1172         &bfin_uart0_device,
1173 #endif
1174 #ifdef CONFIG_SERIAL_BFIN_UART1
1175         &bfin_uart1_device,
1176 #endif
1177 #endif
1178
1179 #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
1180 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
1181         &bfin_sport0_uart_device,
1182 #endif
1183 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
1184         &bfin_sport1_uart_device,
1185 #endif
1186 #endif
1187 };
1188
1189 void __init native_machine_early_platform_add_devices(void)
1190 {
1191         printk(KERN_INFO "register early platform devices\n");
1192         early_platform_add_devices(ezkit_early_devices,
1193                 ARRAY_SIZE(ezkit_early_devices));
1194 }
1195
1196 void native_machine_restart(char *cmd)
1197 {
1198         /* workaround reboot hang when booting from SPI */
1199         if ((bfin_read_SYSCR() & 0x7) == 0x3)
1200                 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
1201 }
1202
1203 void bfin_get_ether_addr(char *addr)
1204 {
1205         /* the MAC is stored in OTP memory page 0xDF */
1206         u32 ret;
1207         u64 otp_mac;
1208         u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
1209
1210         ret = otp_read(0xDF, 0x00, &otp_mac);
1211         if (!(ret & 0x1)) {
1212                 char *otp_mac_p = (char *)&otp_mac;
1213                 for (ret = 0; ret < 6; ++ret)
1214                         addr[ret] = otp_mac_p[5 - ret];
1215         }
1216 }
1217 EXPORT_SYMBOL(bfin_get_ether_addr);