25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/pci.h>
34 #define DRV_NAME "pata_optidma"
35 #define DRV_VERSION "0.3.2"
55 static int optidma_pre_reset(
struct ata_link *
link,
unsigned long deadline)
59 static const struct pci_bits optidma_enable_bits = {
63 if (ap->
port_no && !pci_test_config_bits(pdev, &optidma_enable_bits))
77 static void optidma_unlock(
struct ata_port *ap)
79 void __iomem *regio = ap->ioaddr.cmd_addr;
94 static void optidma_lock(
struct ata_port *ap)
96 void __iomem *regio = ap->ioaddr.cmd_addr;
121 void __iomem *regio = ap->ioaddr.cmd_addr;
125 static const u8 addr_timing[2][5] = {
126 { 0x30, 0x20, 0x20, 0x10, 0x10 },
127 { 0x20, 0x20, 0x10, 0x10, 0x10 }
129 static const u8 data_rec_timing[2][5] = {
130 { 0x59, 0x46, 0x30, 0x20, 0x20 },
131 { 0x46, 0x32, 0x20, 0x20, 0x10 }
133 static const u8 dma_data_rec_timing[2][3] = {
134 { 0x76, 0x20, 0x20 },
151 addr = addr_timing[pci_clock][
pio];
160 if (pair_addr > addr)
206 int dev2 = 2 * adev->
devno;
210 pci_read_config_byte(pdev, 0x44, &udcfg);
211 if (mode <= XFER_UDMA_0) {
212 udcfg &= ~(1 <<
unit);
213 optidma_mode_setup(ap, adev, adev->
dma_mode);
215 udcfg |= (1 <<
unit);
217 pci_read_config_byte(pdev, 0x45, &udslave);
218 udslave &= ~(0x03 << dev2);
219 udslave |= (udma << dev2);
220 pci_write_config_byte(pdev, 0x45, udslave);
222 udcfg &= ~(0x30 << dev2);
223 udcfg |= (udma << dev2);
226 pci_write_config_byte(pdev, 0x44, udcfg);
241 optidma_mode_setup(ap, adev, adev->
pio_mode);
256 optidma_mode_setup(ap, adev, adev->
dma_mode);
271 optiplus_mode_setup(ap, adev, adev->
pio_mode);
286 optiplus_mode_setup(ap, adev, adev->
dma_mode);
299 static const u8 bits43[5] = {
302 if (!ata_dev_enabled(adev))
326 pci_read_config_byte(pdev, 0x43, &r);
328 r &= (0x0F << nybble);
329 r |= (optidma_make_bits43(&link->
device[0]) +
330 (optidma_make_bits43(&link->
device[0]) << 2)) << nybble;
331 pci_write_config_byte(pdev, 0x43, r);
341 .inherits = &ata_bmdma_port_ops,
343 .set_piomode = optidma_set_pio_mode,
344 .set_dmamode = optidma_set_dma_mode,
345 .set_mode = optidma_set_mode,
346 .prereset = optidma_pre_reset,
350 .inherits = &optidma_port_ops,
352 .set_dmamode = optiplus_set_dma_mode,
360 static int optiplus_with_udma(
struct pci_dev *pdev)
373 pci_read_config_byte(dev1, 0x08, &r);
377 pci_read_config_byte(dev1, 0x5F, &r);
381 if ((
inb(ioport + 2) & 1) == 0)
385 pci_read_config_byte(pdev, 0x42, &r);
386 if ((r & 0x36) != 0x36)
388 pci_read_config_byte(dev1, 0x52, &r);
404 .port_ops = &optidma_port_ops
411 .port_ops = &optiplus_port_ops
425 pci_clock =
inb(0x1F5) & 1;
427 if (optiplus_with_udma(dev))
428 ppi[0] = &info_82c700_udma;
430 return ata_pci_bmdma_init_one(dev, ppi, &optidma_sht,
NULL, 0);
439 static struct pci_driver optidma_pci_driver = {
442 .probe = optidma_init_one,
443 .remove = ata_pci_remove_one,
445 .suspend = ata_pci_device_suspend,
446 .resume = ata_pci_device_resume,