]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/scsi/sata_sil.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
[karo-tx-linux.git] / drivers / scsi / sata_sil.c
index 7d43cd3a50fcbda16afa00c86e0e1517063fd960..7aabb45c35e58b6e62f243c37bebe3941c7249c8 100644 (file)
 #include <linux/libata.h>
 
 #define DRV_NAME       "sata_sil"
-#define DRV_VERSION    "1.0"
+#define DRV_VERSION    "2.0"
 
 enum {
        /*
         * host flags
         */
+       SIL_FLAG_NO_SATA_IRQ    = (1 << 28),
        SIL_FLAG_RERR_ON_DMA_ACT = (1 << 29),
        SIL_FLAG_MOD15WRITE     = (1 << 30),
 
        SIL_DFL_HOST_FLAGS      = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
-                                 ATA_FLAG_MMIO,
+                                 ATA_FLAG_MMIO | ATA_FLAG_HRST_TO_RESUME,
 
        /*
         * Controller IDs
         */
        sil_3112                = 0,
-       sil_3512                = 1,
-       sil_3114                = 2,
+       sil_3112_no_sata_irq    = 1,
+       sil_3512                = 2,
+       sil_3114                = 3,
 
        /*
         * Register offsets
@@ -123,8 +125,8 @@ static const struct pci_device_id sil_pci_tbl[] = {
        { 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3512 },
        { 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 },
        { 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
-       { 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
-       { 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
+       { 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_no_sata_irq },
+       { 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_no_sata_irq },
        { }     /* terminate list */
 };
 
@@ -186,7 +188,6 @@ static const struct ata_port_operations sil_ops = {
        .check_status           = ata_check_status,
        .exec_command           = ata_exec_command,
        .dev_select             = ata_std_dev_select,
-       .probe_reset            = ata_std_probe_reset,
        .post_set_mode          = sil_post_set_mode,
        .bmdma_setup            = ata_bmdma_setup,
        .bmdma_start            = ata_bmdma_start,
@@ -218,6 +219,16 @@ static const struct ata_port_info sil_port_info[] = {
                .udma_mask      = 0x3f,                 /* udma0-5 */
                .port_ops       = &sil_ops,
        },
+       /* sil_3112_no_sata_irq */
+       {
+               .sht            = &sil_sht,
+               .host_flags     = SIL_DFL_HOST_FLAGS | SIL_FLAG_MOD15WRITE |
+                                 SIL_FLAG_NO_SATA_IRQ,
+               .pio_mask       = 0x1f,                 /* pio0-4 */
+               .mwdma_mask     = 0x07,                 /* mwdma0-2 */
+               .udma_mask      = 0x3f,                 /* udma0-5 */
+               .port_ops       = &sil_ops,
+       },
        /* sil_3512 */
        {
                .sht            = &sil_sht,
@@ -344,6 +355,29 @@ static void sil_host_intr(struct ata_port *ap, u32 bmdma2)
        struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->active_tag);
        u8 status;
 
+       if (unlikely(bmdma2 & SIL_DMA_SATA_IRQ)) {
+               u32 serror;
+
+               /* SIEN doesn't mask SATA IRQs on some 3112s.  Those
+                * controllers continue to assert IRQ as long as
+                * SError bits are pending.  Clear SError immediately.
+                */
+               serror = sil_scr_read(ap, SCR_ERROR);
+               sil_scr_write(ap, SCR_ERROR, serror);
+
+               /* Trigger hotplug and accumulate SError only if the
+                * port isn't already frozen.  Otherwise, PHY events
+                * during hardreset makes controllers with broken SIEN
+                * repeat probing needlessly.
+                */
+               if (!(ap->flags & ATA_FLAG_FROZEN)) {
+                       ata_ehi_hotplugged(&ap->eh_info);
+                       ap->eh_info.serror |= serror;
+               }
+
+               goto freeze;
+       }
+
        if (unlikely(!qc || qc->tf.ctl & ATA_NIEN))
                goto freeze;
 
@@ -415,7 +449,12 @@ static irqreturn_t sil_interrupt(int irq, void *dev_instance,
                if (unlikely(!ap || ap->flags & ATA_FLAG_DISABLED))
                        continue;
 
-               if (!(bmdma2 & SIL_DMA_COMPLETE))
+               /* turn off SATA_IRQ if not supported */
+               if (ap->flags & SIL_FLAG_NO_SATA_IRQ)
+                       bmdma2 &= ~SIL_DMA_SATA_IRQ;
+
+               if (bmdma2 == 0xffffffff ||
+                   !(bmdma2 & (SIL_DMA_COMPLETE | SIL_DMA_SATA_IRQ)))
                        continue;
 
                sil_host_intr(ap, bmdma2);
@@ -432,6 +471,9 @@ static void sil_freeze(struct ata_port *ap)
        void __iomem *mmio_base = ap->host_set->mmio_base;
        u32 tmp;
 
+       /* global IRQ mask doesn't block SATA IRQ, turn off explicitly */
+       writel(0, mmio_base + sil_port[ap->port_no].sien);
+
        /* plug IRQ */
        tmp = readl(mmio_base + SIL_SYSCFG);
        tmp |= SIL_MASK_IDE0_INT << ap->port_no;
@@ -448,6 +490,10 @@ static void sil_thaw(struct ata_port *ap)
        ata_chk_status(ap);
        ata_bmdma_irq_clear(ap);
 
+       /* turn on SATA IRQ if supported */
+       if (!(ap->flags & SIL_FLAG_NO_SATA_IRQ))
+               writel(SIL_SIEN_N, mmio_base + sil_port[ap->port_no].sien);
+
        /* turn on IRQ */
        tmp = readl(mmio_base + SIL_SYSCFG);
        tmp &= ~(SIL_MASK_IDE0_INT << ap->port_no);
@@ -562,7 +608,7 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        probe_ent->mwdma_mask = sil_port_info[ent->driver_data].mwdma_mask;
        probe_ent->udma_mask = sil_port_info[ent->driver_data].udma_mask;
                probe_ent->irq = pdev->irq;
-               probe_ent->irq_flags = SA_SHIRQ;
+               probe_ent->irq_flags = IRQF_SHARED;
        probe_ent->host_flags = sil_port_info[ent->driver_data].host_flags;
 
        mmio_base = pci_iomap(pdev, 5, 0);
@@ -621,11 +667,6 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
                               mmio_base + sil_port[2].bmdma);
        }
 
-       /* mask all SATA phy-related interrupts */
-       /* TODO: unmask bit 6 (SError N bit) for hotplug */
-       for (i = 0; i < probe_ent->n_ports; i++)
-               writel(0, mmio_base + sil_port[i].sien);
-
        pci_set_master(pdev);
 
        /* FIXME: check ata_device_add return value */