xref: /openbmc/linux/drivers/pinctrl/pinmux.h (revision 0e96cf7f)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Internal interface between the core pin control system and the
4  * pinmux portions
5  *
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
9  *
10  * Author: Linus Walleij <linus.walleij@linaro.org>
11  */
12 #ifdef CONFIG_PINMUX
13 
14 int pinmux_check_ops(struct pinctrl_dev *pctldev);
15 
16 int pinmux_validate_map(const struct pinctrl_map *map, int i);
17 
18 int pinmux_request_gpio(struct pinctrl_dev *pctldev,
19 			struct pinctrl_gpio_range *range,
20 			unsigned pin, unsigned gpio);
21 void pinmux_free_gpio(struct pinctrl_dev *pctldev, unsigned pin,
22 		      struct pinctrl_gpio_range *range);
23 int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
24 			  struct pinctrl_gpio_range *range,
25 			  unsigned pin, bool input);
26 
27 int pinmux_map_to_setting(const struct pinctrl_map *map,
28 			  struct pinctrl_setting *setting);
29 void pinmux_free_setting(const struct pinctrl_setting *setting);
30 int pinmux_enable_setting(const struct pinctrl_setting *setting);
31 void pinmux_disable_setting(const struct pinctrl_setting *setting);
32 
33 #else
34 
35 static inline int pinmux_check_ops(struct pinctrl_dev *pctldev)
36 {
37 	return 0;
38 }
39 
40 static inline int pinmux_validate_map(const struct pinctrl_map *map, int i)
41 {
42 	return 0;
43 }
44 
45 static inline int pinmux_request_gpio(struct pinctrl_dev *pctldev,
46 			struct pinctrl_gpio_range *range,
47 			unsigned pin, unsigned gpio)
48 {
49 	return 0;
50 }
51 
52 static inline void pinmux_free_gpio(struct pinctrl_dev *pctldev,
53 				    unsigned pin,
54 				    struct pinctrl_gpio_range *range)
55 {
56 }
57 
58 static inline int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
59 					struct pinctrl_gpio_range *range,
60 					unsigned pin, bool input)
61 {
62 	return 0;
63 }
64 
65 static inline int pinmux_map_to_setting(const struct pinctrl_map *map,
66 			  struct pinctrl_setting *setting)
67 {
68 	return 0;
69 }
70 
71 static inline void pinmux_free_setting(const struct pinctrl_setting *setting)
72 {
73 }
74 
75 static inline int pinmux_enable_setting(const struct pinctrl_setting *setting)
76 {
77 	return 0;
78 }
79 
80 static inline void pinmux_disable_setting(const struct pinctrl_setting *setting)
81 {
82 }
83 
84 #endif
85 
86 #if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS)
87 
88 void pinmux_show_map(struct seq_file *s, const struct pinctrl_map *map);
89 void pinmux_show_setting(struct seq_file *s,
90 			 const struct pinctrl_setting *setting);
91 void pinmux_init_device_debugfs(struct dentry *devroot,
92 				struct pinctrl_dev *pctldev);
93 
94 #else
95 
96 static inline void pinmux_show_map(struct seq_file *s,
97 				   const struct pinctrl_map *map)
98 {
99 }
100 
101 static inline void pinmux_show_setting(struct seq_file *s,
102 				       const struct pinctrl_setting *setting)
103 {
104 }
105 
106 static inline void pinmux_init_device_debugfs(struct dentry *devroot,
107 					      struct pinctrl_dev *pctldev)
108 {
109 }
110 
111 #endif
112 
113 #ifdef CONFIG_GENERIC_PINMUX_FUNCTIONS
114 
115 /**
116  * struct function_desc - generic function descriptor
117  * @name: name of the function
118  * @group_names: array of pin group names
119  * @num_group_names: number of pin group names
120  * @data: pin controller driver specific data
121  */
122 struct function_desc {
123 	const char *name;
124 	const char **group_names;
125 	int num_group_names;
126 	void *data;
127 };
128 
129 int pinmux_generic_get_function_count(struct pinctrl_dev *pctldev);
130 
131 const char *
132 pinmux_generic_get_function_name(struct pinctrl_dev *pctldev,
133 				 unsigned int selector);
134 
135 int pinmux_generic_get_function_groups(struct pinctrl_dev *pctldev,
136 				       unsigned int selector,
137 				       const char * const **groups,
138 				       unsigned * const num_groups);
139 
140 struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,
141 						  unsigned int selector);
142 
143 int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
144 				const char *name,
145 				const char **groups,
146 				unsigned const num_groups,
147 				void *data);
148 
149 int pinmux_generic_remove_function(struct pinctrl_dev *pctldev,
150 				   unsigned int selector);
151 
152 void pinmux_generic_free_functions(struct pinctrl_dev *pctldev);
153 
154 #else
155 
156 static inline void pinmux_generic_free_functions(struct pinctrl_dev *pctldev)
157 {
158 }
159 
160 #endif /* CONFIG_GENERIC_PINMUX_FUNCTIONS */
161