blob: eccb82036c0c4c5432d78aeabace3a7aadf820e3 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * Copyright 2004-2009 Analog Devices Inc.
3 * 2005 National ICT Australia (NICTA)
4 * Aidan Williams <aidan@nicta.com.au>
Bryan Wu1394f032007-05-06 14:50:22 -07005 *
Robin Getz96f10502009-09-24 14:11:24 +00006 * Licensed under the GPL-2 or later.
Bryan Wu1394f032007-05-06 14:50:22 -07007 */
8
9#include <linux/device.h>
10#include <linux/platform_device.h>
11#include <linux/mtd/mtd.h>
12#include <linux/mtd/partitions.h>
Mike Frysingerde8c43f2008-01-24 17:14:04 +080013#include <linux/mtd/physmap.h>
Bryan Wu1394f032007-05-06 14:50:22 -070014#include <linux/spi/spi.h>
15#include <linux/spi/flash.h>
Yi Li2120b682009-07-16 10:12:30 +000016#include <linux/spi/mmc_spi.h>
Bryan Wu1394f032007-05-06 14:50:22 -070017#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
Mike Frysingerf02bcec2007-11-15 21:29:15 +080018#include <linux/usb/isp1362.h>
Bryan Wu1394f032007-05-06 14:50:22 -070019#endif
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080020#include <linux/irq.h>
Bryan Wu81d9c7f2008-03-26 10:02:13 +080021#include <linux/i2c.h>
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080022#include <asm/dma.h>
Bryan Wu1394f032007-05-06 14:50:22 -070023#include <asm/bfin5xx_spi.h>
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080024#include <asm/reboot.h>
Bryan Wu5d448dd2007-11-12 23:24:42 +080025#include <asm/portmux.h>
Michael Hennerich14b03202008-05-07 11:41:26 +080026#include <asm/dpmc.h>
Bryan Wu1394f032007-05-06 14:50:22 -070027
28/*
29 * Name the Board for the /proc/cpuinfo
30 */
Mike Frysingerfe85cad2008-11-18 17:48:22 +080031const char bfin_board_name[] = "ADI BF533-STAMP";
Bryan Wu1394f032007-05-06 14:50:22 -070032
33#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
34static 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)
Michael Hennerich61f09b52009-07-24 08:48:31 +000044#include <linux/smc91x.h>
45
46static 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
Bryan Wu1394f032007-05-06 14:50:22 -070052static struct resource smc91x_resources[] = {
53 {
54 .name = "smc91x-regs",
55 .start = 0x20300300,
56 .end = 0x20300300 + 16,
57 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080058 }, {
Bryan Wu1394f032007-05-06 14:50:22 -070059 .start = IRQ_PF7,
60 .end = IRQ_PF7,
61 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
62 },
63};
64
65static struct platform_device smc91x_device = {
66 .name = "smc91x",
67 .id = 0,
68 .num_resources = ARRAY_SIZE(smc91x_resources),
69 .resource = smc91x_resources,
Michael Hennerich61f09b52009-07-24 08:48:31 +000070 .dev = {
71 .platform_data = &smc91x_info,
72 },
Bryan Wu1394f032007-05-06 14:50:22 -070073};
74#endif
75
76#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
77static struct resource net2272_bfin_resources[] = {
78 {
79 .start = 0x20300000,
80 .end = 0x20300000 + 0x100,
81 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080082 }, {
Mike Frysinger9be86312011-05-04 11:20:15 -040083 .start = 1,
84 .flags = IORESOURCE_BUS,
85 }, {
Bryan Wu1394f032007-05-06 14:50:22 -070086 .start = IRQ_PF10,
87 .end = IRQ_PF10,
88 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
89 },
90};
91
92static 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
Mike Frysinger9cd9c612008-05-13 12:31:32 +0800100#if defined(CONFIG_MTD_BFIN_ASYNC) || defined(CONFIG_MTD_BFIN_ASYNC_MODULE)
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800101static struct mtd_partition stamp_partitions[] = {
102 {
Robin Getzaa582972008-08-05 17:47:29 +0800103 .name = "bootloader(nor)",
Mike Frysingeredf05642008-02-25 11:38:11 +0800104 .size = 0x40000,
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800105 .offset = 0,
106 }, {
Robin Getzaa582972008-08-05 17:47:29 +0800107 .name = "linux kernel(nor)",
Grace Pan6ecb5b62009-01-07 23:14:38 +0800108 .size = 0x180000,
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800109 .offset = MTDPART_OFS_APPEND,
110 }, {
Robin Getzaa582972008-08-05 17:47:29 +0800111 .name = "file system(nor)",
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800112 .size = MTDPART_SIZ_FULL,
113 .offset = MTDPART_OFS_APPEND,
114 }
115};
116
117static struct physmap_flash_data stamp_flash_data = {
118 .width = 2,
119 .parts = stamp_partitions,
120 .nr_parts = ARRAY_SIZE(stamp_partitions),
121};
122
123static struct resource stamp_flash_resource[] = {
124 {
125 .name = "cfi_probe",
126 .start = 0x20000000,
127 .end = 0x203fffff,
128 .flags = IORESOURCE_MEM,
129 }, {
Mike Frysinger9cd9c612008-05-13 12:31:32 +0800130 .start = 0x7BB07BB0, /* AMBCTL0 setting when accessing flash */
131 .end = 0x7BB07BB0, /* AMBCTL1 setting when accessing flash */
132 .flags = IORESOURCE_MEM,
133 }, {
134 .start = GPIO_PF0,
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800135 .flags = IORESOURCE_IRQ,
136 }
137};
138
139static struct platform_device stamp_flash_device = {
Mike Frysinger9cd9c612008-05-13 12:31:32 +0800140 .name = "bfin-async-flash",
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800141 .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};
Mike Frysinger793dc272008-03-26 08:09:12 +0800148#endif
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800149
Bryan Wu1394f032007-05-06 14:50:22 -0700150#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
151static struct mtd_partition bfin_spi_flash_partitions[] = {
152 {
Robin Getzaa582972008-08-05 17:47:29 +0800153 .name = "bootloader(spi)",
Mike Frysingeredf05642008-02-25 11:38:11 +0800154 .size = 0x00040000,
Bryan Wu1394f032007-05-06 14:50:22 -0700155 .offset = 0,
156 .mask_flags = MTD_CAP_ROM
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800157 }, {
Robin Getzaa582972008-08-05 17:47:29 +0800158 .name = "linux kernel(spi)",
Grace Pan6ecb5b62009-01-07 23:14:38 +0800159 .size = 0x180000,
Mike Frysingeredf05642008-02-25 11:38:11 +0800160 .offset = MTDPART_OFS_APPEND,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800161 }, {
Robin Getzaa582972008-08-05 17:47:29 +0800162 .name = "file system(spi)",
Mike Frysingeredf05642008-02-25 11:38:11 +0800163 .size = MTDPART_SIZ_FULL,
164 .offset = MTDPART_OFS_APPEND,
Bryan Wu1394f032007-05-06 14:50:22 -0700165 }
166};
167
168static 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) */
176static struct bfin5xx_spi_chip spi_flash_chip_info = {
177 .enable_dma = 0, /* use dma transfer with this chip*/
178 .bits_per_word = 8,
179};
180#endif
181
Mike Frysingera261eec2009-05-20 14:05:36 +0000182#if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
Bryan Wu1394f032007-05-06 14:50:22 -0700183/* SPI ADC chip */
184static struct bfin5xx_spi_chip spi_adc_chip_info = {
185 .enable_dma = 1, /* use dma transfer with this chip*/
186 .bits_per_word = 16,
187};
188#endif
189
Barry Song7ba80062010-01-28 09:37:21 +0000190#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
Bryan Wu1394f032007-05-06 14:50:22 -0700191static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
192 .enable_dma = 0,
193 .bits_per_word = 16,
194};
195#endif
196
Michael Hennerich6e668932008-02-09 01:54:09 +0800197#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
198static struct bfin5xx_spi_chip spidev_chip_info = {
199 .enable_dma = 0,
200 .bits_per_word = 8,
201};
202#endif
203
Yi Li2120b682009-07-16 10:12:30 +0000204#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
205#define MMC_SPI_CARD_DETECT_INT IRQ_PF5
206static int bfin_mmc_spi_init(struct device *dev,
207 irqreturn_t (*detect_int)(int, void *), void *data)
208{
209 return request_irq(MMC_SPI_CARD_DETECT_INT, detect_int,
210 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
211 "mmc-spi-detect", data);
212}
213
214static void bfin_mmc_spi_exit(struct device *dev, void *data)
215{
216 free_irq(MMC_SPI_CARD_DETECT_INT, data);
217}
218
219static struct mmc_spi_platform_data bfin_mmc_spi_pdata = {
220 .init = bfin_mmc_spi_init,
221 .exit = bfin_mmc_spi_exit,
222 .detect_delay = 100, /* msecs */
223};
224
225static struct bfin5xx_spi_chip mmc_spi_chip_info = {
226 .enable_dma = 0,
227 .bits_per_word = 8,
228 .pio_interrupt = 0,
229};
230#endif
231
Bryan Wu1394f032007-05-06 14:50:22 -0700232static struct spi_board_info bfin_spi_board_info[] __initdata = {
233#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
234 {
235 /* the modalias must be the same as spi device driver name */
236 .modalias = "m25p80", /* Name of spi_driver for this device */
237 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800238 .bus_num = 0, /* Framework bus number */
Bryan Wu1394f032007-05-06 14:50:22 -0700239 .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
240 .platform_data = &bfin_spi_flash_data,
241 .controller_data = &spi_flash_chip_info,
242 .mode = SPI_MODE_3,
243 },
244#endif
245
Mike Frysingera261eec2009-05-20 14:05:36 +0000246#if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
Bryan Wu1394f032007-05-06 14:50:22 -0700247 {
248 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
249 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800250 .bus_num = 0, /* Framework bus number */
Bryan Wu1394f032007-05-06 14:50:22 -0700251 .chip_select = 1, /* Framework chip select. */
252 .platform_data = NULL, /* No spi_driver specific config */
253 .controller_data = &spi_adc_chip_info,
254 },
255#endif
256
Barry Song7ba80062010-01-28 09:37:21 +0000257#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
Bryan Wu1394f032007-05-06 14:50:22 -0700258 {
Barry Song7ba80062010-01-28 09:37:21 +0000259 .modalias = "ad183x",
Cliff Cai858c5e92009-07-22 06:34:55 +0000260 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800261 .bus_num = 0,
Barry Song7ba80062010-01-28 09:37:21 +0000262 .chip_select = 4,
263 .platform_data = "ad1836", /* only includes chip name for the moment */
Bryan Wu1394f032007-05-06 14:50:22 -0700264 .controller_data = &ad1836_spi_chip_info,
Barry Song7ba80062010-01-28 09:37:21 +0000265 .mode = SPI_MODE_3,
Bryan Wu1394f032007-05-06 14:50:22 -0700266 },
267#endif
268
Michael Hennerich6e668932008-02-09 01:54:09 +0800269#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
270 {
271 .modalias = "spidev",
272 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
273 .bus_num = 0,
274 .chip_select = 1,
275 .controller_data = &spidev_chip_info,
276 },
277#endif
Yi Li2120b682009-07-16 10:12:30 +0000278#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
279 {
280 .modalias = "mmc_spi",
281 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
282 .bus_num = 0,
283 .chip_select = 4,
284 .platform_data = &bfin_mmc_spi_pdata,
285 .controller_data = &mmc_spi_chip_info,
286 .mode = SPI_MODE_3,
287 },
288#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700289};
290
Mike Frysinger5bda2722008-06-07 15:03:01 +0800291#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800292/* SPI (0) */
293static struct resource bfin_spi0_resource[] = {
294 [0] = {
295 .start = SPI0_REGBASE,
296 .end = SPI0_REGBASE + 0xFF,
297 .flags = IORESOURCE_MEM,
298 },
299 [1] = {
300 .start = CH_SPI,
301 .end = CH_SPI,
Yi Li53122692009-06-05 12:11:11 +0000302 .flags = IORESOURCE_DMA,
303 },
304 [2] = {
305 .start = IRQ_SPI,
306 .end = IRQ_SPI,
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800307 .flags = IORESOURCE_IRQ,
308 }
309};
310
Bryan Wu1394f032007-05-06 14:50:22 -0700311/* SPI controller data */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800312static struct bfin5xx_spi_master bfin_spi0_info = {
Bryan Wu1394f032007-05-06 14:50:22 -0700313 .num_chipselect = 8,
314 .enable_dma = 1, /* master has the ability to do dma transfer */
Bryan Wu5d448dd2007-11-12 23:24:42 +0800315 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
Bryan Wu1394f032007-05-06 14:50:22 -0700316};
317
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800318static struct platform_device bfin_spi0_device = {
319 .name = "bfin-spi",
320 .id = 0, /* Bus number */
321 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
322 .resource = bfin_spi0_resource,
Bryan Wu1394f032007-05-06 14:50:22 -0700323 .dev = {
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800324 .platform_data = &bfin_spi0_info, /* Passed to driver */
Bryan Wu1394f032007-05-06 14:50:22 -0700325 },
326};
327#endif /* spi master and devices */
328
Bryan Wu1394f032007-05-06 14:50:22 -0700329#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000330#ifdef CONFIG_SERIAL_BFIN_UART0
331static struct resource bfin_uart0_resources[] = {
Bryan Wu1394f032007-05-06 14:50:22 -0700332 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000333 .start = BFIN_UART_THR,
334 .end = BFIN_UART_GCTL+2,
Bryan Wu1394f032007-05-06 14:50:22 -0700335 .flags = IORESOURCE_MEM,
336 },
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000337 {
338 .start = IRQ_UART0_RX,
339 .end = IRQ_UART0_RX + 1,
340 .flags = IORESOURCE_IRQ,
341 },
342 {
343 .start = IRQ_UART0_ERROR,
344 .end = IRQ_UART0_ERROR,
345 .flags = IORESOURCE_IRQ,
346 },
347 {
348 .start = CH_UART0_TX,
349 .end = CH_UART0_TX,
350 .flags = IORESOURCE_DMA,
351 },
352 {
353 .start = CH_UART0_RX,
354 .end = CH_UART0_RX,
355 .flags = IORESOURCE_DMA,
356 },
Bryan Wu1394f032007-05-06 14:50:22 -0700357};
358
Mike Frysingera8b19882010-11-24 09:23:04 +0000359static unsigned short bfin_uart0_peripherals[] = {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000360 P_UART0_TX, P_UART0_RX, 0
Bryan Wu1394f032007-05-06 14:50:22 -0700361};
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000362
363static struct platform_device bfin_uart0_device = {
364 .name = "bfin-uart",
365 .id = 0,
366 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
367 .resource = bfin_uart0_resources,
368 .dev = {
369 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
370 },
371};
372#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700373#endif
374
Graf Yang5be36d22008-04-25 03:09:15 +0800375#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang5be36d22008-04-25 03:09:15 +0800376#ifdef CONFIG_BFIN_SIR0
Graf Yang42bd8bc2009-01-07 23:14:39 +0800377static struct resource bfin_sir0_resources[] = {
Graf Yang5be36d22008-04-25 03:09:15 +0800378 {
379 .start = 0xFFC00400,
380 .end = 0xFFC004FF,
381 .flags = IORESOURCE_MEM,
382 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800383 {
384 .start = IRQ_UART0_RX,
385 .end = IRQ_UART0_RX+1,
386 .flags = IORESOURCE_IRQ,
387 },
388 {
389 .start = CH_UART0_RX,
390 .end = CH_UART0_RX+1,
391 .flags = IORESOURCE_DMA,
392 },
Graf Yang5be36d22008-04-25 03:09:15 +0800393};
394
Graf Yang42bd8bc2009-01-07 23:14:39 +0800395static struct platform_device bfin_sir0_device = {
Graf Yang5be36d22008-04-25 03:09:15 +0800396 .name = "bfin_sir",
397 .id = 0,
Graf Yang42bd8bc2009-01-07 23:14:39 +0800398 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
399 .resource = bfin_sir0_resources,
Graf Yang5be36d22008-04-25 03:09:15 +0800400};
401#endif
Graf Yang42bd8bc2009-01-07 23:14:39 +0800402#endif
Graf Yang5be36d22008-04-25 03:09:15 +0800403
Bryan Wu1394f032007-05-06 14:50:22 -0700404#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000405#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
406static struct resource bfin_sport0_uart_resources[] = {
407 {
408 .start = SPORT0_TCR1,
409 .end = SPORT0_MRCS3+4,
410 .flags = IORESOURCE_MEM,
411 },
412 {
413 .start = IRQ_SPORT0_RX,
414 .end = IRQ_SPORT0_RX+1,
415 .flags = IORESOURCE_IRQ,
416 },
417 {
418 .start = IRQ_SPORT0_ERROR,
419 .end = IRQ_SPORT0_ERROR,
420 .flags = IORESOURCE_IRQ,
421 },
422};
423
Mike Frysingera8b19882010-11-24 09:23:04 +0000424static unsigned short bfin_sport0_peripherals[] = {
Sonic Zhangdf5de262009-09-23 05:01:56 +0000425 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
Sonic Zhange54b6732010-11-12 02:45:38 +0000426 P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
Sonic Zhangdf5de262009-09-23 05:01:56 +0000427};
428
Bryan Wu1394f032007-05-06 14:50:22 -0700429static struct platform_device bfin_sport0_uart_device = {
430 .name = "bfin-sport-uart",
431 .id = 0,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000432 .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
433 .resource = bfin_sport0_uart_resources,
434 .dev = {
435 .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
436 },
437};
438#endif
439#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
440static struct resource bfin_sport1_uart_resources[] = {
441 {
442 .start = SPORT1_TCR1,
443 .end = SPORT1_MRCS3+4,
444 .flags = IORESOURCE_MEM,
445 },
446 {
447 .start = IRQ_SPORT1_RX,
448 .end = IRQ_SPORT1_RX+1,
449 .flags = IORESOURCE_IRQ,
450 },
451 {
452 .start = IRQ_SPORT1_ERROR,
453 .end = IRQ_SPORT1_ERROR,
454 .flags = IORESOURCE_IRQ,
455 },
456};
457
Mike Frysingera8b19882010-11-24 09:23:04 +0000458static unsigned short bfin_sport1_peripherals[] = {
Sonic Zhangdf5de262009-09-23 05:01:56 +0000459 P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
Sonic Zhange54b6732010-11-12 02:45:38 +0000460 P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
Bryan Wu1394f032007-05-06 14:50:22 -0700461};
462
463static struct platform_device bfin_sport1_uart_device = {
464 .name = "bfin-sport-uart",
465 .id = 1,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000466 .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
467 .resource = bfin_sport1_uart_resources,
468 .dev = {
469 .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
470 },
Bryan Wu1394f032007-05-06 14:50:22 -0700471};
472#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000473#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700474
Michael Hennerich2463ef22008-01-27 16:49:48 +0800475#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
476#include <linux/input.h>
477#include <linux/gpio_keys.h>
478
479static struct gpio_keys_button bfin_gpio_keys_table[] = {
Michael Hennerichf1bceb42008-02-02 16:17:52 +0800480 {BTN_0, GPIO_PF5, 0, "gpio-keys: BTN0"},
481 {BTN_1, GPIO_PF6, 0, "gpio-keys: BTN1"},
482 {BTN_2, GPIO_PF8, 0, "gpio-keys: BTN2"},
Michael Hennerich2463ef22008-01-27 16:49:48 +0800483};
484
485static struct gpio_keys_platform_data bfin_gpio_keys_data = {
486 .buttons = bfin_gpio_keys_table,
487 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
488};
489
490static struct platform_device bfin_device_gpiokeys = {
491 .name = "gpio-keys",
492 .dev = {
493 .platform_data = &bfin_gpio_keys_data,
494 },
495};
496#endif
497
Bryan Wue3163952008-01-24 16:19:15 +0800498#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
499#include <linux/i2c-gpio.h>
500
501static struct i2c_gpio_platform_data i2c_gpio_data = {
Mike Frysinger3d7dc882010-07-02 21:02:50 +0000502 .sda_pin = GPIO_PF2,
503 .scl_pin = GPIO_PF3,
Bryan Wue3163952008-01-24 16:19:15 +0800504 .sda_is_open_drain = 0,
505 .scl_is_open_drain = 0,
506 .udelay = 40,
507};
508
509static struct platform_device i2c_gpio_device = {
510 .name = "i2c-gpio",
511 .id = 0,
512 .dev = {
513 .platform_data = &i2c_gpio_data,
514 },
515};
516#endif
517
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800518static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
519#if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE)
520 {
521 I2C_BOARD_INFO("ad7142_joystick", 0x2C),
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800522 .irq = 39,
523 },
524#endif
Michael Hennerichebd58332009-07-02 11:00:38 +0000525#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800526 {
527 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800528 },
529#endif
Michael Hennerich204844e2009-06-30 14:57:22 +0000530#if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800531 {
532 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800533 .irq = 39,
534 },
535#endif
Michael Hennerich50c4c082009-09-22 13:10:09 +0000536#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
537 {
538 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
539 },
540#endif
steven miao39d3c1c2010-08-26 08:25:13 +0000541#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
542 {
543 I2C_BOARD_INFO("ad5252", 0x2f),
544 },
545#endif
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800546};
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800547
Michael Hennerich14b03202008-05-07 11:41:26 +0800548static const unsigned int cclk_vlev_datasheet[] =
549{
550 VRPAIR(VLEV_085, 250000000),
551 VRPAIR(VLEV_090, 376000000),
552 VRPAIR(VLEV_095, 426000000),
553 VRPAIR(VLEV_100, 426000000),
554 VRPAIR(VLEV_105, 476000000),
555 VRPAIR(VLEV_110, 476000000),
556 VRPAIR(VLEV_115, 476000000),
557 VRPAIR(VLEV_120, 600000000),
558 VRPAIR(VLEV_125, 600000000),
559 VRPAIR(VLEV_130, 600000000),
560};
561
562static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
563 .tuple_tab = cclk_vlev_datasheet,
564 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
565 .vr_settling_time = 25 /* us */,
566};
567
568static struct platform_device bfin_dpmc = {
569 .name = "bfin dpmc",
570 .dev = {
571 .platform_data = &bfin_dmpc_vreg_data,
572 },
573};
574
Barry Song7e1082b2010-01-12 03:59:18 +0000575#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
576static struct platform_device bfin_i2s = {
577 .name = "bfin-i2s",
578 .id = CONFIG_SND_BF5XX_SPORT_NUM,
579 /* TODO: add platform data here */
580};
581#endif
582
583#if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
584static struct platform_device bfin_tdm = {
585 .name = "bfin-tdm",
586 .id = CONFIG_SND_BF5XX_SPORT_NUM,
587 /* TODO: add platform data here */
588};
589#endif
590
591#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
592static struct platform_device bfin_ac97 = {
593 .name = "bfin-ac97",
594 .id = CONFIG_SND_BF5XX_SPORT_NUM,
595 /* TODO: add platform data here */
596};
597#endif
598
Bryan Wu1394f032007-05-06 14:50:22 -0700599static struct platform_device *stamp_devices[] __initdata = {
Michael Hennerich14b03202008-05-07 11:41:26 +0800600
601 &bfin_dpmc,
602
Bryan Wu1394f032007-05-06 14:50:22 -0700603#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
604 &rtc_device,
605#endif
606
607#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
608 &smc91x_device,
609#endif
610
611#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
612 &net2272_bfin_device,
613#endif
614
615#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800616 &bfin_spi0_device,
Bryan Wu1394f032007-05-06 14:50:22 -0700617#endif
618
619#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000620#ifdef CONFIG_SERIAL_BFIN_UART0
621 &bfin_uart0_device,
622#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700623#endif
624
Graf Yang5be36d22008-04-25 03:09:15 +0800625#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang42bd8bc2009-01-07 23:14:39 +0800626#ifdef CONFIG_BFIN_SIR0
627 &bfin_sir0_device,
628#endif
Graf Yang5be36d22008-04-25 03:09:15 +0800629#endif
630
Bryan Wu1394f032007-05-06 14:50:22 -0700631#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000632#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
Bryan Wu1394f032007-05-06 14:50:22 -0700633 &bfin_sport0_uart_device,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000634#endif
635#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
Bryan Wu1394f032007-05-06 14:50:22 -0700636 &bfin_sport1_uart_device,
637#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000638#endif
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800639
Michael Hennerich2463ef22008-01-27 16:49:48 +0800640#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
641 &bfin_device_gpiokeys,
642#endif
Bryan Wue3163952008-01-24 16:19:15 +0800643
644#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
645 &i2c_gpio_device,
646#endif
Mike Frysingercad2ab62008-02-22 17:01:31 +0800647
Mike Frysinger9cd9c612008-05-13 12:31:32 +0800648#if defined(CONFIG_MTD_BFIN_ASYNC) || defined(CONFIG_MTD_BFIN_ASYNC_MODULE)
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800649 &stamp_flash_device,
Mike Frysinger793dc272008-03-26 08:09:12 +0800650#endif
Barry Song7e1082b2010-01-12 03:59:18 +0000651
652#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
653 &bfin_i2s,
654#endif
655
656#if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
657 &bfin_tdm,
658#endif
659
660#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
661 &bfin_ac97,
662#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700663};
664
Mike Frysinger9be86312011-05-04 11:20:15 -0400665static int __init net2272_init(void)
666{
667#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
668 int ret;
669
670 /* Set PF0 to 0, PF1 to 1 make /AMS3 work properly */
671 ret = gpio_request(GPIO_PF0, "net2272");
672 if (ret)
673 return ret;
674
675 ret = gpio_request(GPIO_PF1, "net2272");
676 if (ret) {
677 gpio_free(GPIO_PF0);
678 return ret;
679 }
680
681 ret = gpio_request(GPIO_PF11, "net2272");
682 if (ret) {
683 gpio_free(GPIO_PF0);
684 gpio_free(GPIO_PF1);
685 return ret;
686 }
687
688 gpio_direction_output(GPIO_PF0, 0);
689 gpio_direction_output(GPIO_PF1, 1);
690
691 /* Reset the USB chip */
692 gpio_direction_output(GPIO_PF11, 0);
693 mdelay(2);
694 gpio_set_value(GPIO_PF11, 1);
695#endif
696
697 return 0;
698}
699
Bryan Wu1394f032007-05-06 14:50:22 -0700700static int __init stamp_init(void)
701{
Mike Frysingerc0fc5252007-05-21 18:09:25 +0800702 int ret;
703
Harvey Harrisonb85d8582008-04-23 09:39:01 +0800704 printk(KERN_INFO "%s(): registering device resources\n", __func__);
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800705
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800706 i2c_register_board_info(0, bfin_i2c_board_info,
707 ARRAY_SIZE(bfin_i2c_board_info));
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800708
Mike Frysingerc0fc5252007-05-21 18:09:25 +0800709 ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
710 if (ret < 0)
711 return ret;
712
713#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
Mike Frysinger30e9b952010-10-26 21:30:29 -0400714 /*
715 * setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC.
716 * the bfin-async-map driver takes care of flipping between
717 * flash and ethernet when necessary.
718 */
719 ret = gpio_request(GPIO_PF0, "enet_cpld");
720 if (!ret) {
721 gpio_direction_output(GPIO_PF0, 1);
722 gpio_free(GPIO_PF0);
723 }
Bryan Wu1394f032007-05-06 14:50:22 -0700724#endif
Mike Frysingerc0fc5252007-05-21 18:09:25 +0800725
Mike Frysinger9be86312011-05-04 11:20:15 -0400726 if (net2272_init())
727 pr_warning("unable to configure net2272; it probably won't work\n");
728
Mike Frysinger5bda2722008-06-07 15:03:01 +0800729 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800730 return 0;
Bryan Wu1394f032007-05-06 14:50:22 -0700731}
732
733arch_initcall(stamp_init);
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800734
Sonic Zhangc13ce9f2009-09-23 09:37:46 +0000735static struct platform_device *stamp_early_devices[] __initdata = {
736#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
737#ifdef CONFIG_SERIAL_BFIN_UART0
738 &bfin_uart0_device,
739#endif
740#endif
741
742#if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
743#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
744 &bfin_sport0_uart_device,
745#endif
746#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
747 &bfin_sport1_uart_device,
748#endif
749#endif
750};
751
752void __init native_machine_early_platform_add_devices(void)
753{
754 printk(KERN_INFO "register early platform devices\n");
755 early_platform_add_devices(stamp_early_devices,
756 ARRAY_SIZE(stamp_early_devices));
757}
758
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800759void native_machine_restart(char *cmd)
760{
Mike Frysinger9cd9c612008-05-13 12:31:32 +0800761 /* workaround pull up on cpld / flash pin not being strong enough */
Mike Frysinger30e9b952010-10-26 21:30:29 -0400762 gpio_request(GPIO_PF0, "flash_cpld");
763 gpio_direction_output(GPIO_PF0, 0);
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800764}