162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef __LINUX_EXTCON_INTERNAL_H__
362306a36Sopenharmony_ci#define __LINUX_EXTCON_INTERNAL_H__
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <linux/extcon-provider.h>
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci/**
862306a36Sopenharmony_ci * struct extcon_dev - An extcon device represents one external connector.
962306a36Sopenharmony_ci * @name:		The name of this extcon device. Parent device name is
1062306a36Sopenharmony_ci *			used if NULL.
1162306a36Sopenharmony_ci * @supported_cable:	Array of supported cable names ending with EXTCON_NONE.
1262306a36Sopenharmony_ci *			If supported_cable is NULL, cable name related APIs
1362306a36Sopenharmony_ci *			are disabled.
1462306a36Sopenharmony_ci * @mutually_exclusive:	Array of mutually exclusive set of cables that cannot
1562306a36Sopenharmony_ci *			be attached simultaneously. The array should be
1662306a36Sopenharmony_ci *			ending with 0 or be NULL (no mutually exclusive cables).
1762306a36Sopenharmony_ci *			For example, if it is {0x7, 0x30, 0}, then,
1862306a36Sopenharmony_ci *			{0, 1}, {0, 1, 2}, {0, 2}, {1, 2}, or {4, 5} cannot
1962306a36Sopenharmony_ci *			be attached simulataneously. {0x7, 0} is equivalent to
2062306a36Sopenharmony_ci *			{0x3, 0x6, 0x5, 0}. If it is {0xFFFFFFFF, 0}, there
2162306a36Sopenharmony_ci *			can be no simultaneous connections.
2262306a36Sopenharmony_ci * @dev:		Device of this extcon.
2362306a36Sopenharmony_ci * @id:			Unique device ID of this extcon.
2462306a36Sopenharmony_ci * @state:		Attach/detach state of this extcon. Do not provide at
2562306a36Sopenharmony_ci *			register-time.
2662306a36Sopenharmony_ci * @nh_all:		Notifier for the state change events for all supported
2762306a36Sopenharmony_ci *			external connectors from this extcon.
2862306a36Sopenharmony_ci * @nh:			Notifier for the state change events from this extcon
2962306a36Sopenharmony_ci * @entry:		To support list of extcon devices so that users can
3062306a36Sopenharmony_ci *			search for extcon devices based on the extcon name.
3162306a36Sopenharmony_ci * @lock:		Protects device state and serialises device registration
3262306a36Sopenharmony_ci * @max_supported:	Internal value to store the number of cables.
3362306a36Sopenharmony_ci * @extcon_dev_type:	Device_type struct to provide attribute_groups
3462306a36Sopenharmony_ci *			customized for each extcon device.
3562306a36Sopenharmony_ci * @cables:		Sysfs subdirectories. Each represents one cable.
3662306a36Sopenharmony_ci *
3762306a36Sopenharmony_ci * In most cases, users only need to provide "User initializing data" of
3862306a36Sopenharmony_ci * this struct when registering an extcon. In some exceptional cases,
3962306a36Sopenharmony_ci * optional callbacks may be needed. However, the values in "internal data"
4062306a36Sopenharmony_ci * are overwritten by register function.
4162306a36Sopenharmony_ci */
4262306a36Sopenharmony_cistruct extcon_dev {
4362306a36Sopenharmony_ci	/* Optional user initializing data */
4462306a36Sopenharmony_ci	const char *name;
4562306a36Sopenharmony_ci	const unsigned int *supported_cable;
4662306a36Sopenharmony_ci	const u32 *mutually_exclusive;
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci	/* Internal data. Please do not set. */
4962306a36Sopenharmony_ci	struct device dev;
5062306a36Sopenharmony_ci	unsigned int id;
5162306a36Sopenharmony_ci	struct raw_notifier_head nh_all;
5262306a36Sopenharmony_ci	struct raw_notifier_head *nh;
5362306a36Sopenharmony_ci	struct list_head entry;
5462306a36Sopenharmony_ci	int max_supported;
5562306a36Sopenharmony_ci	spinlock_t lock;	/* could be called by irq handler */
5662306a36Sopenharmony_ci	u32 state;
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci	/* /sys/class/extcon/.../cable.n/... */
5962306a36Sopenharmony_ci	struct device_type extcon_dev_type;
6062306a36Sopenharmony_ci	struct extcon_cable *cables;
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci	/* /sys/class/extcon/.../mutually_exclusive/... */
6362306a36Sopenharmony_ci	struct attribute_group attr_g_muex;
6462306a36Sopenharmony_ci	struct attribute **attrs_muex;
6562306a36Sopenharmony_ci	struct device_attribute *d_attrs_muex;
6662306a36Sopenharmony_ci};
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci#endif /* __LINUX_EXTCON_INTERNAL_H__ */
69