blob: f392af641657d78f5be0294cc162c4c294c4f5d2 [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 Hennerichc6feb762009-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,
85 },
86 [2] = { /* DMA IRQ */
87 .start = IRQ_USB_DMA,
88 .end = IRQ_USB_DMA,
89 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
90 },
91};
92
Bryan Wu50041ac2008-10-08 13:39:40 +080093static struct musb_hdrc_config musb_config = {
94 .multipoint = 0,
95 .dyn_fifo = 0,
96 .soft_con = 1,
97 .dma = 1,
Bryan Wufea05da2009-01-07 23:14:39 +080098 .num_eps = 8,
99 .dma_channels = 8,
Bryan Wu50041ac2008-10-08 13:39:40 +0800100 .gpio_vrsel = GPIO_PF11,
Cliff Cai85eb0e42010-01-22 04:02:46 +0000101 /* Some custom boards need to be active low, just set it to "0"
102 * if it is the case.
103 */
104 .gpio_vrsel_active = 1,
Bryan Wu50041ac2008-10-08 13:39:40 +0800105};
106
Michael Hennerich9db144f2008-07-19 17:16:07 +0800107static struct musb_hdrc_platform_data musb_plat = {
108#if defined(CONFIG_USB_MUSB_OTG)
109 .mode = MUSB_OTG,
110#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
111 .mode = MUSB_HOST,
112#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
113 .mode = MUSB_PERIPHERAL,
114#endif
Bryan Wu50041ac2008-10-08 13:39:40 +0800115 .config = &musb_config,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800116};
117
118static u64 musb_dmamask = ~(u32)0;
119
120static struct platform_device musb_device = {
121 .name = "musb_hdrc",
122 .id = 0,
123 .dev = {
124 .dma_mask = &musb_dmamask,
125 .coherent_dma_mask = 0xffffffff,
126 .platform_data = &musb_plat,
127 },
128 .num_resources = ARRAY_SIZE(musb_resources),
129 .resource = musb_resources,
130};
131#endif
132
Michael Hennerich9db144f2008-07-19 17:16:07 +0800133#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
134static struct mtd_partition partition_info[] = {
135 {
Robin Getzaa582972008-08-05 17:47:29 +0800136 .name = "linux kernel(nand)",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800137 .offset = 0,
Mike Frysingerf4585a02008-10-13 14:45:21 +0800138 .size = 4 * 1024 * 1024,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800139 },
140 {
Robin Getzaa582972008-08-05 17:47:29 +0800141 .name = "file system(nand)",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800142 .offset = MTDPART_OFS_APPEND,
143 .size = MTDPART_SIZ_FULL,
144 },
145};
146
147static struct bf5xx_nand_platform bf5xx_nand_platform = {
148 .page_size = NFC_PG_SIZE_256,
149 .data_width = NFC_NWIDTH_8,
150 .partitions = partition_info,
151 .nr_partitions = ARRAY_SIZE(partition_info),
152 .rd_dly = 3,
153 .wr_dly = 3,
154};
155
156static struct resource bf5xx_nand_resources[] = {
157 {
158 .start = NFC_CTL,
159 .end = NFC_DATA_RD + 2,
160 .flags = IORESOURCE_MEM,
161 },
162 {
163 .start = CH_NFC,
164 .end = CH_NFC,
165 .flags = IORESOURCE_IRQ,
166 },
167};
168
169static struct platform_device bf5xx_nand_device = {
170 .name = "bf5xx-nand",
171 .id = 0,
172 .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
173 .resource = bf5xx_nand_resources,
174 .dev = {
175 .platform_data = &bf5xx_nand_platform,
176 },
177};
178#endif
179
180#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
181static struct resource bfin_pcmcia_cf_resources[] = {
182 {
183 .start = 0x20310000, /* IO PORT */
184 .end = 0x20312000,
185 .flags = IORESOURCE_MEM,
186 }, {
187 .start = 0x20311000, /* Attribute Memory */
188 .end = 0x20311FFF,
189 .flags = IORESOURCE_MEM,
190 }, {
191 .start = IRQ_PF4,
192 .end = IRQ_PF4,
193 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
194 }, {
195 .start = 6, /* Card Detect PF6 */
196 .end = 6,
197 .flags = IORESOURCE_IRQ,
198 },
199};
200
201static struct platform_device bfin_pcmcia_cf_device = {
202 .name = "bfin_cf_pcmcia",
203 .id = -1,
204 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
205 .resource = bfin_pcmcia_cf_resources,
206};
207#endif
208
209#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
210static struct platform_device rtc_device = {
211 .name = "rtc-bfin",
212 .id = -1,
213};
214#endif
215
216#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
Michael Hennerich61f09b52009-07-24 08:48:31 +0000217#include <linux/smc91x.h>
218
219static struct smc91x_platdata smc91x_info = {
220 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
221 .leda = RPC_LED_100_10,
222 .ledb = RPC_LED_TX_RX,
223};
224
Michael Hennerich9db144f2008-07-19 17:16:07 +0800225static struct resource smc91x_resources[] = {
226 {
227 .name = "smc91x-regs",
228 .start = 0x20300300,
229 .end = 0x20300300 + 16,
230 .flags = IORESOURCE_MEM,
231 }, {
232
233 .start = IRQ_PF7,
234 .end = IRQ_PF7,
235 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
236 },
237};
238static struct platform_device smc91x_device = {
239 .name = "smc91x",
240 .id = 0,
241 .num_resources = ARRAY_SIZE(smc91x_resources),
242 .resource = smc91x_resources,
Michael Hennerich61f09b52009-07-24 08:48:31 +0000243 .dev = {
244 .platform_data = &smc91x_info,
245 },
Michael Hennerich9db144f2008-07-19 17:16:07 +0800246};
247#endif
248
249#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
250static struct resource dm9000_resources[] = {
251 [0] = {
252 .start = 0x203FB800,
Barry Songb3dec4a2009-07-27 06:42:50 +0000253 .end = 0x203FB800 + 1,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800254 .flags = IORESOURCE_MEM,
255 },
256 [1] = {
Barry Songb3dec4a2009-07-27 06:42:50 +0000257 .start = 0x203FB804,
258 .end = 0x203FB804 + 1,
259 .flags = IORESOURCE_MEM,
260 },
261 [2] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800262 .start = IRQ_PF9,
263 .end = IRQ_PF9,
264 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
265 },
266};
267
268static struct platform_device dm9000_device = {
269 .name = "dm9000",
270 .id = -1,
271 .num_resources = ARRAY_SIZE(dm9000_resources),
272 .resource = dm9000_resources,
273};
274#endif
275
Michael Hennerich9db144f2008-07-19 17:16:07 +0800276#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
Graf Yang65319622009-02-04 16:49:45 +0800277static struct platform_device bfin_mii_bus = {
278 .name = "bfin_mii_bus",
279};
280
Michael Hennerich9db144f2008-07-19 17:16:07 +0800281static struct platform_device bfin_mac_device = {
282 .name = "bfin_mac",
Graf Yang65319622009-02-04 16:49:45 +0800283 .dev.platform_data = &bfin_mii_bus,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800284};
285#endif
286
287#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
288static struct resource net2272_bfin_resources[] = {
289 {
290 .start = 0x20300000,
291 .end = 0x20300000 + 0x100,
292 .flags = IORESOURCE_MEM,
293 }, {
294 .start = IRQ_PF7,
295 .end = IRQ_PF7,
296 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
297 },
298};
299
300static struct platform_device net2272_bfin_device = {
301 .name = "net2272",
302 .id = -1,
303 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
304 .resource = net2272_bfin_resources,
305};
306#endif
307
308#if defined(CONFIG_MTD_M25P80) \
309 || defined(CONFIG_MTD_M25P80_MODULE)
310static struct mtd_partition bfin_spi_flash_partitions[] = {
311 {
Robin Getzaa582972008-08-05 17:47:29 +0800312 .name = "bootloader(spi)",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800313 .size = 0x00040000,
314 .offset = 0,
315 .mask_flags = MTD_CAP_ROM
316 }, {
Robin Getzaa582972008-08-05 17:47:29 +0800317 .name = "linux kernel(spi)",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800318 .size = MTDPART_SIZ_FULL,
319 .offset = MTDPART_OFS_APPEND,
320 }
321};
322
323static struct flash_platform_data bfin_spi_flash_data = {
324 .name = "m25p80",
325 .parts = bfin_spi_flash_partitions,
326 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
327 .type = "m25p16",
328};
329
330/* SPI flash chip (m25p64) */
331static struct bfin5xx_spi_chip spi_flash_chip_info = {
332 .enable_dma = 0, /* use dma transfer with this chip*/
333 .bits_per_word = 8,
334};
335#endif
336
Mike Frysingera261eec2009-05-20 14:05:36 +0000337#if defined(CONFIG_BFIN_SPI_ADC) \
338 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800339/* SPI ADC chip */
340static struct bfin5xx_spi_chip spi_adc_chip_info = {
341 .enable_dma = 1, /* use dma transfer with this chip*/
342 .bits_per_word = 16,
343};
344#endif
345
Barry Songd40bd712010-02-22 10:31:06 +0000346#if defined(CONFIG_SND_BLACKFIN_AD183X) \
347 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800348static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
349 .enable_dma = 0,
350 .bits_per_word = 16,
351};
352#endif
353
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800354#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
355static struct bfin5xx_spi_chip mmc_spi_chip_info = {
356 .enable_dma = 0,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800357 .bits_per_word = 8,
358};
359#endif
360
Michael Hennerich9db144f2008-07-19 17:16:07 +0800361#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
362static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
363 .enable_dma = 0,
364 .bits_per_word = 16,
365};
366
367static 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
382#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
383 && defined(CONFIG_SND_SOC_WM8731_SPI)
384static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
385 .enable_dma = 0,
386 .bits_per_word = 16,
387};
388#endif
389
390#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
391static struct bfin5xx_spi_chip spidev_chip_info = {
392 .enable_dma = 0,
393 .bits_per_word = 8,
394};
395#endif
396
397static struct spi_board_info bfin_spi_board_info[] __initdata = {
398#if defined(CONFIG_MTD_M25P80) \
399 || defined(CONFIG_MTD_M25P80_MODULE)
400 {
401 /* the modalias must be the same as spi device driver name */
402 .modalias = "m25p80", /* Name of spi_driver for this device */
403 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
404 .bus_num = 0, /* Framework bus number */
405 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
406 .platform_data = &bfin_spi_flash_data,
407 .controller_data = &spi_flash_chip_info,
408 .mode = SPI_MODE_3,
409 },
410#endif
411
Mike Frysingera261eec2009-05-20 14:05:36 +0000412#if defined(CONFIG_BFIN_SPI_ADC) \
413 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800414 {
415 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
416 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
417 .bus_num = 0, /* Framework bus number */
418 .chip_select = 1, /* Framework chip select. */
419 .platform_data = NULL, /* No spi_driver specific config */
420 .controller_data = &spi_adc_chip_info,
421 },
422#endif
423
Barry Songd40bd712010-02-22 10:31:06 +0000424#if defined(CONFIG_SND_BLACKFIN_AD183X) \
425 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800426 {
Barry Songdac98172009-08-13 21:07:37 +0000427 .modalias = "ad1836",
Michael Hennerich9db144f2008-07-19 17:16:07 +0800428 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
429 .bus_num = 0,
430 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
431 .controller_data = &ad1836_spi_chip_info,
432 },
433#endif
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800434#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800435 {
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800436 .modalias = "mmc_spi",
437 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
Michael Hennerich9db144f2008-07-19 17:16:07 +0800438 .bus_num = 0,
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800439 .chip_select = 5,
440 .controller_data = &mmc_spi_chip_info,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800441 .mode = SPI_MODE_3,
442 },
443#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800444#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
445 {
446 .modalias = "ad7877",
447 .platform_data = &bfin_ad7877_ts_info,
448 .irq = IRQ_PF8,
449 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
450 .bus_num = 0,
451 .chip_select = 2,
452 .controller_data = &spi_ad7877_chip_info,
453 },
454#endif
455#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
456 && defined(CONFIG_SND_SOC_WM8731_SPI)
457 {
458 .modalias = "wm8731",
459 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
460 .bus_num = 0,
461 .chip_select = 5,
462 .controller_data = &spi_wm8731_chip_info,
463 .mode = SPI_MODE_0,
464 },
465#endif
466#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
467 {
468 .modalias = "spidev",
469 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
470 .bus_num = 0,
471 .chip_select = 1,
472 .controller_data = &spidev_chip_info,
473 },
474#endif
475};
476
477#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
478/* SPI controller data */
479static struct bfin5xx_spi_master bfin_spi0_info = {
480 .num_chipselect = 8,
481 .enable_dma = 1, /* master has the ability to do dma transfer */
482 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
483};
484
485/* SPI (0) */
486static struct resource bfin_spi0_resource[] = {
487 [0] = {
488 .start = SPI0_REGBASE,
489 .end = SPI0_REGBASE + 0xFF,
490 .flags = IORESOURCE_MEM,
491 },
492 [1] = {
493 .start = CH_SPI,
494 .end = CH_SPI,
Yi Li53122692009-06-05 12:11:11 +0000495 .flags = IORESOURCE_DMA,
496 },
497 [2] = {
498 .start = IRQ_SPI,
499 .end = IRQ_SPI,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800500 .flags = IORESOURCE_IRQ,
501 },
502};
503
504static struct platform_device bfin_spi0_device = {
505 .name = "bfin-spi",
506 .id = 0, /* Bus number */
507 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
508 .resource = bfin_spi0_resource,
509 .dev = {
510 .platform_data = &bfin_spi0_info, /* Passed to driver */
511 },
512};
513#endif /* spi master and devices */
514
Harald Krapfenbauer9c214532009-09-10 15:30:03 +0000515#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
516static struct mtd_partition cm_partitions[] = {
517 {
518 .name = "bootloader(nor)",
519 .size = 0x40000,
520 .offset = 0,
521 }, {
522 .name = "linux kernel(nor)",
523 .size = 0x100000,
524 .offset = MTDPART_OFS_APPEND,
525 }, {
526 .name = "file system(nor)",
527 .size = MTDPART_SIZ_FULL,
528 .offset = MTDPART_OFS_APPEND,
529 }
530};
531
532static struct physmap_flash_data cm_flash_data = {
533 .width = 2,
534 .parts = cm_partitions,
535 .nr_parts = ARRAY_SIZE(cm_partitions),
536};
537
538static unsigned cm_flash_gpios[] = { GPIO_PH9, GPIO_PG11 };
539
540static struct resource cm_flash_resource[] = {
541 {
542 .name = "cfi_probe",
543 .start = 0x20000000,
544 .end = 0x201fffff,
545 .flags = IORESOURCE_MEM,
546 }, {
547 .start = (unsigned long)cm_flash_gpios,
548 .end = ARRAY_SIZE(cm_flash_gpios),
549 .flags = IORESOURCE_IRQ,
550 }
551};
552
553static struct platform_device cm_flash_device = {
554 .name = "gpio-addr-flash",
555 .id = 0,
556 .dev = {
557 .platform_data = &cm_flash_data,
558 },
559 .num_resources = ARRAY_SIZE(cm_flash_resource),
560 .resource = cm_flash_resource,
561};
562#endif
563
Michael Hennerich9db144f2008-07-19 17:16:07 +0800564#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800565#ifdef CONFIG_SERIAL_BFIN_UART0
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000566static struct resource bfin_uart0_resources[] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800567 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000568 .start = UART0_THR,
569 .end = UART0_GCTL+2,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800570 .flags = IORESOURCE_MEM,
571 },
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000572 {
573 .start = IRQ_UART0_RX,
574 .end = IRQ_UART0_RX+1,
575 .flags = IORESOURCE_IRQ,
576 },
577 {
578 .start = IRQ_UART0_ERROR,
579 .end = IRQ_UART0_ERROR,
580 .flags = IORESOURCE_IRQ,
581 },
582 {
583 .start = CH_UART0_TX,
584 .end = CH_UART0_TX,
585 .flags = IORESOURCE_DMA,
586 },
587 {
588 .start = CH_UART0_RX,
589 .end = CH_UART0_RX,
590 .flags = IORESOURCE_DMA,
591 },
592};
593
594unsigned short bfin_uart0_peripherals[] = {
595 P_UART0_TX, P_UART0_RX, 0
596};
597
598static struct platform_device bfin_uart0_device = {
599 .name = "bfin-uart",
600 .id = 0,
601 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
602 .resource = bfin_uart0_resources,
603 .dev = {
604 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
605 },
606};
Michael Hennerich9db144f2008-07-19 17:16:07 +0800607#endif
608#ifdef CONFIG_SERIAL_BFIN_UART1
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000609static struct resource bfin_uart1_resources[] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800610 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000611 .start = UART1_THR,
612 .end = UART1_GCTL+2,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800613 .flags = IORESOURCE_MEM,
614 },
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000615 {
616 .start = IRQ_UART1_RX,
617 .end = IRQ_UART1_RX+1,
618 .flags = IORESOURCE_IRQ,
619 },
620 {
621 .start = IRQ_UART1_ERROR,
622 .end = IRQ_UART1_ERROR,
623 .flags = IORESOURCE_IRQ,
624 },
625 {
626 .start = CH_UART1_TX,
627 .end = CH_UART1_TX,
628 .flags = IORESOURCE_DMA,
629 },
630 {
631 .start = CH_UART1_RX,
632 .end = CH_UART1_RX,
633 .flags = IORESOURCE_DMA,
634 },
635#ifdef CONFIG_BFIN_UART1_CTSRTS
636 { /* CTS pin */
637 .start = GPIO_PF9,
638 .end = GPIO_PF9,
639 .flags = IORESOURCE_IO,
640 },
641 { /* RTS pin */
642 .start = GPIO_PF10,
643 .end = GPIO_PF10,
644 .flags = IORESOURCE_IO,
645 },
Michael Hennerich9db144f2008-07-19 17:16:07 +0800646#endif
647};
648
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000649unsigned short bfin_uart1_peripherals[] = {
650 P_UART1_TX, P_UART1_RX, 0
651};
652
653static struct platform_device bfin_uart1_device = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800654 .name = "bfin-uart",
655 .id = 1,
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000656 .num_resources = ARRAY_SIZE(bfin_uart1_resources),
657 .resource = bfin_uart1_resources,
658 .dev = {
659 .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
660 },
Michael Hennerich9db144f2008-07-19 17:16:07 +0800661};
662#endif
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000663#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800664
665#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800666#ifdef CONFIG_BFIN_SIR0
Graf Yang42bd8bc2009-01-07 23:14:39 +0800667static struct resource bfin_sir0_resources[] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800668 {
669 .start = 0xFFC00400,
670 .end = 0xFFC004FF,
671 .flags = IORESOURCE_MEM,
672 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800673 {
674 .start = IRQ_UART0_RX,
675 .end = IRQ_UART0_RX+1,
676 .flags = IORESOURCE_IRQ,
677 },
678 {
679 .start = CH_UART0_RX,
680 .end = CH_UART0_RX+1,
681 .flags = IORESOURCE_DMA,
682 },
683};
684
685static struct platform_device bfin_sir0_device = {
686 .name = "bfin_sir",
687 .id = 0,
688 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
689 .resource = bfin_sir0_resources,
690};
Michael Hennerich9db144f2008-07-19 17:16:07 +0800691#endif
692#ifdef CONFIG_BFIN_SIR1
Graf Yang42bd8bc2009-01-07 23:14:39 +0800693static struct resource bfin_sir1_resources[] = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800694 {
695 .start = 0xFFC02000,
696 .end = 0xFFC020FF,
697 .flags = IORESOURCE_MEM,
698 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800699 {
700 .start = IRQ_UART1_RX,
701 .end = IRQ_UART1_RX+1,
702 .flags = IORESOURCE_IRQ,
703 },
704 {
705 .start = CH_UART1_RX,
706 .end = CH_UART1_RX+1,
707 .flags = IORESOURCE_DMA,
708 },
Michael Hennerich9db144f2008-07-19 17:16:07 +0800709};
710
Graf Yang42bd8bc2009-01-07 23:14:39 +0800711static struct platform_device bfin_sir1_device = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800712 .name = "bfin_sir",
Graf Yang42bd8bc2009-01-07 23:14:39 +0800713 .id = 1,
714 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
715 .resource = bfin_sir1_resources,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800716};
717#endif
Graf Yang42bd8bc2009-01-07 23:14:39 +0800718#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800719
720#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
721static struct resource bfin_twi0_resource[] = {
722 [0] = {
723 .start = TWI0_REGBASE,
724 .end = TWI0_REGBASE,
725 .flags = IORESOURCE_MEM,
726 },
727 [1] = {
728 .start = IRQ_TWI,
729 .end = IRQ_TWI,
730 .flags = IORESOURCE_IRQ,
731 },
732};
733
734static struct platform_device i2c_bfin_twi_device = {
735 .name = "i2c-bfin-twi",
736 .id = 0,
737 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
738 .resource = bfin_twi0_resource,
739};
740#endif
741
Michael Hennerich9db144f2008-07-19 17:16:07 +0800742static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
Michael Hennerichebd58332009-07-02 11:00:38 +0000743#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800744 {
745 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
Michael Hennerich9db144f2008-07-19 17:16:07 +0800746 },
747#endif
Michael Hennerich204844e2009-06-30 14:57:22 +0000748#if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800749 {
750 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
Michael Hennerich9db144f2008-07-19 17:16:07 +0800751 .irq = IRQ_PF8,
752 },
753#endif
Michael Hennerich50c4c082009-09-22 13:10:09 +0000754#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
755 {
756 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
757 },
758#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800759};
Michael Hennerich9db144f2008-07-19 17:16:07 +0800760
761#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000762#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
763static struct resource bfin_sport0_uart_resources[] = {
764 {
765 .start = SPORT0_TCR1,
766 .end = SPORT0_MRCS3+4,
767 .flags = IORESOURCE_MEM,
768 },
769 {
770 .start = IRQ_SPORT0_RX,
771 .end = IRQ_SPORT0_RX+1,
772 .flags = IORESOURCE_IRQ,
773 },
774 {
775 .start = IRQ_SPORT0_ERROR,
776 .end = IRQ_SPORT0_ERROR,
777 .flags = IORESOURCE_IRQ,
778 },
779};
780
781unsigned short bfin_sport0_peripherals[] = {
782 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
783 P_SPORT0_DRPRI, P_SPORT0_RSCLK, P_SPORT0_DRSEC, P_SPORT0_DTSEC, 0
784};
785
Michael Hennerich9db144f2008-07-19 17:16:07 +0800786static struct platform_device bfin_sport0_uart_device = {
787 .name = "bfin-sport-uart",
788 .id = 0,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000789 .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
790 .resource = bfin_sport0_uart_resources,
791 .dev = {
792 .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
793 },
794};
795#endif
796#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
797static struct resource bfin_sport1_uart_resources[] = {
798 {
799 .start = SPORT1_TCR1,
800 .end = SPORT1_MRCS3+4,
801 .flags = IORESOURCE_MEM,
802 },
803 {
804 .start = IRQ_SPORT1_RX,
805 .end = IRQ_SPORT1_RX+1,
806 .flags = IORESOURCE_IRQ,
807 },
808 {
809 .start = IRQ_SPORT1_ERROR,
810 .end = IRQ_SPORT1_ERROR,
811 .flags = IORESOURCE_IRQ,
812 },
813};
814
815unsigned short bfin_sport1_peripherals[] = {
816 P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
817 P_SPORT1_DRPRI, P_SPORT1_RSCLK, P_SPORT1_DRSEC, P_SPORT1_DTSEC, 0
Michael Hennerich9db144f2008-07-19 17:16:07 +0800818};
819
820static struct platform_device bfin_sport1_uart_device = {
821 .name = "bfin-sport-uart",
822 .id = 1,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000823 .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
824 .resource = bfin_sport1_uart_resources,
825 .dev = {
826 .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
827 },
Michael Hennerich9db144f2008-07-19 17:16:07 +0800828};
829#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000830#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800831
Michael Hennerich9db144f2008-07-19 17:16:07 +0800832#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
833#include <linux/input.h>
834#include <linux/gpio_keys.h>
835
836static struct gpio_keys_button bfin_gpio_keys_table[] = {
837 {BTN_0, GPIO_PF14, 1, "gpio-keys: BTN0"},
838};
839
840static struct gpio_keys_platform_data bfin_gpio_keys_data = {
841 .buttons = bfin_gpio_keys_table,
842 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
843};
844
845static struct platform_device bfin_device_gpiokeys = {
846 .name = "gpio-keys",
847 .dev = {
848 .platform_data = &bfin_gpio_keys_data,
849 },
850};
851#endif
852
Michael Hennerich9db144f2008-07-19 17:16:07 +0800853static const unsigned int cclk_vlev_datasheet[] =
854{
855 VRPAIR(VLEV_100, 400000000),
856 VRPAIR(VLEV_105, 426000000),
857 VRPAIR(VLEV_110, 500000000),
858 VRPAIR(VLEV_115, 533000000),
859 VRPAIR(VLEV_120, 600000000),
860};
861
862static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
863 .tuple_tab = cclk_vlev_datasheet,
864 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
865 .vr_settling_time = 25 /* us */,
866};
867
868static struct platform_device bfin_dpmc = {
869 .name = "bfin dpmc",
870 .dev = {
871 .platform_data = &bfin_dmpc_vreg_data,
872 },
873};
874
Harald Krapfenbauer9c214532009-09-10 15:30:03 +0000875static struct platform_device *cmbf527_devices[] __initdata = {
Michael Hennerich9db144f2008-07-19 17:16:07 +0800876
877 &bfin_dpmc,
878
879#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
880 &bf5xx_nand_device,
881#endif
882
883#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
884 &bfin_pcmcia_cf_device,
885#endif
886
887#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
888 &rtc_device,
889#endif
890
Michael Hennerich3f375692008-11-18 17:48:22 +0800891#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
892 &bfin_isp1760_device,
893#endif
894
Michael Hennerich9db144f2008-07-19 17:16:07 +0800895#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
896 &musb_device,
897#endif
898
899#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
900 &smc91x_device,
901#endif
902
903#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
904 &dm9000_device,
905#endif
906
907#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
Graf Yang65319622009-02-04 16:49:45 +0800908 &bfin_mii_bus,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800909 &bfin_mac_device,
910#endif
911
912#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
913 &net2272_bfin_device,
914#endif
915
916#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
917 &bfin_spi0_device,
918#endif
919
Michael Hennerich9db144f2008-07-19 17:16:07 +0800920#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000921#ifdef CONFIG_SERIAL_BFIN_UART0
922 &bfin_uart0_device,
923#endif
924#ifdef CONFIG_SERIAL_BFIN_UART1
925 &bfin_uart1_device,
926#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800927#endif
928
929#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang42bd8bc2009-01-07 23:14:39 +0800930#ifdef CONFIG_BFIN_SIR0
931 &bfin_sir0_device,
932#endif
933#ifdef CONFIG_BFIN_SIR1
934 &bfin_sir1_device,
935#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800936#endif
937
938#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
939 &i2c_bfin_twi_device,
940#endif
941
942#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
Sonic Zhangdf5de262009-09-23 05:01:56 +0000943#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
Michael Hennerich9db144f2008-07-19 17:16:07 +0800944 &bfin_sport0_uart_device,
Sonic Zhangdf5de262009-09-23 05:01:56 +0000945#endif
946#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
Michael Hennerich9db144f2008-07-19 17:16:07 +0800947 &bfin_sport1_uart_device,
948#endif
Sonic Zhangdf5de262009-09-23 05:01:56 +0000949#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800950
Michael Hennerich9db144f2008-07-19 17:16:07 +0800951#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
952 &bfin_device_gpiokeys,
953#endif
954
Harald Krapfenbauer9c214532009-09-10 15:30:03 +0000955#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
956 &cm_flash_device,
Michael Hennerich9db144f2008-07-19 17:16:07 +0800957#endif
Michael Hennerich9db144f2008-07-19 17:16:07 +0800958};
959
Mike Frysinger7f6678c2009-02-04 16:49:45 +0800960static int __init cm_init(void)
Michael Hennerich9db144f2008-07-19 17:16:07 +0800961{
962 printk(KERN_INFO "%s(): registering device resources\n", __func__);
Michael Hennerich9db144f2008-07-19 17:16:07 +0800963 i2c_register_board_info(0, bfin_i2c_board_info,
964 ARRAY_SIZE(bfin_i2c_board_info));
Harald Krapfenbauer9c214532009-09-10 15:30:03 +0000965 platform_add_devices(cmbf527_devices, ARRAY_SIZE(cmbf527_devices));
Michael Hennerich9db144f2008-07-19 17:16:07 +0800966 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
Michael Hennerich9db144f2008-07-19 17:16:07 +0800967 return 0;
968}
969
Mike Frysinger7f6678c2009-02-04 16:49:45 +0800970arch_initcall(cm_init);
Michael Hennerich9db144f2008-07-19 17:16:07 +0800971
Sonic Zhangc13ce9f2009-09-23 09:37:46 +0000972static struct platform_device *cmbf527_early_devices[] __initdata = {
973#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
974#ifdef CONFIG_SERIAL_BFIN_UART0
975 &bfin_uart0_device,
976#endif
977#ifdef CONFIG_SERIAL_BFIN_UART1
978 &bfin_uart1_device,
979#endif
980#endif
981
982#if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
983#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
984 &bfin_sport0_uart_device,
985#endif
986#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
987 &bfin_sport1_uart_device,
988#endif
989#endif
990};
991
992void __init native_machine_early_platform_add_devices(void)
993{
994 printk(KERN_INFO "register early platform devices\n");
995 early_platform_add_devices(cmbf527_early_devices,
996 ARRAY_SIZE(cmbf527_early_devices));
997}
998
Michael Hennerich9db144f2008-07-19 17:16:07 +0800999void native_machine_restart(char *cmd)
1000{
1001 /* workaround reboot hang when booting from SPI */
1002 if ((bfin_read_SYSCR() & 0x7) == 0x3)
Sonic Zhangb52dae32009-02-04 16:49:45 +08001003 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
Michael Hennerich9db144f2008-07-19 17:16:07 +08001004}
1005
1006void bfin_get_ether_addr(char *addr)
1007{
1008 random_ether_addr(addr);
1009 printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
1010}
1011EXPORT_SYMBOL(bfin_get_ether_addr);