pinmux.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Internal interface between the core pin control system and the
  3. * pinmux portions
  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 <linus.walleij@linaro.org>
  10. *
  11. * License terms: GNU General Public License (GPL) version 2
  12. */
  13. #ifdef CONFIG_PINMUX
  14. int pinmux_check_ops(struct pinctrl_dev *pctldev);
  15. int pinmux_validate_map(const struct pinctrl_map *map, int i);
  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 int pinmux_request_gpio(struct pinctrl_dev *pctldev,
  39. struct pinctrl_gpio_range *range,
  40. unsigned pin, unsigned gpio)
  41. {
  42. return 0;
  43. }
  44. static inline void pinmux_free_gpio(struct pinctrl_dev *pctldev,
  45. unsigned pin,
  46. struct pinctrl_gpio_range *range)
  47. {
  48. }
  49. static inline int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
  50. struct pinctrl_gpio_range *range,
  51. unsigned pin, bool input)
  52. {
  53. return 0;
  54. }
  55. static inline int pinmux_map_to_setting(const struct pinctrl_map *map,
  56. struct pinctrl_setting *setting)
  57. {
  58. return 0;
  59. }
  60. static inline void pinmux_free_setting(const struct pinctrl_setting *setting)
  61. {
  62. }
  63. static inline int pinmux_enable_setting(const struct pinctrl_setting *setting)
  64. {
  65. return 0;
  66. }
  67. static inline void pinmux_disable_setting(const struct pinctrl_setting *setting)
  68. {
  69. }
  70. #endif
  71. #if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS)
  72. void pinmux_show_map(struct seq_file *s, const struct pinctrl_map *map);
  73. void pinmux_show_setting(struct seq_file *s,
  74. const struct pinctrl_setting *setting);
  75. void pinmux_init_device_debugfs(struct dentry *devroot,
  76. struct pinctrl_dev *pctldev);
  77. #else
  78. static inline void pinmux_show_map(struct seq_file *s,
  79. const struct pinctrl_map *map)
  80. {
  81. }
  82. static inline void pinmux_show_setting(struct seq_file *s,
  83. const struct pinctrl_setting *setting)
  84. {
  85. }
  86. static inline void pinmux_init_device_debugfs(struct dentry *devroot,
  87. struct pinctrl_dev *pctldev)
  88. {
  89. }
  90. #endif
  91. #ifdef CONFIG_GENERIC_PINMUX_FUNCTIONS
  92. /**
  93. * struct function_desc - generic function descriptor
  94. * @name: name of the function
  95. * @group_names: array of pin group names
  96. * @num_group_names: number of pin group names
  97. * @data: pin controller driver specific data
  98. */
  99. struct function_desc {
  100. const char *name;
  101. const char **group_names;
  102. int num_group_names;
  103. void *data;
  104. };
  105. int pinmux_generic_get_function_count(struct pinctrl_dev *pctldev);
  106. const char *
  107. pinmux_generic_get_function_name(struct pinctrl_dev *pctldev,
  108. unsigned int selector);
  109. int pinmux_generic_get_function_groups(struct pinctrl_dev *pctldev,
  110. unsigned int selector,
  111. const char * const **groups,
  112. unsigned * const num_groups);
  113. struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,
  114. unsigned int selector);
  115. int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
  116. const char *name,
  117. const char **groups,
  118. unsigned const num_groups,
  119. void *data);
  120. int pinmux_generic_remove_function(struct pinctrl_dev *pctldev,
  121. unsigned int selector);
  122. static inline int
  123. pinmux_generic_remove_last_function(struct pinctrl_dev *pctldev)
  124. {
  125. return pinmux_generic_remove_function(pctldev,
  126. pctldev->num_functions - 1);
  127. }
  128. void pinmux_generic_free_functions(struct pinctrl_dev *pctldev);
  129. #else
  130. static inline void pinmux_generic_free_functions(struct pinctrl_dev *pctldev)
  131. {
  132. }
  133. #endif /* CONFIG_GENERIC_PINMUX_FUNCTIONS */