1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Internal interface between the core pin control system and the
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>
19 struct pinctrl_gpio_range
;
21 struct pinctrl_setting
;
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
);
48 static inline int pinmux_check_ops(struct pinctrl_dev
*pctldev
)
53 static inline int pinmux_validate_map(const struct pinctrl_map
*map
, int i
)
58 static inline bool pinmux_can_be_used_for_gpio(struct pinctrl_dev
*pctldev
,
64 static inline int pinmux_request_gpio(struct pinctrl_dev
*pctldev
,
65 struct pinctrl_gpio_range
*range
,
66 unsigned int pin
, unsigned int gpio
)
71 static inline void pinmux_free_gpio(struct pinctrl_dev
*pctldev
,
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
)
84 static inline int pinmux_map_to_setting(const struct pinctrl_map
*map
,
85 struct pinctrl_setting
*setting
)
90 static inline void pinmux_free_setting(const struct pinctrl_setting
*setting
)
94 static inline int pinmux_enable_setting(const struct pinctrl_setting
*setting
)
99 static inline void pinmux_disable_setting(const struct pinctrl_setting
*setting
)
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
);
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
)
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
;
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), \
151 int pinmux_generic_get_function_count(struct pinctrl_dev
*pctldev
);
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
,
167 const char * const *groups
,
168 unsigned int const ngroups
,
171 int pinmux_generic_remove_function(struct pinctrl_dev
*pctldev
,
172 unsigned int selector
);
174 void pinmux_generic_free_functions(struct pinctrl_dev
*pctldev
);
178 static inline void pinmux_generic_free_functions(struct pinctrl_dev
*pctldev
)
182 #endif /* CONFIG_GENERIC_PINMUX_FUNCTIONS */