aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/cris/ide-cris.c18
-rw-r--r--drivers/ide/ide-cd.c10
-rw-r--r--drivers/ide/ide-floppy.c14
-rw-r--r--drivers/ide/ide-io.c38
-rw-r--r--drivers/ide/ide-iops.c86
-rw-r--r--drivers/ide/ide-probe.c19
-rw-r--r--drivers/ide/ide-tape.c12
-rw-r--r--drivers/ide/ide-taskfile.c29
-rw-r--r--drivers/ide/legacy/ht6560b.c13
-rw-r--r--drivers/ide/pci/hpt366.c2
-rw-r--r--drivers/ide/pci/scc_pata.c6
-rw-r--r--drivers/ide/pci/sgiioc4.c19
-rw-r--r--drivers/ide/ppc/pmac.c3
-rw-r--r--drivers/scsi/ide-scsi.c15
-rw-r--r--include/linux/ide.h29
15 files changed, 175 insertions, 138 deletions
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c
index c8ffbaf29a88..31266d278095 100644
--- a/drivers/ide/cris/ide-cris.c
+++ b/drivers/ide/cris/ide-cris.c
@@ -228,7 +228,10 @@ cris_ide_fill_descriptor(cris_dma_descr_type *d, void* buf, unsigned int len, in
228static void 228static void
229cris_ide_start_dma(ide_drive_t *drive, cris_dma_descr_type *d, int dir,int type,int len) 229cris_ide_start_dma(ide_drive_t *drive, cris_dma_descr_type *d, int dir,int type,int len)
230{ 230{
231 reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int, IDE_DATA_REG); 231 ide_hwif_t *hwif = drive->hwif;
232
233 reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int,
234 hwif->io_ports[IDE_DATA_OFFSET]);
232 reg_ata_rw_trf_cnt trf_cnt = {0}; 235 reg_ata_rw_trf_cnt trf_cnt = {0};
233 236
234 mycontext.saved_data = (dma_descr_data*)virt_to_phys(d); 237 mycontext.saved_data = (dma_descr_data*)virt_to_phys(d);
@@ -264,8 +267,12 @@ cris_ide_wait_dma(int dir)
264 267
265static int cris_dma_test_irq(ide_drive_t *drive) 268static int cris_dma_test_irq(ide_drive_t *drive)
266{ 269{
270 ide_hwif_t *hwif = drive->hwif;
267 int intr = REG_RD_INT(ata, regi_ata, r_intr); 271 int intr = REG_RD_INT(ata, regi_ata, r_intr);
268 reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int, IDE_DATA_REG); 272
273 reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int,
274 hwif->io_ports[IDE_DATA_OFFSET]);
275
269 return intr & (1 << ctrl2.sel) ? 1 : 0; 276 return intr & (1 << ctrl2.sel) ? 1 : 0;
270} 277}
271 278
@@ -523,7 +530,8 @@ static void cris_ide_start_dma(ide_drive_t *drive, cris_dma_descr_type *d, int d
523 IO_STATE(R_ATA_CTRL_DATA, handsh, dma); 530 IO_STATE(R_ATA_CTRL_DATA, handsh, dma);
524 *R_ATA_CTRL_DATA = 531 *R_ATA_CTRL_DATA =
525 cmd | 532 cmd |
526 IO_FIELD(R_ATA_CTRL_DATA, data, IDE_DATA_REG) | 533 IO_FIELD(R_ATA_CTRL_DATA, data,
534 drive->hwif->io_ports[IDE_DATA_OFFSET]) |
527 IO_STATE(R_ATA_CTRL_DATA, src_dst, dma) | 535 IO_STATE(R_ATA_CTRL_DATA, src_dst, dma) |
528 IO_STATE(R_ATA_CTRL_DATA, multi, on) | 536 IO_STATE(R_ATA_CTRL_DATA, multi, on) |
529 IO_STATE(R_ATA_CTRL_DATA, dma_size, word); 537 IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
@@ -541,7 +549,9 @@ cris_ide_wait_dma(int dir)
541static int cris_dma_test_irq(ide_drive_t *drive) 549static int cris_dma_test_irq(ide_drive_t *drive)
542{ 550{
543 int intr = *R_IRQ_MASK0_RD; 551 int intr = *R_IRQ_MASK0_RD;
544 int bus = IO_EXTRACT(R_ATA_CTRL_DATA, sel, IDE_DATA_REG); 552 int bus = IO_EXTRACT(R_ATA_CTRL_DATA, sel,
553 drive->hwif->io_ports[IDE_DATA_OFFSET]);
554
545 return intr & (1 << (bus + IO_BITNR(R_IRQ_MASK0_RD, ata_irq0))) ? 1 : 0; 555 return intr & (1 << (bus + IO_BITNR(R_IRQ_MASK0_RD, ata_irq0))) ? 1 : 0;
546} 556}
547 557
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index c8d0e8715997..396000208f81 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -542,7 +542,8 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
542 542
543 /* packet command */ 543 /* packet command */
544 spin_lock_irqsave(&ide_lock, flags); 544 spin_lock_irqsave(&ide_lock, flags);
545 hwif->OUTBSYNC(drive, WIN_PACKETCMD, IDE_COMMAND_REG); 545 hwif->OUTBSYNC(drive, WIN_PACKETCMD,
546 hwif->io_ports[IDE_COMMAND_OFFSET]);
546 ndelay(400); 547 ndelay(400);
547 spin_unlock_irqrestore(&ide_lock, flags); 548 spin_unlock_irqrestore(&ide_lock, flags);
548 549
@@ -992,6 +993,7 @@ static int cdrom_newpc_intr_dummy_cb(struct request *rq)
992 993
993static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) 994static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
994{ 995{
996 ide_hwif_t *hwif = drive->hwif;
995 struct cdrom_info *info = drive->driver_data; 997 struct cdrom_info *info = drive->driver_data;
996 struct request *rq = HWGROUP(drive)->rq; 998 struct request *rq = HWGROUP(drive)->rq;
997 xfer_func_t *xferfunc; 999 xfer_func_t *xferfunc;
@@ -1032,9 +1034,9 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
1032 /* 1034 /*
1033 * ok we fall to pio :/ 1035 * ok we fall to pio :/
1034 */ 1036 */
1035 ireason = HWIF(drive)->INB(IDE_IREASON_REG) & 0x3; 1037 ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]) & 0x3;
1036 lowcyl = HWIF(drive)->INB(IDE_BCOUNTL_REG); 1038 lowcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]);
1037 highcyl = HWIF(drive)->INB(IDE_BCOUNTH_REG); 1039 highcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]);
1038 1040
1039 len = lowcyl + (256 * highcyl); 1041 len = lowcyl + (256 * highcyl);
1040 1042
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 170c60d93f55..4ce67bdb5d5e 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -498,10 +498,10 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
498 } 498 }
499 499
500 /* Get the number of bytes to transfer */ 500 /* Get the number of bytes to transfer */
501 bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) | 501 bcount = (hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]) << 8) |
502 hwif->INB(IDE_BCOUNTL_REG); 502 hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]);
503 /* on this interrupt */ 503 /* on this interrupt */
504 ireason = hwif->INB(IDE_IREASON_REG); 504 ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
505 505
506 if (ireason & CD) { 506 if (ireason & CD) {
507 printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__); 507 printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__);
@@ -562,6 +562,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
562 */ 562 */
563static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive) 563static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive)
564{ 564{
565 ide_hwif_t *hwif = drive->hwif;
565 ide_startstop_t startstop; 566 ide_startstop_t startstop;
566 idefloppy_floppy_t *floppy = drive->driver_data; 567 idefloppy_floppy_t *floppy = drive->driver_data;
567 u8 ireason; 568 u8 ireason;
@@ -571,7 +572,7 @@ static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive)
571 "initiated yet DRQ isn't asserted\n"); 572 "initiated yet DRQ isn't asserted\n");
572 return startstop; 573 return startstop;
573 } 574 }
574 ireason = drive->hwif->INB(IDE_IREASON_REG); 575 ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
575 if ((ireason & CD) == 0 || (ireason & IO)) { 576 if ((ireason & CD) == 0 || (ireason & IO)) {
576 printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while " 577 printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while "
577 "issuing a packet command\n"); 578 "issuing a packet command\n");
@@ -608,6 +609,7 @@ static int idefloppy_transfer_pc2(ide_drive_t *drive)
608 609
609static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive) 610static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)
610{ 611{
612 ide_hwif_t *hwif = drive->hwif;
611 idefloppy_floppy_t *floppy = drive->driver_data; 613 idefloppy_floppy_t *floppy = drive->driver_data;
612 ide_startstop_t startstop; 614 ide_startstop_t startstop;
613 u8 ireason; 615 u8 ireason;
@@ -617,7 +619,7 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)
617 "initiated yet DRQ isn't asserted\n"); 619 "initiated yet DRQ isn't asserted\n");
618 return startstop; 620 return startstop;
619 } 621 }
620 ireason = drive->hwif->INB(IDE_IREASON_REG); 622 ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
621 if ((ireason & CD) == 0 || (ireason & IO)) { 623 if ((ireason & CD) == 0 || (ireason & IO)) {
622 printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) " 624 printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) "
623 "while issuing a packet command\n"); 625 "while issuing a packet command\n");
@@ -723,7 +725,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
723 return ide_started; 725 return ide_started;
724 } else { 726 } else {
725 /* Issue the packet command */ 727 /* Issue the packet command */
726 HWIF(drive)->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG); 728 hwif->OUTB(WIN_PACKETCMD, hwif->io_ports[IDE_COMMAND_OFFSET]);
727 return (*pkt_xfer_routine) (drive); 729 return (*pkt_xfer_routine) (drive);
728 } 730 }
729} 731}
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 715379605a7b..31e5afadb7e9 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -301,39 +301,45 @@ void ide_tf_read(ide_drive_t *drive, ide_task_t *task)
301 struct ide_taskfile *tf = &task->tf; 301 struct ide_taskfile *tf = &task->tf;
302 302
303 if (task->tf_flags & IDE_TFLAG_IN_DATA) { 303 if (task->tf_flags & IDE_TFLAG_IN_DATA) {
304 u16 data = hwif->INW(IDE_DATA_REG); 304 u16 data = hwif->INW(hwif->io_ports[IDE_DATA_OFFSET]);
305 305
306 tf->data = data & 0xff; 306 tf->data = data & 0xff;
307 tf->hob_data = (data >> 8) & 0xff; 307 tf->hob_data = (data >> 8) & 0xff;
308 } 308 }
309 309
310 /* be sure we're looking at the low order bits */ 310 /* be sure we're looking at the low order bits */
311 hwif->OUTB(drive->ctl & ~0x80, IDE_CONTROL_REG); 311 hwif->OUTB(drive->ctl & ~0x80, hwif->io_ports[IDE_CONTROL_OFFSET]);
312 312
313 if (task->tf_flags & IDE_TFLAG_IN_NSECT) 313 if (task->tf_flags & IDE_TFLAG_IN_NSECT)
314 tf->nsect = hwif->INB(IDE_NSECTOR_REG); 314 tf->nsect = hwif->INB(hwif->io_ports[IDE_NSECTOR_OFFSET]);
315 if (task->tf_flags & IDE_TFLAG_IN_LBAL) 315 if (task->tf_flags & IDE_TFLAG_IN_LBAL)
316 tf->lbal = hwif->INB(IDE_SECTOR_REG); 316 tf->lbal = hwif->INB(hwif->io_ports[IDE_SECTOR_OFFSET]);
317 if (task->tf_flags & IDE_TFLAG_IN_LBAM) 317 if (task->tf_flags & IDE_TFLAG_IN_LBAM)
318 tf->lbam = hwif->INB(IDE_LCYL_REG); 318 tf->lbam = hwif->INB(hwif->io_ports[IDE_LCYL_OFFSET]);
319 if (task->tf_flags & IDE_TFLAG_IN_LBAH) 319 if (task->tf_flags & IDE_TFLAG_IN_LBAH)
320 tf->lbah = hwif->INB(IDE_HCYL_REG); 320 tf->lbah = hwif->INB(hwif->io_ports[IDE_HCYL_OFFSET]);
321 if (task->tf_flags & IDE_TFLAG_IN_DEVICE) 321 if (task->tf_flags & IDE_TFLAG_IN_DEVICE)
322 tf->device = hwif->INB(IDE_SELECT_REG); 322 tf->device = hwif->INB(hwif->io_ports[IDE_SELECT_OFFSET]);
323 323
324 if (task->tf_flags & IDE_TFLAG_LBA48) { 324 if (task->tf_flags & IDE_TFLAG_LBA48) {
325 hwif->OUTB(drive->ctl | 0x80, IDE_CONTROL_REG); 325 hwif->OUTB(drive->ctl | 0x80,
326 hwif->io_ports[IDE_CONTROL_OFFSET]);
326 327
327 if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) 328 if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE)
328 tf->hob_feature = hwif->INB(IDE_FEATURE_REG); 329 tf->hob_feature =
330 hwif->INB(hwif->io_ports[IDE_FEATURE_OFFSET]);
329 if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT) 331 if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT)
330 tf->hob_nsect = hwif->INB(IDE_NSECTOR_REG); 332 tf->hob_nsect =
333 hwif->INB(hwif->io_ports[IDE_NSECTOR_OFFSET]);
331 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL) 334 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL)
332 tf->hob_lbal = hwif->INB(IDE_SECTOR_REG); 335 tf->hob_lbal =
336 hwif->INB(hwif->io_ports[IDE_SECTOR_OFFSET]);
333 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM) 337 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM)
334 tf->hob_lbam = hwif->INB(IDE_LCYL_REG); 338 tf->hob_lbam =
339 hwif->INB(hwif->io_ports[IDE_LCYL_OFFSET]);
335 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH) 340 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH)
336 tf->hob_lbah = hwif->INB(IDE_HCYL_REG); 341 tf->hob_lbah =
342 hwif->INB(hwif->io_ports[IDE_HCYL_OFFSET]);
337 } 343 }
338} 344}
339 345
@@ -448,7 +454,8 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8
448 if (err == ABRT_ERR) { 454 if (err == ABRT_ERR) {
449 if (drive->select.b.lba && 455 if (drive->select.b.lba &&
450 /* some newer drives don't support WIN_SPECIFY */ 456 /* some newer drives don't support WIN_SPECIFY */
451 hwif->INB(IDE_COMMAND_REG) == WIN_SPECIFY) 457 hwif->INB(hwif->io_ports[IDE_COMMAND_OFFSET]) ==
458 WIN_SPECIFY)
452 return ide_stopped; 459 return ide_stopped;
453 } else if ((err & BAD_CRC) == BAD_CRC) { 460 } else if ((err & BAD_CRC) == BAD_CRC) {
454 /* UDMA crc error, just retry the operation */ 461 /* UDMA crc error, just retry the operation */
@@ -500,7 +507,8 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u
500 507
501 if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) 508 if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
502 /* force an abort */ 509 /* force an abort */
503 hwif->OUTB(WIN_IDLEIMMEDIATE, IDE_COMMAND_REG); 510 hwif->OUTB(WIN_IDLEIMMEDIATE,
511 hwif->io_ports[IDE_COMMAND_OFFSET]);
504 512
505 if (rq->errors >= ERROR_MAX) { 513 if (rq->errors >= ERROR_MAX) {
506 ide_kill_rq(drive, rq); 514 ide_kill_rq(drive, rq);
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index e77cee0e5d65..45944219eea0 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -158,9 +158,12 @@ EXPORT_SYMBOL(default_hwif_mmiops);
158 158
159void SELECT_DRIVE (ide_drive_t *drive) 159void SELECT_DRIVE (ide_drive_t *drive)
160{ 160{
161 if (HWIF(drive)->selectproc) 161 ide_hwif_t *hwif = drive->hwif;
162 HWIF(drive)->selectproc(drive); 162
163 HWIF(drive)->OUTB(drive->select.all, IDE_SELECT_REG); 163 if (hwif->selectproc)
164 hwif->selectproc(drive);
165
166 hwif->OUTB(drive->select.all, hwif->io_ports[IDE_SELECT_OFFSET]);
164} 167}
165 168
166void SELECT_MASK (ide_drive_t *drive, int mask) 169void SELECT_MASK (ide_drive_t *drive, int mask)
@@ -194,15 +197,18 @@ static void ata_input_data(ide_drive_t *drive, void *buffer, u32 wcount)
194 if (io_32bit) { 197 if (io_32bit) {
195 if (io_32bit & 2) { 198 if (io_32bit & 2) {
196 unsigned long flags; 199 unsigned long flags;
200
197 local_irq_save(flags); 201 local_irq_save(flags);
198 ata_vlb_sync(drive, IDE_NSECTOR_REG); 202 ata_vlb_sync(drive, hwif->io_ports[IDE_NSECTOR_OFFSET]);
199 hwif->INSL(IDE_DATA_REG, buffer, wcount); 203 hwif->INSL(hwif->io_ports[IDE_DATA_OFFSET], buffer,
204 wcount);
200 local_irq_restore(flags); 205 local_irq_restore(flags);
201 } else 206 } else
202 hwif->INSL(IDE_DATA_REG, buffer, wcount); 207 hwif->INSL(hwif->io_ports[IDE_DATA_OFFSET], buffer,
203 } else { 208 wcount);
204 hwif->INSW(IDE_DATA_REG, buffer, wcount<<1); 209 } else
205 } 210 hwif->INSW(hwif->io_ports[IDE_DATA_OFFSET], buffer,
211 wcount << 1);
206} 212}
207 213
208/* 214/*
@@ -216,15 +222,18 @@ static void ata_output_data(ide_drive_t *drive, void *buffer, u32 wcount)
216 if (io_32bit) { 222 if (io_32bit) {
217 if (io_32bit & 2) { 223 if (io_32bit & 2) {
218 unsigned long flags; 224 unsigned long flags;
225
219 local_irq_save(flags); 226 local_irq_save(flags);
220 ata_vlb_sync(drive, IDE_NSECTOR_REG); 227 ata_vlb_sync(drive, hwif->io_ports[IDE_NSECTOR_OFFSET]);
221 hwif->OUTSL(IDE_DATA_REG, buffer, wcount); 228 hwif->OUTSL(hwif->io_ports[IDE_DATA_OFFSET], buffer,
229 wcount);
222 local_irq_restore(flags); 230 local_irq_restore(flags);
223 } else 231 } else
224 hwif->OUTSL(IDE_DATA_REG, buffer, wcount); 232 hwif->OUTSL(hwif->io_ports[IDE_DATA_OFFSET], buffer,
225 } else { 233 wcount);
226 hwif->OUTSW(IDE_DATA_REG, buffer, wcount<<1); 234 } else
227 } 235 hwif->OUTSW(hwif->io_ports[IDE_DATA_OFFSET], buffer,
236 wcount << 1);
228} 237}
229 238
230/* 239/*
@@ -243,13 +252,15 @@ static void atapi_input_bytes(ide_drive_t *drive, void *buffer, u32 bytecount)
243#if defined(CONFIG_ATARI) || defined(CONFIG_Q40) 252#if defined(CONFIG_ATARI) || defined(CONFIG_Q40)
244 if (MACH_IS_ATARI || MACH_IS_Q40) { 253 if (MACH_IS_ATARI || MACH_IS_Q40) {
245 /* Atari has a byte-swapped IDE interface */ 254 /* Atari has a byte-swapped IDE interface */
246 insw_swapw(IDE_DATA_REG, buffer, bytecount / 2); 255 insw_swapw(hwif->io_ports[IDE_DATA_OFFSET], buffer,
256 bytecount / 2);
247 return; 257 return;
248 } 258 }
249#endif /* CONFIG_ATARI || CONFIG_Q40 */ 259#endif /* CONFIG_ATARI || CONFIG_Q40 */
250 hwif->ata_input_data(drive, buffer, bytecount / 4); 260 hwif->ata_input_data(drive, buffer, bytecount / 4);
251 if ((bytecount & 0x03) >= 2) 261 if ((bytecount & 0x03) >= 2)
252 hwif->INSW(IDE_DATA_REG, ((u8 *)buffer)+(bytecount & ~0x03), 1); 262 hwif->INSW(hwif->io_ports[IDE_DATA_OFFSET],
263 (u8 *)buffer + (bytecount & ~0x03), 1);
253} 264}
254 265
255static void atapi_output_bytes(ide_drive_t *drive, void *buffer, u32 bytecount) 266static void atapi_output_bytes(ide_drive_t *drive, void *buffer, u32 bytecount)
@@ -260,13 +271,15 @@ static void atapi_output_bytes(ide_drive_t *drive, void *buffer, u32 bytecount)
260#if defined(CONFIG_ATARI) || defined(CONFIG_Q40) 271#if defined(CONFIG_ATARI) || defined(CONFIG_Q40)
261 if (MACH_IS_ATARI || MACH_IS_Q40) { 272 if (MACH_IS_ATARI || MACH_IS_Q40) {
262 /* Atari has a byte-swapped IDE interface */ 273 /* Atari has a byte-swapped IDE interface */
263 outsw_swapw(IDE_DATA_REG, buffer, bytecount / 2); 274 outsw_swapw(hwif->io_ports[IDE_DATA_OFFSET], buffer,
275 bytecount / 2);
264 return; 276 return;
265 } 277 }
266#endif /* CONFIG_ATARI || CONFIG_Q40 */ 278#endif /* CONFIG_ATARI || CONFIG_Q40 */
267 hwif->ata_output_data(drive, buffer, bytecount / 4); 279 hwif->ata_output_data(drive, buffer, bytecount / 4);
268 if ((bytecount & 0x03) >= 2) 280 if ((bytecount & 0x03) >= 2)
269 hwif->OUTSW(IDE_DATA_REG, ((u8*)buffer)+(bytecount & ~0x03), 1); 281 hwif->OUTSW(hwif->io_ports[IDE_DATA_OFFSET],
282 (u8 *)buffer + (bytecount & ~0x03), 1);
270} 283}
271 284
272void default_hwif_transport(ide_hwif_t *hwif) 285void default_hwif_transport(ide_hwif_t *hwif)
@@ -429,7 +442,7 @@ int drive_is_ready (ide_drive_t *drive)
429 * an interrupt with another pci card/device. We make no assumptions 442 * an interrupt with another pci card/device. We make no assumptions
430 * about possible isa-pnp and pci-pnp issues yet. 443 * about possible isa-pnp and pci-pnp issues yet.
431 */ 444 */
432 if (IDE_CONTROL_REG) 445 if (hwif->io_ports[IDE_CONTROL_OFFSET])
433 stat = ide_read_altstatus(drive); 446 stat = ide_read_altstatus(drive);
434 else 447 else
435 /* Note: this may clear a pending IRQ!! */ 448 /* Note: this may clear a pending IRQ!! */
@@ -631,7 +644,7 @@ int ide_driveid_update(ide_drive_t *drive)
631 SELECT_MASK(drive, 1); 644 SELECT_MASK(drive, 1);
632 ide_set_irq(drive, 1); 645 ide_set_irq(drive, 1);
633 msleep(50); 646 msleep(50);
634 hwif->OUTB(WIN_IDENTIFY, IDE_COMMAND_REG); 647 hwif->OUTB(WIN_IDENTIFY, hwif->io_ports[IDE_COMMAND_OFFSET]);
635 timeout = jiffies + WAIT_WORSTCASE; 648 timeout = jiffies + WAIT_WORSTCASE;
636 do { 649 do {
637 if (time_after(jiffies, timeout)) { 650 if (time_after(jiffies, timeout)) {
@@ -718,9 +731,10 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
718 SELECT_MASK(drive, 0); 731 SELECT_MASK(drive, 0);
719 udelay(1); 732 udelay(1);
720 ide_set_irq(drive, 0); 733 ide_set_irq(drive, 0);
721 hwif->OUTB(speed, IDE_NSECTOR_REG); 734 hwif->OUTB(speed, hwif->io_ports[IDE_NSECTOR_OFFSET]);
722 hwif->OUTB(SETFEATURES_XFER, IDE_FEATURE_REG); 735 hwif->OUTB(SETFEATURES_XFER, hwif->io_ports[IDE_FEATURE_OFFSET]);
723 hwif->OUTBSYNC(drive, WIN_SETFEATURES, IDE_COMMAND_REG); 736 hwif->OUTBSYNC(drive, WIN_SETFEATURES,
737 hwif->io_ports[IDE_COMMAND_OFFSET]);
724 if (drive->quirk_list == 2) 738 if (drive->quirk_list == 2)
725 ide_set_irq(drive, 1); 739 ide_set_irq(drive, 1);
726 740
@@ -828,7 +842,7 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
828 842
829 spin_lock_irqsave(&ide_lock, flags); 843 spin_lock_irqsave(&ide_lock, flags);
830 __ide_set_handler(drive, handler, timeout, expiry); 844 __ide_set_handler(drive, handler, timeout, expiry);
831 hwif->OUTBSYNC(drive, cmd, IDE_COMMAND_REG); 845 hwif->OUTBSYNC(drive, cmd, hwif->io_ports[IDE_COMMAND_OFFSET]);
832 /* 846 /*
833 * Drive takes 400nS to respond, we must avoid the IRQ being 847 * Drive takes 400nS to respond, we must avoid the IRQ being
834 * serviced before that. 848 * serviced before that.
@@ -1009,7 +1023,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1009 unsigned long flags; 1023 unsigned long flags;
1010 ide_hwif_t *hwif; 1024 ide_hwif_t *hwif;
1011 ide_hwgroup_t *hwgroup; 1025 ide_hwgroup_t *hwgroup;
1012 1026 u8 ctl;
1027
1013 spin_lock_irqsave(&ide_lock, flags); 1028 spin_lock_irqsave(&ide_lock, flags);
1014 hwif = HWIF(drive); 1029 hwif = HWIF(drive);
1015 hwgroup = HWGROUP(drive); 1030 hwgroup = HWGROUP(drive);
@@ -1023,7 +1038,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1023 pre_reset(drive); 1038 pre_reset(drive);
1024 SELECT_DRIVE(drive); 1039 SELECT_DRIVE(drive);
1025 udelay (20); 1040 udelay (20);
1026 hwif->OUTBSYNC(drive, WIN_SRST, IDE_COMMAND_REG); 1041 hwif->OUTBSYNC(drive, WIN_SRST,
1042 hwif->io_ports[IDE_COMMAND_OFFSET]);
1027 ndelay(400); 1043 ndelay(400);
1028 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; 1044 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
1029 hwgroup->polling = 1; 1045 hwgroup->polling = 1;
@@ -1039,7 +1055,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1039 for (unit = 0; unit < MAX_DRIVES; ++unit) 1055 for (unit = 0; unit < MAX_DRIVES; ++unit)
1040 pre_reset(&hwif->drives[unit]); 1056 pre_reset(&hwif->drives[unit]);
1041 1057
1042 if (!IDE_CONTROL_REG) { 1058 if (hwif->io_ports[IDE_CONTROL_OFFSET] == 0) {
1043 spin_unlock_irqrestore(&ide_lock, flags); 1059 spin_unlock_irqrestore(&ide_lock, flags);
1044 return ide_stopped; 1060 return ide_stopped;
1045 } 1061 }
@@ -1054,16 +1070,14 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1054 * recover from reset very quickly, saving us the first 50ms wait time. 1070 * recover from reset very quickly, saving us the first 50ms wait time.
1055 */ 1071 */
1056 /* set SRST and nIEN */ 1072 /* set SRST and nIEN */
1057 hwif->OUTBSYNC(drive, drive->ctl|6,IDE_CONTROL_REG); 1073 hwif->OUTBSYNC(drive, drive->ctl|6, hwif->io_ports[IDE_CONTROL_OFFSET]);
1058 /* more than enough time */ 1074 /* more than enough time */
1059 udelay(10); 1075 udelay(10);
1060 if (drive->quirk_list == 2) { 1076 if (drive->quirk_list == 2)
1061 /* clear SRST and nIEN */ 1077 ctl = drive->ctl; /* clear SRST and nIEN */
1062 hwif->OUTBSYNC(drive, drive->ctl, IDE_CONTROL_REG); 1078 else
1063 } else { 1079 ctl = drive->ctl | 2; /* clear SRST, leave nIEN */
1064 /* clear SRST, leave nIEN */ 1080 hwif->OUTBSYNC(drive, ctl, hwif->io_ports[IDE_CONTROL_OFFSET]);
1065 hwif->OUTBSYNC(drive, drive->ctl|2, IDE_CONTROL_REG);
1066 }
1067 /* more than enough time */ 1081 /* more than enough time */
1068 udelay(10); 1082 udelay(10);
1069 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; 1083 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 33cb5e5a249b..10ccf278d5be 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -271,7 +271,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
271 /* take a deep breath */ 271 /* take a deep breath */
272 msleep(50); 272 msleep(50);
273 273
274 if (IDE_CONTROL_REG) { 274 if (hwif->io_ports[IDE_CONTROL_OFFSET]) {
275 a = ide_read_altstatus(drive); 275 a = ide_read_altstatus(drive);
276 s = ide_read_status(drive); 276 s = ide_read_status(drive);
277 if ((a ^ s) & ~INDEX_STAT) 277 if ((a ^ s) & ~INDEX_STAT)
@@ -289,10 +289,10 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
289 */ 289 */
290 if ((cmd == WIN_PIDENTIFY)) 290 if ((cmd == WIN_PIDENTIFY))
291 /* disable dma & overlap */ 291 /* disable dma & overlap */
292 hwif->OUTB(0, IDE_FEATURE_REG); 292 hwif->OUTB(0, hwif->io_ports[IDE_FEATURE_OFFSET]);
293 293
294 /* ask drive for ID */ 294 /* ask drive for ID */
295 hwif->OUTB(cmd, IDE_COMMAND_REG); 295 hwif->OUTB(cmd, hwif->io_ports[IDE_COMMAND_OFFSET]);
296 296
297 timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; 297 timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2;
298 timeout += jiffies; 298 timeout += jiffies;
@@ -353,7 +353,7 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd)
353 * interrupts during the identify-phase that 353 * interrupts during the identify-phase that
354 * the irq handler isn't expecting. 354 * the irq handler isn't expecting.
355 */ 355 */
356 if (IDE_CONTROL_REG) { 356 if (hwif->io_ports[IDE_CONTROL_OFFSET]) {
357 if (!hwif->irq) { 357 if (!hwif->irq) {
358 autoprobe = 1; 358 autoprobe = 1;
359 cookie = probe_irq_on(); 359 cookie = probe_irq_on();
@@ -445,7 +445,8 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
445 msleep(50); 445 msleep(50);
446 SELECT_DRIVE(drive); 446 SELECT_DRIVE(drive);
447 msleep(50); 447 msleep(50);
448 if (hwif->INB(IDE_SELECT_REG) != drive->select.all && !drive->present) { 448 if (hwif->INB(hwif->io_ports[IDE_SELECT_OFFSET]) != drive->select.all &&
449 !drive->present) {
449 if (drive->select.b.unit != 0) { 450 if (drive->select.b.unit != 0) {
450 /* exit with drive0 selected */ 451 /* exit with drive0 selected */
451 SELECT_DRIVE(&hwif->drives[0]); 452 SELECT_DRIVE(&hwif->drives[0]);
@@ -477,9 +478,11 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
477 printk(KERN_ERR "%s: no response (status = 0x%02x), " 478 printk(KERN_ERR "%s: no response (status = 0x%02x), "
478 "resetting drive\n", drive->name, stat); 479 "resetting drive\n", drive->name, stat);
479 msleep(50); 480 msleep(50);
480 hwif->OUTB(drive->select.all, IDE_SELECT_REG); 481 hwif->OUTB(drive->select.all,
482 hwif->io_ports[IDE_SELECT_OFFSET]);
481 msleep(50); 483 msleep(50);
482 hwif->OUTB(WIN_SRST, IDE_COMMAND_REG); 484 hwif->OUTB(WIN_SRST,
485 hwif->io_ports[IDE_COMMAND_OFFSET]);
483 (void)ide_busy_sleep(hwif); 486 (void)ide_busy_sleep(hwif);
484 rc = try_to_identify(drive, cmd); 487 rc = try_to_identify(drive, cmd);
485 } 488 }
@@ -515,7 +518,7 @@ static void enable_nest (ide_drive_t *drive)
515 printk("%s: enabling %s -- ", hwif->name, drive->id->model); 518 printk("%s: enabling %s -- ", hwif->name, drive->id->model);
516 SELECT_DRIVE(drive); 519 SELECT_DRIVE(drive);
517 msleep(50); 520 msleep(50);
518 hwif->OUTB(EXABYTE_ENABLE_NEST, IDE_COMMAND_REG); 521 hwif->OUTB(EXABYTE_ENABLE_NEST, hwif->io_ports[IDE_COMMAND_OFFSET]);
519 522
520 if (ide_busy_sleep(hwif)) { 523 if (ide_busy_sleep(hwif)) {
521 printk(KERN_CONT "failed (timeout)\n"); 524 printk(KERN_CONT "failed (timeout)\n");
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index bfdc4f449797..8c39146b6088 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -1117,10 +1117,10 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive)
1117 return ide_do_reset(drive); 1117 return ide_do_reset(drive);
1118 } 1118 }
1119 /* Get the number of bytes to transfer on this interrupt. */ 1119 /* Get the number of bytes to transfer on this interrupt. */
1120 bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) | 1120 bcount = (hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]) << 8) |
1121 hwif->INB(IDE_BCOUNTL_REG); 1121 hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]);
1122 1122
1123 ireason = hwif->INB(IDE_IREASON_REG); 1123 ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
1124 1124
1125 if (ireason & CD) { 1125 if (ireason & CD) {
1126 printk(KERN_ERR "ide-tape: CoD != 0 in %s\n", __func__); 1126 printk(KERN_ERR "ide-tape: CoD != 0 in %s\n", __func__);
@@ -1224,12 +1224,12 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive)
1224 "yet DRQ isn't asserted\n"); 1224 "yet DRQ isn't asserted\n");
1225 return startstop; 1225 return startstop;
1226 } 1226 }
1227 ireason = hwif->INB(IDE_IREASON_REG); 1227 ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
1228 while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) { 1228 while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) {
1229 printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while issuing " 1229 printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while issuing "
1230 "a packet command, retrying\n"); 1230 "a packet command, retrying\n");
1231 udelay(100); 1231 udelay(100);
1232 ireason = hwif->INB(IDE_IREASON_REG); 1232 ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
1233 if (retries == 0) { 1233 if (retries == 0) {
1234 printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while " 1234 printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while "
1235 "issuing a packet command, ignoring\n"); 1235 "issuing a packet command, ignoring\n");
@@ -1323,7 +1323,7 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, idetape_pc_t *pc)
1323 IDETAPE_WAIT_CMD, NULL); 1323 IDETAPE_WAIT_CMD, NULL);
1324 return ide_started; 1324 return ide_started;
1325 } else { 1325 } else {
1326 hwif->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG); 1326 hwif->OUTB(WIN_PACKETCMD, hwif->io_ports[IDE_COMMAND_OFFSET]);
1327 return idetape_transfer_pc(drive); 1327 return idetape_transfer_pc(drive);
1328 } 1328 }
1329} 1329}
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 4c86a8d84b4c..155cc904f4eb 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -59,32 +59,34 @@ void ide_tf_load(ide_drive_t *drive, ide_task_t *task)
59 SELECT_MASK(drive, 0); 59 SELECT_MASK(drive, 0);
60 60
61 if (task->tf_flags & IDE_TFLAG_OUT_DATA) 61 if (task->tf_flags & IDE_TFLAG_OUT_DATA)
62 hwif->OUTW((tf->hob_data << 8) | tf->data, IDE_DATA_REG); 62 hwif->OUTW((tf->hob_data << 8) | tf->data,
63 hwif->io_ports[IDE_DATA_OFFSET]);
63 64
64 if (task->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE) 65 if (task->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE)
65 hwif->OUTB(tf->hob_feature, IDE_FEATURE_REG); 66 hwif->OUTB(tf->hob_feature, hwif->io_ports[IDE_FEATURE_OFFSET]);
66 if (task->tf_flags & IDE_TFLAG_OUT_HOB_NSECT) 67 if (task->tf_flags & IDE_TFLAG_OUT_HOB_NSECT)
67 hwif->OUTB(tf->hob_nsect, IDE_NSECTOR_REG); 68 hwif->OUTB(tf->hob_nsect, hwif->io_ports[IDE_NSECTOR_OFFSET]);
68 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAL) 69 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAL)
69 hwif->OUTB(tf->hob_lbal, IDE_SECTOR_REG); 70 hwif->OUTB(tf->hob_lbal, hwif->io_ports[IDE_SECTOR_OFFSET]);
70 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAM) 71 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAM)
71 hwif->OUTB(tf->hob_lbam, IDE_LCYL_REG); 72 hwif->OUTB(tf->hob_lbam, hwif->io_ports[IDE_LCYL_OFFSET]);
72 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAH) 73 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAH)
73 hwif->OUTB(tf->hob_lbah, IDE_HCYL_REG); 74 hwif->OUTB(tf->hob_lbah, hwif->io_ports[IDE_HCYL_OFFSET]);
74 75
75 if (task->tf_flags & IDE_TFLAG_OUT_FEATURE) 76 if (task->tf_flags & IDE_TFLAG_OUT_FEATURE)
76 hwif->OUTB(tf->feature, IDE_FEATURE_REG); 77 hwif->OUTB(tf->feature, hwif->io_ports[IDE_FEATURE_OFFSET]);
77 if (task->tf_flags & IDE_TFLAG_OUT_NSECT) 78 if (task->tf_flags & IDE_TFLAG_OUT_NSECT)
78 hwif->OUTB(tf->nsect, IDE_NSECTOR_REG); 79 hwif->OUTB(tf->nsect, hwif->io_ports[IDE_NSECTOR_OFFSET]);
79 if (task->tf_flags & IDE_TFLAG_OUT_LBAL) 80 if (task->tf_flags & IDE_TFLAG_OUT_LBAL)
80 hwif->OUTB(tf->lbal, IDE_SECTOR_REG); 81 hwif->OUTB(tf->lbal, hwif->io_ports[IDE_SECTOR_OFFSET]);
81 if (task->tf_flags & IDE_TFLAG_OUT_LBAM) 82 if (task->tf_flags & IDE_TFLAG_OUT_LBAM)
82 hwif->OUTB(tf->lbam, IDE_LCYL_REG); 83 hwif->OUTB(tf->lbam, hwif->io_ports[IDE_LCYL_OFFSET]);
83 if (task->tf_flags & IDE_TFLAG_OUT_LBAH) 84 if (task->tf_flags & IDE_TFLAG_OUT_LBAH)
84 hwif->OUTB(tf->lbah, IDE_HCYL_REG); 85 hwif->OUTB(tf->lbah, hwif->io_ports[IDE_HCYL_OFFSET]);
85 86
86 if (task->tf_flags & IDE_TFLAG_OUT_DEVICE) 87 if (task->tf_flags & IDE_TFLAG_OUT_DEVICE)
87 hwif->OUTB((tf->device & HIHI) | drive->select.all, IDE_SELECT_REG); 88 hwif->OUTB((tf->device & HIHI) | drive->select.all,
89 hwif->io_ports[IDE_SELECT_OFFSET]);
88} 90}
89 91
90int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) 92int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf)
@@ -152,7 +154,8 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task)
152 switch (task->data_phase) { 154 switch (task->data_phase) {
153 case TASKFILE_MULTI_OUT: 155 case TASKFILE_MULTI_OUT:
154 case TASKFILE_OUT: 156 case TASKFILE_OUT:
155 hwif->OUTBSYNC(drive, tf->command, IDE_COMMAND_REG); 157 hwif->OUTBSYNC(drive, tf->command,
158 hwif->io_ports[IDE_COMMAND_OFFSET]);
156 ndelay(400); /* FIXME */ 159 ndelay(400); /* FIXME */
157 return pre_task_out_intr(drive, task->rq); 160 return pre_task_out_intr(drive, task->rq);
158 case TASKFILE_MULTI_IN: 161 case TASKFILE_MULTI_IN:
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c
index 78ca68e60f97..314e6c6aeb6c 100644
--- a/drivers/ide/legacy/ht6560b.c
+++ b/drivers/ide/legacy/ht6560b.c
@@ -82,7 +82,7 @@
82 * out how they setup those cycle time interfacing values, as they at Holtek 82 * out how they setup those cycle time interfacing values, as they at Holtek
83 * call them. IDESETUP.COM that is supplied with the drivers figures out 83 * call them. IDESETUP.COM that is supplied with the drivers figures out
84 * optimal values and fetches those values to drivers. I found out that 84 * optimal values and fetches those values to drivers. I found out that
85 * they use IDE_SELECT_REG to fetch timings to the ide board right after 85 * they use Select register to fetch timings to the ide board right after
86 * interface switching. After that it was quite easy to add code to 86 * interface switching. After that it was quite easy to add code to
87 * ht6560b.c. 87 * ht6560b.c.
88 * 88 *
@@ -127,6 +127,7 @@
127 */ 127 */
128static void ht6560b_selectproc (ide_drive_t *drive) 128static void ht6560b_selectproc (ide_drive_t *drive)
129{ 129{
130 ide_hwif_t *hwif = drive->hwif;
130 unsigned long flags; 131 unsigned long flags;
131 static u8 current_select = 0; 132 static u8 current_select = 0;
132 static u8 current_timing = 0; 133 static u8 current_timing = 0;
@@ -155,8 +156,8 @@ static void ht6560b_selectproc (ide_drive_t *drive)
155 /* 156 /*
156 * Set timing for this drive: 157 * Set timing for this drive:
157 */ 158 */
158 outb(timing, IDE_SELECT_REG); 159 outb(timing, hwif->io_ports[IDE_SELECT_OFFSET]);
159 (void)inb(IDE_STATUS_REG); 160 (void)inb(hwif->io_ports[IDE_STATUS_OFFSET]);
160#ifdef DEBUG 161#ifdef DEBUG
161 printk("ht6560b: %s: select=%#x timing=%#x\n", 162 printk("ht6560b: %s: select=%#x timing=%#x\n",
162 drive->name, select, timing); 163 drive->name, select, timing);
@@ -193,9 +194,9 @@ static int __init try_to_init_ht6560b(void)
193 * Ht6560b autodetected 194 * Ht6560b autodetected
194 */ 195 */
195 outb(HT_CONFIG_DEFAULT, HT_CONFIG_PORT); 196 outb(HT_CONFIG_DEFAULT, HT_CONFIG_PORT);
196 outb(HT_TIMING_DEFAULT, 0x1f6); /* IDE_SELECT_REG */ 197 outb(HT_TIMING_DEFAULT, 0x1f6); /* Select register */
197 (void) inb(0x1f7); /* IDE_STATUS_REG */ 198 (void)inb(0x1f7); /* Status register */
198 199
199 printk("ht6560b " HT6560B_VERSION 200 printk("ht6560b " HT6560B_VERSION
200 ": chipset detected and initialized" 201 ": chipset detected and initialized"
201#ifdef DEBUG 202#ifdef DEBUG
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index d03a231d965e..82d0e318a1fe 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -760,7 +760,7 @@ static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
760 } 760 }
761 } else 761 } else
762 outb(mask ? (drive->ctl | 2) : (drive->ctl & ~2), 762 outb(mask ? (drive->ctl | 2) : (drive->ctl & ~2),
763 IDE_CONTROL_REG); 763 hwif->io_ports[IDE_CONTROL_OFFSET]);
764} 764}
765 765
766/* 766/*
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index 1a560dc1eac1..ef07c7a8b97a 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -334,7 +334,8 @@ static int scc_ide_dma_end(ide_drive_t * drive)
334 334
335 /* errata A308 workaround: Step5 (check data loss) */ 335 /* errata A308 workaround: Step5 (check data loss) */
336 /* We don't check non ide_disk because it is limited to UDMA4 */ 336 /* We don't check non ide_disk because it is limited to UDMA4 */
337 if (!(in_be32((void __iomem *)IDE_ALTSTATUS_REG) & ERR_STAT) && 337 if (!(in_be32((void __iomem *)hwif->io_ports[IDE_ALTSTATUS_OFFSET])
338 & ERR_STAT) &&
338 drive->media == ide_disk && drive->current_speed > XFER_UDMA_4) { 339 drive->media == ide_disk && drive->current_speed > XFER_UDMA_4) {
339 reg = in_be32((void __iomem *)intsts_port); 340 reg = in_be32((void __iomem *)intsts_port);
340 if (!(reg & INTSTS_ACTEINT)) { 341 if (!(reg & INTSTS_ACTEINT)) {
@@ -437,7 +438,8 @@ static int scc_dma_test_irq(ide_drive_t *drive)
437 u32 int_stat = in_be32((void __iomem *)hwif->dma_base + 0x014); 438 u32 int_stat = in_be32((void __iomem *)hwif->dma_base + 0x014);
438 439
439 /* SCC errata A252,A308 workaround: Step4 */ 440 /* SCC errata A252,A308 workaround: Step4 */
440 if ((in_be32((void __iomem *)IDE_ALTSTATUS_REG) & ERR_STAT) && 441 if ((in_be32((void __iomem *)hwif->io_ports[IDE_ALTSTATUS_OFFSET])
442 & ERR_STAT) &&
441 (int_stat & INTSTS_INTRQ)) 443 (int_stat & INTSTS_INTRQ))
442 return 1; 444 return 1;
443 445
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 9046a69117ff..9d1a3038af9b 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -112,10 +112,9 @@ static void
112sgiioc4_maskproc(ide_drive_t * drive, int mask) 112sgiioc4_maskproc(ide_drive_t * drive, int mask)
113{ 113{
114 writeb(mask ? (drive->ctl | 2) : (drive->ctl & ~2), 114 writeb(mask ? (drive->ctl | 2) : (drive->ctl & ~2),
115 (void __iomem *)IDE_CONTROL_REG); 115 (void __iomem *)drive->hwif->io_ports[IDE_CONTROL_OFFSET]);
116} 116}
117 117
118
119static int 118static int
120sgiioc4_checkirq(ide_hwif_t * hwif) 119sgiioc4_checkirq(ide_hwif_t * hwif)
121{ 120{
@@ -142,18 +141,18 @@ sgiioc4_clearirq(ide_drive_t * drive)
142 intr_reg = readl((void __iomem *)other_ir); 141 intr_reg = readl((void __iomem *)other_ir);
143 if (intr_reg & 0x03) { /* Valid IOC4-IDE interrupt */ 142 if (intr_reg & 0x03) { /* Valid IOC4-IDE interrupt */
144 /* 143 /*
145 * Using sgiioc4_INB to read the IDE_STATUS_REG has a side effect 144 * Using sgiioc4_INB to read the Status register has a side
146 * of clearing the interrupt. The first read should clear it 145 * effect of clearing the interrupt. The first read should
147 * if it is set. The second read should return a "clear" status 146 * clear it if it is set. The second read should return
148 * if it got cleared. If not, then spin for a bit trying to 147 * a "clear" status if it got cleared. If not, then spin
149 * clear it. 148 * for a bit trying to clear it.
150 */ 149 */
151 u8 stat = sgiioc4_INB(IDE_STATUS_REG); 150 u8 stat = sgiioc4_INB(hwif->io_ports[IDE_STATUS_OFFSET]);
152 int count = 0; 151 int count = 0;
153 stat = sgiioc4_INB(IDE_STATUS_REG); 152 stat = sgiioc4_INB(hwif->io_ports[IDE_STATUS_OFFSET]);
154 while ((stat & 0x80) && (count++ < 100)) { 153 while ((stat & 0x80) && (count++ < 100)) {
155 udelay(1); 154 udelay(1);
156 stat = sgiioc4_INB(IDE_STATUS_REG); 155 stat = sgiioc4_INB(hwif->io_ports[IDE_STATUS_OFFSET]);
157 } 156 }
158 157
159 if (intr_reg & 0x02) { 158 if (intr_reg & 0x02) {
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index b37dcfbdaad6..03a77713caf2 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -450,7 +450,8 @@ pmac_ide_init_hwif_ports(hw_regs_t *hw,
450 hw->dev = &pmac_ide[ix].mdev->ofdev.dev; 450 hw->dev = &pmac_ide[ix].mdev->ofdev.dev;
451} 451}
452 452
453#define PMAC_IDE_REG(x) ((void __iomem *)(IDE_DATA_REG+(x))) 453#define PMAC_IDE_REG(x) \
454 ((void __iomem *)((drive)->hwif->io_ports[IDE_DATA_OFFSET] + (x)))
454 455
455/* 456/*
456 * Apply the timings of the proper unit (master/slave) to the shared 457 * Apply the timings of the proper unit (master/slave) to the shared
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 3c3b3502c4d4..7fea769cf291 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -275,9 +275,12 @@ static int idescsi_end_request(ide_drive_t *, int, int);
275static ide_startstop_t 275static ide_startstop_t
276idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) 276idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
277{ 277{
278 ide_hwif_t *hwif = drive->hwif;
279
278 if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) 280 if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
279 /* force an abort */ 281 /* force an abort */
280 HWIF(drive)->OUTB(WIN_IDLEIMMEDIATE,IDE_COMMAND_REG); 282 hwif->OUTB(WIN_IDLEIMMEDIATE,
283 hwif->io_ports[IDE_COMMAND_OFFSET]);
281 284
282 rq->errors++; 285 rq->errors++;
283 286
@@ -423,9 +426,9 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
423 idescsi_end_request (drive, 1, 0); 426 idescsi_end_request (drive, 1, 0);
424 return ide_stopped; 427 return ide_stopped;
425 } 428 }
426 bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) | 429 bcount = (hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]) << 8) |
427 hwif->INB(IDE_BCOUNTL_REG); 430 hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]);
428 ireason = hwif->INB(IDE_IREASON_REG); 431 ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
429 432
430 if (ireason & CD) { 433 if (ireason & CD) {
431 printk(KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n"); 434 printk(KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n");
@@ -497,7 +500,7 @@ static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive)
497 "initiated yet DRQ isn't asserted\n"); 500 "initiated yet DRQ isn't asserted\n");
498 return startstop; 501 return startstop;
499 } 502 }
500 ireason = hwif->INB(IDE_IREASON_REG); 503 ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
501 if ((ireason & CD) == 0 || (ireason & IO)) { 504 if ((ireason & CD) == 0 || (ireason & IO)) {
502 printk(KERN_ERR "ide-scsi: (IO,CoD) != (0,1) while " 505 printk(KERN_ERR "ide-scsi: (IO,CoD) != (0,1) while "
503 "issuing a packet command\n"); 506 "issuing a packet command\n");
@@ -587,7 +590,7 @@ static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc)
587 return ide_started; 590 return ide_started;
588 } else { 591 } else {
589 /* Issue the packet command */ 592 /* Issue the packet command */
590 HWIF(drive)->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG); 593 hwif->OUTB(WIN_PACKETCMD, hwif->io_ports[IDE_COMMAND_OFFSET]);
591 return idescsi_transfer_pc(drive); 594 return idescsi_transfer_pc(drive);
592 } 595 }
593} 596}
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 2eb99cab4a3d..3b691cce00e1 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -82,24 +82,10 @@ typedef unsigned char byte; /* used everywhere */
82 82
83#define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET 83#define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET
84#define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET 84#define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET
85 85#define IDE_ALTSTATUS_OFFSET IDE_CONTROL_OFFSET
86#define IDE_DATA_REG (HWIF(drive)->io_ports[IDE_DATA_OFFSET]) 86#define IDE_IREASON_OFFSET IDE_NSECTOR_OFFSET
87#define IDE_ERROR_REG (HWIF(drive)->io_ports[IDE_ERROR_OFFSET]) 87#define IDE_BCOUNTL_OFFSET IDE_LCYL_OFFSET
88#define IDE_NSECTOR_REG (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET]) 88#define IDE_BCOUNTH_OFFSET IDE_HCYL_OFFSET
89#define IDE_SECTOR_REG (HWIF(drive)->io_ports[IDE_SECTOR_OFFSET])
90#define IDE_LCYL_REG (HWIF(drive)->io_ports[IDE_LCYL_OFFSET])
91#define IDE_HCYL_REG (HWIF(drive)->io_ports[IDE_HCYL_OFFSET])
92#define IDE_SELECT_REG (HWIF(drive)->io_ports[IDE_SELECT_OFFSET])
93#define IDE_STATUS_REG (HWIF(drive)->io_ports[IDE_STATUS_OFFSET])
94#define IDE_CONTROL_REG (HWIF(drive)->io_ports[IDE_CONTROL_OFFSET])
95#define IDE_IRQ_REG (HWIF(drive)->io_ports[IDE_IRQ_OFFSET])
96
97#define IDE_FEATURE_REG IDE_ERROR_REG
98#define IDE_COMMAND_REG IDE_STATUS_REG
99#define IDE_ALTSTATUS_REG IDE_CONTROL_REG
100#define IDE_IREASON_REG IDE_NSECTOR_REG
101#define IDE_BCOUNTL_REG IDE_LCYL_REG
102#define IDE_BCOUNTH_REG IDE_HCYL_REG
103 89
104#define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good)) 90#define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good))
105#define BAD_R_STAT (BUSY_STAT | ERR_STAT) 91#define BAD_R_STAT (BUSY_STAT | ERR_STAT)
@@ -369,7 +355,7 @@ typedef struct ide_drive_s {
369 u8 wcache; /* status of write cache */ 355 u8 wcache; /* status of write cache */
370 u8 acoustic; /* acoustic management */ 356 u8 acoustic; /* acoustic management */
371 u8 media; /* disk, cdrom, tape, floppy, ... */ 357 u8 media; /* disk, cdrom, tape, floppy, ... */
372 u8 ctl; /* "normal" value for IDE_CONTROL_REG */ 358 u8 ctl; /* "normal" value for Control register */
373 u8 ready_stat; /* min status value for drive ready */ 359 u8 ready_stat; /* min status value for drive ready */
374 u8 mult_count; /* current multiple sector setting */ 360 u8 mult_count; /* current multiple sector setting */
375 u8 mult_req; /* requested multiple sector setting */ 361 u8 mult_req; /* requested multiple sector setting */
@@ -1273,7 +1259,10 @@ static inline ide_drive_t *ide_get_paired_drive(ide_drive_t *drive)
1273 1259
1274static inline void ide_set_irq(ide_drive_t *drive, int on) 1260static inline void ide_set_irq(ide_drive_t *drive, int on)
1275{ 1261{
1276 drive->hwif->OUTB(drive->ctl | (on ? 0 : 2), IDE_CONTROL_REG); 1262 ide_hwif_t *hwif = drive->hwif;
1263
1264 hwif->OUTB(drive->ctl | (on ? 0 : 2),
1265 hwif->io_ports[IDE_CONTROL_OFFSET]);
1277} 1266}
1278 1267
1279static inline u8 ide_read_status(ide_drive_t *drive) 1268static inline u8 ide_read_status(ide_drive_t *drive)