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