1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2013 Google, Inc
8 #include <dm/device_compat.h>
9 #include <dm/device-internal.h>
11 #include <dm/uclass-internal.h>
12 #include <dt-bindings/gpio/gpio.h>
17 #include <linux/bug.h>
18 #include <linux/ctype.h>
20 DECLARE_GLOBAL_DATA_PTR;
23 * gpio_desc_init() - Initialize the GPIO descriptor
25 * @desc: GPIO descriptor to initialize
27 * @offset: Offset of device GPIO
29 static void gpio_desc_init(struct gpio_desc *desc,
34 desc->offset = offset;
39 * gpio_to_device() - Convert global GPIO number to device, number
41 * Convert the GPIO number to an entry in the list of GPIOs
42 * or GPIO blocks registered with the GPIO controller. Returns
43 * entry on success, NULL on error.
45 * @gpio: The numeric representation of the GPIO
46 * @desc: Returns description (desc->flags will always be 0)
47 * @return 0 if found, -ENOENT if not found
49 static int gpio_to_device(unsigned int gpio, struct gpio_desc *desc)
51 struct gpio_dev_priv *uc_priv;
55 for (ret = uclass_first_device(UCLASS_GPIO, &dev);
57 ret = uclass_next_device(&dev)) {
58 uc_priv = dev_get_uclass_priv(dev);
59 if (gpio >= uc_priv->gpio_base &&
60 gpio < uc_priv->gpio_base + uc_priv->gpio_count) {
61 gpio_desc_init(desc, dev, gpio - uc_priv->gpio_base);
67 return ret ? ret : -ENOENT;
70 int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc)
72 struct gpio_dev_priv *uc_priv = NULL;
78 numeric = isdigit(*name) ? simple_strtoul(name, NULL, 10) : -1;
79 for (ret = uclass_first_device(UCLASS_GPIO, &dev);
81 ret = uclass_next_device(&dev)) {
84 uc_priv = dev_get_uclass_priv(dev);
86 offset = numeric - uc_priv->gpio_base;
87 /* Allow GPIOs to be numbered from 0 */
88 if (offset < uc_priv->gpio_count)
92 len = uc_priv->bank_name ? strlen(uc_priv->bank_name) : 0;
94 if (!strncasecmp(name, uc_priv->bank_name, len)) {
95 if (!strict_strtoul(name + len, 10, &offset))
101 return ret ? ret : -EINVAL;
103 gpio_desc_init(desc, dev, offset);
108 int gpio_lookup_name(const char *name, struct udevice **devp,
109 unsigned int *offsetp, unsigned int *gpiop)
111 struct gpio_desc desc;
116 ret = dm_gpio_lookup_name(name, &desc);
123 *offsetp = desc.offset;
125 struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(desc.dev);
127 *gpiop = uc_priv->gpio_base + desc.offset;
133 int gpio_xlate_offs_flags(struct udevice *dev, struct gpio_desc *desc,
134 struct ofnode_phandle_args *args)
136 if (args->args_count < 1)
139 desc->offset = args->args[0];
141 if (args->args_count < 2)
145 if (args->args[1] & GPIO_ACTIVE_LOW)
146 desc->flags |= GPIOD_ACTIVE_LOW;
151 static int gpio_find_and_xlate(struct gpio_desc *desc,
152 struct ofnode_phandle_args *args)
154 struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
157 return ops->xlate(desc->dev, desc, args);
159 return gpio_xlate_offs_flags(desc->dev, desc, args);
162 #if defined(CONFIG_GPIO_HOG)
164 struct gpio_hog_priv {
165 struct gpio_desc gpiod;
168 struct gpio_hog_data {
174 static int gpio_hog_ofdata_to_platdata(struct udevice *dev)
176 struct gpio_hog_data *plat = dev_get_platdata(dev);
177 const char *nodename;
181 if (dev_read_bool(dev, "input")) {
182 plat->gpiod_flags = GPIOD_IS_IN;
183 } else if (dev_read_bool(dev, "output-high")) {
185 plat->gpiod_flags = GPIOD_IS_OUT;
186 } else if (dev_read_bool(dev, "output-low")) {
187 plat->gpiod_flags = GPIOD_IS_OUT;
189 printf("%s: missing gpio-hog state.\n", __func__);
192 ret = dev_read_u32_array(dev, "gpios", plat->val, 2);
194 printf("%s: wrong gpios property, 2 values needed %d\n",
198 nodename = dev_read_string(dev, "line-name");
200 device_set_name(dev, nodename);
205 static int gpio_hog_probe(struct udevice *dev)
207 struct gpio_hog_data *plat = dev_get_platdata(dev);
208 struct gpio_hog_priv *priv = dev_get_priv(dev);
211 ret = gpio_dev_request_index(dev->parent, dev->name, "gpio-hog",
212 plat->val[0], plat->gpiod_flags,
213 plat->val[1], &priv->gpiod);
215 debug("%s: node %s could not get gpio.\n", __func__,
220 if (plat->gpiod_flags == GPIOD_IS_OUT) {
221 ret = dm_gpio_set_value(&priv->gpiod, plat->value);
223 debug("%s: node %s could not set gpio.\n", __func__,
232 int gpio_hog_probe_all(void)
238 for (uclass_first_device(UCLASS_NOP, &dev);
240 uclass_find_next_device(&dev)) {
241 if (dev->driver == DM_GET_DRIVER(gpio_hog)) {
242 ret = device_probe(dev);
244 printf("Failed to probe device %s err: %d\n",
254 int gpio_hog_lookup_name(const char *name, struct gpio_desc **desc)
259 gpio_hog_probe_all();
260 if (!uclass_get_device_by_name(UCLASS_NOP, name, &dev)) {
261 struct gpio_hog_priv *priv = dev_get_priv(dev);
263 *desc = &priv->gpiod;
270 U_BOOT_DRIVER(gpio_hog) = {
273 .ofdata_to_platdata = gpio_hog_ofdata_to_platdata,
274 .probe = gpio_hog_probe,
275 .priv_auto_alloc_size = sizeof(struct gpio_hog_priv),
276 .platdata_auto_alloc_size = sizeof(struct gpio_hog_data),
279 int gpio_hog_lookup_name(const char *name, struct gpio_desc **desc)
285 int dm_gpio_request(struct gpio_desc *desc, const char *label)
287 struct udevice *dev = desc->dev;
288 struct gpio_dev_priv *uc_priv;
292 uc_priv = dev_get_uclass_priv(dev);
293 if (uc_priv->name[desc->offset])
298 if (gpio_get_ops(dev)->request) {
299 ret = gpio_get_ops(dev)->request(dev, desc->offset, label);
305 uc_priv->name[desc->offset] = str;
310 static int dm_gpio_requestf(struct gpio_desc *desc, const char *fmt, ...)
312 #if !defined(CONFIG_SPL_BUILD) || !CONFIG_IS_ENABLED(USE_TINY_PRINTF)
317 vscnprintf(buf, sizeof(buf), fmt, args);
319 return dm_gpio_request(desc, buf);
321 return dm_gpio_request(desc, fmt);
326 * gpio_request() - [COMPAT] Request GPIO
328 * label: Name for the requested GPIO
330 * The label is copied and allocated so the caller does not need to keep
331 * the pointer around.
333 * This function implements the API that's compatible with current
334 * GPIO API used in U-Boot. The request is forwarded to particular
335 * GPIO driver. Returns 0 on success, negative value on error.
337 int gpio_request(unsigned gpio, const char *label)
339 struct gpio_desc desc;
342 ret = gpio_to_device(gpio, &desc);
346 return dm_gpio_request(&desc, label);
350 * gpio_requestf() - [COMPAT] Request GPIO
352 * @fmt: Format string for the requested GPIO
353 * @...: Arguments for the printf() format string
355 * This function implements the API that's compatible with current
356 * GPIO API used in U-Boot. The request is forwarded to particular
357 * GPIO driver. Returns 0 on success, negative value on error.
359 int gpio_requestf(unsigned gpio, const char *fmt, ...)
361 #if !defined(CONFIG_SPL_BUILD) || !CONFIG_IS_ENABLED(USE_TINY_PRINTF)
366 vscnprintf(buf, sizeof(buf), fmt, args);
368 return gpio_request(gpio, buf);
370 return gpio_request(gpio, fmt);
374 int _dm_gpio_free(struct udevice *dev, uint offset)
376 struct gpio_dev_priv *uc_priv;
379 uc_priv = dev_get_uclass_priv(dev);
380 if (!uc_priv->name[offset])
382 if (gpio_get_ops(dev)->rfree) {
383 ret = gpio_get_ops(dev)->rfree(dev, offset);
388 free(uc_priv->name[offset]);
389 uc_priv->name[offset] = NULL;
395 * gpio_free() - [COMPAT] Relinquish GPIO
398 * This function implements the API that's compatible with current
399 * GPIO API used in U-Boot. The request is forwarded to particular
400 * GPIO driver. Returns 0 on success, negative value on error.
402 int gpio_free(unsigned gpio)
404 struct gpio_desc desc;
407 ret = gpio_to_device(gpio, &desc);
411 return _dm_gpio_free(desc.dev, desc.offset);
414 static int check_reserved(const struct gpio_desc *desc, const char *func)
416 struct gpio_dev_priv *uc_priv;
418 if (!dm_gpio_is_valid(desc))
421 uc_priv = dev_get_uclass_priv(desc->dev);
422 if (!uc_priv->name[desc->offset]) {
423 printf("%s: %s: error: gpio %s%d not reserved\n",
424 desc->dev->name, func,
425 uc_priv->bank_name ? uc_priv->bank_name : "",
434 * gpio_direction_input() - [COMPAT] Set GPIO direction to input
437 * This function implements the API that's compatible with current
438 * GPIO API used in U-Boot. The request is forwarded to particular
439 * GPIO driver. Returns 0 on success, negative value on error.
441 int gpio_direction_input(unsigned gpio)
443 struct gpio_desc desc;
446 ret = gpio_to_device(gpio, &desc);
449 ret = check_reserved(&desc, "dir_input");
453 return gpio_get_ops(desc.dev)->direction_input(desc.dev, desc.offset);
457 * gpio_direction_output() - [COMPAT] Set GPIO direction to output and set value
459 * value: Logical value to be set on the GPIO pin
461 * This function implements the API that's compatible with current
462 * GPIO API used in U-Boot. The request is forwarded to particular
463 * GPIO driver. Returns 0 on success, negative value on error.
465 int gpio_direction_output(unsigned gpio, int value)
467 struct gpio_desc desc;
470 ret = gpio_to_device(gpio, &desc);
473 ret = check_reserved(&desc, "dir_output");
477 return gpio_get_ops(desc.dev)->direction_output(desc.dev,
481 static int _gpio_get_value(const struct gpio_desc *desc)
485 value = gpio_get_ops(desc->dev)->get_value(desc->dev, desc->offset);
487 return desc->flags & GPIOD_ACTIVE_LOW ? !value : value;
490 int dm_gpio_get_value(const struct gpio_desc *desc)
494 ret = check_reserved(desc, "get_value");
498 return _gpio_get_value(desc);
501 int dm_gpio_set_value(const struct gpio_desc *desc, int value)
505 ret = check_reserved(desc, "set_value");
509 if (desc->flags & GPIOD_ACTIVE_LOW)
511 gpio_get_ops(desc->dev)->set_value(desc->dev, desc->offset, value);
515 /* check dir flags invalid configuration */
516 static int check_dir_flags(ulong flags)
518 if ((flags & GPIOD_IS_OUT) && (flags & GPIOD_IS_IN)) {
519 log_debug("%s: flags 0x%lx has GPIOD_IS_OUT and GPIOD_IS_IN\n",
527 static int _dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
529 struct udevice *dev = desc->dev;
530 struct dm_gpio_ops *ops = gpio_get_ops(dev);
531 struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
534 ret = check_dir_flags(flags);
537 "%s error: set_dir_flags for gpio %s%d has invalid dir flags 0x%lx\n",
539 uc_priv->bank_name ? uc_priv->bank_name : "",
540 desc->offset, flags);
545 if (flags & GPIOD_IS_OUT) {
546 ret = ops->direction_output(dev, desc->offset,
547 GPIOD_FLAGS_OUTPUT(flags));
548 } else if (flags & GPIOD_IS_IN) {
549 ret = ops->direction_input(dev, desc->offset);
555 int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
559 ret = check_reserved(desc, "set_dir_flags");
563 /* combine the requested flags (for IN/OUT) and the descriptor flags */
564 flags |= desc->flags;
565 ret = _dm_gpio_set_dir_flags(desc, flags);
567 /* update the descriptor flags */
574 int dm_gpio_set_dir(struct gpio_desc *desc)
578 ret = check_reserved(desc, "set_dir");
582 return _dm_gpio_set_dir_flags(desc, desc->flags);
585 int dm_gpio_get_dir_flags(struct gpio_desc *desc, ulong *flags)
590 ret = check_reserved(desc, "get_dir_flags");
594 dir_flags = desc->flags;
595 /* only GPIOD_IS_OUT_ACTIVE is provided by uclass */
596 dir_flags &= ~GPIOD_IS_OUT_ACTIVE;
597 if ((desc->flags & GPIOD_IS_OUT) && _gpio_get_value(desc))
598 dir_flags |= GPIOD_IS_OUT_ACTIVE;
606 * gpio_get_value() - [COMPAT] Sample GPIO pin and return it's value
609 * This function implements the API that's compatible with current
610 * GPIO API used in U-Boot. The request is forwarded to particular
611 * GPIO driver. Returns the value of the GPIO pin, or negative value
614 int gpio_get_value(unsigned gpio)
618 struct gpio_desc desc;
620 ret = gpio_to_device(gpio, &desc);
623 return dm_gpio_get_value(&desc);
627 * gpio_set_value() - [COMPAT] Configure logical value on GPIO pin
629 * value: Logical value to be set on the GPIO pin.
631 * This function implements the API that's compatible with current
632 * GPIO API used in U-Boot. The request is forwarded to particular
633 * GPIO driver. Returns 0 on success, negative value on error.
635 int gpio_set_value(unsigned gpio, int value)
637 struct gpio_desc desc;
640 ret = gpio_to_device(gpio, &desc);
643 return dm_gpio_set_value(&desc, value);
646 const char *gpio_get_bank_info(struct udevice *dev, int *bit_count)
648 struct gpio_dev_priv *priv;
650 /* Must be called on an active device */
651 priv = dev_get_uclass_priv(dev);
654 *bit_count = priv->gpio_count;
655 return priv->bank_name;
658 static const char * const gpio_function[GPIOF_COUNT] = {
666 static int get_function(struct udevice *dev, int offset, bool skip_unused,
669 struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
670 struct dm_gpio_ops *ops = gpio_get_ops(dev);
672 BUILD_BUG_ON(GPIOF_COUNT != ARRAY_SIZE(gpio_function));
673 if (!device_active(dev))
675 if (offset < 0 || offset >= uc_priv->gpio_count)
678 *namep = uc_priv->name[offset];
679 if (skip_unused && !uc_priv->name[offset])
681 if (ops->get_function) {
684 ret = ops->get_function(dev, offset);
687 if (ret >= ARRAY_SIZE(gpio_function))
692 return GPIOF_UNKNOWN;
695 int gpio_get_function(struct udevice *dev, int offset, const char **namep)
697 return get_function(dev, offset, true, namep);
700 int gpio_get_raw_function(struct udevice *dev, int offset, const char **namep)
702 return get_function(dev, offset, false, namep);
705 int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize)
707 struct dm_gpio_ops *ops = gpio_get_ops(dev);
708 struct gpio_dev_priv *priv;
714 BUILD_BUG_ON(GPIOF_COUNT != ARRAY_SIZE(gpio_function));
717 priv = dev_get_uclass_priv(dev);
718 ret = gpio_get_raw_function(dev, offset, NULL);
722 len = snprintf(str, buffsize, "%s%d: %s",
723 priv->bank_name ? priv->bank_name : "",
724 offset, gpio_function[func]);
725 if (func == GPIOF_INPUT || func == GPIOF_OUTPUT ||
726 func == GPIOF_UNUSED) {
730 ret = ops->get_value(dev, offset);
733 used = gpio_get_function(dev, offset, &label) != GPIOF_UNUSED;
734 snprintf(str + len, buffsize - len, ": %d [%c]%s%s",
744 int gpio_claim_vector(const int *gpio_num_array, const char *fmt)
749 for (i = 0; i < 32; i++) {
750 gpio = gpio_num_array[i];
753 ret = gpio_requestf(gpio, fmt, i);
756 ret = gpio_direction_input(gpio);
765 for (i--; i >= 0; i--)
766 gpio_free(gpio_num_array[i]);
772 * get a number comprised of multiple GPIO values. gpio_num_array points to
773 * the array of gpio pin numbers to scan, terminated by -1.
775 int gpio_get_values_as_int(const int *gpio_list)
778 unsigned bitmask = 1;
783 ((gpio = *gpio_list++) != -1)) {
784 ret = gpio_get_value(gpio);
795 int dm_gpio_get_values_as_int(const struct gpio_desc *desc_list, int count)
797 unsigned bitmask = 1;
801 for (i = 0; i < count; i++) {
802 ret = dm_gpio_get_value(&desc_list[i]);
814 * gpio_request_tail: common work for requesting a gpio.
816 * ret: return value from previous work in function which calls
818 * This seems bogus (why calling this function instead not
819 * calling it and end caller function instead?).
820 * Because on error in caller function we want to set some
821 * default values in gpio desc and have a common error
822 * debug message, which provides this function.
823 * nodename: Name of node for which gpio gets requested
824 * used for gpio label name.
825 * args: pointer to output arguments structure
826 * list_name: Name of GPIO list
827 * used for gpio label name.
828 * index: gpio index in gpio list
829 * used for gpio label name.
830 * desc: pointer to gpio descriptor, filled from this
832 * flags: gpio flags to use.
833 * add_index: should index added to gpio label name
834 * gpio_dev: pointer to gpio device from which the gpio
835 * will be requested. If NULL try to get the
836 * gpio device with uclass_get_device_by_ofnode()
838 * return: In error case this function sets default values in
839 * gpio descriptor, also emmits a debug message.
840 * On success it returns 0 else the error code from
841 * function calls, or the error code passed through
842 * ret to this function.
845 static int gpio_request_tail(int ret, const char *nodename,
846 struct ofnode_phandle_args *args,
847 const char *list_name, int index,
848 struct gpio_desc *desc, int flags,
849 bool add_index, struct udevice *gpio_dev)
851 gpio_desc_init(desc, gpio_dev, 0);
856 ret = uclass_get_device_by_ofnode(UCLASS_GPIO, args->node,
859 debug("%s: uclass_get_device_by_ofnode failed\n",
864 ret = gpio_find_and_xlate(desc, args);
866 debug("%s: gpio_find_and_xlate failed\n", __func__);
869 ret = dm_gpio_requestf(desc, add_index ? "%s.%s%d" : "%s.%s",
870 nodename, list_name, index);
872 debug("%s: dm_gpio_requestf failed\n", __func__);
875 ret = dm_gpio_set_dir_flags(desc, flags);
877 debug("%s: dm_gpio_set_dir failed\n", __func__);
883 debug("%s: Node '%s', property '%s', failed to request GPIO index %d: %d\n",
884 __func__, nodename, list_name, index, ret);
888 static int _gpio_request_by_name_nodev(ofnode node, const char *list_name,
889 int index, struct gpio_desc *desc,
890 int flags, bool add_index)
892 struct ofnode_phandle_args args;
895 ret = ofnode_parse_phandle_with_args(node, list_name, "#gpio-cells", 0,
898 return gpio_request_tail(ret, ofnode_get_name(node), &args, list_name,
899 index, desc, flags, add_index, NULL);
902 int gpio_request_by_name_nodev(ofnode node, const char *list_name, int index,
903 struct gpio_desc *desc, int flags)
905 return _gpio_request_by_name_nodev(node, list_name, index, desc, flags,
909 int gpio_request_by_name(struct udevice *dev, const char *list_name, int index,
910 struct gpio_desc *desc, int flags)
912 struct ofnode_phandle_args args;
916 ret = dev_read_phandle_with_args(dev, list_name, "#gpio-cells", 0,
918 node = dev_ofnode(dev);
919 return gpio_request_tail(ret, ofnode_get_name(node), &args, list_name,
920 index, desc, flags, index > 0, NULL);
923 int gpio_request_list_by_name_nodev(ofnode node, const char *list_name,
924 struct gpio_desc *desc, int max_count,
930 for (count = 0; count < max_count; count++) {
931 ret = _gpio_request_by_name_nodev(node, list_name, count,
932 &desc[count], flags, true);
939 /* We ran out of GPIOs in the list */
943 gpio_free_list_nodev(desc, count - 1);
948 int gpio_request_list_by_name(struct udevice *dev, const char *list_name,
949 struct gpio_desc *desc, int max_count,
953 * This isn't ideal since we don't use dev->name in the debug()
954 * calls in gpio_request_by_name(), but we can do this until
955 * gpio_request_list_by_name_nodev() can be dropped.
957 return gpio_request_list_by_name_nodev(dev_ofnode(dev), list_name, desc,
961 int gpio_get_list_count(struct udevice *dev, const char *list_name)
965 ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev),
966 list_name, "#gpio-cells", 0, -1,
969 debug("%s: Node '%s', property '%s', GPIO count failed: %d\n",
970 __func__, dev->name, list_name, ret);
976 int dm_gpio_free(struct udevice *dev, struct gpio_desc *desc)
978 /* For now, we don't do any checking of dev */
979 return _dm_gpio_free(desc->dev, desc->offset);
982 int gpio_free_list(struct udevice *dev, struct gpio_desc *desc, int count)
986 /* For now, we don't do any checking of dev */
987 for (i = 0; i < count; i++)
988 dm_gpio_free(dev, &desc[i]);
993 int gpio_free_list_nodev(struct gpio_desc *desc, int count)
995 return gpio_free_list(NULL, desc, count);
998 /* We need to renumber the GPIOs when any driver is probed/removed */
999 static int gpio_renumber(struct udevice *removed_dev)
1001 struct gpio_dev_priv *uc_priv;
1002 struct udevice *dev;
1007 ret = uclass_get(UCLASS_GPIO, &uc);
1011 /* Ensure that we have a base for each bank */
1013 uclass_foreach_dev(dev, uc) {
1014 if (device_active(dev) && dev != removed_dev) {
1015 uc_priv = dev_get_uclass_priv(dev);
1016 uc_priv->gpio_base = base;
1017 base += uc_priv->gpio_count;
1024 int gpio_get_number(const struct gpio_desc *desc)
1026 struct udevice *dev = desc->dev;
1027 struct gpio_dev_priv *uc_priv;
1031 uc_priv = dev->uclass_priv;
1033 return uc_priv->gpio_base + desc->offset;
1036 static int gpio_post_probe(struct udevice *dev)
1038 struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
1040 uc_priv->name = calloc(uc_priv->gpio_count, sizeof(char *));
1044 return gpio_renumber(NULL);
1047 static int gpio_pre_remove(struct udevice *dev)
1049 struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
1052 for (i = 0; i < uc_priv->gpio_count; i++) {
1053 if (uc_priv->name[i])
1054 free(uc_priv->name[i]);
1056 free(uc_priv->name);
1058 return gpio_renumber(dev);
1061 int gpio_dev_request_index(struct udevice *dev, const char *nodename,
1062 char *list_name, int index, int flags,
1063 int dtflags, struct gpio_desc *desc)
1065 struct ofnode_phandle_args args;
1067 args.node = ofnode_null();
1068 args.args_count = 2;
1069 args.args[0] = index;
1070 args.args[1] = dtflags;
1072 return gpio_request_tail(0, nodename, &args, list_name, index, desc,
1076 static int gpio_post_bind(struct udevice *dev)
1078 struct udevice *child;
1081 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
1082 struct dm_gpio_ops *ops = (struct dm_gpio_ops *)device_get_ops(dev);
1083 static int reloc_done;
1087 ops->request += gd->reloc_off;
1089 ops->rfree += gd->reloc_off;
1090 if (ops->direction_input)
1091 ops->direction_input += gd->reloc_off;
1092 if (ops->direction_output)
1093 ops->direction_output += gd->reloc_off;
1095 ops->get_value += gd->reloc_off;
1097 ops->set_value += gd->reloc_off;
1098 if (ops->get_function)
1099 ops->get_function += gd->reloc_off;
1101 ops->xlate += gd->reloc_off;
1107 if (IS_ENABLED(CONFIG_GPIO_HOG)) {
1108 dev_for_each_subnode(node, dev) {
1109 if (ofnode_read_bool(node, "gpio-hog")) {
1110 const char *name = ofnode_get_name(node);
1113 ret = device_bind_driver_to_node(dev,
1125 UCLASS_DRIVER(gpio) = {
1128 .flags = DM_UC_FLAG_SEQ_ALIAS,
1129 .post_probe = gpio_post_probe,
1130 .post_bind = gpio_post_bind,
1131 .pre_remove = gpio_pre_remove,
1132 .per_device_auto_alloc_size = sizeof(struct gpio_dev_priv),