Pull ec into release branch
[powerpc.git] / drivers / ata / sata_via.c
index c7f5275..598e6a2 100644 (file)
@@ -46,7 +46,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME       "sata_via"
-#define DRV_VERSION    "2.0"
+#define DRV_VERSION    "2.1"
 
 enum board_ids_enum {
        vt6420,
@@ -60,7 +60,7 @@ enum {
        SATA_PATA_SHARING       = 0x49, /* PATA/SATA sharing func ctrl */
        PATA_UDMA_TIMING        = 0xB3, /* PATA timing for DMA/ cable detect */
        PATA_PIO_TIMING         = 0xAB, /* PATA timing register */
-       
+
        PORT0                   = (1 << 1),
        PORT1                   = (1 << 0),
        ALL_PORTS               = PORT0 | PORT1,
@@ -134,7 +134,7 @@ static const struct ata_port_operations vt6420_sata_ops = {
 
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .freeze                 = svia_noop_freeze,
        .thaw                   = ata_bmdma_thaw,
@@ -143,13 +143,15 @@ static const struct ata_port_operations vt6420_sata_ops = {
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = ata_port_start,
 };
 
 static const struct ata_port_operations vt6421_pata_ops = {
        .port_disable           = ata_port_disable,
-       
+
        .set_piomode            = vt6421_set_pio_mode,
        .set_dmamode            = vt6421_set_dma_mode,
 
@@ -166,7 +168,7 @@ static const struct ata_port_operations vt6421_pata_ops = {
 
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
@@ -175,13 +177,15 @@ static const struct ata_port_operations vt6421_pata_ops = {
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .port_start             = vt6421_port_start,
 };
 
 static const struct ata_port_operations vt6421_sata_ops = {
        .port_disable           = ata_port_disable,
-       
+
        .tf_load                = ata_tf_load,
        .tf_read                = ata_tf_read,
        .check_status           = ata_check_status,
@@ -195,7 +199,7 @@ static const struct ata_port_operations vt6421_sata_ops = {
 
        .qc_prep                = ata_qc_prep,
        .qc_issue               = ata_qc_issue_prot,
-       .data_xfer              = ata_pio_data_xfer,
+       .data_xfer              = ata_data_xfer,
 
        .freeze                 = ata_bmdma_freeze,
        .thaw                   = ata_bmdma_thaw,
@@ -204,6 +208,8 @@ static const struct ata_port_operations vt6421_sata_ops = {
 
        .irq_handler            = ata_interrupt,
        .irq_clear              = ata_bmdma_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
 
        .scr_read               = svia_scr_read,
        .scr_write              = svia_scr_write,
@@ -230,14 +236,14 @@ static u32 svia_scr_read (struct ata_port *ap, unsigned int sc_reg)
 {
        if (sc_reg > SCR_CONTROL)
                return 0xffffffffU;
-       return inl(ap->ioaddr.scr_addr + (4 * sc_reg));
+       return ioread32(ap->ioaddr.scr_addr + (4 * sc_reg));
 }
 
 static void svia_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
 {
        if (sc_reg > SCR_CONTROL)
                return;
-       outl(val, ap->ioaddr.scr_addr + (4 * sc_reg));
+       iowrite32(val, ap->ioaddr.scr_addr + (4 * sc_reg));
 }
 
 static void svia_noop_freeze(struct ata_port *ap)
@@ -387,31 +393,28 @@ static const unsigned int vt6421_bar_sizes[] = {
        16, 16, 16, 16, 32, 128
 };
 
-static unsigned long svia_scr_addr(unsigned long addr, unsigned int port)
+static void __iomem * svia_scr_addr(void __iomem *addr, unsigned int port)
 {
        return addr + (port * 128);
 }
 
-static unsigned long vt6421_scr_addr(unsigned long addr, unsigned int port)
+static void __iomem * vt6421_scr_addr(void __iomem *addr, unsigned int port)
 {
        return addr + (port * 64);
 }
 
 static void vt6421_init_addrs(struct ata_probe_ent *probe_ent,
-                             struct pci_dev *pdev,
-                             unsigned int port)
+                             void __iomem * const *iomap, unsigned int port)
 {
-       unsigned long reg_addr = pci_resource_start(pdev, port);
-       unsigned long bmdma_addr = pci_resource_start(pdev, 4) + (port * 8);
-       unsigned long scr_addr;
+       void __iomem *reg_addr = iomap[port];
+       void __iomem *bmdma_addr = iomap[4] + (port * 8);
 
        probe_ent->port[port].cmd_addr = reg_addr;
        probe_ent->port[port].altstatus_addr =
-       probe_ent->port[port].ctl_addr = (reg_addr + 8) | ATA_PCI_CTL_OFS;
+       probe_ent->port[port].ctl_addr = (void __iomem *)
+               ((unsigned long)(reg_addr + 8) | ATA_PCI_CTL_OFS);
        probe_ent->port[port].bmdma_addr = bmdma_addr;
-
-       scr_addr = vt6421_scr_addr(pci_resource_start(pdev, 5), port);
-       probe_ent->port[port].scr_addr = scr_addr;
+       probe_ent->port[port].scr_addr = vt6421_scr_addr(iomap[5], port);
 
        ata_std_ports(&probe_ent->port[port]);
 }
@@ -420,16 +423,21 @@ static struct ata_probe_ent *vt6420_init_probe_ent(struct pci_dev *pdev)
 {
        struct ata_probe_ent *probe_ent;
        struct ata_port_info *ppi[2];
+       void __iomem *bar5;
 
        ppi[0] = ppi[1] = &vt6420_port_info;
        probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
        if (!probe_ent)
                return NULL;
 
-       probe_ent->port[0].scr_addr =
-               svia_scr_addr(pci_resource_start(pdev, 5), 0);
-       probe_ent->port[1].scr_addr =
-               svia_scr_addr(pci_resource_start(pdev, 5), 1);
+       bar5 = pcim_iomap(pdev, 5, 0);
+       if (!bar5) {
+               dev_printk(KERN_ERR, &pdev->dev, "failed to iomap PCI BAR 5\n");
+               return NULL;
+       }
+
+       probe_ent->port[0].scr_addr = svia_scr_addr(bar5, 0);
+       probe_ent->port[1].scr_addr = svia_scr_addr(bar5, 1);
 
        return probe_ent;
 }
@@ -457,8 +465,15 @@ static struct ata_probe_ent *vt6421_init_probe_ent(struct pci_dev *pdev)
        probe_ent->mwdma_mask   = 0x07;
        probe_ent->udma_mask    = 0x7f;
 
+       for (i = 0; i < 6; i++)
+               if (!pcim_iomap(pdev, i, 0)) {
+                       dev_printk(KERN_ERR, &pdev->dev,
+                                  "failed to iomap PCI BAR %d\n", i);
+                       return NULL;
+               }
+
        for (i = 0; i < N_PORTS; i++)
-               vt6421_init_addrs(probe_ent, pdev, i);
+               vt6421_init_addrs(probe_ent, pcim_iomap_table(pdev), i);
 
        return probe_ent;
 }