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 CM BF537U";
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*/
69 #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
71 static struct bfin5xx_spi_chip spi_adc_chip_info
= {
72 .enable_dma
= 1, /* use dma transfer with this chip*/
77 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
78 static struct bfin5xx_spi_chip ad1836_spi_chip_info
= {
84 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
85 static struct bfin5xx_spi_chip mmc_spi_chip_info
= {
91 static struct spi_board_info bfin_spi_board_info
[] __initdata
= {
92 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
94 /* the modalias must be the same as spi device driver name */
95 .modalias
= "m25p80", /* Name of spi_driver for this device */
96 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
97 .bus_num
= 0, /* Framework bus number */
98 .chip_select
= 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
99 .platform_data
= &bfin_spi_flash_data
,
100 .controller_data
= &spi_flash_chip_info
,
105 #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
107 .modalias
= "bfin_spi_adc", /* Name of spi_driver for this device */
108 .max_speed_hz
= 6250000, /* max spi clock (SCK) speed in HZ */
109 .bus_num
= 0, /* Framework bus number */
110 .chip_select
= 1, /* Framework chip select. */
111 .platform_data
= NULL
, /* No spi_driver specific config */
112 .controller_data
= &spi_adc_chip_info
,
116 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
118 .modalias
= "ad183x",
119 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
122 .controller_data
= &ad1836_spi_chip_info
,
126 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
128 .modalias
= "mmc_spi",
129 .max_speed_hz
= 20000000, /* max spi clock (SCK) speed in HZ */
132 .controller_data
= &mmc_spi_chip_info
,
139 static struct resource bfin_spi0_resource
[] = {
141 .start
= SPI0_REGBASE
,
142 .end
= SPI0_REGBASE
+ 0xFF,
143 .flags
= IORESOURCE_MEM
,
148 .flags
= IORESOURCE_DMA
,
153 .flags
= IORESOURCE_IRQ
,
157 /* SPI controller data */
158 static struct bfin5xx_spi_master bfin_spi0_info
= {
160 .enable_dma
= 1, /* master has the ability to do dma transfer */
161 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
164 static struct platform_device bfin_spi0_device
= {
166 .id
= 0, /* Bus number */
167 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
168 .resource
= bfin_spi0_resource
,
170 .platform_data
= &bfin_spi0_info
, /* Passed to driver */
173 #endif /* spi master and devices */
175 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
176 static struct platform_device rtc_device
= {
182 #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
183 static struct platform_device hitachi_fb_device
= {
184 .name
= "hitachi-tx09",
188 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
189 #include <linux/smc91x.h>
191 static struct smc91x_platdata smc91x_info
= {
192 .flags
= SMC91X_USE_16BIT
| SMC91X_NOWAIT
,
193 .leda
= RPC_LED_100_10
,
194 .ledb
= RPC_LED_TX_RX
,
197 static struct resource smc91x_resources
[] = {
200 .end
= 0x20200300 + 16,
201 .flags
= IORESOURCE_MEM
,
205 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
209 static struct platform_device smc91x_device
= {
212 .num_resources
= ARRAY_SIZE(smc91x_resources
),
213 .resource
= smc91x_resources
,
215 .platform_data
= &smc91x_info
,
220 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
221 static struct resource isp1362_hcd_resources
[] = {
225 .flags
= IORESOURCE_MEM
,
229 .flags
= IORESOURCE_MEM
,
233 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWEDGE
,
237 static struct isp1362_platform_data isp1362_priv
= {
242 .int_edge_triggered
= 0,
243 .remote_wakeup_connected
= 0,
244 .no_power_switching
= 1,
245 .power_switching_mode
= 0,
248 static struct platform_device isp1362_hcd_device
= {
249 .name
= "isp1362-hcd",
252 .platform_data
= &isp1362_priv
,
254 .num_resources
= ARRAY_SIZE(isp1362_hcd_resources
),
255 .resource
= isp1362_hcd_resources
,
259 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
260 static struct resource net2272_bfin_resources
[] = {
263 .end
= 0x20200000 + 0x100,
264 .flags
= IORESOURCE_MEM
,
268 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
272 static struct platform_device net2272_bfin_device
= {
275 .num_resources
= ARRAY_SIZE(net2272_bfin_resources
),
276 .resource
= net2272_bfin_resources
,
280 #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
281 static struct mtd_partition cm_partitions
[] = {
283 .name
= "bootloader(nor)",
287 .name
= "linux kernel(nor)",
289 .offset
= MTDPART_OFS_APPEND
,
291 .name
= "file system(nor)",
292 .size
= MTDPART_SIZ_FULL
,
293 .offset
= MTDPART_OFS_APPEND
,
297 static struct physmap_flash_data cm_flash_data
= {
299 .parts
= cm_partitions
,
300 .nr_parts
= ARRAY_SIZE(cm_partitions
),
303 static unsigned cm_flash_gpios
[] = { GPIO_PH0
};
305 static struct resource cm_flash_resource
[] = {
310 .flags
= IORESOURCE_MEM
,
312 .start
= (unsigned long)cm_flash_gpios
,
313 .end
= ARRAY_SIZE(cm_flash_gpios
),
314 .flags
= IORESOURCE_IRQ
,
318 static struct platform_device cm_flash_device
= {
319 .name
= "gpio-addr-flash",
322 .platform_data
= &cm_flash_data
,
324 .num_resources
= ARRAY_SIZE(cm_flash_resource
),
325 .resource
= cm_flash_resource
,
329 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
330 #ifdef CONFIG_SERIAL_BFIN_UART0
331 static struct resource bfin_uart0_resources
[] = {
335 .flags
= IORESOURCE_MEM
,
338 .start
= IRQ_UART0_RX
,
339 .end
= IRQ_UART0_RX
+1,
340 .flags
= IORESOURCE_IRQ
,
343 .start
= IRQ_UART0_ERROR
,
344 .end
= IRQ_UART0_ERROR
,
345 .flags
= IORESOURCE_IRQ
,
348 .start
= CH_UART0_TX
,
350 .flags
= IORESOURCE_DMA
,
353 .start
= CH_UART0_RX
,
355 .flags
= IORESOURCE_DMA
,
359 static unsigned short bfin_uart0_peripherals
[] = {
360 P_UART0_TX
, P_UART0_RX
, 0
363 static struct platform_device bfin_uart0_device
= {
366 .num_resources
= ARRAY_SIZE(bfin_uart0_resources
),
367 .resource
= bfin_uart0_resources
,
369 .platform_data
= &bfin_uart0_peripherals
, /* Passed to driver */
373 #ifdef CONFIG_SERIAL_BFIN_UART1
374 static struct resource bfin_uart1_resources
[] = {
378 .flags
= IORESOURCE_MEM
,
381 .start
= IRQ_UART1_RX
,
382 .end
= IRQ_UART1_RX
+1,
383 .flags
= IORESOURCE_IRQ
,
386 .start
= IRQ_UART1_ERROR
,
387 .end
= IRQ_UART1_ERROR
,
388 .flags
= IORESOURCE_IRQ
,
391 .start
= CH_UART1_TX
,
393 .flags
= IORESOURCE_DMA
,
396 .start
= CH_UART1_RX
,
398 .flags
= IORESOURCE_DMA
,
402 static unsigned short bfin_uart1_peripherals
[] = {
403 P_UART1_TX
, P_UART1_RX
, 0
406 static struct platform_device bfin_uart1_device
= {
409 .num_resources
= ARRAY_SIZE(bfin_uart1_resources
),
410 .resource
= bfin_uart1_resources
,
412 .platform_data
= &bfin_uart1_peripherals
, /* Passed to driver */
418 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
419 #ifdef CONFIG_BFIN_SIR0
420 static struct resource bfin_sir0_resources
[] = {
424 .flags
= IORESOURCE_MEM
,
427 .start
= IRQ_UART0_RX
,
428 .end
= IRQ_UART0_RX
+1,
429 .flags
= IORESOURCE_IRQ
,
432 .start
= CH_UART0_RX
,
433 .end
= CH_UART0_RX
+1,
434 .flags
= IORESOURCE_DMA
,
437 static struct platform_device bfin_sir0_device
= {
440 .num_resources
= ARRAY_SIZE(bfin_sir0_resources
),
441 .resource
= bfin_sir0_resources
,
444 #ifdef CONFIG_BFIN_SIR1
445 static struct resource bfin_sir1_resources
[] = {
449 .flags
= IORESOURCE_MEM
,
452 .start
= IRQ_UART1_RX
,
453 .end
= IRQ_UART1_RX
+1,
454 .flags
= IORESOURCE_IRQ
,
457 .start
= CH_UART1_RX
,
458 .end
= CH_UART1_RX
+1,
459 .flags
= IORESOURCE_DMA
,
462 static struct platform_device bfin_sir1_device
= {
465 .num_resources
= ARRAY_SIZE(bfin_sir1_resources
),
466 .resource
= bfin_sir1_resources
,
471 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
472 static struct resource bfin_twi0_resource
[] = {
474 .start
= TWI0_REGBASE
,
476 .flags
= IORESOURCE_MEM
,
481 .flags
= IORESOURCE_IRQ
,
485 static struct platform_device i2c_bfin_twi_device
= {
486 .name
= "i2c-bfin-twi",
488 .num_resources
= ARRAY_SIZE(bfin_twi0_resource
),
489 .resource
= bfin_twi0_resource
,
493 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
494 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
495 static struct resource bfin_sport0_uart_resources
[] = {
497 .start
= SPORT0_TCR1
,
498 .end
= SPORT0_MRCS3
+4,
499 .flags
= IORESOURCE_MEM
,
502 .start
= IRQ_SPORT0_RX
,
503 .end
= IRQ_SPORT0_RX
+1,
504 .flags
= IORESOURCE_IRQ
,
507 .start
= IRQ_SPORT0_ERROR
,
508 .end
= IRQ_SPORT0_ERROR
,
509 .flags
= IORESOURCE_IRQ
,
513 static unsigned short bfin_sport0_peripherals
[] = {
514 P_SPORT0_TFS
, P_SPORT0_DTPRI
, P_SPORT0_TSCLK
, P_SPORT0_RFS
,
515 P_SPORT0_DRPRI
, P_SPORT0_RSCLK
, 0
518 static struct platform_device bfin_sport0_uart_device
= {
519 .name
= "bfin-sport-uart",
521 .num_resources
= ARRAY_SIZE(bfin_sport0_uart_resources
),
522 .resource
= bfin_sport0_uart_resources
,
524 .platform_data
= &bfin_sport0_peripherals
, /* Passed to driver */
528 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
529 static struct resource bfin_sport1_uart_resources
[] = {
531 .start
= SPORT1_TCR1
,
532 .end
= SPORT1_MRCS3
+4,
533 .flags
= IORESOURCE_MEM
,
536 .start
= IRQ_SPORT1_RX
,
537 .end
= IRQ_SPORT1_RX
+1,
538 .flags
= IORESOURCE_IRQ
,
541 .start
= IRQ_SPORT1_ERROR
,
542 .end
= IRQ_SPORT1_ERROR
,
543 .flags
= IORESOURCE_IRQ
,
547 static unsigned short bfin_sport1_peripherals
[] = {
548 P_SPORT1_TFS
, P_SPORT1_DTPRI
, P_SPORT1_TSCLK
, P_SPORT1_RFS
,
549 P_SPORT1_DRPRI
, P_SPORT1_RSCLK
, 0
552 static struct platform_device bfin_sport1_uart_device
= {
553 .name
= "bfin-sport-uart",
555 .num_resources
= ARRAY_SIZE(bfin_sport1_uart_resources
),
556 .resource
= bfin_sport1_uart_resources
,
558 .platform_data
= &bfin_sport1_peripherals
, /* Passed to driver */
564 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
565 #include <linux/bfin_mac.h>
566 static const unsigned short bfin_mac_peripherals
[] = P_MII0
;
568 static struct bfin_phydev_platform_data bfin_phydev_data
[] = {
571 .irq
= IRQ_MAC_PHYINT
,
575 static struct bfin_mii_bus_platform_data bfin_mii_bus_data
= {
577 .phydev_data
= bfin_phydev_data
,
578 .phy_mode
= PHY_INTERFACE_MODE_MII
,
579 .mac_peripherals
= bfin_mac_peripherals
,
582 static struct platform_device bfin_mii_bus
= {
583 .name
= "bfin_mii_bus",
585 .platform_data
= &bfin_mii_bus_data
,
589 static struct platform_device bfin_mac_device
= {
592 .platform_data
= &bfin_mii_bus
,
597 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
598 #define PATA_INT IRQ_PF14
600 static struct pata_platform_info bfin_pata_platform_data
= {
602 .irq_type
= IRQF_TRIGGER_HIGH
| IRQF_DISABLED
,
605 static struct resource bfin_pata_resources
[] = {
609 .flags
= IORESOURCE_MEM
,
614 .flags
= IORESOURCE_MEM
,
619 .flags
= IORESOURCE_IRQ
,
623 static struct platform_device bfin_pata_device
= {
624 .name
= "pata_platform",
626 .num_resources
= ARRAY_SIZE(bfin_pata_resources
),
627 .resource
= bfin_pata_resources
,
629 .platform_data
= &bfin_pata_platform_data
,
634 static const unsigned int cclk_vlev_datasheet
[] =
636 VRPAIR(VLEV_085
, 250000000),
637 VRPAIR(VLEV_090
, 376000000),
638 VRPAIR(VLEV_095
, 426000000),
639 VRPAIR(VLEV_100
, 426000000),
640 VRPAIR(VLEV_105
, 476000000),
641 VRPAIR(VLEV_110
, 476000000),
642 VRPAIR(VLEV_115
, 476000000),
643 VRPAIR(VLEV_120
, 500000000),
644 VRPAIR(VLEV_125
, 533000000),
645 VRPAIR(VLEV_130
, 600000000),
648 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
649 .tuple_tab
= cclk_vlev_datasheet
,
650 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
651 .vr_settling_time
= 25 /* us */,
654 static struct platform_device bfin_dpmc
= {
657 .platform_data
= &bfin_dmpc_vreg_data
,
661 static struct platform_device
*cm_bf537u_devices
[] __initdata
= {
665 #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
669 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
673 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
674 #ifdef CONFIG_SERIAL_BFIN_UART0
677 #ifdef CONFIG_SERIAL_BFIN_UART1
682 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
683 #ifdef CONFIG_BFIN_SIR0
686 #ifdef CONFIG_BFIN_SIR1
691 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
692 &i2c_bfin_twi_device
,
695 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
696 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
697 &bfin_sport0_uart_device
,
699 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
700 &bfin_sport1_uart_device
,
704 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
708 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
712 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
717 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
718 &net2272_bfin_device
,
721 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
725 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
729 #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
734 static int __init
cm_bf537u_init(void)
736 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
737 platform_add_devices(cm_bf537u_devices
, ARRAY_SIZE(cm_bf537u_devices
));
738 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
739 spi_register_board_info(bfin_spi_board_info
, ARRAY_SIZE(bfin_spi_board_info
));
742 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
743 irq_set_status_flags(PATA_INT
, IRQ_NOAUTOEN
);
748 arch_initcall(cm_bf537u_init
);
750 static struct platform_device
*cm_bf537u_early_devices
[] __initdata
= {
751 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
752 #ifdef CONFIG_SERIAL_BFIN_UART0
755 #ifdef CONFIG_SERIAL_BFIN_UART1
760 #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
761 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
762 &bfin_sport0_uart_device
,
764 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
765 &bfin_sport1_uart_device
,
770 void __init
native_machine_early_platform_add_devices(void)
772 printk(KERN_INFO
"register early platform devices\n");
773 early_platform_add_devices(cm_bf537u_early_devices
,
774 ARRAY_SIZE(cm_bf537u_early_devices
));
777 void bfin_get_ether_addr(char *addr
)
779 random_ether_addr(addr
);
780 printk(KERN_WARNING
"%s:%s: Setting Ethernet MAC to a random one\n", __FILE__
, __func__
);
782 EXPORT_SYMBOL(bfin_get_ether_addr
);