printf: Remove unused 'bprintf'
[drm/drm-misc.git] / drivers / pinctrl / pinmux.h
blob2965ec20b77fb360ca244800e30f1eafa988a2b1
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Internal interface between the core pin control system and the
4 * pinmux portions
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
10 * Author: Linus Walleij <linus.walleij@linaro.org>
13 #include <linux/types.h>
15 struct dentry;
16 struct seq_file;
18 struct pinctrl_dev;
19 struct pinctrl_gpio_range;
20 struct pinctrl_map;
21 struct pinctrl_setting;
23 #ifdef CONFIG_PINMUX
25 int pinmux_check_ops(struct pinctrl_dev *pctldev);
27 int pinmux_validate_map(const struct pinctrl_map *map, int i);
29 bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev, unsigned int pin);
31 int pinmux_request_gpio(struct pinctrl_dev *pctldev,
32 struct pinctrl_gpio_range *range,
33 unsigned int pin, unsigned int gpio);
34 void pinmux_free_gpio(struct pinctrl_dev *pctldev, unsigned int pin,
35 struct pinctrl_gpio_range *range);
36 int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
37 struct pinctrl_gpio_range *range,
38 unsigned int pin, bool input);
40 int pinmux_map_to_setting(const struct pinctrl_map *map,
41 struct pinctrl_setting *setting);
42 void pinmux_free_setting(const struct pinctrl_setting *setting);
43 int pinmux_enable_setting(const struct pinctrl_setting *setting);
44 void pinmux_disable_setting(const struct pinctrl_setting *setting);
46 #else
48 static inline int pinmux_check_ops(struct pinctrl_dev *pctldev)
50 return 0;
53 static inline int pinmux_validate_map(const struct pinctrl_map *map, int i)
55 return 0;
58 static inline bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev,
59 unsigned int pin)
61 return true;
64 static inline int pinmux_request_gpio(struct pinctrl_dev *pctldev,
65 struct pinctrl_gpio_range *range,
66 unsigned int pin, unsigned int gpio)
68 return 0;
71 static inline void pinmux_free_gpio(struct pinctrl_dev *pctldev,
72 unsigned int pin,
73 struct pinctrl_gpio_range *range)
77 static inline int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
78 struct pinctrl_gpio_range *range,
79 unsigned int pin, bool input)
81 return 0;
84 static inline int pinmux_map_to_setting(const struct pinctrl_map *map,
85 struct pinctrl_setting *setting)
87 return 0;
90 static inline void pinmux_free_setting(const struct pinctrl_setting *setting)
94 static inline int pinmux_enable_setting(const struct pinctrl_setting *setting)
96 return 0;
99 static inline void pinmux_disable_setting(const struct pinctrl_setting *setting)
103 #endif
105 #if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS)
107 void pinmux_show_map(struct seq_file *s, const struct pinctrl_map *map);
108 void pinmux_show_setting(struct seq_file *s,
109 const struct pinctrl_setting *setting);
110 void pinmux_init_device_debugfs(struct dentry *devroot,
111 struct pinctrl_dev *pctldev);
113 #else
115 static inline void pinmux_show_map(struct seq_file *s,
116 const struct pinctrl_map *map)
120 static inline void pinmux_show_setting(struct seq_file *s,
121 const struct pinctrl_setting *setting)
125 static inline void pinmux_init_device_debugfs(struct dentry *devroot,
126 struct pinctrl_dev *pctldev)
130 #endif
132 #ifdef CONFIG_GENERIC_PINMUX_FUNCTIONS
135 * struct function_desc - generic function descriptor
136 * @func: generic data of the pin function (name and groups of pins)
137 * @data: pin controller driver specific data
139 struct function_desc {
140 struct pinfunction func;
141 void *data;
144 /* Convenient macro to define a generic pin function descriptor */
145 #define PINCTRL_FUNCTION_DESC(_name, _grps, _num_grps, _data) \
146 (struct function_desc) { \
147 .func = PINCTRL_PINFUNCTION(_name, _grps, _num_grps), \
148 .data = _data, \
151 int pinmux_generic_get_function_count(struct pinctrl_dev *pctldev);
153 const char *
154 pinmux_generic_get_function_name(struct pinctrl_dev *pctldev,
155 unsigned int selector);
157 int pinmux_generic_get_function_groups(struct pinctrl_dev *pctldev,
158 unsigned int selector,
159 const char * const **groups,
160 unsigned int * const ngroups);
162 struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,
163 unsigned int selector);
165 int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
166 const char *name,
167 const char * const *groups,
168 unsigned int const ngroups,
169 void *data);
171 int pinmux_generic_remove_function(struct pinctrl_dev *pctldev,
172 unsigned int selector);
174 void pinmux_generic_free_functions(struct pinctrl_dev *pctldev);
176 #else
178 static inline void pinmux_generic_free_functions(struct pinctrl_dev *pctldev)
182 #endif /* CONFIG_GENERIC_PINMUX_FUNCTIONS */