extcon-provider.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * External Connector (extcon) framework
  4. * - linux/include/linux/extcon-provider.h for extcon provider device driver.
  5. *
  6. * Copyright (C) 2017 Samsung Electronics
  7. * Author: Chanwoo Choi <[email protected]>
  8. */
  9. #ifndef __LINUX_EXTCON_PROVIDER_H__
  10. #define __LINUX_EXTCON_PROVIDER_H__
  11. #include <linux/extcon.h>
  12. struct extcon_dev;
  13. #if IS_ENABLED(CONFIG_EXTCON)
  14. /* Following APIs register/unregister the extcon device. */
  15. int extcon_dev_register(struct extcon_dev *edev);
  16. void extcon_dev_unregister(struct extcon_dev *edev);
  17. int devm_extcon_dev_register(struct device *dev,
  18. struct extcon_dev *edev);
  19. void devm_extcon_dev_unregister(struct device *dev,
  20. struct extcon_dev *edev);
  21. /* Following APIs allocate/free the memory of the extcon device. */
  22. struct extcon_dev *extcon_dev_allocate(const unsigned int *cable);
  23. void extcon_dev_free(struct extcon_dev *edev);
  24. struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
  25. const unsigned int *cable);
  26. void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev);
  27. /* Synchronize the state and property value for each external connector. */
  28. int extcon_sync(struct extcon_dev *edev, unsigned int id);
  29. /*
  30. * Following APIs set the connected state of each external connector.
  31. * The 'id' argument indicates the defined external connector.
  32. */
  33. int extcon_set_state(struct extcon_dev *edev, unsigned int id,
  34. bool state);
  35. int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
  36. bool state);
  37. /*
  38. * Following APIs set the property of each external connector.
  39. * The 'id' argument indicates the defined external connector
  40. * and the 'prop' indicates the extcon property.
  41. *
  42. * And extcon_set_property_capability() set the capability of the property
  43. * for each external connector. They are used to set the capability of the
  44. * property of each external connector based on the id and property.
  45. */
  46. int extcon_set_property(struct extcon_dev *edev, unsigned int id,
  47. unsigned int prop,
  48. union extcon_property_value prop_val);
  49. int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id,
  50. unsigned int prop,
  51. union extcon_property_value prop_val);
  52. int extcon_set_property_capability(struct extcon_dev *edev,
  53. unsigned int id, unsigned int prop);
  54. #else /* CONFIG_EXTCON */
  55. static inline int extcon_dev_register(struct extcon_dev *edev)
  56. {
  57. return 0;
  58. }
  59. static inline void extcon_dev_unregister(struct extcon_dev *edev) { }
  60. static inline int devm_extcon_dev_register(struct device *dev,
  61. struct extcon_dev *edev)
  62. {
  63. return -EINVAL;
  64. }
  65. static inline void devm_extcon_dev_unregister(struct device *dev,
  66. struct extcon_dev *edev) { }
  67. static inline struct extcon_dev *extcon_dev_allocate(const unsigned int *cable)
  68. {
  69. return ERR_PTR(-ENOSYS);
  70. }
  71. static inline void extcon_dev_free(struct extcon_dev *edev) { }
  72. static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
  73. const unsigned int *cable)
  74. {
  75. return ERR_PTR(-ENOSYS);
  76. }
  77. static inline void devm_extcon_dev_free(struct extcon_dev *edev) { }
  78. static inline int extcon_set_state(struct extcon_dev *edev, unsigned int id,
  79. bool state)
  80. {
  81. return 0;
  82. }
  83. static inline int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
  84. bool state)
  85. {
  86. return 0;
  87. }
  88. static inline int extcon_sync(struct extcon_dev *edev, unsigned int id)
  89. {
  90. return 0;
  91. }
  92. static inline int extcon_set_property(struct extcon_dev *edev, unsigned int id,
  93. unsigned int prop,
  94. union extcon_property_value prop_val)
  95. {
  96. return 0;
  97. }
  98. static inline int extcon_set_property_sync(struct extcon_dev *edev,
  99. unsigned int id, unsigned int prop,
  100. union extcon_property_value prop_val)
  101. {
  102. return 0;
  103. }
  104. static inline int extcon_set_property_capability(struct extcon_dev *edev,
  105. unsigned int id, unsigned int prop)
  106. {
  107. return 0;
  108. }
  109. #endif /* CONFIG_EXTCON */
  110. #endif /* __LINUX_EXTCON_PROVIDER_H__ */