From: Benjamin Gaignard <benjamin.gaignard@linaro.org>
To: mchehab@kernel.org, mcoquelin.stm32@gmail.com,
alexandre.torgue@st.com, hans.verkuil@cisco.com
Cc: linux-media@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Benjamin Gaignard <benjamin.gaignard@linaro.org>
Subject: [PATCH 2/2] cec: stm32: add suspend/resume functions
Date: Thu, 15 Mar 2018 10:29:49 +0100 [thread overview]
Message-ID: <20180315092949.9895-3-benjamin.gaignard@st.com> (raw)
In-Reply-To: <20180315092949.9895-1-benjamin.gaignard@st.com>
From: Benjamin Gaignard <benjamin.gaignard@linaro.org>
If wake up irq is defined in device-tree cec adapter
could be used has wake up source.
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
---
drivers/media/platform/stm32/stm32-cec.c | 44 +++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/stm32/stm32-cec.c b/drivers/media/platform/stm32/stm32-cec.c
index 35cc2ffd6b96..68e18ee6655b 100644
--- a/drivers/media/platform/stm32/stm32-cec.c
+++ b/drivers/media/platform/stm32/stm32-cec.c
@@ -11,8 +11,11 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
+#include <linux/of_irq.h>
#include <linux/platform_device.h>
+#include <linux/pinctrl/consumer.h>
#include <linux/pm_runtime.h>
+#include <linux/pm_wakeirq.h>
#include <linux/regmap.h>
#include <media/cec.h>
@@ -243,7 +246,7 @@ static int stm32_cec_probe(struct platform_device *pdev)
struct resource *res;
struct stm32_cec *cec;
void __iomem *mmio;
- int ret;
+ int ret, wakeirq;
cec = devm_kzalloc(&pdev->dev, sizeof(*cec), GFP_KERNEL);
if (!cec)
@@ -274,6 +277,12 @@ static int stm32_cec_probe(struct platform_device *pdev)
if (ret)
return ret;
+ wakeirq = of_irq_get_byname(pdev->dev.of_node, "wakeup");
+ if (wakeirq > 0) {
+ device_init_wakeup(&pdev->dev, true);
+ dev_pm_set_dedicated_wake_irq(&pdev->dev, wakeirq);
+ }
+
cec->clk_cec = devm_clk_get(&pdev->dev, "cec");
if (IS_ERR(cec->clk_cec)) {
dev_err(&pdev->dev, "Cannot get cec clock\n");
@@ -312,12 +321,44 @@ static int stm32_cec_remove(struct platform_device *pdev)
{
struct stm32_cec *cec = platform_get_drvdata(pdev);
+ dev_pm_clear_wake_irq(&pdev->dev);
+ device_init_wakeup(&pdev->dev, false);
+
cec_unregister_adapter(cec->adap);
pm_runtime_disable(&pdev->dev);
return 0;
}
+
+static int __maybe_unused stm32_cec_suspend(struct device *dev)
+{
+ struct stm32_cec *cec = dev_get_drvdata(dev);
+
+ pm_runtime_force_suspend(dev);
+
+ if (device_may_wakeup(dev))
+ enable_irq_wake(cec->irq);
+
+ pinctrl_pm_select_sleep_state(dev);
+
+ return 0;
+}
+
+static int __maybe_unused stm32_cec_resume(struct device *dev)
+{
+ struct stm32_cec *cec = dev_get_drvdata(dev);
+
+ pinctrl_pm_select_default_state(dev);
+
+ if (device_may_wakeup(dev))
+ disable_irq_wake(cec->irq);
+
+ pm_runtime_force_resume(dev);
+
+ return 0;
+}
+
static int __maybe_unused stm32_cec_runtime_suspend(struct device *dev)
{
struct stm32_cec *cec = dev_get_drvdata(dev);
@@ -341,6 +382,7 @@ static int __maybe_unused stm32_cec_runtime_resume(struct device *dev)
static const struct dev_pm_ops stm32_cec_pm_ops = {
SET_RUNTIME_PM_OPS(stm32_cec_runtime_suspend, stm32_cec_runtime_resume,
NULL)
+ SET_SYSTEM_SLEEP_PM_OPS(stm32_cec_suspend, stm32_cec_resume)
};
static const struct of_device_id stm32_cec_of_match[] = {
--
2.15.0
prev parent reply other threads:[~2018-03-15 9:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-15 9:29 [PATCH 0/2] cec: stm32: add wakeup support Benjamin Gaignard
2018-03-15 9:29 ` [PATCH 1/2] cec: stm32: simplify clock management Benjamin Gaignard
2018-03-15 9:29 ` Benjamin Gaignard [this message]
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=20180315092949.9895-3-benjamin.gaignard@st.com \
--to=benjamin.gaignard@linaro.org \
--cc=alexandre.torgue@st.com \
--cc=hans.verkuil@cisco.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mcoquelin.stm32@gmail.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®