blob: 2feca5881fa79e15ea09c2d8c078a1ba90e3d4be [file] [log] [blame]
Chanwoo Choi176aa362017-09-21 12:11:24 +09001/*
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
23struct extcon_dev;
24
25#if IS_ENABLED(CONFIG_EXTCON)
26
27/* Following APIs register/unregister the extcon device. */
28extern int extcon_dev_register(struct extcon_dev *edev);
29extern void extcon_dev_unregister(struct extcon_dev *edev);
30extern int devm_extcon_dev_register(struct device *dev,
31 struct extcon_dev *edev);
32extern 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. */
36extern struct extcon_dev *extcon_dev_allocate(const unsigned int *cable);
37extern void extcon_dev_free(struct extcon_dev *edev);
38extern struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
39 const unsigned int *cable);
40extern void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev);
41
42/* Synchronize the state and property value for each external connector. */
43extern 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 */
49extern int extcon_set_state(struct extcon_dev *edev, unsigned int id,
50 bool state);
51extern 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 */
63extern int extcon_set_property(struct extcon_dev *edev, unsigned int id,
64 unsigned int prop,
65 union extcon_property_value prop_val);
66extern int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id,
67 unsigned int prop,
68 union extcon_property_value prop_val);
69extern int extcon_set_property_capability(struct extcon_dev *edev,
70 unsigned int id, unsigned int prop);
71
72#else /* CONFIG_EXTCON */
73static inline int extcon_dev_register(struct extcon_dev *edev)
74{
75 return 0;
76}
77
78static inline void extcon_dev_unregister(struct extcon_dev *edev) { }
79
80static inline int devm_extcon_dev_register(struct device *dev,
81 struct extcon_dev *edev)
82{
83 return -EINVAL;
84}
85
86static inline void devm_extcon_dev_unregister(struct device *dev,
87 struct extcon_dev *edev) { }
88
89static inline struct extcon_dev *extcon_dev_allocate(const unsigned int *cable)
90{
91 return ERR_PTR(-ENOSYS);
92}
93
94static inline void extcon_dev_free(struct extcon_dev *edev) { }
95
96static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
97 const unsigned int *cable)
98{
99 return ERR_PTR(-ENOSYS);
100}
101
102static inline void devm_extcon_dev_free(struct extcon_dev *edev) { }
103
104
105static inline int extcon_set_state(struct extcon_dev *edev, unsigned int id,
106 bool state)
107{
108 return 0;
109}
110
111static inline int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
112 bool state)
113{
114 return 0;
115}
116
117static inline int extcon_sync(struct extcon_dev *edev, unsigned int id)
118{
119 return 0;
120}
121
122static 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
129static 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
136static 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__ */