From 34be6968c3570d8e03fcafcd60c02f315b8f4602 Mon Sep 17 00:00:00 2001 From: Andrew Jeffery Date: Mon, 31 Jan 2022 13:54:05 +1030 Subject: gpio: Add gpio_request_by_line_name() Add support for the upstream gpio-line-names property already described in the common GPIO binding document[1]. The ability to search for a line name allows boards to lift the implementation of common GPIO behaviours away from specific line indexes on a GPIO controller. [1] https://github.com/devicetree-org/dt-schema/blob/3c35bfee83c2e38e2ae7af5f83eb89ca94a521e8/dtschema/schemas/gpio/gpio.yaml#L17 Signed-off-by: Andrew Jeffery --- drivers/gpio/gpio-uclass.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'drivers/gpio/gpio-uclass.c') diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 125ae53d612..be00a1f7d87 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -1187,6 +1187,32 @@ int gpio_request_by_name(struct udevice *dev, const char *list_name, int index, index, desc, flags, index > 0, NULL); } +int gpio_request_by_line_name(struct udevice *dev, const char *line_name, + struct gpio_desc *desc, int flags) +{ + int ret; + + ret = dev_read_stringlist_search(dev, "gpio-line-names", line_name); + if (ret < 0) + return ret; + + desc->dev = dev; + desc->offset = ret; + desc->flags = 0; + + ret = dm_gpio_request(desc, line_name); + if (ret) { + debug("%s: dm_gpio_requestf failed\n", __func__); + return ret; + } + + ret = dm_gpio_set_dir_flags(desc, flags | desc->flags); + if (ret) + debug("%s: dm_gpio_set_dir failed\n", __func__); + + return ret; +} + int gpio_request_list_by_name_nodev(ofnode node, const char *list_name, struct gpio_desc *desc, int max_count, int flags) -- cgit v1.2.3 From 1d99e673c752bc7d55aa25b02e050741496f7109 Mon Sep 17 00:00:00 2001 From: Eddie James Date: Mon, 7 Feb 2022 17:09:01 -0600 Subject: gpio: Enable hogging support in SPL Use the CONFIG macros to conditionally build the GPIO hogging support in either the SPL or U-Boot, or both, depending on the configuration. Also call the GPIO hog probe function in the common SPL board initialization as an equivalent to adding it to the U-Boot init sequence functions. Signed-off-by: Eddie James Reviewed-by: Simon Glass --- drivers/gpio/gpio-uclass.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/gpio/gpio-uclass.c') diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index be00a1f7d87..0ed32b72170 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -1458,9 +1458,6 @@ void devm_gpiod_put(struct udevice *dev, struct gpio_desc *desc) static int gpio_post_bind(struct udevice *dev) { - struct udevice *child; - ofnode node; - #if defined(CONFIG_NEEDS_MANUAL_RELOC) struct dm_gpio_ops *ops = (struct dm_gpio_ops *)device_get_ops(dev); static int reloc_done; @@ -1491,7 +1488,10 @@ static int gpio_post_bind(struct udevice *dev) } #endif - if (CONFIG_IS_ENABLED(OF_REAL) && IS_ENABLED(CONFIG_GPIO_HOG)) { + if (CONFIG_IS_ENABLED(GPIO_HOG)) { + struct udevice *child; + ofnode node; + dev_for_each_subnode(node, dev) { if (ofnode_read_bool(node, "gpio-hog")) { const char *name = ofnode_get_name(node); -- cgit v1.2.3