1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#ifndef __LINUX_EXTCON_H__
27#define __LINUX_EXTCON_H__
28
29#include <linux/device.h>
30
31
32
33
34#define EXTCON_TYPE_USB BIT(0)
35#define EXTCON_TYPE_CHG BIT(1)
36#define EXTCON_TYPE_JACK BIT(2)
37#define EXTCON_TYPE_DISP BIT(3)
38#define EXTCON_TYPE_MISC BIT(4)
39
40
41
42
43#define EXTCON_NONE 0
44
45
46#define EXTCON_USB 1
47#define EXTCON_USB_HOST 2
48
49
50
51
52
53
54
55
56
57
58
59
60
61#define EXTCON_CHG_USB_SDP 5
62#define EXTCON_CHG_USB_DCP 6
63#define EXTCON_CHG_USB_CDP 7
64#define EXTCON_CHG_USB_ACA 8
65#define EXTCON_CHG_USB_FAST 9
66#define EXTCON_CHG_USB_SLOW 10
67#define EXTCON_CHG_WPT 11
68#define EXTCON_CHG_USB_PD 12
69
70
71#define EXTCON_JACK_MICROPHONE 20
72#define EXTCON_JACK_HEADPHONE 21
73#define EXTCON_JACK_LINE_IN 22
74#define EXTCON_JACK_LINE_OUT 23
75#define EXTCON_JACK_VIDEO_IN 24
76#define EXTCON_JACK_VIDEO_OUT 25
77#define EXTCON_JACK_SPDIF_IN 26
78#define EXTCON_JACK_SPDIF_OUT 27
79
80
81#define EXTCON_DISP_HDMI 40
82#define EXTCON_DISP_MHL 41
83#define EXTCON_DISP_DVI 42
84#define EXTCON_DISP_VGA 43
85#define EXTCON_DISP_DP 44
86#define EXTCON_DISP_HMD 45
87
88
89#define EXTCON_DOCK 60
90#define EXTCON_JIG 61
91#define EXTCON_MECHANICAL 62
92
93#define EXTCON_NUM 63
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130#define EXTCON_PROP_USB_VBUS 0
131#define EXTCON_PROP_USB_TYPEC_POLARITY 1
132#define EXTCON_PROP_USB_SS 2
133
134#define EXTCON_PROP_USB_MIN 0
135#define EXTCON_PROP_USB_MAX 2
136#define EXTCON_PROP_USB_CNT (EXTCON_PROP_USB_MAX - EXTCON_PROP_USB_MIN + 1)
137
138
139#define EXTCON_PROP_CHG_MIN 50
140#define EXTCON_PROP_CHG_MAX 50
141#define EXTCON_PROP_CHG_CNT (EXTCON_PROP_CHG_MAX - EXTCON_PROP_CHG_MIN + 1)
142
143
144#define EXTCON_PROP_JACK_MIN 100
145#define EXTCON_PROP_JACK_MAX 100
146#define EXTCON_PROP_JACK_CNT (EXTCON_PROP_JACK_MAX - EXTCON_PROP_JACK_MIN + 1)
147
148
149
150
151
152
153
154
155
156
157#define EXTCON_PROP_DISP_HPD 150
158
159
160#define EXTCON_PROP_DISP_MIN 150
161#define EXTCON_PROP_DISP_MAX 151
162#define EXTCON_PROP_DISP_CNT (EXTCON_PROP_DISP_MAX - EXTCON_PROP_DISP_MIN + 1)
163
164
165
166
167
168
169
170union extcon_property_value {
171 int intval;
172};
173
174struct extcon_dev;
175
176#if IS_ENABLED(CONFIG_EXTCON)
177
178
179
180
181extern int extcon_get_state(struct extcon_dev *edev, unsigned int id);
182
183
184
185
186
187
188
189
190
191
192extern int extcon_get_property(struct extcon_dev *edev, unsigned int id,
193 unsigned int prop,
194 union extcon_property_value *prop_val);
195extern int extcon_get_property_capability(struct extcon_dev *edev,
196 unsigned int id, unsigned int prop);
197
198
199
200
201
202
203
204
205
206
207extern int extcon_register_notifier(struct extcon_dev *edev, unsigned int id,
208 struct notifier_block *nb);
209extern int extcon_unregister_notifier(struct extcon_dev *edev, unsigned int id,
210 struct notifier_block *nb);
211extern int devm_extcon_register_notifier(struct device *dev,
212 struct extcon_dev *edev, unsigned int id,
213 struct notifier_block *nb);
214extern void devm_extcon_unregister_notifier(struct device *dev,
215 struct extcon_dev *edev, unsigned int id,
216 struct notifier_block *nb);
217
218extern int extcon_register_notifier_all(struct extcon_dev *edev,
219 struct notifier_block *nb);
220extern int extcon_unregister_notifier_all(struct extcon_dev *edev,
221 struct notifier_block *nb);
222extern int devm_extcon_register_notifier_all(struct device *dev,
223 struct extcon_dev *edev,
224 struct notifier_block *nb);
225extern void devm_extcon_unregister_notifier_all(struct device *dev,
226 struct extcon_dev *edev,
227 struct notifier_block *nb);
228
229
230
231
232extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name);
233extern struct extcon_dev *extcon_find_edev_by_node(struct device_node *node);
234extern struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
235 int index);
236
237
238extern const char *extcon_get_edev_name(struct extcon_dev *edev);
239
240#else
241static inline int extcon_get_state(struct extcon_dev *edev, unsigned int id)
242{
243 return 0;
244}
245
246static inline int extcon_get_property(struct extcon_dev *edev, unsigned int id,
247 unsigned int prop,
248 union extcon_property_value *prop_val)
249{
250 return 0;
251}
252
253static inline int extcon_get_property_capability(struct extcon_dev *edev,
254 unsigned int id, unsigned int prop)
255{
256 return 0;
257}
258
259static inline int extcon_register_notifier(struct extcon_dev *edev,
260 unsigned int id, struct notifier_block *nb)
261{
262 return 0;
263}
264
265static inline int extcon_unregister_notifier(struct extcon_dev *edev,
266 unsigned int id, struct notifier_block *nb)
267{
268 return 0;
269}
270
271static inline int devm_extcon_register_notifier(struct device *dev,
272 struct extcon_dev *edev, unsigned int id,
273 struct notifier_block *nb)
274{
275 return -ENOSYS;
276}
277
278static inline void devm_extcon_unregister_notifier(struct device *dev,
279 struct extcon_dev *edev, unsigned int id,
280 struct notifier_block *nb) { }
281
282static inline struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)
283{
284 return ERR_PTR(-ENODEV);
285}
286
287static inline struct extcon_dev *extcon_find_edev_by_node(struct device_node *node)
288{
289 return ERR_PTR(-ENODEV);
290}
291
292static inline struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
293 int index)
294{
295 return ERR_PTR(-ENODEV);
296}
297#endif
298
299
300
301
302
303struct extcon_specific_cable_nb {
304 struct notifier_block *user_nb;
305 int cable_index;
306 struct extcon_dev *edev;
307 unsigned long previous_value;
308};
309
310static inline int extcon_register_interest(struct extcon_specific_cable_nb *obj,
311 const char *extcon_name, const char *cable_name,
312 struct notifier_block *nb)
313{
314 return -EINVAL;
315}
316
317static inline int extcon_unregister_interest(struct extcon_specific_cable_nb *obj)
318{
319 return -EINVAL;
320}
321#endif
322