18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __LINUX_EXTCON_INTERNAL_H__ 38c2ecf20Sopenharmony_ci#define __LINUX_EXTCON_INTERNAL_H__ 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/extcon-provider.h> 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci/** 88c2ecf20Sopenharmony_ci * struct extcon_dev - An extcon device represents one external connector. 98c2ecf20Sopenharmony_ci * @name: The name of this extcon device. Parent device name is 108c2ecf20Sopenharmony_ci * used if NULL. 118c2ecf20Sopenharmony_ci * @supported_cable: Array of supported cable names ending with EXTCON_NONE. 128c2ecf20Sopenharmony_ci * If supported_cable is NULL, cable name related APIs 138c2ecf20Sopenharmony_ci * are disabled. 148c2ecf20Sopenharmony_ci * @mutually_exclusive: Array of mutually exclusive set of cables that cannot 158c2ecf20Sopenharmony_ci * be attached simultaneously. The array should be 168c2ecf20Sopenharmony_ci * ending with NULL or be NULL (no mutually exclusive 178c2ecf20Sopenharmony_ci * cables). For example, if it is { 0x7, 0x30, 0}, then, 188c2ecf20Sopenharmony_ci * {0, 1}, {0, 1, 2}, {0, 2}, {1, 2}, or {4, 5} cannot 198c2ecf20Sopenharmony_ci * be attached simulataneously. {0x7, 0} is equivalent to 208c2ecf20Sopenharmony_ci * {0x3, 0x6, 0x5, 0}. If it is {0xFFFFFFFF, 0}, there 218c2ecf20Sopenharmony_ci * can be no simultaneous connections. 228c2ecf20Sopenharmony_ci * @dev: Device of this extcon. 238c2ecf20Sopenharmony_ci * @state: Attach/detach state of this extcon. Do not provide at 248c2ecf20Sopenharmony_ci * register-time. 258c2ecf20Sopenharmony_ci * @nh_all: Notifier for the state change events for all supported 268c2ecf20Sopenharmony_ci * external connectors from this extcon. 278c2ecf20Sopenharmony_ci * @nh: Notifier for the state change events from this extcon 288c2ecf20Sopenharmony_ci * @entry: To support list of extcon devices so that users can 298c2ecf20Sopenharmony_ci * search for extcon devices based on the extcon name. 308c2ecf20Sopenharmony_ci * @lock: 318c2ecf20Sopenharmony_ci * @max_supported: Internal value to store the number of cables. 328c2ecf20Sopenharmony_ci * @extcon_dev_type: Device_type struct to provide attribute_groups 338c2ecf20Sopenharmony_ci * customized for each extcon device. 348c2ecf20Sopenharmony_ci * @cables: Sysfs subdirectories. Each represents one cable. 358c2ecf20Sopenharmony_ci * 368c2ecf20Sopenharmony_ci * In most cases, users only need to provide "User initializing data" of 378c2ecf20Sopenharmony_ci * this struct when registering an extcon. In some exceptional cases, 388c2ecf20Sopenharmony_ci * optional callbacks may be needed. However, the values in "internal data" 398c2ecf20Sopenharmony_ci * are overwritten by register function. 408c2ecf20Sopenharmony_ci */ 418c2ecf20Sopenharmony_cistruct extcon_dev { 428c2ecf20Sopenharmony_ci /* Optional user initializing data */ 438c2ecf20Sopenharmony_ci const char *name; 448c2ecf20Sopenharmony_ci const unsigned int *supported_cable; 458c2ecf20Sopenharmony_ci const u32 *mutually_exclusive; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci /* Internal data. Please do not set. */ 488c2ecf20Sopenharmony_ci struct device dev; 498c2ecf20Sopenharmony_ci struct raw_notifier_head nh_all; 508c2ecf20Sopenharmony_ci struct raw_notifier_head *nh; 518c2ecf20Sopenharmony_ci struct list_head entry; 528c2ecf20Sopenharmony_ci int max_supported; 538c2ecf20Sopenharmony_ci spinlock_t lock; /* could be called by irq handler */ 548c2ecf20Sopenharmony_ci u32 state; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci /* /sys/class/extcon/.../cable.n/... */ 578c2ecf20Sopenharmony_ci struct device_type extcon_dev_type; 588c2ecf20Sopenharmony_ci struct extcon_cable *cables; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci /* /sys/class/extcon/.../mutually_exclusive/... */ 618c2ecf20Sopenharmony_ci struct attribute_group attr_g_muex; 628c2ecf20Sopenharmony_ci struct attribute **attrs_muex; 638c2ecf20Sopenharmony_ci struct device_attribute *d_attrs_muex; 648c2ecf20Sopenharmony_ci}; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#endif /* __LINUX_EXTCON_INTERNAL_H__ */ 67