driver, touch, gt9xx: enable regulator default
[firefly-linux-kernel-4.4.55.git] / drivers / ata / sata_fsl.c
index 38a2389f5b1bc86abc0baae3fda3f9ab20956cd4..a723ae92978310f64e65eeef44509337a027c8a5 100644 (file)
@@ -24,6 +24,8 @@
 #include <scsi/scsi_cmnd.h>
 #include <linux/libata.h>
 #include <asm/io.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
 #include <linux/of_platform.h>
 
 static unsigned int intr_coalescing_count;
@@ -43,7 +45,8 @@ enum {
        SATA_FSL_MAX_PRD_DIRECT = 16,   /* Direct PRDT entries */
 
        SATA_FSL_HOST_FLAGS     = (ATA_FLAG_SATA | ATA_FLAG_PIO_DMA |
-                               ATA_FLAG_PMP | ATA_FLAG_NCQ | ATA_FLAG_AN),
+                                  ATA_FLAG_PMP | ATA_FLAG_NCQ |
+                                  ATA_FLAG_AN | ATA_FLAG_NO_LOG_PAGE),
 
        SATA_FSL_MAX_CMDS       = SATA_FSL_QUEUE_DEPTH,
        SATA_FSL_CMD_HDR_SIZE   = 16,   /* 4 DWORDS */
@@ -732,13 +735,12 @@ static int sata_fsl_port_start(struct ata_port *ap)
        if (!pp)
                return -ENOMEM;
 
-       mem = dma_alloc_coherent(dev, SATA_FSL_PORT_PRIV_DMA_SZ, &mem_dma,
-                                GFP_KERNEL);
+       mem = dma_zalloc_coherent(dev, SATA_FSL_PORT_PRIV_DMA_SZ, &mem_dma,
+                                 GFP_KERNEL);
        if (!mem) {
                kfree(pp);
                return -ENOMEM;
        }
-       memset(mem, 0, SATA_FSL_PORT_PRIV_DMA_SZ);
 
        pp->cmdslot = mem;
        pp->cmdslot_paddr = mem_dma;
@@ -772,20 +774,6 @@ static int sata_fsl_port_start(struct ata_port *ap)
        VPRINTK("HControl = 0x%x\n", ioread32(hcr_base + HCONTROL));
        VPRINTK("CHBA  = 0x%x\n", ioread32(hcr_base + CHBA));
 
-#ifdef CONFIG_MPC8315_DS
-       /*
-        * Workaround for 8315DS board 3gbps link-up issue,
-        * currently limit SATA port to GEN1 speed
-        */
-       sata_fsl_scr_read(&ap->link, SCR_CONTROL, &temp);
-       temp &= ~(0xF << 4);
-       temp |= (0x1 << 4);
-       sata_fsl_scr_write(&ap->link, SCR_CONTROL, temp);
-
-       sata_fsl_scr_read(&ap->link, SCR_CONTROL, &temp);
-       dev_warn(dev, "scr_control, speed limited to %x\n", temp);
-#endif
-
        return 0;
 }
 
@@ -882,6 +870,8 @@ try_offline_again:
         */
        ata_msleep(ap, 1);
 
+       sata_set_spd(link);
+
        /*
         * Now, bring the host controller online again, this can take time
         * as PHY reset and communication establishment, 1st D2H FIS and
@@ -1533,7 +1523,7 @@ static int sata_fsl_probe(struct platform_device *ofdev)
        ata_host_activate(host, irq, sata_fsl_interrupt, SATA_FSL_IRQ_FLAG,
                          &sata_fsl_sht);
 
-       dev_set_drvdata(&ofdev->dev, host);
+       platform_set_drvdata(ofdev, host);
 
        host_priv->intr_coalescing.show = fsl_sata_intr_coalescing_show;
        host_priv->intr_coalescing.store = fsl_sata_intr_coalescing_store;
@@ -1559,10 +1549,8 @@ static int sata_fsl_probe(struct platform_device *ofdev)
 
 error_exit_with_cleanup:
 
-       if (host) {
-               dev_set_drvdata(&ofdev->dev, NULL);
+       if (host)
                ata_host_detach(host);
-       }
 
        if (hcr_base)
                iounmap(hcr_base);
@@ -1573,7 +1561,7 @@ error_exit_with_cleanup:
 
 static int sata_fsl_remove(struct platform_device *ofdev)
 {
-       struct ata_host *host = dev_get_drvdata(&ofdev->dev);
+       struct ata_host *host = platform_get_drvdata(ofdev);
        struct sata_fsl_host_priv *host_priv = host->private_data;
 
        device_remove_file(&ofdev->dev, &host_priv->intr_coalescing);
@@ -1581,8 +1569,6 @@ static int sata_fsl_remove(struct platform_device *ofdev)
 
        ata_host_detach(host);
 
-       dev_set_drvdata(&ofdev->dev, NULL);
-
        irq_dispose_mapping(host_priv->irq);
        iounmap(host_priv->hcr_base);
        kfree(host_priv);
@@ -1590,16 +1576,16 @@ static int sata_fsl_remove(struct platform_device *ofdev)
        return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int sata_fsl_suspend(struct platform_device *op, pm_message_t state)
 {
-       struct ata_host *host = dev_get_drvdata(&op->dev);
+       struct ata_host *host = platform_get_drvdata(op);
        return ata_host_suspend(host, state);
 }
 
 static int sata_fsl_resume(struct platform_device *op)
 {
-       struct ata_host *host = dev_get_drvdata(&op->dev);
+       struct ata_host *host = platform_get_drvdata(op);
        struct sata_fsl_host_priv *host_priv = host->private_data;
        int ret;
        void __iomem *hcr_base = host_priv->hcr_base;
@@ -1641,12 +1627,11 @@ MODULE_DEVICE_TABLE(of, fsl_sata_match);
 static struct platform_driver fsl_sata_driver = {
        .driver = {
                .name = "fsl-sata",
-               .owner = THIS_MODULE,
                .of_match_table = fsl_sata_match,
        },
        .probe          = sata_fsl_probe,
        .remove         = sata_fsl_remove,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = sata_fsl_suspend,
        .resume         = sata_fsl_resume,
 #endif