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 static const unsigned short bfin_mac_peripherals
[] = P_RMII0
;
105 static struct bfin_phydev_platform_data bfin_phydev_data
[] = {
108 .irq
= IRQ_MAC_PHYINT
,
112 static struct bfin_mii_bus_platform_data bfin_mii_bus_data
= {
114 .phydev_data
= bfin_phydev_data
,
115 .phy_mode
= PHY_INTERFACE_MODE_RMII
,
116 .mac_peripherals
= bfin_mac_peripherals
,
119 static struct platform_device bfin_mii_bus
= {
120 .name
= "bfin_mii_bus",
122 .platform_data
= &bfin_mii_bus_data
,
126 static struct platform_device bfin_mac_device
= {
129 .platform_data
= &bfin_mii_bus
,
134 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
135 static struct resource net2272_bfin_resources
[] = {
138 .end
= 0x20300000 + 0x100,
139 .flags
= IORESOURCE_MEM
,
143 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
147 static struct platform_device net2272_bfin_device
= {
150 .num_resources
= ARRAY_SIZE(net2272_bfin_resources
),
151 .resource
= net2272_bfin_resources
,
155 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
156 /* all SPI peripherals info goes here */
158 #if defined(CONFIG_MTD_M25P80) \
159 || defined(CONFIG_MTD_M25P80_MODULE)
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 defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
191 static struct bfin5xx_spi_chip mmc_spi_chip_info
= {
196 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
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 defined(CONFIG_MTD_M25P80) \
214 || defined(CONFIG_MTD_M25P80_MODULE)
216 /* the modalias must be the same as spi device driver name */
217 .modalias
= "m25p80", /* Name of spi_driver for this device */
218 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
219 .bus_num
= 0, /* Framework bus number */
220 .chip_select
= 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
221 .platform_data
= &bfin_spi_flash_data
,
222 .controller_data
= &spi_flash_chip_info
,
227 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
228 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
230 .modalias
= "ad183x",
231 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
236 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
238 .modalias
= "mmc_spi",
239 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
242 .controller_data
= &mmc_spi_chip_info
,
246 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
248 .modalias
= "ad7877",
249 .platform_data
= &bfin_ad7877_ts_info
,
251 .max_speed_hz
= 12500000, /* max spi clock (SCK) speed in HZ */
260 static struct resource bfin_spi0_resource
[] = {
262 .start
= SPI0_REGBASE
,
263 .end
= SPI0_REGBASE
+ 0xFF,
264 .flags
= IORESOURCE_MEM
,
269 .flags
= IORESOURCE_DMA
,
274 .flags
= IORESOURCE_IRQ
,
278 /* SPI controller data */
279 static struct bfin5xx_spi_master bfin_spi0_info
= {
281 .enable_dma
= 1, /* master has the ability to do dma transfer */
282 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
285 static struct platform_device bfin_spi0_device
= {
287 .id
= 0, /* Bus number */
288 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
289 .resource
= bfin_spi0_resource
,
291 .platform_data
= &bfin_spi0_info
, /* Passed to driver */
294 #endif /* spi master and devices */
296 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
297 static struct platform_device bfin_fb_device
= {
298 .name
= "bf537-lq035",
302 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
303 #ifdef CONFIG_SERIAL_BFIN_UART0
304 static struct resource bfin_uart0_resources
[] = {
308 .flags
= IORESOURCE_MEM
,
311 .start
= IRQ_UART0_TX
,
313 .flags
= IORESOURCE_IRQ
,
316 .start
= IRQ_UART0_RX
,
318 .flags
= IORESOURCE_IRQ
,
321 .start
= IRQ_UART0_ERROR
,
322 .end
= IRQ_UART0_ERROR
,
323 .flags
= IORESOURCE_IRQ
,
326 .start
= CH_UART0_TX
,
328 .flags
= IORESOURCE_DMA
,
331 .start
= CH_UART0_RX
,
333 .flags
= IORESOURCE_DMA
,
337 static unsigned short bfin_uart0_peripherals
[] = {
338 P_UART0_TX
, P_UART0_RX
, 0
341 static struct platform_device bfin_uart0_device
= {
344 .num_resources
= ARRAY_SIZE(bfin_uart0_resources
),
345 .resource
= bfin_uart0_resources
,
347 .platform_data
= &bfin_uart0_peripherals
, /* Passed to driver */
351 #ifdef CONFIG_SERIAL_BFIN_UART1
352 static struct resource bfin_uart1_resources
[] = {
356 .flags
= IORESOURCE_MEM
,
359 .start
= IRQ_UART1_TX
,
361 .flags
= IORESOURCE_IRQ
,
364 .start
= IRQ_UART1_RX
,
366 .flags
= IORESOURCE_IRQ
,
369 .start
= IRQ_UART1_ERROR
,
370 .end
= IRQ_UART1_ERROR
,
371 .flags
= IORESOURCE_IRQ
,
374 .start
= CH_UART1_TX
,
376 .flags
= IORESOURCE_DMA
,
379 .start
= CH_UART1_RX
,
381 .flags
= IORESOURCE_DMA
,
385 static unsigned short bfin_uart1_peripherals
[] = {
386 P_UART1_TX
, P_UART1_RX
, 0
389 static struct platform_device bfin_uart1_device
= {
392 .num_resources
= ARRAY_SIZE(bfin_uart1_resources
),
393 .resource
= bfin_uart1_resources
,
395 .platform_data
= &bfin_uart1_peripherals
, /* Passed to driver */
401 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
402 #ifdef CONFIG_BFIN_SIR0
403 static struct resource bfin_sir0_resources
[] = {
407 .flags
= IORESOURCE_MEM
,
410 .start
= IRQ_UART0_RX
,
411 .end
= IRQ_UART0_RX
+1,
412 .flags
= IORESOURCE_IRQ
,
415 .start
= CH_UART0_RX
,
416 .end
= CH_UART0_RX
+1,
417 .flags
= IORESOURCE_DMA
,
421 static struct platform_device bfin_sir0_device
= {
424 .num_resources
= ARRAY_SIZE(bfin_sir0_resources
),
425 .resource
= bfin_sir0_resources
,
428 #ifdef CONFIG_BFIN_SIR1
429 static struct resource bfin_sir1_resources
[] = {
433 .flags
= IORESOURCE_MEM
,
436 .start
= IRQ_UART1_RX
,
437 .end
= IRQ_UART1_RX
+1,
438 .flags
= IORESOURCE_IRQ
,
441 .start
= CH_UART1_RX
,
442 .end
= CH_UART1_RX
+1,
443 .flags
= IORESOURCE_DMA
,
447 static struct platform_device bfin_sir1_device
= {
450 .num_resources
= ARRAY_SIZE(bfin_sir1_resources
),
451 .resource
= bfin_sir1_resources
,
456 static struct platform_device
*stamp_devices
[] __initdata
= {
457 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
458 &bfin_pcmcia_cf_device
,
461 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
465 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
469 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
474 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
475 &net2272_bfin_device
,
478 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
482 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
486 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
487 #ifdef CONFIG_SERIAL_BFIN_UART0
490 #ifdef CONFIG_SERIAL_BFIN_UART1
495 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
496 #ifdef CONFIG_BFIN_SIR0
499 #ifdef CONFIG_BFIN_SIR1
505 static int __init
pnav_init(void)
507 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
508 platform_add_devices(stamp_devices
, ARRAY_SIZE(stamp_devices
));
509 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
510 spi_register_board_info(bfin_spi_board_info
,
511 ARRAY_SIZE(bfin_spi_board_info
));
516 arch_initcall(pnav_init
);
518 static struct platform_device
*stamp_early_devices
[] __initdata
= {
519 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
520 #ifdef CONFIG_SERIAL_BFIN_UART0
523 #ifdef CONFIG_SERIAL_BFIN_UART1
529 void __init
native_machine_early_platform_add_devices(void)
531 printk(KERN_INFO
"register early platform devices\n");
532 early_platform_add_devices(stamp_early_devices
,
533 ARRAY_SIZE(stamp_early_devices
));
536 void bfin_get_ether_addr(char *addr
)
538 random_ether_addr(addr
);
539 printk(KERN_WARNING
"%s:%s: Setting Ethernet MAC to a random one\n", __FILE__
, __func__
);
541 EXPORT_SYMBOL(bfin_get_ether_addr
);