0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef __LINUX_EXTCON_H__
0019 #define __LINUX_EXTCON_H__
0020
0021 #include <linux/device.h>
0022
0023
0024
0025
0026 #define EXTCON_TYPE_USB BIT(0)
0027 #define EXTCON_TYPE_CHG BIT(1)
0028 #define EXTCON_TYPE_JACK BIT(2)
0029 #define EXTCON_TYPE_DISP BIT(3)
0030 #define EXTCON_TYPE_MISC BIT(4)
0031
0032
0033
0034
0035 #define EXTCON_NONE 0
0036
0037
0038 #define EXTCON_USB 1
0039 #define EXTCON_USB_HOST 2
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 #define EXTCON_CHG_USB_SDP 5
0054 #define EXTCON_CHG_USB_DCP 6
0055 #define EXTCON_CHG_USB_CDP 7
0056 #define EXTCON_CHG_USB_ACA 8
0057 #define EXTCON_CHG_USB_FAST 9
0058 #define EXTCON_CHG_USB_SLOW 10
0059 #define EXTCON_CHG_WPT 11
0060 #define EXTCON_CHG_USB_PD 12
0061
0062
0063 #define EXTCON_JACK_MICROPHONE 20
0064 #define EXTCON_JACK_HEADPHONE 21
0065 #define EXTCON_JACK_LINE_IN 22
0066 #define EXTCON_JACK_LINE_OUT 23
0067 #define EXTCON_JACK_VIDEO_IN 24
0068 #define EXTCON_JACK_VIDEO_OUT 25
0069 #define EXTCON_JACK_SPDIF_IN 26
0070 #define EXTCON_JACK_SPDIF_OUT 27
0071
0072
0073 #define EXTCON_DISP_HDMI 40
0074 #define EXTCON_DISP_MHL 41
0075 #define EXTCON_DISP_DVI 42
0076 #define EXTCON_DISP_VGA 43
0077 #define EXTCON_DISP_DP 44
0078 #define EXTCON_DISP_HMD 45
0079 #define EXTCON_DISP_CVBS 46
0080 #define EXTCON_DISP_EDP 47
0081
0082
0083 #define EXTCON_DOCK 60
0084 #define EXTCON_JIG 61
0085 #define EXTCON_MECHANICAL 62
0086
0087 #define EXTCON_NUM 63
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124 #define EXTCON_PROP_USB_VBUS 0
0125 #define EXTCON_PROP_USB_TYPEC_POLARITY 1
0126 #define EXTCON_PROP_USB_SS 2
0127
0128 #define EXTCON_PROP_USB_MIN 0
0129 #define EXTCON_PROP_USB_MAX 2
0130 #define EXTCON_PROP_USB_CNT (EXTCON_PROP_USB_MAX - EXTCON_PROP_USB_MIN + 1)
0131
0132
0133 #define EXTCON_PROP_CHG_MIN 50
0134 #define EXTCON_PROP_CHG_MAX 50
0135 #define EXTCON_PROP_CHG_CNT (EXTCON_PROP_CHG_MAX - EXTCON_PROP_CHG_MIN + 1)
0136
0137
0138 #define EXTCON_PROP_JACK_MIN 100
0139 #define EXTCON_PROP_JACK_MAX 100
0140 #define EXTCON_PROP_JACK_CNT (EXTCON_PROP_JACK_MAX - EXTCON_PROP_JACK_MIN + 1)
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151 #define EXTCON_PROP_DISP_HPD 150
0152
0153
0154 #define EXTCON_PROP_DISP_MIN 150
0155 #define EXTCON_PROP_DISP_MAX 151
0156 #define EXTCON_PROP_DISP_CNT (EXTCON_PROP_DISP_MAX - EXTCON_PROP_DISP_MIN + 1)
0157
0158
0159
0160
0161
0162
0163
0164 union extcon_property_value {
0165 int intval;
0166 };
0167
0168 struct extcon_dev;
0169
0170 #if IS_ENABLED(CONFIG_EXTCON)
0171
0172
0173
0174
0175 int extcon_get_state(struct extcon_dev *edev, unsigned int id);
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186 int extcon_get_property(struct extcon_dev *edev, unsigned int id,
0187 unsigned int prop,
0188 union extcon_property_value *prop_val);
0189 int extcon_get_property_capability(struct extcon_dev *edev,
0190 unsigned int id, unsigned int prop);
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201 int extcon_register_notifier(struct extcon_dev *edev, unsigned int id,
0202 struct notifier_block *nb);
0203 int extcon_unregister_notifier(struct extcon_dev *edev, unsigned int id,
0204 struct notifier_block *nb);
0205 int devm_extcon_register_notifier(struct device *dev,
0206 struct extcon_dev *edev, unsigned int id,
0207 struct notifier_block *nb);
0208 void devm_extcon_unregister_notifier(struct device *dev,
0209 struct extcon_dev *edev, unsigned int id,
0210 struct notifier_block *nb);
0211
0212 int extcon_register_notifier_all(struct extcon_dev *edev,
0213 struct notifier_block *nb);
0214 int extcon_unregister_notifier_all(struct extcon_dev *edev,
0215 struct notifier_block *nb);
0216 int devm_extcon_register_notifier_all(struct device *dev,
0217 struct extcon_dev *edev,
0218 struct notifier_block *nb);
0219 void devm_extcon_unregister_notifier_all(struct device *dev,
0220 struct extcon_dev *edev,
0221 struct notifier_block *nb);
0222
0223
0224
0225
0226 struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name);
0227 struct extcon_dev *extcon_find_edev_by_node(struct device_node *node);
0228 struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
0229 int index);
0230
0231
0232 const char *extcon_get_edev_name(struct extcon_dev *edev);
0233
0234 #else
0235 static inline int extcon_get_state(struct extcon_dev *edev, unsigned int id)
0236 {
0237 return 0;
0238 }
0239
0240 static inline int extcon_get_property(struct extcon_dev *edev, unsigned int id,
0241 unsigned int prop,
0242 union extcon_property_value *prop_val)
0243 {
0244 return 0;
0245 }
0246
0247 static inline int extcon_get_property_capability(struct extcon_dev *edev,
0248 unsigned int id, unsigned int prop)
0249 {
0250 return 0;
0251 }
0252
0253 static inline int extcon_register_notifier(struct extcon_dev *edev,
0254 unsigned int id, struct notifier_block *nb)
0255 {
0256 return 0;
0257 }
0258
0259 static inline int extcon_unregister_notifier(struct extcon_dev *edev,
0260 unsigned int id, struct notifier_block *nb)
0261 {
0262 return 0;
0263 }
0264
0265 static inline int devm_extcon_register_notifier(struct device *dev,
0266 struct extcon_dev *edev, unsigned int id,
0267 struct notifier_block *nb)
0268 {
0269 return -ENOSYS;
0270 }
0271
0272 static inline void devm_extcon_unregister_notifier(struct device *dev,
0273 struct extcon_dev *edev, unsigned int id,
0274 struct notifier_block *nb) { }
0275
0276 static inline int extcon_register_notifier_all(struct extcon_dev *edev,
0277 struct notifier_block *nb)
0278 {
0279 return 0;
0280 }
0281
0282 static inline int extcon_unregister_notifier_all(struct extcon_dev *edev,
0283 struct notifier_block *nb)
0284 {
0285 return 0;
0286 }
0287
0288 static inline int devm_extcon_register_notifier_all(struct device *dev,
0289 struct extcon_dev *edev,
0290 struct notifier_block *nb)
0291 {
0292 return 0;
0293 }
0294
0295 static inline void devm_extcon_unregister_notifier_all(struct device *dev,
0296 struct extcon_dev *edev,
0297 struct notifier_block *nb) { }
0298
0299 static inline struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)
0300 {
0301 return NULL;
0302 }
0303
0304 static inline struct extcon_dev *extcon_find_edev_by_node(struct device_node *node)
0305 {
0306 return ERR_PTR(-ENODEV);
0307 }
0308
0309 static inline struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
0310 int index)
0311 {
0312 return ERR_PTR(-ENODEV);
0313 }
0314
0315 static inline const char *extcon_get_edev_name(struct extcon_dev *edev)
0316 {
0317 return NULL;
0318 }
0319 #endif
0320
0321
0322
0323
0324
0325 struct extcon_specific_cable_nb {
0326 struct notifier_block *user_nb;
0327 int cable_index;
0328 struct extcon_dev *edev;
0329 unsigned long previous_value;
0330 };
0331
0332 static inline int extcon_register_interest(struct extcon_specific_cable_nb *obj,
0333 const char *extcon_name, const char *cable_name,
0334 struct notifier_block *nb)
0335 {
0336 return -EINVAL;
0337 }
0338
0339 static inline int extcon_unregister_interest(struct extcon_specific_cable_nb *obj)
0340 {
0341 return -EINVAL;
0342 }
0343 #endif