^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Internal interface between the core pin control system and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * pin config portions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2011 ST-Ericsson SA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Written on behalf of Linaro for ST-Ericsson
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Based on bits of regulator core, gpio core and clk core
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Author: Linus Walleij <linus.walleij@linaro.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #ifdef CONFIG_PINCONF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) int pinconf_check_ops(struct pinctrl_dev *pctldev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) int pinconf_validate_map(const struct pinctrl_map *map, int i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) int pinconf_map_to_setting(const struct pinctrl_map *map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct pinctrl_setting *setting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) void pinconf_free_setting(const struct pinctrl_setting *setting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) int pinconf_apply_setting(const struct pinctrl_setting *setting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) int pinconf_set_config(struct pinctrl_dev *pctldev, unsigned pin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) unsigned long *configs, size_t nconfigs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * You will only be interested in these if you're using PINCONF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * so don't supply any stubs for these.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) unsigned long *config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) int pin_config_group_get(const char *dev_name, const char *pin_group,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) unsigned long *config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static inline int pinconf_check_ops(struct pinctrl_dev *pctldev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static inline int pinconf_validate_map(const struct pinctrl_map *map, int i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) static inline int pinconf_map_to_setting(const struct pinctrl_map *map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct pinctrl_setting *setting)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) static inline void pinconf_free_setting(const struct pinctrl_setting *setting)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static inline int pinconf_apply_setting(const struct pinctrl_setting *setting)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static inline int pinconf_set_config(struct pinctrl_dev *pctldev, unsigned pin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) unsigned long *configs, size_t nconfigs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) return -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #if defined(CONFIG_PINCONF) && defined(CONFIG_DEBUG_FS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) void pinconf_show_map(struct seq_file *s, const struct pinctrl_map *map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) void pinconf_show_setting(struct seq_file *s,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) const struct pinctrl_setting *setting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) void pinconf_init_device_debugfs(struct dentry *devroot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct pinctrl_dev *pctldev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static inline void pinconf_show_map(struct seq_file *s,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) const struct pinctrl_map *map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) static inline void pinconf_show_setting(struct seq_file *s,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) const struct pinctrl_setting *setting)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) static inline void pinconf_init_device_debugfs(struct dentry *devroot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) struct pinctrl_dev *pctldev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * The following functions are available if the driver uses the generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * pin config.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #if defined(CONFIG_GENERIC_PINCONF) && defined(CONFIG_DEBUG_FS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) void pinconf_generic_dump_pins(struct pinctrl_dev *pctldev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct seq_file *s, const char *gname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) unsigned pin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) void pinconf_generic_dump_config(struct pinctrl_dev *pctldev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) struct seq_file *s, unsigned long config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static inline void pinconf_generic_dump_pins(struct pinctrl_dev *pctldev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct seq_file *s,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) const char *gname, unsigned pin)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static inline void pinconf_generic_dump_config(struct pinctrl_dev *pctldev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct seq_file *s,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) unsigned long config)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #if defined(CONFIG_GENERIC_PINCONF) && defined(CONFIG_OF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) int pinconf_generic_parse_dt_config(struct device_node *np,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) struct pinctrl_dev *pctldev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) unsigned long **configs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) unsigned int *nconfigs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #endif