From: Christophe Kerello <christophe.kerello@foss.st.com>
To: <miquel.raynal@bootlin.com>, <richard@nod.at>, <vigneshr@ti.com>,
<krzysztof.kozlowski@linaro.org>, <robh+dt@kernel.org>,
<krzysztof.kozlowski+dt@linaro.org>, <conor+dt@kernel.org>
Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
<devicetree@vger.kernel.org>,
Christophe Kerello <christophe.kerello@foss.st.com>
Subject: [PATCH 07/12] memory: stm32-fmc2-ebi: add runtime PM support
Date: Mon, 12 Feb 2024 18:48:17 +0100 [thread overview]
Message-ID: <20240212174822.77734-8-christophe.kerello@foss.st.com> (raw)
In-Reply-To: <20240212174822.77734-1-christophe.kerello@foss.st.com>
Add runtime PM support in FMC2 ebi driver to be able to manage GENPD
support when it will be enabled.
Signed-off-by: Christophe Kerello <christophe.kerello@foss.st.com>
---
drivers/memory/stm32-fmc2-ebi.c | 40 ++++++++++++++++++++++++++-------
1 file changed, 32 insertions(+), 8 deletions(-)
diff --git a/drivers/memory/stm32-fmc2-ebi.c b/drivers/memory/stm32-fmc2-ebi.c
index 04248c15832f..8c30e56be3b0 100644
--- a/drivers/memory/stm32-fmc2-ebi.c
+++ b/drivers/memory/stm32-fmc2-ebi.c
@@ -11,6 +11,7 @@
#include <linux/of_platform.h>
#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/reset.h>
@@ -1381,6 +1382,7 @@ static int stm32_fmc2_ebi_probe(struct platform_device *pdev)
return -ENOMEM;
ebi->dev = dev;
+ platform_set_drvdata(pdev, ebi);
ebi->data = of_device_get_match_data(dev);
if (!ebi->data)
@@ -1398,10 +1400,14 @@ static int stm32_fmc2_ebi_probe(struct platform_device *pdev)
if (PTR_ERR(rstc) == -EPROBE_DEFER)
return -EPROBE_DEFER;
- ret = clk_prepare_enable(ebi->clk);
+ ret = devm_pm_runtime_enable(dev);
if (ret)
return ret;
+ ret = pm_runtime_resume_and_get(dev);
+ if (ret < 0)
+ return ret;
+
if (!IS_ERR(rstc)) {
reset_control_assert(rstc);
reset_control_deassert(rstc);
@@ -1432,7 +1438,6 @@ static int stm32_fmc2_ebi_probe(struct platform_device *pdev)
goto err_release;
stm32_fmc2_ebi_save_setup(ebi);
- platform_set_drvdata(pdev, ebi);
return 0;
@@ -1440,7 +1445,7 @@ static int stm32_fmc2_ebi_probe(struct platform_device *pdev)
stm32_fmc2_ebi_disable_banks(ebi);
stm32_fmc2_ebi_disable(ebi);
stm32_fmc2_ebi_put_sems(ebi);
- clk_disable_unprepare(ebi->clk);
+ pm_runtime_put_sync_suspend(dev);
return ret;
}
@@ -1453,7 +1458,23 @@ static void stm32_fmc2_ebi_remove(struct platform_device *pdev)
stm32_fmc2_ebi_disable_banks(ebi);
stm32_fmc2_ebi_disable(ebi);
stm32_fmc2_ebi_put_sems(ebi);
+ pm_runtime_put_sync_suspend(&pdev->dev);
+}
+
+static int __maybe_unused stm32_fmc2_ebi_runtime_suspend(struct device *dev)
+{
+ struct stm32_fmc2_ebi *ebi = dev_get_drvdata(dev);
+
clk_disable_unprepare(ebi->clk);
+
+ return 0;
+}
+
+static int __maybe_unused stm32_fmc2_ebi_runtime_resume(struct device *dev)
+{
+ struct stm32_fmc2_ebi *ebi = dev_get_drvdata(dev);
+
+ return clk_prepare_enable(ebi->clk);
}
static int __maybe_unused stm32_fmc2_ebi_suspend(struct device *dev)
@@ -1462,7 +1483,7 @@ static int __maybe_unused stm32_fmc2_ebi_suspend(struct device *dev)
stm32_fmc2_ebi_disable(ebi);
stm32_fmc2_ebi_put_sems(ebi);
- clk_disable_unprepare(ebi->clk);
+ pm_runtime_put_sync_suspend(dev);
pinctrl_pm_select_sleep_state(dev);
return 0;
@@ -1475,8 +1496,8 @@ static int __maybe_unused stm32_fmc2_ebi_resume(struct device *dev)
pinctrl_pm_select_default_state(dev);
- ret = clk_prepare_enable(ebi->clk);
- if (ret)
+ ret = pm_runtime_resume_and_get(dev);
+ if (ret < 0)
return ret;
stm32_fmc2_ebi_get_sems(ebi);
@@ -1486,8 +1507,11 @@ static int __maybe_unused stm32_fmc2_ebi_resume(struct device *dev)
return 0;
}
-static SIMPLE_DEV_PM_OPS(stm32_fmc2_ebi_pm_ops, stm32_fmc2_ebi_suspend,
- stm32_fmc2_ebi_resume);
+static const struct dev_pm_ops stm32_fmc2_ebi_pm_ops = {
+ SET_RUNTIME_PM_OPS(stm32_fmc2_ebi_runtime_suspend,
+ stm32_fmc2_ebi_runtime_resume, NULL)
+ SET_SYSTEM_SLEEP_PM_OPS(stm32_fmc2_ebi_suspend, stm32_fmc2_ebi_resume)
+};
static const struct stm32_fmc2_ebi_data stm32_fmc2_ebi_mp1_data = {
.rnb_for_nand = false,
--
2.25.1
next prev parent reply other threads:[~2024-02-12 17:51 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-12 17:48 [PATCH 00/12] Add MP25 FMC2 support Christophe Kerello
2024-02-12 17:48 ` [PATCH 01/12] dt-bindings: memory-controller: st,stm32: add MP25 support Christophe Kerello
2024-02-12 18:30 ` Conor Dooley
2024-02-13 10:56 ` Christophe Kerello
2024-02-12 17:48 ` [PATCH 02/12] dt-bindings: memory-controller: st,stm32: add 'power-domains' property Christophe Kerello
2024-02-12 18:33 ` Conor Dooley
2024-02-13 10:57 ` Christophe Kerello
2024-02-13 11:57 ` Krzysztof Kozlowski
2024-02-13 15:57 ` Christophe Kerello
2024-02-14 10:07 ` Krzysztof Kozlowski
2024-02-12 17:48 ` [PATCH 03/12] memory: stm32-fmc2-ebi: add a platform data structure Christophe Kerello
2024-02-12 17:48 ` [PATCH 04/12] memory: stm32-fmc2-ebi: add MP25 support Christophe Kerello
2024-02-13 7:36 ` Krzysztof Kozlowski
2024-02-13 12:29 ` Christophe Kerello
2024-02-12 17:48 ` [PATCH 05/12] memory: stm32-fmc2-ebi: update the driver to support revision 2 Christophe Kerello
2024-02-13 7:46 ` Krzysztof Kozlowski
2024-02-13 12:36 ` Christophe Kerello
2024-02-12 17:48 ` [PATCH 06/12] memory: stm32-fmc2-ebi: add RIF support Christophe Kerello
2024-02-13 7:52 ` Krzysztof Kozlowski
2024-02-13 13:15 ` Christophe Kerello
2024-02-14 10:07 ` Krzysztof Kozlowski
2024-02-15 9:00 ` Christophe Kerello
2024-02-15 18:56 ` Krzysztof Kozlowski
2024-02-16 8:15 ` Christophe Kerello
2024-02-12 17:48 ` Christophe Kerello [this message]
2024-02-13 7:59 ` [PATCH 07/12] memory: stm32-fmc2-ebi: add runtime PM support Krzysztof Kozlowski
2024-02-13 13:31 ` Christophe Kerello
2024-02-13 13:33 ` Krzysztof Kozlowski
2024-02-12 17:48 ` [PATCH 08/12] dt-bindings: mtd: st,stm32: add MP25 support Christophe Kerello
2024-02-12 18:38 ` Conor Dooley
2024-02-13 10:57 ` Christophe Kerello
2024-02-12 17:48 ` [PATCH 09/12] mtd: rawnand: stm32_fmc2: use dma_get_slave_caps to get DMA max burst Christophe Kerello
2024-02-12 17:48 ` [PATCH 10/12] mtd: rawnand: stm32_fmc2: add a platform data structure Christophe Kerello
2024-02-12 17:48 ` [PATCH 11/12] mtd: rawnand: stm32_fmc2: add MP25 support Christophe Kerello
2024-02-12 17:48 ` [PATCH 12/12] mtd: rawnand: stm32_fmc2: update the driver to support revision 2 Christophe Kerello
2024-02-13 7:34 ` [PATCH 00/12] Add MP25 FMC2 support Krzysztof Kozlowski
2024-02-13 12:09 ` Christophe Kerello
2024-02-14 10:02 ` Krzysztof Kozlowski
2024-02-16 17:59 ` Christophe Kerello
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=20240212174822.77734-8-christophe.kerello@foss.st.com \
--to=christophe.kerello@foss.st.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=robh+dt@kernel.org \
--cc=vigneshr@ti.com \
/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
all inboxes | Powered by JetHome®