devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout' property
@ 2018-02-15 20:49 Moritz Fischer
  2018-02-15 20:49 ` [PATCH 2/2] power: reset: gpio-poweroff: Add support for timeout from DT Moritz Fischer
  2018-02-19 15:59 ` [PATCH 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout' property Rob Herring
  0 siblings, 2 replies; 3+ messages in thread
From: Moritz Fischer @ 2018-02-15 20:49 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA, mark.rutland-5wv7dgnIgG8,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, sre-DgEjT+Ai2ygdnm+yROfE0A,
	Moritz Fischer

From: Moritz Fischer <mdf-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

Add 'timeout' property to support boards where the 3s timeout that the
current driver defaults to is too short.

Signed-off-by: Moritz Fischer <mdf-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
 Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt b/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
index e62d53d844cc..c2459c7d45d5 100644
--- a/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
+++ b/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
@@ -27,6 +27,8 @@ Optional properties:
   it to an output when the power-off handler is called. If this optional
   property is not specified, the GPIO is initialized as an output in its
   inactive state.
+- timeout: Time to wait before asserting a WARN_ON(1). If nothing is
+           specified, 3000 ms is used.
 
 Examples:
 
@@ -34,3 +36,9 @@ gpio-poweroff {
 	compatible = "gpio-poweroff";
 	gpios = <&gpio 4 0>;
 };
+
+gpio-poweroff {
+	compatible = "gpio-poweroff";
+	gpios = <&gpio 4 0>;
+	timeout = <3000>;
+};
-- 
2.16.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 2/2] power: reset: gpio-poweroff: Add support for timeout from DT
  2018-02-15 20:49 [PATCH 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout' property Moritz Fischer
@ 2018-02-15 20:49 ` Moritz Fischer
  2018-02-19 15:59 ` [PATCH 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout' property Rob Herring
  1 sibling, 0 replies; 3+ messages in thread
From: Moritz Fischer @ 2018-02-15 20:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: devicetree, linux-pm, mark.rutland, robh+dt, sre, Moritz Fischer

From: Moritz Fischer <mdf@kernel.org>

Add support for reading a timeout value from devicetree.
Fall back to previous default of 3s if nothing is specified.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/power/reset/gpio-poweroff.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/power/reset/gpio-poweroff.c b/drivers/power/reset/gpio-poweroff.c
index be3d81ff51cc..bc9fad17d22a 100644
--- a/drivers/power/reset/gpio-poweroff.c
+++ b/drivers/power/reset/gpio-poweroff.c
@@ -19,11 +19,13 @@
 #include <linux/of_platform.h>
 #include <linux/module.h>
 
+#define DEFAULT_TIMEOUT_MS 3000
 /*
  * Hold configuration here, cannot be more than one instance of the driver
  * since pm_power_off itself is global.
  */
 static struct gpio_desc *reset_gpio;
+static u32 timeout;
 
 static void gpio_poweroff_do_poweroff(void)
 {
@@ -40,7 +42,7 @@ static void gpio_poweroff_do_poweroff(void)
 	gpiod_set_value(reset_gpio, 1);
 
 	/* give it some time */
-	mdelay(3000);
+	mdelay(timeout);
 
 	WARN_ON(1);
 }
@@ -49,6 +51,7 @@ static int gpio_poweroff_probe(struct platform_device *pdev)
 {
 	bool input = false;
 	enum gpiod_flags flags;
+	int ret;
 
 	/* If a pm_power_off function has already been added, leave it alone */
 	if (pm_power_off != NULL) {
@@ -64,6 +67,10 @@ static int gpio_poweroff_probe(struct platform_device *pdev)
 	else
 		flags = GPIOD_OUT_LOW;
 
+	ret = of_property_read_u32(pdev->dev.of_node, "timeout", &timeout);
+	if (ret)
+		timeout = DEFAULT_TIMEOUT_MS;
+
 	reset_gpio = devm_gpiod_get(&pdev->dev, NULL, flags);
 	if (IS_ERR(reset_gpio))
 		return PTR_ERR(reset_gpio);
-- 
2.16.1

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

* Re: [PATCH 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout' property
  2018-02-15 20:49 [PATCH 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout' property Moritz Fischer
  2018-02-15 20:49 ` [PATCH 2/2] power: reset: gpio-poweroff: Add support for timeout from DT Moritz Fischer
@ 2018-02-19 15:59 ` Rob Herring
  1 sibling, 0 replies; 3+ messages in thread
From: Rob Herring @ 2018-02-19 15:59 UTC (permalink / raw)
  To: Moritz Fischer
  Cc: linux-kernel, devicetree, linux-pm, mark.rutland, sre, Moritz Fischer

On Thu, Feb 15, 2018 at 12:49:25PM -0800, Moritz Fischer wrote:
> From: Moritz Fischer <mdf@kernel.org>
> 
> Add 'timeout' property to support boards where the 3s timeout that the
> current driver defaults to is too short.
> 
> Signed-off-by: Moritz Fischer <mdf@kernel.org>
> ---
>  Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt b/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
> index e62d53d844cc..c2459c7d45d5 100644
> --- a/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
> +++ b/Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
> @@ -27,6 +27,8 @@ Optional properties:
>    it to an output when the power-off handler is called. If this optional
>    property is not specified, the GPIO is initialized as an output in its
>    inactive state.
> +- timeout: Time to wait before asserting a WARN_ON(1). If nothing is
> +           specified, 3000 ms is used.

Needs unit suffix as defined in property-units.txt.

>  
>  Examples:
>  
> @@ -34,3 +36,9 @@ gpio-poweroff {
>  	compatible = "gpio-poweroff";
>  	gpios = <&gpio 4 0>;
>  };
> +
> +gpio-poweroff {
> +	compatible = "gpio-poweroff";
> +	gpios = <&gpio 4 0>;
> +	timeout = <3000>;

Just add to the existing example.

> +};
> -- 
> 2.16.1
> 

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

end of thread, other threads:[~2018-02-19 15:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-15 20:49 [PATCH 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout' property Moritz Fischer
2018-02-15 20:49 ` [PATCH 2/2] power: reset: gpio-poweroff: Add support for timeout from DT Moritz Fischer
2018-02-19 15:59 ` [PATCH 1/2] dt-bindings: power: reset: gpio-poweroff: Add 'timeout' property Rob Herring

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