2 * Copyright 2004-2009 Analog Devices Inc.
3 * 2008-2009 Cambridge Signal Processing
4 * 2005 National ICT Australia (NICTA)
5 * Aidan Williams <aidan@nicta.com.au>
7 * Licensed under the GPL-2 or later.
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/spi/spi.h>
15 #include <linux/spi/flash.h>
16 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
17 #include <linux/usb/isp1362.h>
19 #include <linux/ata_platform.h>
20 #include <linux/irq.h>
21 #include <linux/interrupt.h>
22 #include <linux/usb/sl811.h>
24 #include <asm/bfin5xx_spi.h>
25 #include <asm/reboot.h>
26 #include <asm/portmux.h>
27 #include <linux/spi/ad7877.h>
30 * Name the Board for the /proc/cpuinfo
32 const char bfin_board_name
[] = "CamSig Minotaur BF537";
34 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
35 static struct resource bfin_pcmcia_cf_resources
[] = {
37 .start
= 0x20310000, /* IO PORT */
39 .flags
= IORESOURCE_MEM
,
41 .start
= 0x20311000, /* Attribute Memory */
43 .flags
= IORESOURCE_MEM
,
47 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWLEVEL
,
49 .start
= IRQ_PF6
, /* Card Detect PF6 */
51 .flags
= IORESOURCE_IRQ
,
55 static struct platform_device bfin_pcmcia_cf_device
= {
56 .name
= "bfin_cf_pcmcia",
58 .num_resources
= ARRAY_SIZE(bfin_pcmcia_cf_resources
),
59 .resource
= bfin_pcmcia_cf_resources
,
63 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
64 static struct platform_device rtc_device
= {
70 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
71 #include <linux/bfin_mac.h>
72 static const unsigned short bfin_mac_peripherals
[] = P_MII0
;
74 static struct bfin_phydev_platform_data bfin_phydev_data
[] = {
77 .irq
= IRQ_MAC_PHYINT
,
81 static struct bfin_mii_bus_platform_data bfin_mii_bus_data
= {
83 .phydev_data
= bfin_phydev_data
,
84 .phy_mode
= PHY_INTERFACE_MODE_MII
,
85 .mac_peripherals
= bfin_mac_peripherals
,
88 static struct platform_device bfin_mii_bus
= {
89 .name
= "bfin_mii_bus",
91 .platform_data
= &bfin_mii_bus_data
,
95 static struct platform_device bfin_mac_device
= {
98 .platform_data
= &bfin_mii_bus
,
103 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
104 static struct resource net2272_bfin_resources
[] = {
107 .end
= 0x20300000 + 0x100,
108 .flags
= IORESOURCE_MEM
,
112 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
116 static struct platform_device net2272_bfin_device
= {
119 .num_resources
= ARRAY_SIZE(net2272_bfin_resources
),
120 .resource
= net2272_bfin_resources
,
124 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
125 /* all SPI peripherals info goes here */
127 #if defined(CONFIG_MTD_M25P80) \
128 || defined(CONFIG_MTD_M25P80_MODULE)
130 /* Partition sizes */
131 #define FLASH_SIZE 0x00400000
132 #define PSIZE_UBOOT 0x00030000
133 #define PSIZE_INITRAMFS 0x00240000
135 static struct mtd_partition bfin_spi_flash_partitions
[] = {
137 .name
= "bootloader(spi)",
140 .mask_flags
= MTD_CAP_ROM
142 .name
= "initramfs(spi)",
143 .size
= PSIZE_INITRAMFS
,
144 .offset
= PSIZE_UBOOT
147 .size
= FLASH_SIZE
- (PSIZE_UBOOT
+ PSIZE_INITRAMFS
),
148 .offset
= PSIZE_UBOOT
+ PSIZE_INITRAMFS
,
152 static struct flash_platform_data bfin_spi_flash_data
= {
154 .parts
= bfin_spi_flash_partitions
,
155 .nr_parts
= ARRAY_SIZE(bfin_spi_flash_partitions
),
159 /* SPI flash chip (m25p64) */
160 static struct bfin5xx_spi_chip spi_flash_chip_info
= {
161 .enable_dma
= 0, /* use dma transfer with this chip*/
165 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
166 static struct bfin5xx_spi_chip mmc_spi_chip_info
= {
171 static struct spi_board_info bfin_spi_board_info
[] __initdata
= {
172 #if defined(CONFIG_MTD_M25P80) \
173 || defined(CONFIG_MTD_M25P80_MODULE)
175 /* the modalias must be the same as spi device driver name */
176 .modalias
= "m25p80", /* Name of spi_driver for this device */
177 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
178 .bus_num
= 0, /* Framework bus number */
179 .chip_select
= 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
180 .platform_data
= &bfin_spi_flash_data
,
181 .controller_data
= &spi_flash_chip_info
,
186 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
188 .modalias
= "mmc_spi",
189 .max_speed_hz
= 5000000, /* max spi clock (SCK) speed in HZ */
192 .controller_data
= &mmc_spi_chip_info
,
198 /* SPI controller data */
199 static struct bfin5xx_spi_master bfin_spi0_info
= {
201 .enable_dma
= 1, /* master has the ability to do dma transfer */
205 static struct resource bfin_spi0_resource
[] = {
207 .start
= SPI0_REGBASE
,
208 .end
= SPI0_REGBASE
+ 0xFF,
209 .flags
= IORESOURCE_MEM
,
214 .flags
= IORESOURCE_DMA
,
219 .flags
= IORESOURCE_IRQ
,
223 static struct platform_device bfin_spi0_device
= {
225 .id
= 0, /* Bus number */
226 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
227 .resource
= bfin_spi0_resource
,
229 .platform_data
= &bfin_spi0_info
, /* Passed to driver */
232 #endif /* spi master and devices */
234 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
235 #ifdef CONFIG_SERIAL_BFIN_UART0
236 static struct resource bfin_uart0_resources
[] = {
240 .flags
= IORESOURCE_MEM
,
243 .start
= IRQ_UART0_TX
,
245 .flags
= IORESOURCE_IRQ
,
248 .start
= IRQ_UART0_RX
,
250 .flags
= IORESOURCE_IRQ
,
253 .start
= IRQ_UART0_ERROR
,
254 .end
= IRQ_UART0_ERROR
,
255 .flags
= IORESOURCE_IRQ
,
258 .start
= CH_UART0_TX
,
260 .flags
= IORESOURCE_DMA
,
263 .start
= CH_UART0_RX
,
265 .flags
= IORESOURCE_DMA
,
269 static unsigned short bfin_uart0_peripherals
[] = {
270 P_UART0_TX
, P_UART0_RX
, 0
273 static struct platform_device bfin_uart0_device
= {
276 .num_resources
= ARRAY_SIZE(bfin_uart0_resources
),
277 .resource
= bfin_uart0_resources
,
279 .platform_data
= &bfin_uart0_peripherals
, /* Passed to driver */
283 #ifdef CONFIG_SERIAL_BFIN_UART1
284 static struct resource bfin_uart1_resources
[] = {
288 .flags
= IORESOURCE_MEM
,
291 .start
= IRQ_UART1_TX
,
293 .flags
= IORESOURCE_IRQ
,
296 .start
= IRQ_UART1_RX
,
298 .flags
= IORESOURCE_IRQ
,
301 .start
= IRQ_UART1_ERROR
,
302 .end
= IRQ_UART1_ERROR
,
303 .flags
= IORESOURCE_IRQ
,
306 .start
= CH_UART1_TX
,
308 .flags
= IORESOURCE_DMA
,
311 .start
= CH_UART1_RX
,
313 .flags
= IORESOURCE_DMA
,
317 static unsigned short bfin_uart1_peripherals
[] = {
318 P_UART1_TX
, P_UART1_RX
, 0
321 static struct platform_device bfin_uart1_device
= {
324 .num_resources
= ARRAY_SIZE(bfin_uart1_resources
),
325 .resource
= bfin_uart1_resources
,
327 .platform_data
= &bfin_uart1_peripherals
, /* Passed to driver */
333 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
334 #ifdef CONFIG_BFIN_SIR0
335 static struct resource bfin_sir0_resources
[] = {
339 .flags
= IORESOURCE_MEM
,
342 .start
= IRQ_UART0_RX
,
343 .end
= IRQ_UART0_RX
+1,
344 .flags
= IORESOURCE_IRQ
,
347 .start
= CH_UART0_RX
,
348 .end
= CH_UART0_RX
+1,
349 .flags
= IORESOURCE_DMA
,
353 static struct platform_device bfin_sir0_device
= {
356 .num_resources
= ARRAY_SIZE(bfin_sir0_resources
),
357 .resource
= bfin_sir0_resources
,
360 #ifdef CONFIG_BFIN_SIR1
361 static struct resource bfin_sir1_resources
[] = {
365 .flags
= IORESOURCE_MEM
,
368 .start
= IRQ_UART1_RX
,
369 .end
= IRQ_UART1_RX
+1,
370 .flags
= IORESOURCE_IRQ
,
373 .start
= CH_UART1_RX
,
374 .end
= CH_UART1_RX
+1,
375 .flags
= IORESOURCE_DMA
,
379 static struct platform_device bfin_sir1_device
= {
382 .num_resources
= ARRAY_SIZE(bfin_sir1_resources
),
383 .resource
= bfin_sir1_resources
,
388 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
389 static struct resource bfin_twi0_resource
[] = {
391 .start
= TWI0_REGBASE
,
392 .end
= TWI0_REGBASE
+ 0xFF,
393 .flags
= IORESOURCE_MEM
,
398 .flags
= IORESOURCE_IRQ
,
402 static struct platform_device i2c_bfin_twi_device
= {
403 .name
= "i2c-bfin-twi",
405 .num_resources
= ARRAY_SIZE(bfin_twi0_resource
),
406 .resource
= bfin_twi0_resource
,
410 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
411 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
412 static struct resource bfin_sport0_uart_resources
[] = {
414 .start
= SPORT0_TCR1
,
415 .end
= SPORT0_MRCS3
+4,
416 .flags
= IORESOURCE_MEM
,
419 .start
= IRQ_SPORT0_RX
,
420 .end
= IRQ_SPORT0_RX
+1,
421 .flags
= IORESOURCE_IRQ
,
424 .start
= IRQ_SPORT0_ERROR
,
425 .end
= IRQ_SPORT0_ERROR
,
426 .flags
= IORESOURCE_IRQ
,
430 static unsigned short bfin_sport0_peripherals
[] = {
431 P_SPORT0_TFS
, P_SPORT0_DTPRI
, P_SPORT0_TSCLK
, P_SPORT0_RFS
,
432 P_SPORT0_DRPRI
, P_SPORT0_RSCLK
, 0
435 static struct platform_device bfin_sport0_uart_device
= {
436 .name
= "bfin-sport-uart",
438 .num_resources
= ARRAY_SIZE(bfin_sport0_uart_resources
),
439 .resource
= bfin_sport0_uart_resources
,
441 .platform_data
= &bfin_sport0_peripherals
, /* Passed to driver */
445 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
446 static struct resource bfin_sport1_uart_resources
[] = {
448 .start
= SPORT1_TCR1
,
449 .end
= SPORT1_MRCS3
+4,
450 .flags
= IORESOURCE_MEM
,
453 .start
= IRQ_SPORT1_RX
,
454 .end
= IRQ_SPORT1_RX
+1,
455 .flags
= IORESOURCE_IRQ
,
458 .start
= IRQ_SPORT1_ERROR
,
459 .end
= IRQ_SPORT1_ERROR
,
460 .flags
= IORESOURCE_IRQ
,
464 static unsigned short bfin_sport1_peripherals
[] = {
465 P_SPORT1_TFS
, P_SPORT1_DTPRI
, P_SPORT1_TSCLK
, P_SPORT1_RFS
,
466 P_SPORT1_DRPRI
, P_SPORT1_RSCLK
, 0
469 static struct platform_device bfin_sport1_uart_device
= {
470 .name
= "bfin-sport-uart",
472 .num_resources
= ARRAY_SIZE(bfin_sport1_uart_resources
),
473 .resource
= bfin_sport1_uart_resources
,
475 .platform_data
= &bfin_sport1_peripherals
, /* Passed to driver */
481 static struct platform_device
*minotaur_devices
[] __initdata
= {
482 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
483 &bfin_pcmcia_cf_device
,
486 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
490 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
495 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
496 &net2272_bfin_device
,
499 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
503 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
504 #ifdef CONFIG_SERIAL_BFIN_UART0
507 #ifdef CONFIG_SERIAL_BFIN_UART1
512 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
513 #ifdef CONFIG_BFIN_SIR0
516 #ifdef CONFIG_BFIN_SIR1
521 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
522 &i2c_bfin_twi_device
,
525 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
526 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
527 &bfin_sport0_uart_device
,
529 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
530 &bfin_sport1_uart_device
,
536 static int __init
minotaur_init(void)
538 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
539 platform_add_devices(minotaur_devices
, ARRAY_SIZE(minotaur_devices
));
540 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
541 spi_register_board_info(bfin_spi_board_info
,
542 ARRAY_SIZE(bfin_spi_board_info
));
548 arch_initcall(minotaur_init
);
550 static struct platform_device
*minotaur_early_devices
[] __initdata
= {
551 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
552 #ifdef CONFIG_SERIAL_BFIN_UART0
555 #ifdef CONFIG_SERIAL_BFIN_UART1
560 #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
561 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
562 &bfin_sport0_uart_device
,
564 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
565 &bfin_sport1_uart_device
,
570 void __init
native_machine_early_platform_add_devices(void)
572 printk(KERN_INFO
"register early platform devices\n");
573 early_platform_add_devices(minotaur_early_devices
,
574 ARRAY_SIZE(minotaur_early_devices
));
577 void native_machine_restart(char *cmd
)
579 /* workaround reboot hang when booting from SPI */
580 if ((bfin_read_SYSCR() & 0x7) == 0x3)
581 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS
);