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_TX
,
310 .flags
= IORESOURCE_IRQ
,
313 .start
= IRQ_UART0_RX
,
315 .flags
= IORESOURCE_IRQ
,
318 .start
= IRQ_UART0_ERROR
,
319 .end
= IRQ_UART0_ERROR
,
320 .flags
= IORESOURCE_IRQ
,
323 .start
= CH_UART0_TX
,
325 .flags
= IORESOURCE_DMA
,
328 .start
= CH_UART0_RX
,
330 .flags
= IORESOURCE_DMA
,
332 #ifdef CONFIG_BFIN_UART0_CTSRTS
335 * Refer to arch/blackfin/mach-xxx/include/mach/gpio.h for the GPIO map.
339 .flags
= IORESOURCE_IO
,
343 * Refer to arch/blackfin/mach-xxx/include/mach/gpio.h for the GPIO map.
347 .flags
= IORESOURCE_IO
,
352 static unsigned short bfin_uart0_peripherals
[] = {
353 P_UART0_TX
, P_UART0_RX
, 0
356 static struct platform_device bfin_uart0_device
= {
359 .num_resources
= ARRAY_SIZE(bfin_uart0_resources
),
360 .resource
= bfin_uart0_resources
,
362 .platform_data
= &bfin_uart0_peripherals
, /* Passed to driver */
366 #ifdef CONFIG_SERIAL_BFIN_UART1
367 static struct resource bfin_uart1_resources
[] = {
371 .flags
= IORESOURCE_MEM
,
374 .start
= IRQ_UART1_TX
,
376 .flags
= IORESOURCE_IRQ
,
379 .start
= IRQ_UART1_RX
,
381 .flags
= IORESOURCE_IRQ
,
384 .start
= IRQ_UART1_ERROR
,
385 .end
= IRQ_UART1_ERROR
,
386 .flags
= IORESOURCE_IRQ
,
389 .start
= CH_UART1_TX
,
391 .flags
= IORESOURCE_DMA
,
394 .start
= CH_UART1_RX
,
396 .flags
= IORESOURCE_DMA
,
398 #ifdef CONFIG_BFIN_UART1_CTSRTS
401 * Refer to arch/blackfin/mach-xxx/include/mach/gpio.h for the GPIO map.
405 .flags
= IORESOURCE_IO
,
409 * Refer to arch/blackfin/mach-xxx/include/mach/gpio.h for the GPIO map.
413 .flags
= IORESOURCE_IO
,
418 static unsigned short bfin_uart1_peripherals
[] = {
419 P_UART1_TX
, P_UART1_RX
, 0
422 static struct platform_device bfin_uart1_device
= {
425 .num_resources
= ARRAY_SIZE(bfin_uart1_resources
),
426 .resource
= bfin_uart1_resources
,
428 .platform_data
= &bfin_uart1_peripherals
, /* Passed to driver */
434 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
435 #ifdef CONFIG_BFIN_SIR0
436 static struct resource bfin_sir0_resources
[] = {
440 .flags
= IORESOURCE_MEM
,
443 .start
= IRQ_UART0_RX
,
444 .end
= IRQ_UART0_RX
+1,
445 .flags
= IORESOURCE_IRQ
,
448 .start
= CH_UART0_RX
,
449 .end
= CH_UART0_RX
+1,
450 .flags
= IORESOURCE_DMA
,
453 static struct platform_device bfin_sir0_device
= {
456 .num_resources
= ARRAY_SIZE(bfin_sir0_resources
),
457 .resource
= bfin_sir0_resources
,
460 #ifdef CONFIG_BFIN_SIR1
461 static struct resource bfin_sir1_resources
[] = {
465 .flags
= IORESOURCE_MEM
,
468 .start
= IRQ_UART1_RX
,
469 .end
= IRQ_UART1_RX
+1,
470 .flags
= IORESOURCE_IRQ
,
473 .start
= CH_UART1_RX
,
474 .end
= CH_UART1_RX
+1,
475 .flags
= IORESOURCE_DMA
,
478 static struct platform_device bfin_sir1_device
= {
481 .num_resources
= ARRAY_SIZE(bfin_sir1_resources
),
482 .resource
= bfin_sir1_resources
,
487 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
488 static struct resource bfin_twi0_resource
[] = {
490 .start
= TWI0_REGBASE
,
492 .flags
= IORESOURCE_MEM
,
497 .flags
= IORESOURCE_IRQ
,
501 static struct platform_device i2c_bfin_twi_device
= {
502 .name
= "i2c-bfin-twi",
504 .num_resources
= ARRAY_SIZE(bfin_twi0_resource
),
505 .resource
= bfin_twi0_resource
,
509 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
510 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
511 static struct resource bfin_sport0_uart_resources
[] = {
513 .start
= SPORT0_TCR1
,
514 .end
= SPORT0_MRCS3
+4,
515 .flags
= IORESOURCE_MEM
,
518 .start
= IRQ_SPORT0_RX
,
519 .end
= IRQ_SPORT0_RX
+1,
520 .flags
= IORESOURCE_IRQ
,
523 .start
= IRQ_SPORT0_ERROR
,
524 .end
= IRQ_SPORT0_ERROR
,
525 .flags
= IORESOURCE_IRQ
,
529 static unsigned short bfin_sport0_peripherals
[] = {
530 P_SPORT0_TFS
, P_SPORT0_DTPRI
, P_SPORT0_TSCLK
, P_SPORT0_RFS
,
531 P_SPORT0_DRPRI
, P_SPORT0_RSCLK
, 0
534 static struct platform_device bfin_sport0_uart_device
= {
535 .name
= "bfin-sport-uart",
537 .num_resources
= ARRAY_SIZE(bfin_sport0_uart_resources
),
538 .resource
= bfin_sport0_uart_resources
,
540 .platform_data
= &bfin_sport0_peripherals
, /* Passed to driver */
544 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
545 static struct resource bfin_sport1_uart_resources
[] = {
547 .start
= SPORT1_TCR1
,
548 .end
= SPORT1_MRCS3
+4,
549 .flags
= IORESOURCE_MEM
,
552 .start
= IRQ_SPORT1_RX
,
553 .end
= IRQ_SPORT1_RX
+1,
554 .flags
= IORESOURCE_IRQ
,
557 .start
= IRQ_SPORT1_ERROR
,
558 .end
= IRQ_SPORT1_ERROR
,
559 .flags
= IORESOURCE_IRQ
,
563 static unsigned short bfin_sport1_peripherals
[] = {
564 P_SPORT1_TFS
, P_SPORT1_DTPRI
, P_SPORT1_TSCLK
, P_SPORT1_RFS
,
565 P_SPORT1_DRPRI
, P_SPORT1_RSCLK
, 0
568 static struct platform_device bfin_sport1_uart_device
= {
569 .name
= "bfin-sport-uart",
571 .num_resources
= ARRAY_SIZE(bfin_sport1_uart_resources
),
572 .resource
= bfin_sport1_uart_resources
,
574 .platform_data
= &bfin_sport1_peripherals
, /* Passed to driver */
580 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
581 #include <linux/bfin_mac.h>
582 static const unsigned short bfin_mac_peripherals
[] = P_MII0
;
584 static struct bfin_phydev_platform_data bfin_phydev_data
[] = {
587 .irq
= IRQ_MAC_PHYINT
,
591 static struct bfin_mii_bus_platform_data bfin_mii_bus_data
= {
593 .phydev_data
= bfin_phydev_data
,
594 .phy_mode
= PHY_INTERFACE_MODE_MII
,
595 .mac_peripherals
= bfin_mac_peripherals
,
598 static struct platform_device bfin_mii_bus
= {
599 .name
= "bfin_mii_bus",
601 .platform_data
= &bfin_mii_bus_data
,
605 static struct platform_device bfin_mac_device
= {
608 .platform_data
= &bfin_mii_bus
,
613 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
614 #define PATA_INT IRQ_PF14
616 static struct pata_platform_info bfin_pata_platform_data
= {
618 .irq_type
= IRQF_TRIGGER_HIGH
| IRQF_DISABLED
,
621 static struct resource bfin_pata_resources
[] = {
625 .flags
= IORESOURCE_MEM
,
630 .flags
= IORESOURCE_MEM
,
635 .flags
= IORESOURCE_IRQ
,
639 static struct platform_device bfin_pata_device
= {
640 .name
= "pata_platform",
642 .num_resources
= ARRAY_SIZE(bfin_pata_resources
),
643 .resource
= bfin_pata_resources
,
645 .platform_data
= &bfin_pata_platform_data
,
650 static const unsigned int cclk_vlev_datasheet
[] =
652 VRPAIR(VLEV_085
, 250000000),
653 VRPAIR(VLEV_090
, 376000000),
654 VRPAIR(VLEV_095
, 426000000),
655 VRPAIR(VLEV_100
, 426000000),
656 VRPAIR(VLEV_105
, 476000000),
657 VRPAIR(VLEV_110
, 476000000),
658 VRPAIR(VLEV_115
, 476000000),
659 VRPAIR(VLEV_120
, 500000000),
660 VRPAIR(VLEV_125
, 533000000),
661 VRPAIR(VLEV_130
, 600000000),
664 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
665 .tuple_tab
= cclk_vlev_datasheet
,
666 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
667 .vr_settling_time
= 25 /* us */,
670 static struct platform_device bfin_dpmc
= {
673 .platform_data
= &bfin_dmpc_vreg_data
,
677 static struct platform_device
*cm_bf537e_devices
[] __initdata
= {
681 #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
685 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
689 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
690 #ifdef CONFIG_SERIAL_BFIN_UART0
693 #ifdef CONFIG_SERIAL_BFIN_UART1
698 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
699 #ifdef CONFIG_BFIN_SIR0
702 #ifdef CONFIG_BFIN_SIR1
707 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
708 &i2c_bfin_twi_device
,
711 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
712 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
713 &bfin_sport0_uart_device
,
715 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
716 &bfin_sport1_uart_device
,
720 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
724 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
728 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
733 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
734 &net2272_bfin_device
,
737 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
741 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
745 #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
750 static int __init
net2272_init(void)
752 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
755 ret
= gpio_request(GPIO_PG14
, "net2272");
759 /* Reset USB Chip, PG14 */
760 gpio_direction_output(GPIO_PG14
, 0);
762 gpio_set_value(GPIO_PG14
, 1);
768 static int __init
cm_bf537e_init(void)
770 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
771 platform_add_devices(cm_bf537e_devices
, ARRAY_SIZE(cm_bf537e_devices
));
772 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
773 spi_register_board_info(bfin_spi_board_info
, ARRAY_SIZE(bfin_spi_board_info
));
776 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
777 irq_set_status_flags(PATA_INT
, IRQ_NOAUTOEN
);
781 pr_warning("unable to configure net2272; it probably won't work\n");
786 arch_initcall(cm_bf537e_init
);
788 static struct platform_device
*cm_bf537e_early_devices
[] __initdata
= {
789 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
790 #ifdef CONFIG_SERIAL_BFIN_UART0
793 #ifdef CONFIG_SERIAL_BFIN_UART1
798 #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
799 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
800 &bfin_sport0_uart_device
,
802 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
803 &bfin_sport1_uart_device
,
808 void __init
native_machine_early_platform_add_devices(void)
810 printk(KERN_INFO
"register early platform devices\n");
811 early_platform_add_devices(cm_bf537e_early_devices
,
812 ARRAY_SIZE(cm_bf537e_early_devices
));
815 void bfin_get_ether_addr(char *addr
)
817 random_ether_addr(addr
);
818 printk(KERN_WARNING
"%s:%s: Setting Ethernet MAC to a random one\n", __FILE__
, __func__
);
820 EXPORT_SYMBOL(bfin_get_ether_addr
);