]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/pci/hpt366.c
hpt366: kill set_dma_mode() method wrapper
[linux-2.6-omap-h63xx.git] / drivers / ide / pci / hpt366.c
index 5682895d36d997d556bc442a2399e4ccdb30ab70..faf77fd2e4ef178ca983ac376236acc831cb6764 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * linux/drivers/ide/pci/hpt366.c              Version 1.21    Oct 23, 2007
+ * linux/drivers/ide/pci/hpt366.c              Version 1.24    Dec 8, 2007
  *
  * Copyright (C) 1999-2003             Andre Hedrick <andre@linux-ide.org>
  * Portions Copyright (C) 2001         Sun Microsystems, Inc.
@@ -310,6 +310,8 @@ static u32 twenty_five_base_hpt36x[] = {
        /* XFER_PIO_0 */        0xc0d08585
 };
 
+#if 0
+/* These are the timing tables from the HighPoint open source drivers... */
 static u32 thirty_three_base_hpt37x[] = {
        /* XFER_UDMA_6 */       0x12446231,     /* 0x12646231 ?? */
        /* XFER_UDMA_5 */       0x12446231,
@@ -369,6 +371,73 @@ static u32 sixty_six_base_hpt37x[] = {
        /* XFER_PIO_1 */        0x0d029d26,
        /* XFER_PIO_0 */        0x0d029d5e
 };
+#else
+/*
+ * The following are the new timing tables with PIO mode data/taskfile transfer
+ * overclocking fixed...
+ */
+
+/* This table is taken from the HPT370 data manual rev. 1.02 */
+static u32 thirty_three_base_hpt37x[] = {
+       /* XFER_UDMA_6 */       0x16455031,     /* 0x16655031 ?? */
+       /* XFER_UDMA_5 */       0x16455031,
+       /* XFER_UDMA_4 */       0x16455031,
+       /* XFER_UDMA_3 */       0x166d5031,
+       /* XFER_UDMA_2 */       0x16495031,
+       /* XFER_UDMA_1 */       0x164d5033,
+       /* XFER_UDMA_0 */       0x16515097,
+
+       /* XFER_MW_DMA_2 */     0x26515031,
+       /* XFER_MW_DMA_1 */     0x26515033,
+       /* XFER_MW_DMA_0 */     0x26515097,
+
+       /* XFER_PIO_4 */        0x06515021,
+       /* XFER_PIO_3 */        0x06515022,
+       /* XFER_PIO_2 */        0x06515033,
+       /* XFER_PIO_1 */        0x06915065,
+       /* XFER_PIO_0 */        0x06d1508a
+};
+
+static u32 fifty_base_hpt37x[] = {
+       /* XFER_UDMA_6 */       0x1a861842,
+       /* XFER_UDMA_5 */       0x1a861842,
+       /* XFER_UDMA_4 */       0x1aae1842,
+       /* XFER_UDMA_3 */       0x1a8e1842,
+       /* XFER_UDMA_2 */       0x1a0e1842,
+       /* XFER_UDMA_1 */       0x1a161854,
+       /* XFER_UDMA_0 */       0x1a1a18ea,
+
+       /* XFER_MW_DMA_2 */     0x2a821842,
+       /* XFER_MW_DMA_1 */     0x2a821854,
+       /* XFER_MW_DMA_0 */     0x2a8218ea,
+
+       /* XFER_PIO_4 */        0x0a821842,
+       /* XFER_PIO_3 */        0x0a821843,
+       /* XFER_PIO_2 */        0x0a821855,
+       /* XFER_PIO_1 */        0x0ac218a8,
+       /* XFER_PIO_0 */        0x0b02190c
+};
+
+static u32 sixty_six_base_hpt37x[] = {
+       /* XFER_UDMA_6 */       0x1c86fe62,
+       /* XFER_UDMA_5 */       0x1caefe62,     /* 0x1c8afe62 */
+       /* XFER_UDMA_4 */       0x1c8afe62,
+       /* XFER_UDMA_3 */       0x1c8efe62,
+       /* XFER_UDMA_2 */       0x1c92fe62,
+       /* XFER_UDMA_1 */       0x1c9afe62,
+       /* XFER_UDMA_0 */       0x1c82fe62,
+
+       /* XFER_MW_DMA_2 */     0x2c82fe62,
+       /* XFER_MW_DMA_1 */     0x2c82fe66,
+       /* XFER_MW_DMA_0 */     0x2c82ff2e,
+
+       /* XFER_PIO_4 */        0x0c82fe62,
+       /* XFER_PIO_3 */        0x0c82fe84,
+       /* XFER_PIO_2 */        0x0c82fea6,
+       /* XFER_PIO_1 */        0x0d02ff26,
+       /* XFER_PIO_0 */        0x0d42ff7f
+};
+#endif
 
 #define HPT366_DEBUG_DRIVE_INFO                0
 #define HPT371_ALLOW_ATA133_6          1
@@ -620,19 +689,17 @@ static void hpt36x_set_mode(ide_drive_t *drive, const u8 speed)
        struct hpt_info *info   = pci_get_drvdata(dev);
        u8  itr_addr            = drive->dn ? 0x44 : 0x40;
        u32 old_itr             = 0;
-       u32 itr_mask, new_itr;
-
-       itr_mask = speed < XFER_MW_DMA_0 ? 0x30070000 :
-                 (speed < XFER_UDMA_0   ? 0xc0070000 : 0xc03800ff);
-
-       new_itr = get_speed_setting(speed, info);
+       u32 new_itr             = get_speed_setting(speed, info);
+       u32 itr_mask            = speed < XFER_MW_DMA_0 ? 0xc1f8ffff :
+                                (speed < XFER_UDMA_0   ? 0x303800ff :
+                                                         0x30070000);
 
+       pci_read_config_dword(dev, itr_addr, &old_itr);
+       new_itr = (old_itr & ~itr_mask) | (new_itr & itr_mask);
        /*
         * Disable on-chip PIO FIFO/buffer (and PIO MST mode as well)
         * to avoid problems handling I/O errors later
         */
-       pci_read_config_dword(dev, itr_addr, &old_itr);
-       new_itr  = (new_itr & ~itr_mask) | (old_itr & itr_mask);
        new_itr &= ~0xc0000000;
 
        pci_write_config_dword(dev, itr_addr, new_itr);
@@ -645,35 +712,22 @@ static void hpt37x_set_mode(ide_drive_t *drive, const u8 speed)
        struct hpt_info *info   = pci_get_drvdata(dev);
        u8  itr_addr            = 0x40 + (drive->dn * 4);
        u32 old_itr             = 0;
-       u32 itr_mask, new_itr;
-
-       itr_mask = speed < XFER_MW_DMA_0 ? 0x303c0000 :
-                 (speed < XFER_UDMA_0   ? 0xc03c0000 : 0xc1c001ff);
-
-       new_itr = get_speed_setting(speed, info);
+       u32 new_itr             = get_speed_setting(speed, info);
+       u32 itr_mask            = speed < XFER_MW_DMA_0 ? 0xcfc3ffff :
+                                (speed < XFER_UDMA_0   ? 0x31c001ff :
+                                                         0x303c0000);
 
        pci_read_config_dword(dev, itr_addr, &old_itr);
-       new_itr = (new_itr & ~itr_mask) | (old_itr & itr_mask);
-       
+       new_itr = (old_itr & ~itr_mask) | (new_itr & itr_mask);
+
        if (speed < XFER_MW_DMA_0)
                new_itr &= ~0x80000000; /* Disable on-chip PIO FIFO/buffer */
        pci_write_config_dword(dev, itr_addr, new_itr);
 }
 
-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)
-               hpt37x_set_mode(drive, speed);
-       else    /* hpt368: hpt_minimum_revision(dev, 2) */
-               hpt36x_set_mode(drive, speed);
-}
-
 static void hpt3xx_set_pio_mode(ide_drive_t *drive, const u8 pio)
 {
-       hpt3xx_set_mode(drive, XFER_PIO_0 + pio);
+       HWIF(drive)->set_dma_mode(drive, XFER_PIO_0 + pio);
 }
 
 static int hpt3xx_quirkproc(ide_drive_t *drive)
@@ -1250,7 +1304,11 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
        hwif->select_data       = hwif->channel ? 0x54 : 0x50;
 
        hwif->set_pio_mode      = &hpt3xx_set_pio_mode;
-       hwif->set_dma_mode      = &hpt3xx_set_mode;
+       if (chip_type >= HPT370)
+               hwif->set_dma_mode = &hpt37x_set_mode;
+       else
+               hwif->set_dma_mode = &hpt36x_set_mode;
+
        hwif->quirkproc         = &hpt3xx_quirkproc;
        hwif->intrproc          = &hpt3xx_intrproc;
        hwif->maskproc          = &hpt3xx_maskproc;