d1f6d68edba1ac6659f7e01f72bd52d4a08dd19c
1 /* Driver for MagicBox 2.0 onboard CompactFlash adapter.
2 * Written by Wojtek Kaniewski <wojtekka@toxygen.net>
4 * GNU General Public License.
7 #include <linux/types.h>
9 #include <linux/interrupt.h>
10 #include <linux/blkdev.h>
11 #include <linux/hdreg.h>
12 #include <linux/ide.h>
13 #include <linux/delay.h>
14 #include <linux/platform_device.h>
21 static int ide_offsets
[IDE_NR_PORTS
] = {0, 2, 4, 6, 8, 10, 12, 14, -1, -1};
23 static u8
magicbox_ide_inb (unsigned long port
)
25 return (u8
) (readw((void __iomem
*) port
) >> 8) & 255;
28 static u16
magicbox_ide_inw (unsigned long port
)
30 return (u16
) readw((void __iomem
*) port
);
33 static void magicbox_ide_insw (unsigned long port
, void *addr
, u32 count
)
37 for (ptr
= addr
; count
--; ptr
++)
38 *ptr
= readw((void __iomem
*) port
);
41 static u32
magicbox_ide_inl (unsigned long port
)
43 return (u32
) readl((void __iomem
*) port
);
46 static void magicbox_ide_insl (unsigned long port
, void *addr
, u32 count
)
50 for (ptr
= addr
; count
--; ptr
++)
51 *ptr
= readl((void __iomem
*) port
);
54 static void magicbox_ide_outb (u8 value
, unsigned long port
)
56 writew(value
<< 8, (void __iomem
*) port
);
59 static void magicbox_ide_outbsync (ide_drive_t
*drive
, u8 value
, unsigned long port
)
61 writew(value
<< 8, (void __iomem
*) port
);
64 static void magicbox_ide_outw (u16 value
, unsigned long port
)
66 writew(value
, (void __iomem
*) port
);
69 static void magicbox_ide_outsw (unsigned long port
, void *addr
, u32 count
)
73 for (ptr
= addr
; count
--; ptr
++)
74 writew(*ptr
, (void __iomem
*) port
);
77 static void magicbox_ide_outl (u32 value
, unsigned long port
)
79 writel(value
, (void __iomem
*) port
);
82 static void magicbox_ide_outsl (unsigned long port
, void *addr
, u32 count
)
86 for (ptr
= addr
; count
--; ptr
++)
87 writel(*ptr
, (void __iomem
*) port
);
91 static void __init
ide_magicbox_register(unsigned long addr
,
92 unsigned long caddr
, int irq
)
97 memset(&hw
, 0, sizeof(hw
));
98 ide_setup_ports(&hw
, addr
, ide_offsets
, caddr
+ 12, 0, NULL
,irq
);
100 if (ide_register_hw(&hw
, &hwif
) != -1)
102 printk(KERN_NOTICE
"magicbox-ide: Registered IDE-CF driver\n");
104 hwif
->drives
[0].unmask
= 1;
105 hwif
->OUTB
= magicbox_ide_outb
;
106 hwif
->OUTBSYNC
= magicbox_ide_outbsync
;
107 hwif
->OUTW
= magicbox_ide_outw
;
108 hwif
->OUTSW
= magicbox_ide_outsw
;
109 hwif
->OUTSL
= magicbox_ide_outsl
;
110 hwif
->INB
= magicbox_ide_inb
;
111 hwif
->INW
= magicbox_ide_inw
;
112 hwif
->INSW
= magicbox_ide_insw
;
113 hwif
->INSL
= magicbox_ide_insl
;
117 void __init
ide_magicbox_init(void)
122 /* Turn on PerWE instead of PCIsomething */
123 mtdcr(DCRN_CPC0_PCI_BASE
, mfdcr(DCRN_CPC0_PCI_BASE
) | (0x80000000L
>> 27));
125 /* PerCS1 (CF's CS0): base 0xff100000, 16-bit, rw */
126 mtdcr(DCRN_EBC_BASE
, 1);
127 mtdcr(DCRN_EBC_BASE
+ 1, 0xff11a000);
128 mtdcr(DCRN_EBC_BASE
, 0x11);
129 mtdcr(DCRN_EBC_BASE
+ 1, 0x080bd800);
131 /* PerCS2 (CF's CS1): base 0xff200000, 16-bit, rw */
132 mtdcr(DCRN_EBC_BASE
, 2);
133 mtdcr(DCRN_EBC_BASE
+ 1, 0xff21a000);
134 mtdcr(DCRN_EBC_BASE
, 0x12);
135 mtdcr(DCRN_EBC_BASE
+ 1, 0x080bd800);
137 /* Remap physical address space */
138 addr
= ioremap_nocache(0xff100000, 4096);
139 caddr
= ioremap_nocache(0xff200000, 4096);
141 /* Set interrupt to low-to-high-edge-triggered */
142 mtdcr(UIC0_TR
, mfdcr(UIC0_TR
) & ~(0x80000000L
>> IRQ
));
143 mtdcr(UIC0_PR
, mfdcr(UIC0_PR
) | (0x80000000L
>> IRQ
));
145 ide_magicbox_register((unsigned long)addr
, (unsigned long)caddr
, IRQ
);
This page took 0.059801 seconds and 3 git commands to generate.