blob: 2963c356c68b6f684dd2fdf4f5d8c9123d38e066 [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*/
Michael Hennerich8cc71172008-10-13 14:45:06 +0800256};
257#endif
258
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800259#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
260static struct bfin5xx_spi_chip mmc_spi_chip_info = {
261 .enable_dma = 0,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800262};
263#endif
264
Michael Hennerich8cc71172008-10-13 14:45:06 +0800265#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
Michael Hennerich8cc71172008-10-13 14:45:06 +0800266static const struct ad7877_platform_data bfin_ad7877_ts_info = {
267 .model = 7877,
268 .vref_delay_usecs = 50, /* internal, no capacitor */
269 .x_plate_ohms = 419,
270 .y_plate_ohms = 486,
271 .pressure_max = 1000,
272 .pressure_min = 0,
273 .stopacq_polarity = 1,
274 .first_conversion_delay = 3,
275 .acquisition_time = 1,
276 .averaging = 1,
277 .pen_down_acc_interval = 1,
278};
279#endif
280
Michael Hennerich51054322009-01-07 23:14:38 +0800281#if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
282#include <linux/spi/ad7879.h>
283static const struct ad7879_platform_data bfin_ad7879_ts_info = {
284 .model = 7879, /* Model = AD7879 */
285 .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
286 .pressure_max = 10000,
287 .pressure_min = 0,
288 .first_conversion_delay = 3, /* wait 512us before do a first conversion */
289 .acquisition_time = 1, /* 4us acquisition time per sample */
290 .median = 2, /* do 8 measurements */
291 .averaging = 1, /* take the average of 4 middle samples */
292 .pen_down_acc_interval = 255, /* 9.4 ms */
Michael Hennerich244d3422009-12-18 09:29:39 +0000293 .gpio_export = 1, /* Export GPIO to gpiolib */
294 .gpio_base = -1, /* Dynamic allocation */
Michael Hennerich51054322009-01-07 23:14:38 +0800295};
296#endif
297
Michael Hennerich8cc71172008-10-13 14:45:06 +0800298static struct spi_board_info bfin_spi_board_info[] __initdata = {
299#if defined(CONFIG_MTD_M25P80) \
300 || defined(CONFIG_MTD_M25P80_MODULE)
301 {
302 /* the modalias must be the same as spi device driver name */
303 .modalias = "m25p80", /* Name of spi_driver for this device */
304 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
305 .bus_num = 0, /* Framework bus number */
306 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
307 .platform_data = &bfin_spi_flash_data,
308 .controller_data = &spi_flash_chip_info,
309 .mode = SPI_MODE_3,
310 },
311#endif
312
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800313#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
Michael Hennerich8cc71172008-10-13 14:45:06 +0800314 {
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800315 .modalias = "mmc_spi",
Michael Hennerich8cc71172008-10-13 14:45:06 +0800316 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
317 .bus_num = 0,
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800318 .chip_select = 5,
319 .controller_data = &mmc_spi_chip_info,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800320 .mode = SPI_MODE_3,
321 },
322#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800323#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
324 {
325 .modalias = "ad7877",
326 .platform_data = &bfin_ad7877_ts_info,
327 .irq = IRQ_PF8,
328 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
329 .bus_num = 0,
330 .chip_select = 2,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800331 },
332#endif
Michael Hennerich51054322009-01-07 23:14:38 +0800333#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
334 {
335 .modalias = "ad7879",
336 .platform_data = &bfin_ad7879_ts_info,
337 .irq = IRQ_PG0,
338 .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
339 .bus_num = 0,
340 .chip_select = 5,
Michael Hennerich51054322009-01-07 23:14:38 +0800341 .mode = SPI_CPHA | SPI_CPOL,
342 },
343#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800344#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
345 && defined(CONFIG_SND_SOC_WM8731_SPI)
346 {
347 .modalias = "wm8731",
348 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
349 .bus_num = 0,
350 .chip_select = 5,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800351 .mode = SPI_MODE_0,
352 },
353#endif
354#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
355 {
356 .modalias = "spidev",
357 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
358 .bus_num = 0,
359 .chip_select = 1,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800360 },
361#endif
362#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
363 {
364 .modalias = "bfin-lq035q1-spi",
365 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
366 .bus_num = 0,
367 .chip_select = 1,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800368 .mode = SPI_CPHA | SPI_CPOL,
369 },
370#endif
371};
372
373#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
374/* SPI controller data */
375static struct bfin5xx_spi_master bfin_spi0_info = {
376 .num_chipselect = 8,
377 .enable_dma = 1, /* master has the ability to do dma transfer */
378 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
379};
380
381/* SPI (0) */
382static struct resource bfin_spi0_resource[] = {
383 [0] = {
384 .start = SPI0_REGBASE,
385 .end = SPI0_REGBASE + 0xFF,
386 .flags = IORESOURCE_MEM,
387 },
388 [1] = {
389 .start = CH_SPI,
390 .end = CH_SPI,
Yi Li53122692009-06-05 12:11:11 +0000391 .flags = IORESOURCE_DMA,
392 },
393 [2] = {
394 .start = IRQ_SPI,
395 .end = IRQ_SPI,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800396 .flags = IORESOURCE_IRQ,
397 },
398};
399
400static struct platform_device bfin_spi0_device = {
401 .name = "bfin-spi",
402 .id = 0, /* Bus number */
403 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
404 .resource = bfin_spi0_resource,
405 .dev = {
406 .platform_data = &bfin_spi0_info, /* Passed to driver */
407 },
408};
409#endif /* spi master and devices */
410
411#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Michael Hennerich8cc71172008-10-13 14:45:06 +0800412#ifdef CONFIG_SERIAL_BFIN_UART0
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000413static struct resource bfin_uart0_resources[] = {
Michael Hennerich8cc71172008-10-13 14:45:06 +0800414 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000415 .start = UART0_THR,
416 .end = UART0_GCTL+2,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800417 .flags = IORESOURCE_MEM,
418 },
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000419 {
Sonic Zhangedb0a642011-08-01 17:53:21 +0800420 .start = IRQ_UART0_TX,
421 .end = IRQ_UART0_TX,
422 .flags = IORESOURCE_IRQ,
423 },
424 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000425 .start = IRQ_UART0_RX,
Sonic Zhangedb0a642011-08-01 17:53:21 +0800426 .end = IRQ_UART0_RX,
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000427 .flags = IORESOURCE_IRQ,
428 },
429 {
430 .start = IRQ_UART0_ERROR,
431 .end = IRQ_UART0_ERROR,
432 .flags = IORESOURCE_IRQ,
433 },
434 {
435 .start = CH_UART0_TX,
436 .end = CH_UART0_TX,
437 .flags = IORESOURCE_DMA,
438 },
439 {
440 .start = CH_UART0_RX,
441 .end = CH_UART0_RX,
442 .flags = IORESOURCE_DMA,
443 },
444};
445
Mike Frysingera8b19882010-11-24 09:23:04 +0000446static unsigned short bfin_uart0_peripherals[] = {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000447 P_UART0_TX, P_UART0_RX, 0
448};
449
450static struct platform_device bfin_uart0_device = {
451 .name = "bfin-uart",
452 .id = 0,
453 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
454 .resource = bfin_uart0_resources,
455 .dev = {
456 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
457 },
458};
Michael Hennerich8cc71172008-10-13 14:45:06 +0800459#endif
460#ifdef CONFIG_SERIAL_BFIN_UART1
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000461static struct resource bfin_uart1_resources[] = {
Michael Hennerich8cc71172008-10-13 14:45:06 +0800462 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000463 .start = UART1_THR,
464 .end = UART1_GCTL+2,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800465 .flags = IORESOURCE_MEM,
466 },
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000467 {
Sonic Zhangedb0a642011-08-01 17:53:21 +0800468 .start = IRQ_UART1_TX,
469 .end = IRQ_UART1_TX,
470 .flags = IORESOURCE_IRQ,
471 },
472 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000473 .start = IRQ_UART1_RX,
Sonic Zhangedb0a642011-08-01 17:53:21 +0800474 .end = IRQ_UART1_RX,
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000475 .flags = IORESOURCE_IRQ,
476 },
477 {
478 .start = IRQ_UART1_ERROR,
479 .end = IRQ_UART1_ERROR,
480 .flags = IORESOURCE_IRQ,
481 },
482 {
483 .start = CH_UART1_TX,
484 .end = CH_UART1_TX,
485 .flags = IORESOURCE_DMA,
486 },
487 {
488 .start = CH_UART1_RX,
489 .end = CH_UART1_RX,
490 .flags = IORESOURCE_DMA,
491 },
492#ifdef CONFIG_BFIN_UART1_CTSRTS
493 { /* CTS pin */
494 .start = GPIO_PG0,
495 .end = GPIO_PG0,
496 .flags = IORESOURCE_IO,
497 },
498 { /* RTS pin */
499 .start = GPIO_PF10,
500 .end = GPIO_PF10,
501 .flags = IORESOURCE_IO,
502 },
Michael Hennerich8cc71172008-10-13 14:45:06 +0800503#endif
504};
505
Mike Frysingera8b19882010-11-24 09:23:04 +0000506static unsigned short bfin_uart1_peripherals[] = {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000507 P_UART1_TX, P_UART1_RX, 0
508};
509
510static struct platform_device bfin_uart1_device = {
Michael Hennerich8cc71172008-10-13 14:45:06 +0800511 .name = "bfin-uart",
512 .id = 1,
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000513 .num_resources = ARRAY_SIZE(bfin_uart1_resources),
514 .resource = bfin_uart1_resources,
515 .dev = {
516 .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
517 },
Michael Hennerich8cc71172008-10-13 14:45:06 +0800518};
519#endif
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000520#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800521
522#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Michael Hennerich8cc71172008-10-13 14:45:06 +0800523#ifdef CONFIG_BFIN_SIR0
Graf Yang42bd8bc2009-01-07 23:14:39 +0800524static struct resource bfin_sir0_resources[] = {
Michael Hennerich8cc71172008-10-13 14:45:06 +0800525 {
526 .start = 0xFFC00400,
527 .end = 0xFFC004FF,
528 .flags = IORESOURCE_MEM,
529 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800530 {
531 .start = IRQ_UART0_RX,
532 .end = IRQ_UART0_RX+1,
533 .flags = IORESOURCE_IRQ,
534 },
535 {
536 .start = CH_UART0_RX,
537 .end = CH_UART0_RX+1,
538 .flags = IORESOURCE_DMA,
539 },
540};
541
542static struct platform_device bfin_sir0_device = {
543 .name = "bfin_sir",
544 .id = 0,
545 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
546 .resource = bfin_sir0_resources,
547};
Michael Hennerich8cc71172008-10-13 14:45:06 +0800548#endif
549#ifdef CONFIG_BFIN_SIR1
Graf Yang42bd8bc2009-01-07 23:14:39 +0800550static struct resource bfin_sir1_resources[] = {
Michael Hennerich8cc71172008-10-13 14:45:06 +0800551 {
552 .start = 0xFFC02000,
553 .end = 0xFFC020FF,
554 .flags = IORESOURCE_MEM,
555 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800556 {
557 .start = IRQ_UART1_RX,
558 .end = IRQ_UART1_RX+1,
559 .flags = IORESOURCE_IRQ,
560 },
561 {
562 .start = CH_UART1_RX,
563 .end = CH_UART1_RX+1,
564 .flags = IORESOURCE_DMA,
565 },
Michael Hennerich8cc71172008-10-13 14:45:06 +0800566};
567
Graf Yang42bd8bc2009-01-07 23:14:39 +0800568static struct platform_device bfin_sir1_device = {
Michael Hennerich8cc71172008-10-13 14:45:06 +0800569 .name = "bfin_sir",
Graf Yang42bd8bc2009-01-07 23:14:39 +0800570 .id = 1,
571 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
572 .resource = bfin_sir1_resources,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800573};
574#endif
Graf Yang42bd8bc2009-01-07 23:14:39 +0800575#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800576
577#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
578static struct resource bfin_twi0_resource[] = {
579 [0] = {
580 .start = TWI0_REGBASE,
581 .end = TWI0_REGBASE,
582 .flags = IORESOURCE_MEM,
583 },
584 [1] = {
585 .start = IRQ_TWI,
586 .end = IRQ_TWI,
587 .flags = IORESOURCE_IRQ,
588 },
589};
590
591static struct platform_device i2c_bfin_twi_device = {
592 .name = "i2c-bfin-twi",
593 .id = 0,
594 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
595 .resource = bfin_twi0_resource,
596};
597#endif
598
Michael Hennerich8cc71172008-10-13 14:45:06 +0800599static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
Michael Hennerichebd58332009-07-02 11:00:38 +0000600#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
Michael Hennerich8cc71172008-10-13 14:45:06 +0800601 {
602 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
603 },
604#endif
Michael Hennerich204844e2009-06-30 14:57:22 +0000605#if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
Michael Hennerich8cc71172008-10-13 14:45:06 +0800606 {
607 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
608 .irq = IRQ_PF8,
609 },
610#endif
611};
Michael Hennerich8cc71172008-10-13 14:45:06 +0800612
613#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000614#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
615static struct resource bfin_sport0_uart_resources[] = {
616 {
617 .start = SPORT0_TCR1,
618 .end = SPORT0_MRCS3+4,
619 .flags = IORESOURCE_MEM,
620 },
621 {
622 .start = IRQ_SPORT0_RX,
623 .end = IRQ_SPORT0_RX+1,
624 .flags = IORESOURCE_IRQ,
625 },
626 {
627 .start = IRQ_SPORT0_ERROR,
628 .end = IRQ_SPORT0_ERROR,
629 .flags = IORESOURCE_IRQ,
630 },
631};
632
Mike Frysingera8b19882010-11-24 09:23:04 +0000633static unsigned short bfin_sport0_peripherals[] = {
Sonic Zhangdf5de262009-09-23 05:01:56 +0000634 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
Sonic Zhange54b6732010-11-12 02:45:38 +0000635 P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
Sonic Zhangdf5de262009-09-23 05:01:56 +0000636};
637
Michael Hennerich8cc71172008-10-13 14:45:06 +0800638static struct platform_device bfin_sport0_uart_device = {
639 .name = "bfin-sport-uart",
640 .id = 0,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000641 .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
642 .resource = bfin_sport0_uart_resources,
643 .dev = {
644 .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
645 },
646};
647#endif
648#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
649static struct resource bfin_sport1_uart_resources[] = {
650 {
651 .start = SPORT1_TCR1,
652 .end = SPORT1_MRCS3+4,
653 .flags = IORESOURCE_MEM,
654 },
655 {
656 .start = IRQ_SPORT1_RX,
657 .end = IRQ_SPORT1_RX+1,
658 .flags = IORESOURCE_IRQ,
659 },
660 {
661 .start = IRQ_SPORT1_ERROR,
662 .end = IRQ_SPORT1_ERROR,
663 .flags = IORESOURCE_IRQ,
664 },
665};
666
Mike Frysingera8b19882010-11-24 09:23:04 +0000667static unsigned short bfin_sport1_peripherals[] = {
Sonic Zhangdf5de262009-09-23 05:01:56 +0000668 P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
Sonic Zhange54b6732010-11-12 02:45:38 +0000669 P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
Michael Hennerich8cc71172008-10-13 14:45:06 +0800670};
671
672static struct platform_device bfin_sport1_uart_device = {
673 .name = "bfin-sport-uart",
674 .id = 1,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000675 .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
676 .resource = bfin_sport1_uart_resources,
677 .dev = {
678 .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
679 },
Michael Hennerich8cc71172008-10-13 14:45:06 +0800680};
681#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000682#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800683
684#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
685#include <linux/input.h>
686#include <linux/gpio_keys.h>
Paul Gortmaker8dc7a9c2011-08-09 11:05:22 -0400687#include <linux/export.h>
Michael Hennerich8cc71172008-10-13 14:45:06 +0800688
689static struct gpio_keys_button bfin_gpio_keys_table[] = {
690 {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
691 {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
692};
693
694static struct gpio_keys_platform_data bfin_gpio_keys_data = {
695 .buttons = bfin_gpio_keys_table,
696 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
697};
698
699static struct platform_device bfin_device_gpiokeys = {
700 .name = "gpio-keys",
701 .dev = {
702 .platform_data = &bfin_gpio_keys_data,
703 },
704};
705#endif
706
Michael Hennerich8cc71172008-10-13 14:45:06 +0800707static const unsigned int cclk_vlev_datasheet[] =
708{
709 VRPAIR(VLEV_100, 400000000),
710 VRPAIR(VLEV_105, 426000000),
711 VRPAIR(VLEV_110, 500000000),
712 VRPAIR(VLEV_115, 533000000),
713 VRPAIR(VLEV_120, 600000000),
714};
715
716static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
717 .tuple_tab = cclk_vlev_datasheet,
718 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
719 .vr_settling_time = 25 /* us */,
720};
721
722static struct platform_device bfin_dpmc = {
723 .name = "bfin dpmc",
724 .dev = {
725 .platform_data = &bfin_dmpc_vreg_data,
726 },
727};
728
729#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
730#include <asm/bfin-lq035q1.h>
731
732static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
Michael Hennerichd94a1aa2009-12-08 11:45:55 +0000733 .mode = LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
734 .ppi_mode = USE_RGB565_16_BIT_PPI,
735 .use_bl = 1,
736 .gpio_bl = GPIO_PG12,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800737};
738
739static struct resource bfin_lq035q1_resources[] = {
740 {
741 .start = IRQ_PPI_ERROR,
742 .end = IRQ_PPI_ERROR,
743 .flags = IORESOURCE_IRQ,
744 },
745};
746
747static struct platform_device bfin_lq035q1_device = {
748 .name = "bfin-lq035q1",
749 .id = -1,
750 .num_resources = ARRAY_SIZE(bfin_lq035q1_resources),
751 .resource = bfin_lq035q1_resources,
752 .dev = {
753 .platform_data = &bfin_lq035q1_data,
754 },
755};
756#endif
757
758static struct platform_device *stamp_devices[] __initdata = {
759
760 &bfin_dpmc,
761
762#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
763 &bf5xx_nand_device,
764#endif
765
766#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
767 &rtc_device,
768#endif
769
770#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
771 &musb_device,
772#endif
773
774#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
Graf Yang65319622009-02-04 16:49:45 +0800775 &bfin_mii_bus,
Michael Hennerich8cc71172008-10-13 14:45:06 +0800776 &bfin_mac_device,
777#endif
778
779#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
780 &bfin_spi0_device,
781#endif
782
783#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000784#ifdef CONFIG_SERIAL_BFIN_UART0
785 &bfin_uart0_device,
786#endif
787#ifdef CONFIG_SERIAL_BFIN_UART1
788 &bfin_uart1_device,
789#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800790#endif
791
792#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
793 &bfin_lq035q1_device,
794#endif
795
796#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang42bd8bc2009-01-07 23:14:39 +0800797#ifdef CONFIG_BFIN_SIR0
798 &bfin_sir0_device,
799#endif
800#ifdef CONFIG_BFIN_SIR1
801 &bfin_sir1_device,
802#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800803#endif
804
805#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
806 &i2c_bfin_twi_device,
807#endif
808
809#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000810#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
Michael Hennerich8cc71172008-10-13 14:45:06 +0800811 &bfin_sport0_uart_device,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000812#endif
813#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
Michael Hennerich8cc71172008-10-13 14:45:06 +0800814 &bfin_sport1_uart_device,
815#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000816#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800817
818#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
819 &bfin_device_gpiokeys,
820#endif
821
822#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
823 &ezbrd_flash_device,
824#endif
Michael Hennerich8cc71172008-10-13 14:45:06 +0800825};
826
Mike Frysinger7f6678c2009-02-04 16:49:45 +0800827static int __init ezbrd_init(void)
Michael Hennerich8cc71172008-10-13 14:45:06 +0800828{
829 printk(KERN_INFO "%s(): registering device resources\n", __func__);
Michael Hennerich8cc71172008-10-13 14:45:06 +0800830 i2c_register_board_info(0, bfin_i2c_board_info,
831 ARRAY_SIZE(bfin_i2c_board_info));
Michael Hennerich8cc71172008-10-13 14:45:06 +0800832 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
833 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
834 return 0;
835}
836
Mike Frysinger7f6678c2009-02-04 16:49:45 +0800837arch_initcall(ezbrd_init);
Michael Hennerich8cc71172008-10-13 14:45:06 +0800838
Sonic Zhangc13ce9f2009-09-23 09:37:46 +0000839static struct platform_device *ezbrd_early_devices[] __initdata = {
840#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
841#ifdef CONFIG_SERIAL_BFIN_UART0
842 &bfin_uart0_device,
843#endif
844#ifdef CONFIG_SERIAL_BFIN_UART1
845 &bfin_uart1_device,
846#endif
847#endif
848
849#if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
850#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
851 &bfin_sport0_uart_device,
852#endif
853#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
854 &bfin_sport1_uart_device,
855#endif
856#endif
857};
858
859void __init native_machine_early_platform_add_devices(void)
860{
861 printk(KERN_INFO "register early platform devices\n");
862 early_platform_add_devices(ezbrd_early_devices,
863 ARRAY_SIZE(ezbrd_early_devices));
864}
865
Michael Hennerich8cc71172008-10-13 14:45:06 +0800866void native_machine_restart(char *cmd)
867{
868 /* workaround reboot hang when booting from SPI */
869 if ((bfin_read_SYSCR() & 0x7) == 0x3)
Sonic Zhangb52dae32009-02-04 16:49:45 +0800870 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
Michael Hennerich8cc71172008-10-13 14:45:06 +0800871}
872
873void bfin_get_ether_addr(char *addr)
874{
875 /* the MAC is stored in OTP memory page 0xDF */
876 u32 ret;
877 u64 otp_mac;
878 u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
879
880 ret = otp_read(0xDF, 0x00, &otp_mac);
881 if (!(ret & 0x1)) {
882 char *otp_mac_p = (char *)&otp_mac;
883 for (ret = 0; ret < 6; ++ret)
884 addr[ret] = otp_mac_p[5 - ret];
885 }
886}
887EXPORT_SYMBOL(bfin_get_ether_addr);