]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/ide/pci/piix.c
ide: move ide_config_drive_speed() calls to upper layers (take 2)
[mirror_ubuntu-bionic-kernel.git] / drivers / ide / pci / piix.c
index 1372c35be035fcc898cb1fe708f8056c56079fde..38c91ba6497b30252796f4020b5af9293535438b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  linux/drivers/ide/pci/piix.c       Version 0.50    Jun 10, 2007
+ *  linux/drivers/ide/pci/piix.c       Version 0.52    Jul 14, 2007
  *
  *  Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer
  *  Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
  *                 41
  *                 43
  *
- * | PIO 0       | c0 | 80 | 0 |       piix_tune_drive(drive, 0);
- * | PIO 2 | SW2 | d0 | 90 | 4 |       piix_tune_drive(drive, 2);
- * | PIO 3 | MW1 | e1 | a1 | 9 |       piix_tune_drive(drive, 3);
- * | PIO 4 | MW2 | e3 | a3 | b |       piix_tune_drive(drive, 4);
- * 
+ * | PIO 0       | c0 | 80 | 0 |
+ * | PIO 2 | SW2 | d0 | 90 | 4 |
+ * | PIO 3 | MW1 | e1 | a1 | 9 |
+ * | PIO 4 | MW2 | e3 | a3 | b |
+ *
  * sitre = word40 & 0x4000; primary
  * sitre = word42 & 0x4000; secondary
  *
@@ -109,7 +109,7 @@ static int no_piix_dma;
  *     piix_dma_2_pio          -       return the PIO mode matching DMA
  *     @xfer_rate: transfer speed
  *
- *     Returns the nearest equivalent PIO timing for the PIO or DMA
+ *     Returns the nearest equivalent PIO timing for the DMA
  *     mode requested by the controller.
  */
  
@@ -123,33 +123,28 @@ static u8 piix_dma_2_pio (u8 xfer_rate) {
                case XFER_UDMA_1:
                case XFER_UDMA_0:
                case XFER_MW_DMA_2:
-               case XFER_PIO_4:
                        return 4;
                case XFER_MW_DMA_1:
-               case XFER_PIO_3:
                        return 3;
                case XFER_SW_DMA_2:
-               case XFER_PIO_2:
                        return 2;
                case XFER_MW_DMA_0:
                case XFER_SW_DMA_1:
                case XFER_SW_DMA_0:
-               case XFER_PIO_1:
-               case XFER_PIO_0:
-               case XFER_PIO_SLOW:
                default:
                        return 0;
        }
 }
 
 /**
- *     piix_tune_pio           -       tune PIIX for PIO mode
- *     @drive: drive to tune
- *     @pio: desired PIO mode
+ *     piix_set_pio_mode       -       set host controller for PIO mode
+ *     @drive: drive
+ *     @pio: PIO mode number
  *
  *     Set the interface PIO mode based upon the settings done by AMI BIOS.
  */
-static void piix_tune_pio (ide_drive_t *drive, u8 pio)
+
+static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio)
 {
        ide_hwif_t *hwif        = HWIF(drive);
        struct pci_dev *dev     = hwif->pci_dev;
@@ -210,36 +205,19 @@ static void piix_tune_pio (ide_drive_t *drive, u8 pio)
 }
 
 /**
- *     piix_tune_drive         -       tune a drive attached to PIIX
- *     @drive: drive to tune
- *     @pio: desired PIO mode
+ *     piix_set_dma_mode       -       set host controller for DMA mode
+ *     @drive: drive
+ *     @speed: DMA mode
  *
- *     Set the drive's PIO mode (might be useful if drive is not registered
- *     in CMOS for any reason).
+ *     Set a PIIX host controller to the desired DMA mode.  This involves
+ *     programming the right timing data into the PCI configuration space.
  */
-static void piix_tune_drive (ide_drive_t *drive, u8 pio)
-{
-       pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
-       piix_tune_pio(drive, pio);
-       (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio);
-}
 
-/**
- *     piix_tune_chipset       -       tune a PIIX interface
- *     @drive: IDE drive to tune
- *     @xferspeed: speed to configure
- *
- *     Set a PIIX interface channel to the desired speeds. This involves
- *     requires the right timing data into the PIIX configuration space
- *     then setting the drive parameters appropriately
- */
-static int piix_tune_chipset (ide_drive_t *drive, u8 xferspeed)
+static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed)
 {
        ide_hwif_t *hwif        = HWIF(drive);
        struct pci_dev *dev     = hwif->pci_dev;
        u8 maslave              = hwif->channel ? 0x42 : 0x40;
-       u8 speed                = ide_rate_filter(drive, xferspeed);
        int a_speed             = 3 << (drive->dn * 4);
        int u_flag              = 1 << drive->dn;
        int v_flag              = 0x01 << drive->dn;
@@ -266,11 +244,7 @@ static int piix_tune_chipset (ide_drive_t *drive, u8 xferspeed)
                case XFER_MW_DMA_2:
                case XFER_MW_DMA_1:
                case XFER_SW_DMA_2:     break;
-               case XFER_PIO_4:
-               case XFER_PIO_3:
-               case XFER_PIO_2:
-               case XFER_PIO_0:        break;
-               default:                return -1;
+               default:                return;
        }
 
        if (speed >= XFER_UDMA_0) {
@@ -299,8 +273,7 @@ static int piix_tune_chipset (ide_drive_t *drive, u8 xferspeed)
                        pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag);
        }
 
-       piix_tune_pio(drive, piix_dma_2_pio(speed));
-       return ide_config_drive_speed(drive, speed);
+       piix_set_pio_mode(drive, piix_dma_2_pio(speed));
 }
 
 /**
@@ -319,7 +292,7 @@ static int piix_config_drive_xfer_rate (ide_drive_t *drive)
                return 0;
 
        if (ide_use_fast_pio(drive))
-               piix_tune_drive(drive, 255);
+               ide_set_max_pio(drive);
 
        return -1;
 }
@@ -456,8 +429,10 @@ static void __devinit init_hwif_piix(ide_hwif_t *hwif)
        }
 
        hwif->autodma = 0;
-       hwif->tuneproc = &piix_tune_drive;
-       hwif->speedproc = &piix_tune_chipset;
+
+       hwif->set_pio_mode = &piix_set_pio_mode;
+       hwif->set_dma_mode = &piix_set_dma_mode;
+
        hwif->drives[0].autotune = 1;
        hwif->drives[1].autotune = 1;
 
@@ -495,10 +470,10 @@ static void __devinit init_hwif_piix(ide_hwif_t *hwif)
                .name           = name_str,             \
                .init_chipset   = init_chipset_piix,    \
                .init_hwif      = init_hwif_piix,       \
-               .channels       = 2,                    \
                .autodma        = AUTODMA,              \
                .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \
                .bootable       = ON_BOARD,             \
+               .pio_mask       = ATA_PIO4,             \
                .udma_mask      = udma,                 \
        }
 
@@ -514,11 +489,11 @@ static ide_pci_device_t piix_pci_info[] __devinitdata = {
                 */
                .name           = "MPIIX",
                .init_hwif      = init_hwif_piix,
-               .channels       = 2,
                .autodma        = NODMA,
                .enablebits     = {{0x6d,0xc0,0x80}, {0x6d,0xc0,0xc0}},
                .bootable       = ON_BOARD,
-               .flags          = IDEPCI_FLAG_ISA_PORTS
+               .host_flags     = IDE_HFLAG_ISA_PORTS,
+               .pio_mask       = ATA_PIO4,
        },
 
        /*  3 */ DECLARE_PIIX_DEV("PIIX3", 0x00),       /* no udma */