From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 6/7] gpiolib: implement of_gpio_get_chip_by_alias
Date: Mon, 1 Jul 2024 09:32:19 +0200 [thread overview]
Message-ID: <20240701073220.165946-7-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240701073220.165946-1-a.fatoum@pengutronix.de>
Rockchip pinctrl binding can configure GPIO direction, so let's add a
function that returns a gpio_chip that can be used for this.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/gpio/gpiolib.c | 19 +++++++++++++++++++
include/gpio.h | 6 ++++++
2 files changed, 25 insertions(+)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 520ffed2eefb..f34dce0e98c6 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1057,6 +1057,25 @@ struct gpio_chip *gpio_get_chip_by_dev(struct device *dev)
return NULL;
}
+struct gpio_chip *of_gpio_get_chip_by_alias(const char *alias)
+{
+ struct gpio_chip *chip;
+ struct device_node *np;
+
+ np = of_find_node_by_alias(NULL, alias);
+ if (!np)
+ return NULL;
+
+ of_device_ensure_probed(np);
+
+ list_for_each_entry(chip, &chip_list, list) {
+ if (dev_of_node(chip->dev) == np)
+ return chip;
+ }
+
+ return NULL;
+}
+
int gpio_get_num(struct device *dev, int gpio)
{
struct gpio_chip *chip;
diff --git a/include/gpio.h b/include/gpio.h
index 71896c9d6bdb..8c3eea73d8bb 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -36,6 +36,7 @@ void gpio_set_active(unsigned gpio, bool state);
int gpio_is_active(unsigned gpio);
int gpio_direction_active(unsigned gpio, bool state);
struct gpio_chip *gpio_get_chip_by_dev(struct device *);
+struct gpio_chip *of_gpio_get_chip_by_alias(const char *alias);
/**
* gpio_poll_timeout_us - Poll till GPIO reaches requested active state
@@ -69,6 +70,11 @@ static inline struct gpio_chip *gpio_get_chip_by_dev(struct device *dev)
return NULL;
}
+static struct gpio_chip *of_gpio_get_chip_by_alias(const char *alias)
+{
+ return NULL;
+}
+
#define gpio_poll_timeout_us(gpio, val, timeout_us) (-ENOSYS)
#endif
--
2.39.2
next prev parent reply other threads:[~2024-07-01 7:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-01 7:32 [PATCH 0/7] pinctrl: rockchip: support &pcfg_input/output Ahmad Fatoum
2024-07-01 7:32 ` [PATCH 1/7] pinctrl: import <linux/pinctrl/pinconf-generic.h> header Ahmad Fatoum
2024-07-01 7:32 ` [PATCH 2/7] pinctrl: rockchip: make use of pinconf-generic.h Ahmad Fatoum
2024-07-01 7:32 ` [PATCH 3/7] pinctrl: rockchip: use of_property_read_bool() Ahmad Fatoum
2024-07-01 7:32 ` [PATCH 4/7] pinctrl: rockchip: add support for configuring schmitt trigger Ahmad Fatoum
2024-07-01 7:32 ` [PATCH 5/7] pinctrl: rockchip: add support for bias-pull-pin-default Ahmad Fatoum
2024-07-01 7:32 ` Ahmad Fatoum [this message]
2024-07-01 7:32 ` [PATCH 7/7] pinctrl: rockchip: add support for configuring GPIO direction Ahmad Fatoum
2024-07-01 9:45 ` [PATCH 0/7] pinctrl: rockchip: support &pcfg_input/output Sascha Hauer
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=20240701073220.165946-7-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox