libata: add comment documenting PIO latency issues on UP
[safe/jmp/linux-2.6] / drivers / ata / sata_sis.c
index 9089c7a..f8a91bf 100644 (file)
@@ -64,8 +64,8 @@ enum {
 };
 
 static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
-static int sis_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val);
-static int sis_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val);
+static int sis_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
+static int sis_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
 
 static const struct pci_device_id sis_pci_tbl[] = {
        { PCI_VDEVICE(SI, 0x0180), sis_180 },   /* SiS 964/180 */
@@ -97,8 +97,8 @@ static struct ata_port_operations sis_ops = {
 
 static const struct ata_port_info sis_port_info = {
        .flags          = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
-       .pio_mask       = 0x1f,
-       .mwdma_mask     = 0x7,
+       .pio_mask       = ATA_PIO4,
+       .mwdma_mask     = ATA_MWDMA2,
        .udma_mask      = ATA_UDMA6,
        .port_ops       = &sis_ops,
 };
@@ -109,8 +109,9 @@ MODULE_LICENSE("GPL");
 MODULE_DEVICE_TABLE(pci, sis_pci_tbl);
 MODULE_VERSION(DRV_VERSION);
 
-static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg)
+static unsigned int get_scr_cfg_addr(struct ata_link *link, unsigned int sc_reg)
 {
+       struct ata_port *ap = link->ap;
        struct pci_dev *pdev = to_pci_dev(ap->host->dev);
        unsigned int addr = SIS_SCR_BASE + (4 * sc_reg);
        u8 pmr;
@@ -131,93 +132,62 @@ static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg)
                        break;
                }
        }
+       if (link->pmp)
+               addr += 0x10;
+
        return addr;
 }
 
-static u32 sis_scr_cfg_read(struct ata_port *ap, unsigned int sc_reg, u32 *val)
+static u32 sis_scr_cfg_read(struct ata_link *link,
+                           unsigned int sc_reg, u32 *val)
 {
-       struct pci_dev *pdev = to_pci_dev(ap->host->dev);
-       unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg);
-       u32 val2 = 0;
-       u8 pmr;
+       struct pci_dev *pdev = to_pci_dev(link->ap->host->dev);
+       unsigned int cfg_addr = get_scr_cfg_addr(link, sc_reg);
 
        if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */
-               return 0xffffffff;
-
-       pci_read_config_byte(pdev, SIS_PMR, &pmr);
+               return -EINVAL;
 
        pci_read_config_dword(pdev, cfg_addr, val);
-
-       if ((pdev->device == 0x0182) || (pdev->device == 0x0183) ||
-           (pdev->device == 0x1182) || (pmr & SIS_PMR_COMBINED))
-               pci_read_config_dword(pdev, cfg_addr+0x10, &val2);
-
-       *val |= val2;
-       *val &= 0xfffffffb;     /* avoid problems with powerdowned ports */
-
        return 0;
 }
 
-static void sis_scr_cfg_write(struct ata_port *ap, unsigned int sc_reg, u32 val)
+static int sis_scr_cfg_write(struct ata_link *link,
+                            unsigned int sc_reg, u32 val)
 {
-       struct pci_dev *pdev = to_pci_dev(ap->host->dev);
-       unsigned int cfg_addr = get_scr_cfg_addr(ap, sc_reg);
-       u8 pmr;
-
-       if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */
-               return;
-
-       pci_read_config_byte(pdev, SIS_PMR, &pmr);
+       struct pci_dev *pdev = to_pci_dev(link->ap->host->dev);
+       unsigned int cfg_addr = get_scr_cfg_addr(link, sc_reg);
 
        pci_write_config_dword(pdev, cfg_addr, val);
-
-       if ((pdev->device == 0x0182) || (pdev->device == 0x0183) ||
-           (pdev->device == 0x1182) || (pmr & SIS_PMR_COMBINED))
-               pci_write_config_dword(pdev, cfg_addr+0x10, val);
+       return 0;
 }
 
-static int sis_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val)
+static int sis_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val)
 {
-       struct pci_dev *pdev = to_pci_dev(ap->host->dev);
-       u8 pmr;
+       struct ata_port *ap = link->ap;
+       void __iomem *base = ap->ioaddr.scr_addr + link->pmp * 0x10;
 
        if (sc_reg > SCR_CONTROL)
                return -EINVAL;
 
        if (ap->flags & SIS_FLAG_CFGSCR)
-               return sis_scr_cfg_read(ap, sc_reg, val);
-
-       pci_read_config_byte(pdev, SIS_PMR, &pmr);
-
-       *val = ioread32(ap->ioaddr.scr_addr + (sc_reg * 4));
-
-       if ((pdev->device == 0x0182) || (pdev->device == 0x0183) ||
-           (pdev->device == 0x1182) || (pmr & SIS_PMR_COMBINED))
-               *val |= ioread32(ap->ioaddr.scr_addr + (sc_reg * 4) + 0x10);
-
-       *val &= 0xfffffffb;
+               return sis_scr_cfg_read(link, sc_reg, val);
 
+       *val = ioread32(base + sc_reg * 4);
        return 0;
 }
 
-static int sis_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val)
+static int sis_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
 {
-       struct pci_dev *pdev = to_pci_dev(ap->host->dev);
-       u8 pmr;
+       struct ata_port *ap = link->ap;
+       void __iomem *base = ap->ioaddr.scr_addr + link->pmp * 0x10;
 
        if (sc_reg > SCR_CONTROL)
                return -EINVAL;
 
-       pci_read_config_byte(pdev, SIS_PMR, &pmr);
-
        if (ap->flags & SIS_FLAG_CFGSCR)
-               sis_scr_cfg_write(ap, sc_reg, val);
-       else {
-               iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4));
-               if ((pdev->device == 0x0182) || (pdev->device == 0x0183) ||
-                   (pdev->device == 0x1182) || (pmr & SIS_PMR_COMBINED))
-                       iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4)+0x10);
-       }
+               return sis_scr_cfg_write(link, sc_reg, val);
+
+       iowrite32(val, base + (sc_reg * 4));
        return 0;
 }
 
@@ -230,7 +200,7 @@ static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        u32 genctl, val;
        u8 pmr;
        u8 port2_start = 0x20;
-       int rc;
+       int i, rc;
 
        if (!printed_version++)
                dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
@@ -309,10 +279,21 @@ static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                break;
        }
 
-       rc = ata_pci_prepare_sff_host(pdev, ppi, &host);
+       rc = ata_pci_sff_prepare_host(pdev, ppi, &host);
        if (rc)
                return rc;
 
+       for (i = 0; i < 2; i++) {
+               struct ata_port *ap = host->ports[i];
+
+               if (ap->flags & ATA_FLAG_SATA &&
+                   ap->flags & ATA_FLAG_SLAVE_POSS) {
+                       rc = ata_slave_link_init(ap);
+                       if (rc)
+                               return rc;
+               }
+       }
+
        if (!(pi.flags & SIS_FLAG_CFGSCR)) {
                void __iomem *mmio;
 
@@ -327,8 +308,8 @@ static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        pci_set_master(pdev);
        pci_intx(pdev, 1);
-       return ata_host_activate(host, pdev->irq, ata_interrupt, IRQF_SHARED,
-                                &sis_sht);
+       return ata_host_activate(host, pdev->irq, ata_sff_interrupt,
+                                IRQF_SHARED, &sis_sht);
 }
 
 static int __init sis_init(void)