blob: 7330607856e96061e9badb1ea24b712b1d1d14da [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>
Lars-Peter Clausen90590542011-11-11 11:06:38 +010011#include <linux/export.h>
Michael Hennerich9db144f2008-07-19 17:16:07 +080012#include <linux/platform_device.h>
13#include <linux/mtd/mtd.h>
14#include <linux/mtd/partitions.h>
15#include <linux/mtd/physmap.h>
16#include <linux/spi/spi.h>
17#include <linux/spi/flash.h>
18#include <linux/etherdevice.h>
Michael Hennerich9db144f2008-07-19 17:16:07 +080019#include <linux/i2c.h>
20#include <linux/irq.h>
21#include <linux/interrupt.h>
Michael Hennerich9db144f2008-07-19 17:16:07 +080022#include <linux/usb/musb.h>
Michael Hennerich9db144f2008-07-19 17:16:07 +080023#include <asm/dma.h>
24#include <asm/bfin5xx_spi.h>
25#include <asm/reboot.h>
26#include <asm/nand.h>
27#include <asm/portmux.h>
28#include <asm/dpmc.h>
29#include <linux/spi/ad7877.h>
30
31/*
32 * Name the Board for the /proc/cpuinfo
33 */
34const char bfin_board_name[] = "Bluetechnix CM-BF527";
35
36/*
37 * Driver needs to know address, irq and flag pin.
38 */
39
Michael Hennerich9db144f2008-07-19 17:16:07 +080040#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
Michael Hennerich3f375692008-11-18 17:48:22 +080041#include <linux/usb/isp1760.h>
42static struct resource bfin_isp1760_resources[] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +080043 [0] = {
Michael Hennerich3f375692008-11-18 17:48:22 +080044 .start = 0x203C0000,
45 .end = 0x203C0000 + 0x000fffff,
Michael Hennerich9db144f2008-07-19 17:16:07 +080046 .flags = IORESOURCE_MEM,
47 },
48 [1] = {
Michael Hennerich3f375692008-11-18 17:48:22 +080049 .start = IRQ_PF7,
50 .end = IRQ_PF7,
Michael Hennerich9db144f2008-07-19 17:16:07 +080051 .flags = IORESOURCE_IRQ,
52 },
53};
54
Michael Hennerich3f375692008-11-18 17:48:22 +080055static struct isp1760_platform_data isp1760_priv = {
56 .is_isp1761 = 0,
Michael Hennerich3f375692008-11-18 17:48:22 +080057 .bus_width_16 = 1,
58 .port1_otg = 0,
59 .analog_oc = 0,
60 .dack_polarity_high = 0,
61 .dreq_polarity_high = 0,
62};
63
64static struct platform_device bfin_isp1760_device = {
Michael Hennerichc6feb7682009-10-15 10:37:33 +000065 .name = "isp1760",
Michael Hennerich9db144f2008-07-19 17:16:07 +080066 .id = 0,
Michael Hennerich3f375692008-11-18 17:48:22 +080067 .dev = {
68 .platform_data = &isp1760_priv,
69 },
70 .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
71 .resource = bfin_isp1760_resources,
Michael Hennerich9db144f2008-07-19 17:16:07 +080072};
Michael Hennerich9db144f2008-07-19 17:16:07 +080073#endif
74
75#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
76static struct resource musb_resources[] = {
77 [0] = {
78 .start = 0xffc03800,
79 .end = 0xffc03cff,
80 .flags = IORESOURCE_MEM,
81 },
82 [1] = { /* general IRQ */
83 .start = IRQ_USB_INT0,
84 .end = IRQ_USB_INT0,
85 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
Hema Kalliguddifcf173e2010-09-29 11:26:39 -050086 .name = "mc"
Michael Hennerich9db144f2008-07-19 17:16:07 +080087 },
88 [2] = { /* DMA IRQ */
89 .start = IRQ_USB_DMA,
90 .end = IRQ_USB_DMA,
91 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
Hema Kalliguddifcf173e2010-09-29 11:26:39 -050092 .name = "dma"
Michael Hennerich9db144f2008-07-19 17:16:07 +080093 },
94};
95
Bryan Wu50041ac2008-10-08 13:39:40 +080096static struct musb_hdrc_config musb_config = {
97 .multipoint = 0,
98 .dyn_fifo = 0,
99 .soft_con = 1,
100 .dma = 1,
Bryan Wufea05da2009-01-07 23:14:39 +0800101 .num_eps = 8,
102 .dma_channels = 8,
Bryan Wu50041ac2008-10-08 13:39:40 +0800103 .gpio_vrsel = GPIO_PF11,
Cliff Cai85eb0e42010-01-22 04:02:46 +0000104 /* Some custom boards need to be active low, just set it to "0"
105 * if it is the case.
106 */
107 .gpio_vrsel_active = 1,
Bob Liu759a3f32010-09-17 11:09:57 +0000108 .clkin = 24, /* musb CLKIN in MHZ */
Bryan Wu50041ac2008-10-08 13:39:40 +0800109};
110
Michael Hennerich9db144f2008-07-19 17:16:07 +0800111static struct musb_hdrc_platform_data musb_plat = {
112#if defined(CONFIG_USB_MUSB_OTG)
113 .mode = MUSB_OTG,
114#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
115 .mode = MUSB_HOST,
116#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
117 .mode = MUSB_PERIPHERAL,
118#endif
Bryan Wu50041ac2008-10-08 13:39:40 +0800119 .config = &musb_config,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800120};
121
122static u64 musb_dmamask = ~(u32)0;
123
124static struct platform_device musb_device = {
Felipe Balbi9cb03082010-12-02 09:21:05 +0200125 .name = "musb-blackfin",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800126 .id = 0,
127 .dev = {
128 .dma_mask = &musb_dmamask,
129 .coherent_dma_mask = 0xffffffff,
130 .platform_data = &musb_plat,
131 },
132 .num_resources = ARRAY_SIZE(musb_resources),
133 .resource = musb_resources,
134};
135#endif
136
Michael Hennerich9db144f2008-07-19 17:16:07 +0800137#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
138static struct mtd_partition partition_info[] = {
139 {
Robin Getzaa582972008-08-05 17:47:29 +0800140 .name = "linux kernel(nand)",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800141 .offset = 0,
Mike Frysingerf4585a02008-10-13 14:45:21 +0800142 .size = 4 * 1024 * 1024,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800143 },
144 {
Robin Getzaa582972008-08-05 17:47:29 +0800145 .name = "file system(nand)",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800146 .offset = MTDPART_OFS_APPEND,
147 .size = MTDPART_SIZ_FULL,
148 },
149};
150
151static struct bf5xx_nand_platform bf5xx_nand_platform = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800152 .data_width = NFC_NWIDTH_8,
153 .partitions = partition_info,
154 .nr_partitions = ARRAY_SIZE(partition_info),
155 .rd_dly = 3,
156 .wr_dly = 3,
157};
158
159static struct resource bf5xx_nand_resources[] = {
160 {
161 .start = NFC_CTL,
162 .end = NFC_DATA_RD + 2,
163 .flags = IORESOURCE_MEM,
164 },
165 {
166 .start = CH_NFC,
167 .end = CH_NFC,
168 .flags = IORESOURCE_IRQ,
169 },
170};
171
172static struct platform_device bf5xx_nand_device = {
173 .name = "bf5xx-nand",
174 .id = 0,
175 .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
176 .resource = bf5xx_nand_resources,
177 .dev = {
178 .platform_data = &bf5xx_nand_platform,
179 },
180};
181#endif
182
183#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
184static struct resource bfin_pcmcia_cf_resources[] = {
185 {
186 .start = 0x20310000, /* IO PORT */
187 .end = 0x20312000,
188 .flags = IORESOURCE_MEM,
189 }, {
190 .start = 0x20311000, /* Attribute Memory */
191 .end = 0x20311FFF,
192 .flags = IORESOURCE_MEM,
193 }, {
194 .start = IRQ_PF4,
195 .end = IRQ_PF4,
196 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
197 }, {
198 .start = 6, /* Card Detect PF6 */
199 .end = 6,
200 .flags = IORESOURCE_IRQ,
201 },
202};
203
204static struct platform_device bfin_pcmcia_cf_device = {
205 .name = "bfin_cf_pcmcia",
206 .id = -1,
207 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
208 .resource = bfin_pcmcia_cf_resources,
209};
210#endif
211
212#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
213static struct platform_device rtc_device = {
214 .name = "rtc-bfin",
215 .id = -1,
216};
217#endif
218
219#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
Michael Hennerich61f09b52009-07-24 08:48:31 +0000220#include <linux/smc91x.h>
221
222static struct smc91x_platdata smc91x_info = {
223 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
224 .leda = RPC_LED_100_10,
225 .ledb = RPC_LED_TX_RX,
226};
227
Michael Hennerich9db144f2008-07-19 17:16:07 +0800228static struct resource smc91x_resources[] = {
229 {
230 .name = "smc91x-regs",
231 .start = 0x20300300,
232 .end = 0x20300300 + 16,
233 .flags = IORESOURCE_MEM,
234 }, {
235
236 .start = IRQ_PF7,
237 .end = IRQ_PF7,
238 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
239 },
240};
241static struct platform_device smc91x_device = {
242 .name = "smc91x",
243 .id = 0,
244 .num_resources = ARRAY_SIZE(smc91x_resources),
245 .resource = smc91x_resources,
Michael Hennerich61f09b52009-07-24 08:48:31 +0000246 .dev = {
247 .platform_data = &smc91x_info,
248 },
Michael Hennerich9db144f2008-07-19 17:16:07 +0800249};
250#endif
251
252#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
253static struct resource dm9000_resources[] = {
254 [0] = {
255 .start = 0x203FB800,
Barry Songb3dec4a2009-07-27 06:42:50 +0000256 .end = 0x203FB800 + 1,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800257 .flags = IORESOURCE_MEM,
258 },
259 [1] = {
Barry Songb3dec4a2009-07-27 06:42:50 +0000260 .start = 0x203FB804,
261 .end = 0x203FB804 + 1,
262 .flags = IORESOURCE_MEM,
263 },
264 [2] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800265 .start = IRQ_PF9,
266 .end = IRQ_PF9,
267 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
268 },
269};
270
271static struct platform_device dm9000_device = {
272 .name = "dm9000",
273 .id = -1,
274 .num_resources = ARRAY_SIZE(dm9000_resources),
275 .resource = dm9000_resources,
276};
277#endif
278
Michael Hennerich9db144f2008-07-19 17:16:07 +0800279#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
Sonic Zhang02460d02010-06-11 10:44:22 +0000280#include <linux/bfin_mac.h>
281static const unsigned short bfin_mac_peripherals[] = P_RMII0;
282
283static struct bfin_phydev_platform_data bfin_phydev_data[] = {
284 {
285 .addr = 1,
286 .irq = IRQ_MAC_PHYINT,
287 },
288};
289
290static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
291 .phydev_number = 1,
292 .phydev_data = bfin_phydev_data,
293 .phy_mode = PHY_INTERFACE_MODE_RMII,
294 .mac_peripherals = bfin_mac_peripherals,
295};
296
Graf Yang65319622009-02-04 16:49:45 +0800297static struct platform_device bfin_mii_bus = {
298 .name = "bfin_mii_bus",
Sonic Zhang02460d02010-06-11 10:44:22 +0000299 .dev = {
300 .platform_data = &bfin_mii_bus_data,
301 }
Graf Yang65319622009-02-04 16:49:45 +0800302};
303
Michael Hennerich9db144f2008-07-19 17:16:07 +0800304static struct platform_device bfin_mac_device = {
305 .name = "bfin_mac",
Sonic Zhang02460d02010-06-11 10:44:22 +0000306 .dev = {
307 .platform_data = &bfin_mii_bus,
308 }
Michael Hennerich9db144f2008-07-19 17:16:07 +0800309};
310#endif
311
312#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
313static struct resource net2272_bfin_resources[] = {
314 {
315 .start = 0x20300000,
316 .end = 0x20300000 + 0x100,
317 .flags = IORESOURCE_MEM,
318 }, {
319 .start = IRQ_PF7,
320 .end = IRQ_PF7,
321 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
322 },
323};
324
325static struct platform_device net2272_bfin_device = {
326 .name = "net2272",
327 .id = -1,
328 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
329 .resource = net2272_bfin_resources,
330};
331#endif
332
333#if defined(CONFIG_MTD_M25P80) \
334 || defined(CONFIG_MTD_M25P80_MODULE)
335static struct mtd_partition bfin_spi_flash_partitions[] = {
336 {
Robin Getzaa582972008-08-05 17:47:29 +0800337 .name = "bootloader(spi)",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800338 .size = 0x00040000,
339 .offset = 0,
340 .mask_flags = MTD_CAP_ROM
341 }, {
Robin Getzaa582972008-08-05 17:47:29 +0800342 .name = "linux kernel(spi)",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800343 .size = MTDPART_SIZ_FULL,
344 .offset = MTDPART_OFS_APPEND,
345 }
346};
347
348static struct flash_platform_data bfin_spi_flash_data = {
349 .name = "m25p80",
350 .parts = bfin_spi_flash_partitions,
351 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
352 .type = "m25p16",
353};
354
355/* SPI flash chip (m25p64) */
356static struct bfin5xx_spi_chip spi_flash_chip_info = {
357 .enable_dma = 0, /* use dma transfer with this chip*/
Michael Hennerich9db144f2008-07-19 17:16:07 +0800358};
359#endif
360
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800361#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
362static struct bfin5xx_spi_chip mmc_spi_chip_info = {
363 .enable_dma = 0,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800364};
365#endif
366
Michael Hennerich9db144f2008-07-19 17:16:07 +0800367#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800368static const struct ad7877_platform_data bfin_ad7877_ts_info = {
369 .model = 7877,
370 .vref_delay_usecs = 50, /* internal, no capacitor */
371 .x_plate_ohms = 419,
372 .y_plate_ohms = 486,
373 .pressure_max = 1000,
374 .pressure_min = 0,
375 .stopacq_polarity = 1,
376 .first_conversion_delay = 3,
377 .acquisition_time = 1,
378 .averaging = 1,
379 .pen_down_acc_interval = 1,
380};
381#endif
382
Michael Hennerich9db144f2008-07-19 17:16:07 +0800383static struct spi_board_info bfin_spi_board_info[] __initdata = {
384#if defined(CONFIG_MTD_M25P80) \
385 || defined(CONFIG_MTD_M25P80_MODULE)
386 {
387 /* the modalias must be the same as spi device driver name */
388 .modalias = "m25p80", /* Name of spi_driver for this device */
389 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
390 .bus_num = 0, /* Framework bus number */
391 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
392 .platform_data = &bfin_spi_flash_data,
393 .controller_data = &spi_flash_chip_info,
394 .mode = SPI_MODE_3,
395 },
396#endif
397
Barry Song7ba80062010-01-28 09:37:21 +0000398#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
399 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800400 {
Barry Song7ba80062010-01-28 09:37:21 +0000401 .modalias = "ad183x",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800402 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
403 .bus_num = 0,
Barry Song7ba80062010-01-28 09:37:21 +0000404 .chip_select = 4,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800405 },
406#endif
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800407#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800408 {
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800409 .modalias = "mmc_spi",
410 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
Michael Hennerich9db144f2008-07-19 17:16:07 +0800411 .bus_num = 0,
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800412 .chip_select = 5,
413 .controller_data = &mmc_spi_chip_info,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800414 .mode = SPI_MODE_3,
415 },
416#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800417#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
418 {
419 .modalias = "ad7877",
420 .platform_data = &bfin_ad7877_ts_info,
421 .irq = IRQ_PF8,
422 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
423 .bus_num = 0,
424 .chip_select = 2,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800425 },
426#endif
427#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
428 && defined(CONFIG_SND_SOC_WM8731_SPI)
429 {
430 .modalias = "wm8731",
431 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
432 .bus_num = 0,
433 .chip_select = 5,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800434 .mode = SPI_MODE_0,
435 },
436#endif
437#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
438 {
439 .modalias = "spidev",
440 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
441 .bus_num = 0,
442 .chip_select = 1,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800443 },
444#endif
445};
446
Sonic Zhang7d157fb2011-11-07 18:40:10 +0800447#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800448/* SPI controller data */
449static struct bfin5xx_spi_master bfin_spi0_info = {
450 .num_chipselect = 8,
451 .enable_dma = 1, /* master has the ability to do dma transfer */
452 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
453};
454
455/* SPI (0) */
456static struct resource bfin_spi0_resource[] = {
457 [0] = {
458 .start = SPI0_REGBASE,
459 .end = SPI0_REGBASE + 0xFF,
460 .flags = IORESOURCE_MEM,
461 },
462 [1] = {
463 .start = CH_SPI,
464 .end = CH_SPI,
Yi Li53122692009-06-05 12:11:11 +0000465 .flags = IORESOURCE_DMA,
466 },
467 [2] = {
468 .start = IRQ_SPI,
469 .end = IRQ_SPI,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800470 .flags = IORESOURCE_IRQ,
471 },
472};
473
474static struct platform_device bfin_spi0_device = {
475 .name = "bfin-spi",
476 .id = 0, /* Bus number */
477 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
478 .resource = bfin_spi0_resource,
479 .dev = {
480 .platform_data = &bfin_spi0_info, /* Passed to driver */
481 },
482};
483#endif /* spi master and devices */
484
Harald Krapfenbauer9c214532009-09-10 15:30:03 +0000485#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
486static struct mtd_partition cm_partitions[] = {
487 {
488 .name = "bootloader(nor)",
489 .size = 0x40000,
490 .offset = 0,
491 }, {
492 .name = "linux kernel(nor)",
493 .size = 0x100000,
494 .offset = MTDPART_OFS_APPEND,
495 }, {
496 .name = "file system(nor)",
497 .size = MTDPART_SIZ_FULL,
498 .offset = MTDPART_OFS_APPEND,
499 }
500};
501
502static struct physmap_flash_data cm_flash_data = {
503 .width = 2,
504 .parts = cm_partitions,
505 .nr_parts = ARRAY_SIZE(cm_partitions),
506};
507
508static unsigned cm_flash_gpios[] = { GPIO_PH9, GPIO_PG11 };
509
510static struct resource cm_flash_resource[] = {
511 {
512 .name = "cfi_probe",
513 .start = 0x20000000,
514 .end = 0x201fffff,
515 .flags = IORESOURCE_MEM,
516 }, {
517 .start = (unsigned long)cm_flash_gpios,
518 .end = ARRAY_SIZE(cm_flash_gpios),
519 .flags = IORESOURCE_IRQ,
520 }
521};
522
523static struct platform_device cm_flash_device = {
524 .name = "gpio-addr-flash",
525 .id = 0,
526 .dev = {
527 .platform_data = &cm_flash_data,
528 },
529 .num_resources = ARRAY_SIZE(cm_flash_resource),
530 .resource = cm_flash_resource,
531};
532#endif
533
Michael Hennerich9db144f2008-07-19 17:16:07 +0800534#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800535#ifdef CONFIG_SERIAL_BFIN_UART0
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000536static struct resource bfin_uart0_resources[] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800537 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000538 .start = UART0_THR,
539 .end = UART0_GCTL+2,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800540 .flags = IORESOURCE_MEM,
541 },
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000542 {
Sonic Zhangedb0a642011-08-01 17:53:21 +0800543 .start = IRQ_UART0_TX,
544 .end = IRQ_UART0_TX,
545 .flags = IORESOURCE_IRQ,
546 },
547 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000548 .start = IRQ_UART0_RX,
Sonic Zhangedb0a642011-08-01 17:53:21 +0800549 .end = IRQ_UART0_RX,
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000550 .flags = IORESOURCE_IRQ,
551 },
552 {
553 .start = IRQ_UART0_ERROR,
554 .end = IRQ_UART0_ERROR,
555 .flags = IORESOURCE_IRQ,
556 },
557 {
558 .start = CH_UART0_TX,
559 .end = CH_UART0_TX,
560 .flags = IORESOURCE_DMA,
561 },
562 {
563 .start = CH_UART0_RX,
564 .end = CH_UART0_RX,
565 .flags = IORESOURCE_DMA,
566 },
567};
568
Mike Frysingera8b19882010-11-24 09:23:04 +0000569static unsigned short bfin_uart0_peripherals[] = {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000570 P_UART0_TX, P_UART0_RX, 0
571};
572
573static struct platform_device bfin_uart0_device = {
574 .name = "bfin-uart",
575 .id = 0,
576 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
577 .resource = bfin_uart0_resources,
578 .dev = {
579 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
580 },
581};
Michael Hennerich9db144f2008-07-19 17:16:07 +0800582#endif
583#ifdef CONFIG_SERIAL_BFIN_UART1
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000584static struct resource bfin_uart1_resources[] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800585 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000586 .start = UART1_THR,
587 .end = UART1_GCTL+2,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800588 .flags = IORESOURCE_MEM,
589 },
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000590 {
Sonic Zhangedb0a642011-08-01 17:53:21 +0800591 .start = IRQ_UART1_TX,
592 .end = IRQ_UART1_TX,
593 .flags = IORESOURCE_IRQ,
594 },
595 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000596 .start = IRQ_UART1_RX,
Sonic Zhangedb0a642011-08-01 17:53:21 +0800597 .end = IRQ_UART1_RX,
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000598 .flags = IORESOURCE_IRQ,
599 },
600 {
601 .start = IRQ_UART1_ERROR,
602 .end = IRQ_UART1_ERROR,
603 .flags = IORESOURCE_IRQ,
604 },
605 {
606 .start = CH_UART1_TX,
607 .end = CH_UART1_TX,
608 .flags = IORESOURCE_DMA,
609 },
610 {
611 .start = CH_UART1_RX,
612 .end = CH_UART1_RX,
613 .flags = IORESOURCE_DMA,
614 },
615#ifdef CONFIG_BFIN_UART1_CTSRTS
616 { /* CTS pin */
617 .start = GPIO_PF9,
618 .end = GPIO_PF9,
619 .flags = IORESOURCE_IO,
620 },
621 { /* RTS pin */
622 .start = GPIO_PF10,
623 .end = GPIO_PF10,
624 .flags = IORESOURCE_IO,
625 },
Michael Hennerich9db144f2008-07-19 17:16:07 +0800626#endif
627};
628
Mike Frysingera8b19882010-11-24 09:23:04 +0000629static unsigned short bfin_uart1_peripherals[] = {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000630 P_UART1_TX, P_UART1_RX, 0
631};
632
633static struct platform_device bfin_uart1_device = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800634 .name = "bfin-uart",
635 .id = 1,
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000636 .num_resources = ARRAY_SIZE(bfin_uart1_resources),
637 .resource = bfin_uart1_resources,
638 .dev = {
639 .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
640 },
Michael Hennerich9db144f2008-07-19 17:16:07 +0800641};
642#endif
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000643#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800644
645#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800646#ifdef CONFIG_BFIN_SIR0
Graf Yang42bd8bc2009-01-07 23:14:39 +0800647static struct resource bfin_sir0_resources[] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800648 {
649 .start = 0xFFC00400,
650 .end = 0xFFC004FF,
651 .flags = IORESOURCE_MEM,
652 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800653 {
654 .start = IRQ_UART0_RX,
655 .end = IRQ_UART0_RX+1,
656 .flags = IORESOURCE_IRQ,
657 },
658 {
659 .start = CH_UART0_RX,
660 .end = CH_UART0_RX+1,
661 .flags = IORESOURCE_DMA,
662 },
663};
664
665static struct platform_device bfin_sir0_device = {
666 .name = "bfin_sir",
667 .id = 0,
668 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
669 .resource = bfin_sir0_resources,
670};
Michael Hennerich9db144f2008-07-19 17:16:07 +0800671#endif
672#ifdef CONFIG_BFIN_SIR1
Graf Yang42bd8bc2009-01-07 23:14:39 +0800673static struct resource bfin_sir1_resources[] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800674 {
675 .start = 0xFFC02000,
676 .end = 0xFFC020FF,
677 .flags = IORESOURCE_MEM,
678 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800679 {
680 .start = IRQ_UART1_RX,
681 .end = IRQ_UART1_RX+1,
682 .flags = IORESOURCE_IRQ,
683 },
684 {
685 .start = CH_UART1_RX,
686 .end = CH_UART1_RX+1,
687 .flags = IORESOURCE_DMA,
688 },
Michael Hennerich9db144f2008-07-19 17:16:07 +0800689};
690
Graf Yang42bd8bc2009-01-07 23:14:39 +0800691static struct platform_device bfin_sir1_device = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800692 .name = "bfin_sir",
Graf Yang42bd8bc2009-01-07 23:14:39 +0800693 .id = 1,
694 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
695 .resource = bfin_sir1_resources,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800696};
697#endif
Graf Yang42bd8bc2009-01-07 23:14:39 +0800698#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800699
700#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
701static struct resource bfin_twi0_resource[] = {
702 [0] = {
703 .start = TWI0_REGBASE,
704 .end = TWI0_REGBASE,
705 .flags = IORESOURCE_MEM,
706 },
707 [1] = {
708 .start = IRQ_TWI,
709 .end = IRQ_TWI,
710 .flags = IORESOURCE_IRQ,
711 },
712};
713
714static struct platform_device i2c_bfin_twi_device = {
715 .name = "i2c-bfin-twi",
716 .id = 0,
717 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
718 .resource = bfin_twi0_resource,
719};
720#endif
721
Michael Hennerich9db144f2008-07-19 17:16:07 +0800722static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
Michael Hennerichebd58332009-07-02 11:00:38 +0000723#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800724 {
725 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
Michael Hennerich9db144f2008-07-19 17:16:07 +0800726 },
727#endif
Michael Hennerich204844e2009-06-30 14:57:22 +0000728#if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800729 {
730 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
Michael Hennerich9db144f2008-07-19 17:16:07 +0800731 .irq = IRQ_PF8,
732 },
733#endif
Michael Hennerich50c4c082009-09-22 13:10:09 +0000734#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
735 {
736 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
737 },
738#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800739};
Michael Hennerich9db144f2008-07-19 17:16:07 +0800740
741#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000742#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
743static struct resource bfin_sport0_uart_resources[] = {
744 {
745 .start = SPORT0_TCR1,
746 .end = SPORT0_MRCS3+4,
747 .flags = IORESOURCE_MEM,
748 },
749 {
750 .start = IRQ_SPORT0_RX,
751 .end = IRQ_SPORT0_RX+1,
752 .flags = IORESOURCE_IRQ,
753 },
754 {
755 .start = IRQ_SPORT0_ERROR,
756 .end = IRQ_SPORT0_ERROR,
757 .flags = IORESOURCE_IRQ,
758 },
759};
760
Mike Frysingera8b19882010-11-24 09:23:04 +0000761static unsigned short bfin_sport0_peripherals[] = {
Sonic Zhangdf5de262009-09-23 05:01:56 +0000762 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
Sonic Zhange54b6732010-11-12 02:45:38 +0000763 P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
Sonic Zhangdf5de262009-09-23 05:01:56 +0000764};
765
Michael Hennerich9db144f2008-07-19 17:16:07 +0800766static struct platform_device bfin_sport0_uart_device = {
767 .name = "bfin-sport-uart",
768 .id = 0,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000769 .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
770 .resource = bfin_sport0_uart_resources,
771 .dev = {
772 .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
773 },
774};
775#endif
776#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
777static struct resource bfin_sport1_uart_resources[] = {
778 {
779 .start = SPORT1_TCR1,
780 .end = SPORT1_MRCS3+4,
781 .flags = IORESOURCE_MEM,
782 },
783 {
784 .start = IRQ_SPORT1_RX,
785 .end = IRQ_SPORT1_RX+1,
786 .flags = IORESOURCE_IRQ,
787 },
788 {
789 .start = IRQ_SPORT1_ERROR,
790 .end = IRQ_SPORT1_ERROR,
791 .flags = IORESOURCE_IRQ,
792 },
793};
794
Mike Frysingera8b19882010-11-24 09:23:04 +0000795static unsigned short bfin_sport1_peripherals[] = {
Sonic Zhangdf5de262009-09-23 05:01:56 +0000796 P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
Sonic Zhange54b6732010-11-12 02:45:38 +0000797 P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
Michael Hennerich9db144f2008-07-19 17:16:07 +0800798};
799
800static struct platform_device bfin_sport1_uart_device = {
801 .name = "bfin-sport-uart",
802 .id = 1,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000803 .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
804 .resource = bfin_sport1_uart_resources,
805 .dev = {
806 .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
807 },
Michael Hennerich9db144f2008-07-19 17:16:07 +0800808};
809#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000810#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800811
Michael Hennerich9db144f2008-07-19 17:16:07 +0800812#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
813#include <linux/input.h>
814#include <linux/gpio_keys.h>
815
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
Sonic Zhang7d157fb2011-11-07 18:40:10 +0800896#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800897 &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);