pinconf.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Internal interface between the core pin control system and the
  4. * pin config 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 <[email protected]>
  11. */
  12. #ifdef CONFIG_PINCONF
  13. int pinconf_check_ops(struct pinctrl_dev *pctldev);
  14. int pinconf_validate_map(const struct pinctrl_map *map, int i);
  15. int pinconf_map_to_setting(const struct pinctrl_map *map,
  16. struct pinctrl_setting *setting);
  17. void pinconf_free_setting(const struct pinctrl_setting *setting);
  18. int pinconf_apply_setting(const struct pinctrl_setting *setting);
  19. int pinconf_set_config(struct pinctrl_dev *pctldev, unsigned pin,
  20. unsigned long *configs, size_t nconfigs);
  21. /*
  22. * You will only be interested in these if you're using PINCONF
  23. * so don't supply any stubs for these.
  24. */
  25. int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin,
  26. unsigned long *config);
  27. int pin_config_group_get(const char *dev_name, const char *pin_group,
  28. unsigned long *config);
  29. #else
  30. static inline int pinconf_check_ops(struct pinctrl_dev *pctldev)
  31. {
  32. return 0;
  33. }
  34. static inline int pinconf_validate_map(const struct pinctrl_map *map, int i)
  35. {
  36. return 0;
  37. }
  38. static inline int pinconf_map_to_setting(const struct pinctrl_map *map,
  39. struct pinctrl_setting *setting)
  40. {
  41. return 0;
  42. }
  43. static inline void pinconf_free_setting(const struct pinctrl_setting *setting)
  44. {
  45. }
  46. static inline int pinconf_apply_setting(const struct pinctrl_setting *setting)
  47. {
  48. return 0;
  49. }
  50. static inline int pinconf_set_config(struct pinctrl_dev *pctldev, unsigned pin,
  51. unsigned long *configs, size_t nconfigs)
  52. {
  53. return -ENOTSUPP;
  54. }
  55. #endif
  56. #if defined(CONFIG_PINCONF) && defined(CONFIG_DEBUG_FS)
  57. void pinconf_show_map(struct seq_file *s, const struct pinctrl_map *map);
  58. void pinconf_show_setting(struct seq_file *s,
  59. const struct pinctrl_setting *setting);
  60. void pinconf_init_device_debugfs(struct dentry *devroot,
  61. struct pinctrl_dev *pctldev);
  62. #else
  63. static inline void pinconf_show_map(struct seq_file *s,
  64. const struct pinctrl_map *map)
  65. {
  66. }
  67. static inline void pinconf_show_setting(struct seq_file *s,
  68. const struct pinctrl_setting *setting)
  69. {
  70. }
  71. static inline void pinconf_init_device_debugfs(struct dentry *devroot,
  72. struct pinctrl_dev *pctldev)
  73. {
  74. }
  75. #endif
  76. /*
  77. * The following functions are available if the driver uses the generic
  78. * pin config.
  79. */
  80. #if defined(CONFIG_GENERIC_PINCONF) && defined(CONFIG_DEBUG_FS)
  81. void pinconf_generic_dump_pins(struct pinctrl_dev *pctldev,
  82. struct seq_file *s, const char *gname,
  83. unsigned pin);
  84. void pinconf_generic_dump_config(struct pinctrl_dev *pctldev,
  85. struct seq_file *s, unsigned long config);
  86. #else
  87. static inline void pinconf_generic_dump_pins(struct pinctrl_dev *pctldev,
  88. struct seq_file *s,
  89. const char *gname, unsigned pin)
  90. {
  91. return;
  92. }
  93. static inline void pinconf_generic_dump_config(struct pinctrl_dev *pctldev,
  94. struct seq_file *s,
  95. unsigned long config)
  96. {
  97. return;
  98. }
  99. #endif
  100. #if defined(CONFIG_GENERIC_PINCONF) && defined(CONFIG_OF)
  101. int pinconf_generic_parse_dt_config(struct device_node *np,
  102. struct pinctrl_dev *pctldev,
  103. unsigned long **configs,
  104. unsigned int *nconfigs);
  105. #endif