summaryrefslogtreecommitdiff
path: root/include/linux/extcon-provider.h
blob: fa70945f4e6b8c0ba5cdd802cd3a6e24f192ca19 (plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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
131
132
133
134
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * External Connector (extcon) framework
 * - linux/include/linux/extcon-provider.h for extcon provider device driver.
 *
 * Copyright (C) 2017 Samsung Electronics
 * Author: Chanwoo Choi <cw00.choi@samsung.com>
 */

#ifndef __LINUX_EXTCON_PROVIDER_H__
#define __LINUX_EXTCON_PROVIDER_H__

#include <linux/extcon.h>

struct extcon_dev;

#if IS_ENABLED(CONFIG_EXTCON)

/* Following APIs register/unregister the extcon device. */
int extcon_dev_register(struct extcon_dev *edev);
void extcon_dev_unregister(struct extcon_dev *edev);
int devm_extcon_dev_register(struct device *dev,
				struct extcon_dev *edev);
void devm_extcon_dev_unregister(struct device *dev,
				struct extcon_dev *edev);

/* Following APIs allocate/free the memory of the extcon device. */
struct extcon_dev *extcon_dev_allocate(const unsigned int *cable);
void extcon_dev_free(struct extcon_dev *edev);
struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
				const unsigned int *cable);
void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev);

/* Synchronize the state and property value for each external connector. */
int extcon_sync(struct extcon_dev *edev, unsigned int id);

/*
 * Following APIs set the connected state of each external connector.
 * The 'id' argument indicates the defined external connector.
 */
int extcon_set_state(struct extcon_dev *edev, unsigned int id,
				bool state);
int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
				bool state);

/*
 * Following APIs set the property of each external connector.
 * The 'id' argument indicates the defined external connector
 * and the 'prop' indicates the extcon property.
 *
 * And extcon_set_property_capability() set the capability of the property
 * for each external connector. They are used to set the capability of the
 * property of each external connector based on the id and property.
 */
int extcon_set_property(struct extcon_dev *edev, unsigned int id,
				unsigned int prop,
				union extcon_property_value prop_val);
int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id,
				unsigned int prop,
				union extcon_property_value prop_val);
int extcon_set_property_capability(struct extcon_dev *edev,
				unsigned int id, unsigned int prop);

#else /* CONFIG_EXTCON */
static inline int extcon_dev_register(struct extcon_dev *edev)
{
	return 0;
}

static inline void extcon_dev_unregister(struct extcon_dev *edev) { }

static inline int devm_extcon_dev_register(struct device *dev,
				struct extcon_dev *edev)
{
	return -EINVAL;
}

static inline void devm_extcon_dev_unregister(struct device *dev,
				struct extcon_dev *edev) { }

static inline struct extcon_dev *extcon_dev_allocate(const unsigned int *cable)
{
	return ERR_PTR(-ENOSYS);
}

static inline void extcon_dev_free(struct extcon_dev *edev) { }

static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
				const unsigned int *cable)
{
	return ERR_PTR(-ENOSYS);
}

static inline void devm_extcon_dev_free(struct extcon_dev *edev) { }


static inline int extcon_set_state(struct extcon_dev *edev, unsigned int id,
				bool state)
{
	return 0;
}

static inline int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
				bool state)
{
	return 0;
}

static inline int extcon_sync(struct extcon_dev *edev, unsigned int id)
{
	return 0;
}

static inline int extcon_set_property(struct extcon_dev *edev, unsigned int id,
				unsigned int prop,
				union extcon_property_value prop_val)
{
	return 0;
}

static inline int extcon_set_property_sync(struct extcon_dev *edev,
				unsigned int id, unsigned int prop,
				union extcon_property_value prop_val)
{
	return 0;
}

static inline int extcon_set_property_capability(struct extcon_dev *edev,
				unsigned int id, unsigned int prop)
{
	return 0;
}
#endif /* CONFIG_EXTCON */
#endif /* __LINUX_EXTCON_PROVIDER_H__ */