pinconf.h 3.3 KB

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