[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210506010440.7016-7-peng.fan@oss.nxp.com>
Date: Thu, 6 May 2021 09:04:33 +0800
From: "Peng Fan (OSS)" <peng.fan@....nxp.com>
To: robh+dt@...nel.org, shawnguo@...nel.org, s.hauer@...gutronix.de
Cc: kernel@...gutronix.de, festevam@...il.com, linux-imx@....com,
p.zabel@...gutronix.de, l.stach@...gutronix.de, krzk@...nel.org,
agx@...xcpu.org, marex@...x.de, andrew.smirnov@...il.com,
devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, ping.bai@....com,
frieder.schrempf@...tron.de, aford173@...il.com, abel.vesa@....com,
Peng Fan <peng.fan@....com>
Subject: [PATCH V2 06/13] soc: imx: gpcv2: add runtime PM support for power-domains
From: Lucas Stach <l.stach@...gutronix.de>
This allows to nest domains into other power domains and have the
parent domain powered up/down as required by the child domains.
Reviewed-by: Frieder Schrempf <frieder.schrempf@...tron.de>
Signed-off-by: Lucas Stach <l.stach@...gutronix.de>
Signed-off-by: Peng Fan <peng.fan@....com>
---
drivers/soc/imx/gpcv2.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c
index 558b8b8af9af..bfea8560cb64 100644
--- a/drivers/soc/imx/gpcv2.c
+++ b/drivers/soc/imx/gpcv2.c
@@ -12,6 +12,7 @@
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
+#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/sizes.h>
@@ -141,11 +142,17 @@ static int imx_pgc_power_up(struct generic_pm_domain *genpd)
u32 reg_val;
int ret;
+ ret = pm_runtime_get_sync(domain->dev);
+ if (ret < 0) {
+ pm_runtime_put_noidle(domain->dev);
+ return ret;
+ }
+
if (!IS_ERR(domain->regulator)) {
ret = regulator_enable(domain->regulator);
if (ret) {
dev_err(domain->dev, "failed to enable regulator\n");
- return ret;
+ goto out_put_pm;
}
}
@@ -204,6 +211,8 @@ static int imx_pgc_power_up(struct generic_pm_domain *genpd)
out_regulator_disable:
if (!IS_ERR(domain->regulator))
regulator_disable(domain->regulator);
+out_put_pm:
+ pm_runtime_put(domain->dev);
return ret;
}
@@ -266,6 +275,8 @@ static int imx_pgc_power_down(struct generic_pm_domain *genpd)
}
}
+ pm_runtime_put(domain->dev);
+
return 0;
out_clk_disable:
@@ -523,6 +534,8 @@ static int imx_pgc_domain_probe(struct platform_device *pdev)
return dev_err_probe(domain->dev, domain->num_clks,
"Failed to get domain's clocks\n");
+ pm_runtime_enable(domain->dev);
+
regmap_update_bits(domain->regmap, GPC_PGC_CPU_MAPPING,
domain->bits.map, domain->bits.map);
@@ -546,6 +559,7 @@ static int imx_pgc_domain_probe(struct platform_device *pdev)
out_domain_unmap:
regmap_update_bits(domain->regmap, GPC_PGC_CPU_MAPPING,
domain->bits.map, 0);
+ pm_runtime_disable(domain->dev);
return ret;
}
@@ -560,6 +574,8 @@ static int imx_pgc_domain_remove(struct platform_device *pdev)
regmap_update_bits(domain->regmap, GPC_PGC_CPU_MAPPING,
domain->bits.map, 0);
+ pm_runtime_disable(domain->dev);
+
return 0;
}
--
2.30.0
Powered by blists - more mailing lists