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>
27 #include <linux/spi/mmc_spi.h>
30 * Name the Board for the /proc/cpuinfo
32 const char bfin_board_name
[] = "Bluetechnix TCM BF537";
34 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
35 /* all SPI peripherals info goes here */
37 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
38 static struct mtd_partition bfin_spi_flash_partitions
[] = {
40 .name
= "bootloader(spi)",
43 .mask_flags
= MTD_CAP_ROM
45 .name
= "linux kernel(spi)",
49 .name
= "file system(spi)",
55 static struct flash_platform_data bfin_spi_flash_data
= {
57 .parts
= bfin_spi_flash_partitions
,
58 .nr_parts
= ARRAY_SIZE(bfin_spi_flash_partitions
),
62 /* SPI flash chip (m25p64) */
63 static struct bfin5xx_spi_chip spi_flash_chip_info
= {
64 .enable_dma
= 0, /* use dma transfer with this chip*/
68 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
69 static struct bfin5xx_spi_chip mmc_spi_chip_info
= {
74 static struct spi_board_info bfin_spi_board_info
[] __initdata
= {
75 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
77 /* the modalias must be the same as spi device driver name */
78 .modalias
= "m25p80", /* Name of spi_driver for this device */
79 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
80 .bus_num
= 0, /* Framework bus number */
81 .chip_select
= 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
82 .platform_data
= &bfin_spi_flash_data
,
83 .controller_data
= &spi_flash_chip_info
,
88 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
91 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
97 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
99 .modalias
= "mmc_spi",
100 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
103 .controller_data
= &mmc_spi_chip_info
,
110 static struct resource bfin_spi0_resource
[] = {
112 .start
= SPI0_REGBASE
,
113 .end
= SPI0_REGBASE
+ 0xFF,
114 .flags
= IORESOURCE_MEM
,
119 .flags
= IORESOURCE_DMA
,
124 .flags
= IORESOURCE_IRQ
,
128 /* SPI controller data */
129 static struct bfin5xx_spi_master bfin_spi0_info
= {
131 .enable_dma
= 1, /* master has the ability to do dma transfer */
132 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
135 static struct platform_device bfin_spi0_device
= {
137 .id
= 0, /* Bus number */
138 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
139 .resource
= bfin_spi0_resource
,
141 .platform_data
= &bfin_spi0_info
, /* Passed to driver */
144 #endif /* spi master and devices */
146 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
147 static struct platform_device rtc_device
= {
153 #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
154 static struct platform_device hitachi_fb_device
= {
155 .name
= "hitachi-tx09",
159 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
160 #include <linux/smc91x.h>
162 static struct smc91x_platdata smc91x_info
= {
163 .flags
= SMC91X_USE_16BIT
| SMC91X_NOWAIT
,
164 .leda
= RPC_LED_100_10
,
165 .ledb
= RPC_LED_TX_RX
,
168 static struct resource smc91x_resources
[] = {
171 .end
= 0x20200300 + 16,
172 .flags
= IORESOURCE_MEM
,
176 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
180 static struct platform_device smc91x_device
= {
183 .num_resources
= ARRAY_SIZE(smc91x_resources
),
184 .resource
= smc91x_resources
,
186 .platform_data
= &smc91x_info
,
191 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
192 static struct resource isp1362_hcd_resources
[] = {
196 .flags
= IORESOURCE_MEM
,
200 .flags
= IORESOURCE_MEM
,
204 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWEDGE
,
208 static struct isp1362_platform_data isp1362_priv
= {
213 .int_edge_triggered
= 0,
214 .remote_wakeup_connected
= 0,
215 .no_power_switching
= 1,
216 .power_switching_mode
= 0,
219 static struct platform_device isp1362_hcd_device
= {
220 .name
= "isp1362-hcd",
223 .platform_data
= &isp1362_priv
,
225 .num_resources
= ARRAY_SIZE(isp1362_hcd_resources
),
226 .resource
= isp1362_hcd_resources
,
230 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
231 static struct resource net2272_bfin_resources
[] = {
234 .end
= 0x20300000 + 0x100,
235 .flags
= IORESOURCE_MEM
,
239 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
243 static struct platform_device net2272_bfin_device
= {
246 .num_resources
= ARRAY_SIZE(net2272_bfin_resources
),
247 .resource
= net2272_bfin_resources
,
251 #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
252 static struct mtd_partition cm_partitions
[] = {
254 .name
= "bootloader(nor)",
258 .name
= "linux kernel(nor)",
260 .offset
= MTDPART_OFS_APPEND
,
262 .name
= "file system(nor)",
263 .size
= MTDPART_SIZ_FULL
,
264 .offset
= MTDPART_OFS_APPEND
,
268 static struct physmap_flash_data cm_flash_data
= {
270 .parts
= cm_partitions
,
271 .nr_parts
= ARRAY_SIZE(cm_partitions
),
274 static unsigned cm_flash_gpios
[] = { GPIO_PF4
, GPIO_PF5
};
276 static struct resource cm_flash_resource
[] = {
281 .flags
= IORESOURCE_MEM
,
283 .start
= (unsigned long)cm_flash_gpios
,
284 .end
= ARRAY_SIZE(cm_flash_gpios
),
285 .flags
= IORESOURCE_IRQ
,
289 static struct platform_device cm_flash_device
= {
290 .name
= "gpio-addr-flash",
293 .platform_data
= &cm_flash_data
,
295 .num_resources
= ARRAY_SIZE(cm_flash_resource
),
296 .resource
= cm_flash_resource
,
300 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
301 #ifdef CONFIG_SERIAL_BFIN_UART0
302 static struct resource bfin_uart0_resources
[] = {
306 .flags
= IORESOURCE_MEM
,
309 .start
= IRQ_UART0_RX
,
310 .end
= IRQ_UART0_RX
+1,
311 .flags
= IORESOURCE_IRQ
,
314 .start
= IRQ_UART0_ERROR
,
315 .end
= IRQ_UART0_ERROR
,
316 .flags
= IORESOURCE_IRQ
,
319 .start
= CH_UART0_TX
,
321 .flags
= IORESOURCE_DMA
,
324 .start
= CH_UART0_RX
,
326 .flags
= IORESOURCE_DMA
,
330 static unsigned short bfin_uart0_peripherals
[] = {
331 P_UART0_TX
, P_UART0_RX
, 0
334 static struct platform_device bfin_uart0_device
= {
337 .num_resources
= ARRAY_SIZE(bfin_uart0_resources
),
338 .resource
= bfin_uart0_resources
,
340 .platform_data
= &bfin_uart0_peripherals
, /* Passed to driver */
344 #ifdef CONFIG_SERIAL_BFIN_UART1
345 static struct resource bfin_uart1_resources
[] = {
349 .flags
= IORESOURCE_MEM
,
352 .start
= IRQ_UART1_RX
,
353 .end
= IRQ_UART1_RX
+1,
354 .flags
= IORESOURCE_IRQ
,
357 .start
= IRQ_UART1_ERROR
,
358 .end
= IRQ_UART1_ERROR
,
359 .flags
= IORESOURCE_IRQ
,
362 .start
= CH_UART1_TX
,
364 .flags
= IORESOURCE_DMA
,
367 .start
= CH_UART1_RX
,
369 .flags
= IORESOURCE_DMA
,
373 static unsigned short bfin_uart1_peripherals
[] = {
374 P_UART1_TX
, P_UART1_RX
, 0
377 static struct platform_device bfin_uart1_device
= {
380 .num_resources
= ARRAY_SIZE(bfin_uart1_resources
),
381 .resource
= bfin_uart1_resources
,
383 .platform_data
= &bfin_uart1_peripherals
, /* Passed to driver */
389 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
390 #ifdef CONFIG_BFIN_SIR0
391 static struct resource bfin_sir0_resources
[] = {
395 .flags
= IORESOURCE_MEM
,
398 .start
= IRQ_UART0_RX
,
399 .end
= IRQ_UART0_RX
+1,
400 .flags
= IORESOURCE_IRQ
,
403 .start
= CH_UART0_RX
,
404 .end
= CH_UART0_RX
+1,
405 .flags
= IORESOURCE_DMA
,
409 static struct platform_device bfin_sir0_device
= {
412 .num_resources
= ARRAY_SIZE(bfin_sir0_resources
),
413 .resource
= bfin_sir0_resources
,
416 #ifdef CONFIG_BFIN_SIR1
417 static struct resource bfin_sir1_resources
[] = {
421 .flags
= IORESOURCE_MEM
,
424 .start
= IRQ_UART1_RX
,
425 .end
= IRQ_UART1_RX
+1,
426 .flags
= IORESOURCE_IRQ
,
429 .start
= CH_UART1_RX
,
430 .end
= CH_UART1_RX
+1,
431 .flags
= IORESOURCE_DMA
,
435 static struct platform_device bfin_sir1_device
= {
438 .num_resources
= ARRAY_SIZE(bfin_sir1_resources
),
439 .resource
= bfin_sir1_resources
,
444 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
445 static struct resource bfin_twi0_resource
[] = {
447 .start
= TWI0_REGBASE
,
449 .flags
= IORESOURCE_MEM
,
454 .flags
= IORESOURCE_IRQ
,
458 static struct platform_device i2c_bfin_twi_device
= {
459 .name
= "i2c-bfin-twi",
461 .num_resources
= ARRAY_SIZE(bfin_twi0_resource
),
462 .resource
= bfin_twi0_resource
,
466 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
467 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
468 static struct resource bfin_sport0_uart_resources
[] = {
470 .start
= SPORT0_TCR1
,
471 .end
= SPORT0_MRCS3
+4,
472 .flags
= IORESOURCE_MEM
,
475 .start
= IRQ_SPORT0_RX
,
476 .end
= IRQ_SPORT0_RX
+1,
477 .flags
= IORESOURCE_IRQ
,
480 .start
= IRQ_SPORT0_ERROR
,
481 .end
= IRQ_SPORT0_ERROR
,
482 .flags
= IORESOURCE_IRQ
,
486 static unsigned short bfin_sport0_peripherals
[] = {
487 P_SPORT0_TFS
, P_SPORT0_DTPRI
, P_SPORT0_TSCLK
, P_SPORT0_RFS
,
488 P_SPORT0_DRPRI
, P_SPORT0_RSCLK
, 0
491 static struct platform_device bfin_sport0_uart_device
= {
492 .name
= "bfin-sport-uart",
494 .num_resources
= ARRAY_SIZE(bfin_sport0_uart_resources
),
495 .resource
= bfin_sport0_uart_resources
,
497 .platform_data
= &bfin_sport0_peripherals
, /* Passed to driver */
501 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
502 static struct resource bfin_sport1_uart_resources
[] = {
504 .start
= SPORT1_TCR1
,
505 .end
= SPORT1_MRCS3
+4,
506 .flags
= IORESOURCE_MEM
,
509 .start
= IRQ_SPORT1_RX
,
510 .end
= IRQ_SPORT1_RX
+1,
511 .flags
= IORESOURCE_IRQ
,
514 .start
= IRQ_SPORT1_ERROR
,
515 .end
= IRQ_SPORT1_ERROR
,
516 .flags
= IORESOURCE_IRQ
,
520 static unsigned short bfin_sport1_peripherals
[] = {
521 P_SPORT1_TFS
, P_SPORT1_DTPRI
, P_SPORT1_TSCLK
, P_SPORT1_RFS
,
522 P_SPORT1_DRPRI
, P_SPORT1_RSCLK
, 0
525 static struct platform_device bfin_sport1_uart_device
= {
526 .name
= "bfin-sport-uart",
528 .num_resources
= ARRAY_SIZE(bfin_sport1_uart_resources
),
529 .resource
= bfin_sport1_uart_resources
,
531 .platform_data
= &bfin_sport1_peripherals
, /* Passed to driver */
537 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
538 #include <linux/bfin_mac.h>
539 static const unsigned short bfin_mac_peripherals
[] = P_MII0
;
541 static struct bfin_phydev_platform_data bfin_phydev_data
[] = {
544 .irq
= IRQ_MAC_PHYINT
,
548 static struct bfin_mii_bus_platform_data bfin_mii_bus_data
= {
550 .phydev_data
= bfin_phydev_data
,
551 .phy_mode
= PHY_INTERFACE_MODE_MII
,
552 .mac_peripherals
= bfin_mac_peripherals
,
555 static struct platform_device bfin_mii_bus
= {
556 .name
= "bfin_mii_bus",
558 .platform_data
= &bfin_mii_bus_data
,
562 static struct platform_device bfin_mac_device
= {
565 .platform_data
= &bfin_mii_bus
,
570 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
571 #define PATA_INT IRQ_PF14
573 static struct pata_platform_info bfin_pata_platform_data
= {
575 .irq_type
= IRQF_TRIGGER_HIGH
| IRQF_DISABLED
,
578 static struct resource bfin_pata_resources
[] = {
582 .flags
= IORESOURCE_MEM
,
587 .flags
= IORESOURCE_MEM
,
592 .flags
= IORESOURCE_IRQ
,
596 static struct platform_device bfin_pata_device
= {
597 .name
= "pata_platform",
599 .num_resources
= ARRAY_SIZE(bfin_pata_resources
),
600 .resource
= bfin_pata_resources
,
602 .platform_data
= &bfin_pata_platform_data
,
607 static const unsigned int cclk_vlev_datasheet
[] =
609 VRPAIR(VLEV_085
, 250000000),
610 VRPAIR(VLEV_090
, 376000000),
611 VRPAIR(VLEV_095
, 426000000),
612 VRPAIR(VLEV_100
, 426000000),
613 VRPAIR(VLEV_105
, 476000000),
614 VRPAIR(VLEV_110
, 476000000),
615 VRPAIR(VLEV_115
, 476000000),
616 VRPAIR(VLEV_120
, 500000000),
617 VRPAIR(VLEV_125
, 533000000),
618 VRPAIR(VLEV_130
, 600000000),
621 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
622 .tuple_tab
= cclk_vlev_datasheet
,
623 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
624 .vr_settling_time
= 25 /* us */,
627 static struct platform_device bfin_dpmc
= {
630 .platform_data
= &bfin_dmpc_vreg_data
,
634 static struct platform_device
*cm_bf537_devices
[] __initdata
= {
638 #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
642 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
646 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
647 #ifdef CONFIG_SERIAL_BFIN_UART0
650 #ifdef CONFIG_SERIAL_BFIN_UART1
655 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
656 #ifdef CONFIG_BFIN_SIR0
659 #ifdef CONFIG_BFIN_SIR1
664 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
665 &i2c_bfin_twi_device
,
668 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
669 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
670 &bfin_sport0_uart_device
,
672 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
673 &bfin_sport1_uart_device
,
677 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
681 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
685 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
690 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
691 &net2272_bfin_device
,
694 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
698 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
702 #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
707 static int __init
net2272_init(void)
709 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
712 ret
= gpio_request(GPIO_PG14
, "net2272");
716 /* Reset USB Chip, PG14 */
717 gpio_direction_output(GPIO_PG14
, 0);
719 gpio_set_value(GPIO_PG14
, 1);
725 static int __init
tcm_bf537_init(void)
727 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
728 platform_add_devices(cm_bf537_devices
, ARRAY_SIZE(cm_bf537_devices
));
729 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
730 spi_register_board_info(bfin_spi_board_info
, ARRAY_SIZE(bfin_spi_board_info
));
733 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
734 irq_set_status_flags(PATA_INT
, IRQ_NOAUTOEN
);
738 pr_warning("unable to configure net2272; it probably won't work\n");
743 arch_initcall(tcm_bf537_init
);
745 static struct platform_device
*cm_bf537_early_devices
[] __initdata
= {
746 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
747 #ifdef CONFIG_SERIAL_BFIN_UART0
750 #ifdef CONFIG_SERIAL_BFIN_UART1
755 #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
756 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
757 &bfin_sport0_uart_device
,
759 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
760 &bfin_sport1_uart_device
,
765 void __init
native_machine_early_platform_add_devices(void)
767 printk(KERN_INFO
"register early platform devices\n");
768 early_platform_add_devices(cm_bf537_early_devices
,
769 ARRAY_SIZE(cm_bf537_early_devices
));
772 void bfin_get_ether_addr(char *addr
)
774 random_ether_addr(addr
);
775 printk(KERN_WARNING
"%s:%s: Setting Ethernet MAC to a random one\n", __FILE__
, __func__
);
777 EXPORT_SYMBOL(bfin_get_ether_addr
);