24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/pci.h>
30 #include <linux/device.h>
36 #define DRV_NAME "pata_rdc"
37 #define DRV_VERSION "0.01"
54 static int rdc_pata_cable_detect(
struct ata_port *ap)
60 mask = 0x30 << (2 * ap->
port_no);
74 static int rdc_pata_prereset(
struct ata_link *
link,
unsigned long deadline)
79 static const struct pci_bits rdc_enable_bits[] = {
80 { 0x41
U, 1
U, 0x80
UL, 0x80UL },
81 { 0x43
U, 1
U, 0x80
UL, 0x80UL },
84 if (!pci_test_config_bits(pdev, &rdc_enable_bits[ap->
port_no]))
107 unsigned int is_slave = (adev->
devno != 0);
108 unsigned int master_port= ap->
port_no ? 0x42 : 0x40;
109 unsigned int slave_port = 0x44;
136 pci_read_config_word(dev, master_port, &master_data);
139 master_data &= 0xff0f;
141 master_data |= 0x4000;
143 master_data |= (control << 4);
144 pci_read_config_byte(dev, slave_port, &slave_data);
145 slave_data &= (ap->
port_no ? 0x0f : 0xf0);
147 slave_data |= ((timings[
pio][0] << 2) | timings[pio][1])
151 master_data &= 0xccf0;
156 (timings[
pio][0] << 12) |
157 (timings[pio][1] << 8);
159 pci_write_config_word(dev, master_port, master_data);
161 pci_write_config_byte(dev, slave_port, slave_data);
166 pci_read_config_byte(dev, 0x48, &udma_enable);
168 pci_write_config_byte(dev, 0x48, udma_enable);
170 spin_unlock_irqrestore(&rdc_lock, flags);
188 u8 master_port = ap->
port_no ? 0x42 : 0x40;
195 u8 timings[][2] = { { 0, 0 },
203 pci_read_config_word(dev, master_port, &master_data);
204 pci_read_config_byte(dev, 0x48, &udma_enable);
210 int u_clock, u_speed;
219 u_speed =
min(2 - (udma & 1), udma);
227 udma_enable |= (1 <<
devid);
230 pci_read_config_word(dev, 0x4A, &udma_timing);
231 udma_timing &= ~(3 << (4 *
devid));
232 udma_timing |= u_speed << (4 *
devid);
233 pci_write_config_word(dev, 0x4A, udma_timing);
236 pci_read_config_word(dev, 0x54, &ideconf);
237 ideconf &= ~(0x1001 <<
devid);
238 ideconf |= u_clock <<
devid;
239 pci_write_config_word(dev, 0x54, ideconf);
249 const unsigned int needed_pio[3] = {
259 if (adev->
pio_mode < needed_pio[mwdma])
264 master_data &= 0xFF4F;
265 master_data |= control << 4;
266 pci_read_config_byte(dev, 0x44, &slave_data);
267 slave_data &= (ap->
port_no ? 0x0f : 0xf0);
269 slave_data |= ((timings[
pio][0] << 2) | timings[pio][1]) << (ap->
port_no ? 4 : 0);
270 pci_write_config_byte(dev, 0x44, slave_data);
272 master_data &= 0xCCF4;
276 (timings[
pio][0] << 12) |
277 (timings[pio][1] << 8);
280 udma_enable &= ~(1 <<
devid);
281 pci_write_config_word(dev, master_port, master_data);
283 pci_write_config_byte(dev, 0x48, udma_enable);
285 spin_unlock_irqrestore(&rdc_lock, flags);
289 .inherits = &ata_bmdma32_port_ops,
290 .cable_detect = rdc_pata_cable_detect,
291 .set_piomode = rdc_set_piomode,
292 .set_dmamode = rdc_set_dmamode,
293 .prereset = rdc_pata_prereset,
302 .port_ops = &rdc_pata_ops,
330 unsigned long port_flags;
354 pci_read_config_dword(pdev, 0x54, &hpriv->
saved_iocfg);
356 rc = ata_pci_bmdma_prepare_host(pdev, ppi, &host);
366 return ata_pci_sff_activate_host(host, ata_bmdma_interrupt, &rdc_sht);
369 static void rdc_remove_one(
struct pci_dev *pdev)
374 pci_write_config_dword(pdev, 0x54, hpriv->
saved_iocfg);
376 ata_pci_remove_one(pdev);
387 .id_table = rdc_pci_tbl,
388 .probe = rdc_init_one,
389 .remove = rdc_remove_one,
391 .suspend = ata_pci_device_suspend,
392 .resume = ata_pci_device_resume,