Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * External Connector (extcon) framework
0004  * - linux/include/linux/extcon-provider.h for extcon provider device driver.
0005  *
0006  * Copyright (C) 2017 Samsung Electronics
0007  * Author: Chanwoo Choi <cw00.choi@samsung.com>
0008  */
0009 
0010 #ifndef __LINUX_EXTCON_PROVIDER_H__
0011 #define __LINUX_EXTCON_PROVIDER_H__
0012 
0013 #include <linux/extcon.h>
0014 
0015 struct extcon_dev;
0016 
0017 #if IS_ENABLED(CONFIG_EXTCON)
0018 
0019 /* Following APIs register/unregister the extcon device. */
0020 int extcon_dev_register(struct extcon_dev *edev);
0021 void extcon_dev_unregister(struct extcon_dev *edev);
0022 int devm_extcon_dev_register(struct device *dev,
0023                 struct extcon_dev *edev);
0024 void devm_extcon_dev_unregister(struct device *dev,
0025                 struct extcon_dev *edev);
0026 
0027 /* Following APIs allocate/free the memory of the extcon device. */
0028 struct extcon_dev *extcon_dev_allocate(const unsigned int *cable);
0029 void extcon_dev_free(struct extcon_dev *edev);
0030 struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
0031                 const unsigned int *cable);
0032 void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev);
0033 
0034 /* Synchronize the state and property value for each external connector. */
0035 int extcon_sync(struct extcon_dev *edev, unsigned int id);
0036 
0037 /*
0038  * Following APIs set the connected state of each external connector.
0039  * The 'id' argument indicates the defined external connector.
0040  */
0041 int extcon_set_state(struct extcon_dev *edev, unsigned int id,
0042                 bool state);
0043 int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
0044                 bool state);
0045 
0046 /*
0047  * Following APIs set the property of each external connector.
0048  * The 'id' argument indicates the defined external connector
0049  * and the 'prop' indicates the extcon property.
0050  *
0051  * And extcon_set_property_capability() set the capability of the property
0052  * for each external connector. They are used to set the capability of the
0053  * property of each external connector based on the id and property.
0054  */
0055 int extcon_set_property(struct extcon_dev *edev, unsigned int id,
0056                 unsigned int prop,
0057                 union extcon_property_value prop_val);
0058 int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id,
0059                 unsigned int prop,
0060                 union extcon_property_value prop_val);
0061 int extcon_set_property_capability(struct extcon_dev *edev,
0062                 unsigned int id, unsigned int prop);
0063 
0064 #else /* CONFIG_EXTCON */
0065 static inline int extcon_dev_register(struct extcon_dev *edev)
0066 {
0067     return 0;
0068 }
0069 
0070 static inline void extcon_dev_unregister(struct extcon_dev *edev) { }
0071 
0072 static inline int devm_extcon_dev_register(struct device *dev,
0073                 struct extcon_dev *edev)
0074 {
0075     return -EINVAL;
0076 }
0077 
0078 static inline void devm_extcon_dev_unregister(struct device *dev,
0079                 struct extcon_dev *edev) { }
0080 
0081 static inline struct extcon_dev *extcon_dev_allocate(const unsigned int *cable)
0082 {
0083     return ERR_PTR(-ENOSYS);
0084 }
0085 
0086 static inline void extcon_dev_free(struct extcon_dev *edev) { }
0087 
0088 static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
0089                 const unsigned int *cable)
0090 {
0091     return ERR_PTR(-ENOSYS);
0092 }
0093 
0094 static inline void devm_extcon_dev_free(struct extcon_dev *edev) { }
0095 
0096 
0097 static inline int extcon_set_state(struct extcon_dev *edev, unsigned int id,
0098                 bool state)
0099 {
0100     return 0;
0101 }
0102 
0103 static inline int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
0104                 bool state)
0105 {
0106     return 0;
0107 }
0108 
0109 static inline int extcon_sync(struct extcon_dev *edev, unsigned int id)
0110 {
0111     return 0;
0112 }
0113 
0114 static inline int extcon_set_property(struct extcon_dev *edev, unsigned int id,
0115                 unsigned int prop,
0116                 union extcon_property_value prop_val)
0117 {
0118     return 0;
0119 }
0120 
0121 static inline int extcon_set_property_sync(struct extcon_dev *edev,
0122                 unsigned int id, unsigned int prop,
0123                 union extcon_property_value prop_val)
0124 {
0125     return 0;
0126 }
0127 
0128 static inline int extcon_set_property_capability(struct extcon_dev *edev,
0129                 unsigned int id, unsigned int prop)
0130 {
0131     return 0;
0132 }
0133 #endif /* CONFIG_EXTCON */
0134 #endif /* __LINUX_EXTCON_PROVIDER_H__ */