10 #include <linux/module.h>
11 #include <linux/types.h>
12 #include <linux/kernel.h>
14 #include <linux/pci.h>
21 #define DRV_NAME "ns87415"
32 #define SUPERIO_IDE_MAX_RETRIES 25
38 static u8 superio_ide_inb (
unsigned long port)
41 int retries = SUPERIO_IDE_MAX_RETRIES;
49 }
while (tmp == 0 && retries-- > 0);
56 return superio_ide_inb(hwif->
io_ports.status_addr);
85 static const struct ide_tp_ops superio_tp_ops = {
87 .read_status = superio_read_status,
91 .dev_select = ns87415_dev_select,
93 .tf_read = superio_tf_read,
108 tmp = superio_ide_inb(dma_stat);
112 #define superio_dma_sff_read_status ide_dma_sff_read_status
115 static unsigned int ns87415_count = 0, ns87415_control[
MAX_HWIFS] = { 0 };
133 bit = 1 << (8 + hwif->
channel);
141 bit = 1 << (20 + (drive->
dn & 1) + (hwif->
channel << 1));
142 other = 1 << (20 + (1 - (drive->
dn & 1)) + (hwif->
channel << 1));
143 new = use_dma ? ((
new & ~other) | bit) : (new & ~bit);
152 (
void) pci_read_config_byte(dev, 0x43, &stat);
153 while (stat & 0x03) {
155 (
void) pci_read_config_byte(dev, 0x43, &stat);
159 (
void) pci_write_config_dword(dev, 0x40,
new);
172 ns87415_prepare_drive(drive,
180 ns87415_prepare_drive(drive, 1);
187 u8 dma_stat = 0, dma_cmd = 0;
189 dma_stat = hwif->
dma_ops->dma_sff_read_status(hwif);
198 ns87415_prepare_drive(drive, 0);
201 return (dma_stat & 7) != 4;
207 unsigned int ctrl, using_inta;
221 (
void) pci_read_config_dword(dev, 0x40, &ctrl);
222 (
void) pci_read_config_byte(dev, 0x09, &progif);
224 using_inta = progif & (1 << (hwif->
channel << 1));
226 using_inta = ctrl & (1 << (4 + hwif->
channel));
231 &ns87415_control[ns87415_count++];
232 ctrl |= (1 << 8) | (1 << 9);
236 (
void) pci_write_config_dword(dev, 0x40, ctrl);
242 pci_write_config_byte(dev, 0x55, 0xee);
255 stat = hwif->
tp_ops->read_status(hwif);
258 }
while ((stat &
ATA_BUSY) && --timeout);
263 hwif->
irq = pci_get_legacy_ide_irq(dev, hwif->
channel);
271 static const struct ide_tp_ops ns87415_tp_ops = {
277 .dev_select = ns87415_dev_select,
285 static const struct ide_dma_ops ns87415_dma_ops = {
288 .dma_start = ns87415_dma_start,
289 .dma_end = ns87415_dma_end,
298 .init_hwif = init_hwif_ns87415,
299 .tp_ops = &ns87415_tp_ops,
300 .dma_ops = &ns87415_dma_ops,
309 #ifdef CONFIG_SUPERIO
313 d.
tp_ops = &superio_tp_ops;
325 static struct pci_driver ns87415_pci_driver = {
326 .name =
"NS87415_IDE",
327 .id_table = ns87415_pci_tbl,
328 .probe = ns87415_init_one,
334 static int __init ns87415_ide_init(
void)
339 static void __exit ns87415_ide_exit(
void)