ide: remove IDE_*_REG macros

* Add IDE_{ALTSTATUS,IREASON,BCOUNTL,BCOUNTH}_OFFSET defines.

* Remove IDE_*_REG macros - this results in more readable
  and slightly smaller code.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Acked-by: default avatarSergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 7616c0ad
...@@ -228,7 +228,10 @@ cris_ide_fill_descriptor(cris_dma_descr_type *d, void* buf, unsigned int len, in ...@@ -228,7 +228,10 @@ cris_ide_fill_descriptor(cris_dma_descr_type *d, void* buf, unsigned int len, in
static void static void
cris_ide_start_dma(ide_drive_t *drive, cris_dma_descr_type *d, int dir,int type,int len) cris_ide_start_dma(ide_drive_t *drive, cris_dma_descr_type *d, int dir,int type,int len)
{ {
reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int, IDE_DATA_REG); ide_hwif_t *hwif = drive->hwif;
reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int,
hwif->io_ports[IDE_DATA_OFFSET]);
reg_ata_rw_trf_cnt trf_cnt = {0}; reg_ata_rw_trf_cnt trf_cnt = {0};
mycontext.saved_data = (dma_descr_data*)virt_to_phys(d); mycontext.saved_data = (dma_descr_data*)virt_to_phys(d);
...@@ -264,8 +267,12 @@ cris_ide_wait_dma(int dir) ...@@ -264,8 +267,12 @@ cris_ide_wait_dma(int dir)
static int cris_dma_test_irq(ide_drive_t *drive) static int cris_dma_test_irq(ide_drive_t *drive)
{ {
ide_hwif_t *hwif = drive->hwif;
int intr = REG_RD_INT(ata, regi_ata, r_intr); int intr = REG_RD_INT(ata, regi_ata, r_intr);
reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int, IDE_DATA_REG);
reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int,
hwif->io_ports[IDE_DATA_OFFSET]);
return intr & (1 << ctrl2.sel) ? 1 : 0; return intr & (1 << ctrl2.sel) ? 1 : 0;
} }
...@@ -523,7 +530,8 @@ static void cris_ide_start_dma(ide_drive_t *drive, cris_dma_descr_type *d, int d ...@@ -523,7 +530,8 @@ static void cris_ide_start_dma(ide_drive_t *drive, cris_dma_descr_type *d, int d
IO_STATE(R_ATA_CTRL_DATA, handsh, dma); IO_STATE(R_ATA_CTRL_DATA, handsh, dma);
*R_ATA_CTRL_DATA = *R_ATA_CTRL_DATA =
cmd | cmd |
IO_FIELD(R_ATA_CTRL_DATA, data, IDE_DATA_REG) | IO_FIELD(R_ATA_CTRL_DATA, data,
drive->hwif->io_ports[IDE_DATA_OFFSET]) |
IO_STATE(R_ATA_CTRL_DATA, src_dst, dma) | IO_STATE(R_ATA_CTRL_DATA, src_dst, dma) |
IO_STATE(R_ATA_CTRL_DATA, multi, on) | IO_STATE(R_ATA_CTRL_DATA, multi, on) |
IO_STATE(R_ATA_CTRL_DATA, dma_size, word); IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
...@@ -541,7 +549,9 @@ cris_ide_wait_dma(int dir) ...@@ -541,7 +549,9 @@ cris_ide_wait_dma(int dir)
static int cris_dma_test_irq(ide_drive_t *drive) static int cris_dma_test_irq(ide_drive_t *drive)
{ {
int intr = *R_IRQ_MASK0_RD; int intr = *R_IRQ_MASK0_RD;
int bus = IO_EXTRACT(R_ATA_CTRL_DATA, sel, IDE_DATA_REG); int bus = IO_EXTRACT(R_ATA_CTRL_DATA, sel,
drive->hwif->io_ports[IDE_DATA_OFFSET]);
return intr & (1 << (bus + IO_BITNR(R_IRQ_MASK0_RD, ata_irq0))) ? 1 : 0; return intr & (1 << (bus + IO_BITNR(R_IRQ_MASK0_RD, ata_irq0))) ? 1 : 0;
} }
......
...@@ -542,7 +542,8 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, ...@@ -542,7 +542,8 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
/* packet command */ /* packet command */
spin_lock_irqsave(&ide_lock, flags); spin_lock_irqsave(&ide_lock, flags);
hwif->OUTBSYNC(drive, WIN_PACKETCMD, IDE_COMMAND_REG); hwif->OUTBSYNC(drive, WIN_PACKETCMD,
hwif->io_ports[IDE_COMMAND_OFFSET]);
ndelay(400); ndelay(400);
spin_unlock_irqrestore(&ide_lock, flags); spin_unlock_irqrestore(&ide_lock, flags);
...@@ -992,6 +993,7 @@ static int cdrom_newpc_intr_dummy_cb(struct request *rq) ...@@ -992,6 +993,7 @@ static int cdrom_newpc_intr_dummy_cb(struct request *rq)
static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
{ {
ide_hwif_t *hwif = drive->hwif;
struct cdrom_info *info = drive->driver_data; struct cdrom_info *info = drive->driver_data;
struct request *rq = HWGROUP(drive)->rq; struct request *rq = HWGROUP(drive)->rq;
xfer_func_t *xferfunc; xfer_func_t *xferfunc;
...@@ -1032,9 +1034,9 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) ...@@ -1032,9 +1034,9 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
/* /*
* ok we fall to pio :/ * ok we fall to pio :/
*/ */
ireason = HWIF(drive)->INB(IDE_IREASON_REG) & 0x3; ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]) & 0x3;
lowcyl = HWIF(drive)->INB(IDE_BCOUNTL_REG); lowcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]);
highcyl = HWIF(drive)->INB(IDE_BCOUNTH_REG); highcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]);
len = lowcyl + (256 * highcyl); len = lowcyl + (256 * highcyl);
......
...@@ -498,10 +498,10 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) ...@@ -498,10 +498,10 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
} }
/* Get the number of bytes to transfer */ /* Get the number of bytes to transfer */
bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) | bcount = (hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]) << 8) |
hwif->INB(IDE_BCOUNTL_REG); hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]);
/* on this interrupt */ /* on this interrupt */
ireason = hwif->INB(IDE_IREASON_REG); ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
if (ireason & CD) { if (ireason & CD) {
printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__); 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,6 +562,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
*/ */
static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive) static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive)
{ {
ide_hwif_t *hwif = drive->hwif;
ide_startstop_t startstop; ide_startstop_t startstop;
idefloppy_floppy_t *floppy = drive->driver_data; idefloppy_floppy_t *floppy = drive->driver_data;
u8 ireason; u8 ireason;
...@@ -571,7 +572,7 @@ static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive) ...@@ -571,7 +572,7 @@ static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive)
"initiated yet DRQ isn't asserted\n"); "initiated yet DRQ isn't asserted\n");
return startstop; return startstop;
} }
ireason = drive->hwif->INB(IDE_IREASON_REG); ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
if ((ireason & CD) == 0 || (ireason & IO)) { if ((ireason & CD) == 0 || (ireason & IO)) {
printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while " printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while "
"issuing a packet command\n"); "issuing a packet command\n");
...@@ -608,6 +609,7 @@ static int idefloppy_transfer_pc2(ide_drive_t *drive) ...@@ -608,6 +609,7 @@ static int idefloppy_transfer_pc2(ide_drive_t *drive)
static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive) static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)
{ {
ide_hwif_t *hwif = drive->hwif;
idefloppy_floppy_t *floppy = drive->driver_data; idefloppy_floppy_t *floppy = drive->driver_data;
ide_startstop_t startstop; ide_startstop_t startstop;
u8 ireason; u8 ireason;
...@@ -617,7 +619,7 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive) ...@@ -617,7 +619,7 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)
"initiated yet DRQ isn't asserted\n"); "initiated yet DRQ isn't asserted\n");
return startstop; return startstop;
} }
ireason = drive->hwif->INB(IDE_IREASON_REG); ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
if ((ireason & CD) == 0 || (ireason & IO)) { if ((ireason & CD) == 0 || (ireason & IO)) {
printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) " printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) "
"while issuing a packet command\n"); "while issuing a packet command\n");
...@@ -723,7 +725,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, ...@@ -723,7 +725,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
return ide_started; return ide_started;
} else { } else {
/* Issue the packet command */ /* Issue the packet command */
HWIF(drive)->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG); hwif->OUTB(WIN_PACKETCMD, hwif->io_ports[IDE_COMMAND_OFFSET]);
return (*pkt_xfer_routine) (drive); return (*pkt_xfer_routine) (drive);
} }
} }
......
...@@ -301,39 +301,45 @@ void ide_tf_read(ide_drive_t *drive, ide_task_t *task) ...@@ -301,39 +301,45 @@ void ide_tf_read(ide_drive_t *drive, ide_task_t *task)
struct ide_taskfile *tf = &task->tf; struct ide_taskfile *tf = &task->tf;
if (task->tf_flags & IDE_TFLAG_IN_DATA) { if (task->tf_flags & IDE_TFLAG_IN_DATA) {
u16 data = hwif->INW(IDE_DATA_REG); u16 data = hwif->INW(hwif->io_ports[IDE_DATA_OFFSET]);
tf->data = data & 0xff; tf->data = data & 0xff;
tf->hob_data = (data >> 8) & 0xff; tf->hob_data = (data >> 8) & 0xff;
} }
/* be sure we're looking at the low order bits */ /* be sure we're looking at the low order bits */
hwif->OUTB(drive->ctl & ~0x80, IDE_CONTROL_REG); hwif->OUTB(drive->ctl & ~0x80, hwif->io_ports[IDE_CONTROL_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_NSECT) if (task->tf_flags & IDE_TFLAG_IN_NSECT)
tf->nsect = hwif->INB(IDE_NSECTOR_REG); tf->nsect = hwif->INB(hwif->io_ports[IDE_NSECTOR_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_LBAL) if (task->tf_flags & IDE_TFLAG_IN_LBAL)
tf->lbal = hwif->INB(IDE_SECTOR_REG); tf->lbal = hwif->INB(hwif->io_ports[IDE_SECTOR_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_LBAM) if (task->tf_flags & IDE_TFLAG_IN_LBAM)
tf->lbam = hwif->INB(IDE_LCYL_REG); tf->lbam = hwif->INB(hwif->io_ports[IDE_LCYL_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_LBAH) if (task->tf_flags & IDE_TFLAG_IN_LBAH)
tf->lbah = hwif->INB(IDE_HCYL_REG); tf->lbah = hwif->INB(hwif->io_ports[IDE_HCYL_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_DEVICE) if (task->tf_flags & IDE_TFLAG_IN_DEVICE)
tf->device = hwif->INB(IDE_SELECT_REG); tf->device = hwif->INB(hwif->io_ports[IDE_SELECT_OFFSET]);
if (task->tf_flags & IDE_TFLAG_LBA48) { if (task->tf_flags & IDE_TFLAG_LBA48) {
hwif->OUTB(drive->ctl | 0x80, IDE_CONTROL_REG); hwif->OUTB(drive->ctl | 0x80,
hwif->io_ports[IDE_CONTROL_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE)
tf->hob_feature = hwif->INB(IDE_FEATURE_REG); tf->hob_feature =
hwif->INB(hwif->io_ports[IDE_FEATURE_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT) if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT)
tf->hob_nsect = hwif->INB(IDE_NSECTOR_REG); tf->hob_nsect =
hwif->INB(hwif->io_ports[IDE_NSECTOR_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL) if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL)
tf->hob_lbal = hwif->INB(IDE_SECTOR_REG); tf->hob_lbal =
hwif->INB(hwif->io_ports[IDE_SECTOR_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM) if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM)
tf->hob_lbam = hwif->INB(IDE_LCYL_REG); tf->hob_lbam =
hwif->INB(hwif->io_ports[IDE_LCYL_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH) if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH)
tf->hob_lbah = hwif->INB(IDE_HCYL_REG); tf->hob_lbah =
hwif->INB(hwif->io_ports[IDE_HCYL_OFFSET]);
} }
} }
...@@ -448,7 +454,8 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8 ...@@ -448,7 +454,8 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8
if (err == ABRT_ERR) { if (err == ABRT_ERR) {
if (drive->select.b.lba && if (drive->select.b.lba &&
/* some newer drives don't support WIN_SPECIFY */ /* some newer drives don't support WIN_SPECIFY */
hwif->INB(IDE_COMMAND_REG) == WIN_SPECIFY) hwif->INB(hwif->io_ports[IDE_COMMAND_OFFSET]) ==
WIN_SPECIFY)
return ide_stopped; return ide_stopped;
} else if ((err & BAD_CRC) == BAD_CRC) { } else if ((err & BAD_CRC) == BAD_CRC) {
/* UDMA crc error, just retry the operation */ /* 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,7 +507,8 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u
if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
/* force an abort */ /* force an abort */
hwif->OUTB(WIN_IDLEIMMEDIATE, IDE_COMMAND_REG); hwif->OUTB(WIN_IDLEIMMEDIATE,
hwif->io_ports[IDE_COMMAND_OFFSET]);
if (rq->errors >= ERROR_MAX) { if (rq->errors >= ERROR_MAX) {
ide_kill_rq(drive, rq); ide_kill_rq(drive, rq);
......
...@@ -158,9 +158,12 @@ EXPORT_SYMBOL(default_hwif_mmiops); ...@@ -158,9 +158,12 @@ EXPORT_SYMBOL(default_hwif_mmiops);
void SELECT_DRIVE (ide_drive_t *drive) void SELECT_DRIVE (ide_drive_t *drive)
{ {
if (HWIF(drive)->selectproc) ide_hwif_t *hwif = drive->hwif;
HWIF(drive)->selectproc(drive);
HWIF(drive)->OUTB(drive->select.all, IDE_SELECT_REG); if (hwif->selectproc)
hwif->selectproc(drive);
hwif->OUTB(drive->select.all, hwif->io_ports[IDE_SELECT_OFFSET]);
} }
void SELECT_MASK (ide_drive_t *drive, int mask) void 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,15 +197,18 @@ static void ata_input_data(ide_drive_t *drive, void *buffer, u32 wcount)
if (io_32bit) { if (io_32bit) {
if (io_32bit & 2) { if (io_32bit & 2) {
unsigned long flags; unsigned long flags;
local_irq_save(flags); local_irq_save(flags);
ata_vlb_sync(drive, IDE_NSECTOR_REG); ata_vlb_sync(drive, hwif->io_ports[IDE_NSECTOR_OFFSET]);
hwif->INSL(IDE_DATA_REG, buffer, wcount); hwif->INSL(hwif->io_ports[IDE_DATA_OFFSET], buffer,
wcount);
local_irq_restore(flags); local_irq_restore(flags);
} else } else
hwif->INSL(IDE_DATA_REG, buffer, wcount); hwif->INSL(hwif->io_ports[IDE_DATA_OFFSET], buffer,
} else { wcount);
hwif->INSW(IDE_DATA_REG, buffer, wcount<<1); } else
} hwif->INSW(hwif->io_ports[IDE_DATA_OFFSET], buffer,
wcount << 1);
} }
/* /*
...@@ -216,15 +222,18 @@ static void ata_output_data(ide_drive_t *drive, void *buffer, u32 wcount) ...@@ -216,15 +222,18 @@ static void ata_output_data(ide_drive_t *drive, void *buffer, u32 wcount)
if (io_32bit) { if (io_32bit) {
if (io_32bit & 2) { if (io_32bit & 2) {
unsigned long flags; unsigned long flags;
local_irq_save(flags); local_irq_save(flags);
ata_vlb_sync(drive, IDE_NSECTOR_REG); ata_vlb_sync(drive, hwif->io_ports[IDE_NSECTOR_OFFSET]);
hwif->OUTSL(IDE_DATA_REG, buffer, wcount); hwif->OUTSL(hwif->io_ports[IDE_DATA_OFFSET], buffer,
wcount);
local_irq_restore(flags); local_irq_restore(flags);
} else } else
hwif->OUTSL(IDE_DATA_REG, buffer, wcount); hwif->OUTSL(hwif->io_ports[IDE_DATA_OFFSET], buffer,
} else { wcount);
hwif->OUTSW(IDE_DATA_REG, buffer, wcount<<1); } else
} hwif->OUTSW(hwif->io_ports[IDE_DATA_OFFSET], buffer,
wcount << 1);
} }
/* /*
...@@ -243,13 +252,15 @@ static void atapi_input_bytes(ide_drive_t *drive, void *buffer, u32 bytecount) ...@@ -243,13 +252,15 @@ static void atapi_input_bytes(ide_drive_t *drive, void *buffer, u32 bytecount)
#if defined(CONFIG_ATARI) || defined(CONFIG_Q40) #if defined(CONFIG_ATARI) || defined(CONFIG_Q40)
if (MACH_IS_ATARI || MACH_IS_Q40) { if (MACH_IS_ATARI || MACH_IS_Q40) {
/* Atari has a byte-swapped IDE interface */ /* Atari has a byte-swapped IDE interface */
insw_swapw(IDE_DATA_REG, buffer, bytecount / 2); insw_swapw(hwif->io_ports[IDE_DATA_OFFSET], buffer,
bytecount / 2);
return; return;
} }
#endif /* CONFIG_ATARI || CONFIG_Q40 */ #endif /* CONFIG_ATARI || CONFIG_Q40 */
hwif->ata_input_data(drive, buffer, bytecount / 4); hwif->ata_input_data(drive, buffer, bytecount / 4);
if ((bytecount & 0x03) >= 2) if ((bytecount & 0x03) >= 2)
hwif->INSW(IDE_DATA_REG, ((u8 *)buffer)+(bytecount & ~0x03), 1); hwif->INSW(hwif->io_ports[IDE_DATA_OFFSET],
(u8 *)buffer + (bytecount & ~0x03), 1);
} }
static void atapi_output_bytes(ide_drive_t *drive, void *buffer, u32 bytecount) static 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,13 +271,15 @@ static void atapi_output_bytes(ide_drive_t *drive, void *buffer, u32 bytecount)
#if defined(CONFIG_ATARI) || defined(CONFIG_Q40) #if defined(CONFIG_ATARI) || defined(CONFIG_Q40)
if (MACH_IS_ATARI || MACH_IS_Q40) { if (MACH_IS_ATARI || MACH_IS_Q40) {
/* Atari has a byte-swapped IDE interface */ /* Atari has a byte-swapped IDE interface */
outsw_swapw(IDE_DATA_REG, buffer, bytecount / 2); outsw_swapw(hwif->io_ports[IDE_DATA_OFFSET], buffer,
bytecount / 2);
return; return;
} }
#endif /* CONFIG_ATARI || CONFIG_Q40 */ #endif /* CONFIG_ATARI || CONFIG_Q40 */
hwif->ata_output_data(drive, buffer, bytecount / 4); hwif->ata_output_data(drive, buffer, bytecount / 4);
if ((bytecount & 0x03) >= 2) if ((bytecount & 0x03) >= 2)
hwif->OUTSW(IDE_DATA_REG, ((u8*)buffer)+(bytecount & ~0x03), 1); hwif->OUTSW(hwif->io_ports[IDE_DATA_OFFSET],
(u8 *)buffer + (bytecount & ~0x03), 1);
} }
void default_hwif_transport(ide_hwif_t *hwif) void default_hwif_transport(ide_hwif_t *hwif)
...@@ -429,7 +442,7 @@ int drive_is_ready (ide_drive_t *drive) ...@@ -429,7 +442,7 @@ int drive_is_ready (ide_drive_t *drive)
* an interrupt with another pci card/device. We make no assumptions * an interrupt with another pci card/device. We make no assumptions
* about possible isa-pnp and pci-pnp issues yet. * about possible isa-pnp and pci-pnp issues yet.
*/ */
if (IDE_CONTROL_REG) if (hwif->io_ports[IDE_CONTROL_OFFSET])
stat = ide_read_altstatus(drive); stat = ide_read_altstatus(drive);
else else
/* Note: this may clear a pending IRQ!! */ /* Note: this may clear a pending IRQ!! */
...@@ -631,7 +644,7 @@ int ide_driveid_update(ide_drive_t *drive) ...@@ -631,7 +644,7 @@ int ide_driveid_update(ide_drive_t *drive)
SELECT_MASK(drive, 1); SELECT_MASK(drive, 1);
ide_set_irq(drive, 1); ide_set_irq(drive, 1);
msleep(50); msleep(50);
hwif->OUTB(WIN_IDENTIFY, IDE_COMMAND_REG); hwif->OUTB(WIN_IDENTIFY, hwif->io_ports[IDE_COMMAND_OFFSET]);
timeout = jiffies + WAIT_WORSTCASE; timeout = jiffies + WAIT_WORSTCASE;
do { do {
if (time_after(jiffies, timeout)) { if (time_after(jiffies, timeout)) {
...@@ -718,9 +731,10 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) ...@@ -718,9 +731,10 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
SELECT_MASK(drive, 0); SELECT_MASK(drive, 0);
udelay(1); udelay(1);
ide_set_irq(drive, 0); ide_set_irq(drive, 0);
hwif->OUTB(speed, IDE_NSECTOR_REG); hwif->OUTB(speed, hwif->io_ports[IDE_NSECTOR_OFFSET]);
hwif->OUTB(SETFEATURES_XFER, IDE_FEATURE_REG); hwif->OUTB(SETFEATURES_XFER, hwif->io_ports[IDE_FEATURE_OFFSET]);
hwif->OUTBSYNC(drive, WIN_SETFEATURES, IDE_COMMAND_REG); hwif->OUTBSYNC(drive, WIN_SETFEATURES,
hwif->io_ports[IDE_COMMAND_OFFSET]);
if (drive->quirk_list == 2) if (drive->quirk_list == 2)
ide_set_irq(drive, 1); ide_set_irq(drive, 1);
...@@ -828,7 +842,7 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler, ...@@ -828,7 +842,7 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
spin_lock_irqsave(&ide_lock, flags); spin_lock_irqsave(&ide_lock, flags);
__ide_set_handler(drive, handler, timeout, expiry); __ide_set_handler(drive, handler, timeout, expiry);
hwif->OUTBSYNC(drive, cmd, IDE_COMMAND_REG); hwif->OUTBSYNC(drive, cmd, hwif->io_ports[IDE_COMMAND_OFFSET]);
/* /*
* Drive takes 400nS to respond, we must avoid the IRQ being * Drive takes 400nS to respond, we must avoid the IRQ being
* serviced before that. * serviced before that.
...@@ -1009,7 +1023,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) ...@@ -1009,7 +1023,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
unsigned long flags; unsigned long flags;
ide_hwif_t *hwif; ide_hwif_t *hwif;
ide_hwgroup_t *hwgroup; ide_hwgroup_t *hwgroup;
u8 ctl;
spin_lock_irqsave(&ide_lock, flags); spin_lock_irqsave(&ide_lock, flags);
hwif = HWIF(drive); hwif = HWIF(drive);
hwgroup = HWGROUP(drive); hwgroup = HWGROUP(drive);
...@@ -1023,7 +1038,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) ...@@ -1023,7 +1038,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
pre_reset(drive); pre_reset(drive);
SELECT_DRIVE(drive); SELECT_DRIVE(drive);
udelay (20); udelay (20);
hwif->OUTBSYNC(drive, WIN_SRST, IDE_COMMAND_REG); hwif->OUTBSYNC(drive, WIN_SRST,
hwif->io_ports[IDE_COMMAND_OFFSET]);
ndelay(400); ndelay(400);
hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
hwgroup->polling = 1; hwgroup->polling = 1;
...@@ -1039,7 +1055,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) ...@@ -1039,7 +1055,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
for (unit = 0; unit < MAX_DRIVES; ++unit) for (unit = 0; unit < MAX_DRIVES; ++unit)
pre_reset(&hwif->drives[unit]); pre_reset(&hwif->drives[unit]);
if (!IDE_CONTROL_REG) { if (hwif->io_ports[IDE_CONTROL_OFFSET] == 0) {
spin_unlock_irqrestore(&ide_lock, flags); spin_unlock_irqrestore(&ide_lock, flags);
return ide_stopped; return ide_stopped;
} }
...@@ -1054,16 +1070,14 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) ...@@ -1054,16 +1070,14 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
* recover from reset very quickly, saving us the first 50ms wait time. * recover from reset very quickly, saving us the first 50ms wait time.
*/ */
/* set SRST and nIEN */ /* set SRST and nIEN */
hwif->OUTBSYNC(drive, drive->ctl|6,IDE_CONTROL_REG); hwif->OUTBSYNC(drive, drive->ctl|6, hwif->io_ports[IDE_CONTROL_OFFSET]);
/* more than enough time */ /* more than enough time */
udelay(10); udelay(10);
if (drive->quirk_list == 2) { if (drive->quirk_list == 2)
/* clear SRST and nIEN */ ctl = drive->ctl; /* clear SRST and nIEN */
hwif->OUTBSYNC(drive, drive->ctl, IDE_CONTROL_REG); else
} else { ctl = drive->ctl | 2; /* clear SRST, leave nIEN */
/* clear SRST, leave nIEN */ hwif->OUTBSYNC(drive, ctl, hwif->io_ports[IDE_CONTROL_OFFSET]);
hwif->OUTBSYNC(drive, drive->ctl|2, IDE_CONTROL_REG);
}
/* more than enough time */ /* more than enough time */
udelay(10); udelay(10);
hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
......
...@@ -271,7 +271,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) ...@@ -271,7 +271,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
/* take a deep breath */ /* take a deep breath */
msleep(50); msleep(50);
if (IDE_CONTROL_REG) { if (hwif->io_ports[IDE_CONTROL_OFFSET]) {
a = ide_read_altstatus(drive); a = ide_read_altstatus(drive);
s = ide_read_status(drive); s = ide_read_status(drive);
if ((a ^ s) & ~INDEX_STAT) if ((a ^ s) & ~INDEX_STAT)
...@@ -289,10 +289,10 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) ...@@ -289,10 +289,10 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
*/ */
if ((cmd == WIN_PIDENTIFY)) if ((cmd == WIN_PIDENTIFY))
/* disable dma & overlap */ /* disable dma & overlap */
hwif->OUTB(0, IDE_FEATURE_REG); hwif->OUTB(0, hwif->io_ports[IDE_FEATURE_OFFSET]);
/* ask drive for ID */ /* ask drive for ID */
hwif->OUTB(cmd, IDE_COMMAND_REG); hwif->OUTB(cmd, hwif->io_ports[IDE_COMMAND_OFFSET]);
timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2;
timeout += jiffies; timeout += jiffies;
...@@ -353,7 +353,7 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd) ...@@ -353,7 +353,7 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd)
* interrupts during the identify-phase that * interrupts during the identify-phase that
* the irq handler isn't expecting. * the irq handler isn't expecting.
*/ */
if (IDE_CONTROL_REG) { if (hwif->io_ports[IDE_CONTROL_OFFSET]) {
if (!hwif->irq) { if (!hwif->irq) {
autoprobe = 1; autoprobe = 1;
cookie = probe_irq_on(); cookie = probe_irq_on();
...@@ -445,7 +445,8 @@ static int do_probe (ide_drive_t *drive, u8 cmd) ...@@ -445,7 +445,8 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
msleep(50); msleep(50);
SELECT_DRIVE(drive); SELECT_DRIVE(drive);
msleep(50); msleep(50);
if (hwif->INB(IDE_SELECT_REG) != drive->select.all && !drive->present) { if (hwif->INB(hwif->io_ports[IDE_SELECT_OFFSET]) != drive->select.all &&
!drive->present) {
if (drive->select.b.unit != 0) { if (drive->select.b.unit != 0) {
/* exit with drive0 selected */ /* exit with drive0 selected */
SELECT_DRIVE(&hwif->drives[0]); SELECT_DRIVE(&hwif->drives[0]);
...@@ -477,9 +478,11 @@ static int do_probe (ide_drive_t *drive, u8 cmd) ...@@ -477,9 +478,11 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
printk(KERN_ERR "%s: no response (status = 0x%02x), " printk(KERN_ERR "%s: no response (status = 0x%02x), "
"resetting drive\n", drive->name, stat); "resetting drive\n", drive->name, stat);
msleep(50); msleep(50);
hwif->OUTB(drive->select.all, IDE_SELECT_REG); hwif->OUTB(drive->select.all,
hwif->io_ports[IDE_SELECT_OFFSET]);
msleep(50); msleep(50);
hwif->OUTB(WIN_SRST, IDE_COMMAND_REG); hwif->OUTB(WIN_SRST,
hwif->io_ports[IDE_COMMAND_OFFSET]);
(void)ide_busy_sleep(hwif); (void)ide_busy_sleep(hwif);
rc = try_to_identify(drive, cmd); rc = try_to_identify(drive, cmd);
} }
...@@ -515,7 +518,7 @@ static void enable_nest (ide_drive_t *drive) ...@@ -515,7 +518,7 @@ static void enable_nest (ide_drive_t *drive)
printk("%s: enabling %s -- ", hwif->name, drive->id->model); printk("%s: enabling %s -- ", hwif->name, drive->id->model);
SELECT_DRIVE(drive); SELECT_DRIVE(drive);
msleep(50); msleep(50);
hwif->OUTB(EXABYTE_ENABLE_NEST, IDE_COMMAND_REG); hwif->OUTB(EXABYTE_ENABLE_NEST, hwif->io_ports[IDE_COMMAND_OFFSET]);
if (ide_busy_sleep(hwif)) { if (ide_busy_sleep(hwif)) {
printk(KERN_CONT "failed (timeout)\n"); printk(KERN_CONT "failed (timeout)\n");
......
...@@ -1117,10 +1117,10 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) ...@@ -1117,10 +1117,10 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive)
return ide_do_reset(drive); return ide_do_reset(drive);
} }
/* Get the number of bytes to transfer on this interrupt. */ /* Get the number of bytes to transfer on this interrupt. */
bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) | bcount = (hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]) << 8) |
hwif->INB(IDE_BCOUNTL_REG); hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]);
ireason = hwif->INB(IDE_IREASON_REG); ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
if (ireason & CD) { if (ireason & CD) {
printk(KERN_ERR "ide-tape: CoD != 0 in %s\n", __func__); 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,12 +1224,12 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive)
"yet DRQ isn't asserted\n"); "yet DRQ isn't asserted\n");
return startstop; return startstop;
} }
ireason = hwif->INB(IDE_IREASON_REG); ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) { while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) {
printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while issuing " printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while issuing "
"a packet command, retrying\n"); "a packet command, retrying\n");
udelay(100); udelay(100);
ireason = hwif->INB(IDE_IREASON_REG); ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
if (retries == 0) { if (retries == 0) {
printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while " printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while "
"issuing a packet command, ignoring\n"); "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,7 +1323,7 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, idetape_pc_t *pc)
IDETAPE_WAIT_CMD, NULL); IDETAPE_WAIT_CMD, NULL);
return ide_started; return ide_started;
} else { } else {
hwif->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG); hwif->OUTB(WIN_PACKETCMD, hwif->io_ports[IDE_COMMAND_OFFSET]);
return idetape_transfer_pc(drive); return idetape_transfer_pc(drive);
} }
} }
......
...@@ -59,32 +59,34 @@ void ide_tf_load(ide_drive_t *drive, ide_task_t *task) ...@@ -59,32 +59,34 @@ void ide_tf_load(ide_drive_t *drive, ide_task_t *task)
SELECT_MASK(drive, 0); SELECT_MASK(drive, 0);
if (task->tf_flags & IDE_TFLAG_OUT_DATA) if (task->tf_flags & IDE_TFLAG_OUT_DATA)
hwif->OUTW((tf->hob_data << 8) | tf->data, IDE_DATA_REG); hwif->OUTW((tf->hob_data << 8) | tf->data,
hwif->io_ports[IDE_DATA_OFFSET]);