Merge branch 'upstream'
[powerpc.git] / drivers / scsi / sata_vsc.c
index 3985f34..3e34fed 100644 (file)
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/dma-mapping.h>
-#include "scsi.h"
+#include <linux/device.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 
 #define DRV_NAME       "sata_vsc"
-#define DRV_VERSION    "1.0"
+#define DRV_VERSION    "1.1"
 
 /* Interrupt register offsets (from chip base address) */
 #define VSC_SATA_INT_STAT_OFFSET       0x00
@@ -86,7 +86,7 @@ static u32 vsc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
 {
        if (sc_reg > SCR_CONTROL)
                return 0xffffffffU;
-       return readl((void *) ap->ioaddr.scr_addr + (sc_reg * 4));
+       return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
 }
 
 
@@ -95,16 +95,16 @@ static void vsc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg,
 {
        if (sc_reg > SCR_CONTROL)
                return;
-       writel(val, (void *) ap->ioaddr.scr_addr + (sc_reg * 4));
+       writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
 }
 
 
 static void vsc_intr_mask_update(struct ata_port *ap, u8 ctl)
 {
-       unsigned long mask_addr;
+       void __iomem *mask_addr;
        u8 mask;
 
-       mask_addr = (unsigned long) ap->host_set->mmio_base +
+       mask_addr = ap->host_set->mmio_base +
                VSC_SATA_INT_MASK_OFFSET + ap->port_no;
        mask = readb(mask_addr);
        if (ctl & ATA_NIEN)
@@ -115,7 +115,7 @@ static void vsc_intr_mask_update(struct ata_port *ap, u8 ctl)
 }
 
 
-static void vsc_sata_tf_load(struct ata_port *ap, struct ata_taskfile *tf)
+static void vsc_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
 {
        struct ata_ioports *ioaddr = &ap->ioaddr;
        unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
@@ -153,16 +153,24 @@ static void vsc_sata_tf_load(struct ata_port *ap, struct ata_taskfile *tf)
 static void vsc_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
 {
        struct ata_ioports *ioaddr = &ap->ioaddr;
-       u16 nsect, lbal, lbam, lbah;
+       u16 nsect, lbal, lbam, lbah, feature;
 
-       nsect = tf->nsect = readw(ioaddr->nsect_addr);
-       lbal = tf->lbal = readw(ioaddr->lbal_addr);
-       lbam = tf->lbam = readw(ioaddr->lbam_addr);
-       lbah = tf->lbah = readw(ioaddr->lbah_addr);
+       tf->command = ata_check_status(ap);
        tf->device = readw(ioaddr->device_addr);
+       feature = readw(ioaddr->error_addr);
+       nsect = readw(ioaddr->nsect_addr);
+       lbal = readw(ioaddr->lbal_addr);
+       lbam = readw(ioaddr->lbam_addr);
+       lbah = readw(ioaddr->lbah_addr);
+
+       tf->feature = feature;
+       tf->nsect = nsect;
+       tf->lbal = lbal;
+       tf->lbam = lbam;
+       tf->lbah = lbah;
 
        if (tf->flags & ATA_TFLAG_LBA48) {
-               tf->hob_feature = readb(ioaddr->error_addr);
+               tf->hob_feature = feature >> 8;
                tf->hob_nsect = nsect >> 8;
                tf->hob_lbal = lbal >> 8;
                tf->hob_lbam = lbam >> 8;
@@ -193,12 +201,12 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance,
                        struct ata_port *ap;
 
                        ap = host_set->ports[i];
-                       if (ap && !(ap->flags &
-                                   (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) {
+                       if (ap &&
+                           !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
                                struct ata_queued_cmd *qc;
 
                                qc = ata_qc_from_tag(ap, ap->active_tag);
-                               if (qc && (!(qc->tf.ctl & ATA_NIEN)))
+                               if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)))
                                        handled += ata_host_intr(ap, qc);
                        }
                }
@@ -210,7 +218,7 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance,
 }
 
 
-static Scsi_Host_Template vsc_sata_sht = {
+static struct scsi_host_template vsc_sata_sht = {
        .module                 = THIS_MODULE,
        .name                   = DRV_NAME,
        .ioctl                  = ata_scsi_ioctl,
@@ -227,11 +235,10 @@ static Scsi_Host_Template vsc_sata_sht = {
        .dma_boundary           = ATA_DMA_BOUNDARY,
        .slave_configure        = ata_scsi_slave_config,
        .bios_param             = ata_std_bios_param,
-       .ordered_flush          = 1,
 };
 
 
-static struct ata_port_operations vsc_sata_ops = {
+static const struct ata_port_operations vsc_sata_ops = {
        .port_disable           = ata_port_disable,
        .tf_load                = vsc_sata_tf_load,
        .tf_read                = vsc_sata_tf_read,
@@ -252,7 +259,7 @@ static struct ata_port_operations vsc_sata_ops = {
        .scr_write              = vsc_sata_scr_write,
        .port_start             = ata_port_start,
        .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
+       .host_stop              = ata_pci_host_stop,
 };
 
 static void __devinit vsc_sata_setup_port(struct ata_ioports *port, unsigned long base)
@@ -283,11 +290,11 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
        struct ata_probe_ent *probe_ent = NULL;
        unsigned long base;
        int pci_dev_busy = 0;
-       void *mmio_base;
+       void __iomem *mmio_base;
        int rc;
 
        if (!printed_version++)
-               printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
+               dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
 
        rc = pci_enable_device(pdev);
        if (rc)
@@ -326,8 +333,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
 
-       mmio_base = ioremap(pci_resource_start(pdev, 0),
-                           pci_resource_len(pdev, 0));
+       mmio_base = pci_iomap(pdev, 0, 0);
        if (mmio_base == NULL) {
                rc = -ENOMEM;
                goto err_out_free_ent;
@@ -393,7 +399,7 @@ err_out:
  * 0x8086/0x3200 is the Intel 31244, which is supposed to be identical
  * compatibility is untested as of yet
  */
-static struct pci_device_id vsc_sata_pci_tbl[] = {
+static const struct pci_device_id vsc_sata_pci_tbl[] = {
        { 0x1725, 0x7174, PCI_ANY_ID, PCI_ANY_ID, 0x10600, 0xFFFFFF, 0 },
        { 0x8086, 0x3200, PCI_ANY_ID, PCI_ANY_ID, 0x10600, 0xFFFFFF, 0 },
        { }