1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * External Connector (extcon) framework
4 * - linux/include/linux/extcon-provider.h for extcon provider device driver.
6 * Copyright (C) 2017 Samsung Electronics
7 * Author: Chanwoo Choi <cw00.choi@samsung.com>
10 #ifndef __LINUX_EXTCON_PROVIDER_H__
11 #define __LINUX_EXTCON_PROVIDER_H__
13 #include <linux/extcon.h>
17 #if IS_ENABLED(CONFIG_EXTCON)
19 /* Following APIs register/unregister the extcon device. */
20 extern int extcon_dev_register(struct extcon_dev
*edev
);
21 extern void extcon_dev_unregister(struct extcon_dev
*edev
);
22 extern int devm_extcon_dev_register(struct device
*dev
,
23 struct extcon_dev
*edev
);
24 extern void devm_extcon_dev_unregister(struct device
*dev
,
25 struct extcon_dev
*edev
);
27 /* Following APIs allocate/free the memory of the extcon device. */
28 extern struct extcon_dev
*extcon_dev_allocate(const unsigned int *cable
);
29 extern void extcon_dev_free(struct extcon_dev
*edev
);
30 extern struct extcon_dev
*devm_extcon_dev_allocate(struct device
*dev
,
31 const unsigned int *cable
);
32 extern void devm_extcon_dev_free(struct device
*dev
, struct extcon_dev
*edev
);
34 /* Synchronize the state and property value for each external connector. */
35 extern int extcon_sync(struct extcon_dev
*edev
, unsigned int id
);
38 * Following APIs set the connected state of each external connector.
39 * The 'id' argument indicates the defined external connector.
41 extern int extcon_set_state(struct extcon_dev
*edev
, unsigned int id
,
43 extern int extcon_set_state_sync(struct extcon_dev
*edev
, unsigned int id
,
47 * Following APIs set the property of each external connector.
48 * The 'id' argument indicates the defined external connector
49 * and the 'prop' indicates the extcon property.
51 * And extcon_set_property_capability() set the capability of the property
52 * for each external connector. They are used to set the capability of the
53 * property of each external connector based on the id and property.
55 extern int extcon_set_property(struct extcon_dev
*edev
, unsigned int id
,
57 union extcon_property_value prop_val
);
58 extern int extcon_set_property_sync(struct extcon_dev
*edev
, unsigned int id
,
60 union extcon_property_value prop_val
);
61 extern int extcon_set_property_capability(struct extcon_dev
*edev
,
62 unsigned int id
, unsigned int prop
);
64 #else /* CONFIG_EXTCON */
65 static inline int extcon_dev_register(struct extcon_dev
*edev
)
70 static inline void extcon_dev_unregister(struct extcon_dev
*edev
) { }
72 static inline int devm_extcon_dev_register(struct device
*dev
,
73 struct extcon_dev
*edev
)
78 static inline void devm_extcon_dev_unregister(struct device
*dev
,
79 struct extcon_dev
*edev
) { }
81 static inline struct extcon_dev
*extcon_dev_allocate(const unsigned int *cable
)
83 return ERR_PTR(-ENOSYS
);
86 static inline void extcon_dev_free(struct extcon_dev
*edev
) { }
88 static inline struct extcon_dev
*devm_extcon_dev_allocate(struct device
*dev
,
89 const unsigned int *cable
)
91 return ERR_PTR(-ENOSYS
);
94 static inline void devm_extcon_dev_free(struct extcon_dev
*edev
) { }
97 static inline int extcon_set_state(struct extcon_dev
*edev
, unsigned int id
,
103 static inline int extcon_set_state_sync(struct extcon_dev
*edev
, unsigned int id
,
109 static inline int extcon_sync(struct extcon_dev
*edev
, unsigned int id
)
114 static inline int extcon_set_property(struct extcon_dev
*edev
, unsigned int id
,
116 union extcon_property_value prop_val
)
121 static inline int extcon_set_property_sync(struct extcon_dev
*edev
,
122 unsigned int id
, unsigned int prop
,
123 union extcon_property_value prop_val
)
128 static inline int extcon_set_property_capability(struct extcon_dev
*edev
,
129 unsigned int id
, unsigned int prop
)
133 #endif /* CONFIG_EXTCON */
134 #endif /* __LINUX_EXTCON_PROVIDER_H__ */