ide: switch ide_cmd_ioctl() to use REQ_TYPE_ATA_TASKFILE requests
[pandora-kernel.git] / drivers / ide / ide-iops.c
index e17a9ee..e2a7e95 100644 (file)
@@ -158,14 +158,6 @@ void default_hwif_mmiops (ide_hwif_t *hwif)
 
 EXPORT_SYMBOL(default_hwif_mmiops);
 
-u32 ide_read_24 (ide_drive_t *drive)
-{
-       u8 hcyl = HWIF(drive)->INB(IDE_HCYL_REG);
-       u8 lcyl = HWIF(drive)->INB(IDE_LCYL_REG);
-       u8 sect = HWIF(drive)->INB(IDE_SECTOR_REG);
-       return (hcyl<<16)|(lcyl<<8)|sect;
-}
-
 void SELECT_DRIVE (ide_drive_t *drive)
 {
        if (HWIF(drive)->selectproc)
@@ -175,26 +167,12 @@ void SELECT_DRIVE (ide_drive_t *drive)
 
 EXPORT_SYMBOL(SELECT_DRIVE);
 
-void SELECT_INTERRUPT (ide_drive_t *drive)
-{
-       if (HWIF(drive)->intrproc)
-               HWIF(drive)->intrproc(drive);
-       else
-               HWIF(drive)->OUTB(drive->ctl|2, IDE_CONTROL_REG);
-}
-
 void SELECT_MASK (ide_drive_t *drive, int mask)
 {
        if (HWIF(drive)->maskproc)
                HWIF(drive)->maskproc(drive, mask);
 }
 
-void QUIRK_LIST (ide_drive_t *drive)
-{
-       if (HWIF(drive)->quirkproc)
-               drive->quirk_list = HWIF(drive)->quirkproc(drive);
-}
-
 /*
  * Some localbus EIDE interfaces require a special access sequence
  * when using 32-bit I/O instructions to transfer data.  We call this
@@ -303,9 +281,6 @@ void default_hwif_transport(ide_hwif_t *hwif)
        hwif->atapi_output_bytes        = atapi_output_bytes;
 }
 
-/*
- * Beginning of Taskfile OPCODE Library and feature sets.
- */
 void ide_fix_driveid (struct hd_driveid *id)
 {
 #ifndef __LITTLE_ENDIAN
@@ -452,7 +427,6 @@ int drive_is_ready (ide_drive_t *drive)
        udelay(1);
 #endif
 
-#ifdef CONFIG_IDEPCI_SHARE_IRQ
        /*
         * We do a passive status test under shared PCI interrupts on
         * cards that truly share the ATA side interrupt, but may also share
@@ -462,7 +436,6 @@ int drive_is_ready (ide_drive_t *drive)
        if (IDE_CONTROL_REG)
                stat = hwif->INB(IDE_ALTSTATUS_REG);
        else
-#endif /* CONFIG_IDEPCI_SHARE_IRQ */
                /* Note: this may clear a pending IRQ!! */
                stat = hwif->INB(IDE_STATUS_REG);
 
@@ -592,6 +565,9 @@ EXPORT_SYMBOL_GPL(ide_in_drive_list);
 static const struct drive_list_entry ivb_list[] = {
        { "QUANTUM FIREBALLlct10 05"    , "A03.0900"    },
        { "TSSTcorp CDDVDW SH-S202J"    , "SB00"        },
+       { "TSSTcorp CDDVDW SH-S202J"    , "SB01"        },
+       { "TSSTcorp CDDVDW SH-S202N"    , "SB00"        },
+       { "TSSTcorp CDDVDW SH-S202N"    , "SB01"        },
        { NULL                          , NULL          }
 };
 
@@ -612,12 +588,12 @@ u8 eighty_ninty_three (ide_drive_t *drive)
                printk(KERN_DEBUG "%s: skipping word 93 validity check\n",
                                  drive->name);
 
+       if (ide_dev_is_sata(id) && !ivb)
+               return 1;
+
        if (hwif->cbl != ATA_CBL_PATA80 && !ivb)
                goto no_80w;
 
-       if (ide_dev_is_sata(id))
-               return 1;
-
        /*
         * FIXME:
         * - force bit13 (80c cable present) check also for !ivb devices
@@ -642,9 +618,9 @@ no_80w:
 
 int ide_ata66_check (ide_drive_t *drive, ide_task_t *args)
 {
-       if ((args->tfRegister[IDE_COMMAND_OFFSET] == WIN_SETFEATURES) &&
-           (args->tfRegister[IDE_SECTOR_OFFSET] > XFER_UDMA_2) &&
-           (args->tfRegister[IDE_FEATURE_OFFSET] == SETFEATURES_XFER)) {
+       if (args->tf.command == WIN_SETFEATURES &&
+           args->tf.nsect > XFER_UDMA_2 &&
+           args->tf.feature == SETFEATURES_XFER) {
                if (eighty_ninty_three(drive) == 0) {
                        printk(KERN_WARNING "%s: UDMA speeds >UDMA33 cannot "
                                            "be set\n", drive->name);
@@ -662,9 +638,9 @@ int ide_ata66_check (ide_drive_t *drive, ide_task_t *args)
  */
 int set_transfer (ide_drive_t *drive, ide_task_t *args)
 {
-       if ((args->tfRegister[IDE_COMMAND_OFFSET] == WIN_SETFEATURES) &&
-           (args->tfRegister[IDE_SECTOR_OFFSET] >= XFER_SW_DMA_0) &&
-           (args->tfRegister[IDE_FEATURE_OFFSET] == SETFEATURES_XFER) &&
+       if (args->tf.command == WIN_SETFEATURES &&
+           args->tf.nsect >= XFER_SW_DMA_0 &&
+           args->tf.feature == SETFEATURES_XFER &&
            (drive->id->dma_ultra ||
             drive->id->dma_mword ||
             drive->id->dma_1word))
@@ -712,8 +688,7 @@ int ide_driveid_update(ide_drive_t *drive)
         */
 
        SELECT_MASK(drive, 1);
-       if (IDE_CONTROL_REG)
-               hwif->OUTB(drive->ctl,IDE_CONTROL_REG);
+       ide_set_irq(drive, 1);
        msleep(50);
        hwif->OUTB(WIN_IDENTIFY, IDE_COMMAND_REG);
        timeout = jiffies + WAIT_WORSTCASE;
@@ -748,6 +723,9 @@ int ide_driveid_update(ide_drive_t *drive)
                drive->id->dma_1word = id->dma_1word;
                /* anything more ? */
                kfree(id);
+
+               if (drive->using_dma && ide_id_dma_bug(drive))
+                       ide_dma_off(drive);
        }
 
        return 1;
@@ -756,17 +734,21 @@ int ide_driveid_update(ide_drive_t *drive)
 int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
 {
        ide_hwif_t *hwif = drive->hwif;
-       int error;
+       int error = 0;
        u8 stat;
 
 //     while (HWGROUP(drive)->busy)
 //             msleep(50);
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
-       if (hwif->ide_dma_on)   /* check if host supports DMA */
-               hwif->dma_host_off(drive);
+       if (hwif->dma_host_set) /* check if host supports DMA */
+               hwif->dma_host_set(drive, 0);
 #endif
 
+       /* Skip setting PIO flow-control modes on pre-EIDE drives */
+       if ((speed & 0xf8) == XFER_PIO_0 && !(drive->id->capability & 0x08))
+               goto skip;
+
        /*
         * Don't use ide_wait_cmd here - it will
         * attempt to set_geometry and recalibrate,
@@ -789,13 +771,12 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
        SELECT_DRIVE(drive);
        SELECT_MASK(drive, 0);
        udelay(1);
-       if (IDE_CONTROL_REG)
-               hwif->OUTB(drive->ctl | 2, IDE_CONTROL_REG);
+       ide_set_irq(drive, 0);
        hwif->OUTB(speed, IDE_NSECTOR_REG);
        hwif->OUTB(SETFEATURES_XFER, IDE_FEATURE_REG);
        hwif->OUTBSYNC(drive, WIN_SETFEATURES, IDE_COMMAND_REG);
-       if ((IDE_CONTROL_REG) && (drive->quirk_list == 2))
-               hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
+       if (drive->quirk_list == 2)
+               ide_set_irq(drive, 1);
 
        error = __ide_wait_stat(drive, drive->ready_stat,
                                BUSY_STAT|DRQ_STAT|ERR_STAT,
@@ -814,11 +795,13 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
        drive->id->dma_mword &= ~0x0F00;
        drive->id->dma_1word &= ~0x0F00;
 
+ skip:
 #ifdef CONFIG_BLK_DEV_IDEDMA
-       if (speed >= XFER_SW_DMA_0)
-               hwif->dma_host_on(drive);
-       else if (hwif->ide_dma_on)      /* check if host supports DMA */
-               hwif->dma_off_quietly(drive);
+       if ((speed >= XFER_SW_DMA_0 || (hwif->host_flags & IDE_HFLAG_VDMA)) &&
+           drive->using_dma)
+               hwif->dma_host_set(drive, 1);
+       else if (hwif->dma_host_set)    /* check if host supports DMA */
+               ide_dma_off_quietly(drive);
 #endif
 
        switch(speed) {
@@ -894,8 +877,9 @@ EXPORT_SYMBOL(ide_set_handler);
  *     handler and IRQ setup do not race. All IDE command kick off
  *     should go via this function or do equivalent locking.
  */
-void ide_execute_command(ide_drive_t *drive, task_ioreg_t cmd, ide_handler_t *handler, unsigned timeout, ide_expiry_t *expiry)
+
+void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
+                        unsigned timeout, ide_expiry_t *expiry)
 {
        unsigned long flags;
        ide_hwgroup_t *hwgroup = HWGROUP(drive);
@@ -1027,10 +1011,10 @@ static void check_dma_crc(ide_drive_t *drive)
 {
 #ifdef CONFIG_BLK_DEV_IDEDMA
        if (drive->crc_count) {
-               drive->hwif->dma_off_quietly(drive);
+               ide_dma_off_quietly(drive);
                ide_set_xfer_rate(drive, ide_auto_reduce_xfer(drive));
                if (drive->current_speed >= XFER_SW_DMA_0)
-                       (void) HWIF(drive)->ide_dma_on(drive);
+                       ide_dma_on(drive);
        } else
                ide_dma_off(drive);
 #endif
@@ -1043,8 +1027,7 @@ static void ide_disk_pre_reset(ide_drive_t *drive)
        drive->special.all = 0;
        drive->special.b.set_geometry = legacy;
        drive->special.b.recalibrate  = legacy;
-       if (OK_TO_RESET_CONTROLLER)
-               drive->mult_count = 0;
+       drive->mult_count = 0;
        if (!drive->keep_settings && !drive->using_dma)
                drive->mult_req = 0;
        if (drive->mult_req != drive->mult_count)
@@ -1129,7 +1112,6 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
        for (unit = 0; unit < MAX_DRIVES; ++unit)
                pre_reset(&hwif->drives[unit]);
 
-#if OK_TO_RESET_CONTROLLER
        if (!IDE_CONTROL_REG) {
                spin_unlock_irqrestore(&ide_lock, flags);
                return ide_stopped;
@@ -1166,11 +1148,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
         * state when the disks are reset this way. At least, the Winbond
         * 553 documentation says that
         */
-       if (hwif->resetproc != NULL) {
+       if (hwif->resetproc)
                hwif->resetproc(drive);
-       }
-       
-#endif /* OK_TO_RESET_CONTROLLER */
 
        spin_unlock_irqrestore(&ide_lock, flags);
        return ide_started;