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