]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/pci/siimage.c
ide: add ide_use_fast_pio() helper (v3)
[linux-2.6-omap-h63xx.git] / drivers / ide / pci / siimage.c
index 20b392948f366ac9a5767f2226eb5f2d44f7be52..367733c8c1de1b2c102762164725f60ef7ebad29 100644 (file)
@@ -1,8 +1,9 @@
 /*
- * linux/drivers/ide/pci/siimage.c             Version 1.07    Nov 30, 2003
+ * linux/drivers/ide/pci/siimage.c             Version 1.11    Jan 27, 2007
  *
  * Copyright (C) 2001-2002     Andre Hedrick <andre@linux-ide.org>
  * Copyright (C) 2003          Red Hat <alan@redhat.com>
+ * Copyright (C) 2007          MontaVista Software, Inc.
  *
  *  May be copied or modified under the terms of the GNU General Public License
  *
@@ -205,41 +206,39 @@ static void siimage_tuneproc (ide_drive_t *drive, byte mode_wanted)
        unsigned long tfaddr    = siimage_selreg(hwif, 0x02);
        
        /* cheat for now and use the docs */
-       switch(mode_wanted) {
-               case 4: 
-                       speedp = 0x10c1; 
-                       speedt = 0x10c1;
-                       break;
-               case 3: 
-                       speedp = 0x10C3; 
-                       speedt = 0x10C3;
-                       break;
-               case 2: 
-                       speedp = 0x1104; 
-                       speedt = 0x1281;
-                       break;
-               case 1:         
-                       speedp = 0x2283; 
-                       speedt = 0x1281;
-                       break;
-               case 0:
-               default:
-                       speedp = 0x328A; 
-                       speedt = 0x328A;
-                       break;
+       switch (mode_wanted) {
+       case 4:
+               speedp = 0x10c1;
+               speedt = 0x10c1;
+               break;
+       case 3:
+               speedp = 0x10c3;
+               speedt = 0x10c3;
+               break;
+       case 2:
+               speedp = 0x1104;
+               speedt = 0x1281;
+               break;
+       case 1:
+               speedp = 0x2283;
+               speedt = 0x2283;
+               break;
+       case 0:
+       default:
+               speedp = 0x328a;
+               speedt = 0x328a;
+               break;
        }
-       if (hwif->mmio)
-       {
-               hwif->OUTW(speedt, addr);
-               hwif->OUTW(speedp, tfaddr);
+
+       if (hwif->mmio) {
+               hwif->OUTW(speedp, addr);
+               hwif->OUTW(speedt, tfaddr);
                /* Now set up IORDY */
                if(mode_wanted == 3 || mode_wanted == 4)
                        hwif->OUTW(hwif->INW(tfaddr-2)|0x200, tfaddr-2);
                else
                        hwif->OUTW(hwif->INW(tfaddr-2)&~0x200, tfaddr-2);
-       }
-       else
-       {
+       } else {
                pci_write_config_word(hwif->pci_dev, addr, speedp);
                pci_write_config_word(hwif->pci_dev, tfaddr, speedt);
                pci_read_config_word(hwif->pci_dev, tfaddr-2, &speedp);
@@ -397,12 +396,9 @@ static int config_chipset_for_dma (ide_drive_t *drive)
        if (!speed)
                return 0;
 
-       if (ide_set_xfer_rate(drive, speed))
+       if (siimage_tune_chipset(drive, speed))
                return 0;
 
-       if (!drive->init_speed)
-               drive->init_speed = speed;
-
        return ide_dma_enable(drive);
 }
 
@@ -419,19 +415,11 @@ static int config_chipset_for_dma (ide_drive_t *drive)
 static int siimage_config_drive_for_dma (ide_drive_t *drive)
 {
        ide_hwif_t *hwif        = HWIF(drive);
-       struct hd_driveid *id   = drive->id;
-
-       if ((id->capability & 1) != 0 && drive->autodma) {
-
-               if (ide_use_dma(drive)) {
-                       if (config_chipset_for_dma(drive))
-                               return hwif->ide_dma_on(drive);
-               }
 
-               goto fast_ata_pio;
+       if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+               return hwif->ide_dma_on(drive);
 
-       } else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+       if (ide_use_fast_pio(drive)) {
                config_chipset_for_pio(drive, 1);
                return hwif->ide_dma_off_quietly(drive);
        }
@@ -898,7 +886,6 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif)
                base = (unsigned long) addr;
 
        hwif->dma_base                  = base + (ch ? 0x08 : 0x00);
-       hwif->dma_base2                 = base + (ch ? 0x18 : 0x10);
        hwif->mmio                      = 2;
 }
 
@@ -1097,7 +1084,7 @@ static struct pci_driver driver = {
        .probe          = siimage_init_one,
 };
 
-static int siimage_ide_init(void)
+static int __init siimage_ide_init(void)
 {
        return ide_pci_register_driver(&driver);
 }