From: Shenwei Wang <shenwei.wang@nxp.com>
To: Krzysztof Kozlowski <krzk@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>
Cc: imx@lists.linux.dev, linux-imx@nxp.com,
Shenwei Wang <shenwei.wang@nxp.com>
Subject: [PATCH] reset: gpio: Add self-deasserting reset callback
Date: Thu, 30 Jan 2025 15:53:06 -0600 [thread overview]
Message-ID: <20250130215306.60589-1-shenwei.wang@nxp.com> (raw)
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.
Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
---
drivers/reset/reset-gpio.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/reset/reset-gpio.c b/drivers/reset/reset-gpio.c
index 2290b25b6703..614f9e261a13 100644
--- a/drivers/reset/reset-gpio.c
+++ b/drivers/reset/reset-gpio.c
@@ -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,
};
--
2.43.0
next reply other threads:[~2025-01-30 21:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-30 21:53 Shenwei Wang [this message]
2025-01-31 7:17 ` [PATCH] reset: gpio: Add self-deasserting reset callback Krzysztof Kozlowski
2025-01-31 14:58 ` Shenwei Wang
2025-01-31 15:10 ` Krzysztof Kozlowski
2025-01-31 15:23 ` Shenwei Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250130215306.60589-1-shenwei.wang@nxp.com \
--to=shenwei.wang@nxp.com \
--cc=imx@lists.linux.dev \
--cc=krzk@kernel.org \
--cc=linux-imx@nxp.com \
--cc=p.zabel@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.