Skip to contentSkip to conversation

power: reset: ltc2952: make trigger delay configurable

PATCH Superseded Marek Czerski 2 participants 3 messages Dec 7, 2020 – Feb 3, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power: reset: ltc2952: make trigger delay configurable

Make trigger delay configurable through device tree with trigger-delay-ms property.

Trigger delay is the time to wait before starting shutdown sequence after trigger line assertion.
Trigger delay must take into account the OFFT time configured with the capacitor connected to OFFT pin of the LTC2952 chip. Basically, the higher the capacitance connected to OFFT pin, the larger trigger delay must be.

---
 .../devicetree/bindings/power/reset/ltc2952-poweroff.txt  | 4 ++++
 drivers/power/reset/ltc2952-poweroff.c                    | 8 ++++++++
 2 files changed, 12 insertions(+)
Documentation/devicetree/bindings/power/reset/ltc2952-poweroff.txt +4 -0
index cd2d7f58a..881f15a78 100644
@@ -17,6 +17,9 @@ Optional properties:
 			chip's trigger line. If this property is not set, the
 			trigger function is ignored and the chip is kept alive
 			until an explicit kill signal is received
+- trigger-delay-ms	The number of milliseconds to wait after trigger line
+			assertion before executing shut down procedure.
+			The default is 2500ms.
 
 Example:
 
@@ -24,6 +27,7 @@ ltc2952 {
 	compatible = "lltc,ltc2952";
 
 	trigger-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
+        trigger-delay-ms = <2000>;
 	watchdog-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
 	kill-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
 };
drivers/power/reset/ltc2952-poweroff.c +8 -0
index 318927938..243811541 100644
@@ -55,6 +55,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/gpio/consumer.h>
 #include <linux/reboot.h>
+#include <linux/of.h>
 
 struct ltc2952_poweroff {
 	struct hrtimer timer_trigger;
@@ -172,10 +173,17 @@ static void ltc2952_poweroff_default(struct ltc2952_poweroff *data)
 static int ltc2952_poweroff_init(struct platform_device *pdev)
 {
 	int ret;
+	u32 trigger_delay_ms;
 	struct ltc2952_poweroff *data = platform_get_drvdata(pdev);
 
 	ltc2952_poweroff_default(data);
 
+	if (!of_property_read_u32(pdev->dev.of_node, "trigger-delay-ms",
+				  &trigger_delay_ms)) {
+		data->trigger_delay = ktime_set(trigger_delay_ms / MSEC_PER_SEC,
+			(trigger_delay_ms % MSEC_PER_SEC) * NSEC_PER_MSEC);
+	}
+
 	data->gpio_watchdog = devm_gpiod_get(&pdev->dev, "watchdog",
 					     GPIOD_OUT_LOW);
 	if (IS_ERR(data->gpio_watchdog)) {
Signature · 1 line
2.25.1
#1 lore raw

Hi,

Documentation/devicetree/bindings/power/reset/ltc2952-poweroff.txt

Quoted 20 lines · Marek Czerski

Make trigger delay configurable through device tree with trigger-delay-ms property.

Trigger delay is the time to wait before starting shutdown sequence after trigger line assertion.
Trigger delay must take into account the OFFT time configured with the capacitor connected to OFFT pin of the LTC2952 chip. Basically, the higher the capacitance connected to OFFT pin, the larger trigger delay must be.

---
 .../devicetree/bindings/power/reset/ltc2952-poweroff.txt  | 4 ++++
 drivers/power/reset/ltc2952-poweroff.c                    | 8 ++++++++
 2 files changed, 12 insertions(+)
Documentation/devicetree/bindings/power/reset/ltc2952-poweroff.txt +0 -0
index cd2d7f58a..881f15a78 100644

Please additionally Cc DT binding maintainer:

OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS
M: Rob Herring <[email protected]>
L: [email protected]

Quoted 11 lines
Documentation/devicetree/bindings/power/reset/ltc2952-poweroff.txt +3 -0
@@ -17,6 +17,9 @@ Optional properties:
 			chip's trigger line. If this property is not set, the
 			trigger function is ignored and the chip is kept alive
 			until an explicit kill signal is received
+- trigger-delay-ms	The number of milliseconds to wait after trigger line
+			assertion before executing shut down procedure.
+			The default is 2500ms.
 
 Example:
 

Documentation/devicetree/bindings/power/reset/ltc2952-poweroff.txt ltc2952 { · line 30

Quoted 4 lines
Documentation/devicetree/bindings/power/reset/ltc2952-poweroff.txt +1 -0
@@ -24,6 +27,7 @@ ltc2952 {
 	compatible = "lltc,ltc2952";
 
 	trigger-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
+        trigger-delay-ms = <2000>;

please use tab instead of spaces

Quoted 16 lines
Documentation/devicetree/bindings/power/reset/ltc2952-poweroff.txt +0 -0
 	watchdog-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
 	kill-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
 };
drivers/power/reset/ltc2952-poweroff.c +1 -0
index 318927938..243811541 100644
@@ -55,6 +55,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/gpio/consumer.h>
 #include <linux/reboot.h>
+#include <linux/of.h>
 
 struct ltc2952_poweroff {
 	struct hrtimer timer_trigger;

drivers/power/reset/ltc2952-poweroff.c static void ltc2952_poweroff_default(struct ltc2952_poweroff *data) · line 182

Quoted 10 lines
drivers/power/reset/ltc2952-poweroff.c +3 -0
@@ -172,10 +173,17 @@ static void ltc2952_poweroff_default(struct ltc2952_poweroff *data)
 static int ltc2952_poweroff_init(struct platform_device *pdev)
 {
 	int ret;
+	u32 trigger_delay_ms;
 	struct ltc2952_poweroff *data = platform_get_drvdata(pdev);
 
 	ltc2952_poweroff_default(data);
 
+	if (!of_property_read_u32(pdev->dev.of_node, "trigger-delay-ms",
+				  &trigger_delay_ms)) {

please use device_property_read_u32() from <linux/property.h>.

drivers/power/reset/ltc2952-poweroff.c static void ltc2952_poweroff_default(struct ltc2952_poweroff *data) · line 189

Quoted 7 lines
drivers/power/reset/ltc2952-poweroff.c +4 -0
+		data->trigger_delay = ktime_set(trigger_delay_ms / MSEC_PER_SEC,
+			(trigger_delay_ms % MSEC_PER_SEC) * NSEC_PER_MSEC);
+	}
+
 	data->gpio_watchdog = devm_gpiod_get(&pdev->dev, "watchdog",
 					     GPIOD_OUT_LOW);
 	if (IS_ERR(data->gpio_watchdog)) {

Thanks and sorry for delayed response,

-- Sebastian

#2 lore raw

Hi Sebastian,

Thanks for the review. I will send fixed patch as v2 to the correct list of recipients afer I test it on my hardware this week.

Best regards,
Marek Czerski.

sob., 16 sty 2021 o 16:04 Sebastian Reichel <[email protected]> napisał(a):

Quoted 89 lines

Hi,

Documentation/devicetree/bindings/power/reset/ltc2952-poweroff.txt

Quoted 20 lines · Marek Czerski

Make trigger delay configurable through device tree with trigger-delay-ms property.

Trigger delay is the time to wait before starting shutdown sequence after trigger line assertion.
Trigger delay must take into account the OFFT time configured with the capacitor connected to OFFT pin of the LTC2952 chip. Basically, the higher the capacitance connected to OFFT pin, the larger trigger delay must be.

---
 .../devicetree/bindings/power/reset/ltc2952-poweroff.txt  | 4 ++++
 drivers/power/reset/ltc2952-poweroff.c                    | 8 ++++++++
 2 files changed, 12 insertions(+)
Documentation/devicetree/bindings/power/reset/ltc2952-poweroff.txt +0 -0
index cd2d7f58a..881f15a78 100644

Please additionally Cc DT binding maintainer:

OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS

M:      Rob Herring <[email protected]>
L:      [email protected]
Quoted 11 lines
Documentation/devicetree/bindings/power/reset/ltc2952-poweroff.txt +3 -0
@@ -17,6 +17,9 @@ Optional properties:
                      chip's trigger line. If this property is not set, the
                      trigger function is ignored and the chip is kept alive
                      until an explicit kill signal is received
+- trigger-delay-ms   The number of milliseconds to wait after trigger line
+                     assertion before executing shut down procedure.
+                     The default is 2500ms.
 
 Example:
 

Documentation/devicetree/bindings/power/reset/ltc2952-poweroff.txt ltc2952 { · line 30

Quoted 4 lines
Documentation/devicetree/bindings/power/reset/ltc2952-poweroff.txt +1 -0
@@ -24,6 +27,7 @@ ltc2952 {
      compatible = "lltc,ltc2952";
 
      trigger-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
+        trigger-delay-ms = <2000>;

please use tab instead of spaces

Quoted 16 lines
Documentation/devicetree/bindings/power/reset/ltc2952-poweroff.txt +0 -0
      watchdog-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
      kill-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
 };
drivers/power/reset/ltc2952-poweroff.c +1 -0
index 318927938..243811541 100644
@@ -55,6 +55,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/gpio/consumer.h>
 #include <linux/reboot.h>
+#include <linux/of.h>
 
 struct ltc2952_poweroff {
      struct hrtimer timer_trigger;

drivers/power/reset/ltc2952-poweroff.c static void ltc2952_poweroff_default(struct ltc2952_poweroff *data) · line 182

Quoted 10 lines
drivers/power/reset/ltc2952-poweroff.c +3 -0
@@ -172,10 +173,17 @@ static void ltc2952_poweroff_default(struct ltc2952_poweroff *data)
 static int ltc2952_poweroff_init(struct platform_device *pdev)
 {
      int ret;
+     u32 trigger_delay_ms;
      struct ltc2952_poweroff *data = platform_get_drvdata(pdev);
 
      ltc2952_poweroff_default(data);
 
+     if (!of_property_read_u32(pdev->dev.of_node, "trigger-delay-ms",
+                               &trigger_delay_ms)) {

please use device_property_read_u32() from <linux/property.h>.

drivers/power/reset/ltc2952-poweroff.c static void ltc2952_poweroff_default(struct ltc2952_poweroff *data) · line 189

Quoted 7 lines
drivers/power/reset/ltc2952-poweroff.c +4 -0
+             data->trigger_delay = ktime_set(trigger_delay_ms / MSEC_PER_SEC,
+                     (trigger_delay_ms % MSEC_PER_SEC) * NSEC_PER_MSEC);
+     }
+
      data->gpio_watchdog = devm_gpiod_get(&pdev->dev, "watchdog",
                                           GPIOD_OUT_LOW);
      if (IS_ERR(data->gpio_watchdog)) {

Thanks and sorry for delayed response,

-- Sebastian

Signature · 2 lines
mgr inż. Marek Czerski
+48 696 842 686