aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:56 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:56 -0400
commit374e042c3e767ac2e5a40b78529220e0b3de793c (patch)
tree433d258f6da9783f0cb34234af9c359353f531fe /drivers/ide/pci
parentd6276b5f5cc7508124de291f3ed59c6945c17ae7 (diff)
ide: add struct ide_tp_ops (take 2)
* Add struct ide_tp_ops for transport methods. * Add 'const struct ide_tp_ops *tp_ops' to struct ide_port_info and ide_hwif_t. * Set the default hwif->tp_ops in ide_init_port_data(). * Set host driver specific hwif->tp_ops in ide_init_port(). * Export ide_exec_command(), ide_read_status(), ide_read_altstatus(), ide_read_sff_dma_status(), ide_set_irq(), ide_tf_{load,read}() and ata_{in,out}put_data(). * Convert host drivers and core code to use struct ide_tp_ops. * Remove no longer needed default_hwif_transport(). * Cleanup ide_hwif_t from methods that are now in struct ide_tp_ops. While at it: * Use struct ide_port_info in falconide.c and q40ide.c. * Rename ata_{in,out}put_data() to ide_{in,out}put_data(). v2: * Fix missing convertion in ns87415.c. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/pci')
-rw-r--r--drivers/ide/pci/ns87415.c50
-rw-r--r--drivers/ide/pci/scc_pata.c29
-rw-r--r--drivers/ide/pci/sgiioc4.c18
3 files changed, 60 insertions, 37 deletions
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c
index 02fd3a877afa..5cd2b32ff0ef 100644
--- a/drivers/ide/pci/ns87415.c
+++ b/drivers/ide/pci/ns87415.c
@@ -104,7 +104,22 @@ static void superio_tf_read(ide_drive_t *drive, ide_task_t *task)
104 } 104 }
105} 105}
106 106
107static void __devinit superio_ide_init_iops (struct hwif_s *hwif) 107static const struct ide_tp_ops superio_tp_ops = {
108 .exec_command = ide_exec_command,
109 .read_status = superio_read_status,
110 .read_altstatus = ide_read_altstatus,
111 .read_sff_dma_status = superio_read_sff_dma_status,
112
113 .set_irq = ide_set_irq,
114
115 .tf_load = ide_tf_load,
116 .tf_read = superio_tf_read,
117
118 .input_data = ide_input_data,
119 .output_data = ide_output_data,
120};
121
122static void __devinit superio_init_iops(struct hwif_s *hwif)
108{ 123{
109 struct pci_dev *pdev = to_pci_dev(hwif->dev); 124 struct pci_dev *pdev = to_pci_dev(hwif->dev);
110 u32 dma_stat; 125 u32 dma_stat;
@@ -115,21 +130,6 @@ static void __devinit superio_ide_init_iops (struct hwif_s *hwif)
115 /* Clear error/interrupt, enable dma */ 130 /* Clear error/interrupt, enable dma */
116 tmp = superio_ide_inb(dma_stat); 131 tmp = superio_ide_inb(dma_stat);
117 outb(tmp | 0x66, dma_stat); 132 outb(tmp | 0x66, dma_stat);
118
119 hwif->read_status = superio_read_status;
120 hwif->read_sff_dma_status = superio_read_sff_dma_status;
121
122 hwif->tf_read = superio_tf_read;
123
124}
125
126static void __devinit init_iops_ns87415(ide_hwif_t *hwif)
127{
128 struct pci_dev *dev = to_pci_dev(hwif->dev);
129
130 if (PCI_SLOT(dev->devfn) == 0xE)
131 /* Built-in - assume it's under superio. */
132 superio_ide_init_iops(hwif);
133} 133}
134#endif 134#endif
135 135
@@ -195,7 +195,7 @@ static int ns87415_dma_end(ide_drive_t *drive)
195 u8 dma_stat = 0, dma_cmd = 0; 195 u8 dma_stat = 0, dma_cmd = 0;
196 196
197 drive->waiting_for_dma = 0; 197 drive->waiting_for_dma = 0;
198 dma_stat = hwif->read_sff_dma_status(hwif); 198 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
199 /* get DMA command mode */ 199 /* get DMA command mode */
200 dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); 200 dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD);
201 /* stop DMA */ 201 /* stop DMA */
@@ -271,7 +271,7 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif)
271 outb(8, hwif->io_ports.ctl_addr); 271 outb(8, hwif->io_ports.ctl_addr);
272 do { 272 do {
273 udelay(50); 273 udelay(50);
274 stat = hwif->read_status(hwif); 274 stat = hwif->tp_ops->read_status(hwif);
275 if (stat == 0xff) 275 if (stat == 0xff)
276 break; 276 break;
277 } while ((stat & BUSY_STAT) && --timeout); 277 } while ((stat & BUSY_STAT) && --timeout);
@@ -306,9 +306,6 @@ static const struct ide_dma_ops ns87415_dma_ops = {
306 306
307static const struct ide_port_info ns87415_chipset __devinitdata = { 307static const struct ide_port_info ns87415_chipset __devinitdata = {
308 .name = "NS87415", 308 .name = "NS87415",
309#ifdef CONFIG_SUPERIO
310 .init_iops = init_iops_ns87415,
311#endif
312 .init_hwif = init_hwif_ns87415, 309 .init_hwif = init_hwif_ns87415,
313 .port_ops = &ns87415_port_ops, 310 .port_ops = &ns87415_port_ops,
314 .dma_ops = &ns87415_dma_ops, 311 .dma_ops = &ns87415_dma_ops,
@@ -318,7 +315,16 @@ static const struct ide_port_info ns87415_chipset __devinitdata = {
318 315
319static int __devinit ns87415_init_one(struct pci_dev *dev, const struct pci_device_id *id) 316static int __devinit ns87415_init_one(struct pci_dev *dev, const struct pci_device_id *id)
320{ 317{
321 return ide_setup_pci_device(dev, &ns87415_chipset); 318 struct ide_port_info d = ns87415_chipset;
319
320#ifdef CONFIG_SUPERIO
321 if (PCI_SLOT(dev->devfn) == 0xE) {
322 /* Built-in - assume it's under superio. */
323 d.init_iops = superio_init_iops;
324 d.tp_ops = &superio_tp_ops;
325 }
326#endif
327 return ide_setup_pci_device(dev, &d);
322} 328}
323 329
324static const struct pci_device_id ns87415_pci_tbl[] = { 330static const struct pci_device_id ns87415_pci_tbl[] = {
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index 38765d9b0314..5b1a0e950dfd 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -808,19 +808,6 @@ static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif)
808 808
809 ide_set_hwifdata(hwif, ports); 809 ide_set_hwifdata(hwif, ports);
810 810
811 hwif->exec_command = scc_exec_command;
812 hwif->read_status = scc_read_status;
813 hwif->read_altstatus = scc_read_altstatus;
814 hwif->read_sff_dma_status = scc_read_sff_dma_status;
815
816 hwif->set_irq = scc_set_irq;
817
818 hwif->tf_load = scc_tf_load;
819 hwif->tf_read = scc_tf_read;
820
821 hwif->input_data = scc_input_data;
822 hwif->output_data = scc_output_data;
823
824 hwif->dma_base = dma_base; 811 hwif->dma_base = dma_base;
825 hwif->config_data = ports->ctl; 812 hwif->config_data = ports->ctl;
826} 813}
@@ -872,6 +859,21 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif)
872 hwif->ultra_mask = ATA_UDMA5; /* 100MHz */ 859 hwif->ultra_mask = ATA_UDMA5; /* 100MHz */
873} 860}
874 861
862static const struct ide_tp_ops scc_tp_ops = {
863 .exec_command = scc_exec_command,
864 .read_status = scc_read_status,
865 .read_altstatus = scc_read_altstatus,
866 .read_sff_dma_status = scc_read_sff_dma_status,
867
868 .set_irq = scc_set_irq,
869
870 .tf_load = scc_tf_load,
871 .tf_read = scc_tf_read,
872
873 .input_data = scc_input_data,
874 .output_data = scc_output_data,
875};
876
875static const struct ide_port_ops scc_port_ops = { 877static const struct ide_port_ops scc_port_ops = {
876 .set_pio_mode = scc_set_pio_mode, 878 .set_pio_mode = scc_set_pio_mode,
877 .set_dma_mode = scc_set_dma_mode, 879 .set_dma_mode = scc_set_dma_mode,
@@ -895,6 +897,7 @@ static const struct ide_dma_ops scc_dma_ops = {
895 .name = name_str, \ 897 .name = name_str, \
896 .init_iops = init_iops_scc, \ 898 .init_iops = init_iops_scc, \
897 .init_hwif = init_hwif_scc, \ 899 .init_hwif = init_hwif_scc, \
900 .tp_ops = &scc_tp_ops, \
898 .port_ops = &scc_port_ops, \ 901 .port_ops = &scc_port_ops, \
899 .dma_ops = &scc_dma_ops, \ 902 .dma_ops = &scc_dma_ops, \
900 .host_flags = IDE_HFLAG_SINGLE, \ 903 .host_flags = IDE_HFLAG_SINGLE, \
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 86f7c4901837..5598bd5936d9 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -550,6 +550,21 @@ static int sgiioc4_dma_setup(ide_drive_t *drive)
550 return 0; 550 return 0;
551} 551}
552 552
553static const struct ide_tp_ops sgiioc4_tp_ops = {
554 .exec_command = ide_exec_command,
555 .read_status = sgiioc4_read_status,
556 .read_altstatus = ide_read_altstatus,
557 .read_sff_dma_status = ide_read_sff_dma_status,
558
559 .set_irq = ide_set_irq,
560
561 .tf_load = ide_tf_load,
562 .tf_read = ide_tf_read,
563
564 .input_data = ide_input_data,
565 .output_data = ide_output_data,
566};
567
553static const struct ide_port_ops sgiioc4_port_ops = { 568static const struct ide_port_ops sgiioc4_port_ops = {
554 .set_dma_mode = sgiioc4_set_dma_mode, 569 .set_dma_mode = sgiioc4_set_dma_mode,
555 /* reset DMA engine, clear IRQs */ 570 /* reset DMA engine, clear IRQs */
@@ -572,6 +587,7 @@ static const struct ide_port_info sgiioc4_port_info __devinitdata = {
572 .name = DRV_NAME, 587 .name = DRV_NAME,
573 .chipset = ide_pci, 588 .chipset = ide_pci,
574 .init_dma = ide_dma_sgiioc4, 589 .init_dma = ide_dma_sgiioc4,
590 .tp_ops = &sgiioc4_tp_ops,
575 .port_ops = &sgiioc4_port_ops, 591 .port_ops = &sgiioc4_port_ops,
576 .dma_ops = &sgiioc4_dma_ops, 592 .dma_ops = &sgiioc4_dma_ops,
577 .host_flags = IDE_HFLAG_MMIO, 593 .host_flags = IDE_HFLAG_MMIO,
@@ -626,8 +642,6 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
626 /* Initializing chipset IRQ Registers */ 642 /* Initializing chipset IRQ Registers */
627 writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); 643 writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4));
628 644
629 hwif->read_status = sgiioc4_read_status;
630
631 idx[0] = hwif->index; 645 idx[0] = hwif->index;
632 646
633 if (ide_device_add(idx, &d, hws)) 647 if (ide_device_add(idx, &d, hws))