2 * Copyright 2004-2009 Analog Devices Inc.
3 * 2005 National ICT Australia (NICTA)
4 * Aidan Williams <aidan@nicta.com.au>
6 * Licensed under the GPL-2 or later.
9 #include <linux/device.h>
10 #include <linux/etherdevice.h>
11 #include <linux/platform_device.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/spi/spi.h>
15 #include <linux/spi/flash.h>
16 #include <linux/irq.h>
18 #include <asm/bfin5xx_spi.h>
19 #include <asm/portmux.h>
21 #include <linux/spi/ad7877.h>
24 * Name the Board for the /proc/cpuinfo
26 const char bfin_board_name[] = "ADI PNAV-1.0";
29 * Driver needs to know address, irq and flag pin.
32 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
33 static struct resource bfin_pcmcia_cf_resources[] = {
35 .start = 0x20310000, /* IO PORT */
37 .flags = IORESOURCE_MEM,
39 .start = 0x20311000, /* Attribute Memory */
41 .flags = IORESOURCE_MEM,
45 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
47 .start = 6, /* Card Detect PF6 */
49 .flags = IORESOURCE_IRQ,
53 static struct platform_device bfin_pcmcia_cf_device = {
54 .name = "bfin_cf_pcmcia",
56 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
57 .resource = bfin_pcmcia_cf_resources,
61 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
62 static struct platform_device rtc_device = {
68 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
69 #include <linux/smc91x.h>
71 static struct smc91x_platdata smc91x_info = {
72 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
73 .leda = RPC_LED_100_10,
74 .ledb = RPC_LED_TX_RX,
77 static struct resource smc91x_resources[] = {
79 .name = "smc91x-regs",
81 .end = 0x20300300 + 16,
82 .flags = IORESOURCE_MEM,
87 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
90 static struct platform_device smc91x_device = {
93 .num_resources = ARRAY_SIZE(smc91x_resources),
94 .resource = smc91x_resources,
96 .platform_data = &smc91x_info,
101 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
102 #include <linux/bfin_mac.h>
103 #include <linux/export.h>
104 static const unsigned short bfin_mac_peripherals[] = P_RMII0;
106 static struct bfin_phydev_platform_data bfin_phydev_data[] = {
109 .irq = IRQ_MAC_PHYINT,
113 static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
115 .phydev_data = bfin_phydev_data,
116 .phy_mode = PHY_INTERFACE_MODE_RMII,
117 .mac_peripherals = bfin_mac_peripherals,
120 static struct platform_device bfin_mii_bus = {
121 .name = "bfin_mii_bus",
123 .platform_data = &bfin_mii_bus_data,
127 static struct platform_device bfin_mac_device = {
130 .platform_data = &bfin_mii_bus,
135 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
136 static struct resource net2272_bfin_resources[] = {
139 .end = 0x20300000 + 0x100,
140 .flags = IORESOURCE_MEM,
144 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
148 static struct platform_device net2272_bfin_device = {
151 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
152 .resource = net2272_bfin_resources,
156 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
157 /* all SPI peripherals info goes here */
159 #if defined(CONFIG_MTD_M25P80) \
160 || defined(CONFIG_MTD_M25P80_MODULE)
161 static struct mtd_partition bfin_spi_flash_partitions[] = {
163 .name = "bootloader(spi)",
166 .mask_flags = MTD_CAP_ROM
168 .name = "linux kernel(spi)",
172 .name = "file system(spi)",
174 .offset = 0x00100000,
178 static struct flash_platform_data bfin_spi_flash_data = {
180 .parts = bfin_spi_flash_partitions,
181 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
185 /* SPI flash chip (m25p64) */
186 static struct bfin5xx_spi_chip spi_flash_chip_info = {
187 .enable_dma = 0, /* use dma transfer with this chip*/
191 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
192 static struct bfin5xx_spi_chip mmc_spi_chip_info = {
197 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
198 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
200 .vref_delay_usecs = 50, /* internal, no capacitor */
203 .pressure_max = 1000,
205 .stopacq_polarity = 1,
206 .first_conversion_delay = 3,
207 .acquisition_time = 1,
209 .pen_down_acc_interval = 1,
213 static struct spi_board_info bfin_spi_board_info[] __initdata = {
214 #if defined(CONFIG_MTD_M25P80) \
215 || defined(CONFIG_MTD_M25P80_MODULE)
217 /* the modalias must be the same as spi device driver name */
218 .modalias = "m25p80", /* Name of spi_driver for this device */
219 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
220 .bus_num = 0, /* Framework bus number */
221 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
222 .platform_data = &bfin_spi_flash_data,
223 .controller_data = &spi_flash_chip_info,
228 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
229 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
231 .modalias = "ad183x",
232 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
237 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
239 .modalias = "mmc_spi",
240 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
243 .controller_data = &mmc_spi_chip_info,
247 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
249 .modalias = "ad7877",
250 .platform_data = &bfin_ad7877_ts_info,
252 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
261 static struct resource bfin_spi0_resource[] = {
263 .start = SPI0_REGBASE,
264 .end = SPI0_REGBASE + 0xFF,
265 .flags = IORESOURCE_MEM,
270 .flags = IORESOURCE_DMA,
275 .flags = IORESOURCE_IRQ,
279 /* SPI controller data */
280 static struct bfin5xx_spi_master bfin_spi0_info = {
282 .enable_dma = 1, /* master has the ability to do dma transfer */
283 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
286 static struct platform_device bfin_spi0_device = {
288 .id = 0, /* Bus number */
289 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
290 .resource = bfin_spi0_resource,
292 .platform_data = &bfin_spi0_info, /* Passed to driver */
295 #endif /* spi master and devices */
297 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
298 static struct platform_device bfin_fb_device = {
299 .name = "bf537-lq035",
303 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
304 #ifdef CONFIG_SERIAL_BFIN_UART0
305 static struct resource bfin_uart0_resources[] = {
309 .flags = IORESOURCE_MEM,
312 .start = IRQ_UART0_RX,
313 .end = IRQ_UART0_RX+1,
314 .flags = IORESOURCE_IRQ,
317 .start = IRQ_UART0_ERROR,
318 .end = IRQ_UART0_ERROR,
319 .flags = IORESOURCE_IRQ,
322 .start = CH_UART0_TX,
324 .flags = IORESOURCE_DMA,
327 .start = CH_UART0_RX,
329 .flags = IORESOURCE_DMA,
333 static unsigned short bfin_uart0_peripherals[] = {
334 P_UART0_TX, P_UART0_RX, 0
337 static struct platform_device bfin_uart0_device = {
340 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
341 .resource = bfin_uart0_resources,
343 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
347 #ifdef CONFIG_SERIAL_BFIN_UART1
348 static struct resource bfin_uart1_resources[] = {
352 .flags = IORESOURCE_MEM,
355 .start = IRQ_UART1_RX,
356 .end = IRQ_UART1_RX+1,
357 .flags = IORESOURCE_IRQ,
360 .start = IRQ_UART1_ERROR,
361 .end = IRQ_UART1_ERROR,
362 .flags = IORESOURCE_IRQ,
365 .start = CH_UART1_TX,
367 .flags = IORESOURCE_DMA,
370 .start = CH_UART1_RX,
372 .flags = IORESOURCE_DMA,
376 static unsigned short bfin_uart1_peripherals[] = {
377 P_UART1_TX, P_UART1_RX, 0
380 static struct platform_device bfin_uart1_device = {
383 .num_resources = ARRAY_SIZE(bfin_uart1_resources),
384 .resource = bfin_uart1_resources,
386 .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
392 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
393 #ifdef CONFIG_BFIN_SIR0
394 static struct resource bfin_sir0_resources[] = {
398 .flags = IORESOURCE_MEM,
401 .start = IRQ_UART0_RX,
402 .end = IRQ_UART0_RX+1,
403 .flags = IORESOURCE_IRQ,
406 .start = CH_UART0_RX,
407 .end = CH_UART0_RX+1,
408 .flags = IORESOURCE_DMA,
412 static struct platform_device bfin_sir0_device = {
415 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
416 .resource = bfin_sir0_resources,
419 #ifdef CONFIG_BFIN_SIR1
420 static struct resource bfin_sir1_resources[] = {
424 .flags = IORESOURCE_MEM,
427 .start = IRQ_UART1_RX,
428 .end = IRQ_UART1_RX+1,
429 .flags = IORESOURCE_IRQ,
432 .start = CH_UART1_RX,
433 .end = CH_UART1_RX+1,
434 .flags = IORESOURCE_DMA,
438 static struct platform_device bfin_sir1_device = {
441 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
442 .resource = bfin_sir1_resources,
447 static struct platform_device *stamp_devices[] __initdata = {
448 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
449 &bfin_pcmcia_cf_device,
452 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
456 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
460 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
465 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
466 &net2272_bfin_device,
469 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
473 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
477 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
478 #ifdef CONFIG_SERIAL_BFIN_UART0
481 #ifdef CONFIG_SERIAL_BFIN_UART1
486 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
487 #ifdef CONFIG_BFIN_SIR0
490 #ifdef CONFIG_BFIN_SIR1
496 static int __init pnav_init(void)
498 printk(KERN_INFO "%s(): registering device resources\n", __func__);
499 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
500 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
501 spi_register_board_info(bfin_spi_board_info,
502 ARRAY_SIZE(bfin_spi_board_info));
507 arch_initcall(pnav_init);
509 static struct platform_device *stamp_early_devices[] __initdata = {
510 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
511 #ifdef CONFIG_SERIAL_BFIN_UART0
514 #ifdef CONFIG_SERIAL_BFIN_UART1
520 void __init native_machine_early_platform_add_devices(void)
522 printk(KERN_INFO "register early platform devices\n");
523 early_platform_add_devices(stamp_early_devices,
524 ARRAY_SIZE(stamp_early_devices));
527 void bfin_get_ether_addr(char *addr)
529 random_ether_addr(addr);
530 printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
532 EXPORT_SYMBOL(bfin_get_ether_addr);