diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-24 13:20:33 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-24 13:20:33 -0700 |
commit | 0519359784328bfa92bf0931bf0cff3b58c16932 (patch) | |
tree | 71ab4638b4f0bf86c76eb2b12de01303f6b1f5bf /drivers/ata/sata_rcar.c | |
parent | 596766102a3a37ba20c4d9a4130a8a4b42b34646 (diff) | |
parent | 2d17f460c5d79fa9fc794e813377f3276acf81ce (diff) |
Merge branch 'for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
Pull libata updates from Tejun Heo:
"Nothing too interesting. Mostly ahci and ahci_platform changes, many
around power management"
* 'for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: (22 commits)
ata: ahci_platform: enable to get and control reset
ata: libahci_platform: add reset control support
ata: add an extra argument to ahci_platform_get_resources()
ata: sata_rcar: Add r8a77965 support
ata: sata_rcar: exclude setting of PHY registers in Gen3
ata: sata_rcar: really mask all interrupts on Gen2 and later
Revert "ata: ahci_platform: allow disabling of hotplug to save power"
ata: libahci: Allow reconfigure of DEVSLP register
ata: libahci: Correct setting of DEVSLP register
ata: ahci: Enable DEVSLP by default on x86 with SLP_S0
ata: ahci: Support state with min power but Partial low power state
Revert "ata: ahci_platform: convert kcalloc to devm_kcalloc"
ata: sata_rcar: Add rudimentary Runtime PM support
ata: sata_rcar: Provide a short-hand for &pdev->dev
ata: Only output sg element mapped number in verbose debug
ata: Guard ata_scsi_dump_cdb() by ATA_VERBOSE_DEBUG
ata: ahci_platform: convert kcalloc to devm_kcalloc
ata: ahci_platform: convert kzallloc to kcalloc
ata: ahci_platform: correct parameter documentation for ahci_platform_shutdown
libata: remove ata_sff_data_xfer_noirq()
...
Diffstat (limited to 'drivers/ata/sata_rcar.c')
-rw-r--r-- | drivers/ata/sata_rcar.c | 76 |
1 files changed, 39 insertions, 37 deletions
diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c index 6456e07db72a..10ecb232245d 100644 --- a/drivers/ata/sata_rcar.c +++ b/drivers/ata/sata_rcar.c @@ -17,7 +17,7 @@ #include <linux/libata.h> #include <linux/of_device.h> #include <linux/platform_device.h> -#include <linux/clk.h> +#include <linux/pm_runtime.h> #include <linux/err.h> #define DRV_NAME "sata_rcar" @@ -109,6 +109,8 @@ #define SATAINTMASK_ERRMSK BIT(2) #define SATAINTMASK_ERRCRTMSK BIT(1) #define SATAINTMASK_ATAMSK BIT(0) +#define SATAINTMASK_ALL_GEN1 0x7ff +#define SATAINTMASK_ALL_GEN2 0xfff #define SATA_RCAR_INT_MASK (SATAINTMASK_SERRMSK | \ SATAINTMASK_ATAMSK) @@ -152,7 +154,7 @@ enum sata_rcar_type { struct sata_rcar_priv { void __iomem *base; - struct clk *clk; + u32 sataint_mask; enum sata_rcar_type type; }; @@ -226,7 +228,7 @@ static void sata_rcar_freeze(struct ata_port *ap) struct sata_rcar_priv *priv = ap->host->private_data; /* mask */ - iowrite32(0x7ff, priv->base + SATAINTMASK_REG); + iowrite32(priv->sataint_mask, priv->base + SATAINTMASK_REG); ata_sff_freeze(ap); } @@ -242,7 +244,7 @@ static void sata_rcar_thaw(struct ata_port *ap) ata_sff_thaw(ap); /* unmask */ - iowrite32(0x7ff & ~SATA_RCAR_INT_MASK, base + SATAINTMASK_REG); + iowrite32(priv->sataint_mask & ~SATA_RCAR_INT_MASK, base + SATAINTMASK_REG); } static void sata_rcar_ioread16_rep(void __iomem *reg, void *buffer, int count) @@ -736,7 +738,7 @@ static irqreturn_t sata_rcar_interrupt(int irq, void *dev_instance) if (!sataintstat) goto done; /* ack */ - iowrite32(~sataintstat & 0x7ff, base + SATAINTSTAT_REG); + iowrite32(~sataintstat & priv->sataint_mask, base + SATAINTSTAT_REG); ap = host->ports[0]; @@ -809,7 +811,7 @@ static void sata_rcar_init_module(struct sata_rcar_priv *priv) /* ack and mask */ iowrite32(0, base + SATAINTSTAT_REG); - iowrite32(0x7ff, base + SATAINTMASK_REG); + iowrite32(priv->sataint_mask, base + SATAINTMASK_REG); /* enable interrupts */ iowrite32(ATAPI_INT_ENABLE_SATAINT, base + ATAPI_INT_ENABLE_REG); @@ -819,16 +821,20 @@ static void sata_rcar_init_controller(struct ata_host *host) { struct sata_rcar_priv *priv = host->private_data; + priv->sataint_mask = SATAINTMASK_ALL_GEN2; + /* reset and setup phy */ switch (priv->type) { case RCAR_GEN1_SATA: + priv->sataint_mask = SATAINTMASK_ALL_GEN1; sata_rcar_gen1_phy_init(priv); break; case RCAR_GEN2_SATA: - case RCAR_GEN3_SATA: case RCAR_R8A7790_ES1_SATA: sata_rcar_gen2_phy_init(priv); break; + case RCAR_GEN3_SATA: + break; default: dev_warn(host->dev, "SATA phy is not initialized\n"); break; @@ -881,6 +887,7 @@ MODULE_DEVICE_TABLE(of, sata_rcar_match); static int sata_rcar_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct ata_host *host; struct sata_rcar_priv *priv; struct resource *mem; @@ -891,36 +898,31 @@ static int sata_rcar_probe(struct platform_device *pdev) if (irq <= 0) return -EINVAL; - priv = devm_kzalloc(&pdev->dev, sizeof(struct sata_rcar_priv), - GFP_KERNEL); + priv = devm_kzalloc(dev, sizeof(struct sata_rcar_priv), GFP_KERNEL); if (!priv) return -ENOMEM; - priv->type = (enum sata_rcar_type)of_device_get_match_data(&pdev->dev); - priv->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(priv->clk)) { - dev_err(&pdev->dev, "failed to get access to sata clock\n"); - return PTR_ERR(priv->clk); - } + priv->type = (enum sata_rcar_type)of_device_get_match_data(dev); - ret = clk_prepare_enable(priv->clk); - if (ret) - return ret; + pm_runtime_enable(dev); + ret = pm_runtime_get_sync(dev); + if (ret < 0) + goto err_pm_disable; - host = ata_host_alloc(&pdev->dev, 1); + host = ata_host_alloc(dev, 1); if (!host) { - dev_err(&pdev->dev, "ata_host_alloc failed\n"); + dev_err(dev, "ata_host_alloc failed\n"); ret = -ENOMEM; - goto cleanup; + goto err_pm_put; } host->private_data = priv; mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - priv->base = devm_ioremap_resource(&pdev->dev, mem); + priv->base = devm_ioremap_resource(dev, mem); if (IS_ERR(priv->base)) { ret = PTR_ERR(priv->base); - goto cleanup; + goto err_pm_put; } /* setup port */ @@ -934,9 +936,10 @@ static int sata_rcar_probe(struct platform_device *pdev) if (!ret) return 0; -cleanup: - clk_disable_unprepare(priv->clk); - +err_pm_put: + pm_runtime_put(dev); +err_pm_disable: + pm_runtime_disable(dev); return ret; } @@ -952,9 +955,10 @@ static int sata_rcar_remove(struct platform_device *pdev) iowrite32(0, base + ATAPI_INT_ENABLE_REG); /* ack and mask */ iowrite32(0, base + SATAINTSTAT_REG); - iowrite32(0x7ff, base + SATAINTMASK_REG); + iowrite32(priv->sataint_mask, base + SATAINTMASK_REG); - clk_disable_unprepare(priv->clk); + pm_runtime_put(&pdev->dev); + pm_runtime_disable(&pdev->dev); return 0; } @@ -972,9 +976,9 @@ static int sata_rcar_suspend(struct device *dev) /* disable interrupts */ iowrite32(0, base + ATAPI_INT_ENABLE_REG); /* mask */ - iowrite32(0x7ff, base + SATAINTMASK_REG); + iowrite32(priv->sataint_mask, base + SATAINTMASK_REG); - clk_disable_unprepare(priv->clk); + pm_runtime_put(dev); } return ret; @@ -987,17 +991,16 @@ static int sata_rcar_resume(struct device *dev) void __iomem *base = priv->base; int ret; - ret = clk_prepare_enable(priv->clk); - if (ret) + ret = pm_runtime_get_sync(dev); + if (ret < 0) return ret; if (priv->type == RCAR_GEN3_SATA) { - sata_rcar_gen2_phy_init(priv); sata_rcar_init_module(priv); } else { /* ack and mask */ iowrite32(0, base + SATAINTSTAT_REG); - iowrite32(0x7ff, base + SATAINTMASK_REG); + iowrite32(priv->sataint_mask, base + SATAINTMASK_REG); /* enable interrupts */ iowrite32(ATAPI_INT_ENABLE_SATAINT, @@ -1012,11 +1015,10 @@ static int sata_rcar_resume(struct device *dev) static int sata_rcar_restore(struct device *dev) { struct ata_host *host = dev_get_drvdata(dev); - struct sata_rcar_priv *priv = host->private_data; int ret; - ret = clk_prepare_enable(priv->clk); - if (ret) + ret = pm_runtime_get_sync(dev); + if (ret < 0) return ret; sata_rcar_setup_port(host); |