pinmux.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  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. * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved.
  11. *
  12. * License terms: GNU General Public License (GPL) version 2
  13. */
  14. #define pr_fmt(fmt) "pinmux core: " fmt
  15. #include <linux/kernel.h>
  16. #include <linux/module.h>
  17. #include <linux/init.h>
  18. #include <linux/device.h>
  19. #include <linux/slab.h>
  20. #include <linux/radix-tree.h>
  21. #include <linux/err.h>
  22. #include <linux/list.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. int pinmux_check_ops(struct pinctrl_dev *pctldev)
  32. {
  33. const struct pinmux_ops *ops = pctldev->desc->pmxops;
  34. unsigned nfuncs;
  35. unsigned selector = 0;
  36. /* Check that we implement required operations */
  37. if (!ops ||
  38. !ops->get_functions_count ||
  39. !ops->get_function_name ||
  40. !ops->get_function_groups ||
  41. !ops->set_mux) {
  42. dev_err(pctldev->dev, "pinmux ops lacks necessary functions\n");
  43. return -EINVAL;
  44. }
  45. /* Check that all functions registered have names */
  46. nfuncs = ops->get_functions_count(pctldev);
  47. while (selector < nfuncs) {
  48. const char *fname = ops->get_function_name(pctldev,
  49. selector);
  50. if (!fname) {
  51. dev_err(pctldev->dev, "pinmux ops has no name for function%u\n",
  52. selector);
  53. return -EINVAL;
  54. }
  55. selector++;
  56. }
  57. return 0;
  58. }
  59. int pinmux_validate_map(struct pinctrl_map const *map, int i)
  60. {
  61. if (!map->data.mux.function) {
  62. pr_err("failed to register map %s (%d): no function given\n",
  63. map->name, i);
  64. return -EINVAL;
  65. }
  66. return 0;
  67. }
  68. /**
  69. * pin_request() - request a single pin to be muxed in, typically for GPIO
  70. * @pin: the pin number in the global pin space
  71. * @owner: a representation of the owner of this pin; typically the device
  72. * name that controls its mux function, or the requested GPIO name
  73. * @gpio_range: the range matching the GPIO pin if this is a request for a
  74. * single GPIO pin
  75. */
  76. static int pin_request(struct pinctrl_dev *pctldev,
  77. int pin, const char *owner,
  78. struct pinctrl_gpio_range *gpio_range)
  79. {
  80. struct pin_desc *desc;
  81. const struct pinmux_ops *ops = pctldev->desc->pmxops;
  82. int status = -EINVAL;
  83. desc = pin_desc_get(pctldev, pin);
  84. if (desc == NULL) {
  85. dev_err(pctldev->dev,
  86. "pin %d is not registered so it cannot be requested\n",
  87. pin);
  88. goto out;
  89. }
  90. dev_dbg(pctldev->dev, "request pin %d (%s) for %s\n",
  91. pin, desc->name, owner);
  92. if (gpio_range) {
  93. /* There's no need to support multiple GPIO requests */
  94. if (desc->gpio_owner) {
  95. dev_err(pctldev->dev,
  96. "pin %s already requested by %s; cannot claim for %s\n",
  97. desc->name, desc->gpio_owner, owner);
  98. goto out;
  99. }
  100. if (ops->strict && desc->mux_usecount &&
  101. strcmp(desc->mux_owner, owner)) {
  102. dev_err(pctldev->dev,
  103. "pin %s already requested by %s; cannot claim for %s\n",
  104. desc->name, desc->mux_owner, owner);
  105. goto out;
  106. }
  107. desc->gpio_owner = owner;
  108. } else {
  109. if (desc->mux_usecount && strcmp(desc->mux_owner, owner)) {
  110. dev_err(pctldev->dev,
  111. "pin %s already requested by %s; cannot claim for %s\n",
  112. desc->name, desc->mux_owner, owner);
  113. goto out;
  114. }
  115. if (ops->strict && desc->gpio_owner) {
  116. dev_err(pctldev->dev,
  117. "pin %s already requested by %s; cannot claim for %s\n",
  118. desc->name, desc->gpio_owner, owner);
  119. goto out;
  120. }
  121. desc->mux_usecount++;
  122. if (desc->mux_usecount > 1)
  123. return 0;
  124. desc->mux_owner = owner;
  125. }
  126. /* Let each pin increase references to this module */
  127. if (!try_module_get(pctldev->owner)) {
  128. dev_err(pctldev->dev,
  129. "could not increase module refcount for pin %d\n",
  130. pin);
  131. status = -EINVAL;
  132. goto out_free_pin;
  133. }
  134. /*
  135. * If there is no kind of request function for the pin we just assume
  136. * we got it by default and proceed.
  137. */
  138. if (gpio_range && ops->gpio_request_enable)
  139. /* This requests and enables a single GPIO pin */
  140. status = ops->gpio_request_enable(pctldev, gpio_range, pin);
  141. else if (ops->request)
  142. status = ops->request(pctldev, pin);
  143. else
  144. status = 0;
  145. if (status) {
  146. dev_err(pctldev->dev, "request() failed for pin %d\n", pin);
  147. module_put(pctldev->owner);
  148. }
  149. out_free_pin:
  150. if (status) {
  151. if (gpio_range) {
  152. desc->gpio_owner = NULL;
  153. } else {
  154. desc->mux_usecount--;
  155. if (!desc->mux_usecount)
  156. desc->mux_owner = NULL;
  157. }
  158. }
  159. out:
  160. if (status)
  161. dev_err(pctldev->dev, "pin-%d (%s) status %d\n",
  162. pin, owner, status);
  163. return status;
  164. }
  165. /**
  166. * pin_free() - release a single muxed in pin so something else can be muxed
  167. * @pctldev: pin controller device handling this pin
  168. * @pin: the pin to free
  169. * @gpio_range: the range matching the GPIO pin if this is a request for a
  170. * single GPIO pin
  171. *
  172. * This function returns a pointer to the previous owner. This is used
  173. * for callers that dynamically allocate an owner name so it can be freed
  174. * once the pin is free. This is done for GPIO request functions.
  175. */
  176. static const char *pin_free(struct pinctrl_dev *pctldev, int pin,
  177. struct pinctrl_gpio_range *gpio_range)
  178. {
  179. const struct pinmux_ops *ops = pctldev->desc->pmxops;
  180. struct pin_desc *desc;
  181. const char *owner;
  182. desc = pin_desc_get(pctldev, pin);
  183. if (desc == NULL) {
  184. dev_err(pctldev->dev,
  185. "pin is not registered so it cannot be freed\n");
  186. return NULL;
  187. }
  188. if (!gpio_range) {
  189. /*
  190. * A pin should not be freed more times than allocated.
  191. */
  192. if (WARN_ON(!desc->mux_usecount))
  193. return NULL;
  194. desc->mux_usecount--;
  195. if (desc->mux_usecount)
  196. return NULL;
  197. }
  198. /*
  199. * If there is no kind of request function for the pin we just assume
  200. * we got it by default and proceed.
  201. */
  202. if (gpio_range && ops->gpio_disable_free)
  203. ops->gpio_disable_free(pctldev, gpio_range, pin);
  204. else if (ops->free)
  205. ops->free(pctldev, pin);
  206. if (gpio_range) {
  207. owner = desc->gpio_owner;
  208. desc->gpio_owner = NULL;
  209. } else {
  210. owner = desc->mux_owner;
  211. desc->mux_owner = NULL;
  212. desc->mux_setting = NULL;
  213. }
  214. module_put(pctldev->owner);
  215. return owner;
  216. }
  217. /**
  218. * pinmux_request_gpio() - request pinmuxing for a GPIO pin
  219. * @pctldev: pin controller device affected
  220. * @pin: the pin to mux in for GPIO
  221. * @range: the applicable GPIO range
  222. */
  223. int pinmux_request_gpio(struct pinctrl_dev *pctldev,
  224. struct pinctrl_gpio_range *range,
  225. unsigned pin, unsigned gpio)
  226. {
  227. const char *owner;
  228. int ret;
  229. /* Conjure some name stating what chip and pin this is taken by */
  230. owner = kasprintf(GFP_KERNEL, "%s:%d", range->name, gpio);
  231. if (!owner)
  232. return -EINVAL;
  233. ret = pin_request(pctldev, pin, owner, range);
  234. if (ret < 0)
  235. kfree(owner);
  236. return ret;
  237. }
  238. /**
  239. * pinmux_free_gpio() - release a pin from GPIO muxing
  240. * @pctldev: the pin controller device for the pin
  241. * @pin: the affected currently GPIO-muxed in pin
  242. * @range: applicable GPIO range
  243. */
  244. void pinmux_free_gpio(struct pinctrl_dev *pctldev, unsigned pin,
  245. struct pinctrl_gpio_range *range)
  246. {
  247. const char *owner;
  248. owner = pin_free(pctldev, pin, range);
  249. kfree(owner);
  250. }
  251. /**
  252. * pinmux_gpio_direction() - set the direction of a single muxed-in GPIO pin
  253. * @pctldev: the pin controller handling this pin
  254. * @range: applicable GPIO range
  255. * @pin: the affected GPIO pin in this controller
  256. * @input: true if we set the pin as input, false for output
  257. */
  258. int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
  259. struct pinctrl_gpio_range *range,
  260. unsigned pin, bool input)
  261. {
  262. const struct pinmux_ops *ops;
  263. int ret;
  264. ops = pctldev->desc->pmxops;
  265. if (ops->gpio_set_direction)
  266. ret = ops->gpio_set_direction(pctldev, range, pin, input);
  267. else
  268. ret = 0;
  269. return ret;
  270. }
  271. static int pinmux_func_name_to_selector(struct pinctrl_dev *pctldev,
  272. const char *function)
  273. {
  274. const struct pinmux_ops *ops = pctldev->desc->pmxops;
  275. unsigned nfuncs = ops->get_functions_count(pctldev);
  276. unsigned selector = 0;
  277. /* See if this pctldev has this function */
  278. while (selector < nfuncs) {
  279. const char *fname = ops->get_function_name(pctldev, selector);
  280. if (!strcmp(function, fname))
  281. return selector;
  282. selector++;
  283. }
  284. dev_err(pctldev->dev, "function '%s' not supported\n", function);
  285. return -EINVAL;
  286. }
  287. int pinmux_map_to_setting(struct pinctrl_map const *map,
  288. struct pinctrl_setting *setting)
  289. {
  290. struct pinctrl_dev *pctldev = setting->pctldev;
  291. const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
  292. char const * const *groups;
  293. unsigned num_groups;
  294. int ret;
  295. const char *group;
  296. int i;
  297. if (!pmxops) {
  298. dev_err(pctldev->dev, "does not support mux function\n");
  299. return -EINVAL;
  300. }
  301. ret = pinmux_func_name_to_selector(pctldev, map->data.mux.function);
  302. if (ret < 0) {
  303. dev_err(pctldev->dev, "invalid function %s in map table\n",
  304. map->data.mux.function);
  305. return ret;
  306. }
  307. setting->data.mux.func = ret;
  308. ret = pmxops->get_function_groups(pctldev, setting->data.mux.func,
  309. &groups, &num_groups);
  310. if (ret < 0) {
  311. dev_err(pctldev->dev, "can't query groups for function %s\n",
  312. map->data.mux.function);
  313. return ret;
  314. }
  315. if (!num_groups) {
  316. dev_err(pctldev->dev,
  317. "function %s can't be selected on any group\n",
  318. map->data.mux.function);
  319. return -EINVAL;
  320. }
  321. if (map->data.mux.group) {
  322. bool found = false;
  323. group = map->data.mux.group;
  324. for (i = 0; i < num_groups; i++) {
  325. if (!strcmp(group, groups[i])) {
  326. found = true;
  327. break;
  328. }
  329. }
  330. if (!found) {
  331. dev_err(pctldev->dev,
  332. "invalid group \"%s\" for function \"%s\"\n",
  333. group, map->data.mux.function);
  334. return -EINVAL;
  335. }
  336. } else {
  337. group = groups[0];
  338. }
  339. ret = pinctrl_get_group_selector(pctldev, group);
  340. if (ret < 0) {
  341. dev_err(pctldev->dev, "invalid group %s in map table\n",
  342. map->data.mux.group);
  343. return ret;
  344. }
  345. setting->data.mux.group = ret;
  346. return 0;
  347. }
  348. void pinmux_free_setting(struct pinctrl_setting const *setting)
  349. {
  350. /* This function is currently unused */
  351. }
  352. int pinmux_enable_setting(struct pinctrl_setting const *setting)
  353. {
  354. struct pinctrl_dev *pctldev = setting->pctldev;
  355. const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
  356. const struct pinmux_ops *ops = pctldev->desc->pmxops;
  357. int ret = 0;
  358. const unsigned *pins = NULL;
  359. unsigned num_pins = 0;
  360. int i;
  361. struct pin_desc *desc;
  362. if (pctlops->get_group_pins)
  363. ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
  364. &pins, &num_pins);
  365. if (ret) {
  366. const char *gname;
  367. /* errors only affect debug data, so just warn */
  368. gname = pctlops->get_group_name(pctldev,
  369. setting->data.mux.group);
  370. dev_warn(pctldev->dev,
  371. "could not get pins for group %s\n",
  372. gname);
  373. num_pins = 0;
  374. }
  375. /* Try to allocate all pins in this group, one by one */
  376. for (i = 0; i < num_pins; i++) {
  377. ret = pin_request(pctldev, pins[i], setting->dev_name, NULL);
  378. if (ret) {
  379. const char *gname;
  380. const char *pname;
  381. desc = pin_desc_get(pctldev, pins[i]);
  382. pname = desc ? desc->name : "non-existing";
  383. gname = pctlops->get_group_name(pctldev,
  384. setting->data.mux.group);
  385. dev_err(pctldev->dev,
  386. "could not request pin %d (%s) from group %s "
  387. " on device %s\n",
  388. pins[i], pname, gname,
  389. pinctrl_dev_get_name(pctldev));
  390. goto err_pin_request;
  391. }
  392. }
  393. /* Now that we have acquired the pins, encode the mux setting */
  394. for (i = 0; i < num_pins; i++) {
  395. desc = pin_desc_get(pctldev, pins[i]);
  396. if (desc == NULL) {
  397. dev_warn(pctldev->dev,
  398. "could not get pin desc for pin %d\n",
  399. pins[i]);
  400. continue;
  401. }
  402. desc->mux_setting = &(setting->data.mux);
  403. }
  404. ret = ops->set_mux(pctldev, setting->data.mux.func,
  405. setting->data.mux.group);
  406. if (ret)
  407. goto err_set_mux;
  408. return 0;
  409. err_set_mux:
  410. for (i = 0; i < num_pins; i++) {
  411. desc = pin_desc_get(pctldev, pins[i]);
  412. if (desc)
  413. desc->mux_setting = NULL;
  414. }
  415. err_pin_request:
  416. /* On error release all taken pins */
  417. while (--i >= 0)
  418. pin_free(pctldev, pins[i], NULL);
  419. return ret;
  420. }
  421. void pinmux_disable_setting(struct pinctrl_setting const *setting)
  422. {
  423. struct pinctrl_dev *pctldev = setting->pctldev;
  424. const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
  425. int ret = 0;
  426. const unsigned *pins = NULL;
  427. unsigned num_pins = 0;
  428. int i;
  429. struct pin_desc *desc;
  430. if (pctlops->get_group_pins)
  431. ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
  432. &pins, &num_pins);
  433. if (ret) {
  434. const char *gname;
  435. /* errors only affect debug data, so just warn */
  436. gname = pctlops->get_group_name(pctldev,
  437. setting->data.mux.group);
  438. dev_warn(pctldev->dev,
  439. "could not get pins for group %s\n",
  440. gname);
  441. num_pins = 0;
  442. }
  443. /* Flag the descs that no setting is active */
  444. for (i = 0; i < num_pins; i++) {
  445. desc = pin_desc_get(pctldev, pins[i]);
  446. if (desc == NULL) {
  447. dev_warn(pctldev->dev,
  448. "could not get pin desc for pin %d\n",
  449. pins[i]);
  450. continue;
  451. }
  452. if (desc->mux_setting == &(setting->data.mux)) {
  453. desc->mux_setting = NULL;
  454. /* And release the pin */
  455. pin_free(pctldev, pins[i], NULL);
  456. } else {
  457. const char *gname;
  458. gname = pctlops->get_group_name(pctldev,
  459. setting->data.mux.group);
  460. dev_warn(pctldev->dev,
  461. "not freeing pin %d (%s) as part of "
  462. "deactivating group %s - it is already "
  463. "used for some other setting",
  464. pins[i], desc->name, gname);
  465. }
  466. }
  467. }
  468. #ifdef CONFIG_DEBUG_FS
  469. /* Called from pincontrol core */
  470. static int pinmux_functions_show(struct seq_file *s, void *what)
  471. {
  472. struct pinctrl_dev *pctldev = s->private;
  473. const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
  474. unsigned nfuncs;
  475. unsigned func_selector = 0;
  476. if (!pmxops)
  477. return 0;
  478. mutex_lock(&pctldev->mutex);
  479. nfuncs = pmxops->get_functions_count(pctldev);
  480. while (func_selector < nfuncs) {
  481. const char *func = pmxops->get_function_name(pctldev,
  482. func_selector);
  483. const char * const *groups;
  484. unsigned num_groups;
  485. int ret;
  486. int i;
  487. ret = pmxops->get_function_groups(pctldev, func_selector,
  488. &groups, &num_groups);
  489. if (ret) {
  490. seq_printf(s, "function %s: COULD NOT GET GROUPS\n",
  491. func);
  492. func_selector++;
  493. continue;
  494. }
  495. seq_printf(s, "function: %s, groups = [ ", func);
  496. for (i = 0; i < num_groups; i++)
  497. seq_printf(s, "%s ", groups[i]);
  498. seq_puts(s, "]\n");
  499. func_selector++;
  500. }
  501. mutex_unlock(&pctldev->mutex);
  502. return 0;
  503. }
  504. static int pinmux_pins_show(struct seq_file *s, void *what)
  505. {
  506. struct pinctrl_dev *pctldev = s->private;
  507. const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
  508. const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
  509. unsigned i, pin;
  510. if (!pmxops)
  511. return 0;
  512. seq_puts(s, "Pinmux settings per pin\n");
  513. if (pmxops->strict)
  514. seq_puts(s,
  515. "Format: pin (name): mux_owner|gpio_owner (strict) hog?\n");
  516. else
  517. seq_puts(s,
  518. "Format: pin (name): mux_owner gpio_owner hog?\n");
  519. mutex_lock(&pctldev->mutex);
  520. /* The pin number can be retrived from the pin controller descriptor */
  521. for (i = 0; i < pctldev->desc->npins; i++) {
  522. struct pin_desc *desc;
  523. bool is_hog = false;
  524. pin = pctldev->desc->pins[i].number;
  525. desc = pin_desc_get(pctldev, pin);
  526. /* Skip if we cannot search the pin */
  527. if (desc == NULL)
  528. continue;
  529. if (desc->mux_owner &&
  530. !strcmp(desc->mux_owner, pinctrl_dev_get_name(pctldev)))
  531. is_hog = true;
  532. if (pmxops->strict) {
  533. if (desc->mux_owner)
  534. seq_printf(s, "pin %d (%s): device %s%s",
  535. pin,
  536. desc->name ? desc->name : "unnamed",
  537. desc->mux_owner,
  538. is_hog ? " (HOG)" : "");
  539. else if (desc->gpio_owner)
  540. seq_printf(s, "pin %d (%s): GPIO %s",
  541. pin,
  542. desc->name ? desc->name : "unnamed",
  543. desc->gpio_owner);
  544. else
  545. seq_printf(s, "pin %d (%s): UNCLAIMED",
  546. pin,
  547. desc->name ? desc->name : "unnamed");
  548. } else {
  549. /* For non-strict controllers */
  550. seq_printf(s, "pin %d (%s): %s %s%s", pin,
  551. desc->name ? desc->name : "unnamed",
  552. desc->mux_owner ? desc->mux_owner
  553. : "(MUX UNCLAIMED)",
  554. desc->gpio_owner ? desc->gpio_owner
  555. : "(GPIO UNCLAIMED)",
  556. is_hog ? " (HOG)" : "");
  557. }
  558. /* If mux: print function+group claiming the pin */
  559. if (desc->mux_setting)
  560. seq_printf(s, " function %s group %s\n",
  561. pmxops->get_function_name(pctldev,
  562. desc->mux_setting->func),
  563. pctlops->get_group_name(pctldev,
  564. desc->mux_setting->group));
  565. else
  566. seq_printf(s, "\n");
  567. }
  568. mutex_unlock(&pctldev->mutex);
  569. return 0;
  570. }
  571. void pinmux_show_map(struct seq_file *s, struct pinctrl_map const *map)
  572. {
  573. seq_printf(s, "group %s\nfunction %s\n",
  574. map->data.mux.group ? map->data.mux.group : "(default)",
  575. map->data.mux.function);
  576. }
  577. void pinmux_show_setting(struct seq_file *s,
  578. struct pinctrl_setting const *setting)
  579. {
  580. struct pinctrl_dev *pctldev = setting->pctldev;
  581. const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
  582. const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
  583. seq_printf(s, "group: %s (%u) function: %s (%u)\n",
  584. pctlops->get_group_name(pctldev, setting->data.mux.group),
  585. setting->data.mux.group,
  586. pmxops->get_function_name(pctldev, setting->data.mux.func),
  587. setting->data.mux.func);
  588. }
  589. static int pinmux_functions_open(struct inode *inode, struct file *file)
  590. {
  591. return single_open(file, pinmux_functions_show, inode->i_private);
  592. }
  593. static int pinmux_pins_open(struct inode *inode, struct file *file)
  594. {
  595. return single_open(file, pinmux_pins_show, inode->i_private);
  596. }
  597. static const struct file_operations pinmux_functions_ops = {
  598. .open = pinmux_functions_open,
  599. .read = seq_read,
  600. .llseek = seq_lseek,
  601. .release = single_release,
  602. };
  603. static const struct file_operations pinmux_pins_ops = {
  604. .open = pinmux_pins_open,
  605. .read = seq_read,
  606. .llseek = seq_lseek,
  607. .release = single_release,
  608. };
  609. void pinmux_init_device_debugfs(struct dentry *devroot,
  610. struct pinctrl_dev *pctldev)
  611. {
  612. debugfs_create_file("pinmux-functions", S_IFREG | S_IRUGO,
  613. devroot, pctldev, &pinmux_functions_ops);
  614. debugfs_create_file("pinmux-pins", S_IFREG | S_IRUGO,
  615. devroot, pctldev, &pinmux_pins_ops);
  616. }
  617. #endif /* CONFIG_DEBUG_FS */