blackfin: cleanup board files
[linux.git] / arch / blackfin / mach-bf533 / boards / stamp.c
1 /*
2  * Copyright 2004-2009 Analog Devices Inc.
3  *                2005 National ICT Australia (NICTA)
4  *                      Aidan Williams <aidan@nicta.com.au>
5  *
6  * Licensed under the GPL-2 or later.
7  */
8
9 #include <linux/device.h>
10 #include <linux/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/spi/mmc_spi.h>
17 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
18 #include <linux/usb/isp1362.h>
19 #endif
20 #include <linux/irq.h>
21 #include <linux/i2c.h>
22 #include <asm/dma.h>
23 #include <asm/bfin5xx_spi.h>
24 #include <asm/reboot.h>
25 #include <asm/portmux.h>
26 #include <asm/dpmc.h>
27
28 /*
29  * Name the Board for the /proc/cpuinfo
30  */
31 const char bfin_board_name[] = "ADI BF533-STAMP";
32
33 #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
34 static struct platform_device rtc_device = {
35         .name = "rtc-bfin",
36         .id   = -1,
37 };
38 #endif
39
40 /*
41  *  Driver needs to know address, irq and flag pin.
42  */
43 #if IS_ENABLED(CONFIG_SMC91X)
44 #include <linux/smc91x.h>
45
46 static struct smc91x_platdata smc91x_info = {
47         .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
48         .leda = RPC_LED_100_10,
49         .ledb = RPC_LED_TX_RX,
50 };
51
52 static struct resource smc91x_resources[] = {
53         {
54                 .name = "smc91x-regs",
55                 .start = 0x20300300,
56                 .end = 0x20300300 + 16,
57                 .flags = IORESOURCE_MEM,
58         }, {
59                 .start = IRQ_PF7,
60                 .end = IRQ_PF7,
61                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
62         },
63 };
64
65 static struct platform_device smc91x_device = {
66         .name = "smc91x",
67         .id = 0,
68         .num_resources = ARRAY_SIZE(smc91x_resources),
69         .resource = smc91x_resources,
70         .dev    = {
71                 .platform_data  = &smc91x_info,
72         },
73 };
74 #endif
75
76 #if IS_ENABLED(CONFIG_USB_NET2272)
77 static struct resource net2272_bfin_resources[] = {
78         {
79                 .start = 0x20300000,
80                 .end = 0x20300000 + 0x100,
81                 .flags = IORESOURCE_MEM,
82         }, {
83                 .start = 1,
84                 .flags = IORESOURCE_BUS,
85         }, {
86                 .start = IRQ_PF10,
87                 .end = IRQ_PF10,
88                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
89         },
90 };
91
92 static struct platform_device net2272_bfin_device = {
93         .name = "net2272",
94         .id = -1,
95         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
96         .resource = net2272_bfin_resources,
97 };
98 #endif
99
100 #if IS_ENABLED(CONFIG_MTD_BFIN_ASYNC)
101 static struct mtd_partition stamp_partitions[] = {
102         {
103                 .name   = "bootloader(nor)",
104                 .size   = 0x40000,
105                 .offset = 0,
106         }, {
107                 .name   = "linux kernel(nor)",
108                 .size   = 0x180000,
109                 .offset = MTDPART_OFS_APPEND,
110         }, {
111                 .name   = "file system(nor)",
112                 .size   = MTDPART_SIZ_FULL,
113                 .offset = MTDPART_OFS_APPEND,
114         }
115 };
116
117 static struct physmap_flash_data stamp_flash_data = {
118         .width    = 2,
119         .parts    = stamp_partitions,
120         .nr_parts = ARRAY_SIZE(stamp_partitions),
121 };
122
123 static struct resource stamp_flash_resource[] = {
124         {
125                 .name  = "cfi_probe",
126                 .start = 0x20000000,
127                 .end   = 0x203fffff,
128                 .flags = IORESOURCE_MEM,
129         }, {
130                 .start = 0x7BB07BB0,    /* AMBCTL0 setting when accessing flash */
131                 .end   = 0x7BB07BB0,    /* AMBCTL1 setting when accessing flash */
132                 .flags = IORESOURCE_MEM,
133         }, {
134                 .start = GPIO_PF0,
135                 .flags = IORESOURCE_IRQ,
136         }
137 };
138
139 static struct platform_device stamp_flash_device = {
140         .name          = "bfin-async-flash",
141         .id            = 0,
142         .dev = {
143                 .platform_data = &stamp_flash_data,
144         },
145         .num_resources = ARRAY_SIZE(stamp_flash_resource),
146         .resource      = stamp_flash_resource,
147 };
148 #endif
149
150 #if IS_ENABLED(CONFIG_MTD_M25P80)
151 static struct mtd_partition bfin_spi_flash_partitions[] = {
152         {
153                 .name = "bootloader(spi)",
154                 .size = 0x00040000,
155                 .offset = 0,
156                 .mask_flags = MTD_CAP_ROM
157         }, {
158                 .name = "linux kernel(spi)",
159                 .size = 0x180000,
160                 .offset = MTDPART_OFS_APPEND,
161         }, {
162                 .name = "file system(spi)",
163                 .size = MTDPART_SIZ_FULL,
164                 .offset = MTDPART_OFS_APPEND,
165         }
166 };
167
168 static struct flash_platform_data bfin_spi_flash_data = {
169         .name = "m25p80",
170         .parts = bfin_spi_flash_partitions,
171         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
172         .type = "m25p64",
173 };
174
175 /* SPI flash chip (m25p64) */
176 static struct bfin5xx_spi_chip spi_flash_chip_info = {
177         .enable_dma = 0,         /* use dma transfer with this chip*/
178 };
179 #endif
180
181 #if IS_ENABLED(CONFIG_MMC_SPI)
182 #define MMC_SPI_CARD_DETECT_INT IRQ_PF5
183 static int bfin_mmc_spi_init(struct device *dev,
184         irqreturn_t (*detect_int)(int, void *), void *data)
185 {
186         return request_irq(MMC_SPI_CARD_DETECT_INT, detect_int,
187                 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
188                 "mmc-spi-detect", data);
189 }
190
191 static void bfin_mmc_spi_exit(struct device *dev, void *data)
192 {
193         free_irq(MMC_SPI_CARD_DETECT_INT, data);
194 }
195
196 static struct mmc_spi_platform_data bfin_mmc_spi_pdata = {
197         .init = bfin_mmc_spi_init,
198         .exit = bfin_mmc_spi_exit,
199         .detect_delay = 100, /* msecs */
200 };
201
202 static struct bfin5xx_spi_chip  mmc_spi_chip_info = {
203         .enable_dma = 0,
204         .pio_interrupt = 0,
205 };
206 #endif
207
208 static struct spi_board_info bfin_spi_board_info[] __initdata = {
209 #if IS_ENABLED(CONFIG_MTD_M25P80)
210         {
211                 /* the modalias must be the same as spi device driver name */
212                 .modalias = "m25p80", /* Name of spi_driver for this device */
213                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
214                 .bus_num = 0, /* Framework bus number */
215                 .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
216                 .platform_data = &bfin_spi_flash_data,
217                 .controller_data = &spi_flash_chip_info,
218                 .mode = SPI_MODE_3,
219         },
220 #endif
221
222 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
223         {
224                 .modalias = "ad1836",
225                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
226                 .bus_num = 0,
227                 .chip_select = 4,
228                 .platform_data = "ad1836", /* only includes chip name for the moment */
229                 .mode = SPI_MODE_3,
230         },
231 #endif
232
233 #if IS_ENABLED(CONFIG_SPI_SPIDEV)
234         {
235                 .modalias = "spidev",
236                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
237                 .bus_num = 0,
238                 .chip_select = 1,
239         },
240 #endif
241 #if IS_ENABLED(CONFIG_MMC_SPI)
242         {
243                 .modalias = "mmc_spi",
244                 .max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
245                 .bus_num = 0,
246                 .chip_select = 4,
247                 .platform_data = &bfin_mmc_spi_pdata,
248                 .controller_data = &mmc_spi_chip_info,
249                 .mode = SPI_MODE_3,
250         },
251 #endif
252 };
253
254 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
255 /* SPI (0) */
256 static struct resource bfin_spi0_resource[] = {
257         [0] = {
258                 .start = SPI0_REGBASE,
259                 .end   = SPI0_REGBASE + 0xFF,
260                 .flags = IORESOURCE_MEM,
261         },
262         [1] = {
263                 .start = CH_SPI,
264                 .end   = CH_SPI,
265                 .flags = IORESOURCE_DMA,
266         },
267         [2] = {
268                 .start = IRQ_SPI,
269                 .end   = IRQ_SPI,
270                 .flags = IORESOURCE_IRQ,
271         }
272 };
273
274 /* SPI controller data */
275 static struct bfin5xx_spi_master bfin_spi0_info = {
276         .num_chipselect = 8,
277         .enable_dma = 1,  /* master has the ability to do dma transfer */
278         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
279 };
280
281 static struct platform_device bfin_spi0_device = {
282         .name = "bfin-spi",
283         .id = 0, /* Bus number */
284         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
285         .resource = bfin_spi0_resource,
286         .dev = {
287                 .platform_data = &bfin_spi0_info, /* Passed to driver */
288         },
289 };
290 #endif  /* spi master and devices */
291
292 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
293 #ifdef CONFIG_SERIAL_BFIN_UART0
294 static struct resource bfin_uart0_resources[] = {
295         {
296                 .start = BFIN_UART_THR,
297                 .end = BFIN_UART_GCTL+2,
298                 .flags = IORESOURCE_MEM,
299         },
300         {
301                 .start = IRQ_UART0_TX,
302                 .end = IRQ_UART0_TX,
303                 .flags = IORESOURCE_IRQ,
304         },
305         {
306                 .start = IRQ_UART0_RX,
307                 .end = IRQ_UART0_RX,
308                 .flags = IORESOURCE_IRQ,
309         },
310         {
311                 .start = IRQ_UART0_ERROR,
312                 .end = IRQ_UART0_ERROR,
313                 .flags = IORESOURCE_IRQ,
314         },
315         {
316                 .start = CH_UART0_TX,
317                 .end = CH_UART0_TX,
318                 .flags = IORESOURCE_DMA,
319         },
320         {
321                 .start = CH_UART0_RX,
322                 .end = CH_UART0_RX,
323                 .flags = IORESOURCE_DMA,
324         },
325 };
326
327 static unsigned short bfin_uart0_peripherals[] = {
328         P_UART0_TX, P_UART0_RX, 0
329 };
330
331 static struct platform_device bfin_uart0_device = {
332         .name = "bfin-uart",
333         .id = 0,
334         .num_resources = ARRAY_SIZE(bfin_uart0_resources),
335         .resource = bfin_uart0_resources,
336         .dev = {
337                 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
338         },
339 };
340 #endif
341 #endif
342
343 #if IS_ENABLED(CONFIG_BFIN_SIR)
344 #ifdef CONFIG_BFIN_SIR0
345 static struct resource bfin_sir0_resources[] = {
346         {
347                 .start = 0xFFC00400,
348                 .end = 0xFFC004FF,
349                 .flags = IORESOURCE_MEM,
350         },
351         {
352                 .start = IRQ_UART0_RX,
353                 .end = IRQ_UART0_RX+1,
354                 .flags = IORESOURCE_IRQ,
355         },
356         {
357                 .start = CH_UART0_RX,
358                 .end = CH_UART0_RX+1,
359                 .flags = IORESOURCE_DMA,
360         },
361 };
362
363 static struct platform_device bfin_sir0_device = {
364         .name = "bfin_sir",
365         .id = 0,
366         .num_resources = ARRAY_SIZE(bfin_sir0_resources),
367         .resource = bfin_sir0_resources,
368 };
369 #endif
370 #endif
371
372 #if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
373 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
374 static struct resource bfin_sport0_uart_resources[] = {
375         {
376                 .start = SPORT0_TCR1,
377                 .end = SPORT0_MRCS3+4,
378                 .flags = IORESOURCE_MEM,
379         },
380         {
381                 .start = IRQ_SPORT0_RX,
382                 .end = IRQ_SPORT0_RX+1,
383                 .flags = IORESOURCE_IRQ,
384         },
385         {
386                 .start = IRQ_SPORT0_ERROR,
387                 .end = IRQ_SPORT0_ERROR,
388                 .flags = IORESOURCE_IRQ,
389         },
390 };
391
392 static unsigned short bfin_sport0_peripherals[] = {
393         P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
394         P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
395 };
396
397 static struct platform_device bfin_sport0_uart_device = {
398         .name = "bfin-sport-uart",
399         .id = 0,
400         .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
401         .resource = bfin_sport0_uart_resources,
402         .dev = {
403                 .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
404         },
405 };
406 #endif
407 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
408 static struct resource bfin_sport1_uart_resources[] = {
409         {
410                 .start = SPORT1_TCR1,
411                 .end = SPORT1_MRCS3+4,
412                 .flags = IORESOURCE_MEM,
413         },
414         {
415                 .start = IRQ_SPORT1_RX,
416                 .end = IRQ_SPORT1_RX+1,
417                 .flags = IORESOURCE_IRQ,
418         },
419         {
420                 .start = IRQ_SPORT1_ERROR,
421                 .end = IRQ_SPORT1_ERROR,
422                 .flags = IORESOURCE_IRQ,
423         },
424 };
425
426 static unsigned short bfin_sport1_peripherals[] = {
427         P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
428         P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
429 };
430
431 static struct platform_device bfin_sport1_uart_device = {
432         .name = "bfin-sport-uart",
433         .id = 1,
434         .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
435         .resource = bfin_sport1_uart_resources,
436         .dev = {
437                 .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
438         },
439 };
440 #endif
441 #endif
442
443 #if IS_ENABLED(CONFIG_BFIN_SPORT)
444 static struct resource bfin_sport0_resources[] = {
445         {
446                 .start = SPORT0_TCR1,
447                 .end = SPORT0_MRCS3+4,
448                 .flags = IORESOURCE_MEM,
449         },
450         {
451                 .start = IRQ_SPORT0_TX,
452                 .end = IRQ_SPORT0_TX+1,
453                 .flags = IORESOURCE_IRQ,
454         },
455         {
456                 .start = IRQ_SPORT0_RX,
457                 .end = IRQ_SPORT0_RX+1,
458                 .flags = IORESOURCE_IRQ,
459         },
460         {
461                 .start = IRQ_SPORT0_ERROR,
462                 .end = IRQ_SPORT0_ERROR,
463                 .flags = IORESOURCE_IRQ,
464         },
465         {
466                 .start = CH_SPORT0_TX,
467                 .end = CH_SPORT0_TX,
468                 .flags = IORESOURCE_DMA,
469         },
470         {
471                 .start = CH_SPORT0_RX,
472                 .end = CH_SPORT0_RX,
473                 .flags = IORESOURCE_DMA,
474         },
475 };
476 static struct platform_device bfin_sport0_device = {
477         .name = "bfin_sport_raw",
478         .id = 0,
479         .num_resources = ARRAY_SIZE(bfin_sport0_resources),
480         .resource = bfin_sport0_resources,
481         .dev = {
482                 .platform_data = &bfin_sport0_peripherals,
483         },
484 };
485 #endif
486
487 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
488 #include <linux/input.h>
489 #include <linux/gpio_keys.h>
490
491 static struct gpio_keys_button bfin_gpio_keys_table[] = {
492         {BTN_0, GPIO_PF5, 0, "gpio-keys: BTN0"},
493         {BTN_1, GPIO_PF6, 0, "gpio-keys: BTN1"},
494         {BTN_2, GPIO_PF8, 0, "gpio-keys: BTN2"},
495 };
496
497 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
498         .buttons        = bfin_gpio_keys_table,
499         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
500 };
501
502 static struct platform_device bfin_device_gpiokeys = {
503         .name      = "gpio-keys",
504         .dev = {
505                 .platform_data = &bfin_gpio_keys_data,
506         },
507 };
508 #endif
509
510 #if IS_ENABLED(CONFIG_I2C_GPIO)
511 #include <linux/i2c-gpio.h>
512
513 static struct i2c_gpio_platform_data i2c_gpio_data = {
514         .sda_pin                = GPIO_PF2,
515         .scl_pin                = GPIO_PF3,
516         .sda_is_open_drain      = 0,
517         .scl_is_open_drain      = 0,
518         .udelay                 = 10,
519 };
520
521 static struct platform_device i2c_gpio_device = {
522         .name           = "i2c-gpio",
523         .id             = 0,
524         .dev            = {
525                 .platform_data  = &i2c_gpio_data,
526         },
527 };
528 #endif
529
530 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
531 #if IS_ENABLED(CONFIG_JOYSTICK_AD7142)
532         {
533                 I2C_BOARD_INFO("ad7142_joystick", 0x2C),
534                 .irq = 39,
535         },
536 #endif
537 #if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
538         {
539                 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
540         },
541 #endif
542 #if IS_ENABLED(CONFIG_INPUT_PCF8574)
543         {
544                 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
545                 .irq = 39,
546         },
547 #endif
548 #if IS_ENABLED(CONFIG_FB_BFIN_7393)
549         {
550                 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
551         },
552 #endif
553 #if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
554         {
555                 I2C_BOARD_INFO("ad5252", 0x2f),
556         },
557 #endif
558 };
559
560 static const unsigned int cclk_vlev_datasheet[] =
561 {
562         VRPAIR(VLEV_085, 250000000),
563         VRPAIR(VLEV_090, 376000000),
564         VRPAIR(VLEV_095, 426000000),
565         VRPAIR(VLEV_100, 426000000),
566         VRPAIR(VLEV_105, 476000000),
567         VRPAIR(VLEV_110, 476000000),
568         VRPAIR(VLEV_115, 476000000),
569         VRPAIR(VLEV_120, 600000000),
570         VRPAIR(VLEV_125, 600000000),
571         VRPAIR(VLEV_130, 600000000),
572 };
573
574 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
575         .tuple_tab = cclk_vlev_datasheet,
576         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
577         .vr_settling_time = 25 /* us */,
578 };
579
580 static struct platform_device bfin_dpmc = {
581         .name = "bfin dpmc",
582         .dev = {
583                 .platform_data = &bfin_dmpc_vreg_data,
584         },
585 };
586
587 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S) || \
588         IS_ENABLED(CONFIG_SND_BF5XX_AC97)
589
590 #include <asm/bfin_sport.h>
591
592 #define SPORT_REQ(x) \
593         [x] = {P_SPORT##x##_TFS, P_SPORT##x##_DTPRI, P_SPORT##x##_TSCLK, \
594                 P_SPORT##x##_RFS, P_SPORT##x##_DRPRI, P_SPORT##x##_RSCLK, 0}
595
596 static const u16 bfin_snd_pin[][7] = {
597         SPORT_REQ(0),
598         SPORT_REQ(1),
599 };
600
601 static struct bfin_snd_platform_data bfin_snd_data[] = {
602         {
603                 .pin_req = &bfin_snd_pin[0][0],
604         },
605         {
606                 .pin_req = &bfin_snd_pin[1][0],
607         },
608 };
609
610 #define BFIN_SND_RES(x) \
611         [x] = { \
612                 { \
613                         .start = SPORT##x##_TCR1, \
614                         .end = SPORT##x##_TCR1, \
615                         .flags = IORESOURCE_MEM \
616                 }, \
617                 { \
618                         .start = CH_SPORT##x##_RX, \
619                         .end = CH_SPORT##x##_RX, \
620                         .flags = IORESOURCE_DMA, \
621                 }, \
622                 { \
623                         .start = CH_SPORT##x##_TX, \
624                         .end = CH_SPORT##x##_TX, \
625                         .flags = IORESOURCE_DMA, \
626                 }, \
627                 { \
628                         .start = IRQ_SPORT##x##_ERROR, \
629                         .end = IRQ_SPORT##x##_ERROR, \
630                         .flags = IORESOURCE_IRQ, \
631                 } \
632         }
633
634 static struct resource bfin_snd_resources[][4] = {
635         BFIN_SND_RES(0),
636         BFIN_SND_RES(1),
637 };
638 #endif
639
640 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
641 static struct platform_device bfin_i2s_pcm = {
642         .name = "bfin-i2s-pcm-audio",
643         .id = -1,
644 };
645 #endif
646
647 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
648 static struct platform_device bfin_ac97_pcm = {
649         .name = "bfin-ac97-pcm-audio",
650         .id = -1,
651 };
652 #endif
653
654 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
655 static const char * const ad1836_link[] = {
656         "bfin-i2s.0",
657         "spi0.4",
658 };
659 static struct platform_device bfin_ad1836_machine = {
660         .name = "bfin-snd-ad1836",
661         .id = -1,
662         .dev = {
663                 .platform_data = (void *)ad1836_link,
664         },
665 };
666 #endif
667
668 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD73311)
669 static const unsigned ad73311_gpio[] = {
670         GPIO_PF4,
671 };
672
673 static struct platform_device bfin_ad73311_machine = {
674         .name = "bfin-snd-ad73311",
675         .id = 1,
676         .dev = {
677                 .platform_data = (void *)ad73311_gpio,
678         },
679 };
680 #endif
681
682 #if IS_ENABLED(CONFIG_SND_SOC_AD73311)
683 static struct platform_device bfin_ad73311_codec_device = {
684         .name = "ad73311",
685         .id = -1,
686 };
687 #endif
688
689 #if IS_ENABLED(CONFIG_SND_SOC_AD74111)
690 static struct platform_device bfin_ad74111_codec_device = {
691         .name = "ad74111",
692         .id = -1,
693 };
694 #endif
695
696 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_I2S)
697 static struct platform_device bfin_i2s = {
698         .name = "bfin-i2s",
699         .id = CONFIG_SND_BF5XX_SPORT_NUM,
700         .num_resources =
701                 ARRAY_SIZE(bfin_snd_resources[CONFIG_SND_BF5XX_SPORT_NUM]),
702         .resource = bfin_snd_resources[CONFIG_SND_BF5XX_SPORT_NUM],
703         .dev = {
704                 .platform_data = &bfin_snd_data[CONFIG_SND_BF5XX_SPORT_NUM],
705         },
706 };
707 #endif
708
709 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AC97)
710 static struct platform_device bfin_ac97 = {
711         .name = "bfin-ac97",
712         .id = CONFIG_SND_BF5XX_SPORT_NUM,
713         .num_resources =
714                 ARRAY_SIZE(bfin_snd_resources[CONFIG_SND_BF5XX_SPORT_NUM]),
715         .resource = bfin_snd_resources[CONFIG_SND_BF5XX_SPORT_NUM],
716         .dev = {
717                 .platform_data = &bfin_snd_data[CONFIG_SND_BF5XX_SPORT_NUM],
718         },
719 };
720 #endif
721
722 static struct platform_device *stamp_devices[] __initdata = {
723
724         &bfin_dpmc,
725
726 #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
727         &rtc_device,
728 #endif
729
730 #if IS_ENABLED(CONFIG_SMC91X)
731         &smc91x_device,
732 #endif
733
734 #if IS_ENABLED(CONFIG_USB_NET2272)
735         &net2272_bfin_device,
736 #endif
737
738 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
739         &bfin_spi0_device,
740 #endif
741
742 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
743 #ifdef CONFIG_SERIAL_BFIN_UART0
744         &bfin_uart0_device,
745 #endif
746 #endif
747
748 #if IS_ENABLED(CONFIG_BFIN_SIR)
749 #ifdef CONFIG_BFIN_SIR0
750         &bfin_sir0_device,
751 #endif
752 #endif
753
754 #if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
755 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
756         &bfin_sport0_uart_device,
757 #endif
758 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
759         &bfin_sport1_uart_device,
760 #endif
761 #endif
762
763 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
764         &bfin_device_gpiokeys,
765 #endif
766
767 #if IS_ENABLED(CONFIG_I2C_GPIO)
768         &i2c_gpio_device,
769 #endif
770
771 #if IS_ENABLED(CONFIG_MTD_BFIN_ASYNC)
772         &stamp_flash_device,
773 #endif
774
775 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
776         &bfin_i2s_pcm,
777 #endif
778
779 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
780         &bfin_ac97_pcm,
781 #endif
782
783 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
784         &bfin_ad1836_machine,
785 #endif
786
787 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD73311)
788         &bfin_ad73311_machine,
789 #endif
790
791 #if IS_ENABLED(CONFIG_SND_SOC_AD73311)
792         &bfin_ad73311_codec_device,
793 #endif
794
795 #if IS_ENABLED(CONFIG_SND_SOC_AD74111)
796         &bfin_ad74111_codec_device,
797 #endif
798
799 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_I2S)
800         &bfin_i2s,
801 #endif
802
803 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AC97)
804         &bfin_ac97,
805 #endif
806 };
807
808 static int __init net2272_init(void)
809 {
810 #if IS_ENABLED(CONFIG_USB_NET2272)
811         int ret;
812
813         /* Set PF0 to 0, PF1 to 1 make /AMS3 work properly */
814         ret = gpio_request(GPIO_PF0, "net2272");
815         if (ret)
816                 return ret;
817
818         ret = gpio_request(GPIO_PF1, "net2272");
819         if (ret) {
820                 gpio_free(GPIO_PF0);
821                 return ret;
822         }
823
824         ret = gpio_request(GPIO_PF11, "net2272");
825         if (ret) {
826                 gpio_free(GPIO_PF0);
827                 gpio_free(GPIO_PF1);
828                 return ret;
829         }
830
831         gpio_direction_output(GPIO_PF0, 0);
832         gpio_direction_output(GPIO_PF1, 1);
833
834         /* Reset the USB chip */
835         gpio_direction_output(GPIO_PF11, 0);
836         mdelay(2);
837         gpio_set_value(GPIO_PF11, 1);
838 #endif
839
840         return 0;
841 }
842
843 static int __init stamp_init(void)
844 {
845         int ret;
846
847         printk(KERN_INFO "%s(): registering device resources\n", __func__);
848
849         i2c_register_board_info(0, bfin_i2c_board_info,
850                                 ARRAY_SIZE(bfin_i2c_board_info));
851
852         ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
853         if (ret < 0)
854                 return ret;
855
856 #if IS_ENABLED(CONFIG_SMC91X)
857         /*
858          * setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC.
859          * the bfin-async-map driver takes care of flipping between
860          * flash and ethernet when necessary.
861          */
862         ret = gpio_request(GPIO_PF0, "enet_cpld");
863         if (!ret) {
864                 gpio_direction_output(GPIO_PF0, 1);
865                 gpio_free(GPIO_PF0);
866         }
867 #endif
868
869         if (net2272_init())
870                 pr_warning("unable to configure net2272; it probably won't work\n");
871
872         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
873         return 0;
874 }
875
876 arch_initcall(stamp_init);
877
878 static struct platform_device *stamp_early_devices[] __initdata = {
879 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
880 #ifdef CONFIG_SERIAL_BFIN_UART0
881         &bfin_uart0_device,
882 #endif
883 #endif
884
885 #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
886 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
887         &bfin_sport0_uart_device,
888 #endif
889 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
890         &bfin_sport1_uart_device,
891 #endif
892 #endif
893 };
894
895 void __init native_machine_early_platform_add_devices(void)
896 {
897         printk(KERN_INFO "register early platform devices\n");
898         early_platform_add_devices(stamp_early_devices,
899                 ARRAY_SIZE(stamp_early_devices));
900 }
901
902 void native_machine_restart(char *cmd)
903 {
904         /* workaround pull up on cpld / flash pin not being strong enough */
905         gpio_request(GPIO_PF0, "flash_cpld");
906         gpio_direction_output(GPIO_PF0, 0);
907 }