]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/pci/pdc202xx_old.c
pdc202xx_old: fix PIO mode setup
[linux-2.6-omap-h63xx.git] / drivers / ide / pci / pdc202xx_old.c
index 143239c093d5a5b6da40e5d48b8cda549d358692..e76c1d91533f41fb3a922c92009beea976ccbdc7 100644 (file)
@@ -2,6 +2,7 @@
  *  linux/drivers/ide/pci/pdc202xx_old.c       Version 0.36    Sept 11, 2002
  *
  *  Copyright (C) 1998-2002            Andre Hedrick <andre@linux-ide.org>
+ *  Copyright (C) 2006-2007            MontaVista Software, Inc.
  *
  *  Promise Ultra33 cards with BIOS v1.20 through 1.28 will need this
  *  compiled into the kernel if you have more than one card installed.
@@ -123,26 +124,6 @@ static u8 pdc202xx_ratemask (ide_drive_t *drive)
        return mode;
 }
 
-static int check_in_drive_lists (ide_drive_t *drive, const char **list)
-{
-       struct hd_driveid *id = drive->id;
-
-       if (pdc_quirk_drives == list) {
-               while (*list) {
-                       if (strstr(id->model, *list++)) {
-                               return 2;
-                       }
-               }
-       } else {
-               while (*list) {
-                       if (!strcmp(*list++,id->model)) {
-                               return 1;
-                       }
-               }
-       }
-       return 0;
-}
-
 static int pdc202xx_tune_chipset (ide_drive_t *drive, u8 xferspeed)
 {
        ide_hwif_t *hwif        = HWIF(drive);
@@ -236,21 +217,10 @@ static int pdc202xx_tune_chipset (ide_drive_t *drive, u8 xferspeed)
 }
 
 
-/*   0    1    2    3    4    5    6   7   8
- * 960, 480, 390, 300, 240, 180, 120, 90, 60
- *           180, 150, 120,  90,  60
- * DMA_Speed
- * 180, 120,  90,  90,  90,  60,  30
- *  11,   5,   4,   3,   2,   1,   0
- */
-static void config_chipset_for_pio (ide_drive_t *drive, u8 pio)
+static void pdc202xx_tune_drive(ide_drive_t *drive, u8 pio)
 {
-       u8 speed = 0;
-
-       if (pio == 5) pio = 4;
-       speed = XFER_PIO_0 + ide_get_best_pio_mode(drive, 255, pio, NULL);
-        
-       pdc202xx_tune_chipset(drive, speed);
+       pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
+       pdc202xx_tune_chipset(drive, XFER_PIO_0 + pio);
 }
 
 static u8 pdc202xx_old_cable_detect (ide_hwif_t *hwif)
@@ -368,7 +338,7 @@ static int pdc202xx_config_drive_xfer_rate (ide_drive_t *drive)
 
        } else if ((id->capability & 8) || (id->field_valid & 2)) {
 fast_ata_pio:
-               hwif->tuneproc(drive, 5);
+               pdc202xx_tune_drive(drive, 255);
                return hwif->ide_dma_off_quietly(drive);
        }
        /* IORDY not supported */
@@ -377,7 +347,12 @@ fast_ata_pio:
 
 static int pdc202xx_quirkproc (ide_drive_t *drive)
 {
-       return ((int) check_in_drive_lists(drive, pdc_quirk_drives));
+       const char **list, *model = drive->id->model;
+
+       for (list = pdc_quirk_drives; *list != NULL; list++)
+               if (strstr(model, *list) != NULL)
+                       return 2;
+       return 0;
 }
 
 static void pdc202xx_old_ide_dma_start(ide_drive_t *drive)
@@ -478,7 +453,7 @@ static void pdc202xx_reset (ide_drive_t *drive)
        
        pdc202xx_reset_host(hwif);
        pdc202xx_reset_host(mate);
-       hwif->tuneproc(drive, 5);
+       pdc202xx_tune_drive(drive, 255);
 }
 
 static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev,
@@ -505,7 +480,7 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif)
                hwif->rqsize = 256;
 
        hwif->autodma = 0;
-       hwif->tuneproc  = &config_chipset_for_pio;
+       hwif->tuneproc  = &pdc202xx_tune_drive;
        hwif->quirkproc = &pdc202xx_quirkproc;
 
        if (hwif->pci_dev->device != PCI_DEVICE_ID_PROMISE_20246)