linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: Shawn Guo <shawnguo@kernel.org>, Rob Herring <robh+dt@kernel.org>
Cc: Marek Vasut <marex@denx.de>,
	devicetree@vger.kernel.org, Fabio Estevam <festevam@gmail.com>,
	Frieder Schrempf <frieder.schrempf@kontron.de>,
	patchwork-lst@pengutronix.de, NXP Linux Team <linux-imx@nxp.com>,
	kernel@pengutronix.de, Adam Ford <aford173@gmail.com>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 06/13] soc: imx: gpcv2: add runtime PM support for power-domains
Date: Thu,  5 Nov 2020 18:44:27 +0100	[thread overview]
Message-ID: <20201105174434.1817539-7-l.stach@pengutronix.de> (raw)
In-Reply-To: <20201105174434.1817539-1-l.stach@pengutronix.de>

This allows to nest domains into other power domains and have the
parent domain powered up/down as required by the child domains.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 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 d27025e37a9e..87165619a689 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) {
+		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;
 		}
 	}
 
@@ -200,6 +207,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;
 }
@@ -262,6 +271,8 @@ static int imx_pgc_power_down(struct generic_pm_domain *genpd)
 		}
 	}
 
+	pm_runtime_put(domain->dev);
+
 	return 0;
 
 out_clk_disable:
@@ -519,6 +530,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);
 
@@ -542,6 +555,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;
 }
@@ -556,6 +570,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.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-11-05 17:46 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-05 17:44 [PATCH v2 00/13] i.MX8MM power domain support Lucas Stach
2020-11-05 17:44 ` [PATCH v2 01/13] soc: imx: gpcv2: move to more ideomatic error handling in probe Lucas Stach
2020-11-16 14:10   ` Adam Ford
2020-11-05 17:44 ` [PATCH v2 02/13] soc: imx: gpcv2: move domain mapping to domain driver probe Lucas Stach
2020-11-05 17:44 ` [PATCH v2 03/13] soc: imx: gpcv2: switch to clk_bulk_* API Lucas Stach
2020-11-05 17:44 ` [PATCH v2 04/13] soc: imx: gpcv2: split power up and power down sequence control Lucas Stach
2020-11-05 17:44 ` [PATCH v2 05/13] soc: imx: gpcv2: wait for ADB400 handshake Lucas Stach
2020-11-05 17:44 ` Lucas Stach [this message]
2020-11-05 17:44 ` [PATCH v2 07/13] soc: imx: gpcv2: allow domains without power-sequence control Lucas Stach
2020-11-05 17:44 ` [PATCH v2 08/13] dt-bindings: imx: gpcv2: add support for optional resets Lucas Stach
2020-11-09 20:15   ` Rob Herring
2020-11-17 14:11     ` Lucas Stach
2020-11-30  9:57       ` Lucas Stach
2021-02-10 14:35         ` Lucas Stach
2021-02-10 14:42           ` Marek Vasut
2021-04-26  9:24           ` Frieder Schrempf
2021-04-29 14:38             ` Frieder Schrempf
2021-03-22 18:19       ` Adam Ford
2020-11-05 17:44 ` [PATCH v2 09/13] soc: " Lucas Stach
2020-11-05 17:44 ` [PATCH v2 10/13] dt-bindings: add defines for i.MX8MM power domains Lucas Stach
2020-11-09 20:34   ` Rob Herring
2020-11-05 17:44 ` [PATCH v2 11/13] soc: imx: gpcv2: add support " Lucas Stach
2020-11-05 17:44 ` [PATCH v2 12/13] arm64: dts: imx8mm: add GPC node and " Lucas Stach
2020-12-09 15:26   ` Frieder Schrempf
2021-01-14 10:39     ` Frieder Schrempf
2021-02-18 12:54       ` Adam Ford
2021-02-18 15:19         ` Adam Ford
2021-03-02 15:01           ` Frieder Schrempf
2021-03-02 16:46             ` Adam Ford
2020-11-05 17:44 ` [PATCH v2 13/13] arm64: dts: imx8mm: put USB controllers into power-domains Lucas Stach
2021-05-06  1:04 [PATCH V2 00/13] soc: imx: gpcv2: support i.MX8MM Peng Fan (OSS)
2021-05-06  1:04 ` [PATCH V2 06/13] soc: imx: gpcv2: add runtime PM support for power-domains Peng Fan (OSS)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201105174434.1817539-7-l.stach@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=aford173@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=frieder.schrempf@kontron.de \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=marex@denx.de \
    --cc=patchwork-lst@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).