gpiolib-of.c 16 KB

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