pinmux.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. /*
  2. * Core driver for the pin muxing portions of the pin control subsystem
  3. *
  4. * Copyright (C) 2011-2012 ST-Ericsson SA
  5. * Written on behalf of Linaro for ST-Ericsson
  6. * Based on bits of regulator core, gpio core and clk core
  7. *
  8. * Author: Linus Walleij <linus.walleij@linaro.org>
  9. *
  10. * License terms: GNU General Public License (GPL) version 2
  11. */
  12. #define pr_fmt(fmt) "pinmux core: " fmt
  13. #include <linux/kernel.h>
  14. #include <linux/module.h>
  15. #include <linux/init.h>
  16. #include <linux/device.h>
  17. #include <linux/slab.h>
  18. #include <linux/radix-tree.h>
  19. #include <linux/err.h>
  20. #include <linux/list.h>
  21. #include <linux/mutex.h>
  22. #include <linux/spinlock.h>
  23. #include <linux/string.h>
  24. #include <linux/sysfs.h>
  25. #include <linux/debugfs.h>
  26. #include <linux/seq_file.h>
  27. #include <linux/pinctrl/machine.h>
  28. #include <linux/pinctrl/pinmux.h>
  29. #include "core.h"
  30. #include "pinmux.h"
  31. /**
  32. * struct pinmux_group - group list item for pinmux groups
  33. * @node: pinmux group list node
  34. * @group_selector: the group selector for this group
  35. */
  36. struct pinmux_group {
  37. struct list_head node;
  38. unsigned group_selector;
  39. };
  40. int pinmux_check_ops(struct pinctrl_dev *pctldev)
  41. {
  42. const struct pinmux_ops *ops = pctldev->desc->pmxops;
  43. unsigned selector = 0;
  44. /* Check that we implement required operations */
  45. if (!ops->list_functions ||
  46. !ops->get_function_name ||
  47. !ops->get_function_groups ||
  48. !ops->enable ||
  49. !ops->disable)
  50. return -EINVAL;
  51. /* Check that all functions registered have names */
  52. while (ops->list_functions(pctldev, selector) >= 0) {
  53. const char *fname = ops->get_function_name(pctldev,
  54. selector);
  55. if (!fname) {
  56. pr_err("pinmux ops has no name for function%u\n",
  57. selector);
  58. return -EINVAL;
  59. }
  60. selector++;
  61. }
  62. return 0;
  63. }
  64. /**
  65. * pin_request() - request a single pin to be muxed in, typically for GPIO
  66. * @pin: the pin number in the global pin space
  67. * @function: a functional name to give to this pin, passed to the driver
  68. * so it knows what function to mux in, e.g. the string "gpioNN"
  69. * means that you want to mux in the pin for use as GPIO number NN
  70. * @gpio_range: the range matching the GPIO pin if this is a request for a
  71. * single GPIO pin
  72. */
  73. static int pin_request(struct pinctrl_dev *pctldev,
  74. int pin, const char *function,
  75. struct pinctrl_gpio_range *gpio_range)
  76. {
  77. struct pin_desc *desc;
  78. const struct pinmux_ops *ops = pctldev->desc->pmxops;
  79. int status = -EINVAL;
  80. dev_dbg(pctldev->dev, "request pin %d for %s\n", pin, function);
  81. desc = pin_desc_get(pctldev, pin);
  82. if (desc == NULL) {
  83. dev_err(pctldev->dev,
  84. "pin is not registered so it cannot be requested\n");
  85. goto out;
  86. }
  87. if (!function) {
  88. dev_err(pctldev->dev, "no function name given\n");
  89. return -EINVAL;
  90. }
  91. spin_lock(&desc->lock);
  92. if (desc->mux_function) {
  93. spin_unlock(&desc->lock);
  94. dev_err(pctldev->dev,
  95. "pin already requested\n");
  96. goto out;
  97. }
  98. desc->mux_function = function;
  99. spin_unlock(&desc->lock);
  100. /* Let each pin increase references to this module */
  101. if (!try_module_get(pctldev->owner)) {
  102. dev_err(pctldev->dev,
  103. "could not increase module refcount for pin %d\n",
  104. pin);
  105. status = -EINVAL;
  106. goto out_free_pin;
  107. }
  108. /*
  109. * If there is no kind of request function for the pin we just assume
  110. * we got it by default and proceed.
  111. */
  112. if (gpio_range && ops->gpio_request_enable)
  113. /* This requests and enables a single GPIO pin */
  114. status = ops->gpio_request_enable(pctldev, gpio_range, pin);
  115. else if (ops->request)
  116. status = ops->request(pctldev, pin);
  117. else
  118. status = 0;
  119. if (status)
  120. dev_err(pctldev->dev, "->request on device %s failed for pin %d\n",
  121. pctldev->desc->name, pin);
  122. out_free_pin:
  123. if (status) {
  124. spin_lock(&desc->lock);
  125. desc->mux_function = NULL;
  126. spin_unlock(&desc->lock);
  127. }
  128. out:
  129. if (status)
  130. dev_err(pctldev->dev, "pin-%d (%s) status %d\n",
  131. pin, function ? : "?", status);
  132. return status;
  133. }
  134. /**
  135. * pin_free() - release a single muxed in pin so something else can be muxed
  136. * @pctldev: pin controller device handling this pin
  137. * @pin: the pin to free
  138. * @gpio_range: the range matching the GPIO pin if this is a request for a
  139. * single GPIO pin
  140. *
  141. * This function returns a pointer to the function name in use. This is used
  142. * for callers that dynamically allocate a function name so it can be freed
  143. * once the pin is free. This is done for GPIO request functions.
  144. */
  145. static const char *pin_free(struct pinctrl_dev *pctldev, int pin,
  146. struct pinctrl_gpio_range *gpio_range)
  147. {
  148. const struct pinmux_ops *ops = pctldev->desc->pmxops;
  149. struct pin_desc *desc;
  150. const char *func;
  151. desc = pin_desc_get(pctldev, pin);
  152. if (desc == NULL) {
  153. dev_err(pctldev->dev,
  154. "pin is not registered so it cannot be freed\n");
  155. return NULL;
  156. }
  157. /*
  158. * If there is no kind of request function for the pin we just assume
  159. * we got it by default and proceed.
  160. */
  161. if (gpio_range && ops->gpio_disable_free)
  162. ops->gpio_disable_free(pctldev, gpio_range, pin);
  163. else if (ops->free)
  164. ops->free(pctldev, pin);
  165. spin_lock(&desc->lock);
  166. func = desc->mux_function;
  167. desc->mux_function = NULL;
  168. spin_unlock(&desc->lock);
  169. module_put(pctldev->owner);
  170. return func;
  171. }
  172. /**
  173. * pinmux_request_gpio() - request pinmuxing for a GPIO pin
  174. * @pctldev: pin controller device affected
  175. * @pin: the pin to mux in for GPIO
  176. * @range: the applicable GPIO range
  177. */
  178. int pinmux_request_gpio(struct pinctrl_dev *pctldev,
  179. struct pinctrl_gpio_range *range,
  180. unsigned pin, unsigned gpio)
  181. {
  182. char gpiostr[16];
  183. const char *function;
  184. int ret;
  185. /* Conjure some name stating what chip and pin this is taken by */
  186. snprintf(gpiostr, 15, "%s:%d", range->name, gpio);
  187. function = kstrdup(gpiostr, GFP_KERNEL);
  188. if (!function)
  189. return -EINVAL;
  190. ret = pin_request(pctldev, pin, function, range);
  191. if (ret < 0)
  192. kfree(function);
  193. return ret;
  194. }
  195. /**
  196. * pinmux_free_gpio() - release a pin from GPIO muxing
  197. * @pctldev: the pin controller device for the pin
  198. * @pin: the affected currently GPIO-muxed in pin
  199. * @range: applicable GPIO range
  200. */
  201. void pinmux_free_gpio(struct pinctrl_dev *pctldev, unsigned pin,
  202. struct pinctrl_gpio_range *range)
  203. {
  204. const char *func;
  205. func = pin_free(pctldev, pin, range);
  206. kfree(func);
  207. }
  208. /**
  209. * pinmux_gpio_direction() - set the direction of a single muxed-in GPIO pin
  210. * @pctldev: the pin controller handling this pin
  211. * @range: applicable GPIO range
  212. * @pin: the affected GPIO pin in this controller
  213. * @input: true if we set the pin as input, false for output
  214. */
  215. int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
  216. struct pinctrl_gpio_range *range,
  217. unsigned pin, bool input)
  218. {
  219. const struct pinmux_ops *ops;
  220. int ret;
  221. ops = pctldev->desc->pmxops;
  222. if (ops->gpio_set_direction)
  223. ret = ops->gpio_set_direction(pctldev, range, pin, input);
  224. else
  225. ret = 0;
  226. return ret;
  227. }
  228. /**
  229. * acquire_pins() - acquire all the pins for a certain function on a pinmux
  230. * @pctldev: the device to take the pins on
  231. * @func_selector: the function selector to acquire the pins for
  232. * @group_selector: the group selector containing the pins to acquire
  233. */
  234. static int acquire_pins(struct pinctrl_dev *pctldev,
  235. unsigned func_selector,
  236. unsigned group_selector)
  237. {
  238. const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
  239. const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
  240. const char *func = pmxops->get_function_name(pctldev,
  241. func_selector);
  242. const unsigned *pins;
  243. unsigned num_pins;
  244. int ret;
  245. int i;
  246. ret = pctlops->get_group_pins(pctldev, group_selector,
  247. &pins, &num_pins);
  248. if (ret)
  249. return ret;
  250. dev_dbg(pctldev->dev, "requesting the %u pins from group %u\n",
  251. num_pins, group_selector);
  252. /* Try to allocate all pins in this group, one by one */
  253. for (i = 0; i < num_pins; i++) {
  254. ret = pin_request(pctldev, pins[i], func, NULL);
  255. if (ret) {
  256. dev_err(pctldev->dev,
  257. "could not get pin %d for function %s on device %s - conflicting mux mappings?\n",
  258. pins[i], func ? : "(undefined)",
  259. pinctrl_dev_get_name(pctldev));
  260. /* On error release all taken pins */
  261. i--; /* this pin just failed */
  262. for (; i >= 0; i--)
  263. pin_free(pctldev, pins[i], NULL);
  264. return -ENODEV;
  265. }
  266. }
  267. return 0;
  268. }
  269. /**
  270. * release_pins() - release pins taken by earlier acquirement
  271. * @pctldev: the device to free the pins on
  272. * @group_selector: the group selector containing the pins to free
  273. */
  274. static void release_pins(struct pinctrl_dev *pctldev,
  275. unsigned group_selector)
  276. {
  277. const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
  278. const unsigned *pins;
  279. unsigned num_pins;
  280. int ret;
  281. int i;
  282. ret = pctlops->get_group_pins(pctldev, group_selector,
  283. &pins, &num_pins);
  284. if (ret) {
  285. dev_err(pctldev->dev, "could not get pins to release for group selector %d\n",
  286. group_selector);
  287. return;
  288. }
  289. for (i = 0; i < num_pins; i++)
  290. pin_free(pctldev, pins[i], NULL);
  291. }
  292. /**
  293. * pinmux_check_pin_group() - check function and pin group combo
  294. * @pctldev: device to check the pin group vs function for
  295. * @func_selector: the function selector to check the pin group for, we have
  296. * already looked this up in the calling function
  297. * @pin_group: the pin group to match to the function
  298. *
  299. * This function will check that the pinmux driver can supply the
  300. * selected pin group for a certain function, returns the group selector if
  301. * the group and function selector will work fine together, else returns
  302. * negative
  303. */
  304. static int pinmux_check_pin_group(struct pinctrl_dev *pctldev,
  305. unsigned func_selector,
  306. const char *pin_group)
  307. {
  308. const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
  309. const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
  310. int ret;
  311. /*
  312. * If the driver does not support different pin groups for the
  313. * functions, we only support group 0, and assume this exists.
  314. */
  315. if (!pctlops || !pctlops->list_groups)
  316. return 0;
  317. /*
  318. * Passing NULL (no specific group) will select the first and
  319. * hopefully only group of pins available for this function.
  320. */
  321. if (!pin_group) {
  322. char const * const *groups;
  323. unsigned num_groups;
  324. ret = pmxops->get_function_groups(pctldev, func_selector,
  325. &groups, &num_groups);
  326. if (ret)
  327. return ret;
  328. if (num_groups < 1)
  329. return -EINVAL;
  330. ret = pinctrl_get_group_selector(pctldev, groups[0]);
  331. if (ret < 0) {
  332. dev_err(pctldev->dev,
  333. "function %s wants group %s but the pin controller does not seem to have that group\n",
  334. pmxops->get_function_name(pctldev, func_selector),
  335. groups[0]);
  336. return ret;
  337. }
  338. if (num_groups > 1)
  339. dev_dbg(pctldev->dev,
  340. "function %s support more than one group, default-selecting first group %s (%d)\n",
  341. pmxops->get_function_name(pctldev, func_selector),
  342. groups[0],
  343. ret);
  344. return ret;
  345. }
  346. dev_dbg(pctldev->dev,
  347. "check if we have pin group %s on controller %s\n",
  348. pin_group, pinctrl_dev_get_name(pctldev));
  349. ret = pinctrl_get_group_selector(pctldev, pin_group);
  350. if (ret < 0) {
  351. dev_dbg(pctldev->dev,
  352. "%s does not support pin group %s with function %s\n",
  353. pinctrl_dev_get_name(pctldev),
  354. pin_group,
  355. pmxops->get_function_name(pctldev, func_selector));
  356. }
  357. return ret;
  358. }
  359. /**
  360. * pinmux_search_function() - check pin control driver for a certain function
  361. * @pctldev: device to check for function and position
  362. * @map: function map containing the function and position to look for
  363. * @func_selector: returns the applicable function selector if found
  364. * @group_selector: returns the applicable group selector if found
  365. *
  366. * This will search the pinmux driver for an applicable
  367. * function with a specific pin group, returns 0 if these can be mapped
  368. * negative otherwise
  369. */
  370. static int pinmux_search_function(struct pinctrl_dev *pctldev,
  371. struct pinctrl_map const *map,
  372. unsigned *func_selector,
  373. unsigned *group_selector)
  374. {
  375. const struct pinmux_ops *ops = pctldev->desc->pmxops;
  376. unsigned selector = 0;
  377. /* See if this pctldev has this function */
  378. while (ops->list_functions(pctldev, selector) >= 0) {
  379. const char *fname = ops->get_function_name(pctldev,
  380. selector);
  381. int ret;
  382. if (!strcmp(map->function, fname)) {
  383. /* Found the function, check pin group */
  384. ret = pinmux_check_pin_group(pctldev, selector,
  385. map->group);
  386. if (ret < 0)
  387. return ret;
  388. /* This function and group selector can be used */
  389. *func_selector = selector;
  390. *group_selector = ret;
  391. return 0;
  392. }
  393. selector++;
  394. }
  395. pr_err("%s does not support function %s\n",
  396. pinctrl_dev_get_name(pctldev), map->function);
  397. return -EINVAL;
  398. }
  399. /**
  400. * pinmux_enable_muxmap() - enable a map entry for a certain pinmux
  401. */
  402. static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev,
  403. struct pinctrl *p,
  404. struct device *dev,
  405. const char *devname,
  406. struct pinctrl_map const *map)
  407. {
  408. unsigned func_selector;
  409. unsigned group_selector;
  410. struct pinmux_group *grp;
  411. int ret;
  412. /*
  413. * Note that we're not locking the pinmux mutex here, because
  414. * this is only called at pinmux initialization time when it
  415. * has not been added to any list and thus is not reachable
  416. * by anyone else.
  417. */
  418. if (p->pctldev && p->pctldev != pctldev) {
  419. dev_err(pctldev->dev,
  420. "different pin control devices given for device %s, function %s\n",
  421. devname, map->function);
  422. return -EINVAL;
  423. }
  424. p->dev = dev;
  425. p->pctldev = pctldev;
  426. /* Now go into the driver and try to match a function and group */
  427. ret = pinmux_search_function(pctldev, map, &func_selector,
  428. &group_selector);
  429. if (ret < 0)
  430. return ret;
  431. /*
  432. * If the function selector is already set, it needs to be identical,
  433. * we support several groups with one function but not several
  434. * functions with one or several groups in the same pinmux.
  435. */
  436. if (p->func_selector != UINT_MAX &&
  437. p->func_selector != func_selector) {
  438. dev_err(pctldev->dev,
  439. "dual function defines in the map for device %s\n",
  440. devname);
  441. return -EINVAL;
  442. }
  443. p->func_selector = func_selector;
  444. /* Now add this group selector, we may have many of them */
  445. grp = kmalloc(sizeof(struct pinmux_group), GFP_KERNEL);
  446. if (!grp)
  447. return -ENOMEM;
  448. grp->group_selector = group_selector;
  449. ret = acquire_pins(pctldev, func_selector, group_selector);
  450. if (ret) {
  451. kfree(grp);
  452. return ret;
  453. }
  454. list_add_tail(&grp->node, &p->groups);
  455. return 0;
  456. }
  457. /**
  458. * pinmux_apply_muxmap() - apply a certain mux mapping entry
  459. */
  460. int pinmux_apply_muxmap(struct pinctrl_dev *pctldev,
  461. struct pinctrl *p,
  462. struct device *dev,
  463. const char *devname,
  464. struct pinctrl_map const *map)
  465. {
  466. int ret;
  467. ret = pinmux_enable_muxmap(pctldev, p, dev,
  468. devname, map);
  469. if (ret) {
  470. pinmux_put(p);
  471. return ret;
  472. }
  473. return 0;
  474. }
  475. /**
  476. * pinmux_put() - free up the pinmux portions of a pin controller handle
  477. */
  478. void pinmux_put(struct pinctrl *p)
  479. {
  480. struct list_head *node, *tmp;
  481. list_for_each_safe(node, tmp, &p->groups) {
  482. struct pinmux_group *grp =
  483. list_entry(node, struct pinmux_group, node);
  484. /* Release all pins taken by this group */
  485. release_pins(p->pctldev, grp->group_selector);
  486. list_del(node);
  487. kfree(grp);
  488. }
  489. }
  490. /**
  491. * pinmux_enable() - enable the pinmux portion of a pin control handle
  492. */
  493. int pinmux_enable(struct pinctrl *p)
  494. {
  495. struct pinctrl_dev *pctldev = p->pctldev;
  496. const struct pinmux_ops *ops = pctldev->desc->pmxops;
  497. struct pinmux_group *grp;
  498. int ret;
  499. list_for_each_entry(grp, &p->groups, node) {
  500. ret = ops->enable(pctldev, p->func_selector,
  501. grp->group_selector);
  502. if (ret)
  503. /*
  504. * TODO: call disable() on all groups we called
  505. * enable() on to this point?
  506. */
  507. return ret;
  508. }
  509. return 0;
  510. }
  511. /**
  512. * pinmux_disable() - disable the pinmux portions of a pin control handle
  513. */
  514. void pinmux_disable(struct pinctrl *p)
  515. {
  516. struct pinctrl_dev *pctldev = p->pctldev;
  517. const struct pinmux_ops *ops = pctldev->desc->pmxops;
  518. struct pinmux_group *grp;
  519. list_for_each_entry(grp, &p->groups, node) {
  520. ops->disable(pctldev, p->func_selector,
  521. grp->group_selector);
  522. }
  523. }
  524. #ifdef CONFIG_DEBUG_FS
  525. /* Called from pincontrol core */
  526. static int pinmux_functions_show(struct seq_file *s, void *what)
  527. {
  528. struct pinctrl_dev *pctldev = s->private;
  529. const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
  530. unsigned func_selector = 0;
  531. while (pmxops->list_functions(pctldev, func_selector) >= 0) {
  532. const char *func = pmxops->get_function_name(pctldev,
  533. func_selector);
  534. const char * const *groups;
  535. unsigned num_groups;
  536. int ret;
  537. int i;
  538. ret = pmxops->get_function_groups(pctldev, func_selector,
  539. &groups, &num_groups);
  540. if (ret)
  541. seq_printf(s, "function %s: COULD NOT GET GROUPS\n",
  542. func);
  543. seq_printf(s, "function: %s, groups = [ ", func);
  544. for (i = 0; i < num_groups; i++)
  545. seq_printf(s, "%s ", groups[i]);
  546. seq_puts(s, "]\n");
  547. func_selector++;
  548. }
  549. return 0;
  550. }
  551. static int pinmux_pins_show(struct seq_file *s, void *what)
  552. {
  553. struct pinctrl_dev *pctldev = s->private;
  554. unsigned i, pin;
  555. seq_puts(s, "Pinmux settings per pin\n");
  556. seq_puts(s, "Format: pin (name): pinmuxfunction\n");
  557. /* The pin number can be retrived from the pin controller descriptor */
  558. for (i = 0; i < pctldev->desc->npins; i++) {
  559. struct pin_desc *desc;
  560. pin = pctldev->desc->pins[i].number;
  561. desc = pin_desc_get(pctldev, pin);
  562. /* Skip if we cannot search the pin */
  563. if (desc == NULL)
  564. continue;
  565. seq_printf(s, "pin %d (%s): %s\n", pin,
  566. desc->name ? desc->name : "unnamed",
  567. desc->mux_function ? desc->mux_function
  568. : "UNCLAIMED");
  569. }
  570. return 0;
  571. }
  572. void pinmux_dbg_show(struct seq_file *s, struct pinctrl *p)
  573. {
  574. struct pinctrl_dev *pctldev = p->pctldev;
  575. const struct pinmux_ops *pmxops;
  576. const struct pinctrl_ops *pctlops;
  577. struct pinmux_group *grp;
  578. pmxops = pctldev->desc->pmxops;
  579. pctlops = pctldev->desc->pctlops;
  580. seq_printf(s, " function: %s (%u),",
  581. pmxops->get_function_name(pctldev,
  582. p->func_selector),
  583. p->func_selector);
  584. seq_printf(s, " groups: [");
  585. list_for_each_entry(grp, &p->groups, node) {
  586. seq_printf(s, " %s (%u)",
  587. pctlops->get_group_name(pctldev,
  588. grp->group_selector),
  589. grp->group_selector);
  590. }
  591. seq_printf(s, " ]");
  592. }
  593. static int pinmux_functions_open(struct inode *inode, struct file *file)
  594. {
  595. return single_open(file, pinmux_functions_show, inode->i_private);
  596. }
  597. static int pinmux_pins_open(struct inode *inode, struct file *file)
  598. {
  599. return single_open(file, pinmux_pins_show, inode->i_private);
  600. }
  601. static const struct file_operations pinmux_functions_ops = {
  602. .open = pinmux_functions_open,
  603. .read = seq_read,
  604. .llseek = seq_lseek,
  605. .release = single_release,
  606. };
  607. static const struct file_operations pinmux_pins_ops = {
  608. .open = pinmux_pins_open,
  609. .read = seq_read,
  610. .llseek = seq_lseek,
  611. .release = single_release,
  612. };
  613. void pinmux_init_device_debugfs(struct dentry *devroot,
  614. struct pinctrl_dev *pctldev)
  615. {
  616. debugfs_create_file("pinmux-functions", S_IFREG | S_IRUGO,
  617. devroot, pctldev, &pinmux_functions_ops);
  618. debugfs_create_file("pinmux-pins", S_IFREG | S_IRUGO,
  619. devroot, pctldev, &pinmux_pins_ops);
  620. }
  621. #endif /* CONFIG_DEBUG_FS */