diff options
author | Simon Glass <sjg@chromium.org> | 2017-05-30 21:47:09 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2017-06-01 07:03:10 -0600 |
commit | 150c5afe5bafa90e4fe398e59af32ad3cdbfe5b7 (patch) | |
tree | 15188b7974860d263fb7e5a0a19123a8897a63d4 /drivers/gpio | |
parent | 95795ad6cef37b29fcba5365860a8fa9c2f43898 (diff) | |
download | u-boot-150c5afe5bafa90e4fe398e59af32ad3cdbfe5b7.tar.gz |
dm: gpio: Add live tree support
Add support for requesting GPIOs with a live device tree.
This involves adjusting the function signature for the legacy function
gpio_request_by_name_nodev(), so fix up all callers.
Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes to stm32f746-disco.c:
Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpio-uclass.c | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 92a1346aa2..f611996f17 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -683,45 +683,41 @@ err: return ret; } -static int _gpio_request_by_name_nodev(const void *blob, int node, - const char *list_name, int index, - struct gpio_desc *desc, int flags, - bool add_index) +static int _gpio_request_by_name_nodev(ofnode node, const char *list_name, + int index, struct gpio_desc *desc, + int flags, bool add_index) { struct ofnode_phandle_args args; int ret; - ret = ofnode_parse_phandle_with_args(offset_to_ofnode(node), list_name, - "#gpio-cells", 0, index, &args); - if (ret) - debug("%s: fdtdec_parse_phandle_with_args failed\n", __func__); + ret = ofnode_parse_phandle_with_args(node, list_name, "#gpio-cells", 0, + index, &args); - return gpio_request_tail(ret, offset_to_ofnode(node), &args, list_name, - index, desc, flags, add_index); + return gpio_request_tail(ret, node, &args, list_name, index, desc, + flags, add_index); } -int gpio_request_by_name_nodev(const void *blob, int node, - const char *list_name, int index, +int gpio_request_by_name_nodev(ofnode node, const char *list_name, int index, struct gpio_desc *desc, int flags) { - return _gpio_request_by_name_nodev(blob, node, list_name, index, desc, - flags, index > 0); + return _gpio_request_by_name_nodev(node, list_name, index, desc, flags, + index > 0); } -int gpio_request_by_name(struct udevice *dev, const char *list_name, int index, +int gpio_request_by_name(struct udevice *dev, const char *list_name, int index, struct gpio_desc *desc, int flags) { - /* - * This isn't ideal since we don't use dev->name in the debug() - * calls in gpio_request_by_name(), but we can do this until - * gpio_request_by_name_nodev() can be dropped. - */ - return gpio_request_by_name_nodev(gd->fdt_blob, dev_of_offset(dev), - list_name, index, desc, flags); + struct ofnode_phandle_args args; + int ret; + + ret = dev_read_phandle_with_args(dev, list_name, "#gpio-cells", 0, + index, &args); + + return gpio_request_tail(ret, dev_ofnode(dev), &args, list_name, + index, desc, flags, index > 0); } -int gpio_request_list_by_name_nodev(const void *blob, int node, - const char *list_name, +int gpio_request_list_by_name_nodev(ofnode node, const char *list_name, struct gpio_desc *desc, int max_count, int flags) { @@ -729,7 +725,7 @@ int gpio_request_list_by_name_nodev(const void *blob, int node, int ret; for (count = 0; count < max_count; count++) { - ret = _gpio_request_by_name_nodev(blob, node, list_name, count, + ret = _gpio_request_by_name_nodev(node, list_name, count, &desc[count], flags, true); if (ret == -ENOENT) break; @@ -755,9 +751,8 @@ int gpio_request_list_by_name(struct udevice *dev, const char *list_name, * calls in gpio_request_by_name(), but we can do this until * gpio_request_list_by_name_nodev() can be dropped. */ - return gpio_request_list_by_name_nodev(gd->fdt_blob, dev_of_offset(dev), - list_name, desc, max_count, - flags); + return gpio_request_list_by_name_nodev(dev_ofnode(dev), list_name, desc, + max_count, flags); } int gpio_get_list_count(struct udevice *dev, const char *list_name) |