Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
[sfrench/cifs-2.6.git] / drivers / ata / sata_fsl.c
index 01a5400bd7c533dc3f44f0dc4ce1da4804758a61..0f91e583892e19a4578501407d0b816584bac83e 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,
@@ -187,6 +186,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,
@@ -1043,12 +1047,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);
                                /*
@@ -1296,8 +1303,7 @@ static const struct ata_port_info sata_fsl_port_info[] = {
         },
 };
 
-static int sata_fsl_probe(struct platform_device *ofdev,
-                       const struct of_device_id *match)
+static int sata_fsl_probe(struct platform_device *ofdev)
 {
        int retval = -ENXIO;
        void __iomem *hcr_base = NULL;
@@ -1306,6 +1312,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 };
@@ -1320,6 +1327,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);
@@ -1434,7 +1447,7 @@ static struct of_device_id fsl_sata_match[] = {
 
 MODULE_DEVICE_TABLE(of, fsl_sata_match);
 
-static struct of_platform_driver fsl_sata_driver = {
+static struct platform_driver fsl_sata_driver = {
        .driver = {
                .name = "fsl-sata",
                .owner = THIS_MODULE,
@@ -1450,13 +1463,13 @@ static struct of_platform_driver fsl_sata_driver = {
 
 static int __init sata_fsl_init(void)
 {
-       of_register_platform_driver(&fsl_sata_driver);
+       platform_driver_register(&fsl_sata_driver);
        return 0;
 }
 
 static void __exit sata_fsl_exit(void)
 {
-       of_unregister_platform_driver(&fsl_sata_driver);
+       platform_driver_unregister(&fsl_sata_driver);
 }
 
 MODULE_LICENSE("GPL");