2 #include <linux/kernel.h>
3 #include <linux/init.h>
5 #include <linux/platform_device.h>
6 #include <linux/ata_platform.h>
8 #include <asm/sibyte/board.h>
9 #include <asm/sibyte/sb1250_genbus.h>
10 #include <asm/sibyte/sb1250_regs.h>
12 #define DRV_NAME "pata-swarm"
14 #define SWARM_IDE_SHIFT 5
15 #define SWARM_IDE_BASE 0x1f0
16 #define SWARM_IDE_CTRL 0x3f6
18 static struct resource swarm_pata_resource
[] = {
20 .name
= "Swarm GenBus IDE",
21 .flags
= IORESOURCE_MEM
,
23 .name
= "Swarm GenBus IDE",
24 .flags
= IORESOURCE_MEM
,
26 .name
= "Swarm GenBus IDE",
27 .flags
= IORESOURCE_IRQ
,
28 .start
= K_INT_GB_IDE
,
33 static struct pata_platform_info pata_platform_data
= {
34 .ioport_shift
= SWARM_IDE_SHIFT
,
37 static struct platform_device swarm_pata_device
= {
38 .name
= "pata_platform",
40 .resource
= swarm_pata_resource
,
41 .num_resources
= ARRAY_SIZE(swarm_pata_resource
),
43 .platform_data
= &pata_platform_data
,
44 .coherent_dma_mask
= ~0, /* grumble */
48 static int __init
swarm_pata_init(void)
57 base
= ioremap(A_IO_EXT_BASE
, 0x800);
58 offset
= __raw_readq(base
+ R_IO_EXT_REG(R_IO_EXT_START_ADDR
, IDE_CS
));
59 size
= __raw_readq(base
+ R_IO_EXT_REG(R_IO_EXT_MULT_SIZE
, IDE_CS
));
62 offset
= G_IO_START_ADDR(offset
) << S_IO_ADDRBASE
;
63 size
= (G_IO_MULT_SIZE(size
) + 1) << S_IO_REGSIZE
;
64 if (offset
< A_PHYS_GENBUS
|| offset
>= A_PHYS_GENBUS_END
) {
65 pr_info(DRV_NAME
": PATA interface at GenBus disabled\n");
70 pr_info(DRV_NAME
": PATA interface at GenBus slot %i\n", IDE_CS
);
72 r
= swarm_pata_resource
;
73 r
[0].start
= offset
+ (SWARM_IDE_BASE
<< SWARM_IDE_SHIFT
);
74 r
[0].end
= offset
+ ((SWARM_IDE_BASE
+ 8) << SWARM_IDE_SHIFT
) - 1;
75 r
[1].start
= offset
+ (SWARM_IDE_CTRL
<< SWARM_IDE_SHIFT
);
76 r
[1].end
= offset
+ ((SWARM_IDE_CTRL
+ 1) << SWARM_IDE_SHIFT
) - 1;
78 return platform_device_register(&swarm_pata_device
);
81 device_initcall(swarm_pata_init
);