pinmux.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Internal interface between the core pin control system and the
  4. * pinmux portions
  5. *
  6. * Copyright (C) 2011 ST-Ericsson SA
  7. * Written on behalf of Linaro for ST-Ericsson
  8. * Based on bits of regulator core, gpio core and clk core
  9. *
  10. * Author: Linus Walleij <linus.walleij@linaro.org>
  11. */
  12. #ifdef CONFIG_PINMUX
  13. int pinmux_check_ops(struct pinctrl_dev *pctldev);
  14. int pinmux_validate_map(const struct pinctrl_map *map, int i);
  15. bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev, unsigned pin);
  16. int pinmux_request_gpio(struct pinctrl_dev *pctldev,
  17. struct pinctrl_gpio_range *range,
  18. unsigned pin, unsigned gpio);
  19. void pinmux_free_gpio(struct pinctrl_dev *pctldev, unsigned pin,
  20. struct pinctrl_gpio_range *range);
  21. int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
  22. struct pinctrl_gpio_range *range,
  23. unsigned pin, bool input);
  24. int pinmux_map_to_setting(const struct pinctrl_map *map,
  25. struct pinctrl_setting *setting);
  26. void pinmux_free_setting(const struct pinctrl_setting *setting);
  27. int pinmux_enable_setting(const struct pinctrl_setting *setting);
  28. void pinmux_disable_setting(const struct pinctrl_setting *setting);
  29. #else
  30. static inline int pinmux_check_ops(struct pinctrl_dev *pctldev)
  31. {
  32. return 0;
  33. }
  34. static inline int pinmux_validate_map(const struct pinctrl_map *map, int i)
  35. {
  36. return 0;
  37. }
  38. static inline bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev,
  39. unsigned pin)
  40. {
  41. return true;
  42. }
  43. static inline int pinmux_request_gpio(struct pinctrl_dev *pctldev,
  44. struct pinctrl_gpio_range *range,
  45. unsigned pin, unsigned gpio)
  46. {
  47. return 0;
  48. }
  49. static inline void pinmux_free_gpio(struct pinctrl_dev *pctldev,
  50. unsigned pin,
  51. struct pinctrl_gpio_range *range)
  52. {
  53. }
  54. static inline int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
  55. struct pinctrl_gpio_range *range,
  56. unsigned pin, bool input)
  57. {
  58. return 0;
  59. }
  60. static inline int pinmux_map_to_setting(const struct pinctrl_map *map,
  61. struct pinctrl_setting *setting)
  62. {
  63. return 0;
  64. }
  65. static inline void pinmux_free_setting(const struct pinctrl_setting *setting)
  66. {
  67. }
  68. static inline int pinmux_enable_setting(const struct pinctrl_setting *setting)
  69. {
  70. return 0;
  71. }
  72. static inline void pinmux_disable_setting(const struct pinctrl_setting *setting)
  73. {
  74. }
  75. #endif
  76. #if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS)
  77. void pinmux_show_map(struct seq_file *s, const struct pinctrl_map *map);
  78. void pinmux_show_setting(struct seq_file *s,
  79. const struct pinctrl_setting *setting);
  80. void pinmux_init_device_debugfs(struct dentry *devroot,
  81. struct pinctrl_dev *pctldev);
  82. #else
  83. static inline void pinmux_show_map(struct seq_file *s,
  84. const struct pinctrl_map *map)
  85. {
  86. }
  87. static inline void pinmux_show_setting(struct seq_file *s,
  88. const struct pinctrl_setting *setting)
  89. {
  90. }
  91. static inline void pinmux_init_device_debugfs(struct dentry *devroot,
  92. struct pinctrl_dev *pctldev)
  93. {
  94. }
  95. #endif
  96. #ifdef CONFIG_GENERIC_PINMUX_FUNCTIONS
  97. /**
  98. * struct function_desc - generic function descriptor
  99. * @name: name of the function
  100. * @group_names: array of pin group names
  101. * @num_group_names: number of pin group names
  102. * @data: pin controller driver specific data
  103. */
  104. struct function_desc {
  105. const char *name;
  106. const char **group_names;
  107. int num_group_names;
  108. void *data;
  109. };
  110. int pinmux_generic_get_function_count(struct pinctrl_dev *pctldev);
  111. const char *
  112. pinmux_generic_get_function_name(struct pinctrl_dev *pctldev,
  113. unsigned int selector);
  114. int pinmux_generic_get_function_groups(struct pinctrl_dev *pctldev,
  115. unsigned int selector,
  116. const char * const **groups,
  117. unsigned * const num_groups);
  118. struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,
  119. unsigned int selector);
  120. int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
  121. const char *name,
  122. const char **groups,
  123. unsigned const num_groups,
  124. void *data);
  125. int pinmux_generic_remove_function(struct pinctrl_dev *pctldev,
  126. unsigned int selector);
  127. void pinmux_generic_free_functions(struct pinctrl_dev *pctldev);
  128. #else
  129. static inline void pinmux_generic_free_functions(struct pinctrl_dev *pctldev)
  130. {
  131. }
  132. #endif /* CONFIG_GENERIC_PINMUX_FUNCTIONS */