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 defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
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 defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
63 static struct platform_device rtc_device
= {
69 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
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 defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
103 #include <linux/bfin_mac.h>
104 #include <linux/export.h>
105 static const unsigned short bfin_mac_peripherals
[] = P_RMII0
;
107 static struct bfin_phydev_platform_data bfin_phydev_data
[] = {
110 .irq
= IRQ_MAC_PHYINT
,
114 static struct bfin_mii_bus_platform_data bfin_mii_bus_data
= {
116 .phydev_data
= bfin_phydev_data
,
117 .phy_mode
= PHY_INTERFACE_MODE_RMII
,
118 .mac_peripherals
= bfin_mac_peripherals
,
121 static struct platform_device bfin_mii_bus
= {
122 .name
= "bfin_mii_bus",
124 .platform_data
= &bfin_mii_bus_data
,
128 static struct platform_device bfin_mac_device
= {
131 .platform_data
= &bfin_mii_bus
,
136 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
137 static struct resource net2272_bfin_resources
[] = {
140 .end
= 0x20300000 + 0x100,
141 .flags
= IORESOURCE_MEM
,
145 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
149 static struct platform_device net2272_bfin_device
= {
152 .num_resources
= ARRAY_SIZE(net2272_bfin_resources
),
153 .resource
= net2272_bfin_resources
,
157 #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
158 /* all SPI peripherals info goes here */
160 #if defined(CONFIG_MTD_M25P80) \
161 || defined(CONFIG_MTD_M25P80_MODULE)
162 static struct mtd_partition bfin_spi_flash_partitions
[] = {
164 .name
= "bootloader(spi)",
167 .mask_flags
= MTD_CAP_ROM
169 .name
= "linux kernel(spi)",
173 .name
= "file system(spi)",
175 .offset
= 0x00100000,
179 static struct flash_platform_data bfin_spi_flash_data
= {
181 .parts
= bfin_spi_flash_partitions
,
182 .nr_parts
= ARRAY_SIZE(bfin_spi_flash_partitions
),
186 /* SPI flash chip (m25p64) */
187 static struct bfin5xx_spi_chip spi_flash_chip_info
= {
188 .enable_dma
= 0, /* use dma transfer with this chip*/
192 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
193 static struct bfin5xx_spi_chip mmc_spi_chip_info
= {
198 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
199 static const struct ad7877_platform_data bfin_ad7877_ts_info
= {
201 .vref_delay_usecs
= 50, /* internal, no capacitor */
204 .pressure_max
= 1000,
206 .stopacq_polarity
= 1,
207 .first_conversion_delay
= 3,
208 .acquisition_time
= 1,
210 .pen_down_acc_interval
= 1,
214 static struct spi_board_info bfin_spi_board_info
[] __initdata
= {
215 #if defined(CONFIG_MTD_M25P80) \
216 || defined(CONFIG_MTD_M25P80_MODULE)
218 /* the modalias must be the same as spi device driver name */
219 .modalias
= "m25p80", /* Name of spi_driver for this device */
220 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
221 .bus_num
= 0, /* Framework bus number */
222 .chip_select
= 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
223 .platform_data
= &bfin_spi_flash_data
,
224 .controller_data
= &spi_flash_chip_info
,
229 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
230 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
232 .modalias
= "ad183x",
233 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
238 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
240 .modalias
= "mmc_spi",
241 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
244 .controller_data
= &mmc_spi_chip_info
,
248 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
250 .modalias
= "ad7877",
251 .platform_data
= &bfin_ad7877_ts_info
,
253 .max_speed_hz
= 12500000, /* max spi clock (SCK) speed in HZ */
262 static struct resource bfin_spi0_resource
[] = {
264 .start
= SPI0_REGBASE
,
265 .end
= SPI0_REGBASE
+ 0xFF,
266 .flags
= IORESOURCE_MEM
,
271 .flags
= IORESOURCE_DMA
,
276 .flags
= IORESOURCE_IRQ
,
280 /* SPI controller data */
281 static struct bfin5xx_spi_master bfin_spi0_info
= {
283 .enable_dma
= 1, /* master has the ability to do dma transfer */
284 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
287 static struct platform_device bfin_spi0_device
= {
289 .id
= 0, /* Bus number */
290 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
291 .resource
= bfin_spi0_resource
,
293 .platform_data
= &bfin_spi0_info
, /* Passed to driver */
296 #endif /* spi master and devices */
298 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
299 static struct platform_device bfin_fb_device
= {
300 .name
= "bf537-lq035",
304 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
305 #ifdef CONFIG_SERIAL_BFIN_UART0
306 static struct resource bfin_uart0_resources
[] = {
310 .flags
= IORESOURCE_MEM
,
313 .start
= IRQ_UART0_TX
,
315 .flags
= IORESOURCE_IRQ
,
318 .start
= IRQ_UART0_RX
,
320 .flags
= IORESOURCE_IRQ
,
323 .start
= IRQ_UART0_ERROR
,
324 .end
= IRQ_UART0_ERROR
,
325 .flags
= IORESOURCE_IRQ
,
328 .start
= CH_UART0_TX
,
330 .flags
= IORESOURCE_DMA
,
333 .start
= CH_UART0_RX
,
335 .flags
= IORESOURCE_DMA
,
339 static unsigned short bfin_uart0_peripherals
[] = {
340 P_UART0_TX
, P_UART0_RX
, 0
343 static struct platform_device bfin_uart0_device
= {
346 .num_resources
= ARRAY_SIZE(bfin_uart0_resources
),
347 .resource
= bfin_uart0_resources
,
349 .platform_data
= &bfin_uart0_peripherals
, /* Passed to driver */
353 #ifdef CONFIG_SERIAL_BFIN_UART1
354 static struct resource bfin_uart1_resources
[] = {
358 .flags
= IORESOURCE_MEM
,
361 .start
= IRQ_UART1_TX
,
363 .flags
= IORESOURCE_IRQ
,
366 .start
= IRQ_UART1_RX
,
368 .flags
= IORESOURCE_IRQ
,
371 .start
= IRQ_UART1_ERROR
,
372 .end
= IRQ_UART1_ERROR
,
373 .flags
= IORESOURCE_IRQ
,
376 .start
= CH_UART1_TX
,
378 .flags
= IORESOURCE_DMA
,
381 .start
= CH_UART1_RX
,
383 .flags
= IORESOURCE_DMA
,
387 static unsigned short bfin_uart1_peripherals
[] = {
388 P_UART1_TX
, P_UART1_RX
, 0
391 static struct platform_device bfin_uart1_device
= {
394 .num_resources
= ARRAY_SIZE(bfin_uart1_resources
),
395 .resource
= bfin_uart1_resources
,
397 .platform_data
= &bfin_uart1_peripherals
, /* Passed to driver */
403 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
404 #ifdef CONFIG_BFIN_SIR0
405 static struct resource bfin_sir0_resources
[] = {
409 .flags
= IORESOURCE_MEM
,
412 .start
= IRQ_UART0_RX
,
413 .end
= IRQ_UART0_RX
+1,
414 .flags
= IORESOURCE_IRQ
,
417 .start
= CH_UART0_RX
,
418 .end
= CH_UART0_RX
+1,
419 .flags
= IORESOURCE_DMA
,
423 static struct platform_device bfin_sir0_device
= {
426 .num_resources
= ARRAY_SIZE(bfin_sir0_resources
),
427 .resource
= bfin_sir0_resources
,
430 #ifdef CONFIG_BFIN_SIR1
431 static struct resource bfin_sir1_resources
[] = {
435 .flags
= IORESOURCE_MEM
,
438 .start
= IRQ_UART1_RX
,
439 .end
= IRQ_UART1_RX
+1,
440 .flags
= IORESOURCE_IRQ
,
443 .start
= CH_UART1_RX
,
444 .end
= CH_UART1_RX
+1,
445 .flags
= IORESOURCE_DMA
,
449 static struct platform_device bfin_sir1_device
= {
452 .num_resources
= ARRAY_SIZE(bfin_sir1_resources
),
453 .resource
= bfin_sir1_resources
,
458 static struct platform_device
*stamp_devices
[] __initdata
= {
459 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
460 &bfin_pcmcia_cf_device
,
463 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
467 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
471 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
476 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
477 &net2272_bfin_device
,
480 #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
484 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
488 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
489 #ifdef CONFIG_SERIAL_BFIN_UART0
492 #ifdef CONFIG_SERIAL_BFIN_UART1
497 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
498 #ifdef CONFIG_BFIN_SIR0
501 #ifdef CONFIG_BFIN_SIR1
507 static int __init
pnav_init(void)
509 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
510 platform_add_devices(stamp_devices
, ARRAY_SIZE(stamp_devices
));
511 #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
512 spi_register_board_info(bfin_spi_board_info
,
513 ARRAY_SIZE(bfin_spi_board_info
));
518 arch_initcall(pnav_init
);
520 static struct platform_device
*stamp_early_devices
[] __initdata
= {
521 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
522 #ifdef CONFIG_SERIAL_BFIN_UART0
525 #ifdef CONFIG_SERIAL_BFIN_UART1
531 void __init
native_machine_early_platform_add_devices(void)
533 printk(KERN_INFO
"register early platform devices\n");
534 early_platform_add_devices(stamp_early_devices
,
535 ARRAY_SIZE(stamp_early_devices
));
538 void bfin_get_ether_addr(char *addr
)
540 random_ether_addr(addr
);
541 printk(KERN_WARNING
"%s:%s: Setting Ethernet MAC to a random one\n", __FILE__
, __func__
);
543 EXPORT_SYMBOL(bfin_get_ether_addr
);