Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[safe/jmp/linux-2.6] / drivers / ata / pata_atp867x.c
index 27d3148..9529593 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/blkdev.h>
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/gfp.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 
@@ -155,30 +156,31 @@ static int atp867x_get_active_clocks_shifted(struct ata_port *ap,
        struct atp867x_priv *dp = ap->private_data;
        unsigned char clocks = clk;
 
+       /*
+        * Doc 6.6.9: increase the clock value by 1 for safer PIO speed
+        * on 66MHz bus
+        */
+       if (dp->pci66mhz)
+               clocks++;
+
        switch (clocks) {
        case 0:
                clocks = 1;
                break;
-       case 1 ... 7:
-               break;
-       case 9 ... 12:
-               clocks = 7;
+       case 1 ... 6:
                break;
        default:
                printk(KERN_WARNING "ATP867X: active %dclk is invalid. "
-                       "Using default 8clk.\n", clk);
+                       "Using 12clk.\n", clk);
+       case 9 ... 12:
+               clocks = 7;     /* 12 clk */
+               break;
+       case 7:
        case 8: /* default 8 clk */
                clocks = 0;
                goto active_clock_shift_done;
        }
 
-       /*
-        * Doc 6.6.9: increase the clock value by 1 for safer PIO speed
-        * on 66MHz bus
-        */
-       if (dp->pci66mhz && clocks < 7)
-               clocks++;
-
 active_clock_shift_done:
        return clocks << ATP867X_IO_PIOSPD_ACTIVE_SHIFT;
 }
@@ -193,7 +195,8 @@ static int atp867x_get_recover_clocks_shifted(unsigned int clk)
                break;
        case 1 ... 11:
                break;
-       case 13: case 14:
+       case 13:
+       case 14:
                --clocks;       /* by the spec */
                break;
        case 15:
@@ -235,16 +238,16 @@ static void atp867x_set_piomode(struct ata_port *ap, struct ata_device *adev)
        iowrite8(b, dp->dma_mode);
 
        b = atp867x_get_active_clocks_shifted(ap, t.active) |
-               atp867x_get_recover_clocks_shifted(t.recover);
+           atp867x_get_recover_clocks_shifted(t.recover);
 
        if (adev->devno & 1)
                iowrite8(b, dp->slave_piospd);
        else
                iowrite8(b, dp->mstr_piospd);
 
-       /*
-        * use the same value for comand timing as for PIO timimg
-        */
+       b = atp867x_get_active_clocks_shifted(ap, t.act8b) |
+           atp867x_get_recover_clocks_shifted(t.rec8b);
+
        iowrite8(b, dp->eightb_piospd);
 }
 
@@ -522,7 +525,7 @@ static int atp867x_init_one(struct pci_dev *pdev,
 
        pci_set_master(pdev);
 
-       rc = ata_host_activate(host, pdev->irq, ata_sff_interrupt,
+       rc = ata_host_activate(host, pdev->irq, ata_bmdma_interrupt,
                                IRQF_SHARED, &atp867x_sht);
        if (rc)
                dev_printk(KERN_ERR, &pdev->dev, "failed to activate host\n");
@@ -531,6 +534,23 @@ err_out:
        return rc;
 }
 
+#ifdef CONFIG_PM
+static int atp867x_reinit_one(struct pci_dev *pdev)
+{
+       struct ata_host *host = dev_get_drvdata(&pdev->dev);
+       int rc;
+
+       rc = ata_pci_device_do_resume(pdev);
+       if (rc)
+               return rc;
+
+       atp867x_fixup(host);
+
+       ata_host_resume(host);
+       return 0;
+}
+#endif
+
 static struct pci_device_id atp867x_pci_tbl[] = {
        { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP867A),      0 },
        { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP867B),      0 },
@@ -542,6 +562,10 @@ static struct pci_driver atp867x_driver = {
        .id_table       = atp867x_pci_tbl,
        .probe          = atp867x_init_one,
        .remove         = ata_pci_remove_one,
+#ifdef CONFIG_PM
+       .suspend        = ata_pci_device_suspend,
+       .resume         = atp867x_reinit_one,
+#endif
 };
 
 static int __init atp867x_init(void)