18 #include <linux/module.h>
19 #include <linux/kernel.h>
20 #include <linux/pci.h>
24 #define DRV_NAME "amd74xx"
35 static unsigned int amd_80w;
36 static unsigned int amd_clock;
38 static char *amd_dma[] = {
"16",
"25",
"33",
"44",
"66",
"100",
"133" };
39 static unsigned char amd_cyc2udma[] = { 6, 6, 5, 4, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 7 };
50 static void amd_set_speed(
struct pci_dev *dev,
u8 dn,
u8 udma_mask,
56 t = (t & ~(3 << ((3 -
dn) << 1))) | ((
clamp_val(timing->
setup, 1, 4) - 1) << ((3 - dn) << 1));
91 T = 1000000000 / amd_clock;
92 UT = (udma_mask ==
ATA_UDMA2) ? T : (T / 2);
101 if (speed ==
XFER_UDMA_5 && amd_clock <= 33333) t.udma = 1;
102 if (speed ==
XFER_UDMA_6 && amd_clock <= 33333) t.udma = 15;
104 amd_set_speed(dev, drive->
dn, udma_mask, &t);
114 amd_set_drive(hwif, drive);
117 static void amd7409_cable_detect(
struct pci_dev *dev)
123 static void amd7411_cable_detect(
struct pci_dev *dev)
131 amd_80w = ((t & 0x3) ? 1 : 0) | ((t & 0xc) ? 2 : 0);
132 for (i = 24; i >= 0; i -= 8)
133 if (((u >> i) & 4) && !(amd_80w & (1 << (1 - (i >> 4))))) {
135 "cable bits correctly. Enabling workaround.\n",
137 amd_80w |= (1 << (1 - (i >> 4)));
145 static int init_chipset_amd74xx(
struct pci_dev *dev)
158 amd7409_cable_detect(dev);
160 amd7411_cable_detect(dev);
182 if ((amd_80w >> hwif->
channel) & 1)
189 .set_pio_mode = amd_set_pio_mode,
190 .set_dma_mode = amd_set_drive,
191 .cable_detect = amd_cable_detect,
194 #define IDE_HFLAGS_AMD \
195 (IDE_HFLAG_PIO_NO_BLACKLIST | \
196 IDE_HFLAG_POST_SET_MODE | \
197 IDE_HFLAG_IO_32BIT | \
198 IDE_HFLAG_UNMASK_IRQS)
200 #define DECLARE_AMD_DEV(swdma, udma) \
203 .init_chipset = init_chipset_amd74xx, \
204 .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \
205 .port_ops = &amd_port_ops, \
206 .host_flags = IDE_HFLAGS_AMD, \
207 .pio_mask = ATA_PIO5, \
208 .swdma_mask = swdma, \
209 .mwdma_mask = ATA_MWDMA2, \
213 #define DECLARE_NV_DEV(udma) \
216 .init_chipset = init_chipset_amd74xx, \
217 .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \
218 .port_ops = &amd_port_ops, \
219 .host_flags = IDE_HFLAGS_AMD, \
220 .pio_mask = ATA_PIO5, \
221 .swdma_mask = ATA_SWDMA2, \
222 .mwdma_mask = ATA_MWDMA2, \
241 u8 idx =
id->driver_data;
243 d = amd74xx_chipsets[
idx];
252 }
else if (idx == 3) {
264 ide_pci_is_in_compatibility_mode(dev))
268 d.name, pci_name(dev), amd_dma[fls(
d.udma_mask) - 1]);
276 case 33000: amd_clock = 33333;
break;
277 case 37000: amd_clock = 37500;
break;
278 case 41000: amd_clock = 41666;
break;
281 if (amd_clock < 20000 || amd_clock > 50000) {
283 " (%d), using 33 MHz instead.\n",
300 #ifdef CONFIG_BLK_DEV_IDE_SATA
305 #ifdef CONFIG_BLK_DEV_IDE_SATA
323 static struct pci_driver amd74xx_pci_driver = {
325 .id_table = amd74xx_pci_tbl,
326 .probe = amd74xx_probe,
332 static int __init amd74xx_ide_init(
void)
337 static void __exit amd74xx_ide_exit(
void)