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/export.h>
13 #include <linux/platform_device.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16 #include <linux/mtd/physmap.h>
17 #include <linux/spi/spi.h>
18 #include <linux/spi/flash.h>
19 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
20 #include <linux/usb/isp1362.h>
22 #include <linux/ata_platform.h>
23 #include <linux/irq.h>
24 #include <linux/gpio.h>
26 #include <asm/bfin5xx_spi.h>
27 #include <asm/portmux.h>
29 #include <linux/spi/mmc_spi.h>
32 * Name the Board for the /proc/cpuinfo
34 const char bfin_board_name
[] = "Bluetechnix TCM BF537";
36 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
37 /* all SPI peripherals info goes here */
39 #if IS_ENABLED(CONFIG_MTD_M25P80)
40 static struct mtd_partition bfin_spi_flash_partitions
[] = {
42 .name
= "bootloader(spi)",
45 .mask_flags
= MTD_CAP_ROM
47 .name
= "linux kernel(spi)",
51 .name
= "file system(spi)",
57 static struct flash_platform_data bfin_spi_flash_data
= {
59 .parts
= bfin_spi_flash_partitions
,
60 .nr_parts
= ARRAY_SIZE(bfin_spi_flash_partitions
),
64 /* SPI flash chip (m25p64) */
65 static struct bfin5xx_spi_chip spi_flash_chip_info
= {
66 .enable_dma
= 0, /* use dma transfer with this chip*/
70 #if IS_ENABLED(CONFIG_MMC_SPI)
71 static struct bfin5xx_spi_chip mmc_spi_chip_info
= {
76 static struct spi_board_info bfin_spi_board_info
[] __initdata
= {
77 #if IS_ENABLED(CONFIG_MTD_M25P80)
79 /* the modalias must be the same as spi device driver name */
80 .modalias
= "m25p80", /* Name of spi_driver for this device */
81 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
82 .bus_num
= 0, /* Framework bus number */
83 .chip_select
= 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
84 .platform_data
= &bfin_spi_flash_data
,
85 .controller_data
= &spi_flash_chip_info
,
90 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
93 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
99 #if IS_ENABLED(CONFIG_MMC_SPI)
101 .modalias
= "mmc_spi",
102 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
105 .controller_data
= &mmc_spi_chip_info
,
112 static struct resource bfin_spi0_resource
[] = {
114 .start
= SPI0_REGBASE
,
115 .end
= SPI0_REGBASE
+ 0xFF,
116 .flags
= IORESOURCE_MEM
,
121 .flags
= IORESOURCE_DMA
,
126 .flags
= IORESOURCE_IRQ
,
130 /* SPI controller data */
131 static struct bfin5xx_spi_master bfin_spi0_info
= {
133 .enable_dma
= 1, /* master has the ability to do dma transfer */
134 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
137 static struct platform_device bfin_spi0_device
= {
139 .id
= 0, /* Bus number */
140 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
141 .resource
= bfin_spi0_resource
,
143 .platform_data
= &bfin_spi0_info
, /* Passed to driver */
146 #endif /* spi master and devices */
148 #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
149 static struct platform_device rtc_device
= {
155 #if IS_ENABLED(CONFIG_FB_HITACHI_TX09)
156 static struct platform_device hitachi_fb_device
= {
157 .name
= "hitachi-tx09",
161 #if IS_ENABLED(CONFIG_SMC91X)
162 #include <linux/smc91x.h>
164 static struct smc91x_platdata smc91x_info
= {
165 .flags
= SMC91X_USE_16BIT
| SMC91X_NOWAIT
,
166 .leda
= RPC_LED_100_10
,
167 .ledb
= RPC_LED_TX_RX
,
170 static struct resource smc91x_resources
[] = {
173 .end
= 0x20200300 + 16,
174 .flags
= IORESOURCE_MEM
,
178 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
182 static struct platform_device smc91x_device
= {
185 .num_resources
= ARRAY_SIZE(smc91x_resources
),
186 .resource
= smc91x_resources
,
188 .platform_data
= &smc91x_info
,
193 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
194 static struct resource isp1362_hcd_resources
[] = {
198 .flags
= IORESOURCE_MEM
,
202 .flags
= IORESOURCE_MEM
,
206 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWEDGE
,
210 static struct isp1362_platform_data isp1362_priv
= {
215 .int_edge_triggered
= 0,
216 .remote_wakeup_connected
= 0,
217 .no_power_switching
= 1,
218 .power_switching_mode
= 0,
221 static struct platform_device isp1362_hcd_device
= {
222 .name
= "isp1362-hcd",
225 .platform_data
= &isp1362_priv
,
227 .num_resources
= ARRAY_SIZE(isp1362_hcd_resources
),
228 .resource
= isp1362_hcd_resources
,
232 #if IS_ENABLED(CONFIG_USB_NET2272)
233 static struct resource net2272_bfin_resources
[] = {
236 .end
= 0x20300000 + 0x100,
237 .flags
= IORESOURCE_MEM
,
241 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
245 static struct platform_device net2272_bfin_device
= {
248 .num_resources
= ARRAY_SIZE(net2272_bfin_resources
),
249 .resource
= net2272_bfin_resources
,
253 #if IS_ENABLED(CONFIG_MTD_GPIO_ADDR)
254 static struct mtd_partition cm_partitions
[] = {
256 .name
= "bootloader(nor)",
260 .name
= "linux kernel(nor)",
262 .offset
= MTDPART_OFS_APPEND
,
264 .name
= "file system(nor)",
265 .size
= MTDPART_SIZ_FULL
,
266 .offset
= MTDPART_OFS_APPEND
,
270 static struct physmap_flash_data cm_flash_data
= {
272 .parts
= cm_partitions
,
273 .nr_parts
= ARRAY_SIZE(cm_partitions
),
276 static unsigned cm_flash_gpios
[] = { GPIO_PF4
, GPIO_PF5
};
278 static struct resource cm_flash_resource
[] = {
283 .flags
= IORESOURCE_MEM
,
285 .start
= (unsigned long)cm_flash_gpios
,
286 .end
= ARRAY_SIZE(cm_flash_gpios
),
287 .flags
= IORESOURCE_IRQ
,
291 static struct platform_device cm_flash_device
= {
292 .name
= "gpio-addr-flash",
295 .platform_data
= &cm_flash_data
,
297 .num_resources
= ARRAY_SIZE(cm_flash_resource
),
298 .resource
= cm_flash_resource
,
302 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
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 IS_ENABLED(CONFIG_BFIN_SIR)
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 #if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
457 static const u16 bfin_twi0_pins
[] = {P_TWI0_SCL
, P_TWI0_SDA
, 0};
459 static struct resource bfin_twi0_resource
[] = {
461 .start
= TWI0_REGBASE
,
463 .flags
= IORESOURCE_MEM
,
468 .flags
= IORESOURCE_IRQ
,
472 static struct platform_device i2c_bfin_twi_device
= {
473 .name
= "i2c-bfin-twi",
475 .num_resources
= ARRAY_SIZE(bfin_twi0_resource
),
476 .resource
= bfin_twi0_resource
,
478 .platform_data
= &bfin_twi0_pins
,
483 #if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
484 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
485 static struct resource bfin_sport0_uart_resources
[] = {
487 .start
= SPORT0_TCR1
,
488 .end
= SPORT0_MRCS3
+4,
489 .flags
= IORESOURCE_MEM
,
492 .start
= IRQ_SPORT0_RX
,
493 .end
= IRQ_SPORT0_RX
+1,
494 .flags
= IORESOURCE_IRQ
,
497 .start
= IRQ_SPORT0_ERROR
,
498 .end
= IRQ_SPORT0_ERROR
,
499 .flags
= IORESOURCE_IRQ
,
503 static unsigned short bfin_sport0_peripherals
[] = {
504 P_SPORT0_TFS
, P_SPORT0_DTPRI
, P_SPORT0_TSCLK
, P_SPORT0_RFS
,
505 P_SPORT0_DRPRI
, P_SPORT0_RSCLK
, 0
508 static struct platform_device bfin_sport0_uart_device
= {
509 .name
= "bfin-sport-uart",
511 .num_resources
= ARRAY_SIZE(bfin_sport0_uart_resources
),
512 .resource
= bfin_sport0_uart_resources
,
514 .platform_data
= &bfin_sport0_peripherals
, /* Passed to driver */
518 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
519 static struct resource bfin_sport1_uart_resources
[] = {
521 .start
= SPORT1_TCR1
,
522 .end
= SPORT1_MRCS3
+4,
523 .flags
= IORESOURCE_MEM
,
526 .start
= IRQ_SPORT1_RX
,
527 .end
= IRQ_SPORT1_RX
+1,
528 .flags
= IORESOURCE_IRQ
,
531 .start
= IRQ_SPORT1_ERROR
,
532 .end
= IRQ_SPORT1_ERROR
,
533 .flags
= IORESOURCE_IRQ
,
537 static unsigned short bfin_sport1_peripherals
[] = {
538 P_SPORT1_TFS
, P_SPORT1_DTPRI
, P_SPORT1_TSCLK
, P_SPORT1_RFS
,
539 P_SPORT1_DRPRI
, P_SPORT1_RSCLK
, 0
542 static struct platform_device bfin_sport1_uart_device
= {
543 .name
= "bfin-sport-uart",
545 .num_resources
= ARRAY_SIZE(bfin_sport1_uart_resources
),
546 .resource
= bfin_sport1_uart_resources
,
548 .platform_data
= &bfin_sport1_peripherals
, /* Passed to driver */
554 #if IS_ENABLED(CONFIG_BFIN_MAC)
555 #include <linux/bfin_mac.h>
556 static const unsigned short bfin_mac_peripherals
[] = P_MII0
;
558 static struct bfin_phydev_platform_data bfin_phydev_data
[] = {
561 .irq
= IRQ_MAC_PHYINT
,
565 static struct bfin_mii_bus_platform_data bfin_mii_bus_data
= {
567 .phydev_data
= bfin_phydev_data
,
568 .phy_mode
= PHY_INTERFACE_MODE_MII
,
569 .mac_peripherals
= bfin_mac_peripherals
,
572 static struct platform_device bfin_mii_bus
= {
573 .name
= "bfin_mii_bus",
575 .platform_data
= &bfin_mii_bus_data
,
579 static struct platform_device bfin_mac_device
= {
582 .platform_data
= &bfin_mii_bus
,
587 #if IS_ENABLED(CONFIG_PATA_PLATFORM)
588 #define PATA_INT IRQ_PF14
590 static struct pata_platform_info bfin_pata_platform_data
= {
592 .irq_type
= IRQF_TRIGGER_HIGH
,
595 static struct resource bfin_pata_resources
[] = {
599 .flags
= IORESOURCE_MEM
,
604 .flags
= IORESOURCE_MEM
,
609 .flags
= IORESOURCE_IRQ
,
613 static struct platform_device bfin_pata_device
= {
614 .name
= "pata_platform",
616 .num_resources
= ARRAY_SIZE(bfin_pata_resources
),
617 .resource
= bfin_pata_resources
,
619 .platform_data
= &bfin_pata_platform_data
,
624 static const unsigned int cclk_vlev_datasheet
[] =
626 VRPAIR(VLEV_085
, 250000000),
627 VRPAIR(VLEV_090
, 376000000),
628 VRPAIR(VLEV_095
, 426000000),
629 VRPAIR(VLEV_100
, 426000000),
630 VRPAIR(VLEV_105
, 476000000),
631 VRPAIR(VLEV_110
, 476000000),
632 VRPAIR(VLEV_115
, 476000000),
633 VRPAIR(VLEV_120
, 500000000),
634 VRPAIR(VLEV_125
, 533000000),
635 VRPAIR(VLEV_130
, 600000000),
638 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
639 .tuple_tab
= cclk_vlev_datasheet
,
640 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
641 .vr_settling_time
= 25 /* us */,
644 static struct platform_device bfin_dpmc
= {
647 .platform_data
= &bfin_dmpc_vreg_data
,
651 static struct platform_device
*cm_bf537_devices
[] __initdata
= {
655 #if IS_ENABLED(CONFIG_FB_HITACHI_TX09)
659 #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
663 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
664 #ifdef CONFIG_SERIAL_BFIN_UART0
667 #ifdef CONFIG_SERIAL_BFIN_UART1
672 #if IS_ENABLED(CONFIG_BFIN_SIR)
673 #ifdef CONFIG_BFIN_SIR0
676 #ifdef CONFIG_BFIN_SIR1
681 #if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
682 &i2c_bfin_twi_device
,
685 #if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
686 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
687 &bfin_sport0_uart_device
,
689 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
690 &bfin_sport1_uart_device
,
694 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
698 #if IS_ENABLED(CONFIG_SMC91X)
702 #if IS_ENABLED(CONFIG_BFIN_MAC)
707 #if IS_ENABLED(CONFIG_USB_NET2272)
708 &net2272_bfin_device
,
711 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
715 #if IS_ENABLED(CONFIG_PATA_PLATFORM)
719 #if IS_ENABLED(CONFIG_MTD_GPIO_ADDR)
724 static int __init
net2272_init(void)
726 #if IS_ENABLED(CONFIG_USB_NET2272)
729 ret
= gpio_request(GPIO_PG14
, "net2272");
733 /* Reset USB Chip, PG14 */
734 gpio_direction_output(GPIO_PG14
, 0);
736 gpio_set_value(GPIO_PG14
, 1);
742 static int __init
tcm_bf537_init(void)
744 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
745 platform_add_devices(cm_bf537_devices
, ARRAY_SIZE(cm_bf537_devices
));
746 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
747 spi_register_board_info(bfin_spi_board_info
, ARRAY_SIZE(bfin_spi_board_info
));
750 #if IS_ENABLED(CONFIG_PATA_PLATFORM)
751 irq_set_status_flags(PATA_INT
, IRQ_NOAUTOEN
);
755 pr_warning("unable to configure net2272; it probably won't work\n");
760 arch_initcall(tcm_bf537_init
);
762 static struct platform_device
*cm_bf537_early_devices
[] __initdata
= {
763 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
764 #ifdef CONFIG_SERIAL_BFIN_UART0
767 #ifdef CONFIG_SERIAL_BFIN_UART1
772 #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
773 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
774 &bfin_sport0_uart_device
,
776 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
777 &bfin_sport1_uart_device
,
782 void __init
native_machine_early_platform_add_devices(void)
784 printk(KERN_INFO
"register early platform devices\n");
785 early_platform_add_devices(cm_bf537_early_devices
,
786 ARRAY_SIZE(cm_bf537_early_devices
));
789 int bfin_get_ether_addr(char *addr
)
793 EXPORT_SYMBOL(bfin_get_ether_addr
);