30 #include <linux/module.h>
31 #include <linux/types.h>
32 #include <linux/kernel.h>
34 #include <linux/pci.h>
38 #define DRV_NAME "IT8172"
53 static const u8 timings[] = { 0x3f, 0x3c, 0x1b, 0x12, 0x0a };
55 pci_read_config_word(dev, 0x40, &drive_enables);
56 pci_read_config_dword(dev, 0x44, &drive_timing);
63 drive_enables |= 0x4000;
65 drive_enables &= drive->
dn ? 0xc006 : 0xc060;
68 drive_enables |= 0x0004 << (drive->
dn * 4);
71 drive_enables |= 0x0002 << (drive->
dn * 4);
73 drive_timing &= drive->
dn ? 0x00003f00 : 0x000fc000;
74 drive_timing |= timings[
pio] << (drive->
dn * 6 + 8);
76 pci_write_config_word(dev, 0x40, drive_enables);
77 pci_write_config_dword(dev, 0x44, drive_timing);
83 int a_speed = 3 << (drive->
dn * 4);
84 int u_flag = 1 << drive->
dn;
89 pci_read_config_byte(dev, 0x48, ®48);
90 pci_read_config_byte(dev, 0x4a, ®4a);
94 u_speed = udma << (drive->
dn * 4);
96 pci_write_config_byte(dev, 0x48, reg48 | u_flag);
98 pci_write_config_byte(dev, 0x4a, reg4a | u_speed);
100 const u8 mwdma_to_pio[] = { 0, 3, 4 };
102 pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
103 pci_write_config_byte(dev, 0x4a, reg4a & ~a_speed);
108 it8172_set_pio_mode(hwif, drive);
114 .set_pio_mode = it8172_set_pio_mode,
115 .set_dma_mode = it8172_set_dma_mode,
120 .port_ops = &it8172_port_ops,
121 .enablebits = { {0x41, 0x80, 0x80}, {0x00, 0x00, 0x00} },
142 static struct pci_driver it8172_pci_driver = {
143 .name =
"IT8172_IDE",
144 .id_table = it8172_pci_tbl,
145 .probe = it8172_init_one,
151 static int __init it8172_ide_init(
void)
156 static void __exit it8172_ide_exit(
void)