ide: add ->exec_command method
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Wed, 23 Jul 2008 17:55:51 +0000 (19:55 +0200)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Wed, 23 Jul 2008 17:55:51 +0000 (19:55 +0200)
Add ->exec_command method for writing ATA Command register
and use it instead of ->OUTBSYNC.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
drivers/ide/ide-io.c
drivers/ide/ide-iops.c
drivers/ide/ide-probe.c
drivers/ide/ide-taskfile.c
drivers/ide/pci/scc_pata.c
drivers/ide/ppc/pmac.c
drivers/scsi/ide-scsi.c
include/linux/ide.h

index 661b75a89d4dc4d2227a09d3ce69819a6132e42e..ca0c04a919cba7714bcd25680778a2a7355a9ffb 100644 (file)
@@ -437,8 +437,7 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u
 
        if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
                /* force an abort */
-               hwif->OUTBSYNC(hwif, WIN_IDLEIMMEDIATE,
-                              hwif->io_ports.command_addr);
+               hwif->exec_command(hwif, WIN_IDLEIMMEDIATE);
 
        if (rq->errors >= ERROR_MAX) {
                ide_kill_rq(drive, rq);
index 17cad6c39ee30451ce366c5774f1cb3e7c309a98..d8db25581909340a0ae00afa6537096e4f4380ad 100644 (file)
@@ -103,6 +103,14 @@ void SELECT_MASK(ide_drive_t *drive, int mask)
                port_ops->maskproc(drive, mask);
 }
 
+static void ide_exec_command(ide_hwif_t *hwif, u8 cmd)
+{
+       if (hwif->host_flags & IDE_HFLAG_MMIO)
+               writeb(cmd, (void __iomem *)hwif->io_ports.command_addr);
+       else
+               outb(cmd, hwif->io_ports.command_addr);
+}
+
 static u8 ide_read_sff_dma_status(ide_hwif_t *hwif)
 {
        if (hwif->host_flags & IDE_HFLAG_MMIO)
@@ -331,6 +339,7 @@ static void ata_output_data(ide_drive_t *drive, struct request *rq,
 
 void default_hwif_transport(ide_hwif_t *hwif)
 {
+       hwif->exec_command        = ide_exec_command;
        hwif->read_sff_dma_status = ide_read_sff_dma_status;
 
        hwif->tf_load     = ide_tf_load;
@@ -696,7 +705,7 @@ int ide_driveid_update(ide_drive_t *drive)
        SELECT_MASK(drive, 1);
        ide_set_irq(drive, 0);
        msleep(50);
-       hwif->OUTBSYNC(hwif, WIN_IDENTIFY, hwif->io_ports.command_addr);
+       hwif->exec_command(hwif, WIN_IDENTIFY);
        timeout = jiffies + WAIT_WORSTCASE;
        do {
                if (time_after(jiffies, timeout)) {
@@ -783,7 +792,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
        ide_set_irq(drive, 0);
        hwif->OUTB(speed, io_ports->nsect_addr);
        hwif->OUTB(SETFEATURES_XFER, io_ports->feature_addr);
-       hwif->OUTBSYNC(hwif, WIN_SETFEATURES, io_ports->command_addr);
+       hwif->exec_command(hwif, WIN_SETFEATURES);
        if (drive->quirk_list == 2)
                ide_set_irq(drive, 1);
 
@@ -891,7 +900,7 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
 
        spin_lock_irqsave(&ide_lock, flags);
        __ide_set_handler(drive, handler, timeout, expiry);
-       hwif->OUTBSYNC(hwif, cmd, hwif->io_ports.command_addr);
+       hwif->exec_command(hwif, cmd);
        /*
         * Drive takes 400nS to respond, we must avoid the IRQ being
         * serviced before that.
@@ -909,7 +918,7 @@ void ide_execute_pkt_cmd(ide_drive_t *drive)
        unsigned long flags;
 
        spin_lock_irqsave(&ide_lock, flags);
-       hwif->OUTBSYNC(hwif, WIN_PACKETCMD, hwif->io_ports.command_addr);
+       hwif->exec_command(hwif, WIN_PACKETCMD);
        ndelay(400);
        spin_unlock_irqrestore(&ide_lock, flags);
 }
@@ -1116,7 +1125,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
                pre_reset(drive);
                SELECT_DRIVE(drive);
                udelay (20);
-               hwif->OUTBSYNC(hwif, WIN_SRST, io_ports->command_addr);
+               hwif->exec_command(hwif, WIN_SRST);
                ndelay(400);
                hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
                hwgroup->polling = 1;
index ec5f58c6f19a4bce8b2cca76c34d13dc0f40a8af..d1e834a1c5cd41a04db94e953d9484f3378452a8 100644 (file)
@@ -295,7 +295,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
                hwif->OUTB(0, io_ports->feature_addr);
 
        /* ask drive for ID */
-       hwif->OUTBSYNC(hwif, cmd, hwif->io_ports.command_addr);
+       hwif->exec_command(hwif, cmd);
 
        timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2;
        timeout += jiffies;
@@ -482,7 +482,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
                        msleep(50);
                        SELECT_DRIVE(drive);
                        msleep(50);
-                       hwif->OUTBSYNC(hwif, WIN_SRST, io_ports->command_addr);
+                       hwif->exec_command(hwif, WIN_SRST);
                        (void)ide_busy_sleep(hwif);
                        rc = try_to_identify(drive, cmd);
                }
@@ -518,7 +518,7 @@ static void enable_nest (ide_drive_t *drive)
        printk("%s: enabling %s -- ", hwif->name, drive->id->model);
        SELECT_DRIVE(drive);
        msleep(50);
-       hwif->OUTBSYNC(hwif, EXABYTE_ENABLE_NEST, hwif->io_ports.command_addr);
+       hwif->exec_command(hwif, EXABYTE_ENABLE_NEST);
 
        if (ide_busy_sleep(hwif)) {
                printk(KERN_CONT "failed (timeout)\n");
index 1fbdb746dc88a761a7edf9a66d49e7f68e66b179..c56be289417ed81ee8adbbe659114bc850387454 100644 (file)
@@ -88,7 +88,7 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task)
        switch (task->data_phase) {
        case TASKFILE_MULTI_OUT:
        case TASKFILE_OUT:
-               hwif->OUTBSYNC(hwif, tf->command, hwif->io_ports.command_addr);
+               hwif->exec_command(hwif, tf->command);
                ndelay(400);    /* FIXME */
                return pre_task_out_intr(drive, task->rq);
        case TASKFILE_MULTI_IN:
index fc163a7772a74f592fc83af3c3c9372e76af796f..d140dfd565a430037955839256e48d0c3d4ceb9e 100644 (file)
@@ -126,6 +126,14 @@ static u8 scc_ide_inb(unsigned long port)
        return (u8)data;
 }
 
+static void scc_exec_command(ide_hwif_t *hwif, u8 cmd)
+{
+       out_be32((void *)hwif->io_ports.command_addr, cmd);
+       eieio();
+       in_be32((void *)(hwif->dma_base + 0x01c));
+       eieio();
+}
+
 static u8 scc_read_sff_dma_status(ide_hwif_t *hwif)
 {
        return (u8)in_be32((void *)(hwif->dma_base + 4));
@@ -779,6 +787,7 @@ static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif)
 
        ide_set_hwifdata(hwif, ports);
 
+       hwif->exec_command        = scc_exec_command;
        hwif->read_sff_dma_status = scc_read_sff_dma_status;
 
        hwif->tf_load = scc_tf_load;
index e68e33bb2c35b2972ffec407c7514ac6cb8ecff6..7c3a84f8fbed71fc51de9fff5b31b7aa4a3a98a5 100644 (file)
@@ -495,6 +495,13 @@ static void pmac_outbsync(ide_hwif_t *hwif, u8 value, unsigned long port)
                                     + IDE_TIMING_CONFIG));
 }
 
+static void pmac_exec_command(ide_hwif_t *hwif, u8 cmd)
+{
+       writeb(cmd, (void __iomem *)hwif->io_ports.command_addr);
+       (void)readl((void __iomem *)(hwif->io_ports.data_addr
+                                    + IDE_TIMING_CONFIG));
+}
+
 /*
  * Old tuning functions (called on hdparm -p), sets up drive PIO timings
  */
@@ -1092,6 +1099,8 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
        if (hwif == NULL)
                return -ENOENT;
 
+       hwif->exec_command = pmac_exec_command;
+
        /* Setup MMIO ops */
        default_hwif_mmiops(hwif);
                hwif->OUTBSYNC = pmac_outbsync;
index f843c1383a4b599480fdd53c9887a1263132e294..80123890ced0d0181dce93f93b6a5260fad26dea 100644 (file)
@@ -248,8 +248,7 @@ idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
 
        if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
                /* force an abort */
-               hwif->OUTBSYNC(hwif, WIN_IDLEIMMEDIATE,
-                              hwif->io_ports.command_addr);
+               hwif->exec_command(hwif, WIN_IDLEIMMEDIATE);
 
        rq->errors++;
 
index a179a7f6e444deda683418f22c7f5ee134139987..d77c1994d0e3fcf47f4feb3c791d353efa0f24d3 100644 (file)
@@ -489,7 +489,8 @@ typedef struct hwif_s {
        const struct ide_port_ops       *port_ops;
        const struct ide_dma_ops        *dma_ops;
 
-       u8 (*read_sff_dma_status)(struct hwif_s *);
+       void    (*exec_command)(struct hwif_s *, u8);
+       u8      (*read_sff_dma_status)(struct hwif_s *);
 
        void (*tf_load)(ide_drive_t *, struct ide_task_s *);
        void (*tf_read)(ide_drive_t *, struct ide_task_s *);