]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - drivers/ide/pci/alim15x3.c
ide: add IDE_HFLAG_NO_LBA48 and IDE_HFLAG_NO_LBA48_DMA host flags
[mirror_ubuntu-zesty-kernel.git] / drivers / ide / pci / alim15x3.c
index 20ebe3b7049cd7120f6dcd24e569e86215be99be..79f572572ffbc7069d7bf1884b81337b1fd6eefa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * linux/drivers/ide/pci/alim15x3.c            Version 0.25    Jun 9 2007
+ * linux/drivers/ide/pci/alim15x3.c            Version 0.26    Jul 14 2007
  *
  *  Copyright (C) 1998-2000 Michel Aubry, Maintainer
  *  Copyright (C) 1998-2000 Andrzej Krzysztofowicz, Maintainer
@@ -283,17 +283,14 @@ static int ali_get_info (char *buffer, char **addr, off_t offset, int count)
 #endif  /* defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_IDE_PROC_FS) */
 
 /**
- *     ali15x3_tune_pio        -       set up chipset for PIO mode
- *     @drive: drive to tune
- *     @pio: desired mode
+ *     ali_set_pio_mode        -       set host controller for PIO mode
+ *     @drive: drive
+ *     @pio: PIO mode number
  *
- *     Select the best PIO mode for the drive in question.
- *     Then program the controller for this mode.
- *
- *     Returns the PIO mode programmed.
+ *     Program the controller for the given PIO mode.
  */
-static u8 ali15x3_tune_pio (ide_drive_t *drive, u8 pio)
+
+static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
 {
        ide_hwif_t *hwif = HWIF(drive);
        struct pci_dev *dev = hwif->pci_dev;
@@ -306,7 +303,6 @@ static u8 ali15x3_tune_pio (ide_drive_t *drive, u8 pio)
        u8 cd_dma_fifo = 0;
        int unit = drive->select.b.unit & 1;
 
-       pio = ide_get_best_pio_mode(drive, pio, 5);
        s_time = ide_pio_timings[pio].setup_time;
        a_time = ide_pio_timings[pio].active_time;
        if ((s_clc = (s_time * bus_speed + 999) / 1000) >= 8)
@@ -359,23 +355,6 @@ static u8 ali15x3_tune_pio (ide_drive_t *drive, u8 pio)
         * { 25,   70,     25  },   PIO Mode 4 with IORDY  ns
         * { 20,   50,     30  }    PIO Mode 5 with IORDY (nonstandard)
         */
-
-       return pio;
-}
-
-/**
- *     ali15x3_tune_drive      -       set up drive for PIO mode
- *     @drive: drive to tune
- *     @pio: desired mode
- *
- *     Program the controller with the best PIO timing for the given drive.
- *     Then set up the drive itself.
- */
-
-static void ali15x3_tune_drive (ide_drive_t *drive, u8 pio)
-{
-       pio = ali15x3_tune_pio(drive, pio);
-       (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio);
 }
 
 /**
@@ -407,24 +386,25 @@ static u8 ali_udma_filter(ide_drive_t *drive)
 }
 
 /**
- *     ali15x3_tune_chipset    -       set up chipset/drive for new speed
- *     @drive: drive to configure for
- *     @xferspeed: desired speed
+ *     ali_set_dma_mode        -       set host controller for DMA mode
+ *     @drive: drive
+ *     @speed: DMA mode
  *
  *     Configure the hardware for the desired IDE transfer mode.
- *     We also do the needed drive configuration through helpers
  */
-static int ali15x3_tune_chipset (ide_drive_t *drive, u8 xferspeed)
+
+static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed)
 {
        ide_hwif_t *hwif        = HWIF(drive);
        struct pci_dev *dev     = hwif->pci_dev;
-       u8 speed                = ide_rate_filter(drive, xferspeed);
        u8 speed1               = speed;
        u8 unit                 = (drive->select.b.unit & 0x01);
        u8 tmpbyte              = 0x00;
        int m5229_udma          = (hwif->channel) ? 0x57 : 0x56;
 
+       if (speed < XFER_PIO_0)
+               return;
+
        if (speed == XFER_UDMA_6)
                speed1 = 0x47;
 
@@ -437,8 +417,9 @@ static int ali15x3_tune_chipset (ide_drive_t *drive, u8 xferspeed)
                tmpbyte &= ultra_enable;
                pci_write_config_byte(dev, m5229_udma, tmpbyte);
 
-               if (speed < XFER_SW_DMA_0)
-                       (void) ali15x3_tune_pio(drive, speed - XFER_PIO_0);
+               /*
+                * FIXME: Oh, my... DMA timings are never set.
+                */
        } else {
                pci_read_config_byte(dev, m5229_udma, &tmpbyte);
                tmpbyte &= (0x0f << ((1-unit) << 2));
@@ -453,27 +434,6 @@ static int ali15x3_tune_chipset (ide_drive_t *drive, u8 xferspeed)
                        pci_write_config_byte(dev, 0x4b, tmpbyte);
                }
        }
-       return (ide_config_drive_speed(drive, speed));
-}
-
-/**
- *     ali15x3_config_drive_for_dma    -       configure for DMA
- *     @drive: drive to configure
- *
- *     Configure a drive for DMA operation. If DMA is not possible we
- *     drop the drive into PIO mode instead.
- */
-
-static int ali15x3_config_drive_for_dma(ide_drive_t *drive)
-{
-       drive->init_speed = 0;
-
-       if (ide_tune_dma(drive))
-               return 0;
-
-       ali15x3_tune_drive(drive, 255);
-
-       return -1;
 }
 
 /**
@@ -700,13 +660,13 @@ static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif)
  
 static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif)
 {
-       hwif->autodma = 0;
-       hwif->tuneproc = &ali15x3_tune_drive;
-       hwif->speedproc = &ali15x3_tune_chipset;
+       hwif->set_pio_mode = &ali_set_pio_mode;
+       hwif->set_dma_mode = &ali_set_dma_mode;
        hwif->udma_filter = &ali_udma_filter;
 
        /* don't use LBA48 DMA on ALi devices before rev 0xC5 */
-       hwif->no_lba48_dma = (m5229_revision <= 0xC4) ? 1 : 0;
+       if (m5229_revision <= 0xC4)
+               hwif->host_flags |= IDE_HFLAG_NO_LBA48_DMA;
 
        if (!hwif->dma_base) {
                hwif->drives[0].autotune = 1;
@@ -714,8 +674,12 @@ static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif)
                return;
        }
 
-       if (m5229_revision > 0x20)
-               hwif->atapi_dma = 1;
+       /*
+        * check in ->init_dma guarantees m5229_revision >= 0x20 here
+        */
+
+       if (m5229_revision == 0x20)
+               hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA;
 
        if (m5229_revision <= 0x20)
                hwif->ultra_mask = 0x00; /* no udma */
@@ -731,20 +695,10 @@ static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif)
        hwif->mwdma_mask = 0x07;
        hwif->swdma_mask = 0x07;
 
-        if (m5229_revision >= 0x20) {
-                /*
-                 * M1543C or newer for DMAing
-                 */
-                hwif->ide_dma_check = &ali15x3_config_drive_for_dma;
-               hwif->dma_setup = &ali15x3_dma_setup;
-               if (!noautodma)
-                       hwif->autodma = 1;
-
-               if (hwif->cbl != ATA_CBL_PATA40_SHORT)
-                       hwif->cbl = ata66_ali15x3(hwif);
-       }
-       hwif->drives[0].autodma = hwif->autodma;
-       hwif->drives[1].autodma = hwif->autodma;
+       hwif->dma_setup = &ali15x3_dma_setup;
+
+       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
+               hwif->cbl = ata66_ali15x3(hwif);
 }
 
 /**
@@ -823,8 +777,7 @@ static ide_pci_device_t ali15x3_chipset __devinitdata = {
        .init_chipset   = init_chipset_ali15x3,
        .init_hwif      = init_hwif_ali15x3,
        .init_dma       = init_dma_ali15x3,
-       .autodma        = AUTODMA,
-       .bootable       = ON_BOARD,
+       .host_flags     = IDE_HFLAG_BOOTABLE,
        .pio_mask       = ATA_PIO5,
 };
 
@@ -855,9 +808,9 @@ static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_dev
 }
 
 
-static struct pci_device_id alim15x3_pci_tbl[] = {
-       { PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M5229, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-       { PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M5228, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+static const struct pci_device_id alim15x3_pci_tbl[] = {
+       { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5229), 0 },
+       { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), 0 },
        { 0, },
 };
 MODULE_DEVICE_TABLE(pci, alim15x3_pci_tbl);