Merge branch 'next' of git://git.monstr.eu/linux-2.6-microblaze
[firefly-linux-kernel-4.4.55.git] / drivers / ata / sata_fsl.c
index b0214d00d50bb469de76b40fb8a4f81f70cbb161..7f9eab34a386be7d44ef7690156f2dd882fa32f9 100644 (file)
@@ -33,8 +33,7 @@ enum {
        SATA_FSL_MAX_PRD_USABLE = SATA_FSL_MAX_PRD - 1,
        SATA_FSL_MAX_PRD_DIRECT = 16,   /* Direct PRDT entries */
 
-       SATA_FSL_HOST_FLAGS     = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
-                               ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
+       SATA_FSL_HOST_FLAGS     = (ATA_FLAG_SATA | ATA_FLAG_PIO_DMA |
                                ATA_FLAG_PMP | ATA_FLAG_NCQ | ATA_FLAG_AN),
 
        SATA_FSL_MAX_CMDS       = SATA_FSL_QUEUE_DEPTH,
@@ -186,6 +185,11 @@ enum {
        COMMANDSTAT = 0x20,
 };
 
+/* TRANSCFG (transport-layer) configuration control */
+enum {
+       TRANSCFG_RX_WATER_MARK = (1 << 4),
+};
+
 /* PHY (link-layer) configuration control */
 enum {
        PHY_BIST_ENABLE = 0x01,
@@ -1040,12 +1044,15 @@ static void sata_fsl_error_intr(struct ata_port *ap)
 
                /* find out the offending link and qc */
                if (ap->nr_pmp_links) {
+                       unsigned int dev_num;
+
                        dereg = ioread32(hcr_base + DE);
                        iowrite32(dereg, hcr_base + DE);
                        iowrite32(cereg, hcr_base + CE);
 
-                       if (dereg < ap->nr_pmp_links) {
-                               link = &ap->pmp_link[dereg];
+                       dev_num = ffs(dereg) - 1;
+                       if (dev_num < ap->nr_pmp_links && dereg != 0) {
+                               link = &ap->pmp_link[dev_num];
                                ehi = &link->eh_info;
                                qc = ata_qc_from_tag(ap, link->active_tag);
                                /*
@@ -1303,6 +1310,7 @@ static int sata_fsl_probe(struct platform_device *ofdev,
        struct sata_fsl_host_priv *host_priv = NULL;
        int irq;
        struct ata_host *host;
+       u32 temp;
 
        struct ata_port_info pi = sata_fsl_port_info[0];
        const struct ata_port_info *ppi[] = { &pi, NULL };
@@ -1317,6 +1325,12 @@ static int sata_fsl_probe(struct platform_device *ofdev,
        ssr_base = hcr_base + 0x100;
        csr_base = hcr_base + 0x140;
 
+       if (!of_device_is_compatible(ofdev->dev.of_node, "fsl,mpc8315-sata")) {
+               temp = ioread32(csr_base + TRANSCFG);
+               temp = temp & 0xffffffe0;
+               iowrite32(temp | TRANSCFG_RX_WATER_MARK, csr_base + TRANSCFG);
+       }
+
        DPRINTK("@reset i/o = 0x%x\n", ioread32(csr_base + TRANSCFG));
        DPRINTK("sizeof(cmd_desc) = %d\n", sizeof(struct command_desc));
        DPRINTK("sizeof(#define cmd_desc) = %d\n", SATA_FSL_CMD_DESC_SIZE);