pinmux.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Interface the pinmux subsystem
  4. *
  5. * Copyright (C) 2011 ST-Ericsson SA
  6. * Written on behalf of Linaro for ST-Ericsson
  7. * Based on bits of regulator core, gpio core and clk core
  8. *
  9. * Author: Linus Walleij <[email protected]>
  10. */
  11. #ifndef __LINUX_PINCTRL_PINMUX_H
  12. #define __LINUX_PINCTRL_PINMUX_H
  13. #include <linux/list.h>
  14. #include <linux/seq_file.h>
  15. #include <linux/pinctrl/pinctrl.h>
  16. struct pinctrl_dev;
  17. /**
  18. * struct pinmux_ops - pinmux operations, to be implemented by pin controller
  19. * drivers that support pinmuxing
  20. * @request: called by the core to see if a certain pin can be made
  21. * available for muxing. This is called by the core to acquire the pins
  22. * before selecting any actual mux setting across a function. The driver
  23. * is allowed to answer "no" by returning a negative error code
  24. * @free: the reverse function of the request() callback, frees a pin after
  25. * being requested
  26. * @get_functions_count: returns number of selectable named functions available
  27. * in this pinmux driver
  28. * @get_function_name: return the function name of the muxing selector,
  29. * called by the core to figure out which mux setting it shall map a
  30. * certain device to
  31. * @get_function_groups: return an array of groups names (in turn
  32. * referencing pins) connected to a certain function selector. The group
  33. * name can be used with the generic @pinctrl_ops to retrieve the
  34. * actual pins affected. The applicable groups will be returned in
  35. * @groups and the number of groups in @num_groups
  36. * @set_mux: enable a certain muxing function with a certain pin group. The
  37. * driver does not need to figure out whether enabling this function
  38. * conflicts some other use of the pins in that group, such collisions
  39. * are handled by the pinmux subsystem. The @func_selector selects a
  40. * certain function whereas @group_selector selects a certain set of pins
  41. * to be used. On simple controllers the latter argument may be ignored
  42. * @gpio_request_enable: requests and enables GPIO on a certain pin.
  43. * Implement this only if you can mux every pin individually as GPIO. The
  44. * affected GPIO range is passed along with an offset(pin number) into that
  45. * specific GPIO range - function selectors and pin groups are orthogonal
  46. * to this, the core will however make sure the pins do not collide.
  47. * @gpio_disable_free: free up GPIO muxing on a certain pin, the reverse of
  48. * @gpio_request_enable
  49. * @gpio_set_direction: Since controllers may need different configurations
  50. * depending on whether the GPIO is configured as input or output,
  51. * a direction selector function may be implemented as a backing
  52. * to the GPIO controllers that need pin muxing.
  53. * @strict: do not allow simultaneous use of the same pin for GPIO and another
  54. * function. Check both gpio_owner and mux_owner strictly before approving
  55. * the pin request.
  56. */
  57. struct pinmux_ops {
  58. int (*request) (struct pinctrl_dev *pctldev, unsigned offset);
  59. int (*free) (struct pinctrl_dev *pctldev, unsigned offset);
  60. int (*get_functions_count) (struct pinctrl_dev *pctldev);
  61. const char *(*get_function_name) (struct pinctrl_dev *pctldev,
  62. unsigned selector);
  63. int (*get_function_groups) (struct pinctrl_dev *pctldev,
  64. unsigned selector,
  65. const char * const **groups,
  66. unsigned *num_groups);
  67. int (*set_mux) (struct pinctrl_dev *pctldev, unsigned func_selector,
  68. unsigned group_selector);
  69. int (*gpio_request_enable) (struct pinctrl_dev *pctldev,
  70. struct pinctrl_gpio_range *range,
  71. unsigned offset);
  72. void (*gpio_disable_free) (struct pinctrl_dev *pctldev,
  73. struct pinctrl_gpio_range *range,
  74. unsigned offset);
  75. int (*gpio_set_direction) (struct pinctrl_dev *pctldev,
  76. struct pinctrl_gpio_range *range,
  77. unsigned offset,
  78. bool input);
  79. bool strict;
  80. };
  81. #endif /* __LINUX_PINCTRL_PINMUX_H */