1 // SPDX-License-Identifier: GPL-2.0+
3 * OF helpers for the GPIO API
5 * Copyright (c) 2007-2008 MontaVista Software, Inc.
7 * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
10 #include <linux/device.h>
11 #include <linux/err.h>
12 #include <linux/errno.h>
13 #include <linux/module.h>
15 #include <linux/gpio/consumer.h>
17 #include <linux/of_address.h>
18 #include <linux/of_gpio.h>
19 #include <linux/pinctrl/pinctrl.h>
20 #include <linux/slab.h>
21 #include <linux/gpio/machine.h>
24 #include "gpiolib-of.h"
27 * This is used by external users of of_gpio_count() from <linux/of_gpio.h>
29 * FIXME: get rid of those external users by converting them to GPIO
30 * descriptors and let them all use gpiod_count()
32 int of_gpio_get_count(struct device *dev, const char *con_id)
38 for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {
40 snprintf(propname, sizeof(propname), "%s-%s",
41 con_id, gpio_suffixes[i]);
43 snprintf(propname, sizeof(propname), "%s",
46 ret = of_gpio_named_count(dev->of_node, propname);
50 return ret ? ret : -ENOENT;
53 static int of_gpiochip_match_node_and_xlate(struct gpio_chip *chip, void *data)
55 struct of_phandle_args *gpiospec = data;
57 return chip->gpiodev->dev.of_node == gpiospec->np &&
59 chip->of_xlate(chip, gpiospec, NULL) >= 0;
62 static struct gpio_chip *of_find_gpiochip_by_xlate(
63 struct of_phandle_args *gpiospec)
65 return gpiochip_find(gpiospec, of_gpiochip_match_node_and_xlate);
68 static struct gpio_desc *of_xlate_and_get_gpiod_flags(struct gpio_chip *chip,
69 struct of_phandle_args *gpiospec,
70 enum of_gpio_flags *flags)
74 if (chip->of_gpio_n_cells != gpiospec->args_count)
75 return ERR_PTR(-EINVAL);
77 ret = chip->of_xlate(chip, gpiospec, flags);
81 return gpiochip_get_desc(chip, ret);
85 * of_gpio_need_valid_mask() - figure out if the OF GPIO driver needs
86 * to set the .valid_mask
87 * @gc: the target gpio_chip
89 * Return: true if the valid mask needs to be set
91 bool of_gpio_need_valid_mask(const struct gpio_chip *gc)
94 struct device_node *np = gc->of_node;
96 size = of_property_count_u32_elems(np, "gpio-reserved-ranges");
97 if (size > 0 && size % 2 == 0)
102 static void of_gpio_flags_quirks(struct device_node *np,
103 const char *propname,
104 enum of_gpio_flags *flags,
108 * Handle MMC "cd-inverted" and "wp-inverted" semantics.
110 if (IS_ENABLED(CONFIG_MMC)) {
112 * Active low is the default according to the
113 * SDHCI specification and the device tree
114 * bindings. However the code in the current
115 * kernel was written such that the phandle
116 * flags were always respected, and "cd-inverted"
117 * would invert the flag from the device phandle.
119 if (!strcmp(propname, "cd-gpios")) {
120 if (of_property_read_bool(np, "cd-inverted"))
121 *flags ^= OF_GPIO_ACTIVE_LOW;
123 if (!strcmp(propname, "wp-gpios")) {
124 if (of_property_read_bool(np, "wp-inverted"))
125 *flags ^= OF_GPIO_ACTIVE_LOW;
129 * Some GPIO fixed regulator quirks.
130 * Note that active low is the default.
132 if (IS_ENABLED(CONFIG_REGULATOR) &&
133 (of_device_is_compatible(np, "regulator-fixed") ||
134 of_device_is_compatible(np, "reg-fixed-voltage") ||
135 (!(strcmp(propname, "enable-gpio") &&
136 strcmp(propname, "enable-gpios")) &&
137 of_device_is_compatible(np, "regulator-gpio")))) {
138 bool active_low = !of_property_read_bool(np,
139 "enable-active-high");
141 * The regulator GPIO handles are specified such that the
142 * presence or absence of "enable-active-high" solely controls
143 * the polarity of the GPIO line. Any phandle flags must
144 * be actively ignored.
146 if ((*flags & OF_GPIO_ACTIVE_LOW) && !active_low) {
147 pr_warn("%s GPIO handle specifies active low - ignored\n",
148 of_node_full_name(np));
149 *flags &= ~OF_GPIO_ACTIVE_LOW;
152 *flags |= OF_GPIO_ACTIVE_LOW;
155 * Legacy open drain handling for fixed voltage regulators.
157 if (IS_ENABLED(CONFIG_REGULATOR) &&
158 of_device_is_compatible(np, "reg-fixed-voltage") &&
159 of_property_read_bool(np, "gpio-open-drain")) {
160 *flags |= (OF_GPIO_SINGLE_ENDED | OF_GPIO_OPEN_DRAIN);
161 pr_info("%s uses legacy open drain flag - update the DTS if you can\n",
162 of_node_full_name(np));
166 * Legacy handling of SPI active high chip select. If we have a
167 * property named "cs-gpios" we need to inspect the child node
168 * to determine if the flags should have inverted semantics.
170 if (IS_ENABLED(CONFIG_SPI_MASTER) && !strcmp(propname, "cs-gpios") &&
171 of_property_read_bool(np, "cs-gpios")) {
172 struct device_node *child;
176 for_each_child_of_node(np, child) {
177 ret = of_property_read_u32(child, "reg", &cs);
182 * SPI children have active low chip selects
183 * by default. This can be specified negatively
184 * by just omitting "spi-cs-high" in the
185 * device node, or actively by tagging on
186 * GPIO_ACTIVE_LOW as flag in the device
187 * tree. If the line is simultaneously
188 * tagged as active low in the device tree
189 * and has the "spi-cs-high" set, we get a
190 * conflict and the "spi-cs-high" flag will
193 if (of_property_read_bool(child, "spi-cs-high")) {
194 if (*flags & OF_GPIO_ACTIVE_LOW) {
195 pr_warn("%s GPIO handle specifies active low - ignored\n",
196 of_node_full_name(child));
197 *flags &= ~OF_GPIO_ACTIVE_LOW;
200 if (!(*flags & OF_GPIO_ACTIVE_LOW))
201 pr_info("%s enforce active low on chipselect handle\n",
202 of_node_full_name(child));
203 *flags |= OF_GPIO_ACTIVE_LOW;
211 /* Legacy handling of stmmac's active-low PHY reset line */
212 if (IS_ENABLED(CONFIG_STMMAC_ETH) &&
213 !strcmp(propname, "snps,reset-gpio") &&
214 of_property_read_bool(np, "snps,reset-active-low"))
215 *flags |= OF_GPIO_ACTIVE_LOW;
219 * of_get_named_gpiod_flags() - Get a GPIO descriptor and flags for GPIO API
220 * @np: device node to get GPIO from
221 * @propname: property name containing gpio specifier(s)
222 * @index: index of the GPIO
223 * @flags: a flags pointer to fill in
225 * Returns GPIO descriptor to use with Linux GPIO API, or one of the errno
226 * value on the error condition. If @flags is not NULL the function also fills
227 * in flags for the GPIO.
229 static struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np,
230 const char *propname, int index, enum of_gpio_flags *flags)
232 struct of_phandle_args gpiospec;
233 struct gpio_chip *chip;
234 struct gpio_desc *desc;
237 ret = of_parse_phandle_with_args_map(np, propname, "gpio", index,
240 pr_debug("%s: can't parse '%s' property of node '%pOF[%d]'\n",
241 __func__, propname, np, index);
245 chip = of_find_gpiochip_by_xlate(&gpiospec);
247 desc = ERR_PTR(-EPROBE_DEFER);
251 desc = of_xlate_and_get_gpiod_flags(chip, &gpiospec, flags);
256 of_gpio_flags_quirks(np, propname, flags, index);
258 pr_debug("%s: parsed '%s' property of node '%pOF[%d]' - status (%d)\n",
259 __func__, propname, np, index,
260 PTR_ERR_OR_ZERO(desc));
263 of_node_put(gpiospec.np);
268 int of_get_named_gpio_flags(struct device_node *np, const char *list_name,
269 int index, enum of_gpio_flags *flags)
271 struct gpio_desc *desc;
273 desc = of_get_named_gpiod_flags(np, list_name, index, flags);
276 return PTR_ERR(desc);
278 return desc_to_gpio(desc);
280 EXPORT_SYMBOL_GPL(of_get_named_gpio_flags);
283 * gpiod_get_from_of_node() - obtain a GPIO from an OF node
284 * @node: handle of the OF node
285 * @propname: name of the DT property representing the GPIO
286 * @index: index of the GPIO to obtain for the consumer
287 * @dflags: GPIO initialization flags
288 * @label: label to attach to the requested GPIO
291 * On successful request the GPIO pin is configured in accordance with
294 * In case of error an ERR_PTR() is returned.
296 struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
297 const char *propname, int index,
298 enum gpiod_flags dflags,
301 unsigned long lflags = GPIO_LOOKUP_FLAGS_DEFAULT;
302 struct gpio_desc *desc;
303 enum of_gpio_flags flags;
304 bool active_low = false;
305 bool single_ended = false;
306 bool open_drain = false;
307 bool transitory = false;
310 desc = of_get_named_gpiod_flags(node, propname,
313 if (!desc || IS_ERR(desc)) {
317 active_low = flags & OF_GPIO_ACTIVE_LOW;
318 single_ended = flags & OF_GPIO_SINGLE_ENDED;
319 open_drain = flags & OF_GPIO_OPEN_DRAIN;
320 transitory = flags & OF_GPIO_TRANSITORY;
322 ret = gpiod_request(desc, label);
323 if (ret == -EBUSY && (dflags & GPIOD_FLAGS_BIT_NONEXCLUSIVE))
329 lflags |= GPIO_ACTIVE_LOW;
333 lflags |= GPIO_OPEN_DRAIN;
335 lflags |= GPIO_OPEN_SOURCE;
339 lflags |= GPIO_TRANSITORY;
341 ret = gpiod_configure_flags(desc, propname, lflags, dflags);
349 EXPORT_SYMBOL_GPL(gpiod_get_from_of_node);
352 * The SPI GPIO bindings happened before we managed to establish that GPIO
353 * properties should be named "foo-gpios" so we have this special kludge for
356 static struct gpio_desc *of_find_spi_gpio(struct device *dev, const char *con_id,
357 enum of_gpio_flags *of_flags)
359 char prop_name[32]; /* 32 is max size of property name */
360 struct device_node *np = dev->of_node;
361 struct gpio_desc *desc;
364 * Hopefully the compiler stubs the rest of the function if this
367 if (!IS_ENABLED(CONFIG_SPI_MASTER))
368 return ERR_PTR(-ENOENT);
370 /* Allow this specifically for "spi-gpio" devices */
371 if (!of_device_is_compatible(np, "spi-gpio") || !con_id)
372 return ERR_PTR(-ENOENT);
374 /* Will be "gpio-sck", "gpio-mosi" or "gpio-miso" */
375 snprintf(prop_name, sizeof(prop_name), "%s-%s", "gpio", con_id);
377 desc = of_get_named_gpiod_flags(np, prop_name, 0, of_flags);
382 * The old Freescale bindings use simply "gpios" as name for the chip select
383 * lines rather than "cs-gpios" like all other SPI hardware. Account for this
384 * with a special quirk.
386 static struct gpio_desc *of_find_spi_cs_gpio(struct device *dev,
389 unsigned long *flags)
391 struct device_node *np = dev->of_node;
393 if (!IS_ENABLED(CONFIG_SPI_MASTER))
394 return ERR_PTR(-ENOENT);
396 /* Allow this specifically for Freescale devices */
397 if (!of_device_is_compatible(np, "fsl,spi") &&
398 !of_device_is_compatible(np, "aeroflexgaisler,spictrl"))
399 return ERR_PTR(-ENOENT);
400 /* Allow only if asking for "cs-gpios" */
401 if (!con_id || strcmp(con_id, "cs"))
402 return ERR_PTR(-ENOENT);
405 * While all other SPI controllers use "cs-gpios" the Freescale
406 * uses just "gpios" so translate to that when "cs-gpios" is
409 return of_find_gpio(dev, NULL, idx, flags);
413 * Some regulator bindings happened before we managed to establish that GPIO
414 * properties should be named "foo-gpios" so we have this special kludge for
417 static struct gpio_desc *of_find_regulator_gpio(struct device *dev, const char *con_id,
418 enum of_gpio_flags *of_flags)
420 /* These are the connection IDs we accept as legacy GPIO phandles */
421 const char *whitelist[] = {
422 "wlf,ldoena", /* Arizona */
423 "wlf,ldo1ena", /* WM8994 */
424 "wlf,ldo2ena", /* WM8994 */
426 struct device_node *np = dev->of_node;
427 struct gpio_desc *desc;
430 if (!IS_ENABLED(CONFIG_REGULATOR))
431 return ERR_PTR(-ENOENT);
434 return ERR_PTR(-ENOENT);
436 i = match_string(whitelist, ARRAY_SIZE(whitelist), con_id);
438 return ERR_PTR(-ENOENT);
440 desc = of_get_named_gpiod_flags(np, con_id, 0, of_flags);
444 static struct gpio_desc *of_find_arizona_gpio(struct device *dev,
446 enum of_gpio_flags *of_flags)
448 if (!IS_ENABLED(CONFIG_MFD_ARIZONA))
449 return ERR_PTR(-ENOENT);
451 if (!con_id || strcmp(con_id, "wlf,reset"))
452 return ERR_PTR(-ENOENT);
454 return of_get_named_gpiod_flags(dev->of_node, con_id, 0, of_flags);
457 struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
458 unsigned int idx, unsigned long *flags)
460 char prop_name[32]; /* 32 is max size of property name */
461 enum of_gpio_flags of_flags;
462 struct gpio_desc *desc;
465 /* Try GPIO property "foo-gpios" and "foo-gpio" */
466 for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {
468 snprintf(prop_name, sizeof(prop_name), "%s-%s", con_id,
471 snprintf(prop_name, sizeof(prop_name), "%s",
474 desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx,
477 if (!IS_ERR(desc) || PTR_ERR(desc) != -ENOENT)
481 if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT) {
482 /* Special handling for SPI GPIOs if used */
483 desc = of_find_spi_gpio(dev, con_id, &of_flags);
486 if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT) {
487 /* This quirk looks up flags and all */
488 desc = of_find_spi_cs_gpio(dev, con_id, idx, flags);
493 if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT) {
494 /* Special handling for regulator GPIOs if used */
495 desc = of_find_regulator_gpio(dev, con_id, &of_flags);
498 if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT)
499 desc = of_find_arizona_gpio(dev, con_id, &of_flags);
504 if (of_flags & OF_GPIO_ACTIVE_LOW)
505 *flags |= GPIO_ACTIVE_LOW;
507 if (of_flags & OF_GPIO_SINGLE_ENDED) {
508 if (of_flags & OF_GPIO_OPEN_DRAIN)
509 *flags |= GPIO_OPEN_DRAIN;
511 *flags |= GPIO_OPEN_SOURCE;
514 if (of_flags & OF_GPIO_TRANSITORY)
515 *flags |= GPIO_TRANSITORY;
517 if (of_flags & OF_GPIO_PULL_UP)
518 *flags |= GPIO_PULL_UP;
519 if (of_flags & OF_GPIO_PULL_DOWN)
520 *flags |= GPIO_PULL_DOWN;
526 * of_parse_own_gpio() - Get a GPIO hog descriptor, names and flags for GPIO API
527 * @np: device node to get GPIO from
528 * @chip: GPIO chip whose hog is parsed
529 * @idx: Index of the GPIO to parse
530 * @name: GPIO line name
531 * @lflags: bitmask of gpio_lookup_flags GPIO_* values - returned from
532 * of_find_gpio() or of_parse_own_gpio()
533 * @dflags: gpiod_flags - optional GPIO initialization flags
535 * Returns GPIO descriptor to use with Linux GPIO API, or one of the errno
536 * value on the error condition.
538 static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
539 struct gpio_chip *chip,
540 unsigned int idx, const char **name,
541 unsigned long *lflags,
542 enum gpiod_flags *dflags)
544 struct device_node *chip_np;
545 enum of_gpio_flags xlate_flags;
546 struct of_phandle_args gpiospec;
547 struct gpio_desc *desc;
552 chip_np = chip->of_node;
554 return ERR_PTR(-EINVAL);
557 *lflags = GPIO_LOOKUP_FLAGS_DEFAULT;
560 ret = of_property_read_u32(chip_np, "#gpio-cells", &tmp);
564 gpiospec.np = chip_np;
565 gpiospec.args_count = tmp;
567 for (i = 0; i < tmp; i++) {
568 ret = of_property_read_u32_index(np, "gpios", idx * tmp + i,
574 desc = of_xlate_and_get_gpiod_flags(chip, &gpiospec, &xlate_flags);
578 if (xlate_flags & OF_GPIO_ACTIVE_LOW)
579 *lflags |= GPIO_ACTIVE_LOW;
580 if (xlate_flags & OF_GPIO_TRANSITORY)
581 *lflags |= GPIO_TRANSITORY;
583 if (of_property_read_bool(np, "input"))
585 else if (of_property_read_bool(np, "output-low"))
586 *dflags |= GPIOD_OUT_LOW;
587 else if (of_property_read_bool(np, "output-high"))
588 *dflags |= GPIOD_OUT_HIGH;
590 pr_warn("GPIO line %d (%pOFn): no hogging state specified, bailing out\n",
591 desc_to_gpio(desc), np);
592 return ERR_PTR(-EINVAL);
595 if (name && of_property_read_string(np, "line-name", name))
602 * of_gpiochip_scan_gpios - Scan gpio-controller for gpio definitions
603 * @chip: gpio chip to act on
605 * This is only used by of_gpiochip_add to request/set GPIO initial
607 * It returns error if it fails otherwise 0 on success.
609 static int of_gpiochip_scan_gpios(struct gpio_chip *chip)
611 struct gpio_desc *desc = NULL;
612 struct device_node *np;
614 unsigned long lflags;
615 enum gpiod_flags dflags;
619 for_each_available_child_of_node(chip->of_node, np) {
620 if (!of_property_read_bool(np, "gpio-hog"))
624 desc = of_parse_own_gpio(np, chip, i, &name, &lflags,
629 ret = gpiod_hog(desc, name, lflags, dflags);
641 * of_gpio_simple_xlate - translate gpiospec to the GPIO number and flags
642 * @gc: pointer to the gpio_chip structure
643 * @gpiospec: GPIO specifier as found in the device tree
644 * @flags: a flags pointer to fill in
646 * This is simple translation function, suitable for the most 1:1 mapped
647 * GPIO chips. This function performs only one sanity check: whether GPIO
648 * is less than ngpios (that is specified in the gpio_chip).
650 static int of_gpio_simple_xlate(struct gpio_chip *gc,
651 const struct of_phandle_args *gpiospec,
655 * We're discouraging gpio_cells < 2, since that way you'll have to
656 * write your own xlate function (that will have to retrieve the GPIO
657 * number and the flags from a single gpio cell -- this is possible,
658 * but not recommended).
660 if (gc->of_gpio_n_cells < 2) {
665 if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells))
668 if (gpiospec->args[0] >= gc->ngpio)
672 *flags = gpiospec->args[1];
674 return gpiospec->args[0];
678 * of_mm_gpiochip_add_data - Add memory mapped GPIO chip (bank)
679 * @np: device node of the GPIO chip
680 * @mm_gc: pointer to the of_mm_gpio_chip allocated structure
681 * @data: driver data to store in the struct gpio_chip
683 * To use this function you should allocate and fill mm_gc with:
685 * 1) In the gpio_chip structure:
686 * - all the callbacks
688 * - of_xlate callback (optional)
690 * 3) In the of_mm_gpio_chip structure:
691 * - save_regs callback (optional)
693 * If succeeded, this function will map bank's memory and will
694 * do all necessary work for you. Then you'll able to use .regs
695 * to manage GPIOs from the callbacks.
697 int of_mm_gpiochip_add_data(struct device_node *np,
698 struct of_mm_gpio_chip *mm_gc,
702 struct gpio_chip *gc = &mm_gc->gc;
704 gc->label = kasprintf(GFP_KERNEL, "%pOF", np);
708 mm_gc->regs = of_iomap(np, 0);
714 if (mm_gc->save_regs)
715 mm_gc->save_regs(mm_gc);
717 mm_gc->gc.of_node = np;
719 ret = gpiochip_add_data(gc, data);
725 iounmap(mm_gc->regs);
729 pr_err("%pOF: GPIO chip registration failed with status %d\n", np, ret);
732 EXPORT_SYMBOL_GPL(of_mm_gpiochip_add_data);
735 * of_mm_gpiochip_remove - Remove memory mapped GPIO chip (bank)
736 * @mm_gc: pointer to the of_mm_gpio_chip allocated structure
738 void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc)
740 struct gpio_chip *gc = &mm_gc->gc;
746 iounmap(mm_gc->regs);
749 EXPORT_SYMBOL_GPL(of_mm_gpiochip_remove);
751 static void of_gpiochip_init_valid_mask(struct gpio_chip *chip)
755 struct device_node *np = chip->of_node;
757 len = of_property_count_u32_elems(np, "gpio-reserved-ranges");
758 if (len < 0 || len % 2 != 0)
761 for (i = 0; i < len; i += 2) {
762 of_property_read_u32_index(np, "gpio-reserved-ranges",
764 of_property_read_u32_index(np, "gpio-reserved-ranges",
766 if (start >= chip->ngpio || start + count >= chip->ngpio)
769 bitmap_clear(chip->valid_mask, start, count);
773 #ifdef CONFIG_PINCTRL
774 static int of_gpiochip_add_pin_range(struct gpio_chip *chip)
776 struct device_node *np = chip->of_node;
777 struct of_phandle_args pinspec;
778 struct pinctrl_dev *pctldev;
781 static const char group_names_propname[] = "gpio-ranges-group-names";
782 struct property *group_names;
787 group_names = of_find_property(np, group_names_propname, NULL);
790 ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3,
795 pctldev = of_pinctrl_get(pinspec.np);
796 of_node_put(pinspec.np);
798 return -EPROBE_DEFER;
800 if (pinspec.args[2]) {
802 of_property_read_string_index(np,
803 group_names_propname,
806 pr_err("%pOF: Group name of numeric GPIO ranges must be the empty string.\n",
811 /* npins != 0: linear range */
812 ret = gpiochip_add_pin_range(chip,
813 pinctrl_dev_get_devname(pctldev),
820 /* npins == 0: special range */
821 if (pinspec.args[1]) {
822 pr_err("%pOF: Illegal gpio-range format.\n",
828 pr_err("%pOF: GPIO group range requested but no %s property.\n",
829 np, group_names_propname);
833 ret = of_property_read_string_index(np,
834 group_names_propname,
840 pr_err("%pOF: Group name of GPIO group range cannot be the empty string.\n",
845 ret = gpiochip_add_pingroup_range(chip, pctldev,
846 pinspec.args[0], name);
856 static int of_gpiochip_add_pin_range(struct gpio_chip *chip) { return 0; }
859 int of_gpiochip_add(struct gpio_chip *chip)
866 if (!chip->of_xlate) {
867 chip->of_gpio_n_cells = 2;
868 chip->of_xlate = of_gpio_simple_xlate;
871 if (chip->of_gpio_n_cells > MAX_PHANDLE_ARGS)
874 of_gpiochip_init_valid_mask(chip);
876 ret = of_gpiochip_add_pin_range(chip);
880 /* If the chip defines names itself, these take precedence */
882 devprop_gpiochip_set_names(chip,
883 of_fwnode_handle(chip->of_node));
885 of_node_get(chip->of_node);
887 ret = of_gpiochip_scan_gpios(chip);
889 of_node_put(chip->of_node);
894 void of_gpiochip_remove(struct gpio_chip *chip)
896 of_node_put(chip->of_node);