extcon.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __LINUX_EXTCON_INTERNAL_H__
  3. #define __LINUX_EXTCON_INTERNAL_H__
  4. #include <linux/extcon-provider.h>
  5. /**
  6. * struct extcon_dev - An extcon device represents one external connector.
  7. * @name: The name of this extcon device. Parent device name is
  8. * used if NULL.
  9. * @supported_cable: Array of supported cable names ending with EXTCON_NONE.
  10. * If supported_cable is NULL, cable name related APIs
  11. * are disabled.
  12. * @mutually_exclusive: Array of mutually exclusive set of cables that cannot
  13. * be attached simultaneously. The array should be
  14. * ending with 0 or be NULL (no mutually exclusive cables).
  15. * For example, if it is {0x7, 0x30, 0}, then,
  16. * {0, 1}, {0, 1, 2}, {0, 2}, {1, 2}, or {4, 5} cannot
  17. * be attached simulataneously. {0x7, 0} is equivalent to
  18. * {0x3, 0x6, 0x5, 0}. If it is {0xFFFFFFFF, 0}, there
  19. * can be no simultaneous connections.
  20. * @dev: Device of this extcon.
  21. * @id: Unique device ID of this extcon.
  22. * @state: Attach/detach state of this extcon. Do not provide at
  23. * register-time.
  24. * @nh_all: Notifier for the state change events for all supported
  25. * external connectors from this extcon.
  26. * @nh: Notifier for the state change events from this extcon
  27. * @entry: To support list of extcon devices so that users can
  28. * search for extcon devices based on the extcon name.
  29. * @lock: Protects device state and serialises device registration
  30. * @max_supported: Internal value to store the number of cables.
  31. * @extcon_dev_type: Device_type struct to provide attribute_groups
  32. * customized for each extcon device.
  33. * @cables: Sysfs subdirectories. Each represents one cable.
  34. *
  35. * In most cases, users only need to provide "User initializing data" of
  36. * this struct when registering an extcon. In some exceptional cases,
  37. * optional callbacks may be needed. However, the values in "internal data"
  38. * are overwritten by register function.
  39. */
  40. struct extcon_dev {
  41. /* Optional user initializing data */
  42. const char *name;
  43. const unsigned int *supported_cable;
  44. const u32 *mutually_exclusive;
  45. /* Internal data. Please do not set. */
  46. struct device dev;
  47. unsigned int id;
  48. struct raw_notifier_head nh_all;
  49. struct raw_notifier_head *nh;
  50. struct list_head entry;
  51. int max_supported;
  52. spinlock_t lock; /* could be called by irq handler */
  53. u32 state;
  54. /* /sys/class/extcon/.../cable.n/... */
  55. struct device_type extcon_dev_type;
  56. struct extcon_cable *cables;
  57. /* /sys/class/extcon/.../mutually_exclusive/... */
  58. struct attribute_group attr_g_muex;
  59. struct attribute **attrs_muex;
  60. struct device_attribute *d_attrs_muex;
  61. };
  62. #endif /* __LINUX_EXTCON_INTERNAL_H__ */