aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/arm/bast-ide.c2
-rw-r--r--drivers/ide/arm/icside.c13
-rw-r--r--drivers/ide/arm/palm_bk3710.c14
-rw-r--r--drivers/ide/cris/ide-cris.c8
-rw-r--r--drivers/ide/ide-dma.c9
-rw-r--r--drivers/ide/ide-io.c5
-rw-r--r--drivers/ide/ide-iops.c28
-rw-r--r--drivers/ide/ide-lib.c24
-rw-r--r--drivers/ide/ide-probe.c20
-rw-r--r--drivers/ide/ide.c3
-rw-r--r--drivers/ide/legacy/ali14xx.c7
-rw-r--r--drivers/ide/legacy/dtc2278.c6
-rw-r--r--drivers/ide/legacy/ht6560b.c13
-rw-r--r--drivers/ide/legacy/ide-cs.c6
-rw-r--r--drivers/ide/legacy/qd65xx.c33
-rw-r--r--drivers/ide/legacy/umc8672.c7
-rw-r--r--drivers/ide/mips/au1xxx-ide.c16
-rw-r--r--drivers/ide/pci/aec62xx.c34
-rw-r--r--drivers/ide/pci/alim15x3.c18
-rw-r--r--drivers/ide/pci/amd74xx.c13
-rw-r--r--drivers/ide/pci/atiixp.c24
-rw-r--r--drivers/ide/pci/cmd640.c10
-rw-r--r--drivers/ide/pci/cmd64x.c17
-rw-r--r--drivers/ide/pci/cs5520.c9
-rw-r--r--drivers/ide/pci/cs5530.c15
-rw-r--r--drivers/ide/pci/cs5535.c22
-rw-r--r--drivers/ide/pci/cy82c693.c16
-rw-r--r--drivers/ide/pci/delkin_cb.c6
-rw-r--r--drivers/ide/pci/hpt34x.c13
-rw-r--r--drivers/ide/pci/hpt366.c27
-rw-r--r--drivers/ide/pci/it8213.c22
-rw-r--r--drivers/ide/pci/it821x.c19
-rw-r--r--drivers/ide/pci/jmicron.c25
-rw-r--r--drivers/ide/pci/ns87415.c7
-rw-r--r--drivers/ide/pci/opti621.c16
-rw-r--r--drivers/ide/pci/pdc202xx_new.c21
-rw-r--r--drivers/ide/pci/pdc202xx_old.c61
-rw-r--r--drivers/ide/pci/piix.c13
-rw-r--r--drivers/ide/pci/sc1200.c11
-rw-r--r--drivers/ide/pci/scc_pata.c13
-rw-r--r--drivers/ide/pci/serverworks.c33
-rw-r--r--drivers/ide/pci/sgiioc4.c19
-rw-r--r--drivers/ide/pci/siimage.c44
-rw-r--r--drivers/ide/pci/sis5513.c30
-rw-r--r--drivers/ide/pci/sl82c105.c11
-rw-r--r--drivers/ide/pci/slc90e66.c14
-rw-r--r--drivers/ide/pci/tc86c001.c12
-rw-r--r--drivers/ide/pci/triflex.c11
-rw-r--r--drivers/ide/pci/trm290.c7
-rw-r--r--drivers/ide/pci/via82cxxx.c14
-rw-r--r--drivers/ide/ppc/mpc8xx.c8
-rw-r--r--drivers/ide/ppc/pmac.c24
-rw-r--r--include/linux/ide.h56
53 files changed, 493 insertions, 436 deletions
diff --git a/drivers/ide/arm/bast-ide.c b/drivers/ide/arm/bast-ide.c
index a80b9574865e..5a2b0f163e84 100644
--- a/drivers/ide/arm/bast-ide.c
+++ b/drivers/ide/arm/bast-ide.c
@@ -56,7 +56,7 @@ static int __init bastide_register(unsigned int base, unsigned int aux, int irq)
56 56
57 ide_init_port_hw(hwif, &hw); 57 ide_init_port_hw(hwif, &hw);
58 hwif->mmio = 1; 58 hwif->mmio = 1;
59 hwif->quirkproc = NULL; 59 hwif->port_ops = NULL;
60 60
61 idx[0] = i; 61 idx[0] = i;
62 62
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c
index fd12bbe93f11..b219818a400a 100644
--- a/drivers/ide/arm/icside.c
+++ b/drivers/ide/arm/icside.c
@@ -191,6 +191,10 @@ static void icside_maskproc(ide_drive_t *drive, int mask)
191 local_irq_restore(flags); 191 local_irq_restore(flags);
192} 192}
193 193
194static const struct ide_port_ops icside_v6_no_dma_port_ops = {
195 .maskproc = icside_maskproc,
196};
197
194#ifdef CONFIG_BLK_DEV_IDEDMA_ICS 198#ifdef CONFIG_BLK_DEV_IDEDMA_ICS
195/* 199/*
196 * SG-DMA support. 200 * SG-DMA support.
@@ -266,6 +270,11 @@ static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode)
266 ide_xfer_verbose(xfer_mode), 2000 / drive->drive_data); 270 ide_xfer_verbose(xfer_mode), 2000 / drive->drive_data);
267} 271}
268 272
273static const struct ide_port_ops icside_v6_port_ops = {
274 .set_dma_mode = icside_set_dma_mode,
275 .maskproc = icside_maskproc,
276};
277
269static void icside_dma_host_set(ide_drive_t *drive, int on) 278static void icside_dma_host_set(ide_drive_t *drive, int on)
270{ 279{
271} 280}
@@ -379,7 +388,6 @@ static void icside_dma_init(ide_hwif_t *hwif)
379{ 388{
380 hwif->dmatable_cpu = NULL; 389 hwif->dmatable_cpu = NULL;
381 hwif->dmatable_dma = 0; 390 hwif->dmatable_dma = 0;
382 hwif->set_dma_mode = icside_set_dma_mode;
383 391
384 hwif->dma_host_set = icside_dma_host_set; 392 hwif->dma_host_set = icside_dma_host_set;
385 hwif->dma_setup = icside_dma_setup; 393 hwif->dma_setup = icside_dma_setup;
@@ -462,6 +470,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
462} 470}
463 471
464static const struct ide_port_info icside_v6_port_info __initdata = { 472static const struct ide_port_info icside_v6_port_info __initdata = {
473 .port_ops = &icside_v6_no_dma_port_ops,
465 .host_flags = IDE_HFLAG_SERIALIZE | 474 .host_flags = IDE_HFLAG_SERIALIZE |
466 IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ 475 IDE_HFLAG_NO_DMA | /* no SFF-style DMA */
467 IDE_HFLAG_NO_AUTOTUNE, 476 IDE_HFLAG_NO_AUTOTUNE,
@@ -526,7 +535,6 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
526 state->hwif[0] = hwif; 535 state->hwif[0] = hwif;
527 state->hwif[1] = mate; 536 state->hwif[1] = mate;
528 537
529 hwif->maskproc = icside_maskproc;
530 hwif->hwif_data = state; 538 hwif->hwif_data = state;
531 hwif->config_data = (unsigned long)ioc_base; 539 hwif->config_data = (unsigned long)ioc_base;
532 hwif->select_data = sel; 540 hwif->select_data = sel;
@@ -539,6 +547,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
539 if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) { 547 if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) {
540 icside_dma_init(hwif); 548 icside_dma_init(hwif);
541 icside_dma_init(mate); 549 icside_dma_init(mate);
550 d.port_ops = &icside_v6_dma_port_ops;
542 } else 551 } else
543 d.mwdma_mask = d.swdma_mask = 0; 552 d.mwdma_mask = d.swdma_mask = 0;
544 553
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c
index 666df779a5f4..9e21b8e6099c 100644
--- a/drivers/ide/arm/palm_bk3710.c
+++ b/drivers/ide/arm/palm_bk3710.c
@@ -317,16 +317,14 @@ static u8 __devinit palm_bk3710_cable_detect(ide_hwif_t *hwif)
317 return ATA_CBL_PATA80; 317 return ATA_CBL_PATA80;
318} 318}
319 319
320static void __devinit palm_bk3710_init_hwif(ide_hwif_t *hwif) 320static const struct ide_port_ops palm_bk3710_ports_ops = {
321{ 321 .set_pio_mode = palm_bk3710_set_pio_mode,
322 hwif->set_pio_mode = palm_bk3710_set_pio_mode; 322 .set_dma_mode = palm_bk3710_set_dma_mode,
323 hwif->set_dma_mode = palm_bk3710_set_dma_mode; 323 .cable_detect = palm_bk3710_cable_detect,
324 324};
325 hwif->cable_detect = palm_bk3710_cable_detect;
326}
327 325
328static const struct ide_port_info __devinitdata palm_bk3710_port_info = { 326static const struct ide_port_info __devinitdata palm_bk3710_port_info = {
329 .init_hwif = palm_bk3710_init_hwif, 327 .port_ops = &palm_bk3710_ports_ops,
330 .host_flags = IDE_HFLAG_NO_DMA, /* hack (no PCI) */ 328 .host_flags = IDE_HFLAG_NO_DMA, /* hack (no PCI) */
331 .pio_mask = ATA_PIO4, 329 .pio_mask = ATA_PIO4,
332 .udma_mask = ATA_UDMA4, /* (input clk 99MHz) */ 330 .udma_mask = ATA_UDMA4, /* (input clk 99MHz) */
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c
index 790a7759d455..c64b4c1b8e50 100644
--- a/drivers/ide/cris/ide-cris.c
+++ b/drivers/ide/cris/ide-cris.c
@@ -782,8 +782,14 @@ static void __init cris_setup_ports(hw_regs_t *hw, unsigned long base)
782 hw->ack_intr = cris_ide_ack_intr; 782 hw->ack_intr = cris_ide_ack_intr;
783} 783}
784 784
785static const struct ide_port_ops cris_port_ops = {
786 .set_pio_mode = cris_set_pio_mode,
787 .set_dma_mode = cris_set_dma_mode,
788};
789
785static const struct ide_port_info cris_port_info __initdata = { 790static const struct ide_port_info cris_port_info __initdata = {
786 .chipset = ide_etrax100, 791 .chipset = ide_etrax100,
792 .port_ops = &cris_port_ops,
787 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | 793 .host_flags = IDE_HFLAG_NO_ATAPI_DMA |
788 IDE_HFLAG_NO_DMA, /* no SFF-style DMA */ 794 IDE_HFLAG_NO_DMA, /* no SFF-style DMA */
789 .pio_mask = ATA_PIO4, 795 .pio_mask = ATA_PIO4,
@@ -810,8 +816,6 @@ static int __init init_e100_ide(void)
810 ide_init_port_data(hwif, hwif->index); 816 ide_init_port_data(hwif, hwif->index);
811 ide_init_port_hw(hwif, &hw); 817 ide_init_port_hw(hwif, &hw);
812 hwif->mmio = 1; 818 hwif->mmio = 1;
813 hwif->set_pio_mode = &cris_set_pio_mode;
814 hwif->set_dma_mode = &cris_set_dma_mode;
815 hwif->ata_input_data = &cris_ide_input_data; 819 hwif->ata_input_data = &cris_ide_input_data;
816 hwif->ata_output_data = &cris_ide_output_data; 820 hwif->ata_output_data = &cris_ide_output_data;
817 hwif->atapi_input_bytes = &cris_atapi_input_bytes; 821 hwif->atapi_input_bytes = &cris_atapi_input_bytes;
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 8757e5ef6c95..dc4bc06f9871 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -574,6 +574,7 @@ static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode)
574{ 574{
575 struct hd_driveid *id = drive->id; 575 struct hd_driveid *id = drive->id;
576 ide_hwif_t *hwif = drive->hwif; 576 ide_hwif_t *hwif = drive->hwif;
577 const struct ide_port_ops *port_ops = hwif->port_ops;
577 unsigned int mask = 0; 578 unsigned int mask = 0;
578 579
579 switch(base) { 580 switch(base) {
@@ -581,8 +582,8 @@ static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode)
581 if ((id->field_valid & 4) == 0) 582 if ((id->field_valid & 4) == 0)
582 break; 583 break;
583 584
584 if (hwif->udma_filter) 585 if (port_ops && port_ops->udma_filter)
585 mask = hwif->udma_filter(drive); 586 mask = port_ops->udma_filter(drive);
586 else 587 else
587 mask = hwif->ultra_mask; 588 mask = hwif->ultra_mask;
588 mask &= id->dma_ultra; 589 mask &= id->dma_ultra;
@@ -598,8 +599,8 @@ static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode)
598 case XFER_MW_DMA_0: 599 case XFER_MW_DMA_0:
599 if ((id->field_valid & 2) == 0) 600 if ((id->field_valid & 2) == 0)
600 break; 601 break;
601 if (hwif->mdma_filter) 602 if (port_ops && port_ops->mdma_filter)
602 mask = hwif->mdma_filter(drive); 603 mask = port_ops->mdma_filter(drive);
603 else 604 else
604 mask = hwif->mwdma_mask; 605 mask = hwif->mwdma_mask;
605 mask &= id->dma_mword; 606 mask &= id->dma_mword;
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 51d181ee9cf7..0d3f9c7aa336 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -721,6 +721,7 @@ static ide_startstop_t do_special (ide_drive_t *drive)
721#endif 721#endif
722 if (s->b.set_tune) { 722 if (s->b.set_tune) {
723 ide_hwif_t *hwif = drive->hwif; 723 ide_hwif_t *hwif = drive->hwif;
724 const struct ide_port_ops *port_ops = hwif->port_ops;
724 u8 req_pio = drive->tune_req; 725 u8 req_pio = drive->tune_req;
725 726
726 s->b.set_tune = 0; 727 s->b.set_tune = 0;
@@ -733,10 +734,10 @@ static ide_startstop_t do_special (ide_drive_t *drive)
733 unsigned long flags; 734 unsigned long flags;
734 735
735 spin_lock_irqsave(&ide_lock, flags); 736 spin_lock_irqsave(&ide_lock, flags);
736 hwif->set_pio_mode(drive, req_pio); 737 port_ops->set_pio_mode(drive, req_pio);
737 spin_unlock_irqrestore(&ide_lock, flags); 738 spin_unlock_irqrestore(&ide_lock, flags);
738 } else 739 } else
739 hwif->set_pio_mode(drive, req_pio); 740 port_ops->set_pio_mode(drive, req_pio);
740 } else { 741 } else {
741 int keep_dma = drive->using_dma; 742 int keep_dma = drive->using_dma;
742 743
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 45944219eea0..bfec5d066b25 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -159,17 +159,20 @@ EXPORT_SYMBOL(default_hwif_mmiops);
159void SELECT_DRIVE (ide_drive_t *drive) 159void SELECT_DRIVE (ide_drive_t *drive)
160{ 160{
161 ide_hwif_t *hwif = drive->hwif; 161 ide_hwif_t *hwif = drive->hwif;
162 const struct ide_port_ops *port_ops = hwif->port_ops;
162 163
163 if (hwif->selectproc) 164 if (port_ops && port_ops->selectproc)
164 hwif->selectproc(drive); 165 port_ops->selectproc(drive);
165 166
166 hwif->OUTB(drive->select.all, hwif->io_ports[IDE_SELECT_OFFSET]); 167 hwif->OUTB(drive->select.all, hwif->io_ports[IDE_SELECT_OFFSET]);
167} 168}
168 169
169void SELECT_MASK (ide_drive_t *drive, int mask) 170void SELECT_MASK (ide_drive_t *drive, int mask)
170{ 171{
171 if (HWIF(drive)->maskproc) 172 const struct ide_port_ops *port_ops = drive->hwif->port_ops;
172 HWIF(drive)->maskproc(drive, mask); 173
174 if (port_ops && port_ops->maskproc)
175 port_ops->maskproc(drive, mask);
173} 176}
174 177
175/* 178/*
@@ -905,10 +908,11 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
905{ 908{
906 ide_hwgroup_t *hwgroup = HWGROUP(drive); 909 ide_hwgroup_t *hwgroup = HWGROUP(drive);
907 ide_hwif_t *hwif = HWIF(drive); 910 ide_hwif_t *hwif = HWIF(drive);
911 const struct ide_port_ops *port_ops = hwif->port_ops;
908 u8 tmp; 912 u8 tmp;
909 913
910 if (hwif->reset_poll != NULL) { 914 if (port_ops && port_ops->reset_poll) {
911 if (hwif->reset_poll(drive)) { 915 if (port_ops->reset_poll(drive)) {
912 printk(KERN_ERR "%s: host reset_poll failure for %s.\n", 916 printk(KERN_ERR "%s: host reset_poll failure for %s.\n",
913 hwif->name, drive->name); 917 hwif->name, drive->name);
914 return ide_stopped; 918 return ide_stopped;
@@ -974,6 +978,8 @@ static void ide_disk_pre_reset(ide_drive_t *drive)
974 978
975static void pre_reset(ide_drive_t *drive) 979static void pre_reset(ide_drive_t *drive)
976{ 980{
981 const struct ide_port_ops *port_ops = drive->hwif->port_ops;
982
977 if (drive->media == ide_disk) 983 if (drive->media == ide_disk)
978 ide_disk_pre_reset(drive); 984 ide_disk_pre_reset(drive);
979 else 985 else
@@ -994,8 +1000,8 @@ static void pre_reset(ide_drive_t *drive)
994 return; 1000 return;
995 } 1001 }
996 1002
997 if (HWIF(drive)->pre_reset != NULL) 1003 if (port_ops && port_ops->pre_reset)
998 HWIF(drive)->pre_reset(drive); 1004 port_ops->pre_reset(drive);
999 1005
1000 if (drive->current_speed != 0xff) 1006 if (drive->current_speed != 0xff)
1001 drive->desired_speed = drive->current_speed; 1007 drive->desired_speed = drive->current_speed;
@@ -1023,6 +1029,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1023 unsigned long flags; 1029 unsigned long flags;
1024 ide_hwif_t *hwif; 1030 ide_hwif_t *hwif;
1025 ide_hwgroup_t *hwgroup; 1031 ide_hwgroup_t *hwgroup;
1032 const struct ide_port_ops *port_ops;
1026 u8 ctl; 1033 u8 ctl;
1027 1034
1028 spin_lock_irqsave(&ide_lock, flags); 1035 spin_lock_irqsave(&ide_lock, flags);
@@ -1089,8 +1096,9 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1089 * state when the disks are reset this way. At least, the Winbond 1096 * state when the disks are reset this way. At least, the Winbond
1090 * 553 documentation says that 1097 * 553 documentation says that
1091 */ 1098 */
1092 if (hwif->resetproc) 1099 port_ops = hwif->port_ops;
1093 hwif->resetproc(drive); 1100 if (port_ops && port_ops->resetproc)
1101 port_ops->resetproc(drive);
1094 1102
1095 spin_unlock_irqrestore(&ide_lock, flags); 1103 spin_unlock_irqrestore(&ide_lock, flags);
1096 return ide_started; 1104 return ide_started;
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index c859de77aa8f..46443f163154 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -288,9 +288,10 @@ EXPORT_SYMBOL_GPL(ide_get_best_pio_mode);
288void ide_set_pio(ide_drive_t *drive, u8 req_pio) 288void ide_set_pio(ide_drive_t *drive, u8 req_pio)
289{ 289{
290 ide_hwif_t *hwif = drive->hwif; 290 ide_hwif_t *hwif = drive->hwif;
291 const struct ide_port_ops *port_ops = hwif->port_ops;
291 u8 host_pio, pio; 292 u8 host_pio, pio;
292 293
293 if (hwif->set_pio_mode == NULL || 294 if (port_ops == NULL || port_ops->set_pio_mode == NULL ||
294 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) 295 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
295 return; 296 return;
296 297
@@ -343,29 +344,30 @@ void ide_toggle_bounce(ide_drive_t *drive, int on)
343int ide_set_pio_mode(ide_drive_t *drive, const u8 mode) 344int ide_set_pio_mode(ide_drive_t *drive, const u8 mode)
344{ 345{
345 ide_hwif_t *hwif = drive->hwif; 346 ide_hwif_t *hwif = drive->hwif;
347 const struct ide_port_ops *port_ops = hwif->port_ops;
346 348
347 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) 349 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
348 return 0; 350 return 0;
349 351
350 if (hwif->set_pio_mode == NULL) 352 if (port_ops == NULL || port_ops->set_pio_mode == NULL)
351 return -1; 353 return -1;
352 354
353 /* 355 /*
354 * TODO: temporary hack for some legacy host drivers that didn't 356 * TODO: temporary hack for some legacy host drivers that didn't
355 * set transfer mode on the device in ->set_pio_mode method... 357 * set transfer mode on the device in ->set_pio_mode method...
356 */ 358 */
357 if (hwif->set_dma_mode == NULL) { 359 if (port_ops->set_dma_mode == NULL) {
358 hwif->set_pio_mode(drive, mode - XFER_PIO_0); 360 port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
359 return 0; 361 return 0;
360 } 362 }
361 363
362 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { 364 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) {
363 if (ide_config_drive_speed(drive, mode)) 365 if (ide_config_drive_speed(drive, mode))
364 return -1; 366 return -1;
365 hwif->set_pio_mode(drive, mode - XFER_PIO_0); 367 port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
366 return 0; 368 return 0;
367 } else { 369 } else {
368 hwif->set_pio_mode(drive, mode - XFER_PIO_0); 370 port_ops->set_pio_mode(drive, mode - XFER_PIO_0);
369 return ide_config_drive_speed(drive, mode); 371 return ide_config_drive_speed(drive, mode);
370 } 372 }
371} 373}
@@ -373,20 +375,21 @@ int ide_set_pio_mode(ide_drive_t *drive, const u8 mode)
373int ide_set_dma_mode(ide_drive_t *drive, const u8 mode) 375int ide_set_dma_mode(ide_drive_t *drive, const u8 mode)
374{ 376{
375 ide_hwif_t *hwif = drive->hwif; 377 ide_hwif_t *hwif = drive->hwif;
378 const struct ide_port_ops *port_ops = hwif->port_ops;
376 379
377 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) 380 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
378 return 0; 381 return 0;
379 382
380 if (hwif->set_dma_mode == NULL) 383 if (port_ops == NULL || port_ops->set_dma_mode == NULL)
381 return -1; 384 return -1;
382 385
383 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { 386 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) {
384 if (ide_config_drive_speed(drive, mode)) 387 if (ide_config_drive_speed(drive, mode))
385 return -1; 388 return -1;
386 hwif->set_dma_mode(drive, mode); 389 port_ops->set_dma_mode(drive, mode);
387 return 0; 390 return 0;
388 } else { 391 } else {
389 hwif->set_dma_mode(drive, mode); 392 port_ops->set_dma_mode(drive, mode);
390 return ide_config_drive_speed(drive, mode); 393 return ide_config_drive_speed(drive, mode);
391 } 394 }
392} 395}
@@ -406,8 +409,9 @@ EXPORT_SYMBOL_GPL(ide_set_dma_mode);
406int ide_set_xfer_rate(ide_drive_t *drive, u8 rate) 409int ide_set_xfer_rate(ide_drive_t *drive, u8 rate)
407{ 410{
408 ide_hwif_t *hwif = drive->hwif; 411 ide_hwif_t *hwif = drive->hwif;
412 const struct ide_port_ops *port_ops = hwif->port_ops;
409 413
410 if (hwif->set_dma_mode == NULL || 414 if (port_ops == NULL || port_ops->set_dma_mode == NULL ||
411 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) 415 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
412 return -1; 416 return -1;
413 417
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 875429728021..dfe516fdd079 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -821,13 +821,14 @@ static int ide_probe_port(ide_hwif_t *hwif)
821 821
822static void ide_port_tune_devices(ide_hwif_t *hwif) 822static void ide_port_tune_devices(ide_hwif_t *hwif)
823{ 823{
824 const struct ide_port_ops *port_ops = hwif->port_ops;
824 int unit; 825 int unit;
825 826
826 for (unit = 0; unit < MAX_DRIVES; unit++) { 827 for (unit = 0; unit < MAX_DRIVES; unit++) {
827 ide_drive_t *drive = &hwif->drives[unit]; 828 ide_drive_t *drive = &hwif->drives[unit];
828 829
829 if (drive->present && hwif->quirkproc) 830 if (drive->present && port_ops && port_ops->quirkproc)
830 hwif->quirkproc(drive); 831 port_ops->quirkproc(drive);
831 } 832 }
832 833
833 for (unit = 0; unit < MAX_DRIVES; ++unit) { 834 for (unit = 0; unit < MAX_DRIVES; ++unit) {
@@ -1324,6 +1325,7 @@ static void hwif_register_devices(ide_hwif_t *hwif)
1324 1325
1325static void ide_port_init_devices(ide_hwif_t *hwif) 1326static void ide_port_init_devices(ide_hwif_t *hwif)
1326{ 1327{
1328 const struct ide_port_ops *port_ops = hwif->port_ops;
1327 int i; 1329 int i;
1328 1330
1329 for (i = 0; i < MAX_DRIVES; i++) { 1331 for (i = 0; i < MAX_DRIVES; i++) {
@@ -1339,8 +1341,8 @@ static void ide_port_init_devices(ide_hwif_t *hwif)
1339 drive->autotune = 1; 1341 drive->autotune = 1;
1340 } 1342 }
1341 1343
1342 if (hwif->port_init_devs) 1344 if (port_ops && port_ops->port_init_devs)
1343 hwif->port_init_devs(hwif); 1345 port_ops->port_init_devs(hwif);
1344} 1346}
1345 1347
1346static void ide_init_port(ide_hwif_t *hwif, unsigned int port, 1348static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
@@ -1365,6 +1367,10 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
1365 hwif->host_flags = d->host_flags; 1367 hwif->host_flags = d->host_flags;
1366 hwif->pio_mask = d->pio_mask; 1368 hwif->pio_mask = d->pio_mask;
1367 1369
1370 /* ->set_pio_mode for DTC2278 is currently limited to port 0 */
1371 if (hwif->chipset != ide_dtc2278 || hwif->channel == 0)
1372 hwif->port_ops = d->port_ops;
1373
1368 if ((d->host_flags & IDE_HFLAG_SERIALIZE) && hwif->mate) 1374 if ((d->host_flags & IDE_HFLAG_SERIALIZE) && hwif->mate)
1369 hwif->mate->serialized = hwif->serialized = 1; 1375 hwif->mate->serialized = hwif->serialized = 1;
1370 1376
@@ -1386,9 +1392,11 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
1386 1392
1387static void ide_port_cable_detect(ide_hwif_t *hwif) 1393static void ide_port_cable_detect(ide_hwif_t *hwif)
1388{ 1394{
1389 if (hwif->cable_detect && (hwif->ultra_mask & 0x78)) { 1395 const struct ide_port_ops *port_ops = hwif->port_ops;
1396
1397 if (port_ops && port_ops->cable_detect && (hwif->ultra_mask & 0x78)) {
1390 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 1398 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
1391 hwif->cbl = hwif->cable_detect(hwif); 1399 hwif->cbl = port_ops->cable_detect(hwif);
1392 } 1400 }
1393} 1401}
1394 1402
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index d868ca44d033..91a3c8aff1e2 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -585,11 +585,12 @@ int set_pio_mode(ide_drive_t *drive, int arg)
585{ 585{
586 struct request rq; 586 struct request rq;
587 ide_hwif_t *hwif = drive->hwif; 587 ide_hwif_t *hwif = drive->hwif;
588 const struct ide_port_ops *port_ops = hwif->port_ops;
588 589
589 if (arg < 0 || arg > 255) 590 if (arg < 0 || arg > 255)
590 return -EINVAL; 591 return -EINVAL;
591 592
592 if (hwif->set_pio_mode == NULL || 593 if (port_ops == NULL || port_ops->set_pio_mode == NULL ||
593 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) 594 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE))
594 return -ENOSYS; 595 return -ENOSYS;
595 596
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c
index 33bb7b87be5d..a940784d5796 100644
--- a/drivers/ide/legacy/ali14xx.c
+++ b/drivers/ide/legacy/ali14xx.c
@@ -192,8 +192,13 @@ static int __init initRegisters(void)
192 return t; 192 return t;
193} 193}
194 194
195static const struct ide_port_ops ali14xx_port_ops = {
196 .set_pio_mode = ali14xx_set_pio_mode,
197};
198
195static const struct ide_port_info ali14xx_port_info = { 199static const struct ide_port_info ali14xx_port_info = {
196 .chipset = ide_ali14xx, 200 .chipset = ide_ali14xx,
201 .port_ops = &ali14xx_port_ops,
197 .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE, 202 .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE,
198 .pio_mask = ATA_PIO4, 203 .pio_mask = ATA_PIO4,
199}; 204};
@@ -224,14 +229,12 @@ static int __init ali14xx_probe(void)
224 hwif = ide_find_port(); 229 hwif = ide_find_port();
225 if (hwif) { 230 if (hwif) {
226 ide_init_port_hw(hwif, &hw[0]); 231 ide_init_port_hw(hwif, &hw[0]);
227 hwif->set_pio_mode = &ali14xx_set_pio_mode;
228 idx[0] = hwif->index; 232 idx[0] = hwif->index;
229 } 233 }
230 234
231 mate = ide_find_port(); 235 mate = ide_find_port();
232 if (mate) { 236 if (mate) {
233 ide_init_port_hw(mate, &hw[1]); 237 ide_init_port_hw(mate, &hw[1]);
234 mate->set_pio_mode = &ali14xx_set_pio_mode;
235 idx[1] = mate->index; 238 idx[1] = mate->index;
236 } 239 }
237 240
diff --git a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c
index 9c6b3249a004..a14abb2c23ed 100644
--- a/drivers/ide/legacy/dtc2278.c
+++ b/drivers/ide/legacy/dtc2278.c
@@ -86,8 +86,13 @@ static void dtc2278_set_pio_mode(ide_drive_t *drive, const u8 pio)
86 } 86 }
87} 87}
88 88
89static const struct ide_port_ops dtc2278_port_ops = {
90 .set_pio_mode = dtc2278_set_pio_mode,
91};
92
89static const struct ide_port_info dtc2278_port_info __initdata = { 93static const struct ide_port_info dtc2278_port_info __initdata = {
90 .chipset = ide_dtc2278, 94 .chipset = ide_dtc2278,
95 .port_ops = &dtc2278_port_ops,
91 .host_flags = IDE_HFLAG_SERIALIZE | 96 .host_flags = IDE_HFLAG_SERIALIZE |
92 IDE_HFLAG_NO_UNMASK_IRQS | 97 IDE_HFLAG_NO_UNMASK_IRQS |
93 IDE_HFLAG_IO_32BIT | 98 IDE_HFLAG_IO_32BIT |
@@ -134,7 +139,6 @@ static int __init dtc2278_probe(void)
134 hwif = ide_find_port(); 139 hwif = ide_find_port();
135 if (hwif) { 140 if (hwif) {
136 ide_init_port_hw(hwif, &hw[0]); 141 ide_init_port_hw(hwif, &hw[0]);
137 hwif->set_pio_mode = dtc2278_set_pio_mode;
138 idx[0] = hwif->index; 142 idx[0] = hwif->index;
139 } 143 }
140 144
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c
index 60f52f5158c9..9d45ed3bffaa 100644
--- a/drivers/ide/legacy/ht6560b.c
+++ b/drivers/ide/legacy/ht6560b.c
@@ -328,8 +328,15 @@ int probe_ht6560b = 0;
328module_param_named(probe, probe_ht6560b, bool, 0); 328module_param_named(probe, probe_ht6560b, bool, 0);
329MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); 329MODULE_PARM_DESC(probe, "probe for HT6560B chipset");
330 330
331static const struct ide_port_ops ht6560b_port_ops = {
332 .port_init_devs = ht6560b_port_init_devs,
333 .set_pio_mode = ht6560b_set_pio_mode,
334 .selectproc = ht6560b_selectproc,
335};
336
331static const struct ide_port_info ht6560b_port_info __initdata = { 337static const struct ide_port_info ht6560b_port_info __initdata = {
332 .chipset = ide_ht6560b, 338 .chipset = ide_ht6560b,
339 .port_ops = &ht6560b_port_ops,
333 .host_flags = IDE_HFLAG_SERIALIZE | /* is this needed? */ 340 .host_flags = IDE_HFLAG_SERIALIZE | /* is this needed? */
334 IDE_HFLAG_NO_DMA | 341 IDE_HFLAG_NO_DMA |
335 IDE_HFLAG_NO_AUTOTUNE | 342 IDE_HFLAG_NO_AUTOTUNE |
@@ -368,18 +375,12 @@ static int __init ht6560b_init(void)
368 hwif = ide_find_port(); 375 hwif = ide_find_port();
369 if (hwif) { 376 if (hwif) {
370 ide_init_port_hw(hwif, &hw[0]); 377 ide_init_port_hw(hwif, &hw[0]);
371 hwif->selectproc = ht6560b_selectproc;
372 hwif->set_pio_mode = ht6560b_set_pio_mode;
373 hwif->port_init_devs = ht6560b_port_init_devs;
374 idx[0] = hwif->index; 378 idx[0] = hwif->index;
375 } 379 }
376 380
377 mate = ide_find_port(); 381 mate = ide_find_port();
378 if (mate) { 382 if (mate) {
379 ide_init_port_hw(mate, &hw[1]); 383 ide_init_port_hw(mate, &hw[1]);
380 mate->selectproc = ht6560b_selectproc;
381 mate->set_pio_mode = ht6560b_set_pio_mode;
382 mate->port_init_devs = ht6560b_port_init_devs;
383 idx[1] = mate->index; 384 idx[1] = mate->index;
384 } 385 }
385 386
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index b97b8d51b3eb..c491850e0f7f 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -143,6 +143,10 @@ static void ide_detach(struct pcmcia_device *link)
143 kfree(link->priv); 143 kfree(link->priv);
144} /* ide_detach */ 144} /* ide_detach */
145 145
146static const struct ide_port_ops idecs_port_ops = {
147 .quirkproc = ide_undecoded_slave,
148};
149
146static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq, struct pcmcia_device *handle) 150static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq, struct pcmcia_device *handle)
147{ 151{
148 ide_hwif_t *hwif; 152 ide_hwif_t *hwif;
@@ -168,7 +172,7 @@ static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq
168 ide_init_port_data(hwif, i); 172 ide_init_port_data(hwif, i);
169 173
170 ide_init_port_hw(hwif, &hw); 174 ide_init_port_hw(hwif, &hw);
171 hwif->quirkproc = &ide_undecoded_slave; 175 hwif->port_ops = &idecs_port_ops;
172 176
173 idx[0] = i; 177 idx[0] = i;
174 178
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c
index 6e820c7c5c6b..65f098d15154 100644
--- a/drivers/ide/legacy/qd65xx.c
+++ b/drivers/ide/legacy/qd65xx.c
@@ -304,6 +304,18 @@ static void __init qd6580_port_init_devs(ide_hwif_t *hwif)
304 hwif->drives[1].drive_data = t2; 304 hwif->drives[1].drive_data = t2;
305} 305}
306 306
307static const struct ide_port_ops qd6500_port_ops = {
308 .port_init_devs = qd6500_port_init_devs,
309 .set_pio_mode = qd6500_set_pio_mode,
310 .selectproc = qd65xx_select,
311};
312
313static const struct ide_port_ops qd6580_port_ops = {
314 .port_init_devs = qd6580_port_init_devs,
315 .set_pio_mode = qd6580_set_pio_mode,
316 .selectproc = qd65xx_select,
317};
318
307static const struct ide_port_info qd65xx_port_info __initdata = { 319static const struct ide_port_info qd65xx_port_info __initdata = {
308 .chipset = ide_qd65xx, 320 .chipset = ide_qd65xx,
309 .host_flags = IDE_HFLAG_IO_32BIT | 321 .host_flags = IDE_HFLAG_IO_32BIT |
@@ -361,6 +373,7 @@ static int __init qd_probe(int base)
361 printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n", 373 printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n",
362 config, QD_ID3); 374 config, QD_ID3);
363 375
376 d.port_ops = &qd6500_port_ops;
364 d.host_flags |= IDE_HFLAG_SINGLE; 377 d.host_flags |= IDE_HFLAG_SINGLE;
365 378
366 hwif = ide_find_port_slot(&d); 379 hwif = ide_find_port_slot(&d);
@@ -371,10 +384,6 @@ static int __init qd_probe(int base)
371 384
372 hwif->config_data = (base << 8) | config; 385 hwif->config_data = (base << 8) | config;
373 386
374 hwif->port_init_devs = qd6500_port_init_devs;
375 hwif->set_pio_mode = qd6500_set_pio_mode;
376 hwif->selectproc = qd65xx_select;
377
378 idx[unit] = hwif->index; 387 idx[unit] = hwif->index;
379 388
380 ide_device_add(idx, &d); 389 ide_device_add(idx, &d);
@@ -400,6 +409,8 @@ static int __init qd_probe(int base)
400 409
401 outb(QD_DEF_CONTR, QD_CONTROL_PORT); 410 outb(QD_DEF_CONTR, QD_CONTROL_PORT);
402 411
412 d.port_ops = &qd6580_port_ops;
413
403 if (control & QD_CONTR_SEC_DISABLED) { 414 if (control & QD_CONTR_SEC_DISABLED) {
404 /* secondary disabled */ 415 /* secondary disabled */
405 416
@@ -415,10 +426,6 @@ static int __init qd_probe(int base)
415 426
416 hwif->config_data = (base << 8) | config; 427 hwif->config_data = (base << 8) | config;
417 428
418 hwif->port_init_devs = qd6580_port_init_devs;
419 hwif->set_pio_mode = qd6580_set_pio_mode;
420 hwif->selectproc = qd65xx_select;
421
422 idx[unit] = hwif->index; 429 idx[unit] = hwif->index;
423 430
424 ide_device_add(idx, &d); 431 ide_device_add(idx, &d);
@@ -433,24 +440,16 @@ static int __init qd_probe(int base)
433 hwif = ide_find_port(); 440 hwif = ide_find_port();
434 if (hwif) { 441 if (hwif) {
435 ide_init_port_hw(hwif, &hw[0]); 442 ide_init_port_hw(hwif, &hw[0]);
436 hwif->config_data = (base << 8) | config;
437 hwif->port_init_devs = qd6580_port_init_devs;
438 hwif->set_pio_mode = qd6580_set_pio_mode;
439 hwif->selectproc = qd65xx_select;
440 idx[0] = hwif->index; 443 idx[0] = hwif->index;
441 } 444 }
442 445
443 mate = ide_find_port(); 446 mate = ide_find_port();
444 if (mate) { 447 if (mate) {
445 ide_init_port_hw(mate, &hw[1]); 448 ide_init_port_hw(mate, &hw[1]);
446 mate->config_data = (base << 8) | config;
447 mate->port_init_devs = qd6580_port_init_devs;
448 mate->set_pio_mode = qd6580_set_pio_mode;
449 mate->selectproc = qd65xx_select;
450 idx[1] = mate->index; 449 idx[1] = mate->index;
451 } 450 }
452 451
453 ide_device_add(idx, &qd65xx_port_info); 452 ide_device_add(idx, &d);
454 453
455 return 0; /* no other qd65xx possible */ 454 return 0; /* no other qd65xx possible */
456 } 455 }
diff --git a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c
index 4d90badd2bda..757156060a6b 100644
--- a/drivers/ide/legacy/umc8672.c
+++ b/drivers/ide/legacy/umc8672.c
@@ -120,8 +120,13 @@ static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio)
120 spin_unlock_irqrestore(&ide_lock, flags); 120 spin_unlock_irqrestore(&ide_lock, flags);
121} 121}
122 122
123static const struct ide_port_ops umc8672_port_ops = {
124 .set_pio_mode = umc_set_pio_mode,
125};
126
123static const struct ide_port_info umc8672_port_info __initdata = { 127static const struct ide_port_info umc8672_port_info __initdata = {
124 .chipset = ide_umc8672, 128 .chipset = ide_umc8672,
129 .port_ops = &umc8672_port_ops,
125 .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE, 130 .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE,
126 .pio_mask = ATA_PIO4, 131 .pio_mask = ATA_PIO4,
127}; 132};
@@ -161,14 +166,12 @@ static int __init umc8672_probe(void)
161 hwif = ide_find_port(); 166 hwif = ide_find_port();
162 if (hwif) { 167 if (hwif) {
163 ide_init_port_hw(hwif, &hw[0]); 168 ide_init_port_hw(hwif, &hw[0]);
164 hwif->set_pio_mode = umc_set_pio_mode;
165 idx[0] = hwif->index; 169 idx[0] = hwif->index;
166 } 170 }
167 171
168 mate = ide_find_port(); 172 mate = ide_find_port();
169 if (mate) { 173 if (mate) {
170 ide_init_port_hw(mate, &hw[1]); 174 ide_init_port_hw(mate, &hw[1]);
171 mate->set_pio_mode = umc_set_pio_mode;
172 idx[1] = mate->index; 175 idx[1] = mate->index;
173 } 176 }
174 177
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c
index a8cd0035936d..51dddc0f154e 100644
--- a/drivers/ide/mips/au1xxx-ide.c
+++ b/drivers/ide/mips/au1xxx-ide.c
@@ -543,7 +543,16 @@ static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif)
543 *ata_regs = ahwif->regbase + (14 << AU1XXX_ATA_REG_OFFSET); 543 *ata_regs = ahwif->regbase + (14 << AU1XXX_ATA_REG_OFFSET);
544} 544}
545 545
546static const struct ide_port_ops au1xxx_port_ops = {
547 .set_pio_mode = au1xxx_set_pio_mode,
548 .set_dma_mode = auide_set_dma_mode,
549#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
550 .mdma_filter = auide_mdma_filter,
551#endif
552};
553
546static const struct ide_port_info au1xxx_port_info = { 554static const struct ide_port_info au1xxx_port_info = {
555 .port_ops = &au1xxx_port_ops,
547 .host_flags = IDE_HFLAG_POST_SET_MODE | 556 .host_flags = IDE_HFLAG_POST_SET_MODE |
548 IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ 557 IDE_HFLAG_NO_DMA | /* no SFF-style DMA */
549 IDE_HFLAG_NO_IO_32BIT | 558 IDE_HFLAG_NO_IO_32BIT |
@@ -625,15 +634,8 @@ static int au_ide_probe(struct device *dev)
625 hwif->INSW = auide_insw; 634 hwif->INSW = auide_insw;
626 hwif->OUTSW = auide_outsw; 635 hwif->OUTSW = auide_outsw;
627#endif 636#endif
628
629 hwif->set_pio_mode = &au1xxx_set_pio_mode;
630 hwif->set_dma_mode = &auide_set_dma_mode;
631
632#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 637#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
633 hwif->dma_timeout = &auide_dma_timeout; 638 hwif->dma_timeout = &auide_dma_timeout;
634
635 hwif->mdma_filter = &auide_mdma_filter;
636
637 hwif->dma_host_set = &auide_dma_host_set; 639 hwif->dma_host_set = &auide_dma_host_set;
638 hwif->dma_exec_cmd = &auide_dma_exec_cmd; 640 hwif->dma_exec_cmd = &auide_dma_exec_cmd;
639 hwif->dma_start = &auide_dma_start; 641 hwif->dma_start = &auide_dma_start;
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index c9ba15afe97d..ca16f37f9486 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -135,7 +135,7 @@ static void aec6260_set_mode(ide_drive_t *drive, const u8 speed)
135 135
136static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio) 136static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio)
137{ 137{
138 drive->hwif->set_dma_mode(drive, pio + XFER_PIO_0); 138 drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0);
139} 139}
140 140
141static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name) 141static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name)
@@ -175,27 +175,23 @@ static u8 __devinit atp86x_cable_detect(ide_hwif_t *hwif)
175 return (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; 175 return (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
176} 176}
177 177
178static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) 178static const struct ide_port_ops atp850_port_ops = {
179{ 179 .set_pio_mode = aec_set_pio_mode,
180 struct pci_dev *dev = to_pci_dev(hwif->dev); 180 .set_dma_mode = aec6210_set_mode,
181 181};
182 hwif->set_pio_mode = &aec_set_pio_mode;
183
184 if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF)
185 hwif->set_dma_mode = &aec6210_set_mode;
186 else {
187 hwif->set_dma_mode = &aec6260_set_mode;
188 182
189 hwif->cable_detect = atp86x_cable_detect; 183static const struct ide_port_ops atp86x_port_ops = {
190 } 184 .set_pio_mode = aec_set_pio_mode,
191} 185 .set_dma_mode = aec6260_set_mode,
186 .cable_detect = atp86x_cable_detect,
187};
192 188
193static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { 189static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
194 { /* 0 */ 190 { /* 0 */
195 .name = "AEC6210", 191 .name = "AEC6210",
196 .init_chipset = init_chipset_aec62xx, 192 .init_chipset = init_chipset_aec62xx,
197 .init_hwif = init_hwif_aec62xx,
198 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, 193 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
194 .port_ops = &atp850_port_ops,
199 .host_flags = IDE_HFLAG_SERIALIZE | 195 .host_flags = IDE_HFLAG_SERIALIZE |
200 IDE_HFLAG_NO_ATAPI_DMA | 196 IDE_HFLAG_NO_ATAPI_DMA |
201 IDE_HFLAG_NO_DSC | 197 IDE_HFLAG_NO_DSC |
@@ -207,7 +203,7 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
207 },{ /* 1 */ 203 },{ /* 1 */
208 .name = "AEC6260", 204 .name = "AEC6260",
209 .init_chipset = init_chipset_aec62xx, 205 .init_chipset = init_chipset_aec62xx,
210 .init_hwif = init_hwif_aec62xx, 206 .port_ops = &atp86x_port_ops,
211 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA | 207 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA |
212 IDE_HFLAG_ABUSE_SET_DMA_MODE | 208 IDE_HFLAG_ABUSE_SET_DMA_MODE |
213 IDE_HFLAG_OFF_BOARD, 209 IDE_HFLAG_OFF_BOARD,
@@ -217,8 +213,8 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
217 },{ /* 2 */ 213 },{ /* 2 */
218 .name = "AEC6260R", 214 .name = "AEC6260R",
219 .init_chipset = init_chipset_aec62xx, 215 .init_chipset = init_chipset_aec62xx,
220 .init_hwif = init_hwif_aec62xx,
221 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, 216 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
217 .port_ops = &atp86x_port_ops,
222 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | 218 .host_flags = IDE_HFLAG_NO_ATAPI_DMA |
223 IDE_HFLAG_ABUSE_SET_DMA_MODE | 219 IDE_HFLAG_ABUSE_SET_DMA_MODE |
224 IDE_HFLAG_NON_BOOTABLE, 220 IDE_HFLAG_NON_BOOTABLE,
@@ -228,7 +224,7 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
228 },{ /* 3 */ 224 },{ /* 3 */
229 .name = "AEC6280", 225 .name = "AEC6280",
230 .init_chipset = init_chipset_aec62xx, 226 .init_chipset = init_chipset_aec62xx,
231 .init_hwif = init_hwif_aec62xx, 227 .port_ops = &atp86x_port_ops,
232 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | 228 .host_flags = IDE_HFLAG_NO_ATAPI_DMA |
233 IDE_HFLAG_ABUSE_SET_DMA_MODE | 229 IDE_HFLAG_ABUSE_SET_DMA_MODE |
234 IDE_HFLAG_OFF_BOARD, 230 IDE_HFLAG_OFF_BOARD,
@@ -238,8 +234,8 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
238 },{ /* 4 */ 234 },{ /* 4 */
239 .name = "AEC6280R", 235 .name = "AEC6280R",
240 .init_chipset = init_chipset_aec62xx, 236 .init_chipset = init_chipset_aec62xx,
241 .init_hwif = init_hwif_aec62xx,
242 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, 237 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
238 .port_ops = &atp86x_port_ops,
243 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | 239 .host_flags = IDE_HFLAG_NO_ATAPI_DMA |
244 IDE_HFLAG_ABUSE_SET_DMA_MODE | 240 IDE_HFLAG_ABUSE_SET_DMA_MODE |
245 IDE_HFLAG_OFF_BOARD, 241 IDE_HFLAG_OFF_BOARD,
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index 3fa2d9f7b1b2..ec9fba8ad342 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -610,7 +610,7 @@ static int ali_cable_override(struct pci_dev *pdev)
610} 610}
611 611
612/** 612/**
613 * ata66_ali15x3 - check for UDMA 66 support 613 * ali_cable_detect - cable detection
614 * @hwif: IDE interface 614 * @hwif: IDE interface
615 * 615 *
616 * This checks if the controller and the cable are capable 616 * This checks if the controller and the cable are capable
@@ -620,7 +620,7 @@ static int ali_cable_override(struct pci_dev *pdev)
620 * FIXME: frobs bits that are not defined on newer ALi devicea 620 * FIXME: frobs bits that are not defined on newer ALi devicea
621 */ 621 */
622 622
623static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif) 623static u8 __devinit ali_cable_detect(ide_hwif_t *hwif)
624{ 624{
625 struct pci_dev *dev = to_pci_dev(hwif->dev); 625 struct pci_dev *dev = to_pci_dev(hwif->dev);
626 unsigned long flags; 626 unsigned long flags;
@@ -661,12 +661,6 @@ static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif)
661 661
662static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif) 662static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif)
663{ 663{
664 hwif->set_pio_mode = &ali_set_pio_mode;
665 hwif->set_dma_mode = &ali_set_dma_mode;
666 hwif->udma_filter = &ali_udma_filter;
667
668 hwif->cable_detect = ata66_ali15x3;
669
670 if (hwif->dma_base == 0) 664 if (hwif->dma_base == 0)
671 return; 665 return;
672 666
@@ -745,11 +739,19 @@ static void __devinit init_dma_ali15x3 (ide_hwif_t *hwif, unsigned long dmabase)
745 ide_setup_dma(hwif, dmabase); 739 ide_setup_dma(hwif, dmabase);
746} 740}
747 741
742static const struct ide_port_ops ali_port_ops = {
743 .set_pio_mode = ali_set_pio_mode,
744 .set_dma_mode = ali_set_dma_mode,
745 .udma_filter = ali_udma_filter,
746 .cable_detect = ali_cable_detect,
747};
748
748static const struct ide_port_info ali15x3_chipset __devinitdata = { 749static const struct ide_port_info ali15x3_chipset __devinitdata = {
749 .name = "ALI15X3", 750 .name = "ALI15X3",
750 .init_chipset = init_chipset_ali15x3, 751 .init_chipset = init_chipset_ali15x3,
751 .init_hwif = init_hwif_ali15x3, 752 .init_hwif = init_hwif_ali15x3,
752 .init_dma = init_dma_ali15x3, 753 .init_dma = init_dma_ali15x3,
754 .port_ops = &ali_port_ops,
753 .pio_mask = ATA_PIO5, 755 .pio_mask = ATA_PIO5,
754 .swdma_mask = ATA_SWDMA2, 756 .swdma_mask = ATA_SWDMA2,
755 .mwdma_mask = ATA_MWDMA2, 757 .mwdma_mask = ATA_MWDMA2,
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
index ff684d312378..f7c883808b02 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -210,13 +210,14 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
210 210
211 if (hwif->irq == 0) /* 0 is bogus but will do for now */ 211 if (hwif->irq == 0) /* 0 is bogus but will do for now */
212 hwif->irq = pci_get_legacy_ide_irq(dev, hwif->channel); 212 hwif->irq = pci_get_legacy_ide_irq(dev, hwif->channel);
213
214 hwif->set_pio_mode = &amd_set_pio_mode;
215 hwif->set_dma_mode = &amd_set_drive;
216
217 hwif->cable_detect = amd_cable_detect;
218} 213}
219 214
215static const struct ide_port_ops amd_port_ops = {
216 .set_pio_mode = amd_set_pio_mode,
217 .set_dma_mode = amd_set_drive,
218 .cable_detect = amd_cable_detect,
219};
220
220#define IDE_HFLAGS_AMD \ 221#define IDE_HFLAGS_AMD \
221 (IDE_HFLAG_PIO_NO_BLACKLIST | \ 222 (IDE_HFLAG_PIO_NO_BLACKLIST | \
222 IDE_HFLAG_ABUSE_SET_DMA_MODE | \ 223 IDE_HFLAG_ABUSE_SET_DMA_MODE | \
@@ -230,6 +231,7 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
230 .init_chipset = init_chipset_amd74xx, \ 231 .init_chipset = init_chipset_amd74xx, \
231 .init_hwif = init_hwif_amd74xx, \ 232 .init_hwif = init_hwif_amd74xx, \
232 .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ 233 .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \
234 .port_ops = &amd_port_ops, \
233 .host_flags = IDE_HFLAGS_AMD, \ 235 .host_flags = IDE_HFLAGS_AMD, \
234 .pio_mask = ATA_PIO5, \ 236 .pio_mask = ATA_PIO5, \
235 .swdma_mask = swdma, \ 237 .swdma_mask = swdma, \
@@ -243,6 +245,7 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
243 .init_chipset = init_chipset_amd74xx, \ 245 .init_chipset = init_chipset_amd74xx, \
244 .init_hwif = init_hwif_amd74xx, \ 246 .init_hwif = init_hwif_amd74xx, \
245 .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ 247 .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \
248 .port_ops = &amd_port_ops, \
246 .host_flags = IDE_HFLAGS_AMD, \ 249 .host_flags = IDE_HFLAGS_AMD, \
247 .pio_mask = ATA_PIO5, \ 250 .pio_mask = ATA_PIO5, \
248 .swdma_mask = ATA_SWDMA2, \ 251 .swdma_mask = ATA_SWDMA2, \
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c
index 91722f88b7bd..8b637181681a 100644
--- a/drivers/ide/pci/atiixp.c
+++ b/drivers/ide/pci/atiixp.c
@@ -130,35 +130,25 @@ static u8 __devinit atiixp_cable_detect(ide_hwif_t *hwif)
130 return ATA_CBL_PATA40; 130 return ATA_CBL_PATA40;
131} 131}
132 132
133/** 133static const struct ide_port_ops atiixp_port_ops = {
134 * init_hwif_atiixp - fill in the hwif for the ATIIXP 134 .set_pio_mode = atiixp_set_pio_mode,
135 * @hwif: IDE interface 135 .set_dma_mode = atiixp_set_dma_mode,
136 * 136 .cable_detect = atiixp_cable_detect,
137 * Set up the ide_hwif_t for the ATIIXP interface according to the 137};
138 * capabilities of the hardware.
139 */
140
141static void __devinit init_hwif_atiixp(ide_hwif_t *hwif)
142{
143 hwif->set_pio_mode = &atiixp_set_pio_mode;
144 hwif->set_dma_mode = &atiixp_set_dma_mode;
145
146 hwif->cable_detect = atiixp_cable_detect;
147}
148 138
149static const struct ide_port_info atiixp_pci_info[] __devinitdata = { 139static const struct ide_port_info atiixp_pci_info[] __devinitdata = {
150 { /* 0 */ 140 { /* 0 */
151 .name = "ATIIXP", 141 .name = "ATIIXP",
152 .init_hwif = init_hwif_atiixp,
153 .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}}, 142 .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}},
143 .port_ops = &atiixp_port_ops,
154 .host_flags = IDE_HFLAG_LEGACY_IRQS, 144 .host_flags = IDE_HFLAG_LEGACY_IRQS,
155 .pio_mask = ATA_PIO4, 145 .pio_mask = ATA_PIO4,
156 .mwdma_mask = ATA_MWDMA2, 146 .mwdma_mask = ATA_MWDMA2,
157 .udma_mask = ATA_UDMA5, 147 .udma_mask = ATA_UDMA5,
158 },{ /* 1 */ 148 },{ /* 1 */
159 .name = "SB600_PATA", 149 .name = "SB600_PATA",
160 .init_hwif = init_hwif_atiixp,
161 .enablebits = {{0x48,0x01,0x00}, {0x00,0x00,0x00}}, 150 .enablebits = {{0x48,0x01,0x00}, {0x00,0x00,0x00}},
151 .port_ops = &atiixp_port_ops,
162 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_LEGACY_IRQS, 152 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_LEGACY_IRQS,
163 .pio_mask = ATA_PIO4, 153 .pio_mask = ATA_PIO4,
164 .mwdma_mask = ATA_MWDMA2, 154 .mwdma_mask = ATA_MWDMA2,
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
index b076dbfc43a7..de1bbdcf2297 100644
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/pci/cmd640.c
@@ -633,6 +633,9 @@ static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio)
633 display_clocks(index); 633 display_clocks(index);
634} 634}
635 635
636static const struct ide_port_ops cmd640_port_ops = {
637 .set_pio_mode = cmd640_set_pio_mode,
638};
636#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ 639#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
637 640
638static int pci_conf1(void) 641static int pci_conf1(void)
@@ -678,6 +681,7 @@ static const struct ide_port_info cmd640_port_info __initdata = {
678 IDE_HFLAG_ABUSE_PREFETCH | 681 IDE_HFLAG_ABUSE_PREFETCH |
679 IDE_HFLAG_ABUSE_FAST_DEVSEL, 682 IDE_HFLAG_ABUSE_FAST_DEVSEL,
680#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED 683#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
684 .port_ops = &cmd640_port_ops,
681 .pio_mask = ATA_PIO5, 685 .pio_mask = ATA_PIO5,
682#endif 686#endif
683}; 687};
@@ -752,9 +756,6 @@ static int __init cmd640x_init(void)
752 */ 756 */
753 if (cmd_hwif0) { 757 if (cmd_hwif0) {
754 ide_init_port_hw(cmd_hwif0, &hw[0]); 758 ide_init_port_hw(cmd_hwif0, &hw[0]);
755#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
756 cmd_hwif0->set_pio_mode = &cmd640_set_pio_mode;
757#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
758 759
759 idx[0] = cmd_hwif0->index; 760 idx[0] = cmd_hwif0->index;
760 } 761 }
@@ -808,9 +809,6 @@ static int __init cmd640x_init(void)
808 */ 809 */
809 if (second_port_cmd640 && cmd_hwif1) { 810 if (second_port_cmd640 && cmd_hwif1) {
810 ide_init_port_hw(cmd_hwif1, &hw[1]); 811 ide_init_port_hw(cmd_hwif1, &hw[1]);
811#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
812 cmd_hwif1->set_pio_mode = &cmd640_set_pio_mode;
813#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
814 812
815 idx[1] = cmd_hwif1->index; 813 idx[1] = cmd_hwif1->index;
816 } 814 }
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
index 8baccfef237f..5411ded791bb 100644
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -370,7 +370,7 @@ static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const cha
370 return 0; 370 return 0;
371} 371}
372 372
373static u8 __devinit ata66_cmd64x(ide_hwif_t *hwif) 373static u8 __devinit cmd64x_cable_detect(ide_hwif_t *hwif)
374{ 374{
375 struct pci_dev *dev = to_pci_dev(hwif->dev); 375 struct pci_dev *dev = to_pci_dev(hwif->dev);
376 u8 bmidecsr = 0, mask = hwif->channel ? 0x02 : 0x01; 376 u8 bmidecsr = 0, mask = hwif->channel ? 0x02 : 0x01;
@@ -389,11 +389,6 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif)
389{ 389{
390 struct pci_dev *dev = to_pci_dev(hwif->dev); 390 struct pci_dev *dev = to_pci_dev(hwif->dev);
391 391
392 hwif->set_pio_mode = &cmd64x_set_pio_mode;
393 hwif->set_dma_mode = &cmd64x_set_dma_mode;
394
395 hwif->cable_detect = ata66_cmd64x;
396
397 if (!hwif->dma_base) 392 if (!hwif->dma_base)
398 return; 393 return;
399 394
@@ -433,12 +428,19 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif)
433 } 428 }
434} 429}
435 430
431static const struct ide_port_ops cmd64x_port_ops = {
432 .set_pio_mode = cmd64x_set_pio_mode,
433 .set_dma_mode = cmd64x_set_dma_mode,
434 .cable_detect = cmd64x_cable_detect,
435};
436
436static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { 437static const struct ide_port_info cmd64x_chipsets[] __devinitdata = {
437 { /* 0 */ 438 { /* 0 */
438 .name = "CMD643", 439 .name = "CMD643",
439 .init_chipset = init_chipset_cmd64x, 440 .init_chipset = init_chipset_cmd64x,
440 .init_hwif = init_hwif_cmd64x, 441 .init_hwif = init_hwif_cmd64x,
441 .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, 442 .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}},
443 .port_ops = &cmd64x_port_ops,
442 .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | 444 .host_flags = IDE_HFLAG_CLEAR_SIMPLEX |
443 IDE_HFLAG_ABUSE_PREFETCH, 445 IDE_HFLAG_ABUSE_PREFETCH,
444 .pio_mask = ATA_PIO5, 446 .pio_mask = ATA_PIO5,
@@ -450,6 +452,7 @@ static const struct ide_port_info cmd64x_chipsets[] __devinitdata = {
450 .init_hwif = init_hwif_cmd64x, 452 .init_hwif = init_hwif_cmd64x,
451 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, 453 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
452 .chipset = ide_cmd646, 454 .chipset = ide_cmd646,
455 .port_ops = &cmd64x_port_ops,
453 .host_flags = IDE_HFLAG_ABUSE_PREFETCH, 456 .host_flags = IDE_HFLAG_ABUSE_PREFETCH,
454 .pio_mask = ATA_PIO5, 457 .pio_mask = ATA_PIO5,
455 .mwdma_mask = ATA_MWDMA2, 458 .mwdma_mask = ATA_MWDMA2,
@@ -459,6 +462,7 @@ static const struct ide_port_info cmd64x_chipsets[] __devinitdata = {
459 .init_chipset = init_chipset_cmd64x, 462 .init_chipset = init_chipset_cmd64x,
460 .init_hwif = init_hwif_cmd64x, 463 .init_hwif = init_hwif_cmd64x,
461 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, 464 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
465 .port_ops = &cmd64x_port_ops,
462 .host_flags = IDE_HFLAG_ABUSE_PREFETCH, 466 .host_flags = IDE_HFLAG_ABUSE_PREFETCH,
463 .pio_mask = ATA_PIO5, 467 .pio_mask = ATA_PIO5,
464 .mwdma_mask = ATA_MWDMA2, 468 .mwdma_mask = ATA_MWDMA2,
@@ -468,6 +472,7 @@ static const struct ide_port_info cmd64x_chipsets[] __devinitdata = {
468 .init_chipset = init_chipset_cmd64x, 472 .init_chipset = init_chipset_cmd64x,
469 .init_hwif = init_hwif_cmd64x, 473 .init_hwif = init_hwif_cmd64x,
470 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, 474 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
475 .port_ops = &cmd64x_port_ops,
471 .host_flags = IDE_HFLAG_ABUSE_PREFETCH, 476 .host_flags = IDE_HFLAG_ABUSE_PREFETCH,
472 .pio_mask = ATA_PIO5, 477 .pio_mask = ATA_PIO5,
473 .mwdma_mask = ATA_MWDMA2, 478 .mwdma_mask = ATA_MWDMA2,
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
index 01b37ecb5a5a..41559c6de0ca 100644
--- a/drivers/ide/pci/cs5520.c
+++ b/drivers/ide/pci/cs5520.c
@@ -105,19 +105,22 @@ static void cs5520_dma_host_set(ide_drive_t *drive, int on)
105 105
106static void __devinit init_hwif_cs5520(ide_hwif_t *hwif) 106static void __devinit init_hwif_cs5520(ide_hwif_t *hwif)
107{ 107{
108 hwif->set_pio_mode = &cs5520_set_pio_mode;
109 hwif->set_dma_mode = &cs5520_set_dma_mode;
110
111 if (hwif->dma_base == 0) 108 if (hwif->dma_base == 0)
112 return; 109 return;
113 110
114 hwif->dma_host_set = &cs5520_dma_host_set; 111 hwif->dma_host_set = &cs5520_dma_host_set;
115} 112}
116 113
114static const struct ide_port_ops cs5520_port_ops = {
115 .set_pio_mode = cs5520_set_pio_mode,
116 .set_dma_mode = cs5520_set_dma_mode,
117};
118
117#define DECLARE_CS_DEV(name_str) \ 119#define DECLARE_CS_DEV(name_str) \
118 { \ 120 { \
119 .name = name_str, \ 121 .name = name_str, \
120 .init_hwif = init_hwif_cs5520, \ 122 .init_hwif = init_hwif_cs5520, \
123 .port_ops = &cs5520_port_ops, \
121 .host_flags = IDE_HFLAG_ISA_PORTS | \ 124 .host_flags = IDE_HFLAG_ISA_PORTS | \
122 IDE_HFLAG_CS5520 | \ 125 IDE_HFLAG_CS5520 | \
123 IDE_HFLAG_VDMA | \ 126 IDE_HFLAG_VDMA | \
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c
index 56a369c2a78a..f5534c1ff349 100644
--- a/drivers/ide/pci/cs5530.c
+++ b/drivers/ide/pci/cs5530.c
@@ -228,26 +228,25 @@ static void __devinit init_hwif_cs5530 (ide_hwif_t *hwif)
228 unsigned long basereg; 228 unsigned long basereg;
229 u32 d0_timings; 229 u32 d0_timings;
230 230
231 hwif->set_pio_mode = &cs5530_set_pio_mode;
232 hwif->set_dma_mode = &cs5530_set_dma_mode;
233
234 basereg = CS5530_BASEREG(hwif); 231 basereg = CS5530_BASEREG(hwif);
235 d0_timings = inl(basereg + 0); 232 d0_timings = inl(basereg + 0);
236 if (CS5530_BAD_PIO(d0_timings)) 233 if (CS5530_BAD_PIO(d0_timings))
237 outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 0); 234 outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 0);
238 if (CS5530_BAD_PIO(inl(basereg + 8))) 235 if (CS5530_BAD_PIO(inl(basereg + 8)))
239 outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 8); 236 outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 8);
240
241 if (hwif->dma_base == 0)
242 return;
243
244 hwif->udma_filter = cs5530_udma_filter;
245} 237}
246 238
239static const struct ide_port_ops cs5530_port_ops = {
240 .set_pio_mode = cs5530_set_pio_mode,
241 .set_dma_mode = cs5530_set_dma_mode,
242 .udma_filter = cs5530_udma_filter,
243};
244
247static const struct ide_port_info cs5530_chipset __devinitdata = { 245static const struct ide_port_info cs5530_chipset __devinitdata = {
248 .name = "CS5530", 246 .name = "CS5530",
249 .init_chipset = init_chipset_cs5530, 247 .init_chipset = init_chipset_cs5530,
250 .init_hwif = init_hwif_cs5530, 248 .init_hwif = init_hwif_cs5530,
249 .port_ops = &cs5530_port_ops,
251 .host_flags = IDE_HFLAG_SERIALIZE | 250 .host_flags = IDE_HFLAG_SERIALIZE |
252 IDE_HFLAG_POST_SET_MODE, 251 IDE_HFLAG_POST_SET_MODE,
253 .pio_mask = ATA_PIO4, 252 .pio_mask = ATA_PIO4,
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c
index c9685f239c65..99fe91a191b8 100644
--- a/drivers/ide/pci/cs5535.c
+++ b/drivers/ide/pci/cs5535.c
@@ -166,25 +166,15 @@ static u8 __devinit cs5535_cable_detect(ide_hwif_t *hwif)
166 return (bit & 1) ? ATA_CBL_PATA80 : ATA_CBL_PATA40; 166 return (bit & 1) ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
167} 167}
168 168
169/**** 169static const struct ide_port_ops cs5535_port_ops = {
170 * init_hwif_cs5535 - Initialize one ide cannel 170 .set_pio_mode = cs5535_set_pio_mode,
171 * @hwif: Channel descriptor 171 .set_dma_mode = cs5535_set_dma_mode,
172 * 172 .cable_detect = cs5535_cable_detect,
173 * This gets invoked by the IDE driver once for each channel. It 173};
174 * performs channel-specific pre-initialization before drive probing.
175 *
176 */
177static void __devinit init_hwif_cs5535(ide_hwif_t *hwif)
178{
179 hwif->set_pio_mode = &cs5535_set_pio_mode;
180 hwif->set_dma_mode = &cs5535_set_dma_mode;
181
182 hwif->cable_detect = cs5535_cable_detect;
183}
184 174
185static const struct ide_port_info cs5535_chipset __devinitdata = { 175static const struct ide_port_info cs5535_chipset __devinitdata = {
186 .name = "CS5535", 176 .name = "CS5535",
187 .init_hwif = init_hwif_cs5535, 177 .port_ops = &cs5535_port_ops,
188 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE | 178 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE |
189 IDE_HFLAG_ABUSE_SET_DMA_MODE, 179 IDE_HFLAG_ABUSE_SET_DMA_MODE,
190 .pio_mask = ATA_PIO4, 180 .pio_mask = ATA_PIO4,
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c
index 08eab7e7f051..e30eae5a01b6 100644
--- a/drivers/ide/pci/cy82c693.c
+++ b/drivers/ide/pci/cy82c693.c
@@ -382,15 +382,6 @@ static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev, const c
382 return 0; 382 return 0;
383} 383}
384 384
385/*
386 * the init function - called for each ide channel once
387 */
388static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif)
389{
390 hwif->set_pio_mode = &cy82c693_set_pio_mode;
391 hwif->set_dma_mode = &cy82c693_set_dma_mode;
392}
393
394static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) 385static void __devinit init_iops_cy82c693(ide_hwif_t *hwif)
395{ 386{
396 static ide_hwif_t *primary; 387 static ide_hwif_t *primary;
@@ -404,11 +395,16 @@ static void __devinit init_iops_cy82c693(ide_hwif_t *hwif)
404 } 395 }
405} 396}
406 397
398static const struct ide_port_ops cy82c693_port_ops = {
399 .set_pio_mode = cy82c693_set_pio_mode,
400 .set_dma_mode = cy82c693_set_dma_mode,
401};
402
407static const struct ide_port_info cy82c693_chipset __devinitdata = { 403static const struct ide_port_info cy82c693_chipset __devinitdata = {
408 .name = "CY82C693", 404 .name = "CY82C693",
409 .init_chipset = init_chipset_cy82c693, 405 .init_chipset = init_chipset_cy82c693,
410 .init_iops = init_iops_cy82c693, 406 .init_iops = init_iops_cy82c693,
411 .init_hwif = init_hwif_cy82c693, 407 .port_ops = &cy82c693_port_ops,
412 .chipset = ide_cy82c693, 408 .chipset = ide_cy82c693,
413 .host_flags = IDE_HFLAG_SINGLE, 409 .host_flags = IDE_HFLAG_SINGLE,
414 .pio_mask = ATA_PIO4, 410 .pio_mask = ATA_PIO4,
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c
index 753b86fc6637..cb9af61da2ee 100644
--- a/drivers/ide/pci/delkin_cb.c
+++ b/drivers/ide/pci/delkin_cb.c
@@ -43,6 +43,10 @@ static const u8 setup[] = {
43 0x00, 0x00, 0x00, 0x00, 0xa4, 0x83, 0x02, 0x13, 43 0x00, 0x00, 0x00, 0x00, 0xa4, 0x83, 0x02, 0x13,
44}; 44};
45 45
46static const struct ide_port_ops delkin_cb_port_ops = {
47 .quirkproc = ide_undecoded_slave,
48};
49
46static int __devinit 50static int __devinit
47delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) 51delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
48{ 52{
@@ -90,7 +94,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
90 94
91 ide_init_port_hw(hwif, &hw); 95 ide_init_port_hw(hwif, &hw);
92 hwif->mmio = 1; 96 hwif->mmio = 1;
93 hwif->quirkproc = &ide_undecoded_slave; 97 hwif->port_ops = &delkin_cb_port_ops;
94 98
95 idx[0] = i; 99 idx[0] = i;
96 100
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
index 9f2fc3094000..e4193ef56797 100644
--- a/drivers/ide/pci/hpt34x.c
+++ b/drivers/ide/pci/hpt34x.c
@@ -115,11 +115,10 @@ static unsigned int __devinit init_chipset_hpt34x(struct pci_dev *dev, const cha
115 return dev->irq; 115 return dev->irq;
116} 116}
117 117
118static void __devinit init_hwif_hpt34x(ide_hwif_t *hwif) 118static const struct ide_port_ops hpt34x_port_ops = {
119{ 119 .set_pio_mode = hpt34x_set_pio_mode,
120 hwif->set_pio_mode = &hpt34x_set_pio_mode; 120 .set_dma_mode = hpt34x_set_mode,
121 hwif->set_dma_mode = &hpt34x_set_mode; 121};
122}
123 122
124#define IDE_HFLAGS_HPT34X \ 123#define IDE_HFLAGS_HPT34X \
125 (IDE_HFLAG_NO_ATAPI_DMA | \ 124 (IDE_HFLAG_NO_ATAPI_DMA | \
@@ -131,16 +130,16 @@ static const struct ide_port_info hpt34x_chipsets[] __devinitdata = {
131 { /* 0 */ 130 { /* 0 */
132 .name = "HPT343", 131 .name = "HPT343",
133 .init_chipset = init_chipset_hpt34x, 132 .init_chipset = init_chipset_hpt34x,
134 .init_hwif = init_hwif_hpt34x,
135 .extra = 16, 133 .extra = 16,
134 .port_ops = &hpt34x_port_ops,
136 .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_NON_BOOTABLE, 135 .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_NON_BOOTABLE,
137 .pio_mask = ATA_PIO5, 136 .pio_mask = ATA_PIO5,
138 }, 137 },
139 { /* 1 */ 138 { /* 1 */
140 .name = "HPT345", 139 .name = "HPT345",
141 .init_chipset = init_chipset_hpt34x, 140 .init_chipset = init_chipset_hpt34x,
142 .init_hwif = init_hwif_hpt34x,
143 .extra = 16, 141 .extra = 16,
142 .port_ops = &hpt34x_port_ops,
144 .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_OFF_BOARD, 143 .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_OFF_BOARD,
145 .pio_mask = ATA_PIO5, 144 .pio_mask = ATA_PIO5,
146#ifdef CONFIG_HPT34X_AUTODMA 145#ifdef CONFIG_HPT34X_AUTODMA
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index a49090672145..1592dbf6c5cb 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -1271,17 +1271,6 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1271 /* Cache the channel's MISC. control registers' offset */ 1271 /* Cache the channel's MISC. control registers' offset */
1272 hwif->select_data = hwif->channel ? 0x54 : 0x50; 1272 hwif->select_data = hwif->channel ? 0x54 : 0x50;
1273 1273
1274 hwif->set_pio_mode = &hpt3xx_set_pio_mode;
1275 hwif->set_dma_mode = &hpt3xx_set_mode;
1276
1277 hwif->quirkproc = &hpt3xx_quirkproc;
1278 hwif->maskproc = &hpt3xx_maskproc;
1279
1280 hwif->udma_filter = &hpt3xx_udma_filter;
1281 hwif->mdma_filter = &hpt3xx_mdma_filter;
1282
1283 hwif->cable_detect = hpt3xx_cable_detect;
1284
1285 /* 1274 /*
1286 * HPT3xxN chips have some complications: 1275 * HPT3xxN chips have some complications:
1287 * 1276 *
@@ -1416,6 +1405,16 @@ static int __devinit hpt36x_init(struct pci_dev *dev, struct pci_dev *dev2)
1416 IDE_HFLAG_ABUSE_SET_DMA_MODE | \ 1405 IDE_HFLAG_ABUSE_SET_DMA_MODE | \
1417 IDE_HFLAG_OFF_BOARD) 1406 IDE_HFLAG_OFF_BOARD)
1418 1407
1408static const struct ide_port_ops hpt3xx_port_ops = {
1409 .set_pio_mode = hpt3xx_set_pio_mode,
1410 .set_dma_mode = hpt3xx_set_mode,
1411 .quirkproc = hpt3xx_quirkproc,
1412 .maskproc = hpt3xx_maskproc,
1413 .mdma_filter = hpt3xx_mdma_filter,
1414 .udma_filter = hpt3xx_udma_filter,
1415 .cable_detect = hpt3xx_cable_detect,
1416};
1417
1419static const struct ide_port_info hpt366_chipsets[] __devinitdata = { 1418static const struct ide_port_info hpt366_chipsets[] __devinitdata = {
1420 { /* 0 */ 1419 { /* 0 */
1421 .name = "HPT36x", 1420 .name = "HPT36x",
@@ -1430,6 +1429,7 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = {
1430 */ 1429 */
1431 .enablebits = {{0x50,0x10,0x10}, {0x54,0x04,0x04}}, 1430 .enablebits = {{0x50,0x10,0x10}, {0x54,0x04,0x04}},
1432 .extra = 240, 1431 .extra = 240,
1432 .port_ops = &hpt3xx_port_ops,
1433 .host_flags = IDE_HFLAGS_HPT3XX | IDE_HFLAG_SINGLE, 1433 .host_flags = IDE_HFLAGS_HPT3XX | IDE_HFLAG_SINGLE,
1434 .pio_mask = ATA_PIO4, 1434 .pio_mask = ATA_PIO4,
1435 .mwdma_mask = ATA_MWDMA2, 1435 .mwdma_mask = ATA_MWDMA2,
@@ -1440,6 +1440,7 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = {
1440 .init_dma = init_dma_hpt366, 1440 .init_dma = init_dma_hpt366,
1441 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, 1441 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
1442 .extra = 240, 1442 .extra = 240,
1443 .port_ops = &hpt3xx_port_ops,
1443 .host_flags = IDE_HFLAGS_HPT3XX, 1444 .host_flags = IDE_HFLAGS_HPT3XX,
1444 .pio_mask = ATA_PIO4, 1445 .pio_mask = ATA_PIO4,
1445 .mwdma_mask = ATA_MWDMA2, 1446 .mwdma_mask = ATA_MWDMA2,
@@ -1450,6 +1451,7 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = {
1450 .init_dma = init_dma_hpt366, 1451 .init_dma = init_dma_hpt366,
1451 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, 1452 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
1452 .extra = 240, 1453 .extra = 240,
1454 .port_ops = &hpt3xx_port_ops,
1453 .host_flags = IDE_HFLAGS_HPT3XX, 1455 .host_flags = IDE_HFLAGS_HPT3XX,
1454 .pio_mask = ATA_PIO4, 1456 .pio_mask = ATA_PIO4,
1455 .mwdma_mask = ATA_MWDMA2, 1457 .mwdma_mask = ATA_MWDMA2,
@@ -1460,6 +1462,7 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = {
1460 .init_dma = init_dma_hpt366, 1462 .init_dma = init_dma_hpt366,
1461 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, 1463 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
1462 .extra = 240, 1464 .extra = 240,
1465 .port_ops = &hpt3xx_port_ops,
1463 .host_flags = IDE_HFLAGS_HPT3XX, 1466 .host_flags = IDE_HFLAGS_HPT3XX,
1464 .pio_mask = ATA_PIO4, 1467 .pio_mask = ATA_PIO4,
1465 .mwdma_mask = ATA_MWDMA2, 1468 .mwdma_mask = ATA_MWDMA2,
@@ -1471,6 +1474,7 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = {
1471 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, 1474 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
1472 .udma_mask = ATA_UDMA5, 1475 .udma_mask = ATA_UDMA5,
1473 .extra = 240, 1476 .extra = 240,
1477 .port_ops = &hpt3xx_port_ops,
1474 .host_flags = IDE_HFLAGS_HPT3XX, 1478 .host_flags = IDE_HFLAGS_HPT3XX,
1475 .pio_mask = ATA_PIO4, 1479 .pio_mask = ATA_PIO4,
1476 .mwdma_mask = ATA_MWDMA2, 1480 .mwdma_mask = ATA_MWDMA2,
@@ -1481,6 +1485,7 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = {
1481 .init_dma = init_dma_hpt366, 1485 .init_dma = init_dma_hpt366,
1482 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, 1486 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
1483 .extra = 240, 1487 .extra = 240,
1488 .port_ops = &hpt3xx_port_ops,
1484 .host_flags = IDE_HFLAGS_HPT3XX, 1489 .host_flags = IDE_HFLAGS_HPT3XX,
1485 .pio_mask = ATA_PIO4, 1490 .pio_mask = ATA_PIO4,
1486 .mwdma_mask = ATA_MWDMA2, 1491 .mwdma_mask = ATA_MWDMA2,
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c
index 5b5b0cc4b76a..9053c8771e6e 100644
--- a/drivers/ide/pci/it8213.c
+++ b/drivers/ide/pci/it8213.c
@@ -149,27 +149,17 @@ static u8 __devinit it8213_cable_detect(ide_hwif_t *hwif)
149 return (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; 149 return (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
150} 150}
151 151
152/** 152static const struct ide_port_ops it8213_port_ops = {
153 * init_hwif_it8213 - set up hwif structs 153 .set_pio_mode = it8213_set_pio_mode,
154 * @hwif: interface to set up 154 .set_dma_mode = it8213_set_dma_mode,
155 * 155 .cable_detect = it8213_cable_detect,
156 * We do the basic set up of the interface structure. 156};
157 */
158
159static void __devinit init_hwif_it8213(ide_hwif_t *hwif)
160{
161 hwif->set_dma_mode = &it8213_set_dma_mode;
162 hwif->set_pio_mode = &it8213_set_pio_mode;
163
164 hwif->cable_detect = it8213_cable_detect;
165}
166
167 157
168#define DECLARE_ITE_DEV(name_str) \ 158#define DECLARE_ITE_DEV(name_str) \
169 { \ 159 { \
170 .name = name_str, \ 160 .name = name_str, \
171 .init_hwif = init_hwif_it8213, \
172 .enablebits = { {0x41, 0x80, 0x80} }, \ 161 .enablebits = { {0x41, 0x80, 0x80} }, \
162 .port_ops = &it8213_port_ops, \
173 .host_flags = IDE_HFLAG_SINGLE, \ 163 .host_flags = IDE_HFLAG_SINGLE, \
174 .pio_mask = ATA_PIO4, \ 164 .pio_mask = ATA_PIO4, \
175 .swdma_mask = ATA_SWDMA2_ONLY, \ 165 .swdma_mask = ATA_SWDMA2_ONLY, \
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index a38ec47423a0..7f4db1c0a4fc 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -418,7 +418,7 @@ static void it821x_set_dma_mode(ide_drive_t *drive, const u8 speed)
418} 418}
419 419
420/** 420/**
421 * ata66_it821x - check for 80 pin cable 421 * it821x_cable_detect - cable detection
422 * @hwif: interface to check 422 * @hwif: interface to check
423 * 423 *
424 * Check for the presence of an ATA66 capable cable on the 424 * Check for the presence of an ATA66 capable cable on the
@@ -426,7 +426,7 @@ static void it821x_set_dma_mode(ide_drive_t *drive, const u8 speed)
426 * the needed logic onboard. 426 * the needed logic onboard.
427 */ 427 */
428 428
429static u8 __devinit ata66_it821x(ide_hwif_t *hwif) 429static u8 __devinit it821x_cable_detect(ide_hwif_t *hwif)
430{ 430{
431 /* The reference driver also only does disk side */ 431 /* The reference driver also only does disk side */
432 return ATA_CBL_PATA80; 432 return ATA_CBL_PATA80;
@@ -527,8 +527,6 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
527 struct it821x_dev *idev = itdevs[hwif->channel]; 527 struct it821x_dev *idev = itdevs[hwif->channel];
528 u8 conf; 528 u8 conf;
529 529
530 hwif->quirkproc = &it821x_quirkproc;
531
532 ide_set_hwifdata(hwif, idev); 530 ide_set_hwifdata(hwif, idev);
533 531
534 pci_read_config_byte(dev, 0x50, &conf); 532 pci_read_config_byte(dev, 0x50, &conf);
@@ -563,17 +561,12 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
563 } 561 }
564 562
565 if (idev->smart == 0) { 563 if (idev->smart == 0) {
566 hwif->set_pio_mode = &it821x_set_pio_mode;
567 hwif->set_dma_mode = &it821x_set_dma_mode;
568
569 /* MWDMA/PIO clock switching for pass through mode */ 564 /* MWDMA/PIO clock switching for pass through mode */
570 hwif->dma_start = &it821x_dma_start; 565 hwif->dma_start = &it821x_dma_start;
571 hwif->ide_dma_end = &it821x_dma_end; 566 hwif->ide_dma_end = &it821x_dma_end;
572 } else 567 } else
573 hwif->host_flags |= IDE_HFLAG_NO_SET_MODE; 568 hwif->host_flags |= IDE_HFLAG_NO_SET_MODE;
574 569
575 hwif->cable_detect = ata66_it821x;
576
577 if (hwif->dma_base == 0) 570 if (hwif->dma_base == 0)
578 return; 571 return;
579 572
@@ -613,12 +606,20 @@ static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const cha
613 return 0; 606 return 0;
614} 607}
615 608
609static const struct ide_port_ops it821x_port_ops = {
610 /* it821x_set_{pio,dma}_mode() are only used in pass-through mode */
611 .set_pio_mode = it821x_set_pio_mode,
612 .set_dma_mode = it821x_set_dma_mode,
613 .quirkproc = it821x_quirkproc,
614 .cable_detect = it821x_cable_detect,
615};
616 616
617#define DECLARE_ITE_DEV(name_str) \ 617#define DECLARE_ITE_DEV(name_str) \
618 { \ 618 { \
619 .name = name_str, \ 619 .name = name_str, \
620 .init_chipset = init_chipset_it821x, \ 620 .init_chipset = init_chipset_it821x, \
621 .init_hwif = init_hwif_it821x, \ 621 .init_hwif = init_hwif_it821x, \
622 .port_ops = &it821x_port_ops, \
622 .pio_mask = ATA_PIO4, \ 623 .pio_mask = ATA_PIO4, \
623 } 624 }
624 625
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c
index 673f7dc8ba65..96ef7394f283 100644
--- a/drivers/ide/pci/jmicron.c
+++ b/drivers/ide/pci/jmicron.c
@@ -19,13 +19,13 @@ typedef enum {
19} port_type; 19} port_type;
20 20
21/** 21/**
22 * ata66_jmicron - Cable check 22 * jmicron_cable_detect - cable detection
23 * @hwif: IDE port 23 * @hwif: IDE port
24 * 24 *
25 * Returns the cable type. 25 * Returns the cable type.
26 */ 26 */
27 27
28static u8 __devinit ata66_jmicron(ide_hwif_t *hwif) 28static u8 __devinit jmicron_cable_detect(ide_hwif_t *hwif)
29{ 29{
30 struct pci_dev *pdev = to_pci_dev(hwif->dev); 30 struct pci_dev *pdev = to_pci_dev(hwif->dev);
31 31
@@ -95,25 +95,16 @@ static void jmicron_set_dma_mode(ide_drive_t *drive, const u8 mode)
95{ 95{
96} 96}
97 97
98/** 98static const struct ide_port_ops jmicron_port_ops = {
99 * init_hwif_jmicron - set up hwif structs 99 .set_pio_mode = jmicron_set_pio_mode,
100 * @hwif: interface to set up 100 .set_dma_mode = jmicron_set_dma_mode,
101 * 101 .cable_detect = jmicron_cable_detect,
102 * Minimal set up is required for the Jmicron hardware. 102};
103 */
104
105static void __devinit init_hwif_jmicron(ide_hwif_t *hwif)
106{
107 hwif->set_pio_mode = &jmicron_set_pio_mode;
108 hwif->set_dma_mode = &jmicron_set_dma_mode;
109
110 hwif->cable_detect = ata66_jmicron;
111}
112 103
113static const struct ide_port_info jmicron_chipset __devinitdata = { 104static const struct ide_port_info jmicron_chipset __devinitdata = {
114 .name = "JMB", 105 .name = "JMB",
115 .init_hwif = init_hwif_jmicron,
116 .enablebits = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } }, 106 .enablebits = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } },
107 .port_ops = &jmicron_port_ops,
117 .pio_mask = ATA_PIO5, 108 .pio_mask = ATA_PIO5,
118 .mwdma_mask = ATA_MWDMA2, 109 .mwdma_mask = ATA_MWDMA2,
119 .udma_mask = ATA_UDMA6, 110 .udma_mask = ATA_UDMA6,
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c
index 3015d6916d4c..332de832f171 100644
--- a/drivers/ide/pci/ns87415.c
+++ b/drivers/ide/pci/ns87415.c
@@ -195,8 +195,6 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif)
195 u8 stat; 195 u8 stat;
196#endif 196#endif
197 197
198 hwif->selectproc = &ns87415_selectproc;
199
200 /* 198 /*
201 * We cannot probe for IRQ: both ports share common IRQ on INTA. 199 * We cannot probe for IRQ: both ports share common IRQ on INTA.
202 * Also, leave IRQ masked during drive probing, to prevent infinite 200 * Also, leave IRQ masked during drive probing, to prevent infinite
@@ -258,12 +256,17 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif)
258 hwif->ide_dma_end = &ns87415_ide_dma_end; 256 hwif->ide_dma_end = &ns87415_ide_dma_end;
259} 257}
260 258
259static const struct ide_port_ops ns87415_port_ops = {
260 .selectproc = ns87415_selectproc,
261};
262
261static const struct ide_port_info ns87415_chipset __devinitdata = { 263static const struct ide_port_info ns87415_chipset __devinitdata = {
262 .name = "NS87415", 264 .name = "NS87415",
263#ifdef CONFIG_SUPERIO 265#ifdef CONFIG_SUPERIO
264 .init_iops = init_iops_ns87415, 266 .init_iops = init_iops_ns87415,
265#endif 267#endif
266 .init_hwif = init_hwif_ns87415, 268 .init_hwif = init_hwif_ns87415,
269 .port_ops = &ns87415_port_ops,
267 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | 270 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA |
268 IDE_HFLAG_NO_ATAPI_DMA, 271 IDE_HFLAG_NO_ATAPI_DMA,
269}; 272};
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c
index 88a4dd94eeea..9edacba20ffb 100644
--- a/drivers/ide/pci/opti621.c
+++ b/drivers/ide/pci/opti621.c
@@ -326,28 +326,24 @@ static void __devinit opti621_port_init_devs(ide_hwif_t *hwif)
326 hwif->drives[1].drive_data = PIO_DONT_KNOW; 326 hwif->drives[1].drive_data = PIO_DONT_KNOW;
327} 327}
328 328
329/* 329static const struct ide_port_ops opti621_port_ops = {
330 * init_hwif_opti621() is called once for each hwif found at boot. 330 .port_init_devs = opti621_port_init_devs,
331 */ 331 .set_pio_mode = opti621_set_pio_mode,
332static void __devinit init_hwif_opti621(ide_hwif_t *hwif) 332};
333{
334 hwif->port_init_devs = opti621_port_init_devs;
335 hwif->set_pio_mode = &opti621_set_pio_mode;
336}
337 333
338static const struct ide_port_info opti621_chipsets[] __devinitdata = { 334static const struct ide_port_info opti621_chipsets[] __devinitdata = {
339 { /* 0 */ 335 { /* 0 */
340 .name = "OPTI621", 336 .name = "OPTI621",
341 .init_hwif = init_hwif_opti621,
342 .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} }, 337 .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} },
338 .port_ops = &opti621_port_ops,
343 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA, 339 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
344 .pio_mask = ATA_PIO3, 340 .pio_mask = ATA_PIO3,
345 .swdma_mask = ATA_SWDMA2, 341 .swdma_mask = ATA_SWDMA2,
346 .mwdma_mask = ATA_MWDMA2, 342 .mwdma_mask = ATA_MWDMA2,
347 }, { /* 1 */ 343 }, { /* 1 */
348 .name = "OPTI621X", 344 .name = "OPTI621X",
349 .init_hwif = init_hwif_opti621,
350 .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} }, 345 .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} },
346 .port_ops = &opti621_port_ops,
351 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA, 347 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
352 .pio_mask = ATA_PIO3, 348 .pio_mask = ATA_PIO3,
353 .swdma_mask = ATA_SWDMA2, 349 .swdma_mask = ATA_SWDMA2,
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index 1c8cb7797a4a..35a249cfe03f 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -442,17 +442,6 @@ static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const cha
442 return dev->irq; 442 return dev->irq;
443} 443}
444 444
445static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif)
446{
447 hwif->set_pio_mode = &pdcnew_set_pio_mode;
448 hwif->set_dma_mode = &pdcnew_set_dma_mode;
449
450 hwif->quirkproc = &pdcnew_quirkproc;
451 hwif->resetproc = &pdcnew_reset;
452
453 hwif->cable_detect = pdcnew_cable_detect;
454}
455
456static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) 445static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev)
457{ 446{
458 struct pci_dev *dev2; 447 struct pci_dev *dev2;
@@ -476,11 +465,19 @@ static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev)
476 return NULL; 465 return NULL;
477} 466}
478 467
468static const struct ide_port_ops pdcnew_port_ops = {
469 .set_pio_mode = pdcnew_set_pio_mode,
470 .set_dma_mode = pdcnew_set_dma_mode,
471 .quirkproc = pdcnew_quirkproc,
472 .resetproc = pdcnew_reset,
473 .cable_detect = pdcnew_cable_detect,
474};
475
479#define DECLARE_PDCNEW_DEV(name_str, udma) \ 476#define DECLARE_PDCNEW_DEV(name_str, udma) \
480 { \ 477 { \
481 .name = name_str, \ 478 .name = name_str, \
482 .init_chipset = init_chipset_pdcnew, \ 479 .init_chipset = init_chipset_pdcnew, \
483 .init_hwif = init_hwif_pdc202new, \ 480 .port_ops = &pdcnew_port_ops, \
484 .host_flags = IDE_HFLAG_POST_SET_MODE | \ 481 .host_flags = IDE_HFLAG_POST_SET_MODE | \
485 IDE_HFLAG_ERROR_STOPS_FIFO | \ 482 IDE_HFLAG_ERROR_STOPS_FIFO | \
486 IDE_HFLAG_OFF_BOARD, \ 483 IDE_HFLAG_OFF_BOARD, \
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
index 150422ec3cfa..00563e1bfc73 100644
--- a/drivers/ide/pci/pdc202xx_old.c
+++ b/drivers/ide/pci/pdc202xx_old.c
@@ -115,7 +115,7 @@ static void pdc202xx_set_pio_mode(ide_drive_t *drive, const u8 pio)
115 pdc202xx_set_mode(drive, XFER_PIO_0 + pio); 115 pdc202xx_set_mode(drive, XFER_PIO_0 + pio);
116} 116}
117 117
118static u8 __devinit pdc2026x_old_cable_detect(ide_hwif_t *hwif) 118static u8 __devinit pdc2026x_cable_detect(ide_hwif_t *hwif)
119{ 119{
120 struct pci_dev *dev = to_pci_dev(hwif->dev); 120 struct pci_dev *dev = to_pci_dev(hwif->dev);
121 u16 CIS, mask = hwif->channel ? (1 << 11) : (1 << 10); 121 u16 CIS, mask = hwif->channel ? (1 << 11) : (1 << 10);
@@ -226,26 +226,6 @@ somebody_else:
226 return (dma_stat & 4) == 4; /* return 1 if INTR asserted */ 226 return (dma_stat & 4) == 4; /* return 1 if INTR asserted */
227} 227}
228 228
229static void pdc202xx_dma_lost_irq(ide_drive_t *drive)
230{
231 ide_hwif_t *hwif = HWIF(drive);
232
233 if (hwif->resetproc != NULL)
234 hwif->resetproc(drive);
235
236 ide_dma_lost_irq(drive);
237}
238
239static void pdc202xx_dma_timeout(ide_drive_t *drive)
240{
241 ide_hwif_t *hwif = HWIF(drive);
242
243 if (hwif->resetproc != NULL)
244 hwif->resetproc(drive);
245
246 ide_dma_timeout(drive);
247}
248
249static void pdc202xx_reset_host (ide_hwif_t *hwif) 229static void pdc202xx_reset_host (ide_hwif_t *hwif)
250{ 230{
251 unsigned long high_16 = hwif->extra_base - 16; 231 unsigned long high_16 = hwif->extra_base - 16;
@@ -271,6 +251,18 @@ static void pdc202xx_reset (ide_drive_t *drive)
271 ide_set_max_pio(drive); 251 ide_set_max_pio(drive);
272} 252}
273 253
254static void pdc202xx_dma_lost_irq(ide_drive_t *drive)
255{
256 pdc202xx_reset(drive);
257 ide_dma_lost_irq(drive);
258}
259
260static void pdc202xx_dma_timeout(ide_drive_t *drive)
261{
262 pdc202xx_reset(drive);
263 ide_dma_timeout(drive);
264}
265
274static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev, 266static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev,
275 const char *name) 267 const char *name)
276{ 268{
@@ -281,17 +273,6 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif)
281{ 273{
282 struct pci_dev *dev = to_pci_dev(hwif->dev); 274 struct pci_dev *dev = to_pci_dev(hwif->dev);
283 275
284 hwif->set_pio_mode = &pdc202xx_set_pio_mode;
285 hwif->set_dma_mode = &pdc202xx_set_mode;
286
287 hwif->quirkproc = &pdc202xx_quirkproc;
288
289 if (dev->device != PCI_DEVICE_ID_PROMISE_20246) {
290 hwif->resetproc = &pdc202xx_reset;
291
292 hwif->cable_detect = pdc2026x_old_cable_detect;
293 }
294
295 if (hwif->dma_base == 0) 276 if (hwif->dma_base == 0)
296 return; 277 return;
297 278
@@ -357,6 +338,20 @@ static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev,
357 IDE_HFLAG_ABUSE_SET_DMA_MODE | \ 338 IDE_HFLAG_ABUSE_SET_DMA_MODE | \
358 IDE_HFLAG_OFF_BOARD) 339 IDE_HFLAG_OFF_BOARD)
359 340
341static const struct ide_port_ops pdc20246_port_ops = {
342 .set_pio_mode = pdc202xx_set_pio_mode,
343 .set_dma_mode = pdc202xx_set_mode,
344 .quirkproc = pdc202xx_quirkproc,
345};
346
347static const struct ide_port_ops pdc2026x_port_ops = {
348 .set_pio_mode = pdc202xx_set_pio_mode,
349 .set_dma_mode = pdc202xx_set_mode,
350 .quirkproc = pdc202xx_quirkproc,
351 .resetproc = pdc202xx_reset,
352 .cable_detect = pdc2026x_cable_detect,
353};
354
360#define DECLARE_PDC2026X_DEV(name_str, udma, extra_flags) \ 355#define DECLARE_PDC2026X_DEV(name_str, udma, extra_flags) \
361 { \ 356 { \
362 .name = name_str, \ 357 .name = name_str, \
@@ -364,6 +359,7 @@ static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev,
364 .init_hwif = init_hwif_pdc202xx, \ 359 .init_hwif = init_hwif_pdc202xx, \
365 .init_dma = init_dma_pdc202xx, \ 360 .init_dma = init_dma_pdc202xx, \
366 .extra = 48, \ 361 .extra = 48, \
362 .port_ops = &pdc2026x_port_ops, \
367 .host_flags = IDE_HFLAGS_PDC202XX | extra_flags, \ 363 .host_flags = IDE_HFLAGS_PDC202XX | extra_flags, \
368 .pio_mask = ATA_PIO4, \ 364 .pio_mask = ATA_PIO4, \
369 .mwdma_mask = ATA_MWDMA2, \ 365 .mwdma_mask = ATA_MWDMA2, \
@@ -376,6 +372,7 @@ static const struct ide_port_info pdc202xx_chipsets[] __devinitdata = {
376 .init_chipset = init_chipset_pdc202xx, 372 .init_chipset = init_chipset_pdc202xx,
377 .init_hwif = init_hwif_pdc202xx, 373 .init_hwif = init_hwif_pdc202xx,
378 .init_dma = init_dma_pdc202xx, 374 .init_dma = init_dma_pdc202xx,
375 .port_ops = &pdc20246_port_ops,
379 .extra = 16, 376 .extra = 16,
380 .host_flags = IDE_HFLAGS_PDC202XX, 377 .host_flags = IDE_HFLAGS_PDC202XX,
381 .pio_mask = ATA_PIO4, 378 .pio_mask = ATA_PIO4,
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
index 89d74ffdb207..21c5dd23f928 100644
--- a/drivers/ide/pci/piix.c
+++ b/drivers/ide/pci/piix.c
@@ -285,11 +285,6 @@ static u8 __devinit piix_cable_detect(ide_hwif_t *hwif)
285 285
286static void __devinit init_hwif_piix(ide_hwif_t *hwif) 286static void __devinit init_hwif_piix(ide_hwif_t *hwif)
287{ 287{
288 hwif->set_pio_mode = &piix_set_pio_mode;
289 hwif->set_dma_mode = &piix_set_dma_mode;
290
291 hwif->cable_detect = piix_cable_detect;
292
293 if (!hwif->dma_base) 288 if (!hwif->dma_base)
294 return; 289 return;
295 290
@@ -306,6 +301,12 @@ static void __devinit init_hwif_ich(ide_hwif_t *hwif)
306 hwif->ide_dma_clear_irq = &piix_dma_clear_irq; 301 hwif->ide_dma_clear_irq = &piix_dma_clear_irq;
307} 302}
308 303
304static const struct ide_port_ops piix_port_ops = {
305 .set_pio_mode = piix_set_pio_mode,
306 .set_dma_mode = piix_set_dma_mode,
307 .cable_detect = piix_cable_detect,
308};
309
309#ifndef CONFIG_IA64 310#ifndef CONFIG_IA64
310 #define IDE_HFLAGS_PIIX IDE_HFLAG_LEGACY_IRQS 311 #define IDE_HFLAGS_PIIX IDE_HFLAG_LEGACY_IRQS
311#else 312#else
@@ -317,6 +318,7 @@ static void __devinit init_hwif_ich(ide_hwif_t *hwif)
317 .name = name_str, \ 318 .name = name_str, \
318 .init_hwif = init_hwif_piix, \ 319 .init_hwif = init_hwif_piix, \
319 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ 320 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \
321 .port_ops = &piix_port_ops, \
320 .host_flags = IDE_HFLAGS_PIIX, \ 322 .host_flags = IDE_HFLAGS_PIIX, \
321 .pio_mask = ATA_PIO4, \ 323 .pio_mask = ATA_PIO4, \
322 .swdma_mask = ATA_SWDMA2_ONLY, \ 324 .swdma_mask = ATA_SWDMA2_ONLY, \
@@ -330,6 +332,7 @@ static void __devinit init_hwif_ich(ide_hwif_t *hwif)
330 .init_chipset = init_chipset_ich, \ 332 .init_chipset = init_chipset_ich, \
331 .init_hwif = init_hwif_ich, \ 333 .init_hwif = init_hwif_ich, \
332 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ 334 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \
335 .port_ops = &piix_port_ops, \
333 .host_flags = IDE_HFLAGS_PIIX, \ 336 .host_flags = IDE_HFLAGS_PIIX, \
334 .pio_mask = ATA_PIO4, \ 337 .pio_mask = ATA_PIO4, \
335 .swdma_mask = ATA_SWDMA2_ONLY, \ 338 .swdma_mask = ATA_SWDMA2_ONLY, \
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c
index 44985c8f36e7..0c144770a8da 100644
--- a/drivers/ide/pci/sc1200.c
+++ b/drivers/ide/pci/sc1200.c
@@ -292,19 +292,22 @@ static int sc1200_resume (struct pci_dev *dev)
292 */ 292 */
293static void __devinit init_hwif_sc1200 (ide_hwif_t *hwif) 293static void __devinit init_hwif_sc1200 (ide_hwif_t *hwif)
294{ 294{
295 hwif->set_pio_mode = &sc1200_set_pio_mode;
296 hwif->set_dma_mode = &sc1200_set_dma_mode;
297
298 if (hwif->dma_base == 0) 295 if (hwif->dma_base == 0)
299 return; 296 return;
300 297
301 hwif->udma_filter = sc1200_udma_filter;
302 hwif->ide_dma_end = &sc1200_ide_dma_end; 298 hwif->ide_dma_end = &sc1200_ide_dma_end;
303} 299}
304 300
301static const struct ide_port_ops sc1200_port_ops = {
302 .set_pio_mode = sc1200_set_pio_mode,
303 .set_dma_mode = sc1200_set_dma_mode,
304 .udma_filter = sc1200_udma_filter,
305};
306
305static const struct ide_port_info sc1200_chipset __devinitdata = { 307static const struct ide_port_info sc1200_chipset __devinitdata = {
306 .name = "SC1200", 308 .name = "SC1200",
307 .init_hwif = init_hwif_sc1200, 309 .init_hwif = init_hwif_sc1200,
310 .port_ops = &sc1200_port_ops,
308 .host_flags = IDE_HFLAG_SERIALIZE | 311 .host_flags = IDE_HFLAG_SERIALIZE |
309 IDE_HFLAG_POST_SET_MODE | 312 IDE_HFLAG_POST_SET_MODE |
310 IDE_HFLAG_ABUSE_DMA_MODES, 313 IDE_HFLAG_ABUSE_DMA_MODES,
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index 52145796f12f..c01e2da5c9e6 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -703,24 +703,27 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif)
703 703
704 hwif->dma_setup = scc_dma_setup; 704 hwif->dma_setup = scc_dma_setup;
705 hwif->ide_dma_end = scc_ide_dma_end; 705 hwif->ide_dma_end = scc_ide_dma_end;
706 hwif->set_pio_mode = scc_set_pio_mode;
707 hwif->set_dma_mode = scc_set_dma_mode;
708 hwif->ide_dma_test_irq = scc_dma_test_irq; 706 hwif->ide_dma_test_irq = scc_dma_test_irq;
709 hwif->udma_filter = scc_udma_filter;
710 707
711 if (in_be32((void __iomem *)(hwif->config_data + 0xff0)) & CCKCTRL_ATACLKOEN) 708 if (in_be32((void __iomem *)(hwif->config_data + 0xff0)) & CCKCTRL_ATACLKOEN)
712 hwif->ultra_mask = ATA_UDMA6; /* 133MHz */ 709 hwif->ultra_mask = ATA_UDMA6; /* 133MHz */
713 else 710 else
714 hwif->ultra_mask = ATA_UDMA5; /* 100MHz */ 711 hwif->ultra_mask = ATA_UDMA5; /* 100MHz */
715
716 hwif->cable_detect = scc_cable_detect;
717} 712}
718 713
714static const struct ide_port_ops scc_port_ops = {
715 .set_pio_mode = scc_set_pio_mode,
716 .set_dma_mode = scc_set_dma_mode,
717 .udma_filter = scc_udma_filter,
718 .cable_detect = scc_cable_detect,
719};
720
719#define DECLARE_SCC_DEV(name_str) \ 721#define DECLARE_SCC_DEV(name_str) \
720 { \ 722 { \
721 .name = name_str, \ 723 .name = name_str, \
722 .init_iops = init_iops_scc, \ 724 .init_iops = init_iops_scc, \
723 .init_hwif = init_hwif_scc, \ 725 .init_hwif = init_hwif_scc, \
726 .port_ops = &scc_port_ops, \
724 .host_flags = IDE_HFLAG_SINGLE, \ 727 .host_flags = IDE_HFLAG_SINGLE, \
725 .pio_mask = ATA_PIO4, \ 728 .pio_mask = ATA_PIO4, \
726 } 729 }
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
index cfe927469793..a1fb20826a5b 100644
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/pci/serverworks.c
@@ -312,7 +312,7 @@ static u8 __devinit ata66_svwks_cobalt(ide_hwif_t *hwif)
312 return ATA_CBL_PATA40; 312 return ATA_CBL_PATA40;
313} 313}
314 314
315static u8 __devinit ata66_svwks(ide_hwif_t *hwif) 315static u8 __devinit svwks_cable_detect(ide_hwif_t *hwif)
316{ 316{
317 struct pci_dev *dev = to_pci_dev(hwif->dev); 317 struct pci_dev *dev = to_pci_dev(hwif->dev);
318 318
@@ -336,17 +336,18 @@ static u8 __devinit ata66_svwks(ide_hwif_t *hwif)
336 return ATA_CBL_PATA40; 336 return ATA_CBL_PATA40;
337} 337}
338 338
339static void __devinit init_hwif_svwks (ide_hwif_t *hwif) 339static const struct ide_port_ops osb4_port_ops = {
340{ 340 .set_pio_mode = svwks_set_pio_mode,
341 struct pci_dev *dev = to_pci_dev(hwif->dev); 341 .set_dma_mode = svwks_set_dma_mode,
342 342 .udma_filter = svwks_udma_filter,
343 hwif->set_pio_mode = &svwks_set_pio_mode; 343};
344 hwif->set_dma_mode = &svwks_set_dma_mode;
345 hwif->udma_filter = &svwks_udma_filter;
346 344
347 if (dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) 345static const struct ide_port_ops svwks_port_ops = {
348 hwif->cable_detect = ata66_svwks; 346 .set_pio_mode = svwks_set_pio_mode,
349} 347 .set_dma_mode = svwks_set_dma_mode,
348 .udma_filter = svwks_udma_filter,
349 .cable_detect = svwks_cable_detect,
350};
350 351
351#define IDE_HFLAGS_SVWKS \ 352#define IDE_HFLAGS_SVWKS \
352 (IDE_HFLAG_LEGACY_IRQS | \ 353 (IDE_HFLAG_LEGACY_IRQS | \
@@ -356,7 +357,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
356 { /* 0 */ 357 { /* 0 */
357 .name = "SvrWks OSB4", 358 .name = "SvrWks OSB4",
358 .init_chipset = init_chipset_svwks, 359 .init_chipset = init_chipset_svwks,
359 .init_hwif = init_hwif_svwks, 360 .port_ops = &osb4_port_ops,
360 .host_flags = IDE_HFLAGS_SVWKS, 361 .host_flags = IDE_HFLAGS_SVWKS,
361 .pio_mask = ATA_PIO4, 362 .pio_mask = ATA_PIO4,
362 .mwdma_mask = ATA_MWDMA2, 363 .mwdma_mask = ATA_MWDMA2,
@@ -364,7 +365,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
364 },{ /* 1 */ 365 },{ /* 1 */
365 .name = "SvrWks CSB5", 366 .name = "SvrWks CSB5",
366 .init_chipset = init_chipset_svwks, 367 .init_chipset = init_chipset_svwks,
367 .init_hwif = init_hwif_svwks, 368 .port_ops = &svwks_port_ops,
368 .host_flags = IDE_HFLAGS_SVWKS, 369 .host_flags = IDE_HFLAGS_SVWKS,
369 .pio_mask = ATA_PIO4, 370 .pio_mask = ATA_PIO4,
370 .mwdma_mask = ATA_MWDMA2, 371 .mwdma_mask = ATA_MWDMA2,
@@ -372,7 +373,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
372 },{ /* 2 */ 373 },{ /* 2 */
373 .name = "SvrWks CSB6", 374 .name = "SvrWks CSB6",
374 .init_chipset = init_chipset_svwks, 375 .init_chipset = init_chipset_svwks,
375 .init_hwif = init_hwif_svwks, 376 .port_ops = &svwks_port_ops,
376 .host_flags = IDE_HFLAGS_SVWKS, 377 .host_flags = IDE_HFLAGS_SVWKS,
377 .pio_mask = ATA_PIO4, 378 .pio_mask = ATA_PIO4,
378 .mwdma_mask = ATA_MWDMA2, 379 .mwdma_mask = ATA_MWDMA2,
@@ -380,7 +381,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
380 },{ /* 3 */ 381 },{ /* 3 */
381 .name = "SvrWks CSB6", 382 .name = "SvrWks CSB6",
382 .init_chipset = init_chipset_svwks, 383 .init_chipset = init_chipset_svwks,
383 .init_hwif = init_hwif_svwks, 384 .port_ops = &svwks_port_ops,
384 .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, 385 .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE,
385 .pio_mask = ATA_PIO4, 386 .pio_mask = ATA_PIO4,
386 .mwdma_mask = ATA_MWDMA2, 387 .mwdma_mask = ATA_MWDMA2,
@@ -388,7 +389,7 @@ static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
388 },{ /* 4 */ 389 },{ /* 4 */
389 .name = "SvrWks HT1000", 390 .name = "SvrWks HT1000",
390 .init_chipset = init_chipset_svwks, 391 .init_chipset = init_chipset_svwks,
391 .init_hwif = init_hwif_svwks, 392 .port_ops = &svwks_port_ops,
392 .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, 393 .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE,
393 .pio_mask = ATA_PIO4, 394 .pio_mask = ATA_PIO4,
394 .mwdma_mask = ATA_MWDMA2, 395 .mwdma_mask = ATA_MWDMA2,
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 6bd9523cf642..22ac0f70c423 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -552,16 +552,6 @@ static void __devinit
552ide_init_sgiioc4(ide_hwif_t * hwif) 552ide_init_sgiioc4(ide_hwif_t * hwif)
553{ 553{
554 hwif->mmio = 1; 554 hwif->mmio = 1;
555 hwif->set_pio_mode = NULL; /* Sets timing for PIO mode */
556 hwif->set_dma_mode = &sgiioc4_set_dma_mode;
557 hwif->selectproc = NULL;/* Use the default routine to select drive */
558 hwif->reset_poll = NULL;/* No HBA specific reset_poll needed */
559 hwif->pre_reset = NULL; /* No HBA specific pre_set needed */
560 hwif->resetproc = &sgiioc4_resetproc;/* Reset DMA engine,
561 clear interrupts */
562 hwif->maskproc = &sgiioc4_maskproc; /* Mask on/off NIEN register */
563 hwif->quirkproc = NULL;
564
565 hwif->INB = &sgiioc4_INB; 555 hwif->INB = &sgiioc4_INB;
566 556
567 if (hwif->dma_base == 0) 557 if (hwif->dma_base == 0)
@@ -576,8 +566,17 @@ ide_init_sgiioc4(ide_hwif_t * hwif)
576 hwif->dma_timeout = &ide_dma_timeout; 566 hwif->dma_timeout = &ide_dma_timeout;
577} 567}
578 568
569static const struct ide_port_ops sgiioc4_port_ops = {
570 .set_dma_mode = sgiioc4_set_dma_mode,
571 /* reset DMA engine, clear IRQs */
572 .resetproc = sgiioc4_resetproc,
573 /* mask on/off NIEN register */
574 .maskproc = sgiioc4_maskproc,
575};
576
579static const struct ide_port_info sgiioc4_port_info __devinitdata = { 577static const struct ide_port_info sgiioc4_port_info __devinitdata = {
580 .chipset = ide_pci, 578 .chipset = ide_pci,
579 .port_ops = &sgiioc4_port_ops,
581 .host_flags = IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ 580 .host_flags = IDE_HFLAG_NO_DMA | /* no SFF-style DMA */
582 IDE_HFLAG_NO_AUTOTUNE, 581 IDE_HFLAG_NO_AUTOTUNE,
583 .mwdma_mask = ATA_MWDMA2_ONLY, 582 .mwdma_mask = ATA_MWDMA2_ONLY,
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index c9ecab8aeb61..3e4b99380709 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -735,14 +735,14 @@ static void __devinit init_iops_siimage(ide_hwif_t *hwif)
735} 735}
736 736
737/** 737/**
738 * ata66_siimage - check for 80 pin cable 738 * sil_cable_detect - cable detection
739 * @hwif: interface to check 739 * @hwif: interface to check
740 * 740 *
741 * Check for the presence of an ATA66 capable cable on the 741 * Check for the presence of an ATA66 capable cable on the
742 * interface. 742 * interface.
743 */ 743 */
744 744
745static u8 __devinit ata66_siimage(ide_hwif_t *hwif) 745static u8 __devinit sil_cable_detect(ide_hwif_t *hwif)
746{ 746{
747 struct pci_dev *dev = to_pci_dev(hwif->dev); 747 struct pci_dev *dev = to_pci_dev(hwif->dev);
748 unsigned long addr = siimage_selreg(hwif, 0); 748 unsigned long addr = siimage_selreg(hwif, 0);
@@ -769,25 +769,14 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
769{ 769{
770 u8 sata = is_sata(hwif); 770 u8 sata = is_sata(hwif);
771 771
772 hwif->set_pio_mode = &sil_set_pio_mode;
773 hwif->set_dma_mode = &sil_set_dma_mode;
774 hwif->quirkproc = &sil_quirkproc;
775
776 if (sata) { 772 if (sata) {
777 static int first = 1; 773 static int first = 1;
778 774
779 hwif->reset_poll = &sil_sata_reset_poll;
780 hwif->pre_reset = &sil_sata_pre_reset;
781 hwif->udma_filter = &sil_sata_udma_filter;
782
783 if (first) { 775 if (first) {
784 printk(KERN_INFO "siimage: For full SATA support you should use the libata sata_sil module.\n"); 776 printk(KERN_INFO "siimage: For full SATA support you should use the libata sata_sil module.\n");
785 first = 0; 777 first = 0;
786 } 778 }
787 } else 779 }
788 hwif->udma_filter = &sil_pata_udma_filter;
789
790 hwif->cable_detect = ata66_siimage;
791 780
792 if (hwif->dma_base == 0) 781 if (hwif->dma_base == 0)
793 return; 782 return;
@@ -802,21 +791,40 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
802 } 791 }
803} 792}
804 793
805#define DECLARE_SII_DEV(name_str) \ 794static const struct ide_port_ops sil_pata_port_ops = {
795 .set_pio_mode = sil_set_pio_mode,
796 .set_dma_mode = sil_set_dma_mode,
797 .quirkproc = sil_quirkproc,
798 .udma_filter = sil_pata_udma_filter,
799 .cable_detect = sil_cable_detect,
800};
801
802static const struct ide_port_ops sil_sata_port_ops = {
803 .set_pio_mode = sil_set_pio_mode,
804 .set_dma_mode = sil_set_dma_mode,
805 .reset_poll = sil_sata_reset_poll,
806 .pre_reset = sil_sata_pre_reset,
807 .quirkproc = sil_quirkproc,
808 .udma_filter = sil_sata_udma_filter,
809 .cable_detect = sil_cable_detect,
810};
811
812#define DECLARE_SII_DEV(name_str, p_ops) \
806 { \ 813 { \
807 .name = name_str, \ 814 .name = name_str, \
808 .init_chipset = init_chipset_siimage, \ 815 .init_chipset = init_chipset_siimage, \
809 .init_iops = init_iops_siimage, \ 816 .init_iops = init_iops_siimage, \
810 .init_hwif = init_hwif_siimage, \ 817 .init_hwif = init_hwif_siimage, \
818 .port_ops = p_ops, \
811 .pio_mask = ATA_PIO4, \ 819 .pio_mask = ATA_PIO4, \
812 .mwdma_mask = ATA_MWDMA2, \ 820 .mwdma_mask = ATA_MWDMA2, \
813 .udma_mask = ATA_UDMA6, \ 821 .udma_mask = ATA_UDMA6, \
814 } 822 }
815 823
816static const struct ide_port_info siimage_chipsets[] __devinitdata = { 824static const struct ide_port_info siimage_chipsets[] __devinitdata = {
817 /* 0 */ DECLARE_SII_DEV("SiI680"), 825 /* 0 */ DECLARE_SII_DEV("SiI680", &sil_pata_port_ops),
818 /* 1 */ DECLARE_SII_DEV("SiI3112 Serial ATA"), 826 /* 1 */ DECLARE_SII_DEV("SiI3112 Serial ATA", &sil_sata_port_ops),
819 /* 2 */ DECLARE_SII_DEV("Adaptec AAR-1210SA") 827 /* 2 */ DECLARE_SII_DEV("Adaptec AAR-1210SA", &sil_sata_port_ops)
820}; 828};
821 829
822/** 830/**
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
index 181b647e5ca9..4b0b85d8faf5 100644
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/pci/sis5513.c
@@ -347,7 +347,7 @@ static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed)
347 sis_program_timings(drive, speed); 347 sis_program_timings(drive, speed);
348} 348}
349 349
350static u8 sis5513_ata133_udma_filter(ide_drive_t *drive) 350static u8 sis_ata133_udma_filter(ide_drive_t *drive)
351{ 351{
352 struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 352 struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
353 u32 regdw = 0; 353 u32 regdw = 0;
@@ -514,7 +514,7 @@ static const struct sis_laptop sis_laptop[] = {
514 { 0, } 514 { 0, }
515}; 515};
516 516
517static u8 __devinit ata66_sis5513(ide_hwif_t *hwif) 517static u8 __devinit sis_cable_detect(ide_hwif_t *hwif)
518{ 518{
519 struct pci_dev *pdev = to_pci_dev(hwif->dev); 519 struct pci_dev *pdev = to_pci_dev(hwif->dev);
520 const struct sis_laptop *lap = &sis_laptop[0]; 520 const struct sis_laptop *lap = &sis_laptop[0];
@@ -543,21 +543,22 @@ static u8 __devinit ata66_sis5513(ide_hwif_t *hwif)
543 return ata66 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; 543 return ata66 ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
544} 544}
545 545
546static void __devinit init_hwif_sis5513(ide_hwif_t *hwif) 546static const struct ide_port_ops sis_port_ops = {
547{ 547 .set_pio_mode = sis_set_pio_mode,
548 hwif->set_pio_mode = &sis_set_pio_mode; 548 .set_dma_mode = sis_set_dma_mode,
549 hwif->set_dma_mode = &sis_set_dma_mode; 549 .cable_detect = sis_cable_detect,
550 550};
551 if (chipset_family >= ATA_133)
552 hwif->udma_filter = sis5513_ata133_udma_filter;
553 551
554 hwif->cable_detect = ata66_sis5513; 552static const struct ide_port_ops sis_ata133_port_ops = {
555} 553 .set_pio_mode = sis_set_pio_mode,
554 .set_dma_mode = sis_set_dma_mode,
555 .udma_filter = sis_ata133_udma_filter,
556 .cable_detect = sis_cable_detect,
557};
556 558
557static const struct ide_port_info sis5513_chipset __devinitdata = { 559static const struct ide_port_info sis5513_chipset __devinitdata = {
558 .name = "SIS5513", 560 .name = "SIS5513",
559 .init_chipset = init_chipset_sis5513, 561 .init_chipset = init_chipset_sis5513,
560 .init_hwif = init_hwif_sis5513,
561 .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} }, 562 .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} },
562 .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_NO_AUTODMA, 563 .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_NO_AUTODMA,
563 .pio_mask = ATA_PIO4, 564 .pio_mask = ATA_PIO4,
@@ -572,6 +573,11 @@ static int __devinit sis5513_init_one(struct pci_dev *dev, const struct pci_devi
572 if (sis_find_family(dev) == 0) 573 if (sis_find_family(dev) == 0)
573 return -ENOTSUPP; 574 return -ENOTSUPP;
574 575
576 if (chipset_family >= ATA_133)
577 d.port_ops = &sis_ata133_port_ops;
578 else
579 d.port_ops = &sis_port_ops;
580
575 d.udma_mask = udma_rates[chipset_family]; 581 d.udma_mask = udma_rates[chipset_family];
576 582
577 return ide_setup_pci_device(dev, &d); 583 return ide_setup_pci_device(dev, &d);
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
index 40b3eeb2d847..66817fe1eeae 100644
--- a/drivers/ide/pci/sl82c105.c
+++ b/drivers/ide/pci/sl82c105.c
@@ -292,10 +292,6 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
292 292
293 DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index)); 293 DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index));
294 294
295 hwif->set_pio_mode = &sl82c105_set_pio_mode;
296 hwif->set_dma_mode = &sl82c105_set_dma_mode;
297 hwif->resetproc = &sl82c105_resetproc;
298
299 if (!hwif->dma_base) 295 if (!hwif->dma_base)
300 return; 296 return;
301 297
@@ -321,11 +317,18 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
321 hwif->serialized = hwif->mate->serialized = 1; 317 hwif->serialized = hwif->mate->serialized = 1;
322} 318}
323 319
320static const struct ide_port_ops sl82c105_port_ops = {
321 .set_pio_mode = sl82c105_set_pio_mode,
322 .set_dma_mode = sl82c105_set_dma_mode,
323 .resetproc = sl82c105_resetproc,
324};
325
324static const struct ide_port_info sl82c105_chipset __devinitdata = { 326static const struct ide_port_info sl82c105_chipset __devinitdata = {
325 .name = "W82C105", 327 .name = "W82C105",
326 .init_chipset = init_chipset_sl82c105, 328 .init_chipset = init_chipset_sl82c105,
327 .init_hwif = init_hwif_sl82c105, 329 .init_hwif = init_hwif_sl82c105,
328 .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}}, 330 .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}},
331 .port_ops = &sl82c105_port_ops,
329 .host_flags = IDE_HFLAG_IO_32BIT | 332 .host_flags = IDE_HFLAG_IO_32BIT |
330 IDE_HFLAG_UNMASK_IRQS | 333 IDE_HFLAG_UNMASK_IRQS |
331/* FIXME: check for Compatibility mode in generic IDE PCI code */ 334/* FIXME: check for Compatibility mode in generic IDE PCI code */
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c
index eab557c45d1b..dae6e2c94d86 100644
--- a/drivers/ide/pci/slc90e66.c
+++ b/drivers/ide/pci/slc90e66.c
@@ -125,18 +125,16 @@ static u8 __devinit slc90e66_cable_detect(ide_hwif_t *hwif)
125 return (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; 125 return (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
126} 126}
127 127
128static void __devinit init_hwif_slc90e66(ide_hwif_t *hwif) 128static const struct ide_port_ops slc90e66_port_ops = {
129{ 129 .set_pio_mode = slc90e66_set_pio_mode,
130 hwif->set_pio_mode = &slc90e66_set_pio_mode; 130 .set_dma_mode = slc90e66_set_dma_mode,
131 hwif->set_dma_mode = &slc90e66_set_dma_mode; 131 .cable_detect = slc90e66_cable_detect,
132 132};
133 hwif->cable_detect = slc90e66_cable_detect;
134}
135 133
136static const struct ide_port_info slc90e66_chipset __devinitdata = { 134static const struct ide_port_info slc90e66_chipset __devinitdata = {
137 .name = "SLC90E66", 135 .name = "SLC90E66",
138 .init_hwif = init_hwif_slc90e66,
139 .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} }, 136 .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} },
137 .port_ops = &slc90e66_port_ops,
140 .host_flags = IDE_HFLAG_LEGACY_IRQS, 138 .host_flags = IDE_HFLAG_LEGACY_IRQS,
141 .pio_mask = ATA_PIO4, 139 .pio_mask = ATA_PIO4,
142 .swdma_mask = ATA_SWDMA2_ONLY, 140 .swdma_mask = ATA_SWDMA2_ONLY,
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c
index c15435182e3c..14ce400a0eaf 100644
--- a/drivers/ide/pci/tc86c001.c
+++ b/drivers/ide/pci/tc86c001.c
@@ -157,11 +157,6 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif)
157 /* Store the system control register base for convenience... */ 157 /* Store the system control register base for convenience... */
158 hwif->config_data = sc_base; 158 hwif->config_data = sc_base;
159 159
160 hwif->set_pio_mode = &tc86c001_set_pio_mode;
161 hwif->set_dma_mode = &tc86c001_set_mode;
162
163 hwif->cable_detect = tc86c001_cable_detect;
164
165 if (!hwif->dma_base) 160 if (!hwif->dma_base)
166 return; 161 return;
167 162
@@ -187,10 +182,17 @@ static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev,
187 return err; 182 return err;
188} 183}
189 184
185static const struct ide_port_ops tc86c001_port_ops = {
186 .set_pio_mode = tc86c001_set_pio_mode,
187 .set_dma_mode = tc86c001_set_mode,
188 .cable_detect = tc86c001_cable_detect,
189};
190
190static const struct ide_port_info tc86c001_chipset __devinitdata = { 191static const struct ide_port_info tc86c001_chipset __devinitdata = {
191 .name = "TC86C001", 192 .name = "TC86C001",
192 .init_chipset = init_chipset_tc86c001, 193 .init_chipset = init_chipset_tc86c001,
193 .init_hwif = init_hwif_tc86c001, 194 .init_hwif = init_hwif_tc86c001,
195 .port_ops = &tc86c001_port_ops,
194 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_OFF_BOARD | 196 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_OFF_BOARD |
195 IDE_HFLAG_ABUSE_SET_DMA_MODE, 197 IDE_HFLAG_ABUSE_SET_DMA_MODE,
196 .pio_mask = ATA_PIO4, 198 .pio_mask = ATA_PIO4,
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c
index 3316b197c779..db65a558d4ec 100644
--- a/drivers/ide/pci/triflex.c
+++ b/drivers/ide/pci/triflex.c
@@ -87,16 +87,15 @@ static void triflex_set_pio_mode(ide_drive_t *drive, const u8 pio)
87 triflex_set_mode(drive, XFER_PIO_0 + pio); 87 triflex_set_mode(drive, XFER_PIO_0 + pio);
88} 88}
89 89
90static void __devinit init_hwif_triflex(ide_hwif_t *hwif) 90static const struct ide_port_ops triflex_port_ops = {
91{ 91 .set_pio_mode = triflex_set_pio_mode,
92 hwif->set_pio_mode = &triflex_set_pio_mode; 92 .set_dma_mode = triflex_set_mode,
93 hwif->set_dma_mode = &triflex_set_mode; 93};
94}
95 94
96static const struct ide_port_info triflex_device __devinitdata = { 95static const struct ide_port_info triflex_device __devinitdata = {
97 .name = "TRIFLEX", 96 .name = "TRIFLEX",
98 .init_hwif = init_hwif_triflex,
99 .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}}, 97 .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}},
98 .port_ops = &triflex_port_ops,
100 .pio_mask = ATA_PIO4, 99 .pio_mask = ATA_PIO4,
101 .swdma_mask = ATA_SWDMA2, 100 .swdma_mask = ATA_SWDMA2,
102 .mwdma_mask = ATA_MWDMA2, 101 .mwdma_mask = ATA_MWDMA2,
diff --git a/drivers/ide/pci/trm290.c b/drivers/ide/pci/trm290.c
index 2b8f3a2837d7..47265030f87d 100644
--- a/drivers/ide/pci/trm290.c
+++ b/drivers/ide/pci/trm290.c
@@ -297,8 +297,6 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif)
297 hwif->dma_start = &trm290_dma_start; 297 hwif->dma_start = &trm290_dma_start;
298 hwif->ide_dma_end = &trm290_ide_dma_end; 298 hwif->ide_dma_end = &trm290_ide_dma_end;
299 hwif->ide_dma_test_irq = &trm290_ide_dma_test_irq; 299 hwif->ide_dma_test_irq = &trm290_ide_dma_test_irq;
300
301 hwif->selectproc = &trm290_selectproc;
302#if 1 300#if 1
303 { 301 {
304 /* 302 /*
@@ -328,10 +326,15 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif)
328#endif 326#endif
329} 327}
330 328
329static const struct ide_port_ops trm290_port_ops = {
330 .selectproc = trm290_selectproc,
331};
332
331static const struct ide_port_info trm290_chipset __devinitdata = { 333static const struct ide_port_info trm290_chipset __devinitdata = {
332 .name = "TRM290", 334 .name = "TRM290",
333 .init_hwif = init_hwif_trm290, 335 .init_hwif = init_hwif_trm290,
334 .chipset = ide_trm290, 336 .chipset = ide_trm290,
337 .port_ops = &trm290_port_ops,
335 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | 338 .host_flags = IDE_HFLAG_NO_ATAPI_DMA |
336#if 0 /* play it safe for now */ 339#if 0 /* play it safe for now */
337 IDE_HFLAG_TRUST_BIOS_FOR_DMA | 340 IDE_HFLAG_TRUST_BIOS_FOR_DMA |
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
index cff3cafedc47..bbd17bec6ffe 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -415,19 +415,17 @@ static u8 __devinit via82cxxx_cable_detect(ide_hwif_t *hwif)
415 return ATA_CBL_PATA40; 415 return ATA_CBL_PATA40;
416} 416}
417 417
418static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif) 418static const struct ide_port_ops via_port_ops = {
419{ 419 .set_pio_mode = via_set_pio_mode,
420 hwif->set_pio_mode = &via_set_pio_mode; 420 .set_dma_mode = via_set_drive,
421 hwif->set_dma_mode = &via_set_drive; 421 .cable_detect = via82cxxx_cable_detect,
422 422};
423 hwif->cable_detect = via82cxxx_cable_detect;
424}
425 423
426static const struct ide_port_info via82cxxx_chipset __devinitdata = { 424static const struct ide_port_info via82cxxx_chipset __devinitdata = {
427 .name = "VP_IDE", 425 .name = "VP_IDE",
428 .init_chipset = init_chipset_via82cxxx, 426 .init_chipset = init_chipset_via82cxxx,
429 .init_hwif = init_hwif_via82cxxx,
430 .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } }, 427 .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } },
428 .port_ops = &via_port_ops,
431 .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST | 429 .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST |
432 IDE_HFLAG_ABUSE_SET_DMA_MODE | 430 IDE_HFLAG_ABUSE_SET_DMA_MODE |
433 IDE_HFLAG_POST_SET_MODE | 431 IDE_HFLAG_POST_SET_MODE |
diff --git a/drivers/ide/ppc/mpc8xx.c b/drivers/ide/ppc/mpc8xx.c
index 467656f06ccc..0fd98489d587 100644
--- a/drivers/ide/ppc/mpc8xx.c
+++ b/drivers/ide/ppc/mpc8xx.c
@@ -442,6 +442,10 @@ static void m8xx_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
442#endif /* defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_PCMCIA */ 442#endif /* defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_PCMCIA */
443} 443}
444 444
445static const struct ide_port_ops m8xx_port_ops = {
446 .set_pio_mode = m8xx_ide_set_pio_mode,
447};
448
445static void 449static void
446ide_interrupt_ack (void *dev) 450ide_interrupt_ack (void *dev)
447{ 451{
@@ -812,7 +816,7 @@ static int __init mpc8xx_ide_probe(void)
812 ide_init_port_hw(hwif, &hw); 816 ide_init_port_hw(hwif, &hw);
813 hwif->mmio = 1; 817 hwif->mmio = 1;
814 hwif->pio_mask = ATA_PIO4; 818 hwif->pio_mask = ATA_PIO4;
815 hwif->set_pio_mode = m8xx_ide_set_pio_mode; 819 hwif->port_ops = &m8xx_port_ops;
816 820
817 idx[0] = 0; 821 idx[0] = 0;
818 } 822 }
@@ -824,7 +828,7 @@ static int __init mpc8xx_ide_probe(void)
824 ide_init_port_hw(mate, &hw); 828 ide_init_port_hw(mate, &hw);
825 mate->mmio = 1; 829 mate->mmio = 1;
826 mate->pio_mask = ATA_PIO4; 830 mate->pio_mask = ATA_PIO4;
827 mate->set_pio_mode = m8xx_ide_set_pio_mode; 831 mate->port_ops = &m8xx_port_ops;
828 832
829 idx[1] = 1; 833 idx[1] = 1;
830 } 834 }
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 177961edc430..3277bf2d66a5 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -918,8 +918,21 @@ pmac_ide_do_resume(ide_hwif_t *hwif)
918 return 0; 918 return 0;
919} 919}
920 920
921static const struct ide_port_ops pmac_ide_ata6_port_ops = {
922 .set_pio_mode = pmac_ide_set_pio_mode,
923 .set_dma_mode = pmac_ide_set_dma_mode,
924 .selectproc = pmac_ide_kauai_selectproc,
925};
926
927static const struct ide_port_ops pmac_ide_port_ops = {
928 .set_pio_mode = pmac_ide_set_pio_mode,
929 .set_dma_mode = pmac_ide_set_dma_mode,
930 .selectproc = pmac_ide_selectproc,
931};
932
921static const struct ide_port_info pmac_port_info = { 933static const struct ide_port_info pmac_port_info = {
922 .chipset = ide_pmac, 934 .chipset = ide_pmac,
935 .port_ops = &pmac_ide_port_ops,
923 .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | 936 .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA |
924 IDE_HFLAG_POST_SET_MODE | 937 IDE_HFLAG_POST_SET_MODE |
925 IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ 938 IDE_HFLAG_NO_DMA | /* no SFF-style DMA */
@@ -947,12 +960,15 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw)
947 pmif->broken_dma = pmif->broken_dma_warn = 0; 960 pmif->broken_dma = pmif->broken_dma_warn = 0;
948 if (of_device_is_compatible(np, "shasta-ata")) { 961 if (of_device_is_compatible(np, "shasta-ata")) {
949 pmif->kind = controller_sh_ata6; 962 pmif->kind = controller_sh_ata6;
963 d.port_ops = &pmac_ide_ata6_port_ops;
950 d.udma_mask = ATA_UDMA6; 964 d.udma_mask = ATA_UDMA6;
951 } else if (of_device_is_compatible(np, "kauai-ata")) { 965 } else if (of_device_is_compatible(np, "kauai-ata")) {
952 pmif->kind = controller_un_ata6; 966 pmif->kind = controller_un_ata6;
967 d.port_ops = &pmac_ide_ata6_port_ops;
953 d.udma_mask = ATA_UDMA5; 968 d.udma_mask = ATA_UDMA5;
954 } else if (of_device_is_compatible(np, "K2-UATA")) { 969 } else if (of_device_is_compatible(np, "K2-UATA")) {
955 pmif->kind = controller_k2_ata6; 970 pmif->kind = controller_k2_ata6;
971 d.port_ops = &pmac_ide_ata6_port_ops;
956 d.udma_mask = ATA_UDMA5; 972 d.udma_mask = ATA_UDMA5;
957 } else if (of_device_is_compatible(np, "keylargo-ata")) { 973 } else if (of_device_is_compatible(np, "keylargo-ata")) {
958 if (strcmp(np->name, "ata-4") == 0) { 974 if (strcmp(np->name, "ata-4") == 0) {
@@ -1035,14 +1051,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw)
1035 ide_init_port_hw(hwif, hw); 1051 ide_init_port_hw(hwif, hw);
1036 hwif->noprobe = pmif->mediabay; 1052 hwif->noprobe = pmif->mediabay;
1037 hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; 1053 hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
1038 hwif->set_pio_mode = pmac_ide_set_pio_mode;
1039 if (pmif->kind == controller_un_ata6
1040 || pmif->kind == controller_k2_ata6
1041 || pmif->kind == controller_sh_ata6)
1042 hwif->selectproc = pmac_ide_kauai_selectproc;
1043 else
1044 hwif->selectproc = pmac_ide_selectproc;
1045 hwif->set_dma_mode = pmac_ide_set_dma_mode;
1046 1054
1047 printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n", 1055 printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n",
1048 hwif->index, model_name[pmif->kind], pmif->aapl_bus_id, 1056 hwif->index, model_name[pmif->kind], pmif->aapl_bus_id,
diff --git a/include/linux/ide.h b/include/linux/ide.h
index f20410dd4482..b594f04a67f4 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -387,6 +387,32 @@ typedef struct ide_drive_s {
387 387
388struct ide_port_info; 388struct ide_port_info;
389 389
390struct ide_port_ops {
391 /* host specific initialization of devices on a port */
392 void (*port_init_devs)(struct hwif_s *);
393 /* routine to program host for PIO mode */
394 void (*set_pio_mode)(ide_drive_t *, const u8);
395 /* routine to program host for DMA mode */
396 void (*set_dma_mode)(ide_drive_t *, const u8);
397 /* tweaks hardware to select drive */
398 void (*selectproc)(ide_drive_t *);
399 /* chipset polling based on hba specifics */
400 int (*reset_poll)(ide_drive_t *);
401 /* chipset specific changes to default for device-hba resets */
402 void (*pre_reset)(ide_drive_t *);
403 /* routine to reset controller after a disk reset */
404 void (*resetproc)(ide_drive_t *);
405 /* special host masking for drive selection */
406 void (*maskproc)(ide_drive_t *, int);
407 /* check host's drive quirk list */
408 void (*quirkproc)(ide_drive_t *);
409
410 u8 (*mdma_filter)(ide_drive_t *);
411 u8 (*udma_filter)(ide_drive_t *);
412
413 u8 (*cable_detect)(struct hwif_s *);
414};
415
390typedef struct hwif_s { 416typedef struct hwif_s {
391 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ 417 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */
392 struct hwif_s *mate; /* other hwif from same PCI chip */ 418 struct hwif_s *mate; /* other hwif from same PCI chip */
@@ -426,32 +452,7 @@ typedef struct hwif_s {
426 452
427 void (*rw_disk)(ide_drive_t *, struct request *); 453 void (*rw_disk)(ide_drive_t *, struct request *);
428 454
429#if 0 455 const struct ide_port_ops *port_ops;
430 ide_hwif_ops_t *hwifops;
431#else
432 /* host specific initialization of devices on a port */
433 void (*port_init_devs)(struct hwif_s *);
434 /* routine to program host for PIO mode */
435 void (*set_pio_mode)(ide_drive_t *, const u8);
436 /* routine to program host for DMA mode */
437 void (*set_dma_mode)(ide_drive_t *, const u8);
438 /* tweaks hardware to select drive */
439 void (*selectproc)(ide_drive_t *);
440 /* chipset polling based on hba specifics */
441 int (*reset_poll)(ide_drive_t *);
442 /* chipset specific changes to default for device-hba resets */
443 void (*pre_reset)(ide_drive_t *);
444 /* routine to reset controller after a disk reset */
445 void (*resetproc)(ide_drive_t *);
446 /* special host masking for drive selection */
447 void (*maskproc)(ide_drive_t *, int);
448 /* check host's drive quirk list */
449 void (*quirkproc)(ide_drive_t *);
450#endif
451 u8 (*mdma_filter)(ide_drive_t *);
452 u8 (*udma_filter)(ide_drive_t *);
453
454 u8 (*cable_detect)(struct hwif_s *);
455 456
456 void (*ata_input_data)(ide_drive_t *, void *, u32); 457 void (*ata_input_data)(ide_drive_t *, void *, u32);
457 void (*ata_output_data)(ide_drive_t *, void *, u32); 458 void (*ata_output_data)(ide_drive_t *, void *, u32);
@@ -1106,6 +1107,9 @@ struct ide_port_info {
1106 void (*init_iops)(ide_hwif_t *); 1107 void (*init_iops)(ide_hwif_t *);
1107 void (*init_hwif)(ide_hwif_t *); 1108 void (*init_hwif)(ide_hwif_t *);
1108 void (*init_dma)(ide_hwif_t *, unsigned long); 1109 void (*init_dma)(ide_hwif_t *, unsigned long);
1110
1111 const struct ide_port_ops *port_ops;
1112
1109 ide_pci_enablebit_t enablebits[2]; 1113 ide_pci_enablebit_t enablebits[2];
1110 hwif_chipset_t chipset; 1114 hwif_chipset_t chipset;
1111 u8 extra; 1115 u8 extra;