Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / pinctrl / pinmux.h
blob78c3a31be88294d148778f9c81642b555765e03c
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>
12 #ifdef CONFIG_PINMUX
14 int pinmux_check_ops(struct pinctrl_dev *pctldev);
16 int pinmux_validate_map(const struct pinctrl_map *map, int i);
18 bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev, unsigned pin);
20 int pinmux_request_gpio(struct pinctrl_dev *pctldev,
21 struct pinctrl_gpio_range *range,
22 unsigned pin, unsigned gpio);
23 void pinmux_free_gpio(struct pinctrl_dev *pctldev, unsigned pin,
24 struct pinctrl_gpio_range *range);
25 int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
26 struct pinctrl_gpio_range *range,
27 unsigned pin, bool input);
29 int pinmux_map_to_setting(const struct pinctrl_map *map,
30 struct pinctrl_setting *setting);
31 void pinmux_free_setting(const struct pinctrl_setting *setting);
32 int pinmux_enable_setting(const struct pinctrl_setting *setting);
33 void pinmux_disable_setting(const struct pinctrl_setting *setting);
35 #else
37 static inline int pinmux_check_ops(struct pinctrl_dev *pctldev)
39 return 0;
42 static inline int pinmux_validate_map(const struct pinctrl_map *map, int i)
44 return 0;
47 static inline bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev,
48 unsigned pin)
50 return true;
53 static inline int pinmux_request_gpio(struct pinctrl_dev *pctldev,
54 struct pinctrl_gpio_range *range,
55 unsigned pin, unsigned gpio)
57 return 0;
60 static inline void pinmux_free_gpio(struct pinctrl_dev *pctldev,
61 unsigned pin,
62 struct pinctrl_gpio_range *range)
66 static inline int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
67 struct pinctrl_gpio_range *range,
68 unsigned pin, bool input)
70 return 0;
73 static inline int pinmux_map_to_setting(const struct pinctrl_map *map,
74 struct pinctrl_setting *setting)
76 return 0;
79 static inline void pinmux_free_setting(const struct pinctrl_setting *setting)
83 static inline int pinmux_enable_setting(const struct pinctrl_setting *setting)
85 return 0;
88 static inline void pinmux_disable_setting(const struct pinctrl_setting *setting)
92 #endif
94 #if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS)
96 void pinmux_show_map(struct seq_file *s, const struct pinctrl_map *map);
97 void pinmux_show_setting(struct seq_file *s,
98 const struct pinctrl_setting *setting);
99 void pinmux_init_device_debugfs(struct dentry *devroot,
100 struct pinctrl_dev *pctldev);
102 #else
104 static inline void pinmux_show_map(struct seq_file *s,
105 const struct pinctrl_map *map)
109 static inline void pinmux_show_setting(struct seq_file *s,
110 const struct pinctrl_setting *setting)
114 static inline void pinmux_init_device_debugfs(struct dentry *devroot,
115 struct pinctrl_dev *pctldev)
119 #endif
121 #ifdef CONFIG_GENERIC_PINMUX_FUNCTIONS
124 * struct function_desc - generic function descriptor
125 * @name: name of the function
126 * @group_names: array of pin group names
127 * @num_group_names: number of pin group names
128 * @data: pin controller driver specific data
130 struct function_desc {
131 const char *name;
132 const char **group_names;
133 int num_group_names;
134 void *data;
137 int pinmux_generic_get_function_count(struct pinctrl_dev *pctldev);
139 const char *
140 pinmux_generic_get_function_name(struct pinctrl_dev *pctldev,
141 unsigned int selector);
143 int pinmux_generic_get_function_groups(struct pinctrl_dev *pctldev,
144 unsigned int selector,
145 const char * const **groups,
146 unsigned * const num_groups);
148 struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,
149 unsigned int selector);
151 int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
152 const char *name,
153 const char **groups,
154 unsigned const num_groups,
155 void *data);
157 int pinmux_generic_remove_function(struct pinctrl_dev *pctldev,
158 unsigned int selector);
160 void pinmux_generic_free_functions(struct pinctrl_dev *pctldev);
162 #else
164 static inline void pinmux_generic_free_functions(struct pinctrl_dev *pctldev)
168 #endif /* CONFIG_GENERIC_PINMUX_FUNCTIONS */