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/platform_device.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/spi/spi.h>
15 #include <linux/spi/flash.h>
16 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
17 #include <linux/usb/isp1362.h>
19 #include <linux/ata_platform.h>
20 #include <linux/irq.h>
21 #include <linux/gpio.h>
23 #include <asm/bfin5xx_spi.h>
24 #include <asm/portmux.h>
26 #include <linux/mtd/physmap.h>
29 * Name the Board for the /proc/cpuinfo
31 const char bfin_board_name
[] = "Bluetechnix CM BF561";
33 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
34 /* all SPI peripherals info goes here */
36 #if IS_ENABLED(CONFIG_MTD_M25P80)
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 static struct spi_board_info bfin_spi_board_info
[] __initdata
= {
68 #if IS_ENABLED(CONFIG_MTD_M25P80)
70 /* the modalias must be the same as spi device driver name */
71 .modalias
= "m25p80", /* Name of spi_driver for this device */
72 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
73 .bus_num
= 0, /* Framework bus number */
74 .chip_select
= 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
75 .platform_data
= &bfin_spi_flash_data
,
76 .controller_data
= &spi_flash_chip_info
,
81 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
84 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
89 #if IS_ENABLED(CONFIG_MMC_SPI)
91 .modalias
= "mmc_spi",
92 .max_speed_hz
= 20000000, /* max spi clock (SCK) speed in HZ */
101 static struct resource bfin_spi0_resource
[] = {
103 .start
= SPI0_REGBASE
,
104 .end
= SPI0_REGBASE
+ 0xFF,
105 .flags
= IORESOURCE_MEM
,
110 .flags
= IORESOURCE_DMA
,
115 .flags
= IORESOURCE_IRQ
,
119 /* SPI controller data */
120 static struct bfin5xx_spi_master bfin_spi0_info
= {
122 .enable_dma
= 1, /* master has the ability to do dma transfer */
123 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
126 static struct platform_device bfin_spi0_device
= {
128 .id
= 0, /* Bus number */
129 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
130 .resource
= bfin_spi0_resource
,
132 .platform_data
= &bfin_spi0_info
, /* Passed to driver */
135 #endif /* spi master and devices */
138 #if IS_ENABLED(CONFIG_FB_HITACHI_TX09)
139 static struct platform_device hitachi_fb_device
= {
140 .name
= "hitachi-tx09",
145 #if IS_ENABLED(CONFIG_SMC91X)
146 #include <linux/smc91x.h>
148 static struct smc91x_platdata smc91x_info
= {
149 .flags
= SMC91X_USE_8BIT
| SMC91X_USE_16BIT
| SMC91X_USE_32BIT
|
151 .leda
= RPC_LED_100_10
,
152 .ledb
= RPC_LED_TX_RX
,
155 static struct resource smc91x_resources
[] = {
157 .name
= "smc91x-regs",
159 .end
= 0x28000300 + 16,
160 .flags
= IORESOURCE_MEM
,
164 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
167 static struct platform_device smc91x_device
= {
170 .num_resources
= ARRAY_SIZE(smc91x_resources
),
171 .resource
= smc91x_resources
,
173 .platform_data
= &smc91x_info
,
178 #if IS_ENABLED(CONFIG_SMSC911X)
179 #include <linux/smsc911x.h>
181 static struct resource smsc911x_resources
[] = {
183 .name
= "smsc911x-memory",
185 .end
= 0x24008000 + 0xFF,
186 .flags
= IORESOURCE_MEM
,
191 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWLEVEL
,
195 static struct smsc911x_platform_config smsc911x_config
= {
196 .flags
= SMSC911X_USE_16BIT
,
197 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_LOW
,
198 .irq_type
= SMSC911X_IRQ_TYPE_OPEN_DRAIN
,
199 .phy_interface
= PHY_INTERFACE_MODE_MII
,
202 static struct platform_device smsc911x_device
= {
205 .num_resources
= ARRAY_SIZE(smsc911x_resources
),
206 .resource
= smsc911x_resources
,
208 .platform_data
= &smsc911x_config
,
213 #if IS_ENABLED(CONFIG_USB_NET2272)
214 static struct resource net2272_bfin_resources
[] = {
217 .end
= 0x24000000 + 0x100,
218 .flags
= IORESOURCE_MEM
,
222 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
226 static struct platform_device net2272_bfin_device
= {
229 .num_resources
= ARRAY_SIZE(net2272_bfin_resources
),
230 .resource
= net2272_bfin_resources
,
234 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
235 static struct resource isp1362_hcd_resources
[] = {
239 .flags
= IORESOURCE_MEM
,
243 .flags
= IORESOURCE_MEM
,
247 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWEDGE
,
251 static struct isp1362_platform_data isp1362_priv
= {
256 .int_edge_triggered
= 0,
257 .remote_wakeup_connected
= 0,
258 .no_power_switching
= 1,
259 .power_switching_mode
= 0,
262 static struct platform_device isp1362_hcd_device
= {
263 .name
= "isp1362-hcd",
266 .platform_data
= &isp1362_priv
,
268 .num_resources
= ARRAY_SIZE(isp1362_hcd_resources
),
269 .resource
= isp1362_hcd_resources
,
273 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
274 #ifdef CONFIG_SERIAL_BFIN_UART0
275 static struct resource bfin_uart0_resources
[] = {
277 .start
= BFIN_UART_THR
,
278 .end
= BFIN_UART_GCTL
+2,
279 .flags
= IORESOURCE_MEM
,
282 .start
= IRQ_UART_TX
,
284 .flags
= IORESOURCE_IRQ
,
287 .start
= IRQ_UART_RX
,
289 .flags
= IORESOURCE_IRQ
,
292 .start
= IRQ_UART_ERROR
,
293 .end
= IRQ_UART_ERROR
,
294 .flags
= IORESOURCE_IRQ
,
299 .flags
= IORESOURCE_DMA
,
304 .flags
= IORESOURCE_DMA
,
308 static unsigned short bfin_uart0_peripherals
[] = {
309 P_UART0_TX
, P_UART0_RX
, 0
312 static struct platform_device bfin_uart0_device
= {
315 .num_resources
= ARRAY_SIZE(bfin_uart0_resources
),
316 .resource
= bfin_uart0_resources
,
318 .platform_data
= &bfin_uart0_peripherals
, /* Passed to driver */
324 #if IS_ENABLED(CONFIG_BFIN_SIR)
325 #ifdef CONFIG_BFIN_SIR0
326 static struct resource bfin_sir0_resources
[] = {
330 .flags
= IORESOURCE_MEM
,
333 .start
= IRQ_UART0_RX
,
334 .end
= IRQ_UART0_RX
+1,
335 .flags
= IORESOURCE_IRQ
,
338 .start
= CH_UART0_RX
,
339 .end
= CH_UART0_RX
+1,
340 .flags
= IORESOURCE_DMA
,
344 static struct platform_device bfin_sir0_device
= {
347 .num_resources
= ARRAY_SIZE(bfin_sir0_resources
),
348 .resource
= bfin_sir0_resources
,
353 #if IS_ENABLED(CONFIG_PATA_PLATFORM)
354 #define PATA_INT IRQ_PF46
356 static struct pata_platform_info bfin_pata_platform_data
= {
360 static struct resource bfin_pata_resources
[] = {
364 .flags
= IORESOURCE_MEM
,
369 .flags
= IORESOURCE_MEM
,
374 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
378 static struct platform_device bfin_pata_device
= {
379 .name
= "pata_platform",
381 .num_resources
= ARRAY_SIZE(bfin_pata_resources
),
382 .resource
= bfin_pata_resources
,
384 .platform_data
= &bfin_pata_platform_data
,
389 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
390 static struct mtd_partition para_partitions
[] = {
392 .name
= "bootloader(nor)",
396 .name
= "linux kernel(nor)",
398 .offset
= MTDPART_OFS_APPEND
,
400 .name
= "file system(nor)",
401 .size
= MTDPART_SIZ_FULL
,
402 .offset
= MTDPART_OFS_APPEND
,
406 static struct physmap_flash_data para_flash_data
= {
408 .parts
= para_partitions
,
409 .nr_parts
= ARRAY_SIZE(para_partitions
),
412 static struct resource para_flash_resource
= {
415 .flags
= IORESOURCE_MEM
,
418 static struct platform_device para_flash_device
= {
419 .name
= "physmap-flash",
422 .platform_data
= ¶_flash_data
,
425 .resource
= ¶_flash_resource
,
429 static const unsigned int cclk_vlev_datasheet
[] =
431 VRPAIR(VLEV_085
, 250000000),
432 VRPAIR(VLEV_090
, 300000000),
433 VRPAIR(VLEV_095
, 313000000),
434 VRPAIR(VLEV_100
, 350000000),
435 VRPAIR(VLEV_105
, 400000000),
436 VRPAIR(VLEV_110
, 444000000),
437 VRPAIR(VLEV_115
, 450000000),
438 VRPAIR(VLEV_120
, 475000000),
439 VRPAIR(VLEV_125
, 500000000),
440 VRPAIR(VLEV_130
, 600000000),
443 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
444 .tuple_tab
= cclk_vlev_datasheet
,
445 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
446 .vr_settling_time
= 25 /* us */,
449 static struct platform_device bfin_dpmc
= {
452 .platform_data
= &bfin_dmpc_vreg_data
,
456 static struct platform_device
*cm_bf561_devices
[] __initdata
= {
460 #if IS_ENABLED(CONFIG_FB_HITACHI_TX09)
464 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
465 #ifdef CONFIG_SERIAL_BFIN_UART0
470 #if IS_ENABLED(CONFIG_BFIN_SIR)
471 #ifdef CONFIG_BFIN_SIR0
476 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
480 #if IS_ENABLED(CONFIG_SMC91X)
484 #if IS_ENABLED(CONFIG_SMSC911X)
488 #if IS_ENABLED(CONFIG_USB_NET2272)
489 &net2272_bfin_device
,
492 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
496 #if IS_ENABLED(CONFIG_PATA_PLATFORM)
500 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
505 static int __init
net2272_init(void)
507 #if IS_ENABLED(CONFIG_USB_NET2272)
510 ret
= gpio_request(GPIO_PF46
, "net2272");
514 /* Reset USB Chip, PF46 */
515 gpio_direction_output(GPIO_PF46
, 0);
517 gpio_set_value(GPIO_PF46
, 1);
523 static int __init
cm_bf561_init(void)
525 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
526 platform_add_devices(cm_bf561_devices
, ARRAY_SIZE(cm_bf561_devices
));
527 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
528 spi_register_board_info(bfin_spi_board_info
, ARRAY_SIZE(bfin_spi_board_info
));
531 #if IS_ENABLED(CONFIG_PATA_PLATFORM)
532 irq_set_status_flags(PATA_INT
, IRQ_NOAUTOEN
);
536 pr_warning("unable to configure net2272; it probably won't work\n");
541 arch_initcall(cm_bf561_init
);
543 static struct platform_device
*cm_bf561_early_devices
[] __initdata
= {
544 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
545 #ifdef CONFIG_SERIAL_BFIN_UART0
551 void __init
native_machine_early_platform_add_devices(void)
553 printk(KERN_INFO
"register early platform devices\n");
554 early_platform_add_devices(cm_bf561_early_devices
,
555 ARRAY_SIZE(cm_bf561_early_devices
));