blob: c13065b895f26bdfe3aa1c3572464ee8813a4650 [file] [log] [blame]
Michael Hennerich9db144f2008-07-19 17:16:07 +08001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * Copyright 2004-2009 Analog Devices Inc.
3 * 2008-2009 Bluetechnix
4 * 2005 National ICT Australia (NICTA)
5 * Aidan Williams <aidan@nicta.com.au>
Michael Hennerich9db144f2008-07-19 17:16:07 +08006 *
Robin Getz96f10502009-09-24 14:11:24 +00007 * Licensed under the GPL-2 or later.
Michael Hennerich9db144f2008-07-19 17:16:07 +08008 */
9
10#include <linux/device.h>
11#include <linux/platform_device.h>
12#include <linux/mtd/mtd.h>
13#include <linux/mtd/partitions.h>
14#include <linux/mtd/physmap.h>
15#include <linux/spi/spi.h>
16#include <linux/spi/flash.h>
17#include <linux/etherdevice.h>
Michael Hennerich9db144f2008-07-19 17:16:07 +080018#include <linux/i2c.h>
19#include <linux/irq.h>
20#include <linux/interrupt.h>
Michael Hennerich9db144f2008-07-19 17:16:07 +080021#include <linux/usb/musb.h>
Michael Hennerich9db144f2008-07-19 17:16:07 +080022#include <asm/dma.h>
23#include <asm/bfin5xx_spi.h>
24#include <asm/reboot.h>
25#include <asm/nand.h>
26#include <asm/portmux.h>
27#include <asm/dpmc.h>
28#include <linux/spi/ad7877.h>
29
30/*
31 * Name the Board for the /proc/cpuinfo
32 */
33const char bfin_board_name[] = "Bluetechnix CM-BF527";
34
35/*
36 * Driver needs to know address, irq and flag pin.
37 */
38
Michael Hennerich9db144f2008-07-19 17:16:07 +080039#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
Michael Hennerich3f375692008-11-18 17:48:22 +080040#include <linux/usb/isp1760.h>
41static struct resource bfin_isp1760_resources[] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +080042 [0] = {
Michael Hennerich3f375692008-11-18 17:48:22 +080043 .start = 0x203C0000,
44 .end = 0x203C0000 + 0x000fffff,
Michael Hennerich9db144f2008-07-19 17:16:07 +080045 .flags = IORESOURCE_MEM,
46 },
47 [1] = {
Michael Hennerich3f375692008-11-18 17:48:22 +080048 .start = IRQ_PF7,
49 .end = IRQ_PF7,
Michael Hennerich9db144f2008-07-19 17:16:07 +080050 .flags = IORESOURCE_IRQ,
51 },
52};
53
Michael Hennerich3f375692008-11-18 17:48:22 +080054static struct isp1760_platform_data isp1760_priv = {
55 .is_isp1761 = 0,
Michael Hennerich3f375692008-11-18 17:48:22 +080056 .bus_width_16 = 1,
57 .port1_otg = 0,
58 .analog_oc = 0,
59 .dack_polarity_high = 0,
60 .dreq_polarity_high = 0,
61};
62
63static struct platform_device bfin_isp1760_device = {
Michael Hennerichc6feb7682009-10-15 10:37:33 +000064 .name = "isp1760",
Michael Hennerich9db144f2008-07-19 17:16:07 +080065 .id = 0,
Michael Hennerich3f375692008-11-18 17:48:22 +080066 .dev = {
67 .platform_data = &isp1760_priv,
68 },
69 .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
70 .resource = bfin_isp1760_resources,
Michael Hennerich9db144f2008-07-19 17:16:07 +080071};
Michael Hennerich9db144f2008-07-19 17:16:07 +080072#endif
73
74#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
75static struct resource musb_resources[] = {
76 [0] = {
77 .start = 0xffc03800,
78 .end = 0xffc03cff,
79 .flags = IORESOURCE_MEM,
80 },
81 [1] = { /* general IRQ */
82 .start = IRQ_USB_INT0,
83 .end = IRQ_USB_INT0,
84 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
Hema Kalliguddifcf173e2010-09-29 11:26:39 -050085 .name = "mc"
Michael Hennerich9db144f2008-07-19 17:16:07 +080086 },
87 [2] = { /* DMA IRQ */
88 .start = IRQ_USB_DMA,
89 .end = IRQ_USB_DMA,
90 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
Hema Kalliguddifcf173e2010-09-29 11:26:39 -050091 .name = "dma"
Michael Hennerich9db144f2008-07-19 17:16:07 +080092 },
93};
94
Bryan Wu50041ac2008-10-08 13:39:40 +080095static struct musb_hdrc_config musb_config = {
96 .multipoint = 0,
97 .dyn_fifo = 0,
98 .soft_con = 1,
99 .dma = 1,
Bryan Wufea05da2009-01-07 23:14:39 +0800100 .num_eps = 8,
101 .dma_channels = 8,
Bryan Wu50041ac2008-10-08 13:39:40 +0800102 .gpio_vrsel = GPIO_PF11,
Cliff Cai85eb0e42010-01-22 04:02:46 +0000103 /* Some custom boards need to be active low, just set it to "0"
104 * if it is the case.
105 */
106 .gpio_vrsel_active = 1,
Bob Liu759a3f32010-09-17 11:09:57 +0000107 .clkin = 24, /* musb CLKIN in MHZ */
Bryan Wu50041ac2008-10-08 13:39:40 +0800108};
109
Michael Hennerich9db144f2008-07-19 17:16:07 +0800110static struct musb_hdrc_platform_data musb_plat = {
111#if defined(CONFIG_USB_MUSB_OTG)
112 .mode = MUSB_OTG,
113#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
114 .mode = MUSB_HOST,
115#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
116 .mode = MUSB_PERIPHERAL,
117#endif
Bryan Wu50041ac2008-10-08 13:39:40 +0800118 .config = &musb_config,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800119};
120
121static u64 musb_dmamask = ~(u32)0;
122
123static struct platform_device musb_device = {
Felipe Balbi9cb03082010-12-02 09:21:05 +0200124 .name = "musb-blackfin",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800125 .id = 0,
126 .dev = {
127 .dma_mask = &musb_dmamask,
128 .coherent_dma_mask = 0xffffffff,
129 .platform_data = &musb_plat,
130 },
131 .num_resources = ARRAY_SIZE(musb_resources),
132 .resource = musb_resources,
133};
134#endif
135
Michael Hennerich9db144f2008-07-19 17:16:07 +0800136#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
137static struct mtd_partition partition_info[] = {
138 {
Robin Getzaa582972008-08-05 17:47:29 +0800139 .name = "linux kernel(nand)",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800140 .offset = 0,
Mike Frysingerf4585a02008-10-13 14:45:21 +0800141 .size = 4 * 1024 * 1024,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800142 },
143 {
Robin Getzaa582972008-08-05 17:47:29 +0800144 .name = "file system(nand)",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800145 .offset = MTDPART_OFS_APPEND,
146 .size = MTDPART_SIZ_FULL,
147 },
148};
149
150static struct bf5xx_nand_platform bf5xx_nand_platform = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800151 .data_width = NFC_NWIDTH_8,
152 .partitions = partition_info,
153 .nr_partitions = ARRAY_SIZE(partition_info),
154 .rd_dly = 3,
155 .wr_dly = 3,
156};
157
158static struct resource bf5xx_nand_resources[] = {
159 {
160 .start = NFC_CTL,
161 .end = NFC_DATA_RD + 2,
162 .flags = IORESOURCE_MEM,
163 },
164 {
165 .start = CH_NFC,
166 .end = CH_NFC,
167 .flags = IORESOURCE_IRQ,
168 },
169};
170
171static struct platform_device bf5xx_nand_device = {
172 .name = "bf5xx-nand",
173 .id = 0,
174 .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
175 .resource = bf5xx_nand_resources,
176 .dev = {
177 .platform_data = &bf5xx_nand_platform,
178 },
179};
180#endif
181
182#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
183static struct resource bfin_pcmcia_cf_resources[] = {
184 {
185 .start = 0x20310000, /* IO PORT */
186 .end = 0x20312000,
187 .flags = IORESOURCE_MEM,
188 }, {
189 .start = 0x20311000, /* Attribute Memory */
190 .end = 0x20311FFF,
191 .flags = IORESOURCE_MEM,
192 }, {
193 .start = IRQ_PF4,
194 .end = IRQ_PF4,
195 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
196 }, {
197 .start = 6, /* Card Detect PF6 */
198 .end = 6,
199 .flags = IORESOURCE_IRQ,
200 },
201};
202
203static struct platform_device bfin_pcmcia_cf_device = {
204 .name = "bfin_cf_pcmcia",
205 .id = -1,
206 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
207 .resource = bfin_pcmcia_cf_resources,
208};
209#endif
210
211#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
212static struct platform_device rtc_device = {
213 .name = "rtc-bfin",
214 .id = -1,
215};
216#endif
217
218#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
Michael Hennerich61f09b52009-07-24 08:48:31 +0000219#include <linux/smc91x.h>
220
221static struct smc91x_platdata smc91x_info = {
222 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
223 .leda = RPC_LED_100_10,
224 .ledb = RPC_LED_TX_RX,
225};
226
Michael Hennerich9db144f2008-07-19 17:16:07 +0800227static struct resource smc91x_resources[] = {
228 {
229 .name = "smc91x-regs",
230 .start = 0x20300300,
231 .end = 0x20300300 + 16,
232 .flags = IORESOURCE_MEM,
233 }, {
234
235 .start = IRQ_PF7,
236 .end = IRQ_PF7,
237 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
238 },
239};
240static struct platform_device smc91x_device = {
241 .name = "smc91x",
242 .id = 0,
243 .num_resources = ARRAY_SIZE(smc91x_resources),
244 .resource = smc91x_resources,
Michael Hennerich61f09b52009-07-24 08:48:31 +0000245 .dev = {
246 .platform_data = &smc91x_info,
247 },
Michael Hennerich9db144f2008-07-19 17:16:07 +0800248};
249#endif
250
251#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
252static struct resource dm9000_resources[] = {
253 [0] = {
254 .start = 0x203FB800,
Barry Songb3dec4a2009-07-27 06:42:50 +0000255 .end = 0x203FB800 + 1,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800256 .flags = IORESOURCE_MEM,
257 },
258 [1] = {
Barry Songb3dec4a2009-07-27 06:42:50 +0000259 .start = 0x203FB804,
260 .end = 0x203FB804 + 1,
261 .flags = IORESOURCE_MEM,
262 },
263 [2] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800264 .start = IRQ_PF9,
265 .end = IRQ_PF9,
266 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
267 },
268};
269
270static struct platform_device dm9000_device = {
271 .name = "dm9000",
272 .id = -1,
273 .num_resources = ARRAY_SIZE(dm9000_resources),
274 .resource = dm9000_resources,
275};
276#endif
277
Michael Hennerich9db144f2008-07-19 17:16:07 +0800278#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
Sonic Zhang02460d02010-06-11 10:44:22 +0000279#include <linux/bfin_mac.h>
280static const unsigned short bfin_mac_peripherals[] = P_RMII0;
281
282static struct bfin_phydev_platform_data bfin_phydev_data[] = {
283 {
284 .addr = 1,
285 .irq = IRQ_MAC_PHYINT,
286 },
287};
288
289static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
290 .phydev_number = 1,
291 .phydev_data = bfin_phydev_data,
292 .phy_mode = PHY_INTERFACE_MODE_RMII,
293 .mac_peripherals = bfin_mac_peripherals,
294};
295
Graf Yang65319622009-02-04 16:49:45 +0800296static struct platform_device bfin_mii_bus = {
297 .name = "bfin_mii_bus",
Sonic Zhang02460d02010-06-11 10:44:22 +0000298 .dev = {
299 .platform_data = &bfin_mii_bus_data,
300 }
Graf Yang65319622009-02-04 16:49:45 +0800301};
302
Michael Hennerich9db144f2008-07-19 17:16:07 +0800303static struct platform_device bfin_mac_device = {
304 .name = "bfin_mac",
Sonic Zhang02460d02010-06-11 10:44:22 +0000305 .dev = {
306 .platform_data = &bfin_mii_bus,
307 }
Michael Hennerich9db144f2008-07-19 17:16:07 +0800308};
309#endif
310
311#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
312static struct resource net2272_bfin_resources[] = {
313 {
314 .start = 0x20300000,
315 .end = 0x20300000 + 0x100,
316 .flags = IORESOURCE_MEM,
317 }, {
318 .start = IRQ_PF7,
319 .end = IRQ_PF7,
320 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
321 },
322};
323
324static struct platform_device net2272_bfin_device = {
325 .name = "net2272",
326 .id = -1,
327 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
328 .resource = net2272_bfin_resources,
329};
330#endif
331
332#if defined(CONFIG_MTD_M25P80) \
333 || defined(CONFIG_MTD_M25P80_MODULE)
334static struct mtd_partition bfin_spi_flash_partitions[] = {
335 {
Robin Getzaa582972008-08-05 17:47:29 +0800336 .name = "bootloader(spi)",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800337 .size = 0x00040000,
338 .offset = 0,
339 .mask_flags = MTD_CAP_ROM
340 }, {
Robin Getzaa582972008-08-05 17:47:29 +0800341 .name = "linux kernel(spi)",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800342 .size = MTDPART_SIZ_FULL,
343 .offset = MTDPART_OFS_APPEND,
344 }
345};
346
347static struct flash_platform_data bfin_spi_flash_data = {
348 .name = "m25p80",
349 .parts = bfin_spi_flash_partitions,
350 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
351 .type = "m25p16",
352};
353
354/* SPI flash chip (m25p64) */
355static struct bfin5xx_spi_chip spi_flash_chip_info = {
356 .enable_dma = 0, /* use dma transfer with this chip*/
Michael Hennerich9db144f2008-07-19 17:16:07 +0800357};
358#endif
359
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800360#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
361static struct bfin5xx_spi_chip mmc_spi_chip_info = {
362 .enable_dma = 0,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800363};
364#endif
365
Michael Hennerich9db144f2008-07-19 17:16:07 +0800366#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800367static const struct ad7877_platform_data bfin_ad7877_ts_info = {
368 .model = 7877,
369 .vref_delay_usecs = 50, /* internal, no capacitor */
370 .x_plate_ohms = 419,
371 .y_plate_ohms = 486,
372 .pressure_max = 1000,
373 .pressure_min = 0,
374 .stopacq_polarity = 1,
375 .first_conversion_delay = 3,
376 .acquisition_time = 1,
377 .averaging = 1,
378 .pen_down_acc_interval = 1,
379};
380#endif
381
Michael Hennerich9db144f2008-07-19 17:16:07 +0800382static struct spi_board_info bfin_spi_board_info[] __initdata = {
383#if defined(CONFIG_MTD_M25P80) \
384 || defined(CONFIG_MTD_M25P80_MODULE)
385 {
386 /* the modalias must be the same as spi device driver name */
387 .modalias = "m25p80", /* Name of spi_driver for this device */
388 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
389 .bus_num = 0, /* Framework bus number */
390 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
391 .platform_data = &bfin_spi_flash_data,
392 .controller_data = &spi_flash_chip_info,
393 .mode = SPI_MODE_3,
394 },
395#endif
396
Barry Song7ba80062010-01-28 09:37:21 +0000397#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
398 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800399 {
Barry Song7ba80062010-01-28 09:37:21 +0000400 .modalias = "ad183x",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800401 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
402 .bus_num = 0,
Barry Song7ba80062010-01-28 09:37:21 +0000403 .chip_select = 4,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800404 },
405#endif
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800406#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800407 {
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800408 .modalias = "mmc_spi",
409 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
Michael Hennerich9db144f2008-07-19 17:16:07 +0800410 .bus_num = 0,
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800411 .chip_select = 5,
412 .controller_data = &mmc_spi_chip_info,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800413 .mode = SPI_MODE_3,
414 },
415#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800416#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
417 {
418 .modalias = "ad7877",
419 .platform_data = &bfin_ad7877_ts_info,
420 .irq = IRQ_PF8,
421 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
422 .bus_num = 0,
423 .chip_select = 2,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800424 },
425#endif
426#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
427 && defined(CONFIG_SND_SOC_WM8731_SPI)
428 {
429 .modalias = "wm8731",
430 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
431 .bus_num = 0,
432 .chip_select = 5,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800433 .mode = SPI_MODE_0,
434 },
435#endif
436#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
437 {
438 .modalias = "spidev",
439 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
440 .bus_num = 0,
441 .chip_select = 1,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800442 },
443#endif
444};
445
446#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
447/* SPI controller data */
448static struct bfin5xx_spi_master bfin_spi0_info = {
449 .num_chipselect = 8,
450 .enable_dma = 1, /* master has the ability to do dma transfer */
451 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
452};
453
454/* SPI (0) */
455static struct resource bfin_spi0_resource[] = {
456 [0] = {
457 .start = SPI0_REGBASE,
458 .end = SPI0_REGBASE + 0xFF,
459 .flags = IORESOURCE_MEM,
460 },
461 [1] = {
462 .start = CH_SPI,
463 .end = CH_SPI,
Yi Li53122692009-06-05 12:11:11 +0000464 .flags = IORESOURCE_DMA,
465 },
466 [2] = {
467 .start = IRQ_SPI,
468 .end = IRQ_SPI,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800469 .flags = IORESOURCE_IRQ,
470 },
471};
472
473static struct platform_device bfin_spi0_device = {
474 .name = "bfin-spi",
475 .id = 0, /* Bus number */
476 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
477 .resource = bfin_spi0_resource,
478 .dev = {
479 .platform_data = &bfin_spi0_info, /* Passed to driver */
480 },
481};
482#endif /* spi master and devices */
483
Harald Krapfenbauer9c214532009-09-10 15:30:03 +0000484#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
485static struct mtd_partition cm_partitions[] = {
486 {
487 .name = "bootloader(nor)",
488 .size = 0x40000,
489 .offset = 0,
490 }, {
491 .name = "linux kernel(nor)",
492 .size = 0x100000,
493 .offset = MTDPART_OFS_APPEND,
494 }, {
495 .name = "file system(nor)",
496 .size = MTDPART_SIZ_FULL,
497 .offset = MTDPART_OFS_APPEND,
498 }
499};
500
501static struct physmap_flash_data cm_flash_data = {
502 .width = 2,
503 .parts = cm_partitions,
504 .nr_parts = ARRAY_SIZE(cm_partitions),
505};
506
507static unsigned cm_flash_gpios[] = { GPIO_PH9, GPIO_PG11 };
508
509static struct resource cm_flash_resource[] = {
510 {
511 .name = "cfi_probe",
512 .start = 0x20000000,
513 .end = 0x201fffff,
514 .flags = IORESOURCE_MEM,
515 }, {
516 .start = (unsigned long)cm_flash_gpios,
517 .end = ARRAY_SIZE(cm_flash_gpios),
518 .flags = IORESOURCE_IRQ,
519 }
520};
521
522static struct platform_device cm_flash_device = {
523 .name = "gpio-addr-flash",
524 .id = 0,
525 .dev = {
526 .platform_data = &cm_flash_data,
527 },
528 .num_resources = ARRAY_SIZE(cm_flash_resource),
529 .resource = cm_flash_resource,
530};
531#endif
532
Michael Hennerich9db144f2008-07-19 17:16:07 +0800533#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800534#ifdef CONFIG_SERIAL_BFIN_UART0
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000535static struct resource bfin_uart0_resources[] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800536 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000537 .start = UART0_THR,
538 .end = UART0_GCTL+2,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800539 .flags = IORESOURCE_MEM,
540 },
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000541 {
Sonic Zhangedb0a642011-08-01 17:53:21 +0800542 .start = IRQ_UART0_TX,
543 .end = IRQ_UART0_TX,
544 .flags = IORESOURCE_IRQ,
545 },
546 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000547 .start = IRQ_UART0_RX,
Sonic Zhangedb0a642011-08-01 17:53:21 +0800548 .end = IRQ_UART0_RX,
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000549 .flags = IORESOURCE_IRQ,
550 },
551 {
552 .start = IRQ_UART0_ERROR,
553 .end = IRQ_UART0_ERROR,
554 .flags = IORESOURCE_IRQ,
555 },
556 {
557 .start = CH_UART0_TX,
558 .end = CH_UART0_TX,
559 .flags = IORESOURCE_DMA,
560 },
561 {
562 .start = CH_UART0_RX,
563 .end = CH_UART0_RX,
564 .flags = IORESOURCE_DMA,
565 },
566};
567
Mike Frysingera8b19882010-11-24 09:23:04 +0000568static unsigned short bfin_uart0_peripherals[] = {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000569 P_UART0_TX, P_UART0_RX, 0
570};
571
572static struct platform_device bfin_uart0_device = {
573 .name = "bfin-uart",
574 .id = 0,
575 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
576 .resource = bfin_uart0_resources,
577 .dev = {
578 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
579 },
580};
Michael Hennerich9db144f2008-07-19 17:16:07 +0800581#endif
582#ifdef CONFIG_SERIAL_BFIN_UART1
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000583static struct resource bfin_uart1_resources[] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800584 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000585 .start = UART1_THR,
586 .end = UART1_GCTL+2,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800587 .flags = IORESOURCE_MEM,
588 },
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000589 {
Sonic Zhangedb0a642011-08-01 17:53:21 +0800590 .start = IRQ_UART1_TX,
591 .end = IRQ_UART1_TX,
592 .flags = IORESOURCE_IRQ,
593 },
594 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000595 .start = IRQ_UART1_RX,
Sonic Zhangedb0a642011-08-01 17:53:21 +0800596 .end = IRQ_UART1_RX,
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000597 .flags = IORESOURCE_IRQ,
598 },
599 {
600 .start = IRQ_UART1_ERROR,
601 .end = IRQ_UART1_ERROR,
602 .flags = IORESOURCE_IRQ,
603 },
604 {
605 .start = CH_UART1_TX,
606 .end = CH_UART1_TX,
607 .flags = IORESOURCE_DMA,
608 },
609 {
610 .start = CH_UART1_RX,
611 .end = CH_UART1_RX,
612 .flags = IORESOURCE_DMA,
613 },
614#ifdef CONFIG_BFIN_UART1_CTSRTS
615 { /* CTS pin */
616 .start = GPIO_PF9,
617 .end = GPIO_PF9,
618 .flags = IORESOURCE_IO,
619 },
620 { /* RTS pin */
621 .start = GPIO_PF10,
622 .end = GPIO_PF10,
623 .flags = IORESOURCE_IO,
624 },
Michael Hennerich9db144f2008-07-19 17:16:07 +0800625#endif
626};
627
Mike Frysingera8b19882010-11-24 09:23:04 +0000628static unsigned short bfin_uart1_peripherals[] = {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000629 P_UART1_TX, P_UART1_RX, 0
630};
631
632static struct platform_device bfin_uart1_device = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800633 .name = "bfin-uart",
634 .id = 1,
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000635 .num_resources = ARRAY_SIZE(bfin_uart1_resources),
636 .resource = bfin_uart1_resources,
637 .dev = {
638 .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
639 },
Michael Hennerich9db144f2008-07-19 17:16:07 +0800640};
641#endif
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000642#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800643
644#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800645#ifdef CONFIG_BFIN_SIR0
Graf Yang42bd8bc2009-01-07 23:14:39 +0800646static struct resource bfin_sir0_resources[] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800647 {
648 .start = 0xFFC00400,
649 .end = 0xFFC004FF,
650 .flags = IORESOURCE_MEM,
651 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800652 {
653 .start = IRQ_UART0_RX,
654 .end = IRQ_UART0_RX+1,
655 .flags = IORESOURCE_IRQ,
656 },
657 {
658 .start = CH_UART0_RX,
659 .end = CH_UART0_RX+1,
660 .flags = IORESOURCE_DMA,
661 },
662};
663
664static struct platform_device bfin_sir0_device = {
665 .name = "bfin_sir",
666 .id = 0,
667 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
668 .resource = bfin_sir0_resources,
669};
Michael Hennerich9db144f2008-07-19 17:16:07 +0800670#endif
671#ifdef CONFIG_BFIN_SIR1
Graf Yang42bd8bc2009-01-07 23:14:39 +0800672static struct resource bfin_sir1_resources[] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800673 {
674 .start = 0xFFC02000,
675 .end = 0xFFC020FF,
676 .flags = IORESOURCE_MEM,
677 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800678 {
679 .start = IRQ_UART1_RX,
680 .end = IRQ_UART1_RX+1,
681 .flags = IORESOURCE_IRQ,
682 },
683 {
684 .start = CH_UART1_RX,
685 .end = CH_UART1_RX+1,
686 .flags = IORESOURCE_DMA,
687 },
Michael Hennerich9db144f2008-07-19 17:16:07 +0800688};
689
Graf Yang42bd8bc2009-01-07 23:14:39 +0800690static struct platform_device bfin_sir1_device = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800691 .name = "bfin_sir",
Graf Yang42bd8bc2009-01-07 23:14:39 +0800692 .id = 1,
693 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
694 .resource = bfin_sir1_resources,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800695};
696#endif
Graf Yang42bd8bc2009-01-07 23:14:39 +0800697#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800698
699#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
700static struct resource bfin_twi0_resource[] = {
701 [0] = {
702 .start = TWI0_REGBASE,
703 .end = TWI0_REGBASE,
704 .flags = IORESOURCE_MEM,
705 },
706 [1] = {
707 .start = IRQ_TWI,
708 .end = IRQ_TWI,
709 .flags = IORESOURCE_IRQ,
710 },
711};
712
713static struct platform_device i2c_bfin_twi_device = {
714 .name = "i2c-bfin-twi",
715 .id = 0,
716 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
717 .resource = bfin_twi0_resource,
718};
719#endif
720
Michael Hennerich9db144f2008-07-19 17:16:07 +0800721static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
Michael Hennerichebd58332009-07-02 11:00:38 +0000722#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800723 {
724 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
Michael Hennerich9db144f2008-07-19 17:16:07 +0800725 },
726#endif
Michael Hennerich204844e2009-06-30 14:57:22 +0000727#if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800728 {
729 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
Michael Hennerich9db144f2008-07-19 17:16:07 +0800730 .irq = IRQ_PF8,
731 },
732#endif
Michael Hennerich50c4c082009-09-22 13:10:09 +0000733#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
734 {
735 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
736 },
737#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800738};
Michael Hennerich9db144f2008-07-19 17:16:07 +0800739
740#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000741#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
742static struct resource bfin_sport0_uart_resources[] = {
743 {
744 .start = SPORT0_TCR1,
745 .end = SPORT0_MRCS3+4,
746 .flags = IORESOURCE_MEM,
747 },
748 {
749 .start = IRQ_SPORT0_RX,
750 .end = IRQ_SPORT0_RX+1,
751 .flags = IORESOURCE_IRQ,
752 },
753 {
754 .start = IRQ_SPORT0_ERROR,
755 .end = IRQ_SPORT0_ERROR,
756 .flags = IORESOURCE_IRQ,
757 },
758};
759
Mike Frysingera8b19882010-11-24 09:23:04 +0000760static unsigned short bfin_sport0_peripherals[] = {
Sonic Zhangdf5de262009-09-23 05:01:56 +0000761 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
Sonic Zhange54b6732010-11-12 02:45:38 +0000762 P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
Sonic Zhangdf5de262009-09-23 05:01:56 +0000763};
764
Michael Hennerich9db144f2008-07-19 17:16:07 +0800765static struct platform_device bfin_sport0_uart_device = {
766 .name = "bfin-sport-uart",
767 .id = 0,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000768 .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
769 .resource = bfin_sport0_uart_resources,
770 .dev = {
771 .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
772 },
773};
774#endif
775#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
776static struct resource bfin_sport1_uart_resources[] = {
777 {
778 .start = SPORT1_TCR1,
779 .end = SPORT1_MRCS3+4,
780 .flags = IORESOURCE_MEM,
781 },
782 {
783 .start = IRQ_SPORT1_RX,
784 .end = IRQ_SPORT1_RX+1,
785 .flags = IORESOURCE_IRQ,
786 },
787 {
788 .start = IRQ_SPORT1_ERROR,
789 .end = IRQ_SPORT1_ERROR,
790 .flags = IORESOURCE_IRQ,
791 },
792};
793
Mike Frysingera8b19882010-11-24 09:23:04 +0000794static unsigned short bfin_sport1_peripherals[] = {
Sonic Zhangdf5de262009-09-23 05:01:56 +0000795 P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
Sonic Zhange54b6732010-11-12 02:45:38 +0000796 P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
Michael Hennerich9db144f2008-07-19 17:16:07 +0800797};
798
799static struct platform_device bfin_sport1_uart_device = {
800 .name = "bfin-sport-uart",
801 .id = 1,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000802 .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
803 .resource = bfin_sport1_uart_resources,
804 .dev = {
805 .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
806 },
Michael Hennerich9db144f2008-07-19 17:16:07 +0800807};
808#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000809#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800810
Michael Hennerich9db144f2008-07-19 17:16:07 +0800811#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
812#include <linux/input.h>
813#include <linux/gpio_keys.h>
Paul Gortmaker8dc7a9c2011-08-09 11:05:22 -0400814#include <linux/export.h>
Michael Hennerich9db144f2008-07-19 17:16:07 +0800815
816static struct gpio_keys_button bfin_gpio_keys_table[] = {
817 {BTN_0, GPIO_PF14, 1, "gpio-keys: BTN0"},
818};
819
820static struct gpio_keys_platform_data bfin_gpio_keys_data = {
821 .buttons = bfin_gpio_keys_table,
822 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
823};
824
825static struct platform_device bfin_device_gpiokeys = {
826 .name = "gpio-keys",
827 .dev = {
828 .platform_data = &bfin_gpio_keys_data,
829 },
830};
831#endif
832
Michael Hennerich9db144f2008-07-19 17:16:07 +0800833static const unsigned int cclk_vlev_datasheet[] =
834{
835 VRPAIR(VLEV_100, 400000000),
836 VRPAIR(VLEV_105, 426000000),
837 VRPAIR(VLEV_110, 500000000),
838 VRPAIR(VLEV_115, 533000000),
839 VRPAIR(VLEV_120, 600000000),
840};
841
842static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
843 .tuple_tab = cclk_vlev_datasheet,
844 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
845 .vr_settling_time = 25 /* us */,
846};
847
848static struct platform_device bfin_dpmc = {
849 .name = "bfin dpmc",
850 .dev = {
851 .platform_data = &bfin_dmpc_vreg_data,
852 },
853};
854
Harald Krapfenbauer9c214532009-09-10 15:30:03 +0000855static struct platform_device *cmbf527_devices[] __initdata = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800856
857 &bfin_dpmc,
858
859#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
860 &bf5xx_nand_device,
861#endif
862
863#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
864 &bfin_pcmcia_cf_device,
865#endif
866
867#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
868 &rtc_device,
869#endif
870
Michael Hennerich3f375692008-11-18 17:48:22 +0800871#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
872 &bfin_isp1760_device,
873#endif
874
Michael Hennerich9db144f2008-07-19 17:16:07 +0800875#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
876 &musb_device,
877#endif
878
879#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
880 &smc91x_device,
881#endif
882
883#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
884 &dm9000_device,
885#endif
886
887#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
Graf Yang65319622009-02-04 16:49:45 +0800888 &bfin_mii_bus,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800889 &bfin_mac_device,
890#endif
891
892#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
893 &net2272_bfin_device,
894#endif
895
896#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
897 &bfin_spi0_device,
898#endif
899
Michael Hennerich9db144f2008-07-19 17:16:07 +0800900#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000901#ifdef CONFIG_SERIAL_BFIN_UART0
902 &bfin_uart0_device,
903#endif
904#ifdef CONFIG_SERIAL_BFIN_UART1
905 &bfin_uart1_device,
906#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800907#endif
908
909#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang42bd8bc2009-01-07 23:14:39 +0800910#ifdef CONFIG_BFIN_SIR0
911 &bfin_sir0_device,
912#endif
913#ifdef CONFIG_BFIN_SIR1
914 &bfin_sir1_device,
915#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800916#endif
917
918#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
919 &i2c_bfin_twi_device,
920#endif
921
922#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000923#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
Michael Hennerich9db144f2008-07-19 17:16:07 +0800924 &bfin_sport0_uart_device,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000925#endif
926#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
Michael Hennerich9db144f2008-07-19 17:16:07 +0800927 &bfin_sport1_uart_device,
928#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000929#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800930
Michael Hennerich9db144f2008-07-19 17:16:07 +0800931#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
932 &bfin_device_gpiokeys,
933#endif
934
Harald Krapfenbauer9c214532009-09-10 15:30:03 +0000935#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
936 &cm_flash_device,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800937#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800938};
939
Mike Frysinger7f6678c2009-02-04 16:49:45 +0800940static int __init cm_init(void)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800941{
942 printk(KERN_INFO "%s(): registering device resources\n", __func__);
Michael Hennerich9db144f2008-07-19 17:16:07 +0800943 i2c_register_board_info(0, bfin_i2c_board_info,
944 ARRAY_SIZE(bfin_i2c_board_info));
Harald Krapfenbauer9c214532009-09-10 15:30:03 +0000945 platform_add_devices(cmbf527_devices, ARRAY_SIZE(cmbf527_devices));
Michael Hennerich9db144f2008-07-19 17:16:07 +0800946 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
Michael Hennerich9db144f2008-07-19 17:16:07 +0800947 return 0;
948}
949
Mike Frysinger7f6678c2009-02-04 16:49:45 +0800950arch_initcall(cm_init);
Michael Hennerich9db144f2008-07-19 17:16:07 +0800951
Sonic Zhangc13ce9f2009-09-23 09:37:46 +0000952static struct platform_device *cmbf527_early_devices[] __initdata = {
953#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
954#ifdef CONFIG_SERIAL_BFIN_UART0
955 &bfin_uart0_device,
956#endif
957#ifdef CONFIG_SERIAL_BFIN_UART1
958 &bfin_uart1_device,
959#endif
960#endif
961
962#if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
963#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
964 &bfin_sport0_uart_device,
965#endif
966#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
967 &bfin_sport1_uart_device,
968#endif
969#endif
970};
971
972void __init native_machine_early_platform_add_devices(void)
973{
974 printk(KERN_INFO "register early platform devices\n");
975 early_platform_add_devices(cmbf527_early_devices,
976 ARRAY_SIZE(cmbf527_early_devices));
977}
978
Michael Hennerich9db144f2008-07-19 17:16:07 +0800979void native_machine_restart(char *cmd)
980{
981 /* workaround reboot hang when booting from SPI */
982 if ((bfin_read_SYSCR() & 0x7) == 0x3)
Sonic Zhangb52dae32009-02-04 16:49:45 +0800983 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
Michael Hennerich9db144f2008-07-19 17:16:07 +0800984}
985
986void bfin_get_ether_addr(char *addr)
987{
988 random_ether_addr(addr);
989 printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
990}
991EXPORT_SYMBOL(bfin_get_ether_addr);