gpiolib-of.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. /*
  2. * OF helpers for the GPIO API
  3. *
  4. * Copyright (c) 2007-2008 MontaVista Software, Inc.
  5. *
  6. * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #include <linux/device.h>
  14. #include <linux/err.h>
  15. #include <linux/errno.h>
  16. #include <linux/module.h>
  17. #include <linux/io.h>
  18. #include <linux/gpio/consumer.h>
  19. #include <linux/of.h>
  20. #include <linux/of_address.h>
  21. #include <linux/of_gpio.h>
  22. #include <linux/pinctrl/pinctrl.h>
  23. #include <linux/slab.h>
  24. #include <linux/gpio/machine.h>
  25. #include "gpiolib.h"
  26. static int of_gpiochip_match_node_and_xlate(struct gpio_chip *chip, void *data)
  27. {
  28. struct of_phandle_args *gpiospec = data;
  29. return chip->gpiodev->dev.of_node == gpiospec->np &&
  30. chip->of_xlate(chip, gpiospec, NULL) >= 0;
  31. }
  32. static struct gpio_chip *of_find_gpiochip_by_xlate(
  33. struct of_phandle_args *gpiospec)
  34. {
  35. return gpiochip_find(gpiospec, of_gpiochip_match_node_and_xlate);
  36. }
  37. static struct gpio_desc *of_xlate_and_get_gpiod_flags(struct gpio_chip *chip,
  38. struct of_phandle_args *gpiospec,
  39. enum of_gpio_flags *flags)
  40. {
  41. int ret;
  42. if (chip->of_gpio_n_cells != gpiospec->args_count)
  43. return ERR_PTR(-EINVAL);
  44. ret = chip->of_xlate(chip, gpiospec, flags);
  45. if (ret < 0)
  46. return ERR_PTR(ret);
  47. return gpiochip_get_desc(chip, ret);
  48. }
  49. static void of_gpio_flags_quirks(struct device_node *np,
  50. enum of_gpio_flags *flags)
  51. {
  52. /*
  53. * Some GPIO fixed regulator quirks.
  54. * Note that active low is the default.
  55. */
  56. if (IS_ENABLED(CONFIG_REGULATOR) &&
  57. (of_device_is_compatible(np, "reg-fixed-voltage") ||
  58. of_device_is_compatible(np, "regulator-gpio"))) {
  59. /*
  60. * The regulator GPIO handles are specified such that the
  61. * presence or absence of "enable-active-high" solely controls
  62. * the polarity of the GPIO line. Any phandle flags must
  63. * be actively ignored.
  64. */
  65. if (*flags & OF_GPIO_ACTIVE_LOW) {
  66. pr_warn("%s GPIO handle specifies active low - ignored\n",
  67. of_node_full_name(np));
  68. *flags &= ~OF_GPIO_ACTIVE_LOW;
  69. }
  70. if (!of_property_read_bool(np, "enable-active-high"))
  71. *flags |= OF_GPIO_ACTIVE_LOW;
  72. }
  73. /*
  74. * Legacy open drain handling for fixed voltage regulators.
  75. */
  76. if (IS_ENABLED(CONFIG_REGULATOR) &&
  77. of_device_is_compatible(np, "reg-fixed-voltage") &&
  78. of_property_read_bool(np, "gpio-open-drain")) {
  79. *flags |= (OF_GPIO_SINGLE_ENDED | OF_GPIO_OPEN_DRAIN);
  80. pr_info("%s uses legacy open drain flag - update the DTS if you can\n",
  81. of_node_full_name(np));
  82. }
  83. }
  84. /**
  85. * of_get_named_gpiod_flags() - Get a GPIO descriptor and flags for GPIO API
  86. * @np: device node to get GPIO from
  87. * @propname: property name containing gpio specifier(s)
  88. * @index: index of the GPIO
  89. * @flags: a flags pointer to fill in
  90. *
  91. * Returns GPIO descriptor to use with Linux GPIO API, or one of the errno
  92. * value on the error condition. If @flags is not NULL the function also fills
  93. * in flags for the GPIO.
  94. */
  95. struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np,
  96. const char *propname, int index, enum of_gpio_flags *flags)
  97. {
  98. struct of_phandle_args gpiospec;
  99. struct gpio_chip *chip;
  100. struct gpio_desc *desc;
  101. int ret;
  102. ret = of_parse_phandle_with_args_map(np, propname, "gpio", index,
  103. &gpiospec);
  104. if (ret) {
  105. pr_debug("%s: can't parse '%s' property of node '%pOF[%d]'\n",
  106. __func__, propname, np, index);
  107. return ERR_PTR(ret);
  108. }
  109. chip = of_find_gpiochip_by_xlate(&gpiospec);
  110. if (!chip) {
  111. desc = ERR_PTR(-EPROBE_DEFER);
  112. goto out;
  113. }
  114. desc = of_xlate_and_get_gpiod_flags(chip, &gpiospec, flags);
  115. if (IS_ERR(desc))
  116. goto out;
  117. if (flags)
  118. of_gpio_flags_quirks(np, flags);
  119. pr_debug("%s: parsed '%s' property of node '%pOF[%d]' - status (%d)\n",
  120. __func__, propname, np, index,
  121. PTR_ERR_OR_ZERO(desc));
  122. out:
  123. of_node_put(gpiospec.np);
  124. return desc;
  125. }
  126. int of_get_named_gpio_flags(struct device_node *np, const char *list_name,
  127. int index, enum of_gpio_flags *flags)
  128. {
  129. struct gpio_desc *desc;
  130. desc = of_get_named_gpiod_flags(np, list_name, index, flags);
  131. if (IS_ERR(desc))
  132. return PTR_ERR(desc);
  133. else
  134. return desc_to_gpio(desc);
  135. }
  136. EXPORT_SYMBOL(of_get_named_gpio_flags);
  137. /*
  138. * The SPI GPIO bindings happened before we managed to establish that GPIO
  139. * properties should be named "foo-gpios" so we have this special kludge for
  140. * them.
  141. */
  142. static struct gpio_desc *of_find_spi_gpio(struct device *dev, const char *con_id,
  143. enum of_gpio_flags *of_flags)
  144. {
  145. char prop_name[32]; /* 32 is max size of property name */
  146. struct device_node *np = dev->of_node;
  147. struct gpio_desc *desc;
  148. /*
  149. * Hopefully the compiler stubs the rest of the function if this
  150. * is false.
  151. */
  152. if (!IS_ENABLED(CONFIG_SPI_MASTER))
  153. return ERR_PTR(-ENOENT);
  154. /* Allow this specifically for "spi-gpio" devices */
  155. if (!of_device_is_compatible(np, "spi-gpio") || !con_id)
  156. return ERR_PTR(-ENOENT);
  157. /* Will be "gpio-sck", "gpio-mosi" or "gpio-miso" */
  158. snprintf(prop_name, sizeof(prop_name), "%s-%s", "gpio", con_id);
  159. desc = of_get_named_gpiod_flags(np, prop_name, 0, of_flags);
  160. return desc;
  161. }
  162. /*
  163. * Some regulator bindings happened before we managed to establish that GPIO
  164. * properties should be named "foo-gpios" so we have this special kludge for
  165. * them.
  166. */
  167. static struct gpio_desc *of_find_regulator_gpio(struct device *dev, const char *con_id,
  168. enum of_gpio_flags *of_flags)
  169. {
  170. /* These are the connection IDs we accept as legacy GPIO phandles */
  171. const char *whitelist[] = {
  172. "wlf,ldoena", /* Arizona */
  173. "wlf,ldo1ena", /* WM8994 */
  174. "wlf,ldo2ena", /* WM8994 */
  175. };
  176. struct device_node *np = dev->of_node;
  177. struct gpio_desc *desc;
  178. int i;
  179. if (!IS_ENABLED(CONFIG_REGULATOR))
  180. return ERR_PTR(-ENOENT);
  181. if (!con_id)
  182. return ERR_PTR(-ENOENT);
  183. i = match_string(whitelist, ARRAY_SIZE(whitelist), con_id);
  184. if (i < 0)
  185. return ERR_PTR(-ENOENT);
  186. desc = of_get_named_gpiod_flags(np, con_id, 0, of_flags);
  187. return desc;
  188. }
  189. struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
  190. unsigned int idx,
  191. enum gpio_lookup_flags *flags)
  192. {
  193. char prop_name[32]; /* 32 is max size of property name */
  194. enum of_gpio_flags of_flags;
  195. struct gpio_desc *desc;
  196. unsigned int i;
  197. /* Try GPIO property "foo-gpios" and "foo-gpio" */
  198. for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {
  199. if (con_id)
  200. snprintf(prop_name, sizeof(prop_name), "%s-%s", con_id,
  201. gpio_suffixes[i]);
  202. else
  203. snprintf(prop_name, sizeof(prop_name), "%s",
  204. gpio_suffixes[i]);
  205. desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx,
  206. &of_flags);
  207. /*
  208. * -EPROBE_DEFER in our case means that we found a
  209. * valid GPIO property, but no controller has been
  210. * registered so far.
  211. *
  212. * This means we don't need to look any further for
  213. * alternate name conventions, and we should really
  214. * preserve the return code for our user to be able to
  215. * retry probing later.
  216. */
  217. if (IS_ERR(desc) && PTR_ERR(desc) == -EPROBE_DEFER)
  218. return desc;
  219. if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))
  220. break;
  221. }
  222. /* Special handling for SPI GPIOs if used */
  223. if (IS_ERR(desc))
  224. desc = of_find_spi_gpio(dev, con_id, &of_flags);
  225. /* Special handling for regulator GPIOs if used */
  226. if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER)
  227. desc = of_find_regulator_gpio(dev, con_id, &of_flags);
  228. if (IS_ERR(desc))
  229. return desc;
  230. if (of_flags & OF_GPIO_ACTIVE_LOW)
  231. *flags |= GPIO_ACTIVE_LOW;
  232. if (of_flags & OF_GPIO_SINGLE_ENDED) {
  233. if (of_flags & OF_GPIO_OPEN_DRAIN)
  234. *flags |= GPIO_OPEN_DRAIN;
  235. else
  236. *flags |= GPIO_OPEN_SOURCE;
  237. }
  238. if (of_flags & OF_GPIO_TRANSITORY)
  239. *flags |= GPIO_TRANSITORY;
  240. return desc;
  241. }
  242. /**
  243. * of_parse_own_gpio() - Get a GPIO hog descriptor, names and flags for GPIO API
  244. * @np: device node to get GPIO from
  245. * @chip: GPIO chip whose hog is parsed
  246. * @idx: Index of the GPIO to parse
  247. * @name: GPIO line name
  248. * @lflags: gpio_lookup_flags - returned from of_find_gpio() or
  249. * of_parse_own_gpio()
  250. * @dflags: gpiod_flags - optional GPIO initialization flags
  251. *
  252. * Returns GPIO descriptor to use with Linux GPIO API, or one of the errno
  253. * value on the error condition.
  254. */
  255. static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
  256. struct gpio_chip *chip,
  257. unsigned int idx, const char **name,
  258. enum gpio_lookup_flags *lflags,
  259. enum gpiod_flags *dflags)
  260. {
  261. struct device_node *chip_np;
  262. enum of_gpio_flags xlate_flags;
  263. struct of_phandle_args gpiospec;
  264. struct gpio_desc *desc;
  265. unsigned int i;
  266. u32 tmp;
  267. int ret;
  268. chip_np = chip->of_node;
  269. if (!chip_np)
  270. return ERR_PTR(-EINVAL);
  271. xlate_flags = 0;
  272. *lflags = 0;
  273. *dflags = 0;
  274. ret = of_property_read_u32(chip_np, "#gpio-cells", &tmp);
  275. if (ret)
  276. return ERR_PTR(ret);
  277. gpiospec.np = chip_np;
  278. gpiospec.args_count = tmp;
  279. for (i = 0; i < tmp; i++) {
  280. ret = of_property_read_u32_index(np, "gpios", idx * tmp + i,
  281. &gpiospec.args[i]);
  282. if (ret)
  283. return ERR_PTR(ret);
  284. }
  285. desc = of_xlate_and_get_gpiod_flags(chip, &gpiospec, &xlate_flags);
  286. if (IS_ERR(desc))
  287. return desc;
  288. if (xlate_flags & OF_GPIO_ACTIVE_LOW)
  289. *lflags |= GPIO_ACTIVE_LOW;
  290. if (xlate_flags & OF_GPIO_TRANSITORY)
  291. *lflags |= GPIO_TRANSITORY;
  292. if (of_property_read_bool(np, "input"))
  293. *dflags |= GPIOD_IN;
  294. else if (of_property_read_bool(np, "output-low"))
  295. *dflags |= GPIOD_OUT_LOW;
  296. else if (of_property_read_bool(np, "output-high"))
  297. *dflags |= GPIOD_OUT_HIGH;
  298. else {
  299. pr_warn("GPIO line %d (%s): no hogging state specified, bailing out\n",
  300. desc_to_gpio(desc), np->name);
  301. return ERR_PTR(-EINVAL);
  302. }
  303. if (name && of_property_read_string(np, "line-name", name))
  304. *name = np->name;
  305. return desc;
  306. }
  307. /**
  308. * of_gpiochip_scan_gpios - Scan gpio-controller for gpio definitions
  309. * @chip: gpio chip to act on
  310. *
  311. * This is only used by of_gpiochip_add to request/set GPIO initial
  312. * configuration.
  313. * It returns error if it fails otherwise 0 on success.
  314. */
  315. static int of_gpiochip_scan_gpios(struct gpio_chip *chip)
  316. {
  317. struct gpio_desc *desc = NULL;
  318. struct device_node *np;
  319. const char *name;
  320. enum gpio_lookup_flags lflags;
  321. enum gpiod_flags dflags;
  322. unsigned int i;
  323. int ret;
  324. for_each_available_child_of_node(chip->of_node, np) {
  325. if (!of_property_read_bool(np, "gpio-hog"))
  326. continue;
  327. for (i = 0;; i++) {
  328. desc = of_parse_own_gpio(np, chip, i, &name, &lflags,
  329. &dflags);
  330. if (IS_ERR(desc))
  331. break;
  332. ret = gpiod_hog(desc, name, lflags, dflags);
  333. if (ret < 0) {
  334. of_node_put(np);
  335. return ret;
  336. }
  337. }
  338. }
  339. return 0;
  340. }
  341. /**
  342. * of_gpio_simple_xlate - translate gpiospec to the GPIO number and flags
  343. * @gc: pointer to the gpio_chip structure
  344. * @gpiospec: GPIO specifier as found in the device tree
  345. * @flags: a flags pointer to fill in
  346. *
  347. * This is simple translation function, suitable for the most 1:1 mapped
  348. * GPIO chips. This function performs only one sanity check: whether GPIO
  349. * is less than ngpios (that is specified in the gpio_chip).
  350. */
  351. int of_gpio_simple_xlate(struct gpio_chip *gc,
  352. const struct of_phandle_args *gpiospec, u32 *flags)
  353. {
  354. /*
  355. * We're discouraging gpio_cells < 2, since that way you'll have to
  356. * write your own xlate function (that will have to retrieve the GPIO
  357. * number and the flags from a single gpio cell -- this is possible,
  358. * but not recommended).
  359. */
  360. if (gc->of_gpio_n_cells < 2) {
  361. WARN_ON(1);
  362. return -EINVAL;
  363. }
  364. if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells))
  365. return -EINVAL;
  366. if (gpiospec->args[0] >= gc->ngpio)
  367. return -EINVAL;
  368. if (flags)
  369. *flags = gpiospec->args[1];
  370. return gpiospec->args[0];
  371. }
  372. EXPORT_SYMBOL(of_gpio_simple_xlate);
  373. /**
  374. * of_mm_gpiochip_add_data - Add memory mapped GPIO chip (bank)
  375. * @np: device node of the GPIO chip
  376. * @mm_gc: pointer to the of_mm_gpio_chip allocated structure
  377. * @data: driver data to store in the struct gpio_chip
  378. *
  379. * To use this function you should allocate and fill mm_gc with:
  380. *
  381. * 1) In the gpio_chip structure:
  382. * - all the callbacks
  383. * - of_gpio_n_cells
  384. * - of_xlate callback (optional)
  385. *
  386. * 3) In the of_mm_gpio_chip structure:
  387. * - save_regs callback (optional)
  388. *
  389. * If succeeded, this function will map bank's memory and will
  390. * do all necessary work for you. Then you'll able to use .regs
  391. * to manage GPIOs from the callbacks.
  392. */
  393. int of_mm_gpiochip_add_data(struct device_node *np,
  394. struct of_mm_gpio_chip *mm_gc,
  395. void *data)
  396. {
  397. int ret = -ENOMEM;
  398. struct gpio_chip *gc = &mm_gc->gc;
  399. gc->label = kasprintf(GFP_KERNEL, "%pOF", np);
  400. if (!gc->label)
  401. goto err0;
  402. mm_gc->regs = of_iomap(np, 0);
  403. if (!mm_gc->regs)
  404. goto err1;
  405. gc->base = -1;
  406. if (mm_gc->save_regs)
  407. mm_gc->save_regs(mm_gc);
  408. mm_gc->gc.of_node = np;
  409. ret = gpiochip_add_data(gc, data);
  410. if (ret)
  411. goto err2;
  412. return 0;
  413. err2:
  414. iounmap(mm_gc->regs);
  415. err1:
  416. kfree(gc->label);
  417. err0:
  418. pr_err("%pOF: GPIO chip registration failed with status %d\n", np, ret);
  419. return ret;
  420. }
  421. EXPORT_SYMBOL(of_mm_gpiochip_add_data);
  422. /**
  423. * of_mm_gpiochip_remove - Remove memory mapped GPIO chip (bank)
  424. * @mm_gc: pointer to the of_mm_gpio_chip allocated structure
  425. */
  426. void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc)
  427. {
  428. struct gpio_chip *gc = &mm_gc->gc;
  429. if (!mm_gc)
  430. return;
  431. gpiochip_remove(gc);
  432. iounmap(mm_gc->regs);
  433. kfree(gc->label);
  434. }
  435. EXPORT_SYMBOL(of_mm_gpiochip_remove);
  436. static void of_gpiochip_init_valid_mask(struct gpio_chip *chip)
  437. {
  438. int len, i;
  439. u32 start, count;
  440. struct device_node *np = chip->of_node;
  441. len = of_property_count_u32_elems(np, "gpio-reserved-ranges");
  442. if (len < 0 || len % 2 != 0)
  443. return;
  444. for (i = 0; i < len; i += 2) {
  445. of_property_read_u32_index(np, "gpio-reserved-ranges",
  446. i, &start);
  447. of_property_read_u32_index(np, "gpio-reserved-ranges",
  448. i + 1, &count);
  449. if (start >= chip->ngpio || start + count >= chip->ngpio)
  450. continue;
  451. bitmap_clear(chip->valid_mask, start, count);
  452. }
  453. };
  454. #ifdef CONFIG_PINCTRL
  455. static int of_gpiochip_add_pin_range(struct gpio_chip *chip)
  456. {
  457. struct device_node *np = chip->of_node;
  458. struct of_phandle_args pinspec;
  459. struct pinctrl_dev *pctldev;
  460. int index = 0, ret;
  461. const char *name;
  462. static const char group_names_propname[] = "gpio-ranges-group-names";
  463. struct property *group_names;
  464. if (!np)
  465. return 0;
  466. group_names = of_find_property(np, group_names_propname, NULL);
  467. for (;; index++) {
  468. ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3,
  469. index, &pinspec);
  470. if (ret)
  471. break;
  472. pctldev = of_pinctrl_get(pinspec.np);
  473. of_node_put(pinspec.np);
  474. if (!pctldev)
  475. return -EPROBE_DEFER;
  476. if (pinspec.args[2]) {
  477. if (group_names) {
  478. of_property_read_string_index(np,
  479. group_names_propname,
  480. index, &name);
  481. if (strlen(name)) {
  482. pr_err("%pOF: Group name of numeric GPIO ranges must be the empty string.\n",
  483. np);
  484. break;
  485. }
  486. }
  487. /* npins != 0: linear range */
  488. ret = gpiochip_add_pin_range(chip,
  489. pinctrl_dev_get_devname(pctldev),
  490. pinspec.args[0],
  491. pinspec.args[1],
  492. pinspec.args[2]);
  493. if (ret)
  494. return ret;
  495. } else {
  496. /* npins == 0: special range */
  497. if (pinspec.args[1]) {
  498. pr_err("%pOF: Illegal gpio-range format.\n",
  499. np);
  500. break;
  501. }
  502. if (!group_names) {
  503. pr_err("%pOF: GPIO group range requested but no %s property.\n",
  504. np, group_names_propname);
  505. break;
  506. }
  507. ret = of_property_read_string_index(np,
  508. group_names_propname,
  509. index, &name);
  510. if (ret)
  511. break;
  512. if (!strlen(name)) {
  513. pr_err("%pOF: Group name of GPIO group range cannot be the empty string.\n",
  514. np);
  515. break;
  516. }
  517. ret = gpiochip_add_pingroup_range(chip, pctldev,
  518. pinspec.args[0], name);
  519. if (ret)
  520. return ret;
  521. }
  522. }
  523. return 0;
  524. }
  525. #else
  526. static int of_gpiochip_add_pin_range(struct gpio_chip *chip) { return 0; }
  527. #endif
  528. int of_gpiochip_add(struct gpio_chip *chip)
  529. {
  530. int status;
  531. if ((!chip->of_node) && (chip->parent))
  532. chip->of_node = chip->parent->of_node;
  533. if (!chip->of_node)
  534. return 0;
  535. if (!chip->of_xlate) {
  536. chip->of_gpio_n_cells = 2;
  537. chip->of_xlate = of_gpio_simple_xlate;
  538. }
  539. if (chip->of_gpio_n_cells > MAX_PHANDLE_ARGS)
  540. return -EINVAL;
  541. of_gpiochip_init_valid_mask(chip);
  542. status = of_gpiochip_add_pin_range(chip);
  543. if (status)
  544. return status;
  545. /* If the chip defines names itself, these take precedence */
  546. if (!chip->names)
  547. devprop_gpiochip_set_names(chip,
  548. of_fwnode_handle(chip->of_node));
  549. of_node_get(chip->of_node);
  550. return of_gpiochip_scan_gpios(chip);
  551. }
  552. void of_gpiochip_remove(struct gpio_chip *chip)
  553. {
  554. gpiochip_remove_pin_ranges(chip);
  555. of_node_put(chip->of_node);
  556. }