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