pinmux.c 18 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. * 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,
  280. selector);
  281. if (!strcmp(function, fname))
  282. return selector;
  283. selector++;
  284. }
  285. pr_err("%s does not support function %s\n",
  286. pinctrl_dev_get_name(pctldev), function);
  287. return -EINVAL;
  288. }
  289. int pinmux_map_to_setting(struct pinctrl_map const *map,
  290. struct pinctrl_setting *setting)
  291. {
  292. struct pinctrl_dev *pctldev = setting->pctldev;
  293. const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
  294. char const * const *groups;
  295. unsigned num_groups;
  296. int ret;
  297. const char *group;
  298. int i;
  299. if (!pmxops) {
  300. dev_err(pctldev->dev, "does not support mux function\n");
  301. return -EINVAL;
  302. }
  303. ret = pinmux_func_name_to_selector(pctldev, map->data.mux.function);
  304. if (ret < 0) {
  305. dev_err(pctldev->dev, "invalid function %s in map table\n",
  306. map->data.mux.function);
  307. return ret;
  308. }
  309. setting->data.mux.func = ret;
  310. ret = pmxops->get_function_groups(pctldev, setting->data.mux.func,
  311. &groups, &num_groups);
  312. if (ret < 0) {
  313. dev_err(pctldev->dev, "can't query groups for function %s\n",
  314. map->data.mux.function);
  315. return ret;
  316. }
  317. if (!num_groups) {
  318. dev_err(pctldev->dev,
  319. "function %s can't be selected on any group\n",
  320. map->data.mux.function);
  321. return -EINVAL;
  322. }
  323. if (map->data.mux.group) {
  324. bool found = false;
  325. group = map->data.mux.group;
  326. for (i = 0; i < num_groups; i++) {
  327. if (!strcmp(group, groups[i])) {
  328. found = true;
  329. break;
  330. }
  331. }
  332. if (!found) {
  333. dev_err(pctldev->dev,
  334. "invalid group \"%s\" for function \"%s\"\n",
  335. group, map->data.mux.function);
  336. return -EINVAL;
  337. }
  338. } else {
  339. group = groups[0];
  340. }
  341. ret = pinctrl_get_group_selector(pctldev, group);
  342. if (ret < 0) {
  343. dev_err(pctldev->dev, "invalid group %s in map table\n",
  344. map->data.mux.group);
  345. return ret;
  346. }
  347. setting->data.mux.group = ret;
  348. return 0;
  349. }
  350. void pinmux_free_setting(struct pinctrl_setting const *setting)
  351. {
  352. /* This function is currently unused */
  353. }
  354. int pinmux_enable_setting(struct pinctrl_setting const *setting)
  355. {
  356. struct pinctrl_dev *pctldev = setting->pctldev;
  357. const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
  358. const struct pinmux_ops *ops = pctldev->desc->pmxops;
  359. int ret = 0;
  360. const unsigned *pins = NULL;
  361. unsigned num_pins = 0;
  362. int i;
  363. struct pin_desc *desc;
  364. if (pctlops->get_group_pins)
  365. ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
  366. &pins, &num_pins);
  367. if (ret) {
  368. const char *gname;
  369. /* errors only affect debug data, so just warn */
  370. gname = pctlops->get_group_name(pctldev,
  371. setting->data.mux.group);
  372. dev_warn(pctldev->dev,
  373. "could not get pins for group %s\n",
  374. gname);
  375. num_pins = 0;
  376. }
  377. /* Try to allocate all pins in this group, one by one */
  378. for (i = 0; i < num_pins; i++) {
  379. ret = pin_request(pctldev, pins[i], setting->dev_name, NULL);
  380. if (ret) {
  381. const char *gname;
  382. const char *pname;
  383. desc = pin_desc_get(pctldev, pins[i]);
  384. pname = desc ? desc->name : "non-existing";
  385. gname = pctlops->get_group_name(pctldev,
  386. setting->data.mux.group);
  387. dev_err(pctldev->dev,
  388. "could not request pin %d (%s) from group %s "
  389. " on device %s\n",
  390. pins[i], pname, gname,
  391. pinctrl_dev_get_name(pctldev));
  392. goto err_pin_request;
  393. }
  394. }
  395. /* Now that we have acquired the pins, encode the mux setting */
  396. for (i = 0; i < num_pins; i++) {
  397. desc = pin_desc_get(pctldev, pins[i]);
  398. if (desc == NULL) {
  399. dev_warn(pctldev->dev,
  400. "could not get pin desc for pin %d\n",
  401. pins[i]);
  402. continue;
  403. }
  404. desc->mux_setting = &(setting->data.mux);
  405. }
  406. ret = ops->set_mux(pctldev, setting->data.mux.func,
  407. setting->data.mux.group);
  408. if (ret)
  409. goto err_set_mux;
  410. return 0;
  411. err_set_mux:
  412. for (i = 0; i < num_pins; i++) {
  413. desc = pin_desc_get(pctldev, pins[i]);
  414. if (desc)
  415. desc->mux_setting = NULL;
  416. }
  417. err_pin_request:
  418. /* On error release all taken pins */
  419. while (--i >= 0)
  420. pin_free(pctldev, pins[i], NULL);
  421. return ret;
  422. }
  423. void pinmux_disable_setting(struct pinctrl_setting const *setting)
  424. {
  425. struct pinctrl_dev *pctldev = setting->pctldev;
  426. const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
  427. int ret = 0;
  428. const unsigned *pins = NULL;
  429. unsigned num_pins = 0;
  430. int i;
  431. struct pin_desc *desc;
  432. if (pctlops->get_group_pins)
  433. ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
  434. &pins, &num_pins);
  435. if (ret) {
  436. const char *gname;
  437. /* errors only affect debug data, so just warn */
  438. gname = pctlops->get_group_name(pctldev,
  439. setting->data.mux.group);
  440. dev_warn(pctldev->dev,
  441. "could not get pins for group %s\n",
  442. gname);
  443. num_pins = 0;
  444. }
  445. /* Flag the descs that no setting is active */
  446. for (i = 0; i < num_pins; i++) {
  447. desc = pin_desc_get(pctldev, pins[i]);
  448. if (desc == NULL) {
  449. dev_warn(pctldev->dev,
  450. "could not get pin desc for pin %d\n",
  451. pins[i]);
  452. continue;
  453. }
  454. if (desc->mux_setting == &(setting->data.mux)) {
  455. desc->mux_setting = NULL;
  456. /* And release the pin */
  457. pin_free(pctldev, pins[i], NULL);
  458. } else {
  459. const char *gname;
  460. gname = pctlops->get_group_name(pctldev,
  461. setting->data.mux.group);
  462. dev_warn(pctldev->dev,
  463. "not freeing pin %d (%s) as part of "
  464. "deactivating group %s - it is already "
  465. "used for some other setting",
  466. pins[i], desc->name, gname);
  467. }
  468. }
  469. }
  470. #ifdef CONFIG_DEBUG_FS
  471. /* Called from pincontrol core */
  472. static int pinmux_functions_show(struct seq_file *s, void *what)
  473. {
  474. struct pinctrl_dev *pctldev = s->private;
  475. const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
  476. unsigned nfuncs;
  477. unsigned func_selector = 0;
  478. if (!pmxops)
  479. return 0;
  480. mutex_lock(&pctldev->mutex);
  481. nfuncs = pmxops->get_functions_count(pctldev);
  482. while (func_selector < nfuncs) {
  483. const char *func = pmxops->get_function_name(pctldev,
  484. func_selector);
  485. const char * const *groups;
  486. unsigned num_groups;
  487. int ret;
  488. int i;
  489. ret = pmxops->get_function_groups(pctldev, func_selector,
  490. &groups, &num_groups);
  491. if (ret) {
  492. seq_printf(s, "function %s: COULD NOT GET GROUPS\n",
  493. func);
  494. func_selector++;
  495. continue;
  496. }
  497. seq_printf(s, "function: %s, groups = [ ", func);
  498. for (i = 0; i < num_groups; i++)
  499. seq_printf(s, "%s ", groups[i]);
  500. seq_puts(s, "]\n");
  501. func_selector++;
  502. }
  503. mutex_unlock(&pctldev->mutex);
  504. return 0;
  505. }
  506. static int pinmux_pins_show(struct seq_file *s, void *what)
  507. {
  508. struct pinctrl_dev *pctldev = s->private;
  509. const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
  510. const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
  511. unsigned i, pin;
  512. if (!pmxops)
  513. return 0;
  514. seq_puts(s, "Pinmux settings per pin\n");
  515. if (pmxops->strict)
  516. seq_puts(s,
  517. "Format: pin (name): mux_owner|gpio_owner (strict) hog?\n");
  518. else
  519. seq_puts(s,
  520. "Format: pin (name): mux_owner gpio_owner hog?\n");
  521. mutex_lock(&pctldev->mutex);
  522. /* The pin number can be retrived from the pin controller descriptor */
  523. for (i = 0; i < pctldev->desc->npins; i++) {
  524. struct pin_desc *desc;
  525. bool is_hog = false;
  526. pin = pctldev->desc->pins[i].number;
  527. desc = pin_desc_get(pctldev, pin);
  528. /* Skip if we cannot search the pin */
  529. if (desc == NULL)
  530. continue;
  531. if (desc->mux_owner &&
  532. !strcmp(desc->mux_owner, pinctrl_dev_get_name(pctldev)))
  533. is_hog = true;
  534. if (pmxops->strict) {
  535. if (desc->mux_owner)
  536. seq_printf(s, "pin %d (%s): device %s%s",
  537. pin,
  538. desc->name ? desc->name : "unnamed",
  539. desc->mux_owner,
  540. is_hog ? " (HOG)" : "");
  541. else if (desc->gpio_owner)
  542. seq_printf(s, "pin %d (%s): GPIO %s",
  543. pin,
  544. desc->name ? desc->name : "unnamed",
  545. desc->gpio_owner);
  546. else
  547. seq_printf(s, "pin %d (%s): UNCLAIMED",
  548. pin,
  549. desc->name ? desc->name : "unnamed");
  550. } else {
  551. /* For non-strict controllers */
  552. seq_printf(s, "pin %d (%s): %s %s%s", pin,
  553. desc->name ? desc->name : "unnamed",
  554. desc->mux_owner ? desc->mux_owner
  555. : "(MUX UNCLAIMED)",
  556. desc->gpio_owner ? desc->gpio_owner
  557. : "(GPIO UNCLAIMED)",
  558. is_hog ? " (HOG)" : "");
  559. }
  560. /* If mux: print function+group claiming the pin */
  561. if (desc->mux_setting)
  562. seq_printf(s, " function %s group %s\n",
  563. pmxops->get_function_name(pctldev,
  564. desc->mux_setting->func),
  565. pctlops->get_group_name(pctldev,
  566. desc->mux_setting->group));
  567. else
  568. seq_printf(s, "\n");
  569. }
  570. mutex_unlock(&pctldev->mutex);
  571. return 0;
  572. }
  573. void pinmux_show_map(struct seq_file *s, struct pinctrl_map const *map)
  574. {
  575. seq_printf(s, "group %s\nfunction %s\n",
  576. map->data.mux.group ? map->data.mux.group : "(default)",
  577. map->data.mux.function);
  578. }
  579. void pinmux_show_setting(struct seq_file *s,
  580. struct pinctrl_setting const *setting)
  581. {
  582. struct pinctrl_dev *pctldev = setting->pctldev;
  583. const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
  584. const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
  585. seq_printf(s, "group: %s (%u) function: %s (%u)\n",
  586. pctlops->get_group_name(pctldev, setting->data.mux.group),
  587. setting->data.mux.group,
  588. pmxops->get_function_name(pctldev, setting->data.mux.func),
  589. setting->data.mux.func);
  590. }
  591. static int pinmux_functions_open(struct inode *inode, struct file *file)
  592. {
  593. return single_open(file, pinmux_functions_show, inode->i_private);
  594. }
  595. static int pinmux_pins_open(struct inode *inode, struct file *file)
  596. {
  597. return single_open(file, pinmux_pins_show, inode->i_private);
  598. }
  599. static const struct file_operations pinmux_functions_ops = {
  600. .open = pinmux_functions_open,
  601. .read = seq_read,
  602. .llseek = seq_lseek,
  603. .release = single_release,
  604. };
  605. static const struct file_operations pinmux_pins_ops = {
  606. .open = pinmux_pins_open,
  607. .read = seq_read,
  608. .llseek = seq_lseek,
  609. .release = single_release,
  610. };
  611. void pinmux_init_device_debugfs(struct dentry *devroot,
  612. struct pinctrl_dev *pctldev)
  613. {
  614. debugfs_create_file("pinmux-functions", S_IFREG | S_IRUGO,
  615. devroot, pctldev, &pinmux_functions_ops);
  616. debugfs_create_file("pinmux-pins", S_IFREG | S_IRUGO,
  617. devroot, pctldev, &pinmux_pins_ops);
  618. }
  619. #endif /* CONFIG_DEBUG_FS */