1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2013 Google, Inc
8 #include <dm/device-internal.h>
10 #include <dm/uclass-internal.h>
11 #include <dt-bindings/gpio/gpio.h>
16 #include <linux/bug.h>
17 #include <linux/ctype.h>
19 DECLARE_GLOBAL_DATA_PTR;
22 * gpio_to_device() - Convert global GPIO number to device, number
24 * Convert the GPIO number to an entry in the list of GPIOs
25 * or GPIO blocks registered with the GPIO controller. Returns
26 * entry on success, NULL on error.
28 * @gpio: The numeric representation of the GPIO
29 * @desc: Returns description (desc->flags will always be 0)
30 * @return 0 if found, -ENOENT if not found
32 static int gpio_to_device(unsigned int gpio, struct gpio_desc *desc)
34 struct gpio_dev_priv *uc_priv;
38 for (ret = uclass_first_device(UCLASS_GPIO, &dev);
40 ret = uclass_next_device(&dev)) {
41 uc_priv = dev_get_uclass_priv(dev);
42 if (gpio >= uc_priv->gpio_base &&
43 gpio < uc_priv->gpio_base + uc_priv->gpio_count) {
45 desc->offset = gpio - uc_priv->gpio_base;
52 return ret ? ret : -ENOENT;
55 int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc)
57 struct gpio_dev_priv *uc_priv = NULL;
63 numeric = isdigit(*name) ? simple_strtoul(name, NULL, 10) : -1;
64 for (ret = uclass_first_device(UCLASS_GPIO, &dev);
66 ret = uclass_next_device(&dev)) {
69 uc_priv = dev_get_uclass_priv(dev);
71 offset = numeric - uc_priv->gpio_base;
72 /* Allow GPIOs to be numbered from 0 */
73 if (offset < uc_priv->gpio_count)
77 len = uc_priv->bank_name ? strlen(uc_priv->bank_name) : 0;
79 if (!strncasecmp(name, uc_priv->bank_name, len)) {
80 if (!strict_strtoul(name + len, 10, &offset))
86 return ret ? ret : -EINVAL;
89 desc->offset = offset;
94 int gpio_lookup_name(const char *name, struct udevice **devp,
95 unsigned int *offsetp, unsigned int *gpiop)
97 struct gpio_desc desc;
102 ret = dm_gpio_lookup_name(name, &desc);
109 *offsetp = desc.offset;
111 struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(desc.dev);
113 *gpiop = uc_priv->gpio_base + desc.offset;
119 int gpio_xlate_offs_flags(struct udevice *dev, struct gpio_desc *desc,
120 struct ofnode_phandle_args *args)
122 if (args->args_count < 1)
125 desc->offset = args->args[0];
127 if (args->args_count < 2)
130 if (args->args[1] & GPIO_ACTIVE_LOW)
131 desc->flags = GPIOD_ACTIVE_LOW;
136 static int gpio_find_and_xlate(struct gpio_desc *desc,
137 struct ofnode_phandle_args *args)
139 struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
142 return ops->xlate(desc->dev, desc, args);
144 return gpio_xlate_offs_flags(desc->dev, desc, args);
147 #if defined(CONFIG_GPIO_HOG)
149 struct gpio_hog_priv {
150 struct gpio_desc gpiod;
153 struct gpio_hog_data {
159 static int gpio_hog_ofdata_to_platdata(struct udevice *dev)
161 struct gpio_hog_data *plat = dev_get_platdata(dev);
162 const char *nodename;
166 if (dev_read_bool(dev, "input")) {
167 plat->gpiod_flags = GPIOD_IS_IN;
168 } else if (dev_read_bool(dev, "output-high")) {
170 plat->gpiod_flags = GPIOD_IS_OUT;
171 } else if (dev_read_bool(dev, "output-low")) {
172 plat->gpiod_flags = GPIOD_IS_OUT;
174 printf("%s: missing gpio-hog state.\n", __func__);
177 ret = dev_read_u32_array(dev, "gpios", plat->val, 2);
179 printf("%s: wrong gpios property, 2 values needed %d\n",
183 nodename = dev_read_string(dev, "line-name");
185 device_set_name(dev, nodename);
190 static int gpio_hog_probe(struct udevice *dev)
192 struct gpio_hog_data *plat = dev_get_platdata(dev);
193 struct gpio_hog_priv *priv = dev_get_priv(dev);
196 ret = gpio_dev_request_index(dev->parent, dev->name, "gpio-hog",
197 plat->val[0], plat->gpiod_flags,
198 plat->val[1], &priv->gpiod);
200 debug("%s: node %s could not get gpio.\n", __func__,
205 if (plat->gpiod_flags == GPIOD_IS_OUT) {
206 ret = dm_gpio_set_value(&priv->gpiod, plat->value);
208 debug("%s: node %s could not set gpio.\n", __func__,
217 int gpio_hog_probe_all(void)
223 for (uclass_first_device(UCLASS_NOP, &dev);
225 uclass_find_next_device(&dev)) {
226 if (dev->driver == DM_GET_DRIVER(gpio_hog)) {
227 ret = device_probe(dev);
229 printf("Failed to probe device %s err: %d\n",
239 int gpio_hog_lookup_name(const char *name, struct gpio_desc **desc)
244 gpio_hog_probe_all();
245 if (!uclass_get_device_by_name(UCLASS_NOP, name, &dev)) {
246 struct gpio_hog_priv *priv = dev_get_priv(dev);
248 *desc = &priv->gpiod;
255 U_BOOT_DRIVER(gpio_hog) = {
258 .ofdata_to_platdata = gpio_hog_ofdata_to_platdata,
259 .probe = gpio_hog_probe,
260 .priv_auto_alloc_size = sizeof(struct gpio_hog_priv),
261 .platdata_auto_alloc_size = sizeof(struct gpio_hog_data),
264 int gpio_hog_lookup_name(const char *name, struct gpio_desc **desc)
270 int dm_gpio_request(struct gpio_desc *desc, const char *label)
272 struct udevice *dev = desc->dev;
273 struct gpio_dev_priv *uc_priv;
277 uc_priv = dev_get_uclass_priv(dev);
278 if (uc_priv->name[desc->offset])
283 if (gpio_get_ops(dev)->request) {
284 ret = gpio_get_ops(dev)->request(dev, desc->offset, label);
290 uc_priv->name[desc->offset] = str;
295 static int dm_gpio_requestf(struct gpio_desc *desc, const char *fmt, ...)
297 #if !defined(CONFIG_SPL_BUILD) || !CONFIG_IS_ENABLED(USE_TINY_PRINTF)
302 vscnprintf(buf, sizeof(buf), fmt, args);
304 return dm_gpio_request(desc, buf);
306 return dm_gpio_request(desc, fmt);
311 * gpio_request() - [COMPAT] Request GPIO
313 * label: Name for the requested GPIO
315 * The label is copied and allocated so the caller does not need to keep
316 * the pointer around.
318 * This function implements the API that's compatible with current
319 * GPIO API used in U-Boot. The request is forwarded to particular
320 * GPIO driver. Returns 0 on success, negative value on error.
322 int gpio_request(unsigned gpio, const char *label)
324 struct gpio_desc desc;
327 ret = gpio_to_device(gpio, &desc);
331 return dm_gpio_request(&desc, label);
335 * gpio_requestf() - [COMPAT] Request GPIO
337 * @fmt: Format string for the requested GPIO
338 * @...: Arguments for the printf() format string
340 * This function implements the API that's compatible with current
341 * GPIO API used in U-Boot. The request is forwarded to particular
342 * GPIO driver. Returns 0 on success, negative value on error.
344 int gpio_requestf(unsigned gpio, const char *fmt, ...)
346 #if !defined(CONFIG_SPL_BUILD) || !CONFIG_IS_ENABLED(USE_TINY_PRINTF)
351 vscnprintf(buf, sizeof(buf), fmt, args);
353 return gpio_request(gpio, buf);
355 return gpio_request(gpio, fmt);
359 int _dm_gpio_free(struct udevice *dev, uint offset)
361 struct gpio_dev_priv *uc_priv;
364 uc_priv = dev_get_uclass_priv(dev);
365 if (!uc_priv->name[offset])
367 if (gpio_get_ops(dev)->free) {
368 ret = gpio_get_ops(dev)->free(dev, offset);
373 free(uc_priv->name[offset]);
374 uc_priv->name[offset] = NULL;
380 * gpio_free() - [COMPAT] Relinquish GPIO
383 * This function implements the API that's compatible with current
384 * GPIO API used in U-Boot. The request is forwarded to particular
385 * GPIO driver. Returns 0 on success, negative value on error.
387 int gpio_free(unsigned gpio)
389 struct gpio_desc desc;
392 ret = gpio_to_device(gpio, &desc);
396 return _dm_gpio_free(desc.dev, desc.offset);
399 static int check_reserved(const struct gpio_desc *desc, const char *func)
401 struct gpio_dev_priv *uc_priv;
403 if (!dm_gpio_is_valid(desc))
406 uc_priv = dev_get_uclass_priv(desc->dev);
407 if (!uc_priv->name[desc->offset]) {
408 printf("%s: %s: error: gpio %s%d not reserved\n",
409 desc->dev->name, func,
410 uc_priv->bank_name ? uc_priv->bank_name : "",
419 * gpio_direction_input() - [COMPAT] Set GPIO direction to input
422 * This function implements the API that's compatible with current
423 * GPIO API used in U-Boot. The request is forwarded to particular
424 * GPIO driver. Returns 0 on success, negative value on error.
426 int gpio_direction_input(unsigned gpio)
428 struct gpio_desc desc;
431 ret = gpio_to_device(gpio, &desc);
434 ret = check_reserved(&desc, "dir_input");
438 return gpio_get_ops(desc.dev)->direction_input(desc.dev, desc.offset);
442 * gpio_direction_output() - [COMPAT] Set GPIO direction to output and set value
444 * value: Logical value to be set on the GPIO pin
446 * This function implements the API that's compatible with current
447 * GPIO API used in U-Boot. The request is forwarded to particular
448 * GPIO driver. Returns 0 on success, negative value on error.
450 int gpio_direction_output(unsigned gpio, int value)
452 struct gpio_desc desc;
455 ret = gpio_to_device(gpio, &desc);
458 ret = check_reserved(&desc, "dir_output");
462 return gpio_get_ops(desc.dev)->direction_output(desc.dev,
466 int dm_gpio_get_value(const struct gpio_desc *desc)
471 ret = check_reserved(desc, "get_value");
475 value = gpio_get_ops(desc->dev)->get_value(desc->dev, desc->offset);
477 return desc->flags & GPIOD_ACTIVE_LOW ? !value : value;
480 int dm_gpio_set_value(const struct gpio_desc *desc, int value)
484 ret = check_reserved(desc, "set_value");
488 if (desc->flags & GPIOD_ACTIVE_LOW)
490 gpio_get_ops(desc->dev)->set_value(desc->dev, desc->offset, value);
494 int dm_gpio_get_open_drain(struct gpio_desc *desc)
496 struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
499 ret = check_reserved(desc, "get_open_drain");
503 if (ops->set_open_drain)
504 return ops->get_open_drain(desc->dev, desc->offset);
509 int dm_gpio_set_open_drain(struct gpio_desc *desc, int value)
511 struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
514 ret = check_reserved(desc, "set_open_drain");
518 if (ops->set_open_drain)
519 ret = ops->set_open_drain(desc->dev, desc->offset, value);
521 return 0; /* feature not supported -> ignore setting */
526 int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
528 struct udevice *dev = desc->dev;
529 struct dm_gpio_ops *ops = gpio_get_ops(dev);
532 ret = check_reserved(desc, "set_dir");
536 if (flags & GPIOD_IS_OUT) {
537 int value = flags & GPIOD_IS_OUT_ACTIVE ? 1 : 0;
539 if (flags & GPIOD_ACTIVE_LOW)
541 ret = ops->direction_output(dev, desc->offset, value);
542 } else if (flags & GPIOD_IS_IN) {
543 ret = ops->direction_input(dev, desc->offset);
548 * Update desc->flags here, so that GPIO_ACTIVE_LOW is honoured in
556 int dm_gpio_set_dir(struct gpio_desc *desc)
558 return dm_gpio_set_dir_flags(desc, desc->flags);
562 * gpio_get_value() - [COMPAT] Sample GPIO pin and return it's value
565 * This function implements the API that's compatible with current
566 * GPIO API used in U-Boot. The request is forwarded to particular
567 * GPIO driver. Returns the value of the GPIO pin, or negative value
570 int gpio_get_value(unsigned gpio)
574 struct gpio_desc desc;
576 ret = gpio_to_device(gpio, &desc);
579 return dm_gpio_get_value(&desc);
583 * gpio_set_value() - [COMPAT] Configure logical value on GPIO pin
585 * value: Logical value to be set on the GPIO pin.
587 * This function implements the API that's compatible with current
588 * GPIO API used in U-Boot. The request is forwarded to particular
589 * GPIO driver. Returns 0 on success, negative value on error.
591 int gpio_set_value(unsigned gpio, int value)
593 struct gpio_desc desc;
596 ret = gpio_to_device(gpio, &desc);
599 return dm_gpio_set_value(&desc, value);
602 const char *gpio_get_bank_info(struct udevice *dev, int *bit_count)
604 struct gpio_dev_priv *priv;
606 /* Must be called on an active device */
607 priv = dev_get_uclass_priv(dev);
610 *bit_count = priv->gpio_count;
611 return priv->bank_name;
614 static const char * const gpio_function[GPIOF_COUNT] = {
622 static int get_function(struct udevice *dev, int offset, bool skip_unused,
625 struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
626 struct dm_gpio_ops *ops = gpio_get_ops(dev);
628 BUILD_BUG_ON(GPIOF_COUNT != ARRAY_SIZE(gpio_function));
629 if (!device_active(dev))
631 if (offset < 0 || offset >= uc_priv->gpio_count)
634 *namep = uc_priv->name[offset];
635 if (skip_unused && !uc_priv->name[offset])
637 if (ops->get_function) {
640 ret = ops->get_function(dev, offset);
643 if (ret >= ARRAY_SIZE(gpio_function))
648 return GPIOF_UNKNOWN;
651 int gpio_get_function(struct udevice *dev, int offset, const char **namep)
653 return get_function(dev, offset, true, namep);
656 int gpio_get_raw_function(struct udevice *dev, int offset, const char **namep)
658 return get_function(dev, offset, false, namep);
661 int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize)
663 struct dm_gpio_ops *ops = gpio_get_ops(dev);
664 struct gpio_dev_priv *priv;
670 BUILD_BUG_ON(GPIOF_COUNT != ARRAY_SIZE(gpio_function));
673 priv = dev_get_uclass_priv(dev);
674 ret = gpio_get_raw_function(dev, offset, NULL);
678 len = snprintf(str, buffsize, "%s%d: %s",
679 priv->bank_name ? priv->bank_name : "",
680 offset, gpio_function[func]);
681 if (func == GPIOF_INPUT || func == GPIOF_OUTPUT ||
682 func == GPIOF_UNUSED) {
686 ret = ops->get_value(dev, offset);
689 used = gpio_get_function(dev, offset, &label) != GPIOF_UNUSED;
690 snprintf(str + len, buffsize - len, ": %d [%c]%s%s",
700 int gpio_claim_vector(const int *gpio_num_array, const char *fmt)
705 for (i = 0; i < 32; i++) {
706 gpio = gpio_num_array[i];
709 ret = gpio_requestf(gpio, fmt, i);
712 ret = gpio_direction_input(gpio);
721 for (i--; i >= 0; i--)
722 gpio_free(gpio_num_array[i]);
728 * get a number comprised of multiple GPIO values. gpio_num_array points to
729 * the array of gpio pin numbers to scan, terminated by -1.
731 int gpio_get_values_as_int(const int *gpio_list)
734 unsigned bitmask = 1;
739 ((gpio = *gpio_list++) != -1)) {
740 ret = gpio_get_value(gpio);
751 int dm_gpio_get_values_as_int(const struct gpio_desc *desc_list, int count)
753 unsigned bitmask = 1;
757 for (i = 0; i < count; i++) {
758 ret = dm_gpio_get_value(&desc_list[i]);
770 * gpio_request_tail: common work for requesting a gpio.
772 * ret: return value from previous work in function which calls
774 * This seems bogus (why calling this function instead not
775 * calling it and end caller function instead?).
776 * Because on error in caller function we want to set some
777 * default values in gpio desc and have a common error
778 * debug message, which provides this function.
779 * nodename: Name of node for which gpio gets requested
780 * used for gpio label name.
781 * args: pointer to output arguments structure
782 * list_name: Name of GPIO list
783 * used for gpio label name.
784 * index: gpio index in gpio list
785 * used for gpio label name.
786 * desc: pointer to gpio descriptor, filled from this
788 * flags: gpio flags to use.
789 * add_index: should index added to gpio label name
790 * gpio_dev: pointer to gpio device from which the gpio
791 * will be requested. If NULL try to get the
792 * gpio device with uclass_get_device_by_ofnode()
794 * return: In error case this function sets default values in
795 * gpio descriptor, also emmits a debug message.
796 * On success it returns 0 else the error code from
797 * function calls, or the error code passed through
798 * ret to this function.
801 static int gpio_request_tail(int ret, const char *nodename,
802 struct ofnode_phandle_args *args,
803 const char *list_name, int index,
804 struct gpio_desc *desc, int flags,
805 bool add_index, struct udevice *gpio_dev)
807 desc->dev = gpio_dev;
814 ret = uclass_get_device_by_ofnode(UCLASS_GPIO, args->node,
817 debug("%s: uclass_get_device_by_ofnode failed\n",
822 ret = gpio_find_and_xlate(desc, args);
824 debug("%s: gpio_find_and_xlate failed\n", __func__);
827 ret = dm_gpio_requestf(desc, add_index ? "%s.%s%d" : "%s.%s",
828 nodename, list_name, index);
830 debug("%s: dm_gpio_requestf failed\n", __func__);
833 ret = dm_gpio_set_dir_flags(desc, flags | desc->flags);
835 debug("%s: dm_gpio_set_dir failed\n", __func__);
841 debug("%s: Node '%s', property '%s', failed to request GPIO index %d: %d\n",
842 __func__, nodename, list_name, index, ret);
846 static int _gpio_request_by_name_nodev(ofnode node, const char *list_name,
847 int index, struct gpio_desc *desc,
848 int flags, bool add_index)
850 struct ofnode_phandle_args args;
853 ret = ofnode_parse_phandle_with_args(node, list_name, "#gpio-cells", 0,
856 return gpio_request_tail(ret, ofnode_get_name(node), &args, list_name,
857 index, desc, flags, add_index, NULL);
860 int gpio_request_by_name_nodev(ofnode node, const char *list_name, int index,
861 struct gpio_desc *desc, int flags)
863 return _gpio_request_by_name_nodev(node, list_name, index, desc, flags,
867 int gpio_request_by_name(struct udevice *dev, const char *list_name, int index,
868 struct gpio_desc *desc, int flags)
870 struct ofnode_phandle_args args;
874 ret = dev_read_phandle_with_args(dev, list_name, "#gpio-cells", 0,
876 node = dev_ofnode(dev);
877 return gpio_request_tail(ret, ofnode_get_name(node), &args, list_name,
878 index, desc, flags, index > 0, NULL);
881 int gpio_request_list_by_name_nodev(ofnode node, const char *list_name,
882 struct gpio_desc *desc, int max_count,
888 for (count = 0; count < max_count; count++) {
889 ret = _gpio_request_by_name_nodev(node, list_name, count,
890 &desc[count], flags, true);
897 /* We ran out of GPIOs in the list */
901 gpio_free_list_nodev(desc, count - 1);
906 int gpio_request_list_by_name(struct udevice *dev, const char *list_name,
907 struct gpio_desc *desc, int max_count,
911 * This isn't ideal since we don't use dev->name in the debug()
912 * calls in gpio_request_by_name(), but we can do this until
913 * gpio_request_list_by_name_nodev() can be dropped.
915 return gpio_request_list_by_name_nodev(dev_ofnode(dev), list_name, desc,
919 int gpio_get_list_count(struct udevice *dev, const char *list_name)
923 ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev),
924 list_name, "#gpio-cells", 0, -1,
927 debug("%s: Node '%s', property '%s', GPIO count failed: %d\n",
928 __func__, dev->name, list_name, ret);
934 int dm_gpio_free(struct udevice *dev, struct gpio_desc *desc)
936 /* For now, we don't do any checking of dev */
937 return _dm_gpio_free(desc->dev, desc->offset);
940 int gpio_free_list(struct udevice *dev, struct gpio_desc *desc, int count)
944 /* For now, we don't do any checking of dev */
945 for (i = 0; i < count; i++)
946 dm_gpio_free(dev, &desc[i]);
951 int gpio_free_list_nodev(struct gpio_desc *desc, int count)
953 return gpio_free_list(NULL, desc, count);
956 /* We need to renumber the GPIOs when any driver is probed/removed */
957 static int gpio_renumber(struct udevice *removed_dev)
959 struct gpio_dev_priv *uc_priv;
965 ret = uclass_get(UCLASS_GPIO, &uc);
969 /* Ensure that we have a base for each bank */
971 uclass_foreach_dev(dev, uc) {
972 if (device_active(dev) && dev != removed_dev) {
973 uc_priv = dev_get_uclass_priv(dev);
974 uc_priv->gpio_base = base;
975 base += uc_priv->gpio_count;
982 int gpio_get_number(const struct gpio_desc *desc)
984 struct udevice *dev = desc->dev;
985 struct gpio_dev_priv *uc_priv;
989 uc_priv = dev->uclass_priv;
991 return uc_priv->gpio_base + desc->offset;
994 static int gpio_post_probe(struct udevice *dev)
996 struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
998 uc_priv->name = calloc(uc_priv->gpio_count, sizeof(char *));
1002 return gpio_renumber(NULL);
1005 static int gpio_pre_remove(struct udevice *dev)
1007 struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
1010 for (i = 0; i < uc_priv->gpio_count; i++) {
1011 if (uc_priv->name[i])
1012 free(uc_priv->name[i]);
1014 free(uc_priv->name);
1016 return gpio_renumber(dev);
1019 int gpio_dev_request_index(struct udevice *dev, const char *nodename,
1020 char *list_name, int index, int flags,
1021 int dtflags, struct gpio_desc *desc)
1023 struct ofnode_phandle_args args;
1025 args.node = ofnode_null();
1026 args.args_count = 2;
1027 args.args[0] = index;
1028 args.args[1] = dtflags;
1030 return gpio_request_tail(0, nodename, &args, list_name, index, desc,
1034 static int gpio_post_bind(struct udevice *dev)
1036 struct udevice *child;
1039 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
1040 struct dm_gpio_ops *ops = (struct dm_gpio_ops *)device_get_ops(dev);
1041 static int reloc_done;
1045 ops->request += gd->reloc_off;
1047 ops->free += gd->reloc_off;
1048 if (ops->direction_input)
1049 ops->direction_input += gd->reloc_off;
1050 if (ops->direction_output)
1051 ops->direction_output += gd->reloc_off;
1053 ops->get_value += gd->reloc_off;
1055 ops->set_value += gd->reloc_off;
1056 if (ops->get_open_drain)
1057 ops->get_open_drain += gd->reloc_off;
1058 if (ops->set_open_drain)
1059 ops->set_open_drain += gd->reloc_off;
1060 if (ops->get_function)
1061 ops->get_function += gd->reloc_off;
1063 ops->xlate += gd->reloc_off;
1069 if (IS_ENABLED(CONFIG_GPIO_HOG)) {
1070 dev_for_each_subnode(node, dev) {
1071 if (ofnode_read_bool(node, "gpio-hog")) {
1072 const char *name = ofnode_get_name(node);
1075 ret = device_bind_driver_to_node(dev,
1087 UCLASS_DRIVER(gpio) = {
1090 .flags = DM_UC_FLAG_SEQ_ALIAS,
1091 .post_probe = gpio_post_probe,
1092 .post_bind = gpio_post_bind,
1093 .pre_remove = gpio_pre_remove,
1094 .per_device_auto_alloc_size = sizeof(struct gpio_dev_priv),