14 #include <linux/kernel.h>
15 #include <linux/module.h>
16 #include <linux/pci.h>
20 #include <linux/device.h>
25 #define DRV_NAME "pata_efar"
26 #define DRV_VERSION "0.4.5"
37 static int efar_pre_reset(
struct ata_link *
link,
unsigned long deadline)
39 static const struct pci_bits efar_enable_bits[] = {
40 { 0x41
U, 1
U, 0x80
UL, 0x80UL },
41 { 0x43
U, 1
U, 0x80
UL, 0x80UL },
46 if (!pci_test_config_bits(pdev, &efar_enable_bits[ap->
port_no]))
60 static int efar_cable_detect(
struct ata_port *ap)
65 pci_read_config_byte(pdev, 0x47, &tmp);
88 unsigned int master_port = ap->
port_no ? 0x42 : 0x40;
116 pci_read_config_word(dev, master_port, &master_data);
119 if (adev->
devno == 0) {
120 master_data &= 0xCCF0;
122 master_data |= (timings[
pio][0] << 12) |
123 (timings[pio][1] << 8);
128 master_data &= 0xFF0F;
129 master_data |= (control << 4);
132 pci_read_config_byte(dev, 0x44, &slave_data);
133 slave_data &= ap->
port_no ? 0x0F : 0xF0;
134 slave_data |= ((timings[
pio][0] << 2) | timings[pio][1]) << shift;
135 pci_write_config_byte(dev, 0x44, slave_data);
138 master_data |= 0x4000;
139 pci_write_config_word(dev, master_port, master_data);
141 pci_read_config_byte(dev, 0x48, &udma_enable);
143 pci_write_config_byte(dev, 0x48, udma_enable);
144 spin_unlock_irqrestore(&efar_lock, flags);
161 u8 master_port = ap->
port_no ? 0x42 : 0x40;
169 u8 timings[][2] = { { 0, 0 },
177 pci_read_config_word(dev, master_port, &master_data);
178 pci_read_config_byte(dev, 0x48, &udma_enable);
184 udma_enable |= (1 <<
devid);
187 pci_read_config_word(dev, 0x4A, &udma_timing);
188 udma_timing &= ~(7 << (4 *
devid));
189 udma_timing |= udma << (4 *
devid);
190 pci_write_config_word(dev, 0x4A, udma_timing);
200 const unsigned int needed_pio[3] = {
210 if (adev->
pio_mode < needed_pio[mwdma])
215 master_data &= 0xFF4F;
216 master_data |= control << 4;
217 pci_read_config_byte(dev, 0x44, &slave_data);
218 slave_data &= ap->
port_no ? 0x0F : 0xF0;
220 slave_data |= ((timings[
pio][0] << 2) | timings[pio][1]) << (ap->
port_no ? 4 : 0);
221 pci_write_config_byte(dev, 0x44, slave_data);
223 master_data &= 0xCCF4;
227 (timings[
pio][0] << 12) |
228 (timings[pio][1] << 8);
230 udma_enable &= ~(1 <<
devid);
231 pci_write_config_word(dev, master_port, master_data);
233 pci_write_config_byte(dev, 0x48, udma_enable);
234 spin_unlock_irqrestore(&efar_lock, flags);
242 .inherits = &ata_bmdma_port_ops,
243 .cable_detect = efar_cable_detect,
244 .set_piomode = efar_set_piomode,
245 .set_dmamode = efar_set_dmamode,
246 .prereset = efar_pre_reset,
271 .port_ops = &efar_ops,
277 return ata_pci_bmdma_init_one(pdev, ppi, &efar_sht,
NULL,
289 .id_table = efar_pci_tbl,
290 .probe = efar_init_one,
291 .remove = ata_pci_remove_one,
293 .suspend = ata_pci_device_suspend,
294 .resume = ata_pci_device_resume,