2 * Copyright 2004-2009 Analog Devices Inc.
3 * 2008-2009 Bluetechnix
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/etherdevice.h>
12 #include <linux/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/mtd/physmap.h>
16 #include <linux/spi/spi.h>
17 #include <linux/spi/flash.h>
18 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
19 #include <linux/usb/isp1362.h>
21 #include <linux/ata_platform.h>
22 #include <linux/irq.h>
24 #include <asm/bfin5xx_spi.h>
25 #include <asm/portmux.h>
29 * Name the Board for the /proc/cpuinfo
31 const char bfin_board_name
[] = "Bluetechnix CM BF537E";
33 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
34 /* all SPI peripherals info goes here */
36 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
37 static struct mtd_partition bfin_spi_flash_partitions
[] = {
39 .name
= "bootloader(spi)",
42 .mask_flags
= MTD_CAP_ROM
44 .name
= "linux kernel(spi)",
48 .name
= "file system(spi)",
54 static struct flash_platform_data bfin_spi_flash_data
= {
56 .parts
= bfin_spi_flash_partitions
,
57 .nr_parts
= ARRAY_SIZE(bfin_spi_flash_partitions
),
61 /* SPI flash chip (m25p64) */
62 static struct bfin5xx_spi_chip spi_flash_chip_info
= {
63 .enable_dma
= 0, /* use dma transfer with this chip*/
67 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
68 static struct bfin5xx_spi_chip mmc_spi_chip_info
= {
73 static struct spi_board_info bfin_spi_board_info
[] __initdata
= {
74 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
76 /* the modalias must be the same as spi device driver name */
77 .modalias
= "m25p80", /* Name of spi_driver for this device */
78 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
79 .bus_num
= 0, /* Framework bus number */
80 .chip_select
= 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
81 .platform_data
= &bfin_spi_flash_data
,
82 .controller_data
= &spi_flash_chip_info
,
87 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
90 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
96 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
98 .modalias
= "mmc_spi",
99 .max_speed_hz
= 20000000, /* max spi clock (SCK) speed in HZ */
102 .controller_data
= &mmc_spi_chip_info
,
109 static struct resource bfin_spi0_resource
[] = {
111 .start
= SPI0_REGBASE
,
112 .end
= SPI0_REGBASE
+ 0xFF,
113 .flags
= IORESOURCE_MEM
,
118 .flags
= IORESOURCE_DMA
,
123 .flags
= IORESOURCE_IRQ
,
127 /* SPI controller data */
128 static struct bfin5xx_spi_master bfin_spi0_info
= {
130 .enable_dma
= 1, /* master has the ability to do dma transfer */
131 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
134 static struct platform_device bfin_spi0_device
= {
136 .id
= 0, /* Bus number */
137 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
138 .resource
= bfin_spi0_resource
,
140 .platform_data
= &bfin_spi0_info
, /* Passed to driver */
143 #endif /* spi master and devices */
145 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
146 static struct platform_device rtc_device
= {
152 #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
153 static struct platform_device hitachi_fb_device
= {
154 .name
= "hitachi-tx09",
158 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
159 #include <linux/smc91x.h>
161 static struct smc91x_platdata smc91x_info
= {
162 .flags
= SMC91X_USE_16BIT
| SMC91X_NOWAIT
,
163 .leda
= RPC_LED_100_10
,
164 .ledb
= RPC_LED_TX_RX
,
167 static struct resource smc91x_resources
[] = {
170 .end
= 0x20200300 + 16,
171 .flags
= IORESOURCE_MEM
,
175 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
179 static struct platform_device smc91x_device
= {
182 .num_resources
= ARRAY_SIZE(smc91x_resources
),
183 .resource
= smc91x_resources
,
185 .platform_data
= &smc91x_info
,
190 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
191 static struct resource isp1362_hcd_resources
[] = {
195 .flags
= IORESOURCE_MEM
,
199 .flags
= IORESOURCE_MEM
,
203 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWEDGE
,
207 static struct isp1362_platform_data isp1362_priv
= {
212 .int_edge_triggered
= 0,
213 .remote_wakeup_connected
= 0,
214 .no_power_switching
= 1,
215 .power_switching_mode
= 0,
218 static struct platform_device isp1362_hcd_device
= {
219 .name
= "isp1362-hcd",
222 .platform_data
= &isp1362_priv
,
224 .num_resources
= ARRAY_SIZE(isp1362_hcd_resources
),
225 .resource
= isp1362_hcd_resources
,
229 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
230 static struct resource net2272_bfin_resources
[] = {
233 .end
= 0x20300000 + 0x100,
234 .flags
= IORESOURCE_MEM
,
238 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
242 static struct platform_device net2272_bfin_device
= {
245 .num_resources
= ARRAY_SIZE(net2272_bfin_resources
),
246 .resource
= net2272_bfin_resources
,
250 #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
251 static struct mtd_partition cm_partitions
[] = {
253 .name
= "bootloader(nor)",
257 .name
= "linux kernel(nor)",
259 .offset
= MTDPART_OFS_APPEND
,
261 .name
= "file system(nor)",
262 .size
= MTDPART_SIZ_FULL
,
263 .offset
= MTDPART_OFS_APPEND
,
267 static struct physmap_flash_data cm_flash_data
= {
269 .parts
= cm_partitions
,
270 .nr_parts
= ARRAY_SIZE(cm_partitions
),
273 static unsigned cm_flash_gpios
[] = { GPIO_PF4
};
275 static struct resource cm_flash_resource
[] = {
280 .flags
= IORESOURCE_MEM
,
282 .start
= (unsigned long)cm_flash_gpios
,
283 .end
= ARRAY_SIZE(cm_flash_gpios
),
284 .flags
= IORESOURCE_IRQ
,
288 static struct platform_device cm_flash_device
= {
289 .name
= "gpio-addr-flash",
292 .platform_data
= &cm_flash_data
,
294 .num_resources
= ARRAY_SIZE(cm_flash_resource
),
295 .resource
= cm_flash_resource
,
299 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
300 #ifdef CONFIG_SERIAL_BFIN_UART0
301 static struct resource bfin_uart0_resources
[] = {
305 .flags
= IORESOURCE_MEM
,
308 .start
= IRQ_UART0_RX
,
309 .end
= IRQ_UART0_RX
+1,
310 .flags
= IORESOURCE_IRQ
,
313 .start
= IRQ_UART0_ERROR
,
314 .end
= IRQ_UART0_ERROR
,
315 .flags
= IORESOURCE_IRQ
,
318 .start
= CH_UART0_TX
,
320 .flags
= IORESOURCE_DMA
,
323 .start
= CH_UART0_RX
,
325 .flags
= IORESOURCE_DMA
,
327 #ifdef CONFIG_BFIN_UART0_CTSRTS
330 * Refer to arch/blackfin/mach-xxx/include/mach/gpio.h for the GPIO map.
334 .flags
= IORESOURCE_IO
,
338 * Refer to arch/blackfin/mach-xxx/include/mach/gpio.h for the GPIO map.
342 .flags
= IORESOURCE_IO
,
347 static unsigned short bfin_uart0_peripherals
[] = {
348 P_UART0_TX
, P_UART0_RX
, 0
351 static struct platform_device bfin_uart0_device
= {
354 .num_resources
= ARRAY_SIZE(bfin_uart0_resources
),
355 .resource
= bfin_uart0_resources
,
357 .platform_data
= &bfin_uart0_peripherals
, /* Passed to driver */
361 #ifdef CONFIG_SERIAL_BFIN_UART1
362 static struct resource bfin_uart1_resources
[] = {
366 .flags
= IORESOURCE_MEM
,
369 .start
= IRQ_UART1_RX
,
370 .end
= IRQ_UART1_RX
+1,
371 .flags
= IORESOURCE_IRQ
,
374 .start
= IRQ_UART1_ERROR
,
375 .end
= IRQ_UART1_ERROR
,
376 .flags
= IORESOURCE_IRQ
,
379 .start
= CH_UART1_TX
,
381 .flags
= IORESOURCE_DMA
,
384 .start
= CH_UART1_RX
,
386 .flags
= IORESOURCE_DMA
,
388 #ifdef CONFIG_BFIN_UART1_CTSRTS
391 * Refer to arch/blackfin/mach-xxx/include/mach/gpio.h for the GPIO map.
395 .flags
= IORESOURCE_IO
,
399 * Refer to arch/blackfin/mach-xxx/include/mach/gpio.h for the GPIO map.
403 .flags
= IORESOURCE_IO
,
408 static unsigned short bfin_uart1_peripherals
[] = {
409 P_UART1_TX
, P_UART1_RX
, 0
412 static struct platform_device bfin_uart1_device
= {
415 .num_resources
= ARRAY_SIZE(bfin_uart1_resources
),
416 .resource
= bfin_uart1_resources
,
418 .platform_data
= &bfin_uart1_peripherals
, /* Passed to driver */
424 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
425 #ifdef CONFIG_BFIN_SIR0
426 static struct resource bfin_sir0_resources
[] = {
430 .flags
= IORESOURCE_MEM
,
433 .start
= IRQ_UART0_RX
,
434 .end
= IRQ_UART0_RX
+1,
435 .flags
= IORESOURCE_IRQ
,
438 .start
= CH_UART0_RX
,
439 .end
= CH_UART0_RX
+1,
440 .flags
= IORESOURCE_DMA
,
443 static struct platform_device bfin_sir0_device
= {
446 .num_resources
= ARRAY_SIZE(bfin_sir0_resources
),
447 .resource
= bfin_sir0_resources
,
450 #ifdef CONFIG_BFIN_SIR1
451 static struct resource bfin_sir1_resources
[] = {
455 .flags
= IORESOURCE_MEM
,
458 .start
= IRQ_UART1_RX
,
459 .end
= IRQ_UART1_RX
+1,
460 .flags
= IORESOURCE_IRQ
,
463 .start
= CH_UART1_RX
,
464 .end
= CH_UART1_RX
+1,
465 .flags
= IORESOURCE_DMA
,
468 static struct platform_device bfin_sir1_device
= {
471 .num_resources
= ARRAY_SIZE(bfin_sir1_resources
),
472 .resource
= bfin_sir1_resources
,
477 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
478 static struct resource bfin_twi0_resource
[] = {
480 .start
= TWI0_REGBASE
,
482 .flags
= IORESOURCE_MEM
,
487 .flags
= IORESOURCE_IRQ
,
491 static struct platform_device i2c_bfin_twi_device
= {
492 .name
= "i2c-bfin-twi",
494 .num_resources
= ARRAY_SIZE(bfin_twi0_resource
),
495 .resource
= bfin_twi0_resource
,
499 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
500 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
501 static struct resource bfin_sport0_uart_resources
[] = {
503 .start
= SPORT0_TCR1
,
504 .end
= SPORT0_MRCS3
+4,
505 .flags
= IORESOURCE_MEM
,
508 .start
= IRQ_SPORT0_RX
,
509 .end
= IRQ_SPORT0_RX
+1,
510 .flags
= IORESOURCE_IRQ
,
513 .start
= IRQ_SPORT0_ERROR
,
514 .end
= IRQ_SPORT0_ERROR
,
515 .flags
= IORESOURCE_IRQ
,
519 static unsigned short bfin_sport0_peripherals
[] = {
520 P_SPORT0_TFS
, P_SPORT0_DTPRI
, P_SPORT0_TSCLK
, P_SPORT0_RFS
,
521 P_SPORT0_DRPRI
, P_SPORT0_RSCLK
, 0
524 static struct platform_device bfin_sport0_uart_device
= {
525 .name
= "bfin-sport-uart",
527 .num_resources
= ARRAY_SIZE(bfin_sport0_uart_resources
),
528 .resource
= bfin_sport0_uart_resources
,
530 .platform_data
= &bfin_sport0_peripherals
, /* Passed to driver */
534 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
535 static struct resource bfin_sport1_uart_resources
[] = {
537 .start
= SPORT1_TCR1
,
538 .end
= SPORT1_MRCS3
+4,
539 .flags
= IORESOURCE_MEM
,
542 .start
= IRQ_SPORT1_RX
,
543 .end
= IRQ_SPORT1_RX
+1,
544 .flags
= IORESOURCE_IRQ
,
547 .start
= IRQ_SPORT1_ERROR
,
548 .end
= IRQ_SPORT1_ERROR
,
549 .flags
= IORESOURCE_IRQ
,
553 static unsigned short bfin_sport1_peripherals
[] = {
554 P_SPORT1_TFS
, P_SPORT1_DTPRI
, P_SPORT1_TSCLK
, P_SPORT1_RFS
,
555 P_SPORT1_DRPRI
, P_SPORT1_RSCLK
, 0
558 static struct platform_device bfin_sport1_uart_device
= {
559 .name
= "bfin-sport-uart",
561 .num_resources
= ARRAY_SIZE(bfin_sport1_uart_resources
),
562 .resource
= bfin_sport1_uart_resources
,
564 .platform_data
= &bfin_sport1_peripherals
, /* Passed to driver */
570 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
571 #include <linux/bfin_mac.h>
572 static const unsigned short bfin_mac_peripherals
[] = P_MII0
;
574 static struct bfin_phydev_platform_data bfin_phydev_data
[] = {
577 .irq
= IRQ_MAC_PHYINT
,
581 static struct bfin_mii_bus_platform_data bfin_mii_bus_data
= {
583 .phydev_data
= bfin_phydev_data
,
584 .phy_mode
= PHY_INTERFACE_MODE_MII
,
585 .mac_peripherals
= bfin_mac_peripherals
,
588 static struct platform_device bfin_mii_bus
= {
589 .name
= "bfin_mii_bus",
591 .platform_data
= &bfin_mii_bus_data
,
595 static struct platform_device bfin_mac_device
= {
598 .platform_data
= &bfin_mii_bus
,
603 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
604 #define PATA_INT IRQ_PF14
606 static struct pata_platform_info bfin_pata_platform_data
= {
608 .irq_type
= IRQF_TRIGGER_HIGH
| IRQF_DISABLED
,
611 static struct resource bfin_pata_resources
[] = {
615 .flags
= IORESOURCE_MEM
,
620 .flags
= IORESOURCE_MEM
,
625 .flags
= IORESOURCE_IRQ
,
629 static struct platform_device bfin_pata_device
= {
630 .name
= "pata_platform",
632 .num_resources
= ARRAY_SIZE(bfin_pata_resources
),
633 .resource
= bfin_pata_resources
,
635 .platform_data
= &bfin_pata_platform_data
,
640 static const unsigned int cclk_vlev_datasheet
[] =
642 VRPAIR(VLEV_085
, 250000000),
643 VRPAIR(VLEV_090
, 376000000),
644 VRPAIR(VLEV_095
, 426000000),
645 VRPAIR(VLEV_100
, 426000000),
646 VRPAIR(VLEV_105
, 476000000),
647 VRPAIR(VLEV_110
, 476000000),
648 VRPAIR(VLEV_115
, 476000000),
649 VRPAIR(VLEV_120
, 500000000),
650 VRPAIR(VLEV_125
, 533000000),
651 VRPAIR(VLEV_130
, 600000000),
654 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
655 .tuple_tab
= cclk_vlev_datasheet
,
656 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
657 .vr_settling_time
= 25 /* us */,
660 static struct platform_device bfin_dpmc
= {
663 .platform_data
= &bfin_dmpc_vreg_data
,
667 static struct platform_device
*cm_bf537e_devices
[] __initdata
= {
671 #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
675 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
679 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
680 #ifdef CONFIG_SERIAL_BFIN_UART0
683 #ifdef CONFIG_SERIAL_BFIN_UART1
688 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
689 #ifdef CONFIG_BFIN_SIR0
692 #ifdef CONFIG_BFIN_SIR1
697 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
698 &i2c_bfin_twi_device
,
701 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
702 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
703 &bfin_sport0_uart_device
,
705 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
706 &bfin_sport1_uart_device
,
710 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
714 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
718 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
723 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
724 &net2272_bfin_device
,
727 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
731 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
735 #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
740 static int __init
net2272_init(void)
742 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
745 ret
= gpio_request(GPIO_PG14
, "net2272");
749 /* Reset USB Chip, PG14 */
750 gpio_direction_output(GPIO_PG14
, 0);
752 gpio_set_value(GPIO_PG14
, 1);
758 static int __init
cm_bf537e_init(void)
760 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
761 platform_add_devices(cm_bf537e_devices
, ARRAY_SIZE(cm_bf537e_devices
));
762 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
763 spi_register_board_info(bfin_spi_board_info
, ARRAY_SIZE(bfin_spi_board_info
));
766 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
767 irq_set_status_flags(PATA_INT
, IRQ_NOAUTOEN
);
771 pr_warning("unable to configure net2272; it probably won't work\n");
776 arch_initcall(cm_bf537e_init
);
778 static struct platform_device
*cm_bf537e_early_devices
[] __initdata
= {
779 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
780 #ifdef CONFIG_SERIAL_BFIN_UART0
783 #ifdef CONFIG_SERIAL_BFIN_UART1
788 #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
789 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
790 &bfin_sport0_uart_device
,
792 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
793 &bfin_sport1_uart_device
,
798 void __init
native_machine_early_platform_add_devices(void)
800 printk(KERN_INFO
"register early platform devices\n");
801 early_platform_add_devices(cm_bf537e_early_devices
,
802 ARRAY_SIZE(cm_bf537e_early_devices
));
805 void bfin_get_ether_addr(char *addr
)
807 random_ether_addr(addr
);
808 printk(KERN_WARNING
"%s:%s: Setting Ethernet MAC to a random one\n", __FILE__
, __func__
);
810 EXPORT_SYMBOL(bfin_get_ether_addr
);