]> err.no Git - linux-2.6/blobdiff - drivers/ide/pci/hpt366.c
pdc202xx_old: remove broken SWDMA support
[linux-2.6] / drivers / ide / pci / hpt366.c
index f87eec970574b4ff82e4370accf37291ed04737c..a805236bbae6c9854eea2680576d84b7d9c724e9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * linux/drivers/ide/pci/hpt366.c              Version 1.11    Aug 11, 2007
+ * linux/drivers/ide/pci/hpt366.c              Version 1.14    Oct 1, 2007
  *
  * Copyright (C) 1999-2003             Andre Hedrick <andre@linux-ide.org>
  * Portions Copyright (C) 2001         Sun Microsystems, Inc.
  *   unify HPT36x/37x timing setup code and the speedproc handlers by joining
  *   the register setting lists into the table indexed by the clock selected
  * - set the correct hwif->ultra_mask for each individual chip
+ * - add Ultra and MW DMA mode filtering for the HPT37[24] based SATA cards
  *     Sergei Shtylyov, <sshtylyov@ru.mvista.com> or <source@mvista.com>
  */
 
@@ -518,47 +519,67 @@ static int check_in_drive_list(ide_drive_t *drive, const char **list)
 }
 
 /*
- *     Note for the future; the SATA hpt37x we must set
- *     either PIO or UDMA modes 0,4,5
+ * The Marvell bridge chips used on the HighPoint SATA cards do not seem
+ * to support the UltraDMA modes 1, 2, and 3 as well as any MWDMA modes...
  */
 
 static u8 hpt3xx_udma_filter(ide_drive_t *drive)
 {
-       struct hpt_info *info   = pci_get_drvdata(HWIF(drive)->pci_dev);
-       u8 mask;
+       ide_hwif_t *hwif        = HWIF(drive);
+       struct hpt_info *info   = pci_get_drvdata(hwif->pci_dev);
+       u8 mask                 = hwif->ultra_mask;
 
        switch (info->chip_type) {
-       case HPT370A:
-               if (!HPT370_ALLOW_ATA100_5 ||
-                   check_in_drive_list(drive, bad_ata100_5))
-                       return 0x1f;
-               else
-                       return 0x3f;
-       case HPT370:
-               if (!HPT370_ALLOW_ATA100_5 ||
-                   check_in_drive_list(drive, bad_ata100_5))
-                       mask = 0x1f;
-               else
-                       mask = 0x3f;
-               break;
        case HPT36x:
                if (!HPT366_ALLOW_ATA66_4 ||
                    check_in_drive_list(drive, bad_ata66_4))
-                       mask = 0x0f;
-               else
-                       mask = 0x1f;
+                       mask = ATA_UDMA3;
 
                if (!HPT366_ALLOW_ATA66_3 ||
                    check_in_drive_list(drive, bad_ata66_3))
-                       mask = 0x07;
+                       mask = ATA_UDMA2;
                break;
+       case HPT370:
+               if (!HPT370_ALLOW_ATA100_5 ||
+                   check_in_drive_list(drive, bad_ata100_5))
+                       mask = ATA_UDMA4;
+               break;
+       case HPT370A:
+               if (!HPT370_ALLOW_ATA100_5 ||
+                   check_in_drive_list(drive, bad_ata100_5))
+                       return ATA_UDMA4;
+       case HPT372 :
+       case HPT372A:
+       case HPT372N:
+       case HPT374 :
+               if (ide_dev_is_sata(drive->id))
+                       mask &= ~0x0e;
+               /* Fall thru */
        default:
-               return 0x7f;
+               return mask;
        }
 
        return check_in_drive_list(drive, bad_ata33) ? 0x00 : mask;
 }
 
+static u8 hpt3xx_mdma_filter(ide_drive_t *drive)
+{
+       ide_hwif_t *hwif        = HWIF(drive);
+       struct hpt_info *info   = pci_get_drvdata(hwif->pci_dev);
+
+       switch (info->chip_type) {
+       case HPT372 :
+       case HPT372A:
+       case HPT372N:
+       case HPT374 :
+               if (ide_dev_is_sata(drive->id))
+                       return 0x00;
+               /* Fall thru */
+       default:
+               return 0x07;
+       }
+}
+
 static u32 get_speed_setting(u8 speed, struct hpt_info *info)
 {
        int i;
@@ -579,20 +600,15 @@ static u32 get_speed_setting(u8 speed, struct hpt_info *info)
        return (*info->settings)[i];
 }
 
-static int hpt36x_tune_chipset(ide_drive_t *drive, u8 xferspeed)
+static void hpt36x_set_mode(ide_drive_t *drive, const u8 speed)
 {
        ide_hwif_t *hwif        = HWIF(drive);
        struct pci_dev  *dev    = hwif->pci_dev;
        struct hpt_info *info   = pci_get_drvdata(dev);
-       u8  speed               = ide_rate_filter(drive, xferspeed);
        u8  itr_addr            = drive->dn ? 0x44 : 0x40;
        u32 old_itr             = 0;
        u32 itr_mask, new_itr;
 
-       /* TODO: move this to ide_rate_filter() [ check ->atapi_dma ] */
-       if (drive->media != ide_disk)
-               speed = min_t(u8, speed, XFER_PIO_4);
-
        itr_mask = speed < XFER_MW_DMA_0 ? 0x30070000 :
                  (speed < XFER_UDMA_0   ? 0xc0070000 : 0xc03800ff);
 
@@ -607,24 +623,17 @@ static int hpt36x_tune_chipset(ide_drive_t *drive, u8 xferspeed)
        new_itr &= ~0xc0000000;
 
        pci_write_config_dword(dev, itr_addr, new_itr);
-
-       return ide_config_drive_speed(drive, speed);
 }
 
-static int hpt37x_tune_chipset(ide_drive_t *drive, u8 xferspeed)
+static void hpt37x_set_mode(ide_drive_t *drive, const u8 speed)
 {
        ide_hwif_t *hwif        = HWIF(drive);
        struct pci_dev  *dev    = hwif->pci_dev;
        struct hpt_info *info   = pci_get_drvdata(dev);
-       u8  speed               = ide_rate_filter(drive, xferspeed);
        u8  itr_addr            = 0x40 + (drive->dn * 4);
        u32 old_itr             = 0;
        u32 itr_mask, new_itr;
 
-       /* TODO: move this to ide_rate_filter() [ check ->atapi_dma ] */
-       if (drive->media != ide_disk)
-               speed = min_t(u8, speed, XFER_PIO_4);
-
        itr_mask = speed < XFER_MW_DMA_0 ? 0x303c0000 :
                  (speed < XFER_UDMA_0   ? 0xc03c0000 : 0xc1c001ff);
 
@@ -636,25 +645,22 @@ static int hpt37x_tune_chipset(ide_drive_t *drive, u8 xferspeed)
        if (speed < XFER_MW_DMA_0)
                new_itr &= ~0x80000000; /* Disable on-chip PIO FIFO/buffer */
        pci_write_config_dword(dev, itr_addr, new_itr);
-
-       return ide_config_drive_speed(drive, speed);
 }
 
-static int hpt3xx_tune_chipset(ide_drive_t *drive, u8 speed)
+static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed)
 {
        ide_hwif_t *hwif        = HWIF(drive);
        struct hpt_info *info   = pci_get_drvdata(hwif->pci_dev);
 
        if (info->chip_type >= HPT370)
-               return hpt37x_tune_chipset(drive, speed);
+               hpt37x_set_mode(drive, speed);
        else    /* hpt368: hpt_minimum_revision(dev, 2) */
-               return hpt36x_tune_chipset(drive, speed);
+               hpt36x_set_mode(drive, speed);
 }
 
-static void hpt3xx_tune_drive(ide_drive_t *drive, u8 pio)
+static void hpt3xx_set_pio_mode(ide_drive_t *drive, const u8 pio)
 {
-       pio = ide_get_best_pio_mode(drive, pio, 4);
-       (void) hpt3xx_tune_chipset (drive, XFER_PIO_0 + pio);
+       hpt3xx_set_mode(drive, XFER_PIO_0 + pio);
 }
 
 static int hpt3xx_quirkproc(ide_drive_t *drive)
@@ -707,19 +713,6 @@ static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
                           IDE_CONTROL_REG);
 }
 
-static int hpt366_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))
-               hpt3xx_tune_drive(drive, 255);
-
-       return -1;
-}
-
 /*
  * This is specific to the HPT366 UDMA chipset
  * by HighPoint|Triones Technologies, Inc.
@@ -1236,25 +1229,25 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha
 
 static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
 {
-       struct pci_dev  *dev            = hwif->pci_dev;
-       struct hpt_info *info           = pci_get_drvdata(dev);
-       int serialize                   = HPT_SERIALIZE_IO;
-       u8  scr1 = 0, ata66             = hwif->channel ? 0x01 : 0x02;
-       u8  chip_type                   = info->chip_type;
-       u8  new_mcr, old_mcr            = 0;
+       struct pci_dev  *dev    = hwif->pci_dev;
+       struct hpt_info *info   = pci_get_drvdata(dev);
+       int serialize           = HPT_SERIALIZE_IO;
+       u8  scr1 = 0, ata66     = hwif->channel ? 0x01 : 0x02;
+       u8  chip_type           = info->chip_type;
+       u8  new_mcr, old_mcr    = 0;
 
        /* Cache the channel's MISC. control registers' offset */
-       hwif->select_data               = hwif->channel ? 0x54 : 0x50;
+       hwif->select_data       = hwif->channel ? 0x54 : 0x50;
 
-       hwif->tuneproc                  = &hpt3xx_tune_drive;
-       hwif->speedproc                 = &hpt3xx_tune_chipset;
-       hwif->quirkproc                 = &hpt3xx_quirkproc;
-       hwif->intrproc                  = &hpt3xx_intrproc;
-       hwif->maskproc                  = &hpt3xx_maskproc;
-       hwif->busproc                   = &hpt3xx_busproc;
+       hwif->set_pio_mode      = &hpt3xx_set_pio_mode;
+       hwif->set_dma_mode      = &hpt3xx_set_mode;
+       hwif->quirkproc         = &hpt3xx_quirkproc;
+       hwif->intrproc          = &hpt3xx_intrproc;
+       hwif->maskproc          = &hpt3xx_maskproc;
+       hwif->busproc           = &hpt3xx_busproc;
 
-       if (chip_type <= HPT370A)
-               hwif->udma_filter       = &hpt3xx_udma_filter;
+       hwif->udma_filter       = &hpt3xx_udma_filter;
+       hwif->mdma_filter       = &hpt3xx_mdma_filter;
 
        /*
         * HPT3xxN chips have some complications:
@@ -1298,10 +1291,10 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
        if (new_mcr != old_mcr)
                pci_write_config_byte(dev, hwif->select_data + 1, new_mcr);
 
-       if (!hwif->dma_base) {
-               hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
+       hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
+
+       if (hwif->dma_base == 0)
                return;
-       }
 
        hwif->ultra_mask = hwif->cds->udma_mask;
        hwif->mwdma_mask = 0x07;
@@ -1343,8 +1336,6 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
        if (hwif->cbl != ATA_CBL_PATA40_SHORT)
                hwif->cbl = (scr1 & ata66) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
 
-       hwif->ide_dma_check             = &hpt366_config_drive_xfer_rate;
-
        if (chip_type >= HPT374) {
                hwif->ide_dma_test_irq  = &hpt374_ide_dma_test_irq;
                hwif->ide_dma_end       = &hpt374_ide_dma_end;
@@ -1354,10 +1345,6 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
                hwif->dma_timeout       = &hpt370_dma_timeout;
        } else
                hwif->dma_lost_irq      = &hpt366_dma_lost_irq;
-
-       if (!noautodma)
-               hwif->autodma = 1;
-       hwif->drives[0].autodma = hwif->drives[1].autodma = hwif->autodma;
 }
 
 static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase)
@@ -1504,19 +1491,19 @@ static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d)
                d->host_flags |= IDE_HFLAG_SINGLE;
                d->enablebits[0].mask = d->enablebits[0].val = 0x10;
 
-               d->udma_mask = HPT366_ALLOW_ATA66_3 ?
-                             (HPT366_ALLOW_ATA66_4 ? 0x1f : 0x0f) : 0x07;
+               d->udma_mask = HPT366_ALLOW_ATA66_3 ? (HPT366_ALLOW_ATA66_4 ?
+                              ATA_UDMA4 : ATA_UDMA3) : ATA_UDMA2;
                break;
        case 3:
        case 4:
-               d->udma_mask = HPT370_ALLOW_ATA100_5 ? 0x3f : 0x1f;
+               d->udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4;
                break;
        default:
                rev = 6;
                /* fall thru */
        case 5:
        case 6:
-               d->udma_mask = HPT372_ALLOW_ATA133_6 ? 0x7f : 0x3f;
+               d->udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5;
                break;
        }
 
@@ -1544,7 +1531,7 @@ static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d)
                pci_read_config_byte(dev,  PCI_INTERRUPT_PIN, &pin1);
                pci_read_config_byte(dev2, PCI_INTERRUPT_PIN, &pin2);
                if (pin1 != pin2 && dev->irq == dev2->irq) {
-                       d->bootable = ON_BOARD;
+                       d->host_flags |= IDE_HFLAG_BOOTABLE;
                        printk("%s: onboard version of chipset, pin1=%d pin2=%d\n",
                               d->name, pin1, pin2);
                }
@@ -1564,10 +1551,9 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = {
                .init_chipset   = init_chipset_hpt366,
                .init_hwif      = init_hwif_hpt366,
                .init_dma       = init_dma_hpt366,
-               .autodma        = AUTODMA,
                .enablebits     = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
-               .bootable       = OFF_BOARD,
                .extra          = 240,
+               .host_flags     = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD,
                .pio_mask       = ATA_PIO4,
        },{     /* 1 */
                .name           = "HPT372A",
@@ -1575,11 +1561,10 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = {
                .init_chipset   = init_chipset_hpt366,
                .init_hwif      = init_hwif_hpt366,
                .init_dma       = init_dma_hpt366,
-               .autodma        = AUTODMA,
                .enablebits     = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
-               .udma_mask      = HPT372_ALLOW_ATA133_6 ? 0x7f : 0x3f,
-               .bootable       = OFF_BOARD,
+               .udma_mask      = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
                .extra          = 240,
+               .host_flags     = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD,
                .pio_mask       = ATA_PIO4,
        },{     /* 2 */
                .name           = "HPT302",
@@ -1587,11 +1572,10 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = {
                .init_chipset   = init_chipset_hpt366,
                .init_hwif      = init_hwif_hpt366,
                .init_dma       = init_dma_hpt366,
-               .autodma        = AUTODMA,
                .enablebits     = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
-               .udma_mask      = HPT302_ALLOW_ATA133_6 ? 0x7f : 0x3f,
-               .bootable       = OFF_BOARD,
+               .udma_mask      = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
                .extra          = 240,
+               .host_flags     = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD,
                .pio_mask       = ATA_PIO4,
        },{     /* 3 */
                .name           = "HPT371",
@@ -1599,11 +1583,10 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = {
                .init_chipset   = init_chipset_hpt366,
                .init_hwif      = init_hwif_hpt366,
                .init_dma       = init_dma_hpt366,
-               .autodma        = AUTODMA,
                .enablebits     = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
-               .udma_mask      = HPT371_ALLOW_ATA133_6 ? 0x7f : 0x3f,
-               .bootable       = OFF_BOARD,
+               .udma_mask      = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
                .extra          = 240,
+               .host_flags     = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD,
                .pio_mask       = ATA_PIO4,
        },{     /* 4 */
                .name           = "HPT374",
@@ -1611,11 +1594,10 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = {
                .init_chipset   = init_chipset_hpt366,
                .init_hwif      = init_hwif_hpt366,
                .init_dma       = init_dma_hpt366,
-               .autodma        = AUTODMA,
                .enablebits     = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
-               .udma_mask      = 0x3f,
-               .bootable       = OFF_BOARD,
+               .udma_mask      = ATA_UDMA5,
                .extra          = 240,
+               .host_flags     = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD,
                .pio_mask       = ATA_PIO4,
        },{     /* 5 */
                .name           = "HPT372N",
@@ -1623,11 +1605,10 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = {
                .init_chipset   = init_chipset_hpt366,
                .init_hwif      = init_hwif_hpt366,
                .init_dma       = init_dma_hpt366,
-               .autodma        = AUTODMA,
                .enablebits     = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
-               .udma_mask      = HPT372_ALLOW_ATA133_6 ? 0x7f : 0x3f,
-               .bootable       = OFF_BOARD,
+               .udma_mask      = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
                .extra          = 240,
+               .host_flags     = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_OFF_BOARD,
                .pio_mask       = ATA_PIO4,
        }
 };
@@ -1651,13 +1632,13 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic
        return d.init_setup(dev, &d);
 }
 
-static struct pci_device_id hpt366_pci_tbl[] = {
-       { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT366, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-       { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT372, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
-       { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT302, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},
-       { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3},
-       { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT374, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4},
-       { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT372N, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5},
+static const struct pci_device_id hpt366_pci_tbl[] = {
+       { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT366),  0 },
+       { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT372),  1 },
+       { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT302),  2 },
+       { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT371),  3 },
+       { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT374),  4 },
+       { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT372N), 5 },
        { 0, },
 };
 MODULE_DEVICE_TABLE(pci, hpt366_pci_tbl);