]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/extcon-provider.h
regulator: ab8500: Remove AB8505 USB regulator
[mirror_ubuntu-bionic-kernel.git] / include / linux / extcon-provider.h
1 /*
2 * External Connector (extcon) framework
3 * - linux/include/linux/extcon-provider.h for extcon provider device driver.
4 *
5 * Copyright (C) 2017 Samsung Electronics
6 * Author: Chanwoo Choi <cw00.choi@samsung.com>
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18 #ifndef __LINUX_EXTCON_PROVIDER_H__
19 #define __LINUX_EXTCON_PROVIDER_H__
20
21 #include <linux/extcon.h>
22
23 struct extcon_dev;
24
25 #if IS_ENABLED(CONFIG_EXTCON)
26
27 /* Following APIs register/unregister the extcon device. */
28 extern int extcon_dev_register(struct extcon_dev *edev);
29 extern void extcon_dev_unregister(struct extcon_dev *edev);
30 extern int devm_extcon_dev_register(struct device *dev,
31 struct extcon_dev *edev);
32 extern void devm_extcon_dev_unregister(struct device *dev,
33 struct extcon_dev *edev);
34
35 /* Following APIs allocate/free the memory of the extcon device. */
36 extern struct extcon_dev *extcon_dev_allocate(const unsigned int *cable);
37 extern void extcon_dev_free(struct extcon_dev *edev);
38 extern struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
39 const unsigned int *cable);
40 extern void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev);
41
42 /* Synchronize the state and property value for each external connector. */
43 extern int extcon_sync(struct extcon_dev *edev, unsigned int id);
44
45 /*
46 * Following APIs set the connected state of each external connector.
47 * The 'id' argument indicates the defined external connector.
48 */
49 extern int extcon_set_state(struct extcon_dev *edev, unsigned int id,
50 bool state);
51 extern int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
52 bool state);
53
54 /*
55 * Following APIs set the property of each external connector.
56 * The 'id' argument indicates the defined external connector
57 * and the 'prop' indicates the extcon property.
58 *
59 * And extcon_set_property_capability() set the capability of the property
60 * for each external connector. They are used to set the capability of the
61 * property of each external connector based on the id and property.
62 */
63 extern int extcon_set_property(struct extcon_dev *edev, unsigned int id,
64 unsigned int prop,
65 union extcon_property_value prop_val);
66 extern int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id,
67 unsigned int prop,
68 union extcon_property_value prop_val);
69 extern int extcon_set_property_capability(struct extcon_dev *edev,
70 unsigned int id, unsigned int prop);
71
72 #else /* CONFIG_EXTCON */
73 static inline int extcon_dev_register(struct extcon_dev *edev)
74 {
75 return 0;
76 }
77
78 static inline void extcon_dev_unregister(struct extcon_dev *edev) { }
79
80 static inline int devm_extcon_dev_register(struct device *dev,
81 struct extcon_dev *edev)
82 {
83 return -EINVAL;
84 }
85
86 static inline void devm_extcon_dev_unregister(struct device *dev,
87 struct extcon_dev *edev) { }
88
89 static inline struct extcon_dev *extcon_dev_allocate(const unsigned int *cable)
90 {
91 return ERR_PTR(-ENOSYS);
92 }
93
94 static inline void extcon_dev_free(struct extcon_dev *edev) { }
95
96 static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
97 const unsigned int *cable)
98 {
99 return ERR_PTR(-ENOSYS);
100 }
101
102 static inline void devm_extcon_dev_free(struct extcon_dev *edev) { }
103
104
105 static inline int extcon_set_state(struct extcon_dev *edev, unsigned int id,
106 bool state)
107 {
108 return 0;
109 }
110
111 static inline int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
112 bool state)
113 {
114 return 0;
115 }
116
117 static inline int extcon_sync(struct extcon_dev *edev, unsigned int id)
118 {
119 return 0;
120 }
121
122 static inline int extcon_set_property(struct extcon_dev *edev, unsigned int id,
123 unsigned int prop,
124 union extcon_property_value prop_val)
125 {
126 return 0;
127 }
128
129 static inline int extcon_set_property_sync(struct extcon_dev *edev,
130 unsigned int id, unsigned int prop,
131 union extcon_property_value prop_val)
132 {
133 return 0;
134 }
135
136 static inline int extcon_set_property_capability(struct extcon_dev *edev,
137 unsigned int id, unsigned int prop)
138 {
139 return 0;
140 }
141 #endif /* CONFIG_EXTCON */
142 #endif /* __LINUX_EXTCON_PROVIDER_H__ */