reset: gpio: Add self-deasserting reset callback
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
@@ -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
Krzysztof Kozlowski
maintainerQuoted 8 lines · Shenwei Wang
During the driver probe phase, many drivers leverage convenience wrapper APIs such as
device_resetanddevice_reset_optionalprovided 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
Signed-off-by Shenwei Wang <[email protected]>--- drivers/reset/reset-gpio.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/reset/reset-gpio.c +1
-0@@ -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
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 callbackQuoted 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
Signed-off-by Shenwei Wang <[email protected]>--- drivers/reset/reset-gpio.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/reset/reset-gpio.c +1
-0@@ -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
-0return 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
Krzysztof Kozlowski
maintainerQuoted 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
-0return 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
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 callbackQuoted 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