]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide-iops.c
ide: add ide_dev_is_sata() helper (take 2)
[linux-2.6-omap-h63xx.git] / drivers / ide / ide-iops.c
index 1ee53a551c3adf6fe6397aea0945c5f1f4cbff20..646a54e233d361451bfab4982a1da96956be82a2 100644 (file)
@@ -565,57 +565,98 @@ int ide_wait_stat (ide_startstop_t *startstop, ide_drive_t *drive, u8 good, u8 b
 
 EXPORT_SYMBOL(ide_wait_stat);
 
+/**
+ *     ide_in_drive_list       -       look for drive in black/white list
+ *     @id: drive identifier
+ *     @drive_table: list to inspect
+ *
+ *     Look for a drive in the blacklist and the whitelist tables
+ *     Returns 1 if the drive is found in the table.
+ */
+
+int ide_in_drive_list(struct hd_driveid *id, const struct drive_list_entry *drive_table)
+{
+       for ( ; drive_table->id_model; drive_table++)
+               if ((!strcmp(drive_table->id_model, id->model)) &&
+                   (!drive_table->id_firmware ||
+                    strstr(id->fw_rev, drive_table->id_firmware)))
+                       return 1;
+       return 0;
+}
+
+EXPORT_SYMBOL_GPL(ide_in_drive_list);
+
+/*
+ * Early UDMA66 devices don't set bit14 to 1, only bit13 is valid.
+ * We list them here and depend on the device side cable detection for them.
+ */
+static const struct drive_list_entry ivb_list[] = {
+       { "QUANTUM FIREBALLlct10 05"    , "A03.0900"    },
+       { NULL                          , NULL          }
+};
+
 /*
  *  All hosts that use the 80c ribbon must use!
  *  The name is derived from upper byte of word 93 and the 80c ribbon.
  */
 u8 eighty_ninty_three (ide_drive_t *drive)
 {
-       if(HWIF(drive)->udma_four == 0)
-               return 0;
+       ide_hwif_t *hwif = drive->hwif;
+       struct hd_driveid *id = drive->id;
+       int ivb = ide_in_drive_list(id, ivb_list);
 
-       /* Check for SATA but only if we are ATA5 or higher */
-       if (drive->id->hw_config == 0 && (drive->id->major_rev_num & 0x7FE0))
+       if (hwif->cbl == ATA_CBL_PATA40_SHORT)
                return 1;
-       if (!(drive->id->hw_config & 0x6000))
-               return 0;
-#ifndef CONFIG_IDEDMA_IVB
-       if(!(drive->id->hw_config & 0x4000))
-               return 0;
-#endif /* CONFIG_IDEDMA_IVB */
+
+       if (ivb)
+               printk(KERN_DEBUG "%s: skipping word 93 validity check\n",
+                                 drive->name);
+
+       if (hwif->cbl != ATA_CBL_PATA80 && !ivb)
+               goto no_80w;
+
+       if (ide_dev_is_sata(id))
+               return 1;
+
        /*
         * FIXME:
         * - change master/slave IDENTIFY order
-        * - force bit13 (80c cable present) check
+        * - force bit13 (80c cable present) check also for !ivb devices
         *   (unless the slave device is pre-ATA3)
         */
-       return 1;
-}
+#ifndef CONFIG_IDEDMA_IVB
+       if ((id->hw_config & 0x4000) || (ivb && (id->hw_config & 0x2000)))
+#else
+       if (id->hw_config & 0x6000)
+#endif
+               return 1;
 
-EXPORT_SYMBOL(eighty_ninty_three);
+no_80w:
+       if (drive->udma33_warned == 1)
+               return 0;
+
+       printk(KERN_WARNING "%s: %s side 80-wire cable detection failed, "
+                           "limiting max speed to UDMA33\n",
+                           drive->name,
+                           hwif->cbl == ATA_CBL_PATA80 ? "drive" : "host");
+
+       drive->udma33_warned = 1;
+
+       return 0;
+}
 
 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)) {
-#ifndef CONFIG_IDEDMA_IVB
-               if ((drive->id->hw_config & 0x6000) == 0) {
-#else /* !CONFIG_IDEDMA_IVB */
-               if (((drive->id->hw_config & 0x2000) == 0) ||
-                   ((drive->id->hw_config & 0x4000) == 0)) {
-#endif /* CONFIG_IDEDMA_IVB */
-                       printk("%s: Speed warnings UDMA 3/4/5 is not "
-                               "functional.\n", drive->name);
-                       return 1;
-               }
-               if (!HWIF(drive)->udma_four) {
-                       printk("%s: Speed warnings UDMA 3/4/5 is not "
-                               "functional.\n",
-                               HWIF(drive)->name);
+               if (eighty_ninty_three(drive) == 0) {
+                       printk(KERN_WARNING "%s: UDMA speeds >UDMA33 cannot "
+                                           "be set\n", drive->name);
                        return 1;
                }
        }
+
        return 0;
 }
 
@@ -788,7 +829,7 @@ int ide_config_drive_speed (ide_drive_t *drive, u8 speed)
                hwif->OUTB(drive->ctl | 2, IDE_CONTROL_REG);
        hwif->OUTB(speed, IDE_NSECTOR_REG);
        hwif->OUTB(SETFEATURES_XFER, IDE_FEATURE_REG);
-       hwif->OUTB(WIN_SETFEATURES, IDE_COMMAND_REG);
+       hwif->OUTBSYNC(drive, WIN_SETFEATURES, IDE_COMMAND_REG);
        if ((IDE_CONTROL_REG) && (drive->quirk_list == 2))
                hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
        udelay(1);
@@ -815,7 +856,7 @@ int ide_config_drive_speed (ide_drive_t *drive, u8 speed)
         */
        for (i = 0; i < 10; i++) {
                udelay(1);
-               if (OK_STAT((stat = hwif->INB(IDE_STATUS_REG)), DRIVE_READY, BUSY_STAT|DRQ_STAT|ERR_STAT)) {
+               if (OK_STAT((stat = hwif->INB(IDE_STATUS_REG)), drive->ready_stat, BUSY_STAT|DRQ_STAT|ERR_STAT)) {
                        error = 0;
                        break;
                }
@@ -889,6 +930,7 @@ static void __ide_set_handler (ide_drive_t *drive, ide_handler_t *handler,
        hwgroup->handler        = handler;
        hwgroup->expiry         = expiry;
        hwgroup->timer.expires  = jiffies + timeout;
+       hwgroup->req_gen_timer = hwgroup->req_gen;
        add_timer(&hwgroup->timer);
 }
 
@@ -929,6 +971,7 @@ void ide_execute_command(ide_drive_t *drive, task_ioreg_t cmd, ide_handler_t *ha
        hwgroup->handler        = handler;
        hwgroup->expiry         = expiry;
        hwgroup->timer.expires  = jiffies + timeout;
+       hwgroup->req_gen_timer = hwgroup->req_gen;
        add_timer(&hwgroup->timer);
        hwif->OUTBSYNC(drive, cmd, IDE_COMMAND_REG);
        /* Drive takes 400nS to respond, we must avoid the IRQ being