blob: b7101aa6e3aadd1dd5a2ae65ded872f7b4a9ce92 [file] [log] [blame]
Michael Hennerich8cc71172008-10-13 14:45:06 +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>
Michael Hennerich8cc71172008-10-13 14:45:06 +08005 *
Robin Getz96f10502009-09-24 14:11:24 +00006 * Licensed under the GPL-2 or later.
Michael Hennerich8cc71172008-10-13 14:45:06 +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 <linux/usb/musb.h>
21#include <asm/dma.h>
22#include <asm/bfin5xx_spi.h>
23#include <asm/reboot.h>
24#include <asm/nand.h>
25#include <asm/portmux.h>
26#include <asm/dpmc.h>
27#include <linux/spi/ad7877.h>
28
29/*
30 * Name the Board for the /proc/cpuinfo
31 */
Mike Frysingerfe85cad2008-11-18 17:48:22 +080032const char bfin_board_name[] = "ADI BF526-EZBRD";
Michael Hennerich8cc71172008-10-13 14:45:06 +080033
34/*
35 * Driver needs to know address, irq and flag pin.
36 */
37
38#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
39static struct resource musb_resources[] = {
40 [0] = {
41 .start = 0xffc03800,
42 .end = 0xffc03cff,
43 .flags = IORESOURCE_MEM,
44 },
45 [1] = { /* general IRQ */
46 .start = IRQ_USB_INT0,
47 .end = IRQ_USB_INT0,
48 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
Hema Kalliguddifcf173e2010-09-29 11:26:39 -050049 .name = "mc"
Michael Hennerich8cc71172008-10-13 14:45:06 +080050 },
51 [2] = { /* DMA IRQ */
52 .start = IRQ_USB_DMA,
53 .end = IRQ_USB_DMA,
54 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
Hema Kalliguddifcf173e2010-09-29 11:26:39 -050055 .name = "dma"
Michael Hennerich8cc71172008-10-13 14:45:06 +080056 },
57};
58
59static struct musb_hdrc_config musb_config = {
60 .multipoint = 0,
61 .dyn_fifo = 0,
62 .soft_con = 1,
63 .dma = 1,
Bryan Wufea05da2009-01-07 23:14:39 +080064 .num_eps = 8,
65 .dma_channels = 8,
Michael Hennerich8cc71172008-10-13 14:45:06 +080066 .gpio_vrsel = GPIO_PG13,
Cliff Cai85eb0e42010-01-22 04:02:46 +000067 /* Some custom boards need to be active low, just set it to "0"
68 * if it is the case.
69 */
70 .gpio_vrsel_active = 1,
Bob Liu759a3f32010-09-17 11:09:57 +000071 .clkin = 24, /* musb CLKIN in MHZ */
Michael Hennerich8cc71172008-10-13 14:45:06 +080072};
73
74static struct musb_hdrc_platform_data musb_plat = {
75#if defined(CONFIG_USB_MUSB_OTG)
76 .mode = MUSB_OTG,
77#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
78 .mode = MUSB_HOST,
79#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
80 .mode = MUSB_PERIPHERAL,
81#endif
82 .config = &musb_config,
83};
84
85static u64 musb_dmamask = ~(u32)0;
86
87static struct platform_device musb_device = {
Felipe Balbi9cb03082010-12-02 09:21:05 +020088 .name = "musb-blackfin",
Michael Hennerich8cc71172008-10-13 14:45:06 +080089 .id = 0,
90 .dev = {
91 .dma_mask = &musb_dmamask,
92 .coherent_dma_mask = 0xffffffff,
93 .platform_data = &musb_plat,
94 },
95 .num_resources = ARRAY_SIZE(musb_resources),
96 .resource = musb_resources,
97};
98#endif
99
100#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
101static struct mtd_partition ezbrd_partitions[] = {
102 {
103 .name = "bootloader(nor)",
104 .size = 0x40000,
105 .offset = 0,
106 }, {
107 .name = "linux kernel(nor)",
108 .size = 0x1C0000,
109 .offset = MTDPART_OFS_APPEND,
110 }, {
111 .name = "file system(nor)",
112 .size = MTDPART_SIZ_FULL,
113 .offset = MTDPART_OFS_APPEND,
114 }
115};
116
117static struct physmap_flash_data ezbrd_flash_data = {
118 .width = 2,
119 .parts = ezbrd_partitions,
120 .nr_parts = ARRAY_SIZE(ezbrd_partitions),
121};
122
123static struct resource ezbrd_flash_resource = {
124 .start = 0x20000000,
125 .end = 0x203fffff,
126 .flags = IORESOURCE_MEM,
127};
128
129static struct platform_device ezbrd_flash_device = {
130 .name = "physmap-flash",
131 .id = 0,
132 .dev = {
133 .platform_data = &ezbrd_flash_data,
134 },
135 .num_resources = 1,
136 .resource = &ezbrd_flash_resource,
137};
138#endif
139
140#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
141static struct mtd_partition partition_info[] = {
142 {
Mike Frysinger5cc1c562010-09-22 02:46:44 +0000143 .name = "bootloader(nand)",
Michael Hennerich8cc71172008-10-13 14:45:06 +0800144 .offset = 0,
Mike Frysinger5cc1c562010-09-22 02:46:44 +0000145 .size = 0x40000,
146 }, {
147 .name = "linux kernel(nand)",
148 .offset = MTDPART_OFS_APPEND,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800149 .size = 4 * 1024 * 1024,
150 },
151 {
152 .name = "file system(nand)",
153 .offset = MTDPART_OFS_APPEND,
154 .size = MTDPART_SIZ_FULL,
155 },
156};
157
158static struct bf5xx_nand_platform bf5xx_nand_platform = {
Michael Hennerich8cc71172008-10-13 14:45:06 +0800159 .data_width = NFC_NWIDTH_8,
160 .partitions = partition_info,
161 .nr_partitions = ARRAY_SIZE(partition_info),
162 .rd_dly = 3,
163 .wr_dly = 3,
164};
165
166static struct resource bf5xx_nand_resources[] = {
167 {
168 .start = NFC_CTL,
169 .end = NFC_DATA_RD + 2,
170 .flags = IORESOURCE_MEM,
171 },
172 {
173 .start = CH_NFC,
174 .end = CH_NFC,
175 .flags = IORESOURCE_IRQ,
176 },
177};
178
179static struct platform_device bf5xx_nand_device = {
180 .name = "bf5xx-nand",
181 .id = 0,
182 .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
183 .resource = bf5xx_nand_resources,
184 .dev = {
185 .platform_data = &bf5xx_nand_platform,
186 },
187};
188#endif
189
190#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
191static struct platform_device rtc_device = {
192 .name = "rtc-bfin",
193 .id = -1,
194};
195#endif
196
197
198#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
Sonic Zhang02460d02010-06-11 10:44:22 +0000199#include <linux/bfin_mac.h>
200static const unsigned short bfin_mac_peripherals[] = P_RMII0;
201
202static struct bfin_phydev_platform_data bfin_phydev_data[] = {
203 {
204 .addr = 1,
205 .irq = IRQ_MAC_PHYINT,
206 },
207};
208
209static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
210 .phydev_number = 1,
211 .phydev_data = bfin_phydev_data,
212 .phy_mode = PHY_INTERFACE_MODE_RMII,
213 .mac_peripherals = bfin_mac_peripherals,
214};
215
Graf Yang65319622009-02-04 16:49:45 +0800216static struct platform_device bfin_mii_bus = {
217 .name = "bfin_mii_bus",
Sonic Zhang02460d02010-06-11 10:44:22 +0000218 .dev = {
219 .platform_data = &bfin_mii_bus_data,
220 }
Graf Yang65319622009-02-04 16:49:45 +0800221};
222
Michael Hennerich8cc71172008-10-13 14:45:06 +0800223static struct platform_device bfin_mac_device = {
224 .name = "bfin_mac",
Sonic Zhang02460d02010-06-11 10:44:22 +0000225 .dev = {
226 .platform_data = &bfin_mii_bus,
227 }
Michael Hennerich8cc71172008-10-13 14:45:06 +0800228};
229#endif
230
231#if defined(CONFIG_MTD_M25P80) \
232 || defined(CONFIG_MTD_M25P80_MODULE)
233static struct mtd_partition bfin_spi_flash_partitions[] = {
234 {
235 .name = "bootloader(spi)",
236 .size = 0x00040000,
237 .offset = 0,
238 .mask_flags = MTD_CAP_ROM
239 }, {
240 .name = "linux kernel(spi)",
241 .size = MTDPART_SIZ_FULL,
242 .offset = MTDPART_OFS_APPEND,
243 }
244};
245
246static struct flash_platform_data bfin_spi_flash_data = {
247 .name = "m25p80",
248 .parts = bfin_spi_flash_partitions,
249 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
Graf Yangdc2c46b2009-06-15 08:23:41 +0000250 .type = "sst25wf040",
Michael Hennerich8cc71172008-10-13 14:45:06 +0800251};
252
Graf Yangdc2c46b2009-06-15 08:23:41 +0000253/* SPI flash chip (sst25wf040) */
Michael Hennerich8cc71172008-10-13 14:45:06 +0800254static struct bfin5xx_spi_chip spi_flash_chip_info = {
255 .enable_dma = 0, /* use dma transfer with this chip*/
256 .bits_per_word = 8,
257};
258#endif
259
Mike Frysingera261eec2009-05-20 14:05:36 +0000260#if defined(CONFIG_BFIN_SPI_ADC) \
261 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
Michael Hennerich8cc71172008-10-13 14:45:06 +0800262/* SPI ADC chip */
263static struct bfin5xx_spi_chip spi_adc_chip_info = {
264 .enable_dma = 1, /* use dma transfer with this chip*/
265 .bits_per_word = 16,
266};
267#endif
268
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800269#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
270static struct bfin5xx_spi_chip mmc_spi_chip_info = {
271 .enable_dma = 0,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800272 .bits_per_word = 8,
273};
274#endif
275
Michael Hennerich8cc71172008-10-13 14:45:06 +0800276#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
277static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
278 .enable_dma = 0,
279 .bits_per_word = 16,
280};
281
282static const struct ad7877_platform_data bfin_ad7877_ts_info = {
283 .model = 7877,
284 .vref_delay_usecs = 50, /* internal, no capacitor */
285 .x_plate_ohms = 419,
286 .y_plate_ohms = 486,
287 .pressure_max = 1000,
288 .pressure_min = 0,
289 .stopacq_polarity = 1,
290 .first_conversion_delay = 3,
291 .acquisition_time = 1,
292 .averaging = 1,
293 .pen_down_acc_interval = 1,
294};
295#endif
296
Michael Hennerich51054322009-01-07 23:14:38 +0800297#if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
298#include <linux/spi/ad7879.h>
299static const struct ad7879_platform_data bfin_ad7879_ts_info = {
300 .model = 7879, /* Model = AD7879 */
301 .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
302 .pressure_max = 10000,
303 .pressure_min = 0,
304 .first_conversion_delay = 3, /* wait 512us before do a first conversion */
305 .acquisition_time = 1, /* 4us acquisition time per sample */
306 .median = 2, /* do 8 measurements */
307 .averaging = 1, /* take the average of 4 middle samples */
308 .pen_down_acc_interval = 255, /* 9.4 ms */
Michael Hennerich244d3422009-12-18 09:29:39 +0000309 .gpio_export = 1, /* Export GPIO to gpiolib */
310 .gpio_base = -1, /* Dynamic allocation */
Michael Hennerich51054322009-01-07 23:14:38 +0800311};
312#endif
313
314#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
315static struct bfin5xx_spi_chip spi_ad7879_chip_info = {
316 .enable_dma = 0,
317 .bits_per_word = 16,
318};
319#endif
320
Michael Hennerich8cc71172008-10-13 14:45:06 +0800321#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
322 && defined(CONFIG_SND_SOC_WM8731_SPI)
323static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
324 .enable_dma = 0,
325 .bits_per_word = 16,
326};
327#endif
328
329#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
330static struct bfin5xx_spi_chip spidev_chip_info = {
331 .enable_dma = 0,
332 .bits_per_word = 8,
333};
334#endif
335
336#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
337static struct bfin5xx_spi_chip lq035q1_spi_chip_info = {
338 .enable_dma = 0,
339 .bits_per_word = 8,
340};
341#endif
342
343static struct spi_board_info bfin_spi_board_info[] __initdata = {
344#if defined(CONFIG_MTD_M25P80) \
345 || defined(CONFIG_MTD_M25P80_MODULE)
346 {
347 /* the modalias must be the same as spi device driver name */
348 .modalias = "m25p80", /* Name of spi_driver for this device */
349 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
350 .bus_num = 0, /* Framework bus number */
351 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
352 .platform_data = &bfin_spi_flash_data,
353 .controller_data = &spi_flash_chip_info,
354 .mode = SPI_MODE_3,
355 },
356#endif
357
Mike Frysingera261eec2009-05-20 14:05:36 +0000358#if defined(CONFIG_BFIN_SPI_ADC) \
359 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
Michael Hennerich8cc71172008-10-13 14:45:06 +0800360 {
361 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
362 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
363 .bus_num = 0, /* Framework bus number */
364 .chip_select = 1, /* Framework chip select. */
365 .platform_data = NULL, /* No spi_driver specific config */
366 .controller_data = &spi_adc_chip_info,
367 },
368#endif
369
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800370#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
Michael Hennerich8cc71172008-10-13 14:45:06 +0800371 {
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800372 .modalias = "mmc_spi",
Michael Hennerich8cc71172008-10-13 14:45:06 +0800373 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
374 .bus_num = 0,
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800375 .chip_select = 5,
376 .controller_data = &mmc_spi_chip_info,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800377 .mode = SPI_MODE_3,
378 },
379#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800380#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
381 {
382 .modalias = "ad7877",
383 .platform_data = &bfin_ad7877_ts_info,
384 .irq = IRQ_PF8,
385 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
386 .bus_num = 0,
387 .chip_select = 2,
388 .controller_data = &spi_ad7877_chip_info,
389 },
390#endif
Michael Hennerich51054322009-01-07 23:14:38 +0800391#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
392 {
393 .modalias = "ad7879",
394 .platform_data = &bfin_ad7879_ts_info,
395 .irq = IRQ_PG0,
396 .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
397 .bus_num = 0,
398 .chip_select = 5,
399 .controller_data = &spi_ad7879_chip_info,
400 .mode = SPI_CPHA | SPI_CPOL,
401 },
402#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800403#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
404 && defined(CONFIG_SND_SOC_WM8731_SPI)
405 {
406 .modalias = "wm8731",
407 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
408 .bus_num = 0,
409 .chip_select = 5,
410 .controller_data = &spi_wm8731_chip_info,
411 .mode = SPI_MODE_0,
412 },
413#endif
414#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
415 {
416 .modalias = "spidev",
417 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
418 .bus_num = 0,
419 .chip_select = 1,
420 .controller_data = &spidev_chip_info,
421 },
422#endif
423#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
424 {
425 .modalias = "bfin-lq035q1-spi",
426 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
427 .bus_num = 0,
428 .chip_select = 1,
429 .controller_data = &lq035q1_spi_chip_info,
430 .mode = SPI_CPHA | SPI_CPOL,
431 },
432#endif
433};
434
435#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
436/* SPI controller data */
437static struct bfin5xx_spi_master bfin_spi0_info = {
438 .num_chipselect = 8,
439 .enable_dma = 1, /* master has the ability to do dma transfer */
440 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
441};
442
443/* SPI (0) */
444static struct resource bfin_spi0_resource[] = {
445 [0] = {
446 .start = SPI0_REGBASE,
447 .end = SPI0_REGBASE + 0xFF,
448 .flags = IORESOURCE_MEM,
449 },
450 [1] = {
451 .start = CH_SPI,
452 .end = CH_SPI,
Yi Li53122692009-06-05 12:11:11 +0000453 .flags = IORESOURCE_DMA,
454 },
455 [2] = {
456 .start = IRQ_SPI,
457 .end = IRQ_SPI,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800458 .flags = IORESOURCE_IRQ,
459 },
460};
461
462static struct platform_device bfin_spi0_device = {
463 .name = "bfin-spi",
464 .id = 0, /* Bus number */
465 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
466 .resource = bfin_spi0_resource,
467 .dev = {
468 .platform_data = &bfin_spi0_info, /* Passed to driver */
469 },
470};
471#endif /* spi master and devices */
472
473#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Michael Hennerich8cc71172008-10-13 14:45:06 +0800474#ifdef CONFIG_SERIAL_BFIN_UART0
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000475static struct resource bfin_uart0_resources[] = {
Michael Hennerich8cc71172008-10-13 14:45:06 +0800476 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000477 .start = UART0_THR,
478 .end = UART0_GCTL+2,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800479 .flags = IORESOURCE_MEM,
480 },
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000481 {
482 .start = IRQ_UART0_RX,
483 .end = IRQ_UART0_RX+1,
484 .flags = IORESOURCE_IRQ,
485 },
486 {
487 .start = IRQ_UART0_ERROR,
488 .end = IRQ_UART0_ERROR,
489 .flags = IORESOURCE_IRQ,
490 },
491 {
492 .start = CH_UART0_TX,
493 .end = CH_UART0_TX,
494 .flags = IORESOURCE_DMA,
495 },
496 {
497 .start = CH_UART0_RX,
498 .end = CH_UART0_RX,
499 .flags = IORESOURCE_DMA,
500 },
501};
502
Mike Frysingera8b19882010-11-24 09:23:04 +0000503static unsigned short bfin_uart0_peripherals[] = {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000504 P_UART0_TX, P_UART0_RX, 0
505};
506
507static struct platform_device bfin_uart0_device = {
508 .name = "bfin-uart",
509 .id = 0,
510 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
511 .resource = bfin_uart0_resources,
512 .dev = {
513 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
514 },
515};
Michael Hennerich8cc71172008-10-13 14:45:06 +0800516#endif
517#ifdef CONFIG_SERIAL_BFIN_UART1
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000518static struct resource bfin_uart1_resources[] = {
Michael Hennerich8cc71172008-10-13 14:45:06 +0800519 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000520 .start = UART1_THR,
521 .end = UART1_GCTL+2,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800522 .flags = IORESOURCE_MEM,
523 },
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000524 {
525 .start = IRQ_UART1_RX,
526 .end = IRQ_UART1_RX+1,
527 .flags = IORESOURCE_IRQ,
528 },
529 {
530 .start = IRQ_UART1_ERROR,
531 .end = IRQ_UART1_ERROR,
532 .flags = IORESOURCE_IRQ,
533 },
534 {
535 .start = CH_UART1_TX,
536 .end = CH_UART1_TX,
537 .flags = IORESOURCE_DMA,
538 },
539 {
540 .start = CH_UART1_RX,
541 .end = CH_UART1_RX,
542 .flags = IORESOURCE_DMA,
543 },
544#ifdef CONFIG_BFIN_UART1_CTSRTS
545 { /* CTS pin */
546 .start = GPIO_PG0,
547 .end = GPIO_PG0,
548 .flags = IORESOURCE_IO,
549 },
550 { /* RTS pin */
551 .start = GPIO_PF10,
552 .end = GPIO_PF10,
553 .flags = IORESOURCE_IO,
554 },
Michael Hennerich8cc71172008-10-13 14:45:06 +0800555#endif
556};
557
Mike Frysingera8b19882010-11-24 09:23:04 +0000558static unsigned short bfin_uart1_peripherals[] = {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000559 P_UART1_TX, P_UART1_RX, 0
560};
561
562static struct platform_device bfin_uart1_device = {
Michael Hennerich8cc71172008-10-13 14:45:06 +0800563 .name = "bfin-uart",
564 .id = 1,
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000565 .num_resources = ARRAY_SIZE(bfin_uart1_resources),
566 .resource = bfin_uart1_resources,
567 .dev = {
568 .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
569 },
Michael Hennerich8cc71172008-10-13 14:45:06 +0800570};
571#endif
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000572#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800573
574#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Michael Hennerich8cc71172008-10-13 14:45:06 +0800575#ifdef CONFIG_BFIN_SIR0
Graf Yang42bd8bc2009-01-07 23:14:39 +0800576static struct resource bfin_sir0_resources[] = {
Michael Hennerich8cc71172008-10-13 14:45:06 +0800577 {
578 .start = 0xFFC00400,
579 .end = 0xFFC004FF,
580 .flags = IORESOURCE_MEM,
581 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800582 {
583 .start = IRQ_UART0_RX,
584 .end = IRQ_UART0_RX+1,
585 .flags = IORESOURCE_IRQ,
586 },
587 {
588 .start = CH_UART0_RX,
589 .end = CH_UART0_RX+1,
590 .flags = IORESOURCE_DMA,
591 },
592};
593
594static struct platform_device bfin_sir0_device = {
595 .name = "bfin_sir",
596 .id = 0,
597 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
598 .resource = bfin_sir0_resources,
599};
Michael Hennerich8cc71172008-10-13 14:45:06 +0800600#endif
601#ifdef CONFIG_BFIN_SIR1
Graf Yang42bd8bc2009-01-07 23:14:39 +0800602static struct resource bfin_sir1_resources[] = {
Michael Hennerich8cc71172008-10-13 14:45:06 +0800603 {
604 .start = 0xFFC02000,
605 .end = 0xFFC020FF,
606 .flags = IORESOURCE_MEM,
607 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800608 {
609 .start = IRQ_UART1_RX,
610 .end = IRQ_UART1_RX+1,
611 .flags = IORESOURCE_IRQ,
612 },
613 {
614 .start = CH_UART1_RX,
615 .end = CH_UART1_RX+1,
616 .flags = IORESOURCE_DMA,
617 },
Michael Hennerich8cc71172008-10-13 14:45:06 +0800618};
619
Graf Yang42bd8bc2009-01-07 23:14:39 +0800620static struct platform_device bfin_sir1_device = {
Michael Hennerich8cc71172008-10-13 14:45:06 +0800621 .name = "bfin_sir",
Graf Yang42bd8bc2009-01-07 23:14:39 +0800622 .id = 1,
623 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
624 .resource = bfin_sir1_resources,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800625};
626#endif
Graf Yang42bd8bc2009-01-07 23:14:39 +0800627#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800628
629#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
630static struct resource bfin_twi0_resource[] = {
631 [0] = {
632 .start = TWI0_REGBASE,
633 .end = TWI0_REGBASE,
634 .flags = IORESOURCE_MEM,
635 },
636 [1] = {
637 .start = IRQ_TWI,
638 .end = IRQ_TWI,
639 .flags = IORESOURCE_IRQ,
640 },
641};
642
643static struct platform_device i2c_bfin_twi_device = {
644 .name = "i2c-bfin-twi",
645 .id = 0,
646 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
647 .resource = bfin_twi0_resource,
648};
649#endif
650
Michael Hennerich8cc71172008-10-13 14:45:06 +0800651static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
Michael Hennerichebd58332009-07-02 11:00:38 +0000652#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
Michael Hennerich8cc71172008-10-13 14:45:06 +0800653 {
654 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
655 },
656#endif
Michael Hennerich204844e2009-06-30 14:57:22 +0000657#if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
Michael Hennerich8cc71172008-10-13 14:45:06 +0800658 {
659 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
660 .irq = IRQ_PF8,
661 },
662#endif
663};
Michael Hennerich8cc71172008-10-13 14:45:06 +0800664
665#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000666#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
667static struct resource bfin_sport0_uart_resources[] = {
668 {
669 .start = SPORT0_TCR1,
670 .end = SPORT0_MRCS3+4,
671 .flags = IORESOURCE_MEM,
672 },
673 {
674 .start = IRQ_SPORT0_RX,
675 .end = IRQ_SPORT0_RX+1,
676 .flags = IORESOURCE_IRQ,
677 },
678 {
679 .start = IRQ_SPORT0_ERROR,
680 .end = IRQ_SPORT0_ERROR,
681 .flags = IORESOURCE_IRQ,
682 },
683};
684
Mike Frysingera8b19882010-11-24 09:23:04 +0000685static unsigned short bfin_sport0_peripherals[] = {
Sonic Zhangdf5de262009-09-23 05:01:56 +0000686 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
Sonic Zhange54b6732010-11-12 02:45:38 +0000687 P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
Sonic Zhangdf5de262009-09-23 05:01:56 +0000688};
689
Michael Hennerich8cc71172008-10-13 14:45:06 +0800690static struct platform_device bfin_sport0_uart_device = {
691 .name = "bfin-sport-uart",
692 .id = 0,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000693 .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
694 .resource = bfin_sport0_uart_resources,
695 .dev = {
696 .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
697 },
698};
699#endif
700#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
701static struct resource bfin_sport1_uart_resources[] = {
702 {
703 .start = SPORT1_TCR1,
704 .end = SPORT1_MRCS3+4,
705 .flags = IORESOURCE_MEM,
706 },
707 {
708 .start = IRQ_SPORT1_RX,
709 .end = IRQ_SPORT1_RX+1,
710 .flags = IORESOURCE_IRQ,
711 },
712 {
713 .start = IRQ_SPORT1_ERROR,
714 .end = IRQ_SPORT1_ERROR,
715 .flags = IORESOURCE_IRQ,
716 },
717};
718
Mike Frysingera8b19882010-11-24 09:23:04 +0000719static unsigned short bfin_sport1_peripherals[] = {
Sonic Zhangdf5de262009-09-23 05:01:56 +0000720 P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
Sonic Zhange54b6732010-11-12 02:45:38 +0000721 P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
Michael Hennerich8cc71172008-10-13 14:45:06 +0800722};
723
724static struct platform_device bfin_sport1_uart_device = {
725 .name = "bfin-sport-uart",
726 .id = 1,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000727 .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
728 .resource = bfin_sport1_uart_resources,
729 .dev = {
730 .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
731 },
Michael Hennerich8cc71172008-10-13 14:45:06 +0800732};
733#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000734#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800735
736#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
737#include <linux/input.h>
738#include <linux/gpio_keys.h>
739
740static struct gpio_keys_button bfin_gpio_keys_table[] = {
741 {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
742 {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
743};
744
745static struct gpio_keys_platform_data bfin_gpio_keys_data = {
746 .buttons = bfin_gpio_keys_table,
747 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
748};
749
750static struct platform_device bfin_device_gpiokeys = {
751 .name = "gpio-keys",
752 .dev = {
753 .platform_data = &bfin_gpio_keys_data,
754 },
755};
756#endif
757
Michael Hennerich8cc71172008-10-13 14:45:06 +0800758static const unsigned int cclk_vlev_datasheet[] =
759{
760 VRPAIR(VLEV_100, 400000000),
761 VRPAIR(VLEV_105, 426000000),
762 VRPAIR(VLEV_110, 500000000),
763 VRPAIR(VLEV_115, 533000000),
764 VRPAIR(VLEV_120, 600000000),
765};
766
767static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
768 .tuple_tab = cclk_vlev_datasheet,
769 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
770 .vr_settling_time = 25 /* us */,
771};
772
773static struct platform_device bfin_dpmc = {
774 .name = "bfin dpmc",
775 .dev = {
776 .platform_data = &bfin_dmpc_vreg_data,
777 },
778};
779
780#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
781#include <asm/bfin-lq035q1.h>
782
783static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
Michael Hennerichd94a1aa2009-12-08 11:45:55 +0000784 .mode = LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
785 .ppi_mode = USE_RGB565_16_BIT_PPI,
786 .use_bl = 1,
787 .gpio_bl = GPIO_PG12,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800788};
789
790static struct resource bfin_lq035q1_resources[] = {
791 {
792 .start = IRQ_PPI_ERROR,
793 .end = IRQ_PPI_ERROR,
794 .flags = IORESOURCE_IRQ,
795 },
796};
797
798static struct platform_device bfin_lq035q1_device = {
799 .name = "bfin-lq035q1",
800 .id = -1,
801 .num_resources = ARRAY_SIZE(bfin_lq035q1_resources),
802 .resource = bfin_lq035q1_resources,
803 .dev = {
804 .platform_data = &bfin_lq035q1_data,
805 },
806};
807#endif
808
809static struct platform_device *stamp_devices[] __initdata = {
810
811 &bfin_dpmc,
812
813#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
814 &bf5xx_nand_device,
815#endif
816
817#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
818 &rtc_device,
819#endif
820
821#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
822 &musb_device,
823#endif
824
825#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
Graf Yang65319622009-02-04 16:49:45 +0800826 &bfin_mii_bus,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800827 &bfin_mac_device,
828#endif
829
830#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
831 &bfin_spi0_device,
832#endif
833
834#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000835#ifdef CONFIG_SERIAL_BFIN_UART0
836 &bfin_uart0_device,
837#endif
838#ifdef CONFIG_SERIAL_BFIN_UART1
839 &bfin_uart1_device,
840#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800841#endif
842
843#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
844 &bfin_lq035q1_device,
845#endif
846
847#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang42bd8bc2009-01-07 23:14:39 +0800848#ifdef CONFIG_BFIN_SIR0
849 &bfin_sir0_device,
850#endif
851#ifdef CONFIG_BFIN_SIR1
852 &bfin_sir1_device,
853#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800854#endif
855
856#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
857 &i2c_bfin_twi_device,
858#endif
859
860#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000861#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
Michael Hennerich8cc71172008-10-13 14:45:06 +0800862 &bfin_sport0_uart_device,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000863#endif
864#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
Michael Hennerich8cc71172008-10-13 14:45:06 +0800865 &bfin_sport1_uart_device,
866#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000867#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800868
869#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
870 &bfin_device_gpiokeys,
871#endif
872
873#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
874 &ezbrd_flash_device,
875#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800876};
877
Mike Frysinger7f6678c2009-02-04 16:49:45 +0800878static int __init ezbrd_init(void)
Michael Hennerich8cc71172008-10-13 14:45:06 +0800879{
880 printk(KERN_INFO "%s(): registering device resources\n", __func__);
Michael Hennerich8cc71172008-10-13 14:45:06 +0800881 i2c_register_board_info(0, bfin_i2c_board_info,
882 ARRAY_SIZE(bfin_i2c_board_info));
Michael Hennerich8cc71172008-10-13 14:45:06 +0800883 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
884 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
885 return 0;
886}
887
Mike Frysinger7f6678c2009-02-04 16:49:45 +0800888arch_initcall(ezbrd_init);
Michael Hennerich8cc71172008-10-13 14:45:06 +0800889
Sonic Zhangc13ce9f2009-09-23 09:37:46 +0000890static struct platform_device *ezbrd_early_devices[] __initdata = {
891#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
892#ifdef CONFIG_SERIAL_BFIN_UART0
893 &bfin_uart0_device,
894#endif
895#ifdef CONFIG_SERIAL_BFIN_UART1
896 &bfin_uart1_device,
897#endif
898#endif
899
900#if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
901#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
902 &bfin_sport0_uart_device,
903#endif
904#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
905 &bfin_sport1_uart_device,
906#endif
907#endif
908};
909
910void __init native_machine_early_platform_add_devices(void)
911{
912 printk(KERN_INFO "register early platform devices\n");
913 early_platform_add_devices(ezbrd_early_devices,
914 ARRAY_SIZE(ezbrd_early_devices));
915}
916
Michael Hennerich8cc71172008-10-13 14:45:06 +0800917void native_machine_restart(char *cmd)
918{
919 /* workaround reboot hang when booting from SPI */
920 if ((bfin_read_SYSCR() & 0x7) == 0x3)
Sonic Zhangb52dae32009-02-04 16:49:45 +0800921 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
Michael Hennerich8cc71172008-10-13 14:45:06 +0800922}
923
924void bfin_get_ether_addr(char *addr)
925{
926 /* the MAC is stored in OTP memory page 0xDF */
927 u32 ret;
928 u64 otp_mac;
929 u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
930
931 ret = otp_read(0xDF, 0x00, &otp_mac);
932 if (!(ret & 0x1)) {
933 char *otp_mac_p = (char *)&otp_mac;
934 for (ret = 0; ret < 6; ++ret)
935 addr[ret] = otp_mac_p[5 - ret];
936 }
937}
938EXPORT_SYMBOL(bfin_get_ether_addr);