Skip to contentSkip to conversation

dt-bindings: power: reset: gpio-poweroff: Add 'timeout' property

PATCH In review Moritz Fischer 2 participants 3 messages Feb 15, 2018 – Feb 19, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dt-bindings: power: reset: gpio-poweroff: Add 'timeout' property

From: Moritz Fischer <[email protected]>

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

---
 Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt +8 -0
index e62d53d844cc..c2459c7d45d5 100644
@@ -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>;
+};
Signature · 6 lines
2.16.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

PATCH 2/2 power: reset: gpio-poweroff: Add support for timeout from DT

From: Moritz Fischer <[email protected]>

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

---
 drivers/power/reset/gpio-poweroff.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/power/reset/gpio-poweroff.c +8 -1
index be3d81ff51cc..bc9fad17d22a 100644
@@ -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);
Signature · 1 line
2.16.1
maintainer
#2 lore raw
In reply to Moritz Fischer
Quoted 15 lines · Moritz Fischer

From: Moritz Fischer <[email protected]>

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

---
 Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt +0 -0
index e62d53d844cc..c2459c7d45d5 100644

Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt Optional properties: · line 31

Quoted 5 lines
Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt +2 -0
@@ -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.

Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt gpio-poweroff { · line 43

Quoted 12 lines
Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt +5 -0
 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.

Quoted 4 lines
Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt +1 -0
+};
Signature · 1 line
2.16.1