summaryrefslogtreecommitdiffstats
path: root/include/gpio.h
diff options
context:
space:
mode:
authorOleksij Rempel <o.rempel@pengutronix.de>2020-08-20 09:34:44 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-08-24 08:48:36 +0200
commit8b45504693e9912140bbc1f7875a994f90c76d55 (patch)
treec0d5a28229caa9a389099b13658872975efd71c8 /include/gpio.h
parent5e1fc532538ad1cec643eb61b8f248dd98a54efc (diff)
downloadbarebox-8b45504693e9912140bbc1f7875a994f90c76d55.tar.gz
barebox-8b45504693e9912140bbc1f7875a994f90c76d55.tar.xz
gpiolib: add gpio_array_to_id helper to get ID out of GPIO array
Some boards provide a board version and/or ID coded by pull-up/down resistors connected to the gpio pins (or pins which can be multiplexed at some point as gpio). In this case every one implements own gpio id reader function. To avoid it, provide the common helper function to extract a value out of provided gpio array. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/gpio.h')
-rw-r--r--include/gpio.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/gpio.h b/include/gpio.h
index 98c5b93ba2..81beb47309 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -145,6 +145,10 @@ static inline void gpio_free_array(const struct gpio *array, size_t num)
/* GPIO can never have been requested */
WARN_ON(1);
}
+static inline int gpio_array_to_id(const struct gpio *array, size_t num, u32 *val)
+{
+ return -EINVAL;
+}
#else
int gpio_request(unsigned gpio, const char *label);
int gpio_find_by_name(const char *name);
@@ -153,6 +157,7 @@ void gpio_free(unsigned gpio);
int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
int gpio_request_array(const struct gpio *array, size_t num);
void gpio_free_array(const struct gpio *array, size_t num);
+int gpio_array_to_id(const struct gpio *array, size_t num, u32 *val);
#endif
struct gpio_chip;