#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"
struct sata_rcar_priv {
void __iomem *base;
- struct clk *clk;
enum sata_rcar_type type;
};
return -ENOMEM;
priv->type = (enum sata_rcar_type)of_device_get_match_data(dev);
- priv->clk = devm_clk_get(dev, NULL);
- if (IS_ERR(priv->clk)) {
- dev_err(dev, "failed to get access to sata clock\n");
- return PTR_ERR(priv->clk);
- }
- 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(dev, 1);
if (!host) {
dev_err(dev, "ata_host_alloc failed\n");
ret = -ENOMEM;
- goto cleanup;
+ goto err_pm_put;
}
host->private_data = priv;
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 */
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;
}
iowrite32(0, base + SATAINTSTAT_REG);
iowrite32(0x7ff, base + SATAINTMASK_REG);
- clk_disable_unprepare(priv->clk);
+ pm_runtime_put(&pdev->dev);
+ pm_runtime_disable(&pdev->dev);
return 0;
}
/* mask */
iowrite32(0x7ff, base + SATAINTMASK_REG);
- clk_disable_unprepare(priv->clk);
+ pm_runtime_put(dev);
}
return ret;
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) {
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);