blob: 29c219eff2ff4499ff951341b8469f5d7326a63e [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>
David Howellsf3441942010-10-07 14:08:50 +010027#include <mach/fio_flag.h>
Bryan Wu1394f032007-05-06 14:50:22 -070028
29/*
30 * Name the Board for the /proc/cpuinfo
31 */
Mike Frysingerfe85cad2008-11-18 17:48:22 +080032const char bfin_board_name[] = "ADI BF533-STAMP";
Bryan Wu1394f032007-05-06 14:50:22 -070033
34#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
35static struct platform_device rtc_device = {
36 .name = "rtc-bfin",
37 .id = -1,
38};
39#endif
40
41/*
42 * Driver needs to know address, irq and flag pin.
43 */
44#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
Michael Hennerich61f09b52009-07-24 08:48:31 +000045#include <linux/smc91x.h>
46
47static struct smc91x_platdata smc91x_info = {
48 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
49 .leda = RPC_LED_100_10,
50 .ledb = RPC_LED_TX_RX,
51};
52
Bryan Wu1394f032007-05-06 14:50:22 -070053static struct resource smc91x_resources[] = {
54 {
55 .name = "smc91x-regs",
56 .start = 0x20300300,
57 .end = 0x20300300 + 16,
58 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080059 }, {
Bryan Wu1394f032007-05-06 14:50:22 -070060 .start = IRQ_PF7,
61 .end = IRQ_PF7,
62 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
63 },
64};
65
66static struct platform_device smc91x_device = {
67 .name = "smc91x",
68 .id = 0,
69 .num_resources = ARRAY_SIZE(smc91x_resources),
70 .resource = smc91x_resources,
Michael Hennerich61f09b52009-07-24 08:48:31 +000071 .dev = {
72 .platform_data = &smc91x_info,
73 },
Bryan Wu1394f032007-05-06 14:50:22 -070074};
75#endif
76
77#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
78static struct resource net2272_bfin_resources[] = {
79 {
80 .start = 0x20300000,
81 .end = 0x20300000 + 0x100,
82 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080083 }, {
Bryan Wu1394f032007-05-06 14:50:22 -070084 .start = IRQ_PF10,
85 .end = IRQ_PF10,
86 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
87 },
88};
89
90static struct platform_device net2272_bfin_device = {
91 .name = "net2272",
92 .id = -1,
93 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
94 .resource = net2272_bfin_resources,
95};
96#endif
97
Mike Frysinger9cd9c612008-05-13 12:31:32 +080098#if defined(CONFIG_MTD_BFIN_ASYNC) || defined(CONFIG_MTD_BFIN_ASYNC_MODULE)
Mike Frysingerde8c43f2008-01-24 17:14:04 +080099static struct mtd_partition stamp_partitions[] = {
100 {
Robin Getzaa582972008-08-05 17:47:29 +0800101 .name = "bootloader(nor)",
Mike Frysingeredf05642008-02-25 11:38:11 +0800102 .size = 0x40000,
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800103 .offset = 0,
104 }, {
Robin Getzaa582972008-08-05 17:47:29 +0800105 .name = "linux kernel(nor)",
Grace Pan6ecb5b62009-01-07 23:14:38 +0800106 .size = 0x180000,
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800107 .offset = MTDPART_OFS_APPEND,
108 }, {
Robin Getzaa582972008-08-05 17:47:29 +0800109 .name = "file system(nor)",
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800110 .size = MTDPART_SIZ_FULL,
111 .offset = MTDPART_OFS_APPEND,
112 }
113};
114
115static struct physmap_flash_data stamp_flash_data = {
116 .width = 2,
117 .parts = stamp_partitions,
118 .nr_parts = ARRAY_SIZE(stamp_partitions),
119};
120
121static struct resource stamp_flash_resource[] = {
122 {
123 .name = "cfi_probe",
124 .start = 0x20000000,
125 .end = 0x203fffff,
126 .flags = IORESOURCE_MEM,
127 }, {
Mike Frysinger9cd9c612008-05-13 12:31:32 +0800128 .start = 0x7BB07BB0, /* AMBCTL0 setting when accessing flash */
129 .end = 0x7BB07BB0, /* AMBCTL1 setting when accessing flash */
130 .flags = IORESOURCE_MEM,
131 }, {
132 .start = GPIO_PF0,
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800133 .flags = IORESOURCE_IRQ,
134 }
135};
136
137static struct platform_device stamp_flash_device = {
Mike Frysinger9cd9c612008-05-13 12:31:32 +0800138 .name = "bfin-async-flash",
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800139 .id = 0,
140 .dev = {
141 .platform_data = &stamp_flash_data,
142 },
143 .num_resources = ARRAY_SIZE(stamp_flash_resource),
144 .resource = stamp_flash_resource,
145};
Mike Frysinger793dc272008-03-26 08:09:12 +0800146#endif
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800147
Bryan Wu1394f032007-05-06 14:50:22 -0700148#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
149static struct mtd_partition bfin_spi_flash_partitions[] = {
150 {
Robin Getzaa582972008-08-05 17:47:29 +0800151 .name = "bootloader(spi)",
Mike Frysingeredf05642008-02-25 11:38:11 +0800152 .size = 0x00040000,
Bryan Wu1394f032007-05-06 14:50:22 -0700153 .offset = 0,
154 .mask_flags = MTD_CAP_ROM
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800155 }, {
Robin Getzaa582972008-08-05 17:47:29 +0800156 .name = "linux kernel(spi)",
Grace Pan6ecb5b62009-01-07 23:14:38 +0800157 .size = 0x180000,
Mike Frysingeredf05642008-02-25 11:38:11 +0800158 .offset = MTDPART_OFS_APPEND,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800159 }, {
Robin Getzaa582972008-08-05 17:47:29 +0800160 .name = "file system(spi)",
Mike Frysingeredf05642008-02-25 11:38:11 +0800161 .size = MTDPART_SIZ_FULL,
162 .offset = MTDPART_OFS_APPEND,
Bryan Wu1394f032007-05-06 14:50:22 -0700163 }
164};
165
166static struct flash_platform_data bfin_spi_flash_data = {
167 .name = "m25p80",
168 .parts = bfin_spi_flash_partitions,
169 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
170 .type = "m25p64",
171};
172
173/* SPI flash chip (m25p64) */
174static struct bfin5xx_spi_chip spi_flash_chip_info = {
175 .enable_dma = 0, /* use dma transfer with this chip*/
176 .bits_per_word = 8,
177};
178#endif
179
Mike Frysingera261eec2009-05-20 14:05:36 +0000180#if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
Bryan Wu1394f032007-05-06 14:50:22 -0700181/* SPI ADC chip */
182static struct bfin5xx_spi_chip spi_adc_chip_info = {
183 .enable_dma = 1, /* use dma transfer with this chip*/
184 .bits_per_word = 16,
185};
186#endif
187
Barry Songd40bd712010-02-22 10:31:06 +0000188#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE)
Bryan Wu1394f032007-05-06 14:50:22 -0700189static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
190 .enable_dma = 0,
191 .bits_per_word = 16,
192};
193#endif
194
Michael Hennerich6e668932008-02-09 01:54:09 +0800195#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
196static struct bfin5xx_spi_chip spidev_chip_info = {
197 .enable_dma = 0,
198 .bits_per_word = 8,
199};
200#endif
201
Yi Li2120b682009-07-16 10:12:30 +0000202#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
203#define MMC_SPI_CARD_DETECT_INT IRQ_PF5
204static int bfin_mmc_spi_init(struct device *dev,
205 irqreturn_t (*detect_int)(int, void *), void *data)
206{
207 return request_irq(MMC_SPI_CARD_DETECT_INT, detect_int,
208 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
209 "mmc-spi-detect", data);
210}
211
212static void bfin_mmc_spi_exit(struct device *dev, void *data)
213{
214 free_irq(MMC_SPI_CARD_DETECT_INT, data);
215}
216
217static struct mmc_spi_platform_data bfin_mmc_spi_pdata = {
218 .init = bfin_mmc_spi_init,
219 .exit = bfin_mmc_spi_exit,
220 .detect_delay = 100, /* msecs */
221};
222
223static struct bfin5xx_spi_chip mmc_spi_chip_info = {
224 .enable_dma = 0,
225 .bits_per_word = 8,
226 .pio_interrupt = 0,
227};
228#endif
229
Bryan Wu1394f032007-05-06 14:50:22 -0700230static struct spi_board_info bfin_spi_board_info[] __initdata = {
231#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
232 {
233 /* the modalias must be the same as spi device driver name */
234 .modalias = "m25p80", /* Name of spi_driver for this device */
235 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800236 .bus_num = 0, /* Framework bus number */
Bryan Wu1394f032007-05-06 14:50:22 -0700237 .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
238 .platform_data = &bfin_spi_flash_data,
239 .controller_data = &spi_flash_chip_info,
240 .mode = SPI_MODE_3,
241 },
242#endif
243
Mike Frysingera261eec2009-05-20 14:05:36 +0000244#if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
Bryan Wu1394f032007-05-06 14:50:22 -0700245 {
246 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
247 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800248 .bus_num = 0, /* Framework bus number */
Bryan Wu1394f032007-05-06 14:50:22 -0700249 .chip_select = 1, /* Framework chip select. */
250 .platform_data = NULL, /* No spi_driver specific config */
251 .controller_data = &spi_adc_chip_info,
252 },
253#endif
254
Barry Songd40bd712010-02-22 10:31:06 +0000255#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE)
Bryan Wu1394f032007-05-06 14:50:22 -0700256 {
Barry Songdac98172009-08-13 21:07:37 +0000257 .modalias = "ad1836",
Cliff Cai858c5e92009-07-22 06:34:55 +0000258 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800259 .bus_num = 0,
Bryan Wu1394f032007-05-06 14:50:22 -0700260 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
261 .controller_data = &ad1836_spi_chip_info,
262 },
263#endif
264
Michael Hennerich6e668932008-02-09 01:54:09 +0800265#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
266 {
267 .modalias = "spidev",
268 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
269 .bus_num = 0,
270 .chip_select = 1,
271 .controller_data = &spidev_chip_info,
272 },
273#endif
Yi Li2120b682009-07-16 10:12:30 +0000274#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
275 {
276 .modalias = "mmc_spi",
277 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
278 .bus_num = 0,
279 .chip_select = 4,
280 .platform_data = &bfin_mmc_spi_pdata,
281 .controller_data = &mmc_spi_chip_info,
282 .mode = SPI_MODE_3,
283 },
284#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700285};
286
Mike Frysinger5bda2722008-06-07 15:03:01 +0800287#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800288/* SPI (0) */
289static struct resource bfin_spi0_resource[] = {
290 [0] = {
291 .start = SPI0_REGBASE,
292 .end = SPI0_REGBASE + 0xFF,
293 .flags = IORESOURCE_MEM,
294 },
295 [1] = {
296 .start = CH_SPI,
297 .end = CH_SPI,
Yi Li53122692009-06-05 12:11:11 +0000298 .flags = IORESOURCE_DMA,
299 },
300 [2] = {
301 .start = IRQ_SPI,
302 .end = IRQ_SPI,
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800303 .flags = IORESOURCE_IRQ,
304 }
305};
306
Bryan Wu1394f032007-05-06 14:50:22 -0700307/* SPI controller data */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800308static struct bfin5xx_spi_master bfin_spi0_info = {
Bryan Wu1394f032007-05-06 14:50:22 -0700309 .num_chipselect = 8,
310 .enable_dma = 1, /* master has the ability to do dma transfer */
Bryan Wu5d448dd2007-11-12 23:24:42 +0800311 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
Bryan Wu1394f032007-05-06 14:50:22 -0700312};
313
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800314static struct platform_device bfin_spi0_device = {
315 .name = "bfin-spi",
316 .id = 0, /* Bus number */
317 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
318 .resource = bfin_spi0_resource,
Bryan Wu1394f032007-05-06 14:50:22 -0700319 .dev = {
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800320 .platform_data = &bfin_spi0_info, /* Passed to driver */
Bryan Wu1394f032007-05-06 14:50:22 -0700321 },
322};
323#endif /* spi master and devices */
324
Bryan Wu1394f032007-05-06 14:50:22 -0700325#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000326#ifdef CONFIG_SERIAL_BFIN_UART0
327static struct resource bfin_uart0_resources[] = {
Bryan Wu1394f032007-05-06 14:50:22 -0700328 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000329 .start = BFIN_UART_THR,
330 .end = BFIN_UART_GCTL+2,
Bryan Wu1394f032007-05-06 14:50:22 -0700331 .flags = IORESOURCE_MEM,
332 },
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000333 {
334 .start = IRQ_UART0_RX,
335 .end = IRQ_UART0_RX + 1,
336 .flags = IORESOURCE_IRQ,
337 },
338 {
339 .start = IRQ_UART0_ERROR,
340 .end = IRQ_UART0_ERROR,
341 .flags = IORESOURCE_IRQ,
342 },
343 {
344 .start = CH_UART0_TX,
345 .end = CH_UART0_TX,
346 .flags = IORESOURCE_DMA,
347 },
348 {
349 .start = CH_UART0_RX,
350 .end = CH_UART0_RX,
351 .flags = IORESOURCE_DMA,
352 },
Bryan Wu1394f032007-05-06 14:50:22 -0700353};
354
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000355unsigned short bfin_uart0_peripherals[] = {
356 P_UART0_TX, P_UART0_RX, 0
Bryan Wu1394f032007-05-06 14:50:22 -0700357};
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000358
359static struct platform_device bfin_uart0_device = {
360 .name = "bfin-uart",
361 .id = 0,
362 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
363 .resource = bfin_uart0_resources,
364 .dev = {
365 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
366 },
367};
368#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700369#endif
370
Graf Yang5be36d22008-04-25 03:09:15 +0800371#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang5be36d22008-04-25 03:09:15 +0800372#ifdef CONFIG_BFIN_SIR0
Graf Yang42bd8bc2009-01-07 23:14:39 +0800373static struct resource bfin_sir0_resources[] = {
Graf Yang5be36d22008-04-25 03:09:15 +0800374 {
375 .start = 0xFFC00400,
376 .end = 0xFFC004FF,
377 .flags = IORESOURCE_MEM,
378 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800379 {
380 .start = IRQ_UART0_RX,
381 .end = IRQ_UART0_RX+1,
382 .flags = IORESOURCE_IRQ,
383 },
384 {
385 .start = CH_UART0_RX,
386 .end = CH_UART0_RX+1,
387 .flags = IORESOURCE_DMA,
388 },
Graf Yang5be36d22008-04-25 03:09:15 +0800389};
390
Graf Yang42bd8bc2009-01-07 23:14:39 +0800391static struct platform_device bfin_sir0_device = {
Graf Yang5be36d22008-04-25 03:09:15 +0800392 .name = "bfin_sir",
393 .id = 0,
Graf Yang42bd8bc2009-01-07 23:14:39 +0800394 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
395 .resource = bfin_sir0_resources,
Graf Yang5be36d22008-04-25 03:09:15 +0800396};
397#endif
Graf Yang42bd8bc2009-01-07 23:14:39 +0800398#endif
Graf Yang5be36d22008-04-25 03:09:15 +0800399
Bryan Wu1394f032007-05-06 14:50:22 -0700400#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000401#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
402static struct resource bfin_sport0_uart_resources[] = {
403 {
404 .start = SPORT0_TCR1,
405 .end = SPORT0_MRCS3+4,
406 .flags = IORESOURCE_MEM,
407 },
408 {
409 .start = IRQ_SPORT0_RX,
410 .end = IRQ_SPORT0_RX+1,
411 .flags = IORESOURCE_IRQ,
412 },
413 {
414 .start = IRQ_SPORT0_ERROR,
415 .end = IRQ_SPORT0_ERROR,
416 .flags = IORESOURCE_IRQ,
417 },
418};
419
420unsigned short bfin_sport0_peripherals[] = {
421 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
422 P_SPORT0_DRPRI, P_SPORT0_RSCLK, P_SPORT0_DRSEC, P_SPORT0_DTSEC, 0
423};
424
Bryan Wu1394f032007-05-06 14:50:22 -0700425static struct platform_device bfin_sport0_uart_device = {
426 .name = "bfin-sport-uart",
427 .id = 0,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000428 .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
429 .resource = bfin_sport0_uart_resources,
430 .dev = {
431 .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
432 },
433};
434#endif
435#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
436static struct resource bfin_sport1_uart_resources[] = {
437 {
438 .start = SPORT1_TCR1,
439 .end = SPORT1_MRCS3+4,
440 .flags = IORESOURCE_MEM,
441 },
442 {
443 .start = IRQ_SPORT1_RX,
444 .end = IRQ_SPORT1_RX+1,
445 .flags = IORESOURCE_IRQ,
446 },
447 {
448 .start = IRQ_SPORT1_ERROR,
449 .end = IRQ_SPORT1_ERROR,
450 .flags = IORESOURCE_IRQ,
451 },
452};
453
454unsigned short bfin_sport1_peripherals[] = {
455 P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
456 P_SPORT1_DRPRI, P_SPORT1_RSCLK, P_SPORT1_DRSEC, P_SPORT1_DTSEC, 0
Bryan Wu1394f032007-05-06 14:50:22 -0700457};
458
459static struct platform_device bfin_sport1_uart_device = {
460 .name = "bfin-sport-uart",
461 .id = 1,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000462 .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
463 .resource = bfin_sport1_uart_resources,
464 .dev = {
465 .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
466 },
Bryan Wu1394f032007-05-06 14:50:22 -0700467};
468#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000469#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700470
Michael Hennerich2463ef22008-01-27 16:49:48 +0800471#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
472#include <linux/input.h>
473#include <linux/gpio_keys.h>
474
475static struct gpio_keys_button bfin_gpio_keys_table[] = {
Michael Hennerichf1bceb42008-02-02 16:17:52 +0800476 {BTN_0, GPIO_PF5, 0, "gpio-keys: BTN0"},
477 {BTN_1, GPIO_PF6, 0, "gpio-keys: BTN1"},
478 {BTN_2, GPIO_PF8, 0, "gpio-keys: BTN2"},
Michael Hennerich2463ef22008-01-27 16:49:48 +0800479};
480
481static struct gpio_keys_platform_data bfin_gpio_keys_data = {
482 .buttons = bfin_gpio_keys_table,
483 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
484};
485
486static struct platform_device bfin_device_gpiokeys = {
487 .name = "gpio-keys",
488 .dev = {
489 .platform_data = &bfin_gpio_keys_data,
490 },
491};
492#endif
493
Bryan Wue3163952008-01-24 16:19:15 +0800494#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
495#include <linux/i2c-gpio.h>
496
497static struct i2c_gpio_platform_data i2c_gpio_data = {
498 .sda_pin = 2,
499 .scl_pin = 3,
500 .sda_is_open_drain = 0,
501 .scl_is_open_drain = 0,
502 .udelay = 40,
503};
504
505static struct platform_device i2c_gpio_device = {
506 .name = "i2c-gpio",
507 .id = 0,
508 .dev = {
509 .platform_data = &i2c_gpio_data,
510 },
511};
512#endif
513
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800514static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
515#if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE)
516 {
517 I2C_BOARD_INFO("ad7142_joystick", 0x2C),
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800518 .irq = 39,
519 },
520#endif
Michael Hennerichebd58332009-07-02 11:00:38 +0000521#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800522 {
523 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800524 },
525#endif
Michael Hennerich204844e2009-06-30 14:57:22 +0000526#if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800527 {
528 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800529 .irq = 39,
530 },
531#endif
Michael Hennerich50c4c082009-09-22 13:10:09 +0000532#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
533 {
534 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
535 },
536#endif
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800537};
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800538
Michael Hennerich14b03202008-05-07 11:41:26 +0800539static const unsigned int cclk_vlev_datasheet[] =
540{
541 VRPAIR(VLEV_085, 250000000),
542 VRPAIR(VLEV_090, 376000000),
543 VRPAIR(VLEV_095, 426000000),
544 VRPAIR(VLEV_100, 426000000),
545 VRPAIR(VLEV_105, 476000000),
546 VRPAIR(VLEV_110, 476000000),
547 VRPAIR(VLEV_115, 476000000),
548 VRPAIR(VLEV_120, 600000000),
549 VRPAIR(VLEV_125, 600000000),
550 VRPAIR(VLEV_130, 600000000),
551};
552
553static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
554 .tuple_tab = cclk_vlev_datasheet,
555 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
556 .vr_settling_time = 25 /* us */,
557};
558
559static struct platform_device bfin_dpmc = {
560 .name = "bfin dpmc",
561 .dev = {
562 .platform_data = &bfin_dmpc_vreg_data,
563 },
564};
565
Barry Song7e1082b2010-01-12 03:59:18 +0000566#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
567static struct platform_device bfin_i2s = {
568 .name = "bfin-i2s",
569 .id = CONFIG_SND_BF5XX_SPORT_NUM,
570 /* TODO: add platform data here */
571};
572#endif
573
574#if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
575static struct platform_device bfin_tdm = {
576 .name = "bfin-tdm",
577 .id = CONFIG_SND_BF5XX_SPORT_NUM,
578 /* TODO: add platform data here */
579};
580#endif
581
582#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
583static struct platform_device bfin_ac97 = {
584 .name = "bfin-ac97",
585 .id = CONFIG_SND_BF5XX_SPORT_NUM,
586 /* TODO: add platform data here */
587};
588#endif
589
Bryan Wu1394f032007-05-06 14:50:22 -0700590static struct platform_device *stamp_devices[] __initdata = {
Michael Hennerich14b03202008-05-07 11:41:26 +0800591
592 &bfin_dpmc,
593
Bryan Wu1394f032007-05-06 14:50:22 -0700594#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
595 &rtc_device,
596#endif
597
598#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
599 &smc91x_device,
600#endif
601
602#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
603 &net2272_bfin_device,
604#endif
605
606#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800607 &bfin_spi0_device,
Bryan Wu1394f032007-05-06 14:50:22 -0700608#endif
609
610#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000611#ifdef CONFIG_SERIAL_BFIN_UART0
612 &bfin_uart0_device,
613#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700614#endif
615
Graf Yang5be36d22008-04-25 03:09:15 +0800616#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang42bd8bc2009-01-07 23:14:39 +0800617#ifdef CONFIG_BFIN_SIR0
618 &bfin_sir0_device,
619#endif
Graf Yang5be36d22008-04-25 03:09:15 +0800620#endif
621
Bryan Wu1394f032007-05-06 14:50:22 -0700622#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000623#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
Bryan Wu1394f032007-05-06 14:50:22 -0700624 &bfin_sport0_uart_device,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000625#endif
626#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
Bryan Wu1394f032007-05-06 14:50:22 -0700627 &bfin_sport1_uart_device,
628#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000629#endif
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800630
Michael Hennerich2463ef22008-01-27 16:49:48 +0800631#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
632 &bfin_device_gpiokeys,
633#endif
Bryan Wue3163952008-01-24 16:19:15 +0800634
635#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
636 &i2c_gpio_device,
637#endif
Mike Frysingercad2ab62008-02-22 17:01:31 +0800638
Mike Frysinger9cd9c612008-05-13 12:31:32 +0800639#if defined(CONFIG_MTD_BFIN_ASYNC) || defined(CONFIG_MTD_BFIN_ASYNC_MODULE)
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800640 &stamp_flash_device,
Mike Frysinger793dc272008-03-26 08:09:12 +0800641#endif
Barry Song7e1082b2010-01-12 03:59:18 +0000642
643#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
644 &bfin_i2s,
645#endif
646
647#if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
648 &bfin_tdm,
649#endif
650
651#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
652 &bfin_ac97,
653#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700654};
655
656static int __init stamp_init(void)
657{
Mike Frysingerc0fc5252007-05-21 18:09:25 +0800658 int ret;
659
Harvey Harrisonb85d8582008-04-23 09:39:01 +0800660 printk(KERN_INFO "%s(): registering device resources\n", __func__);
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800661
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800662 i2c_register_board_info(0, bfin_i2c_board_info,
663 ARRAY_SIZE(bfin_i2c_board_info));
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800664
Mike Frysingerc0fc5252007-05-21 18:09:25 +0800665 ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
666 if (ret < 0)
667 return ret;
668
669#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
Mike Frysingerc0fc5252007-05-21 18:09:25 +0800670 /* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC */
Mike Frysinger9cd9c612008-05-13 12:31:32 +0800671 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF0);
672 bfin_write_FIO_FLAG_S(PF0);
Mike Frysingerc0fc5252007-05-21 18:09:25 +0800673 SSYNC();
Bryan Wu1394f032007-05-06 14:50:22 -0700674#endif
Mike Frysingerc0fc5252007-05-21 18:09:25 +0800675
Mike Frysinger5bda2722008-06-07 15:03:01 +0800676 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800677 return 0;
Bryan Wu1394f032007-05-06 14:50:22 -0700678}
679
680arch_initcall(stamp_init);
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800681
Sonic Zhangc13ce9f2009-09-23 09:37:46 +0000682static struct platform_device *stamp_early_devices[] __initdata = {
683#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
684#ifdef CONFIG_SERIAL_BFIN_UART0
685 &bfin_uart0_device,
686#endif
687#endif
688
689#if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
690#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
691 &bfin_sport0_uart_device,
692#endif
693#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
694 &bfin_sport1_uart_device,
695#endif
696#endif
697};
698
699void __init native_machine_early_platform_add_devices(void)
700{
701 printk(KERN_INFO "register early platform devices\n");
702 early_platform_add_devices(stamp_early_devices,
703 ARRAY_SIZE(stamp_early_devices));
704}
705
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800706void native_machine_restart(char *cmd)
707{
Mike Frysinger9cd9c612008-05-13 12:31:32 +0800708 /* workaround pull up on cpld / flash pin not being strong enough */
709 bfin_write_FIO_INEN(~PF0);
710 bfin_write_FIO_DIR(PF0);
711 bfin_write_FIO_FLAG_C(PF0);
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800712}