ARM: pxa168/gplugd: add the correct SSP device
[pandora-kernel.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 defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
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 defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
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 defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
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 defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
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 defined(CONFIG_MTD_BFIN_ASYNC) || defined(CONFIG_MTD_BFIN_ASYNC_MODULE)
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 defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
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 defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
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 defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
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 defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
223         {
224                 .modalias = "ad183x",
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 defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
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 defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
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 defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
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 defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
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_RX,
302                 .end = IRQ_UART0_RX + 1,
303                 .flags = IORESOURCE_IRQ,
304         },
305         {
306                 .start = IRQ_UART0_ERROR,
307                 .end = IRQ_UART0_ERROR,
308                 .flags = IORESOURCE_IRQ,
309         },
310         {
311                 .start = CH_UART0_TX,
312                 .end = CH_UART0_TX,
313                 .flags = IORESOURCE_DMA,
314         },
315         {
316                 .start = CH_UART0_RX,
317                 .end = CH_UART0_RX,
318                 .flags = IORESOURCE_DMA,
319         },
320 };
321
322 static unsigned short bfin_uart0_peripherals[] = {
323         P_UART0_TX, P_UART0_RX, 0
324 };
325
326 static struct platform_device bfin_uart0_device = {
327         .name = "bfin-uart",
328         .id = 0,
329         .num_resources = ARRAY_SIZE(bfin_uart0_resources),
330         .resource = bfin_uart0_resources,
331         .dev = {
332                 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
333         },
334 };
335 #endif
336 #endif
337
338 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
339 #ifdef CONFIG_BFIN_SIR0
340 static struct resource bfin_sir0_resources[] = {
341         {
342                 .start = 0xFFC00400,
343                 .end = 0xFFC004FF,
344                 .flags = IORESOURCE_MEM,
345         },
346         {
347                 .start = IRQ_UART0_RX,
348                 .end = IRQ_UART0_RX+1,
349                 .flags = IORESOURCE_IRQ,
350         },
351         {
352                 .start = CH_UART0_RX,
353                 .end = CH_UART0_RX+1,
354                 .flags = IORESOURCE_DMA,
355         },
356 };
357
358 static struct platform_device bfin_sir0_device = {
359         .name = "bfin_sir",
360         .id = 0,
361         .num_resources = ARRAY_SIZE(bfin_sir0_resources),
362         .resource = bfin_sir0_resources,
363 };
364 #endif
365 #endif
366
367 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
368 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
369 static struct resource bfin_sport0_uart_resources[] = {
370         {
371                 .start = SPORT0_TCR1,
372                 .end = SPORT0_MRCS3+4,
373                 .flags = IORESOURCE_MEM,
374         },
375         {
376                 .start = IRQ_SPORT0_RX,
377                 .end = IRQ_SPORT0_RX+1,
378                 .flags = IORESOURCE_IRQ,
379         },
380         {
381                 .start = IRQ_SPORT0_ERROR,
382                 .end = IRQ_SPORT0_ERROR,
383                 .flags = IORESOURCE_IRQ,
384         },
385 };
386
387 static unsigned short bfin_sport0_peripherals[] = {
388         P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
389         P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
390 };
391
392 static struct platform_device bfin_sport0_uart_device = {
393         .name = "bfin-sport-uart",
394         .id = 0,
395         .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
396         .resource = bfin_sport0_uart_resources,
397         .dev = {
398                 .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
399         },
400 };
401 #endif
402 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
403 static struct resource bfin_sport1_uart_resources[] = {
404         {
405                 .start = SPORT1_TCR1,
406                 .end = SPORT1_MRCS3+4,
407                 .flags = IORESOURCE_MEM,
408         },
409         {
410                 .start = IRQ_SPORT1_RX,
411                 .end = IRQ_SPORT1_RX+1,
412                 .flags = IORESOURCE_IRQ,
413         },
414         {
415                 .start = IRQ_SPORT1_ERROR,
416                 .end = IRQ_SPORT1_ERROR,
417                 .flags = IORESOURCE_IRQ,
418         },
419 };
420
421 static unsigned short bfin_sport1_peripherals[] = {
422         P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
423         P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
424 };
425
426 static struct platform_device bfin_sport1_uart_device = {
427         .name = "bfin-sport-uart",
428         .id = 1,
429         .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
430         .resource = bfin_sport1_uart_resources,
431         .dev = {
432                 .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
433         },
434 };
435 #endif
436 #endif
437
438 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
439 #include <linux/input.h>
440 #include <linux/gpio_keys.h>
441
442 static struct gpio_keys_button bfin_gpio_keys_table[] = {
443         {BTN_0, GPIO_PF5, 0, "gpio-keys: BTN0"},
444         {BTN_1, GPIO_PF6, 0, "gpio-keys: BTN1"},
445         {BTN_2, GPIO_PF8, 0, "gpio-keys: BTN2"},
446 };
447
448 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
449         .buttons        = bfin_gpio_keys_table,
450         .nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
451 };
452
453 static struct platform_device bfin_device_gpiokeys = {
454         .name      = "gpio-keys",
455         .dev = {
456                 .platform_data = &bfin_gpio_keys_data,
457         },
458 };
459 #endif
460
461 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
462 #include <linux/i2c-gpio.h>
463
464 static struct i2c_gpio_platform_data i2c_gpio_data = {
465         .sda_pin                = GPIO_PF2,
466         .scl_pin                = GPIO_PF3,
467         .sda_is_open_drain      = 0,
468         .scl_is_open_drain      = 0,
469         .udelay                 = 40,
470 };
471
472 static struct platform_device i2c_gpio_device = {
473         .name           = "i2c-gpio",
474         .id             = 0,
475         .dev            = {
476                 .platform_data  = &i2c_gpio_data,
477         },
478 };
479 #endif
480
481 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
482 #if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE)
483         {
484                 I2C_BOARD_INFO("ad7142_joystick", 0x2C),
485                 .irq = 39,
486         },
487 #endif
488 #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
489         {
490                 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
491         },
492 #endif
493 #if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
494         {
495                 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
496                 .irq = 39,
497         },
498 #endif
499 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
500         {
501                 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
502         },
503 #endif
504 #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
505         {
506                 I2C_BOARD_INFO("ad5252", 0x2f),
507         },
508 #endif
509 };
510
511 static const unsigned int cclk_vlev_datasheet[] =
512 {
513         VRPAIR(VLEV_085, 250000000),
514         VRPAIR(VLEV_090, 376000000),
515         VRPAIR(VLEV_095, 426000000),
516         VRPAIR(VLEV_100, 426000000),
517         VRPAIR(VLEV_105, 476000000),
518         VRPAIR(VLEV_110, 476000000),
519         VRPAIR(VLEV_115, 476000000),
520         VRPAIR(VLEV_120, 600000000),
521         VRPAIR(VLEV_125, 600000000),
522         VRPAIR(VLEV_130, 600000000),
523 };
524
525 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
526         .tuple_tab = cclk_vlev_datasheet,
527         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
528         .vr_settling_time = 25 /* us */,
529 };
530
531 static struct platform_device bfin_dpmc = {
532         .name = "bfin dpmc",
533         .dev = {
534                 .platform_data = &bfin_dmpc_vreg_data,
535         },
536 };
537
538 #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
539 static struct platform_device bfin_i2s = {
540         .name = "bfin-i2s",
541         .id = CONFIG_SND_BF5XX_SPORT_NUM,
542         /* TODO: add platform data here */
543 };
544 #endif
545
546 #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
547 static struct platform_device bfin_tdm = {
548         .name = "bfin-tdm",
549         .id = CONFIG_SND_BF5XX_SPORT_NUM,
550         /* TODO: add platform data here */
551 };
552 #endif
553
554 #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
555 static struct platform_device bfin_ac97 = {
556         .name = "bfin-ac97",
557         .id = CONFIG_SND_BF5XX_SPORT_NUM,
558         /* TODO: add platform data here */
559 };
560 #endif
561
562 static struct platform_device *stamp_devices[] __initdata = {
563
564         &bfin_dpmc,
565
566 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
567         &rtc_device,
568 #endif
569
570 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
571         &smc91x_device,
572 #endif
573
574 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
575         &net2272_bfin_device,
576 #endif
577
578 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
579         &bfin_spi0_device,
580 #endif
581
582 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
583 #ifdef CONFIG_SERIAL_BFIN_UART0
584         &bfin_uart0_device,
585 #endif
586 #endif
587
588 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
589 #ifdef CONFIG_BFIN_SIR0
590         &bfin_sir0_device,
591 #endif
592 #endif
593
594 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
595 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
596         &bfin_sport0_uart_device,
597 #endif
598 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
599         &bfin_sport1_uart_device,
600 #endif
601 #endif
602
603 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
604         &bfin_device_gpiokeys,
605 #endif
606
607 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
608         &i2c_gpio_device,
609 #endif
610
611 #if defined(CONFIG_MTD_BFIN_ASYNC) || defined(CONFIG_MTD_BFIN_ASYNC_MODULE)
612         &stamp_flash_device,
613 #endif
614
615 #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
616         &bfin_i2s,
617 #endif
618
619 #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
620         &bfin_tdm,
621 #endif
622
623 #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
624         &bfin_ac97,
625 #endif
626 };
627
628 static int __init net2272_init(void)
629 {
630 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
631         int ret;
632
633         /* Set PF0 to 0, PF1 to 1 make /AMS3 work properly */
634         ret = gpio_request(GPIO_PF0, "net2272");
635         if (ret)
636                 return ret;
637
638         ret = gpio_request(GPIO_PF1, "net2272");
639         if (ret) {
640                 gpio_free(GPIO_PF0);
641                 return ret;
642         }
643
644         ret = gpio_request(GPIO_PF11, "net2272");
645         if (ret) {
646                 gpio_free(GPIO_PF0);
647                 gpio_free(GPIO_PF1);
648                 return ret;
649         }
650
651         gpio_direction_output(GPIO_PF0, 0);
652         gpio_direction_output(GPIO_PF1, 1);
653
654         /* Reset the USB chip */
655         gpio_direction_output(GPIO_PF11, 0);
656         mdelay(2);
657         gpio_set_value(GPIO_PF11, 1);
658 #endif
659
660         return 0;
661 }
662
663 static int __init stamp_init(void)
664 {
665         int ret;
666
667         printk(KERN_INFO "%s(): registering device resources\n", __func__);
668
669         i2c_register_board_info(0, bfin_i2c_board_info,
670                                 ARRAY_SIZE(bfin_i2c_board_info));
671
672         ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
673         if (ret < 0)
674                 return ret;
675
676 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
677         /*
678          * setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC.
679          * the bfin-async-map driver takes care of flipping between
680          * flash and ethernet when necessary.
681          */
682         ret = gpio_request(GPIO_PF0, "enet_cpld");
683         if (!ret) {
684                 gpio_direction_output(GPIO_PF0, 1);
685                 gpio_free(GPIO_PF0);
686         }
687 #endif
688
689         if (net2272_init())
690                 pr_warning("unable to configure net2272; it probably won't work\n");
691
692         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
693         return 0;
694 }
695
696 arch_initcall(stamp_init);
697
698 static struct platform_device *stamp_early_devices[] __initdata = {
699 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
700 #ifdef CONFIG_SERIAL_BFIN_UART0
701         &bfin_uart0_device,
702 #endif
703 #endif
704
705 #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
706 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
707         &bfin_sport0_uart_device,
708 #endif
709 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
710         &bfin_sport1_uart_device,
711 #endif
712 #endif
713 };
714
715 void __init native_machine_early_platform_add_devices(void)
716 {
717         printk(KERN_INFO "register early platform devices\n");
718         early_platform_add_devices(stamp_early_devices,
719                 ARRAY_SIZE(stamp_early_devices));
720 }
721
722 void native_machine_restart(char *cmd)
723 {
724         /* workaround pull up on cpld / flash pin not being strong enough */
725         gpio_request(GPIO_PF0, "flash_cpld");
726         gpio_direction_output(GPIO_PF0, 0);
727 }