ide: remove ->ide_dma_check (take 2)
[linux-2.6-block.git] / drivers / ide / pci / slc90e66.c
index ebac87f7200a0d4af94199cc30bed6d95528217f..bf21f1dfb7b5e356db8ba9804cd70bcbb0ce5fba 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  linux/drivers/ide/pci/slc90e66.c   Version 0.16    Jul 14, 2007
+ *  linux/drivers/ide/pci/slc90e66.c   Version 0.17    Aug 2, 2007
  *
  *  Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org>
  *  Copyright (C) 2006-2007 MontaVista Software, Inc. <source@mvista.com>
 
 #include <asm/io.h>
 
-static u8 slc90e66_dma_2_pio (u8 xfer_rate) {
-       switch(xfer_rate) {
-               case XFER_UDMA_4:
-               case XFER_UDMA_3:
-               case XFER_UDMA_2:
-               case XFER_UDMA_1:
-               case XFER_UDMA_0:
-               case XFER_MW_DMA_2:
-                       return 4;
-               case XFER_MW_DMA_1:
-                       return 3;
-               case XFER_SW_DMA_2:
-                       return 2;
-               case XFER_MW_DMA_0:
-               case XFER_SW_DMA_1:
-               case XFER_SW_DMA_0:
-               default:
-                       return 0;
-       }
-}
-
 static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio)
 {
        ide_hwif_t *hwif        = HWIF(drive);
@@ -103,6 +82,7 @@ static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed)
        int sitre = 0, a_speed  = 7 << (drive->dn * 4);
        int u_speed = 0, u_flag = 1 << drive->dn;
        u16                     reg4042, reg44, reg48, reg4a;
+       u8                      pio;
 
        pci_read_config_word(dev, maslave, &reg4042);
        sitre = (reg4042 & 0x4000) ? 1 : 0;
@@ -131,27 +111,23 @@ static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed)
                        pci_read_config_word(dev, 0x4a, &reg4a);
                        pci_write_config_word(dev, 0x4a, reg4a|u_speed);
                }
+
+               pio = 4;
        } else {
+               const u8 mwdma_to_pio[] = { 0, 3, 4 };
+
                if (reg48 & u_flag)
                        pci_write_config_word(dev, 0x48, reg48 & ~u_flag);
                if (reg4a & a_speed)
                        pci_write_config_word(dev, 0x4a, reg4a & ~a_speed);
-       }
 
-       slc90e66_set_pio_mode(drive, slc90e66_dma_2_pio(speed));
-}
-
-static int slc90e66_config_drive_xfer_rate (ide_drive_t *drive)
-{
-       drive->init_speed = 0;
-
-       if (ide_tune_dma(drive))
-               return 0;
-
-       if (ide_use_fast_pio(drive))
-               ide_set_max_pio(drive);
+               if (speed >= XFER_MW_DMA_0)
+                       pio = mwdma_to_pio[speed - XFER_MW_DMA_0];
+               else
+                       pio = 2; /* only SWDMA2 is allowed */
+       }
 
-       return -1;
+       slc90e66_set_pio_mode(drive, pio);
 }
 
 static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif)
@@ -169,11 +145,11 @@ static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif)
 
        pci_read_config_byte(hwif->pci_dev, 0x47, &reg47);
 
-       if (!hwif->dma_base) {
-               hwif->drives[0].autotune = 1;
-               hwif->drives[1].autotune = 1;
+       hwif->drives[0].autotune = 1;
+       hwif->drives[1].autotune = 1;
+
+       if (hwif->dma_base == 0)
                return;
-       }
 
        hwif->atapi_dma = 1;
        hwif->ultra_mask = 0x1f;
@@ -184,8 +160,6 @@ static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif)
                /* bit[0(1)]: 0:80, 1:40 */
                hwif->cbl = (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
 
-       hwif->ide_dma_check = &slc90e66_config_drive_xfer_rate;
-
        if (!noautodma)
                hwif->autodma = 1;
        hwif->drives[0].autodma = hwif->autodma;