gpio-uclass.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. /*
  2. * Copyright (c) 2013 Google, Inc
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <dm.h>
  8. #include <errno.h>
  9. #include <fdtdec.h>
  10. #include <malloc.h>
  11. #include <asm/gpio.h>
  12. #include <linux/ctype.h>
  13. DECLARE_GLOBAL_DATA_PTR;
  14. /**
  15. * gpio_to_device() - Convert global GPIO number to device, number
  16. *
  17. * Convert the GPIO number to an entry in the list of GPIOs
  18. * or GPIO blocks registered with the GPIO controller. Returns
  19. * entry on success, NULL on error.
  20. *
  21. * @gpio: The numeric representation of the GPIO
  22. * @desc: Returns description (desc->flags will always be 0)
  23. * @return 0 if found, -ENOENT if not found
  24. */
  25. static int gpio_to_device(unsigned int gpio, struct gpio_desc *desc)
  26. {
  27. struct gpio_dev_priv *uc_priv;
  28. struct udevice *dev;
  29. int ret;
  30. for (ret = uclass_first_device(UCLASS_GPIO, &dev);
  31. dev;
  32. ret = uclass_next_device(&dev)) {
  33. uc_priv = dev->uclass_priv;
  34. if (gpio >= uc_priv->gpio_base &&
  35. gpio < uc_priv->gpio_base + uc_priv->gpio_count) {
  36. desc->dev = dev;
  37. desc->offset = gpio - uc_priv->gpio_base;
  38. desc->flags = 0;
  39. return 0;
  40. }
  41. }
  42. /* No such GPIO */
  43. return ret ? ret : -ENOENT;
  44. }
  45. int gpio_lookup_name(const char *name, struct udevice **devp,
  46. unsigned int *offsetp, unsigned int *gpiop)
  47. {
  48. struct gpio_dev_priv *uc_priv = NULL;
  49. struct udevice *dev;
  50. ulong offset;
  51. int numeric;
  52. int ret;
  53. if (devp)
  54. *devp = NULL;
  55. numeric = isdigit(*name) ? simple_strtoul(name, NULL, 10) : -1;
  56. for (ret = uclass_first_device(UCLASS_GPIO, &dev);
  57. dev;
  58. ret = uclass_next_device(&dev)) {
  59. int len;
  60. uc_priv = dev->uclass_priv;
  61. if (numeric != -1) {
  62. offset = numeric - uc_priv->gpio_base;
  63. /* Allow GPIOs to be numbered from 0 */
  64. if (offset >= 0 && offset < uc_priv->gpio_count)
  65. break;
  66. }
  67. len = uc_priv->bank_name ? strlen(uc_priv->bank_name) : 0;
  68. if (!strncasecmp(name, uc_priv->bank_name, len)) {
  69. if (!strict_strtoul(name + len, 10, &offset))
  70. break;
  71. }
  72. }
  73. if (!dev)
  74. return ret ? ret : -EINVAL;
  75. if (devp)
  76. *devp = dev;
  77. if (offsetp)
  78. *offsetp = offset;
  79. if (gpiop)
  80. *gpiop = uc_priv->gpio_base + offset;
  81. return 0;
  82. }
  83. static int gpio_find_and_xlate(struct gpio_desc *desc,
  84. struct fdtdec_phandle_args *args)
  85. {
  86. struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
  87. /* Use the first argument as the offset by default */
  88. if (args->args_count > 0)
  89. desc->offset = args->args[0];
  90. else
  91. desc->offset = -1;
  92. desc->flags = 0;
  93. return ops->xlate ? ops->xlate(desc->dev, desc, args) : 0;
  94. }
  95. static int dm_gpio_request(struct gpio_desc *desc, const char *label)
  96. {
  97. struct udevice *dev = desc->dev;
  98. struct gpio_dev_priv *uc_priv;
  99. char *str;
  100. int ret;
  101. uc_priv = dev->uclass_priv;
  102. if (uc_priv->name[desc->offset])
  103. return -EBUSY;
  104. str = strdup(label);
  105. if (!str)
  106. return -ENOMEM;
  107. if (gpio_get_ops(dev)->request) {
  108. ret = gpio_get_ops(dev)->request(dev, desc->offset, label);
  109. if (ret) {
  110. free(str);
  111. return ret;
  112. }
  113. }
  114. uc_priv->name[desc->offset] = str;
  115. return 0;
  116. }
  117. static int dm_gpio_requestf(struct gpio_desc *desc, const char *fmt, ...)
  118. {
  119. va_list args;
  120. char buf[40];
  121. va_start(args, fmt);
  122. vscnprintf(buf, sizeof(buf), fmt, args);
  123. va_end(args);
  124. return dm_gpio_request(desc, buf);
  125. }
  126. /**
  127. * gpio_request() - [COMPAT] Request GPIO
  128. * gpio: GPIO number
  129. * label: Name for the requested GPIO
  130. *
  131. * The label is copied and allocated so the caller does not need to keep
  132. * the pointer around.
  133. *
  134. * This function implements the API that's compatible with current
  135. * GPIO API used in U-Boot. The request is forwarded to particular
  136. * GPIO driver. Returns 0 on success, negative value on error.
  137. */
  138. int gpio_request(unsigned gpio, const char *label)
  139. {
  140. struct gpio_desc desc;
  141. int ret;
  142. ret = gpio_to_device(gpio, &desc);
  143. if (ret)
  144. return ret;
  145. return dm_gpio_request(&desc, label);
  146. }
  147. /**
  148. * gpio_requestf() - [COMPAT] Request GPIO
  149. * @gpio: GPIO number
  150. * @fmt: Format string for the requested GPIO
  151. * @...: Arguments for the printf() format string
  152. *
  153. * This function implements the API that's compatible with current
  154. * GPIO API used in U-Boot. The request is forwarded to particular
  155. * GPIO driver. Returns 0 on success, negative value on error.
  156. */
  157. int gpio_requestf(unsigned gpio, const char *fmt, ...)
  158. {
  159. va_list args;
  160. char buf[40];
  161. va_start(args, fmt);
  162. vscnprintf(buf, sizeof(buf), fmt, args);
  163. va_end(args);
  164. return gpio_request(gpio, buf);
  165. }
  166. int _dm_gpio_free(struct udevice *dev, uint offset)
  167. {
  168. struct gpio_dev_priv *uc_priv;
  169. int ret;
  170. uc_priv = dev->uclass_priv;
  171. if (!uc_priv->name[offset])
  172. return -ENXIO;
  173. if (gpio_get_ops(dev)->free) {
  174. ret = gpio_get_ops(dev)->free(dev, offset);
  175. if (ret)
  176. return ret;
  177. }
  178. free(uc_priv->name[offset]);
  179. uc_priv->name[offset] = NULL;
  180. return 0;
  181. }
  182. /**
  183. * gpio_free() - [COMPAT] Relinquish GPIO
  184. * gpio: GPIO number
  185. *
  186. * This function implements the API that's compatible with current
  187. * GPIO API used in U-Boot. The request is forwarded to particular
  188. * GPIO driver. Returns 0 on success, negative value on error.
  189. */
  190. int gpio_free(unsigned gpio)
  191. {
  192. struct gpio_desc desc;
  193. int ret;
  194. ret = gpio_to_device(gpio, &desc);
  195. if (ret)
  196. return ret;
  197. return _dm_gpio_free(desc.dev, desc.offset);
  198. }
  199. static int check_reserved(struct gpio_desc *desc, const char *func)
  200. {
  201. struct gpio_dev_priv *uc_priv = desc->dev->uclass_priv;
  202. if (!uc_priv->name[desc->offset]) {
  203. printf("%s: %s: error: gpio %s%d not reserved\n",
  204. desc->dev->name, func,
  205. uc_priv->bank_name ? uc_priv->bank_name : "",
  206. desc->offset);
  207. return -EBUSY;
  208. }
  209. return 0;
  210. }
  211. /**
  212. * gpio_direction_input() - [COMPAT] Set GPIO direction to input
  213. * gpio: GPIO number
  214. *
  215. * This function implements the API that's compatible with current
  216. * GPIO API used in U-Boot. The request is forwarded to particular
  217. * GPIO driver. Returns 0 on success, negative value on error.
  218. */
  219. int gpio_direction_input(unsigned gpio)
  220. {
  221. struct gpio_desc desc;
  222. int ret;
  223. ret = gpio_to_device(gpio, &desc);
  224. if (ret)
  225. return ret;
  226. ret = check_reserved(&desc, "dir_input");
  227. if (ret)
  228. return ret;
  229. return gpio_get_ops(desc.dev)->direction_input(desc.dev, desc.offset);
  230. }
  231. /**
  232. * gpio_direction_output() - [COMPAT] Set GPIO direction to output and set value
  233. * gpio: GPIO number
  234. * value: Logical value to be set on the GPIO pin
  235. *
  236. * This function implements the API that's compatible with current
  237. * GPIO API used in U-Boot. The request is forwarded to particular
  238. * GPIO driver. Returns 0 on success, negative value on error.
  239. */
  240. int gpio_direction_output(unsigned gpio, int value)
  241. {
  242. struct gpio_desc desc;
  243. int ret;
  244. ret = gpio_to_device(gpio, &desc);
  245. if (ret)
  246. return ret;
  247. ret = check_reserved(&desc, "dir_output");
  248. if (ret)
  249. return ret;
  250. return gpio_get_ops(desc.dev)->direction_output(desc.dev,
  251. desc.offset, value);
  252. }
  253. int dm_gpio_get_value(struct gpio_desc *desc)
  254. {
  255. int value;
  256. int ret;
  257. ret = check_reserved(desc, "get_value");
  258. if (ret)
  259. return ret;
  260. value = gpio_get_ops(desc->dev)->get_value(desc->dev, desc->offset);
  261. return desc->flags & GPIOD_ACTIVE_LOW ? !value : value;
  262. }
  263. int dm_gpio_set_value(struct gpio_desc *desc, int value)
  264. {
  265. int ret;
  266. ret = check_reserved(desc, "set_value");
  267. if (ret)
  268. return ret;
  269. if (desc->flags & GPIOD_ACTIVE_LOW)
  270. value = !value;
  271. gpio_get_ops(desc->dev)->set_value(desc->dev, desc->offset, value);
  272. return 0;
  273. }
  274. int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
  275. {
  276. struct udevice *dev = desc->dev;
  277. struct dm_gpio_ops *ops = gpio_get_ops(dev);
  278. int ret;
  279. ret = check_reserved(desc, "set_dir");
  280. if (ret)
  281. return ret;
  282. if (flags & GPIOD_IS_OUT) {
  283. int value = flags & GPIOD_IS_OUT_ACTIVE ? 1 : 0;
  284. if (flags & GPIOD_ACTIVE_LOW)
  285. value = !value;
  286. ret = ops->direction_output(dev, desc->offset, value);
  287. } else if (flags & GPIOD_IS_IN) {
  288. ret = ops->direction_input(dev, desc->offset);
  289. }
  290. if (ret)
  291. return ret;
  292. /*
  293. * Update desc->flags here, so that GPIO_ACTIVE_LOW is honoured in
  294. * futures
  295. */
  296. desc->flags = flags;
  297. return 0;
  298. }
  299. int dm_gpio_set_dir(struct gpio_desc *desc)
  300. {
  301. return dm_gpio_set_dir_flags(desc, desc->flags);
  302. }
  303. /**
  304. * gpio_get_value() - [COMPAT] Sample GPIO pin and return it's value
  305. * gpio: GPIO number
  306. *
  307. * This function implements the API that's compatible with current
  308. * GPIO API used in U-Boot. The request is forwarded to particular
  309. * GPIO driver. Returns the value of the GPIO pin, or negative value
  310. * on error.
  311. */
  312. int gpio_get_value(unsigned gpio)
  313. {
  314. int ret;
  315. struct gpio_desc desc;
  316. ret = gpio_to_device(gpio, &desc);
  317. if (ret)
  318. return ret;
  319. return dm_gpio_get_value(&desc);
  320. }
  321. /**
  322. * gpio_set_value() - [COMPAT] Configure logical value on GPIO pin
  323. * gpio: GPIO number
  324. * value: Logical value to be set on the GPIO pin.
  325. *
  326. * This function implements the API that's compatible with current
  327. * GPIO API used in U-Boot. The request is forwarded to particular
  328. * GPIO driver. Returns 0 on success, negative value on error.
  329. */
  330. int gpio_set_value(unsigned gpio, int value)
  331. {
  332. struct gpio_desc desc;
  333. int ret;
  334. ret = gpio_to_device(gpio, &desc);
  335. if (ret)
  336. return ret;
  337. return dm_gpio_set_value(&desc, value);
  338. }
  339. const char *gpio_get_bank_info(struct udevice *dev, int *bit_count)
  340. {
  341. struct gpio_dev_priv *priv;
  342. /* Must be called on an active device */
  343. priv = dev->uclass_priv;
  344. assert(priv);
  345. *bit_count = priv->gpio_count;
  346. return priv->bank_name;
  347. }
  348. static const char * const gpio_function[GPIOF_COUNT] = {
  349. "input",
  350. "output",
  351. "unused",
  352. "unknown",
  353. "func",
  354. };
  355. int get_function(struct udevice *dev, int offset, bool skip_unused,
  356. const char **namep)
  357. {
  358. struct gpio_dev_priv *uc_priv = dev->uclass_priv;
  359. struct dm_gpio_ops *ops = gpio_get_ops(dev);
  360. BUILD_BUG_ON(GPIOF_COUNT != ARRAY_SIZE(gpio_function));
  361. if (!device_active(dev))
  362. return -ENODEV;
  363. if (offset < 0 || offset >= uc_priv->gpio_count)
  364. return -EINVAL;
  365. if (namep)
  366. *namep = uc_priv->name[offset];
  367. if (skip_unused && !uc_priv->name[offset])
  368. return GPIOF_UNUSED;
  369. if (ops->get_function) {
  370. int ret;
  371. ret = ops->get_function(dev, offset);
  372. if (ret < 0)
  373. return ret;
  374. if (ret >= ARRAY_SIZE(gpio_function))
  375. return -ENODATA;
  376. return ret;
  377. }
  378. return GPIOF_UNKNOWN;
  379. }
  380. int gpio_get_function(struct udevice *dev, int offset, const char **namep)
  381. {
  382. return get_function(dev, offset, true, namep);
  383. }
  384. int gpio_get_raw_function(struct udevice *dev, int offset, const char **namep)
  385. {
  386. return get_function(dev, offset, false, namep);
  387. }
  388. int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize)
  389. {
  390. struct dm_gpio_ops *ops = gpio_get_ops(dev);
  391. struct gpio_dev_priv *priv;
  392. char *str = buf;
  393. int func;
  394. int ret;
  395. int len;
  396. BUILD_BUG_ON(GPIOF_COUNT != ARRAY_SIZE(gpio_function));
  397. *buf = 0;
  398. priv = dev->uclass_priv;
  399. ret = gpio_get_raw_function(dev, offset, NULL);
  400. if (ret < 0)
  401. return ret;
  402. func = ret;
  403. len = snprintf(str, buffsize, "%s%d: %s",
  404. priv->bank_name ? priv->bank_name : "",
  405. offset, gpio_function[func]);
  406. if (func == GPIOF_INPUT || func == GPIOF_OUTPUT ||
  407. func == GPIOF_UNUSED) {
  408. const char *label;
  409. bool used;
  410. ret = ops->get_value(dev, offset);
  411. if (ret < 0)
  412. return ret;
  413. used = gpio_get_function(dev, offset, &label) != GPIOF_UNUSED;
  414. snprintf(str + len, buffsize - len, ": %d [%c]%s%s",
  415. ret,
  416. used ? 'x' : ' ',
  417. used ? " " : "",
  418. label ? label : "");
  419. }
  420. return 0;
  421. }
  422. /*
  423. * get a number comprised of multiple GPIO values. gpio_num_array points to
  424. * the array of gpio pin numbers to scan, terminated by -1.
  425. */
  426. unsigned gpio_get_values_as_int(const int *gpio_num_array)
  427. {
  428. int gpio;
  429. unsigned bitmask = 1;
  430. unsigned vector = 0;
  431. while (bitmask &&
  432. ((gpio = *gpio_num_array++) != -1)) {
  433. if (gpio_get_value(gpio))
  434. vector |= bitmask;
  435. bitmask <<= 1;
  436. }
  437. return vector;
  438. }
  439. static int _gpio_request_by_name_nodev(const void *blob, int node,
  440. const char *list_name, int index,
  441. struct gpio_desc *desc, int flags,
  442. bool add_index)
  443. {
  444. struct fdtdec_phandle_args args;
  445. int ret;
  446. desc->dev = NULL;
  447. desc->offset = 0;
  448. ret = fdtdec_parse_phandle_with_args(blob, node, list_name,
  449. "#gpio-cells", 0, index, &args);
  450. if (ret) {
  451. debug("%s: fdtdec_parse_phandle_with_args failed\n", __func__);
  452. goto err;
  453. }
  454. ret = uclass_get_device_by_of_offset(UCLASS_GPIO, args.node,
  455. &desc->dev);
  456. if (ret) {
  457. debug("%s: uclass_get_device_by_of_offset failed\n", __func__);
  458. goto err;
  459. }
  460. ret = gpio_find_and_xlate(desc, &args);
  461. if (ret) {
  462. debug("%s: gpio_find_and_xlate failed\n", __func__);
  463. goto err;
  464. }
  465. ret = dm_gpio_requestf(desc, add_index ? "%s.%s%d" : "%s.%s",
  466. fdt_get_name(blob, node, NULL),
  467. list_name, index);
  468. if (ret) {
  469. debug("%s: dm_gpio_requestf failed\n", __func__);
  470. goto err;
  471. }
  472. ret = dm_gpio_set_dir_flags(desc, flags | desc->flags);
  473. if (ret) {
  474. debug("%s: dm_gpio_set_dir failed\n", __func__);
  475. goto err;
  476. }
  477. return 0;
  478. err:
  479. debug("%s: Node '%s', property '%s', failed to request GPIO index %d: %d\n",
  480. __func__, fdt_get_name(blob, node, NULL), list_name, index, ret);
  481. return ret;
  482. }
  483. int gpio_request_by_name_nodev(const void *blob, int node,
  484. const char *list_name, int index,
  485. struct gpio_desc *desc, int flags)
  486. {
  487. return _gpio_request_by_name_nodev(blob, node, list_name, index, desc,
  488. flags, index > 0);
  489. }
  490. int gpio_request_by_name(struct udevice *dev, const char *list_name, int index,
  491. struct gpio_desc *desc, int flags)
  492. {
  493. /*
  494. * This isn't ideal since we don't use dev->name in the debug()
  495. * calls in gpio_request_by_name(), but we can do this until
  496. * gpio_request_by_name_nodev() can be dropped.
  497. */
  498. return gpio_request_by_name_nodev(gd->fdt_blob, dev->of_offset,
  499. list_name, index, desc, flags);
  500. }
  501. int gpio_request_list_by_name_nodev(const void *blob, int node,
  502. const char *list_name,
  503. struct gpio_desc *desc, int max_count,
  504. int flags)
  505. {
  506. int count;
  507. int ret;
  508. for (count = 0; ; count++) {
  509. if (count >= max_count) {
  510. ret = -ENOSPC;
  511. goto err;
  512. }
  513. ret = _gpio_request_by_name_nodev(blob, node, list_name, count,
  514. &desc[count], flags, true);
  515. if (ret == -ENOENT)
  516. break;
  517. else if (ret)
  518. goto err;
  519. }
  520. /* We ran out of GPIOs in the list */
  521. return count;
  522. err:
  523. gpio_free_list_nodev(desc, count - 1);
  524. return ret;
  525. }
  526. int gpio_request_list_by_name(struct udevice *dev, const char *list_name,
  527. struct gpio_desc *desc, int max_count,
  528. int flags)
  529. {
  530. /*
  531. * This isn't ideal since we don't use dev->name in the debug()
  532. * calls in gpio_request_by_name(), but we can do this until
  533. * gpio_request_list_by_name_nodev() can be dropped.
  534. */
  535. return gpio_request_list_by_name_nodev(gd->fdt_blob, dev->of_offset,
  536. list_name, desc, max_count,
  537. flags);
  538. }
  539. int gpio_get_list_count(struct udevice *dev, const char *list_name)
  540. {
  541. int ret;
  542. ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev->of_offset,
  543. list_name, "#gpio-cells", 0, -1,
  544. NULL);
  545. if (ret) {
  546. debug("%s: Node '%s', property '%s', GPIO count failed: %d\n",
  547. __func__, dev->name, list_name, ret);
  548. }
  549. return ret;
  550. }
  551. int dm_gpio_free(struct udevice *dev, struct gpio_desc *desc)
  552. {
  553. /* For now, we don't do any checking of dev */
  554. return _dm_gpio_free(desc->dev, desc->offset);
  555. }
  556. int gpio_free_list(struct udevice *dev, struct gpio_desc *desc, int count)
  557. {
  558. int i;
  559. /* For now, we don't do any checking of dev */
  560. for (i = 0; i < count; i++)
  561. dm_gpio_free(dev, &desc[i]);
  562. return 0;
  563. }
  564. int gpio_free_list_nodev(struct gpio_desc *desc, int count)
  565. {
  566. return gpio_free_list(NULL, desc, count);
  567. }
  568. /* We need to renumber the GPIOs when any driver is probed/removed */
  569. static int gpio_renumber(struct udevice *removed_dev)
  570. {
  571. struct gpio_dev_priv *uc_priv;
  572. struct udevice *dev;
  573. struct uclass *uc;
  574. unsigned base;
  575. int ret;
  576. ret = uclass_get(UCLASS_GPIO, &uc);
  577. if (ret)
  578. return ret;
  579. /* Ensure that we have a base for each bank */
  580. base = 0;
  581. uclass_foreach_dev(dev, uc) {
  582. if (device_active(dev) && dev != removed_dev) {
  583. uc_priv = dev->uclass_priv;
  584. uc_priv->gpio_base = base;
  585. base += uc_priv->gpio_count;
  586. }
  587. }
  588. return 0;
  589. }
  590. static int gpio_post_probe(struct udevice *dev)
  591. {
  592. struct gpio_dev_priv *uc_priv = dev->uclass_priv;
  593. uc_priv->name = calloc(uc_priv->gpio_count, sizeof(char *));
  594. if (!uc_priv->name)
  595. return -ENOMEM;
  596. return gpio_renumber(NULL);
  597. }
  598. static int gpio_pre_remove(struct udevice *dev)
  599. {
  600. struct gpio_dev_priv *uc_priv = dev->uclass_priv;
  601. int i;
  602. for (i = 0; i < uc_priv->gpio_count; i++) {
  603. if (uc_priv->name[i])
  604. free(uc_priv->name[i]);
  605. }
  606. free(uc_priv->name);
  607. return gpio_renumber(dev);
  608. }
  609. UCLASS_DRIVER(gpio) = {
  610. .id = UCLASS_GPIO,
  611. .name = "gpio",
  612. .post_probe = gpio_post_probe,
  613. .pre_remove = gpio_pre_remove,
  614. .per_device_auto_alloc_size = sizeof(struct gpio_dev_priv),
  615. };