linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] remoteproc: stm32: allow wdg irq to be a wakeup source
@ 2019-08-26 15:38 Fabien Dessenne
  2019-08-26 15:38 ` [PATCH 1/2] dt-bindings: remoteproc: stm32: add wakeup-source Fabien Dessenne
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Fabien Dessenne @ 2019-08-26 15:38 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Maxime Coquelin, Alexandre Torgue,
	Ohad Ben-Cohen, Bjorn Andersson, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, linux-remoteproc
  Cc: Arnaud Pouliquen, Loic Pallardy, Fabien Dessenne

The watchdog IRQ which notifies the remote processor crash is used by the
remoteproc framework to perform a recovery procedure.
Since this IRQ may be fired when the Linux system is suspended, this IRQ may
be configured to wake up the system.

Fabien Dessenne (2):
  dt-bindings: remoteproc: stm32: add wakeup-source
  remoteproc: stm32: wakeup the system by wdg irq

 .../devicetree/bindings/remoteproc/stm32-rproc.txt |  3 ++
 drivers/remoteproc/stm32_rproc.c                   | 47 ++++++++++++++++++++++
 2 files changed, 50 insertions(+)

-- 
2.7.4


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] dt-bindings: remoteproc: stm32: add wakeup-source
  2019-08-26 15:38 [PATCH 0/2] remoteproc: stm32: allow wdg irq to be a wakeup source Fabien Dessenne
@ 2019-08-26 15:38 ` Fabien Dessenne
  2019-08-29 22:57   ` Rob Herring
  2019-08-26 15:38 ` [PATCH 2/2] remoteproc: stm32: wakeup the system by wdg irq Fabien Dessenne
  2019-10-10 15:16 ` [PATCH 0/2] remoteproc: stm32: allow wdg irq to be a wakeup source Fabien DESSENNE
  2 siblings, 1 reply; 5+ messages in thread
From: Fabien Dessenne @ 2019-08-26 15:38 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Maxime Coquelin, Alexandre Torgue,
	Ohad Ben-Cohen, Bjorn Andersson, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, linux-remoteproc
  Cc: Arnaud Pouliquen, Loic Pallardy, Fabien Dessenne

Add the "wakeup-source" property: if the optional wdg interrupt is
defined, then this property may be defined too.

Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
---
 Documentation/devicetree/bindings/remoteproc/stm32-rproc.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/remoteproc/stm32-rproc.txt b/Documentation/devicetree/bindings/remoteproc/stm32-rproc.txt
index 5fa915a..ac54b5b 100644
--- a/Documentation/devicetree/bindings/remoteproc/stm32-rproc.txt
+++ b/Documentation/devicetree/bindings/remoteproc/stm32-rproc.txt
@@ -21,6 +21,9 @@ Required properties:
 
 Optional properties:
 - interrupts:	Should contain the watchdog interrupt
+- wakeup-source: Flag indicating whether remoteproc can wake up the system by
+		the watchdog interrupt. Only meaningful if the "interrupts"
+		property is defined.
 - mboxes:	This property is required only if the rpmsg/virtio functionality
 		is used. List of phandle and mailbox channel specifiers:
 		- a channel (a) used to communicate through virtqueues with the
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] remoteproc: stm32: wakeup the system by wdg irq
  2019-08-26 15:38 [PATCH 0/2] remoteproc: stm32: allow wdg irq to be a wakeup source Fabien Dessenne
  2019-08-26 15:38 ` [PATCH 1/2] dt-bindings: remoteproc: stm32: add wakeup-source Fabien Dessenne
@ 2019-08-26 15:38 ` Fabien Dessenne
  2019-10-10 15:16 ` [PATCH 0/2] remoteproc: stm32: allow wdg irq to be a wakeup source Fabien DESSENNE
  2 siblings, 0 replies; 5+ messages in thread
From: Fabien Dessenne @ 2019-08-26 15:38 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Maxime Coquelin, Alexandre Torgue,
	Ohad Ben-Cohen, Bjorn Andersson, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, linux-remoteproc
  Cc: Arnaud Pouliquen, Loic Pallardy, Fabien Dessenne

If the device node defines the 'wakeup-source' property, use the WDG
exti IRQ as a wakeup source of the system.

Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
---
 drivers/remoteproc/stm32_rproc.c | 47 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
index 2cf4b29..7ed8895 100644
--- a/drivers/remoteproc/stm32_rproc.c
+++ b/drivers/remoteproc/stm32_rproc.c
@@ -15,6 +15,7 @@
 #include <linux/of_address.h>
 #include <linux/of_device.h>
 #include <linux/of_reserved_mem.h>
+#include <linux/pm_wakeirq.h>
 #include <linux/regmap.h>
 #include <linux/remoteproc.h>
 #include <linux/reset.h>
@@ -65,6 +66,7 @@ struct stm32_rproc {
 	struct reset_control *rst;
 	struct stm32_syscon hold_boot;
 	struct stm32_syscon pdds;
+	int wdg_irq;
 	u32 nb_rmems;
 	struct stm32_rproc_mem *rmems;
 	struct stm32_mbox mb[MBOX_NB_MBX];
@@ -528,6 +530,13 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev)
 			return err;
 		}
 
+		ddata->wdg_irq = irq;
+
+		if (of_property_read_bool(np, "wakeup-source")) {
+			device_init_wakeup(dev, true);
+			dev_pm_set_wake_irq(dev, irq);
+		}
+
 		dev_info(dev, "wdg irq registered\n");
 	}
 
@@ -607,6 +616,10 @@ static int stm32_rproc_probe(struct platform_device *pdev)
 free_mb:
 	stm32_rproc_free_mbox(rproc);
 free_rproc:
+	if (device_may_wakeup(dev)) {
+		dev_pm_clear_wake_irq(dev);
+		device_init_wakeup(dev, false);
+	}
 	rproc_free(rproc);
 	return ret;
 }
@@ -614,22 +627,56 @@ static int stm32_rproc_probe(struct platform_device *pdev)
 static int stm32_rproc_remove(struct platform_device *pdev)
 {
 	struct rproc *rproc = platform_get_drvdata(pdev);
+	struct device *dev = &pdev->dev;
 
 	if (atomic_read(&rproc->power) > 0)
 		rproc_shutdown(rproc);
 
 	rproc_del(rproc);
 	stm32_rproc_free_mbox(rproc);
+
+	if (device_may_wakeup(dev)) {
+		dev_pm_clear_wake_irq(dev);
+		device_init_wakeup(dev, false);
+	}
 	rproc_free(rproc);
 
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int stm32_rproc_suspend(struct device *dev)
+{
+	struct rproc *rproc = dev_get_drvdata(dev);
+	struct stm32_rproc *ddata = rproc->priv;
+
+	if (device_may_wakeup(dev))
+		return enable_irq_wake(ddata->wdg_irq);
+
+	return 0;
+}
+
+static int stm32_rproc_resume(struct device *dev)
+{
+	struct rproc *rproc = dev_get_drvdata(dev);
+	struct stm32_rproc *ddata = rproc->priv;
+
+	if (device_may_wakeup(dev))
+		return disable_irq_wake(ddata->wdg_irq);
+
+	return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(stm32_rproc_pm_ops,
+			 stm32_rproc_suspend, stm32_rproc_resume);
+
 static struct platform_driver stm32_rproc_driver = {
 	.probe = stm32_rproc_probe,
 	.remove = stm32_rproc_remove,
 	.driver = {
 		.name = "stm32-rproc",
+		.pm = &stm32_rproc_pm_ops,
 		.of_match_table = of_match_ptr(stm32_rproc_match),
 	},
 };
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] dt-bindings: remoteproc: stm32: add wakeup-source
  2019-08-26 15:38 ` [PATCH 1/2] dt-bindings: remoteproc: stm32: add wakeup-source Fabien Dessenne
@ 2019-08-29 22:57   ` Rob Herring
  0 siblings, 0 replies; 5+ messages in thread
From: Rob Herring @ 2019-08-29 22:57 UTC (permalink / raw)
  To: Fabien Dessenne
  Cc: Mark Rutland, Ohad Ben-Cohen, Alexandre Torgue, Loic Pallardy,
	devicetree, Arnaud Pouliquen, linux-remoteproc, linux-kernel,
	Fabien Dessenne, Bjorn Andersson, Maxime Coquelin, linux-stm32,
	linux-arm-kernel

On Mon, 26 Aug 2019 17:38:42 +0200, Fabien Dessenne wrote:
> Add the "wakeup-source" property: if the optional wdg interrupt is
> defined, then this property may be defined too.
> 
> Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
> ---
>  Documentation/devicetree/bindings/remoteproc/stm32-rproc.txt | 3 +++
>  1 file changed, 3 insertions(+)
> 

Acked-by: Rob Herring <robh@kernel.org>

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 0/2] remoteproc: stm32: allow wdg irq to be a wakeup source
  2019-08-26 15:38 [PATCH 0/2] remoteproc: stm32: allow wdg irq to be a wakeup source Fabien Dessenne
  2019-08-26 15:38 ` [PATCH 1/2] dt-bindings: remoteproc: stm32: add wakeup-source Fabien Dessenne
  2019-08-26 15:38 ` [PATCH 2/2] remoteproc: stm32: wakeup the system by wdg irq Fabien Dessenne
@ 2019-10-10 15:16 ` Fabien DESSENNE
  2 siblings, 0 replies; 5+ messages in thread
From: Fabien DESSENNE @ 2019-10-10 15:16 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Maxime Coquelin, Alexandre TORGUE,
	Ohad Ben-Cohen, Bjorn Andersson, devicetree, linux-stm32,
	linux-arm-kernel, linux-kernel, linux-remoteproc
  Cc: Arnaud POULIQUEN, Loic PALLARDY

Hi

I Got Rob's Reviewed-by for the bindings. Any further comments for the driver part?

Fabien

> -----Original Message-----
> From: Fabien DESSENNE <fabien.dessenne@st.com>
> Sent: lundi 26 août 2019 17:39
> To: Rob Herring <robh+dt@kernel.org>; Mark Rutland <mark.rutland@arm.com>;
> Maxime Coquelin <mcoquelin.stm32@gmail.com>; Alexandre TORGUE
> <alexandre.torgue@st.com>; Ohad Ben-Cohen <ohad@wizery.com>; Bjorn
> Andersson <bjorn.andersson@linaro.org>; devicetree@vger.kernel.org; linux-
> stm32@st-md-mailman.stormreply.com; linux-arm-kernel@lists.infradead.org;
> linux-kernel@vger.kernel.org; linux-remoteproc@vger.kernel.org
> Cc: Fabien DESSENNE <fabien.dessenne@st.com>; Loic PALLARDY
> <loic.pallardy@st.com>; Arnaud POULIQUEN <arnaud.pouliquen@st.com>
> Subject: [PATCH 0/2] remoteproc: stm32: allow wdg irq to be a wakeup source
> 
> The watchdog IRQ which notifies the remote processor crash is used by the
> remoteproc framework to perform a recovery procedure.
> Since this IRQ may be fired when the Linux system is suspended, this IRQ may
> be configured to wake up the system.
> 
> Fabien Dessenne (2):
>   dt-bindings: remoteproc: stm32: add wakeup-source
>   remoteproc: stm32: wakeup the system by wdg irq
> 
>  .../devicetree/bindings/remoteproc/stm32-rproc.txt |  3 ++
>  drivers/remoteproc/stm32_rproc.c                   | 47 ++++++++++++++++++++++
>  2 files changed, 50 insertions(+)
> 
> --
> 2.7.4


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-10-10 15:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-26 15:38 [PATCH 0/2] remoteproc: stm32: allow wdg irq to be a wakeup source Fabien Dessenne
2019-08-26 15:38 ` [PATCH 1/2] dt-bindings: remoteproc: stm32: add wakeup-source Fabien Dessenne
2019-08-29 22:57   ` Rob Herring
2019-08-26 15:38 ` [PATCH 2/2] remoteproc: stm32: wakeup the system by wdg irq Fabien Dessenne
2019-10-10 15:16 ` [PATCH 0/2] remoteproc: stm32: allow wdg irq to be a wakeup source Fabien DESSENNE

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).