blob: 0c75aa35faf48271e99dc42816587fa4642f60ab [file] [log] [blame]
Bryan Wu2f6f4bc2008-11-18 17:48:21 +08001/*
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 Wu2f6f4bc2008-11-18 17:48:21 +08005 *
Robin Getz96f10502009-09-24 14:11:24 +00006 * Licensed under the GPL-2 or later.
Bryan Wu2f6f4bc2008-11-18 17:48:21 +08007 */
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
17#include <linux/i2c.h>
18#include <linux/irq.h>
19#include <linux/interrupt.h>
20#include <asm/dma.h>
21#include <asm/bfin5xx_spi.h>
22#include <asm/reboot.h>
23#include <asm/portmux.h>
24#include <asm/dpmc.h>
Cliff Cai501674a2009-01-07 23:14:38 +080025#include <asm/bfin_sdh.h>
Bryan Wu2f6f4bc2008-11-18 17:48:21 +080026#include <linux/spi/ad7877.h>
Graf Yang65319622009-02-04 16:49:45 +080027#include <net/dsa.h>
Bryan Wu2f6f4bc2008-11-18 17:48:21 +080028
29/*
30 * Name the Board for the /proc/cpuinfo
31 */
Mike Frysingerfe85cad2008-11-18 17:48:22 +080032const char bfin_board_name[] = "ADI BF518F-EZBRD";
Bryan Wu2f6f4bc2008-11-18 17:48:21 +080033
34/*
35 * Driver needs to know address, irq and flag pin.
36 */
37
38#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
39static struct mtd_partition ezbrd_partitions[] = {
40 {
41 .name = "bootloader(nor)",
42 .size = 0x40000,
43 .offset = 0,
44 }, {
45 .name = "linux kernel(nor)",
46 .size = 0x1C0000,
47 .offset = MTDPART_OFS_APPEND,
48 }, {
49 .name = "file system(nor)",
50 .size = MTDPART_SIZ_FULL,
51 .offset = MTDPART_OFS_APPEND,
52 }
53};
54
55static struct physmap_flash_data ezbrd_flash_data = {
56 .width = 2,
57 .parts = ezbrd_partitions,
58 .nr_parts = ARRAY_SIZE(ezbrd_partitions),
59};
60
61static struct resource ezbrd_flash_resource = {
62 .start = 0x20000000,
Graf Yangee0263c2009-05-20 06:06:15 +000063#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
64 .end = 0x202fffff,
65#else
Bryan Wu2f6f4bc2008-11-18 17:48:21 +080066 .end = 0x203fffff,
Graf Yangee0263c2009-05-20 06:06:15 +000067#endif
Bryan Wu2f6f4bc2008-11-18 17:48:21 +080068 .flags = IORESOURCE_MEM,
69};
70
71static struct platform_device ezbrd_flash_device = {
72 .name = "physmap-flash",
73 .id = 0,
74 .dev = {
75 .platform_data = &ezbrd_flash_data,
76 },
77 .num_resources = 1,
78 .resource = &ezbrd_flash_resource,
79};
80#endif
81
82#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
83static struct platform_device rtc_device = {
84 .name = "rtc-bfin",
85 .id = -1,
86};
87#endif
88
89#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
Sonic Zhang02460d02010-06-11 10:44:22 +000090#include <linux/bfin_mac.h>
91static const unsigned short bfin_mac_peripherals[] = {
92 P_MII0_ETxD0,
93 P_MII0_ETxD1,
94 P_MII0_ETxEN,
95 P_MII0_ERxD0,
96 P_MII0_ERxD1,
97 P_MII0_TxCLK,
98 P_MII0_PHYINT,
99 P_MII0_CRS,
100 P_MII0_MDC,
101 P_MII0_MDIO,
102 0
103};
104
105static struct bfin_phydev_platform_data bfin_phydev_data[] = {
106 {
107 .addr = 1,
108 .irq = IRQ_MAC_PHYINT,
109 },
110 {
111 .addr = 2,
112 .irq = IRQ_MAC_PHYINT,
113 },
114 {
115 .addr = 3,
116 .irq = IRQ_MAC_PHYINT,
117 },
118};
119
120static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
121 .phydev_number = 3,
122 .phydev_data = bfin_phydev_data,
123 .phy_mode = PHY_INTERFACE_MODE_MII,
124 .mac_peripherals = bfin_mac_peripherals,
125};
126
Graf Yang65319622009-02-04 16:49:45 +0800127static struct platform_device bfin_mii_bus = {
128 .name = "bfin_mii_bus",
Sonic Zhang02460d02010-06-11 10:44:22 +0000129 .dev = {
130 .platform_data = &bfin_mii_bus_data,
131 }
Graf Yang65319622009-02-04 16:49:45 +0800132};
133
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800134static struct platform_device bfin_mac_device = {
135 .name = "bfin_mac",
Sonic Zhang02460d02010-06-11 10:44:22 +0000136 .dev = {
137 .platform_data = &bfin_mii_bus,
138 }
Graf Yang65319622009-02-04 16:49:45 +0800139};
Graf Yang65319622009-02-04 16:49:45 +0800140
141#if defined(CONFIG_NET_DSA_KSZ8893M) || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
Mike Frysinger2780cd62009-06-11 09:22:02 -0400142static struct dsa_chip_data ksz8893m_switch_chip_data = {
Graf Yang65319622009-02-04 16:49:45 +0800143 .mii_bus = &bfin_mii_bus.dev,
Mike Frysinger2780cd62009-06-11 09:22:02 -0400144 .port_names = {
145 NULL,
146 "eth%d",
147 "eth%d",
148 "cpu",
149 },
150};
151static struct dsa_platform_data ksz8893m_switch_data = {
152 .nr_chips = 1,
Graf Yang65319622009-02-04 16:49:45 +0800153 .netdev = &bfin_mac_device.dev,
Mike Frysinger2780cd62009-06-11 09:22:02 -0400154 .chip = &ksz8893m_switch_chip_data,
Graf Yang65319622009-02-04 16:49:45 +0800155};
156
157static struct platform_device ksz8893m_switch_device = {
158 .name = "dsa",
159 .id = 0,
160 .num_resources = 0,
161 .dev.platform_data = &ksz8893m_switch_data,
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800162};
163#endif
Graf Yangc19577e2009-03-05 17:35:59 +0800164#endif
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800165
166#if defined(CONFIG_MTD_M25P80) \
167 || defined(CONFIG_MTD_M25P80_MODULE)
168static struct mtd_partition bfin_spi_flash_partitions[] = {
169 {
170 .name = "bootloader(spi)",
171 .size = 0x00040000,
172 .offset = 0,
173 .mask_flags = MTD_CAP_ROM
174 }, {
175 .name = "linux kernel(spi)",
176 .size = MTDPART_SIZ_FULL,
177 .offset = MTDPART_OFS_APPEND,
178 }
179};
180
181static struct flash_platform_data bfin_spi_flash_data = {
182 .name = "m25p80",
183 .parts = bfin_spi_flash_partitions,
184 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
185 .type = "m25p16",
186};
187
188/* SPI flash chip (m25p64) */
189static struct bfin5xx_spi_chip spi_flash_chip_info = {
190 .enable_dma = 0, /* use dma transfer with this chip*/
191 .bits_per_word = 8,
192};
193#endif
194
Mike Frysingera261eec2009-05-20 14:05:36 +0000195#if defined(CONFIG_BFIN_SPI_ADC) \
196 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800197/* SPI ADC chip */
198static struct bfin5xx_spi_chip spi_adc_chip_info = {
199 .enable_dma = 1, /* use dma transfer with this chip*/
200 .bits_per_word = 16,
201};
202#endif
203
Graf Yangc19577e2009-03-05 17:35:59 +0800204#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
Graf Yang65319622009-02-04 16:49:45 +0800205#if defined(CONFIG_NET_DSA_KSZ8893M) \
206 || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
207/* SPI SWITCH CHIP */
208static struct bfin5xx_spi_chip spi_switch_info = {
209 .enable_dma = 0,
210 .bits_per_word = 8,
211};
212#endif
Graf Yangc19577e2009-03-05 17:35:59 +0800213#endif
Graf Yang65319622009-02-04 16:49:45 +0800214
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800215#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
216static struct bfin5xx_spi_chip mmc_spi_chip_info = {
217 .enable_dma = 0,
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800218 .bits_per_word = 8,
219};
220#endif
221
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800222#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
223static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
224 .enable_dma = 0,
225 .bits_per_word = 16,
226};
227
228static const struct ad7877_platform_data bfin_ad7877_ts_info = {
229 .model = 7877,
230 .vref_delay_usecs = 50, /* internal, no capacitor */
231 .x_plate_ohms = 419,
232 .y_plate_ohms = 486,
233 .pressure_max = 1000,
234 .pressure_min = 0,
235 .stopacq_polarity = 1,
236 .first_conversion_delay = 3,
237 .acquisition_time = 1,
238 .averaging = 1,
239 .pen_down_acc_interval = 1,
240};
241#endif
242
243#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
244 && defined(CONFIG_SND_SOC_WM8731_SPI)
245static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
246 .enable_dma = 0,
247 .bits_per_word = 16,
248};
249#endif
250
251#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
252static struct bfin5xx_spi_chip spidev_chip_info = {
253 .enable_dma = 0,
254 .bits_per_word = 8,
255};
256#endif
257
258static struct spi_board_info bfin_spi_board_info[] __initdata = {
259#if defined(CONFIG_MTD_M25P80) \
260 || defined(CONFIG_MTD_M25P80_MODULE)
261 {
262 /* the modalias must be the same as spi device driver name */
263 .modalias = "m25p80", /* Name of spi_driver for this device */
264 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
265 .bus_num = 0, /* Framework bus number */
Graf Yanga4272932009-06-10 08:45:12 +0000266 .chip_select = 2, /* On BF518F-EZBRD it's SPI0_SSEL2 */
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800267 .platform_data = &bfin_spi_flash_data,
268 .controller_data = &spi_flash_chip_info,
269 .mode = SPI_MODE_3,
270 },
271#endif
272
Mike Frysingera261eec2009-05-20 14:05:36 +0000273#if defined(CONFIG_BFIN_SPI_ADC) \
274 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800275 {
276 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
277 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
278 .bus_num = 0, /* Framework bus number */
279 .chip_select = 1, /* Framework chip select. */
280 .platform_data = NULL, /* No spi_driver specific config */
281 .controller_data = &spi_adc_chip_info,
282 },
283#endif
284
Graf Yangc19577e2009-03-05 17:35:59 +0800285#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
Graf Yang65319622009-02-04 16:49:45 +0800286#if defined(CONFIG_NET_DSA_KSZ8893M) \
287 || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
288 {
289 .modalias = "ksz8893m",
290 .max_speed_hz = 5000000,
291 .bus_num = 0,
292 .chip_select = 1,
293 .platform_data = NULL,
294 .controller_data = &spi_switch_info,
295 .mode = SPI_MODE_3,
296 },
297#endif
Graf Yangc19577e2009-03-05 17:35:59 +0800298#endif
Graf Yang65319622009-02-04 16:49:45 +0800299
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800300#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800301 {
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800302 .modalias = "mmc_spi",
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800303 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
304 .bus_num = 0,
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800305 .chip_select = 5,
306 .controller_data = &mmc_spi_chip_info,
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800307 .mode = SPI_MODE_3,
308 },
309#endif
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800310#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
311 {
312 .modalias = "ad7877",
313 .platform_data = &bfin_ad7877_ts_info,
314 .irq = IRQ_PF8,
315 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
316 .bus_num = 0,
317 .chip_select = 2,
318 .controller_data = &spi_ad7877_chip_info,
319 },
320#endif
321#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
322 && defined(CONFIG_SND_SOC_WM8731_SPI)
323 {
324 .modalias = "wm8731",
325 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
326 .bus_num = 0,
327 .chip_select = 5,
328 .controller_data = &spi_wm8731_chip_info,
329 .mode = SPI_MODE_0,
330 },
331#endif
332#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
333 {
334 .modalias = "spidev",
335 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
336 .bus_num = 0,
337 .chip_select = 1,
338 .controller_data = &spidev_chip_info,
339 },
340#endif
341#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
342 {
343 .modalias = "bfin-lq035q1-spi",
344 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
345 .bus_num = 0,
346 .chip_select = 1,
347 .controller_data = &lq035q1_spi_chip_info,
348 .mode = SPI_CPHA | SPI_CPOL,
349 },
350#endif
351};
352
353/* SPI controller data */
354#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
355/* SPI (0) */
356static struct bfin5xx_spi_master bfin_spi0_info = {
Mike Frysingerc5af5452010-06-16 19:29:51 +0000357 .num_chipselect = 6,
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800358 .enable_dma = 1, /* master has the ability to do dma transfer */
359 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
360};
361
362static struct resource bfin_spi0_resource[] = {
363 [0] = {
364 .start = SPI0_REGBASE,
365 .end = SPI0_REGBASE + 0xFF,
366 .flags = IORESOURCE_MEM,
367 },
368 [1] = {
369 .start = CH_SPI0,
370 .end = CH_SPI0,
Yi Li53122692009-06-05 12:11:11 +0000371 .flags = IORESOURCE_DMA,
372 },
373 [2] = {
374 .start = IRQ_SPI0,
375 .end = IRQ_SPI0,
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800376 .flags = IORESOURCE_IRQ,
377 },
378};
379
380static struct platform_device bfin_spi0_device = {
381 .name = "bfin-spi",
382 .id = 0, /* Bus number */
383 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
384 .resource = bfin_spi0_resource,
385 .dev = {
386 .platform_data = &bfin_spi0_info, /* Passed to driver */
387 },
388};
389
390/* SPI (1) */
391static struct bfin5xx_spi_master bfin_spi1_info = {
Mike Frysingerc5af5452010-06-16 19:29:51 +0000392 .num_chipselect = 6,
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800393 .enable_dma = 1, /* master has the ability to do dma transfer */
394 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
395};
396
397static struct resource bfin_spi1_resource[] = {
398 [0] = {
399 .start = SPI1_REGBASE,
400 .end = SPI1_REGBASE + 0xFF,
401 .flags = IORESOURCE_MEM,
402 },
403 [1] = {
404 .start = CH_SPI1,
405 .end = CH_SPI1,
Yi Li53122692009-06-05 12:11:11 +0000406 .flags = IORESOURCE_DMA,
407 },
408 [2] = {
409 .start = IRQ_SPI1,
410 .end = IRQ_SPI1,
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800411 .flags = IORESOURCE_IRQ,
412 },
413};
414
415static struct platform_device bfin_spi1_device = {
416 .name = "bfin-spi",
417 .id = 1, /* Bus number */
418 .num_resources = ARRAY_SIZE(bfin_spi1_resource),
419 .resource = bfin_spi1_resource,
420 .dev = {
421 .platform_data = &bfin_spi1_info, /* Passed to driver */
422 },
423};
424#endif /* spi master and devices */
425
426#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800427#ifdef CONFIG_SERIAL_BFIN_UART0
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000428static struct resource bfin_uart0_resources[] = {
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800429 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000430 .start = UART0_THR,
431 .end = UART0_GCTL+2,
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800432 .flags = IORESOURCE_MEM,
433 },
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800434 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000435 .start = IRQ_UART0_RX,
436 .end = IRQ_UART0_RX+1,
437 .flags = IORESOURCE_IRQ,
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800438 },
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000439 {
440 .start = IRQ_UART0_ERROR,
441 .end = IRQ_UART0_ERROR,
442 .flags = IORESOURCE_IRQ,
443 },
444 {
445 .start = CH_UART0_TX,
446 .end = CH_UART0_TX,
447 .flags = IORESOURCE_DMA,
448 },
449 {
450 .start = CH_UART0_RX,
451 .end = CH_UART0_RX,
452 .flags = IORESOURCE_DMA,
453 },
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800454};
455
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000456unsigned short bfin_uart0_peripherals[] = {
457 P_UART0_TX, P_UART0_RX, 0
458};
459
460static struct platform_device bfin_uart0_device = {
461 .name = "bfin-uart",
462 .id = 0,
463 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
464 .resource = bfin_uart0_resources,
465 .dev = {
466 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
467 },
468};
469#endif
470#ifdef CONFIG_SERIAL_BFIN_UART1
471static struct resource bfin_uart1_resources[] = {
472 {
473 .start = UART1_THR,
474 .end = UART1_GCTL+2,
475 .flags = IORESOURCE_MEM,
476 },
477 {
478 .start = IRQ_UART1_RX,
479 .end = IRQ_UART1_RX+1,
480 .flags = IORESOURCE_IRQ,
481 },
482 {
483 .start = IRQ_UART1_ERROR,
484 .end = IRQ_UART1_ERROR,
485 .flags = IORESOURCE_IRQ,
486 },
487 {
488 .start = CH_UART1_TX,
489 .end = CH_UART1_TX,
490 .flags = IORESOURCE_DMA,
491 },
492 {
493 .start = CH_UART1_RX,
494 .end = CH_UART1_RX,
495 .flags = IORESOURCE_DMA,
496 },
497};
498
499unsigned short bfin_uart1_peripherals[] = {
500 P_UART1_TX, P_UART1_RX, 0
501};
502
503static struct platform_device bfin_uart1_device = {
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800504 .name = "bfin-uart",
505 .id = 1,
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000506 .num_resources = ARRAY_SIZE(bfin_uart1_resources),
507 .resource = bfin_uart1_resources,
508 .dev = {
509 .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
510 },
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800511};
512#endif
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000513#endif
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800514
515#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800516#ifdef CONFIG_BFIN_SIR0
Graf Yang42bd8bc2009-01-07 23:14:39 +0800517static struct resource bfin_sir0_resources[] = {
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800518 {
519 .start = 0xFFC00400,
520 .end = 0xFFC004FF,
521 .flags = IORESOURCE_MEM,
522 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800523 {
524 .start = IRQ_UART0_RX,
525 .end = IRQ_UART0_RX+1,
526 .flags = IORESOURCE_IRQ,
527 },
528 {
529 .start = CH_UART0_RX,
530 .end = CH_UART0_RX+1,
531 .flags = IORESOURCE_DMA,
532 },
533};
534
535static struct platform_device bfin_sir0_device = {
536 .name = "bfin_sir",
537 .id = 0,
538 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
539 .resource = bfin_sir0_resources,
540};
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800541#endif
542#ifdef CONFIG_BFIN_SIR1
Graf Yang42bd8bc2009-01-07 23:14:39 +0800543static struct resource bfin_sir1_resources[] = {
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800544 {
545 .start = 0xFFC02000,
546 .end = 0xFFC020FF,
547 .flags = IORESOURCE_MEM,
548 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800549 {
550 .start = IRQ_UART1_RX,
551 .end = IRQ_UART1_RX+1,
552 .flags = IORESOURCE_IRQ,
553 },
554 {
555 .start = CH_UART1_RX,
556 .end = CH_UART1_RX+1,
557 .flags = IORESOURCE_DMA,
558 },
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800559};
560
Graf Yang42bd8bc2009-01-07 23:14:39 +0800561static struct platform_device bfin_sir1_device = {
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800562 .name = "bfin_sir",
Graf Yang42bd8bc2009-01-07 23:14:39 +0800563 .id = 1,
564 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
565 .resource = bfin_sir1_resources,
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800566};
567#endif
Graf Yang42bd8bc2009-01-07 23:14:39 +0800568#endif
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800569
Bob Liu97dd5052010-09-29 08:30:12 +0000570#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
571static struct platform_device bfin_i2s = {
572 .name = "bfin-i2s",
573 .id = CONFIG_SND_BF5XX_SPORT_NUM,
574 /* TODO: add platform data here */
575};
576#endif
577
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800578#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
579static struct resource bfin_twi0_resource[] = {
580 [0] = {
581 .start = TWI0_REGBASE,
582 .end = TWI0_REGBASE,
583 .flags = IORESOURCE_MEM,
584 },
585 [1] = {
586 .start = IRQ_TWI,
587 .end = IRQ_TWI,
588 .flags = IORESOURCE_IRQ,
589 },
590};
591
592static struct platform_device i2c_bfin_twi_device = {
593 .name = "i2c-bfin-twi",
594 .id = 0,
595 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
596 .resource = bfin_twi0_resource,
597};
598#endif
599
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800600static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
Michael Hennerichebd58332009-07-02 11:00:38 +0000601#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800602 {
603 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
604 },
605#endif
Michael Hennerich204844e2009-06-30 14:57:22 +0000606#if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800607 {
608 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
609 .irq = IRQ_PF8,
610 },
611#endif
Bob Liu97dd5052010-09-29 08:30:12 +0000612#if defined(CONFIG_SND_SOC_SSM2602) || defined(CONFIG_SND_SOC_SSM2602_MODULE)
613 {
614 I2C_BOARD_INFO("ssm2602", 0x1b),
615 },
616#endif
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800617};
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800618
619#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000620#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
621static struct resource bfin_sport0_uart_resources[] = {
622 {
623 .start = SPORT0_TCR1,
624 .end = SPORT0_MRCS3+4,
625 .flags = IORESOURCE_MEM,
626 },
627 {
628 .start = IRQ_SPORT0_RX,
629 .end = IRQ_SPORT0_RX+1,
630 .flags = IORESOURCE_IRQ,
631 },
632 {
633 .start = IRQ_SPORT0_ERROR,
634 .end = IRQ_SPORT0_ERROR,
635 .flags = IORESOURCE_IRQ,
636 },
637};
638
639unsigned short bfin_sport0_peripherals[] = {
640 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
Sonic Zhange54b6732010-11-12 02:45:38 +0000641 P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
Sonic Zhangdf5de262009-09-23 05:01:56 +0000642};
643
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800644static struct platform_device bfin_sport0_uart_device = {
645 .name = "bfin-sport-uart",
646 .id = 0,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000647 .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
648 .resource = bfin_sport0_uart_resources,
649 .dev = {
650 .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
651 },
652};
653#endif
654#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
655static struct resource bfin_sport1_uart_resources[] = {
656 {
657 .start = SPORT1_TCR1,
658 .end = SPORT1_MRCS3+4,
659 .flags = IORESOURCE_MEM,
660 },
661 {
662 .start = IRQ_SPORT1_RX,
663 .end = IRQ_SPORT1_RX+1,
664 .flags = IORESOURCE_IRQ,
665 },
666 {
667 .start = IRQ_SPORT1_ERROR,
668 .end = IRQ_SPORT1_ERROR,
669 .flags = IORESOURCE_IRQ,
670 },
671};
672
673unsigned short bfin_sport1_peripherals[] = {
674 P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
Sonic Zhange54b6732010-11-12 02:45:38 +0000675 P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800676};
677
678static struct platform_device bfin_sport1_uart_device = {
679 .name = "bfin-sport-uart",
680 .id = 1,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000681 .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
682 .resource = bfin_sport1_uart_resources,
683 .dev = {
684 .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
685 },
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800686};
687#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000688#endif
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800689
690#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
691#include <linux/input.h>
692#include <linux/gpio_keys.h>
693
694static struct gpio_keys_button bfin_gpio_keys_table[] = {
695 {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
696 {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
697};
698
699static struct gpio_keys_platform_data bfin_gpio_keys_data = {
700 .buttons = bfin_gpio_keys_table,
701 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
702};
703
704static struct platform_device bfin_device_gpiokeys = {
705 .name = "gpio-keys",
706 .dev = {
707 .platform_data = &bfin_gpio_keys_data,
708 },
709};
710#endif
711
Cliff Cai501674a2009-01-07 23:14:38 +0800712#if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
713
714static struct bfin_sd_host bfin_sdh_data = {
715 .dma_chan = CH_RSI,
716 .irq_int0 = IRQ_RSI_INT0,
717 .pin_req = {P_RSI_DATA0, P_RSI_DATA1, P_RSI_DATA2, P_RSI_DATA3, P_RSI_CMD, P_RSI_CLK, 0},
718};
719
720static struct platform_device bf51x_sdh_device = {
721 .name = "bfin-sdh",
722 .id = 0,
723 .dev = {
724 .platform_data = &bfin_sdh_data,
725 },
726};
727#endif
728
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800729static const unsigned int cclk_vlev_datasheet[] =
730{
731 VRPAIR(VLEV_100, 400000000),
732 VRPAIR(VLEV_105, 426000000),
733 VRPAIR(VLEV_110, 500000000),
734 VRPAIR(VLEV_115, 533000000),
735 VRPAIR(VLEV_120, 600000000),
736};
737
738static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
739 .tuple_tab = cclk_vlev_datasheet,
740 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
741 .vr_settling_time = 25 /* us */,
742};
743
744static struct platform_device bfin_dpmc = {
745 .name = "bfin dpmc",
746 .dev = {
747 .platform_data = &bfin_dmpc_vreg_data,
748 },
749};
750
751static struct platform_device *stamp_devices[] __initdata = {
752
753 &bfin_dpmc,
754
755#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
756 &rtc_device,
757#endif
758
759#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
Graf Yang65319622009-02-04 16:49:45 +0800760 &bfin_mii_bus,
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800761 &bfin_mac_device,
Graf Yang65319622009-02-04 16:49:45 +0800762#if defined(CONFIG_NET_DSA_KSZ8893M) || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
763 &ksz8893m_switch_device,
764#endif
Graf Yangc19577e2009-03-05 17:35:59 +0800765#endif
Graf Yang65319622009-02-04 16:49:45 +0800766
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800767#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
768 &bfin_spi0_device,
769 &bfin_spi1_device,
770#endif
771
772#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000773#ifdef CONFIG_SERIAL_BFIN_UART0
774 &bfin_uart0_device,
775#endif
776#ifdef CONFIG_SERIAL_BFIN_UART1
777 &bfin_uart1_device,
778#endif
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800779#endif
780
781#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang42bd8bc2009-01-07 23:14:39 +0800782#ifdef CONFIG_BFIN_SIR0
783 &bfin_sir0_device,
784#endif
785#ifdef CONFIG_BFIN_SIR1
786 &bfin_sir1_device,
787#endif
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800788#endif
789
790#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
791 &i2c_bfin_twi_device,
792#endif
793
Bob Liu97dd5052010-09-29 08:30:12 +0000794#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
795 &bfin_i2s,
796#endif
797
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800798#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000799#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800800 &bfin_sport0_uart_device,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000801#endif
802#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800803 &bfin_sport1_uart_device,
804#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000805#endif
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800806
807#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
808 &bfin_device_gpiokeys,
809#endif
810
Cliff Cai501674a2009-01-07 23:14:38 +0800811#if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
812 &bf51x_sdh_device,
813#endif
814
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800815#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
816 &ezbrd_flash_device,
817#endif
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800818};
819
820static int __init ezbrd_init(void)
821{
822 printk(KERN_INFO "%s(): registering device resources\n", __func__);
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800823 i2c_register_board_info(0, bfin_i2c_board_info,
824 ARRAY_SIZE(bfin_i2c_board_info));
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800825 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
826 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
Graf Yangee0263c2009-05-20 06:06:15 +0000827 /* setup BF518-EZBRD GPIO pin PG11 to AMS2, PG15 to AMS3. */
828 peripheral_request(P_AMS2, "ParaFlash");
829#if !defined(CONFIG_SPI_BFIN) && !defined(CONFIG_SPI_BFIN_MODULE)
830 peripheral_request(P_AMS3, "ParaFlash");
831#endif
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800832 return 0;
833}
834
835arch_initcall(ezbrd_init);
836
Sonic Zhangc13ce9f2009-09-23 09:37:46 +0000837static struct platform_device *ezbrd_early_devices[] __initdata = {
838#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
839#ifdef CONFIG_SERIAL_BFIN_UART0
840 &bfin_uart0_device,
841#endif
842#ifdef CONFIG_SERIAL_BFIN_UART1
843 &bfin_uart1_device,
844#endif
845#endif
846
847#if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
848#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
849 &bfin_sport0_uart_device,
850#endif
851#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
852 &bfin_sport1_uart_device,
853#endif
854#endif
855};
856
857void __init native_machine_early_platform_add_devices(void)
858{
859 printk(KERN_INFO "register early platform devices\n");
860 early_platform_add_devices(ezbrd_early_devices,
861 ARRAY_SIZE(ezbrd_early_devices));
862}
863
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800864void native_machine_restart(char *cmd)
865{
866 /* workaround reboot hang when booting from SPI */
867 if ((bfin_read_SYSCR() & 0x7) == 0x3)
Sonic Zhangb52dae32009-02-04 16:49:45 +0800868 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
Bryan Wu2f6f4bc2008-11-18 17:48:21 +0800869}
870
871void bfin_get_ether_addr(char *addr)
872{
873 /* the MAC is stored in OTP memory page 0xDF */
874 u32 ret;
875 u64 otp_mac;
876 u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
877
878 ret = otp_read(0xDF, 0x00, &otp_mac);
879 if (!(ret & 0x1)) {
880 char *otp_mac_p = (char *)&otp_mac;
881 for (ret = 0; ret < 6; ++ret)
882 addr[ret] = otp_mac_p[5 - ret];
883 }
884}
885EXPORT_SYMBOL(bfin_get_ether_addr);