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/export.h>
12 #include <linux/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/flash.h>
17 #include <linux/irq.h>
19 #include <asm/bfin5xx_spi.h>
20 #include <asm/portmux.h>
22 #include <linux/spi/ad7877.h>
25 * Name the Board for the /proc/cpuinfo
27 const char bfin_board_name[] = "ADI PNAV-1.0";
30 * Driver needs to know address, irq and flag pin.
33 #if IS_ENABLED(CONFIG_BFIN_CFPCMCIA)
34 static struct resource bfin_pcmcia_cf_resources[] = {
36 .start = 0x20310000, /* IO PORT */
38 .flags = IORESOURCE_MEM,
40 .start = 0x20311000, /* Attribute Memory */
42 .flags = IORESOURCE_MEM,
46 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
48 .start = 6, /* Card Detect PF6 */
50 .flags = IORESOURCE_IRQ,
54 static struct platform_device bfin_pcmcia_cf_device = {
55 .name = "bfin_cf_pcmcia",
57 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
58 .resource = bfin_pcmcia_cf_resources,
62 #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
63 static struct platform_device rtc_device = {
69 #if IS_ENABLED(CONFIG_SMC91X)
70 #include <linux/smc91x.h>
72 static struct smc91x_platdata smc91x_info = {
73 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
74 .leda = RPC_LED_100_10,
75 .ledb = RPC_LED_TX_RX,
78 static struct resource smc91x_resources[] = {
80 .name = "smc91x-regs",
82 .end = 0x20300300 + 16,
83 .flags = IORESOURCE_MEM,
88 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
91 static struct platform_device smc91x_device = {
94 .num_resources = ARRAY_SIZE(smc91x_resources),
95 .resource = smc91x_resources,
97 .platform_data = &smc91x_info,
102 #if IS_ENABLED(CONFIG_BFIN_MAC)
103 #include <linux/bfin_mac.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 IS_ENABLED(CONFIG_USB_NET2272)
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 IS_ENABLED(CONFIG_SPI_BFIN5XX)
157 /* all SPI peripherals info goes here */
159 #if IS_ENABLED(CONFIG_MTD_M25P80)
160 static struct mtd_partition bfin_spi_flash_partitions[] = {
162 .name = "bootloader(spi)",
165 .mask_flags = MTD_CAP_ROM
167 .name = "linux kernel(spi)",
171 .name = "file system(spi)",
173 .offset = 0x00100000,
177 static struct flash_platform_data bfin_spi_flash_data = {
179 .parts = bfin_spi_flash_partitions,
180 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
184 /* SPI flash chip (m25p64) */
185 static struct bfin5xx_spi_chip spi_flash_chip_info = {
186 .enable_dma = 0, /* use dma transfer with this chip*/
190 #if IS_ENABLED(CONFIG_MMC_SPI)
191 static struct bfin5xx_spi_chip mmc_spi_chip_info = {
196 #if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
197 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
199 .vref_delay_usecs = 50, /* internal, no capacitor */
202 .pressure_max = 1000,
204 .stopacq_polarity = 1,
205 .first_conversion_delay = 3,
206 .acquisition_time = 1,
208 .pen_down_acc_interval = 1,
212 static struct spi_board_info bfin_spi_board_info[] __initdata = {
213 #if IS_ENABLED(CONFIG_MTD_M25P80)
215 /* the modalias must be the same as spi device driver name */
216 .modalias = "m25p80", /* Name of spi_driver for this device */
217 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
218 .bus_num = 0, /* Framework bus number */
219 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
220 .platform_data = &bfin_spi_flash_data,
221 .controller_data = &spi_flash_chip_info,
226 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
228 .modalias = "ad183x",
229 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
234 #if IS_ENABLED(CONFIG_MMC_SPI)
236 .modalias = "mmc_spi",
237 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
240 .controller_data = &mmc_spi_chip_info,
244 #if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
246 .modalias = "ad7877",
247 .platform_data = &bfin_ad7877_ts_info,
249 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
258 static struct resource bfin_spi0_resource[] = {
260 .start = SPI0_REGBASE,
261 .end = SPI0_REGBASE + 0xFF,
262 .flags = IORESOURCE_MEM,
267 .flags = IORESOURCE_DMA,
272 .flags = IORESOURCE_IRQ,
276 /* SPI controller data */
277 static struct bfin5xx_spi_master bfin_spi0_info = {
279 .enable_dma = 1, /* master has the ability to do dma transfer */
280 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
283 static struct platform_device bfin_spi0_device = {
285 .id = 0, /* Bus number */
286 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
287 .resource = bfin_spi0_resource,
289 .platform_data = &bfin_spi0_info, /* Passed to driver */
292 #endif /* spi master and devices */
294 #if IS_ENABLED(CONFIG_FB_BF537_LQ035)
295 static struct platform_device bfin_fb_device = {
296 .name = "bf537-lq035",
300 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
301 #ifdef CONFIG_SERIAL_BFIN_UART0
302 static struct resource bfin_uart0_resources[] = {
306 .flags = IORESOURCE_MEM,
309 .start = IRQ_UART0_TX,
311 .flags = IORESOURCE_IRQ,
314 .start = IRQ_UART0_RX,
316 .flags = IORESOURCE_IRQ,
319 .start = IRQ_UART0_ERROR,
320 .end = IRQ_UART0_ERROR,
321 .flags = IORESOURCE_IRQ,
324 .start = CH_UART0_TX,
326 .flags = IORESOURCE_DMA,
329 .start = CH_UART0_RX,
331 .flags = IORESOURCE_DMA,
335 static unsigned short bfin_uart0_peripherals[] = {
336 P_UART0_TX, P_UART0_RX, 0
339 static struct platform_device bfin_uart0_device = {
342 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
343 .resource = bfin_uart0_resources,
345 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
349 #ifdef CONFIG_SERIAL_BFIN_UART1
350 static struct resource bfin_uart1_resources[] = {
354 .flags = IORESOURCE_MEM,
357 .start = IRQ_UART1_TX,
359 .flags = IORESOURCE_IRQ,
362 .start = IRQ_UART1_RX,
364 .flags = IORESOURCE_IRQ,
367 .start = IRQ_UART1_ERROR,
368 .end = IRQ_UART1_ERROR,
369 .flags = IORESOURCE_IRQ,
372 .start = CH_UART1_TX,
374 .flags = IORESOURCE_DMA,
377 .start = CH_UART1_RX,
379 .flags = IORESOURCE_DMA,
383 static unsigned short bfin_uart1_peripherals[] = {
384 P_UART1_TX, P_UART1_RX, 0
387 static struct platform_device bfin_uart1_device = {
390 .num_resources = ARRAY_SIZE(bfin_uart1_resources),
391 .resource = bfin_uart1_resources,
393 .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
399 #if IS_ENABLED(CONFIG_BFIN_SIR)
400 #ifdef CONFIG_BFIN_SIR0
401 static struct resource bfin_sir0_resources[] = {
405 .flags = IORESOURCE_MEM,
408 .start = IRQ_UART0_RX,
409 .end = IRQ_UART0_RX+1,
410 .flags = IORESOURCE_IRQ,
413 .start = CH_UART0_RX,
414 .end = CH_UART0_RX+1,
415 .flags = IORESOURCE_DMA,
419 static struct platform_device bfin_sir0_device = {
422 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
423 .resource = bfin_sir0_resources,
426 #ifdef CONFIG_BFIN_SIR1
427 static struct resource bfin_sir1_resources[] = {
431 .flags = IORESOURCE_MEM,
434 .start = IRQ_UART1_RX,
435 .end = IRQ_UART1_RX+1,
436 .flags = IORESOURCE_IRQ,
439 .start = CH_UART1_RX,
440 .end = CH_UART1_RX+1,
441 .flags = IORESOURCE_DMA,
445 static struct platform_device bfin_sir1_device = {
448 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
449 .resource = bfin_sir1_resources,
454 static struct platform_device *stamp_devices[] __initdata = {
455 #if IS_ENABLED(CONFIG_BFIN_CFPCMCIA)
456 &bfin_pcmcia_cf_device,
459 #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
463 #if IS_ENABLED(CONFIG_SMC91X)
467 #if IS_ENABLED(CONFIG_BFIN_MAC)
472 #if IS_ENABLED(CONFIG_USB_NET2272)
473 &net2272_bfin_device,
476 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
480 #if IS_ENABLED(CONFIG_FB_BF537_LQ035)
484 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
485 #ifdef CONFIG_SERIAL_BFIN_UART0
488 #ifdef CONFIG_SERIAL_BFIN_UART1
493 #if IS_ENABLED(CONFIG_BFIN_SIR)
494 #ifdef CONFIG_BFIN_SIR0
497 #ifdef CONFIG_BFIN_SIR1
503 static int __init pnav_init(void)
505 printk(KERN_INFO "%s(): registering device resources\n", __func__);
506 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
507 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
508 spi_register_board_info(bfin_spi_board_info,
509 ARRAY_SIZE(bfin_spi_board_info));
514 arch_initcall(pnav_init);
516 static struct platform_device *stamp_early_devices[] __initdata = {
517 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
518 #ifdef CONFIG_SERIAL_BFIN_UART0
521 #ifdef CONFIG_SERIAL_BFIN_UART1
527 void __init native_machine_early_platform_add_devices(void)
529 printk(KERN_INFO "register early platform devices\n");
530 early_platform_add_devices(stamp_early_devices,
531 ARRAY_SIZE(stamp_early_devices));
534 int bfin_get_ether_addr(char *addr)
538 EXPORT_SYMBOL(bfin_get_ether_addr);