25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/pci.h>
31 #include <linux/device.h>
36 #define DRV_NAME "pata_ns87415"
37 #define DRV_VERSION "0.0.1"
58 unsigned long T = 1000000000 / 33333;
72 clocking |= (clocking << 8);
73 pci_write_config_word(dev, timing, clocking);
76 pci_read_config_byte(dev, 0x42, &iordy);
77 iordy &= ~(1 << (4 +
unit));
79 iordy |= (1 << (4 + unit));
84 pci_read_config_byte(dev, 0x43, &status);
85 while (status & 0x03) {
87 pci_read_config_byte(dev, 0x43, &status);
91 pci_write_config_byte(dev, 0x42, iordy);
110 ns87415_set_mode(ap, adev, adev->
pio_mode);
141 ap->
ops->sff_exec_command(ap, &qc->
tf);
157 ns87415_set_mode(qc->
ap, qc->
dev, qc->
dev->dma_mode);
171 ns87415_set_mode(qc->
ap, qc->
dev, qc->
dev->pio_mode);
182 static void ns87415_irq_clear(
struct ata_port *ap)
184 void __iomem *mmio = ap->ioaddr.bmdma_addr;
205 #if defined(CONFIG_SUPERIO)
218 #define SUPERIO_IDE_MAX_RETRIES 25
230 int retries = SUPERIO_IDE_MAX_RETRIES;
236 }
while(retries-- > 0);
248 static u8 ns87560_check_status(
struct ata_port *ap)
250 return ns87560_read_buggy(ap->ioaddr.status_addr);
266 struct ata_ioports *ioaddr = &ap->ioaddr;
268 tf->
command = ns87560_check_status(ap);
274 tf->
device = ns87560_read_buggy(ioaddr->device_addr);
284 ap->last_ctl = tf->
ctl;
296 static u8 ns87560_bmdma_status(
struct ata_port *ap)
298 return ns87560_read_buggy(ap->ioaddr.bmdma_addr +
ATA_DMA_STATUS);
303 .inherits = &ata_bmdma_port_ops,
305 .check_atapi_dma = ns87415_check_atapi_dma,
306 .bmdma_setup = ns87415_bmdma_setup,
307 .bmdma_start = ns87415_bmdma_start,
308 .bmdma_stop = ns87415_bmdma_stop,
309 .sff_irq_clear = ns87415_irq_clear,
312 .set_piomode = ns87415_set_piomode,
315 #if defined(CONFIG_SUPERIO)
318 .sff_tf_read = ns87560_tf_read,
319 .sff_check_status = ns87560_check_status,
320 .bmdma_status = ns87560_bmdma_status,
328 static void ns87415_fixup(
struct pci_dev *pdev)
331 pci_write_config_byte(pdev, 0x55, 0xEE);
333 pci_write_config_byte(pdev, 0x54, 0xB7);
357 .port_ops = &ns87415_pata_ops,
361 #if defined(CONFIG_SUPERIO)
366 .port_ops = &ns87560_pata_ops,
380 return ata_pci_bmdma_init_one(pdev, ppi, &ns87415_sht,
NULL, 0);
390 static int ns87415_reinit_one(
struct pci_dev *pdev)
395 rc = ata_pci_device_do_resume(pdev);
401 ata_host_resume(host);
406 static struct pci_driver ns87415_pci_driver = {
408 .id_table = ns87415_pci_tbl,
409 .probe = ns87415_init_one,
410 .remove = ata_pci_remove_one,
412 .suspend = ata_pci_device_suspend,
413 .resume = ns87415_reinit_one,