2 * External Connector (extcon) framework
3 * - linux/include/linux/extcon-provider.h for extcon provider device driver.
5 * Copyright (C) 2017 Samsung Electronics
6 * Author: Chanwoo Choi <cw00.choi@samsung.com>
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.
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.
18 #ifndef __LINUX_EXTCON_PROVIDER_H__
19 #define __LINUX_EXTCON_PROVIDER_H__
21 #include <linux/extcon.h>
25 #if IS_ENABLED(CONFIG_EXTCON)
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
);
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
);
42 /* Synchronize the state and property value for each external connector. */
43 extern int extcon_sync(struct extcon_dev
*edev
, unsigned int id
);
46 * Following APIs set the connected state of each external connector.
47 * The 'id' argument indicates the defined external connector.
49 extern int extcon_set_state(struct extcon_dev
*edev
, unsigned int id
,
51 extern int extcon_set_state_sync(struct extcon_dev
*edev
, unsigned int id
,
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.
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.
63 extern int extcon_set_property(struct extcon_dev
*edev
, unsigned int id
,
65 union extcon_property_value prop_val
);
66 extern int extcon_set_property_sync(struct extcon_dev
*edev
, unsigned int id
,
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
);
72 #else /* CONFIG_EXTCON */
73 static inline int extcon_dev_register(struct extcon_dev
*edev
)
78 static inline void extcon_dev_unregister(struct extcon_dev
*edev
) { }
80 static inline int devm_extcon_dev_register(struct device
*dev
,
81 struct extcon_dev
*edev
)
86 static inline void devm_extcon_dev_unregister(struct device
*dev
,
87 struct extcon_dev
*edev
) { }
89 static inline struct extcon_dev
*extcon_dev_allocate(const unsigned int *cable
)
91 return ERR_PTR(-ENOSYS
);
94 static inline void extcon_dev_free(struct extcon_dev
*edev
) { }
96 static inline struct extcon_dev
*devm_extcon_dev_allocate(struct device
*dev
,
97 const unsigned int *cable
)
99 return ERR_PTR(-ENOSYS
);
102 static inline void devm_extcon_dev_free(struct extcon_dev
*edev
) { }
105 static inline int extcon_set_state(struct extcon_dev
*edev
, unsigned int id
,
111 static inline int extcon_set_state_sync(struct extcon_dev
*edev
, unsigned int id
,
117 static inline int extcon_sync(struct extcon_dev
*edev
, unsigned int id
)
122 static inline int extcon_set_property(struct extcon_dev
*edev
, unsigned int id
,
124 union extcon_property_value prop_val
)
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
)
136 static inline int extcon_set_property_capability(struct extcon_dev
*edev
,
137 unsigned int id
, unsigned int prop
)
141 #endif /* CONFIG_EXTCON */
142 #endif /* __LINUX_EXTCON_PROVIDER_H__ */