Skip to contentSkip to conversation

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

PATCH In review Moritz Fischer 3 participants 4 messages Feb 22, 2018 – Mar 9, 2018

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

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

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

---

Changes from v2:
- Addressed Rob's feedback (timeout_ms -> timeout-ms)

Changes from v1:
- Addressed Rob's feedback (timeout -> timeout_ms)
- Added to old example rather than creating separate one

---

 Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt +3 -0
index e62d53d844cc..6d8980c18c34 100644
@@ -27,10 +27,13 @@ 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-ms: Time to wait before asserting a WARN_ON(1). If nothing is
+              specified, 3000 ms is used.
 
 Examples:
 
 gpio-poweroff {
 	compatible = "gpio-poweroff";
 	gpios = <&gpio 4 0>;
+	timeout-ms = <3000>;
 };
Signature · 1 line
2.16.1
#1 lore raw

PATCH v3 2/2 power: reset: gpio-poweroff: Support for timeout from device property

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

---
Changes from v2:
- use device_property_read_{bool,u32} instead of of equivalent

Changes from v1:
- of_property_read_u32() overwrites the output only if it succeeds, simplify error handling
---

 drivers/power/reset/gpio-poweroff.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/power/reset/gpio-poweroff.c +6 -2
index be3d81ff51cc..6273ad3b411d 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 = DEFAULT_TIMEOUT_MS;
 
 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);
 }
@@ -58,12 +60,14 @@ static int gpio_poweroff_probe(struct platform_device *pdev)
 		return -EBUSY;
 	}
 
-	input = of_property_read_bool(pdev->dev.of_node, "input");
+	input = device_property_read_bool(&pdev->dev, "input");
 	if (input)
 		flags = GPIOD_IN;
 	else
 		flags = GPIOD_OUT_LOW;
 
+	device_property_read_u32(&pdev->dev, "timeout-ms", &timeout);
+
 	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
#2 lore raw

Re: [PATCH v3 2/2] power: reset: gpio-poweroff: Support for timeout from device property

Hi,

Quoted 5 lines · Moritz Fischer

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

---

Thanks, both queued.

-- Sebastian

Quoted 57 lines

Changes from v2:
- use device_property_read_{bool,u32} instead of of equivalent

Changes from v1:
- of_property_read_u32() overwrites the output only if it succeeds, simplify error handling
---

 drivers/power/reset/gpio-poweroff.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/power/reset/gpio-poweroff.c +6 -2
index be3d81ff51cc..6273ad3b411d 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 = DEFAULT_TIMEOUT_MS;
 
 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);
 }
@@ -58,12 +60,14 @@ static int gpio_poweroff_probe(struct platform_device *pdev)
 		return -EBUSY;
 	}
 
-	input = of_property_read_bool(pdev->dev.of_node, "input");
+	input = device_property_read_bool(&pdev->dev, "input");
 	if (input)
 		flags = GPIOD_IN;
 	else
 		flags = GPIOD_OUT_LOW;
 
+	device_property_read_u32(&pdev->dev, "timeout-ms", &timeout);
+
 	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 Reviewed-by on v3 1/2
#3 lore raw
In reply to Moritz Fischer
Quoted 9 lines · Moritz Fischer

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

---

Changes from v2:
- Addressed Rob's feedback (timeout_ms -> timeout-ms)

Quoted 8 lines

Changes from v1:
- Addressed Rob's feedback (timeout -> timeout_ms)
- Added to old example rather than creating separate one

---

 Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt | 3 +++
 1 file changed, 3 insertions(+)