Skip to contentSkip to conversation

reset: gpio: Add self-deasserting reset callback

PATCH In review Shenwei Wang 2 participants 5 messages Jan 30, 2025 – Jan 31, 2025

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

PATCH 1/1 reset: gpio: Add self-deasserting reset callback

During the driver probe phase, many drivers leverage convenience wrapper APIs such as device_reset and device_reset_optional provided by the reset core driver. However, both of these APIs depend on the presence of a .reset callback within the reset controller's operations structure.

Introducing the self-deasserting reset callback enhances flexibility for users and enables a more simple reset process during device initialization.

---
 drivers/reset/reset-gpio.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/reset/reset-gpio.c +13 -0
index 2290b25b6703..614f9e261a13 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 
+#include <linux/delay.h>
 #include <linux/gpio/consumer.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
@@ -37,6 +38,17 @@ static int reset_gpio_deassert(struct reset_controller_dev *rc,
 	return 0;
 }
 
+static int reset_gpio_reset(struct reset_controller_dev *rc, unsigned long id)
+{
+	struct reset_gpio_priv *priv = rc_to_reset_gpio(rc);
+
+	gpiod_set_value_cansleep(priv->reset, 1);
+	usleep_range(10, 20);
+	gpiod_set_value_cansleep(priv->reset, 0);
+
+	return 0;
+}
+
 static int reset_gpio_status(struct reset_controller_dev *rc, unsigned long id)
 {
 	struct reset_gpio_priv *priv = rc_to_reset_gpio(rc);
@@ -47,6 +59,7 @@ static int reset_gpio_status(struct reset_controller_dev *rc, unsigned long id)
 static const struct reset_control_ops reset_gpio_ops = {
 	.assert = reset_gpio_assert,
 	.deassert = reset_gpio_deassert,
+	.reset = reset_gpio_reset,
 	.status = reset_gpio_status,
 };
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 8 lines · Shenwei Wang

During the driver probe phase, many drivers leverage convenience wrapper APIs such as device_reset and device_reset_optional provided by the reset core driver. However, both of these APIs depend on the presence of a .reset callback within the reset controller's operations structure.

Introducing the self-deasserting reset callback enhances flexibility for users and enables a more simple reset process during device initialization.

The reset callback was not added on purpose and you totally ignored the reasons here. See below.

Quoted 18 lines
---
 drivers/reset/reset-gpio.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/reset/reset-gpio.c +1 -0
index 2290b25b6703..614f9e261a13 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 
+#include <linux/delay.h>
 #include <linux/gpio/consumer.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>

drivers/reset/reset-gpio.c static int reset_gpio_deassert(struct reset_controller_dev *rc, · line 46

Quoted 9 lines
drivers/reset/reset-gpio.c +6 -0
@@ -37,6 +38,17 @@ static int reset_gpio_deassert(struct reset_controller_dev *rc,
 	return 0;
 }
 
+static int reset_gpio_reset(struct reset_controller_dev *rc, unsigned long id)
+{
+	struct reset_gpio_priv *priv = rc_to_reset_gpio(rc);
+
+	gpiod_set_value_cansleep(priv->reset, 1);
+	usleep_range(10, 20);

No, because this is some arbitrary value which might or might not work. If this gets accepted, next person will change it to their own need. Then next person will revert previous change... and so on.

Best regards,
Krzysztof

#2 lore raw
Quoted 39 lines

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Friday, January 31, 2025 1:18 AM
To: Shenwei Wang <[email protected]>; Philipp Zabel <[email protected]>
Cc: [email protected]; dl-linux-imx <[email protected]>
Subject: [EXT] Re: [PATCH] reset: gpio: Add self-deasserting reset callback

Quoted 3 lines

Introducing the self-deasserting reset callback enhances flexibility for users and enables a more simple reset process during device initialization.

The reset callback was not added on purpose and you totally ignored the reasons here. See below.

drivers/reset/reset-gpio.c static int reset_gpio_deassert(struct

Quoted 18 lines
---
 drivers/reset/reset-gpio.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/reset/reset-gpio.c +1 -0
index 2290b25b6703..614f9e261a13 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 
+#include <linux/delay.h>
 #include <linux/gpio/consumer.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
@@ -37,6 +38,17 @@ static int reset_gpio_deassert(struct

reset_controller_dev *rc,

Quoted 3 lines
drivers/reset/reset-gpio.c +0 -0
      return 0;
 }
 
Quoted 12 lines

drivers/reset/reset-gpio.c static int reset_gpio_deassert(struct reset_controller_dev *rc, · line 46

Quoted 6 lines
drivers/reset/reset-gpio.c +6 -0
+static int reset_gpio_reset(struct reset_controller_dev *rc, unsigned
+long id) {
+     struct reset_gpio_priv *priv = rc_to_reset_gpio(rc);
+
+     gpiod_set_value_cansleep(priv->reset, 1);
+     usleep_range(10, 20);

No, because this is some arbitrary value which might or might not work. If this gets accepted, next person will change it to their own need. Then next person will revert previous change... and so on.

If the arbitrary value is a concern, would moving it to the DTS be an appropriate solution? This may give the user more flexible.

Shenwei

Quoted 3 lines

Best regards,
Krzysztof

#3 lore raw
Quoted 22 lines · Shenwei Wang
Quoted 9 lines

drivers/reset/reset-gpio.c static int reset_gpio_deassert(struct

Quoted 5 lines
drivers/reset/reset-gpio.c +1 -0
+#include <linux/delay.h>
 #include <linux/gpio/consumer.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
@@ -37,6 +38,17 @@ static int reset_gpio_deassert(struct

reset_controller_dev *rc,

Quoted 3 lines
drivers/reset/reset-gpio.c +0 -0
      return 0;
 }
 
Quoted 12 lines

drivers/reset/reset-gpio.c static int reset_gpio_deassert(struct reset_controller_dev *rc, · line 46

Quoted 6 lines
drivers/reset/reset-gpio.c +6 -0
+static int reset_gpio_reset(struct reset_controller_dev *rc, unsigned
+long id) {
+     struct reset_gpio_priv *priv = rc_to_reset_gpio(rc);
+
+     gpiod_set_value_cansleep(priv->reset, 1);
+     usleep_range(10, 20);

No, because this is some arbitrary value which might or might not work. If this gets accepted, next person will change it to their own need. Then next person will revert previous change... and so on.

Quoted 2 lines

If the arbitrary value is a concern, would moving it to the DTS be an appropriate solution? This may give the user more flexible.

Sure, as discussed when this series were upstreamed and as discussed with Sean's patchset. BTW, Sean's mentioned need to revive his work, but I think it did not materialize.

Best regards,
Krzysztof

#4 lore raw
Quoted 17 lines

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Friday, January 31, 2025 9:10 AM
To: Shenwei Wang <[email protected]>; Philipp Zabel <[email protected]>
Cc: [email protected]; dl-linux-imx <[email protected]>
Subject: [EXT] Re: [PATCH] reset: gpio: Add self-deasserting reset callback

Quoted 8 lines
Quoted 7 lines
Quoted 1 line

+ usleep_range(10, 20);

No, because this is some arbitrary value which might or might not work. If this gets accepted, next person will change it to their own need. Then next person will revert previous change... and so on.

Quoted 8 lines
Quoted 1 line

If the arbitrary value is a concern, would moving it to the DTS be an appropriate

solution?

Quoted 1 line

This may give the user more flexible.

Sure, as discussed when this series were upstreamed and as discussed with Sean's patchset. BTW, Sean's mentioned need to revive his work, but I think it did not materialize.

Do you know if Sean is still working on this feature? If not, I'm willing to take it over and complete the implementation.

Thanks,
Shenwei

Quoted 2 lines

Best regards,
Krzysztof