drivers/usb/typec/ucsi/ucsi.h

Source file repositories/reference/linux-study-clean/drivers/usb/typec/ucsi/ucsi.h

File Facts

System
Linux kernel
Corpus path
drivers/usb/typec/ucsi/ucsi.h
Extension
.h
Size
24822 bytes
Lines
646
Domain
Driver Families
Bucket
drivers/usb
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct ucsi_operations {
	int (*read_version)(struct ucsi *ucsi, u16 *version);
	int (*read_cci)(struct ucsi *ucsi, u32 *cci);
	int (*poll_cci)(struct ucsi *ucsi, u32 *cci);
	int (*read_message_in)(struct ucsi *ucsi, void *val, size_t val_len);
	int (*sync_control)(struct ucsi *ucsi, u64 command, u32 *cci,
			    void *data, size_t size);
	int (*async_control)(struct ucsi *ucsi, u64 command);
	bool (*update_altmodes)(struct ucsi *ucsi, u8 recipient,
				struct ucsi_altmode *orig,
				struct ucsi_altmode *updated);
	void (*update_connector)(struct ucsi_connector *con);
	void (*connector_status)(struct ucsi_connector *con);
	void (*add_partner_altmodes)(struct ucsi_connector *con);
	void (*remove_partner_altmodes)(struct ucsi_connector *con);
};

struct ucsi *ucsi_create(struct device *dev, const struct ucsi_operations *ops);
void ucsi_destroy(struct ucsi *ucsi);
int ucsi_register(struct ucsi *ucsi);
void ucsi_unregister(struct ucsi *ucsi);
void *ucsi_get_drvdata(struct ucsi *ucsi);
void ucsi_set_drvdata(struct ucsi *ucsi, void *data);
bool ucsi_con_mutex_lock(struct ucsi_connector *con);
void ucsi_con_mutex_unlock(struct ucsi_connector *con);

void ucsi_connector_change(struct ucsi *ucsi, u8 num);

/* -------------------------------------------------------------------------- */

/* Commands */
#define UCSI_PPM_RESET				0x01
#define UCSI_CANCEL				0x02
#define UCSI_CONNECTOR_RESET			0x03
#define UCSI_ACK_CC_CI				0x04
#define UCSI_SET_NOTIFICATION_ENABLE		0x05
#define UCSI_GET_CAPABILITY			0x06
#define UCSI_GET_CAPABILITY_SIZE		128
#define UCSI_GET_CONNECTOR_CAPABILITY		0x07
#define UCSI_GET_CONNECTOR_CAPABILITY_SIZE	32
#define UCSI_SET_CCOM				0x08
#define UCSI_SET_UOR				0x09
#define UCSI_SET_PDM				0x0a
#define UCSI_SET_PDR				0x0b
#define UCSI_GET_ALTERNATE_MODES		0x0c
#define UCSI_GET_CAM_SUPPORTED			0x0d
#define UCSI_GET_CURRENT_CAM			0x0e
#define UCSI_SET_NEW_CAM			0x0f
#define UCSI_GET_PDOS				0x10
#define UCSI_GET_CABLE_PROPERTY			0x11
#define UCSI_GET_CABLE_PROPERTY_SIZE		64
#define UCSI_GET_CONNECTOR_STATUS		0x12
#define UCSI_GET_CONNECTOR_STATUS_SIZE		152
#define UCSI_GET_ERROR_STATUS			0x13
#define UCSI_SET_POWER_LEVEL			0x14
#define UCSI_GET_ATTENTION_VDO			0x16
#define UCSI_GET_PD_MESSAGE			0x15
#define UCSI_GET_CAM_CS			0x18
#define UCSI_SET_SINK_PATH			0x1c
#define UCSI_READ_POWER_LEVEL			0x1e
#define UCSI_SET_USB				0x21
#define UCSI_GET_LPM_PPM_INFO			0x22

#define UCSI_CONNECTOR_NUMBER(_num_)		((u64)(_num_) << 16)
#define UCSI_COMMAND(_cmd_)			((_cmd_) & 0xff)

#define UCSI_GET_ALTMODE_GET_CONNECTOR_NUMBER(_cmd_)	(((_cmd_) >> 24) & GENMASK(6, 0))
#define UCSI_DEFAULT_GET_CONNECTOR_NUMBER(_cmd_)	(((_cmd_) >> 16) & GENMASK(6, 0))

/* CONNECTOR_RESET command bits */
#define UCSI_CONNECTOR_RESET_HARD_VER_1_0	BIT(23) /* Deprecated in v1.1 */
#define UCSI_CONNECTOR_RESET_DATA_VER_2_0	BIT(23) /* Redefined in v2.0 */

/* ACK_CC_CI bits */
#define UCSI_ACK_CONNECTOR_CHANGE		BIT(16)
#define UCSI_ACK_COMMAND_COMPLETE		BIT(17)

/* SET_NOTIFICATION_ENABLE command bits */
#define UCSI_ENABLE_NTFY_CMD_COMPLETE		BIT_ULL(16)
#define UCSI_ENABLE_NTFY_EXT_PWR_SRC_CHANGE	BIT_ULL(17)
#define UCSI_ENABLE_NTFY_PWR_OPMODE_CHANGE	BIT_ULL(18)
#define UCSI_ENABLE_NTFY_ATTENTION		BIT_ULL(19)
#define UCSI_ENABLE_NTFY_LPM_FW_UPDATE_REQ	BIT_ULL(20)
#define UCSI_ENABLE_NTFY_CAP_CHANGE		BIT_ULL(21)
#define UCSI_ENABLE_NTFY_PWR_LEVEL_CHANGE	BIT_ULL(22)
#define UCSI_ENABLE_NTFY_PD_RESET_COMPLETE	BIT_ULL(23)
#define UCSI_ENABLE_NTFY_CAM_CHANGE		BIT_ULL(24)
#define UCSI_ENABLE_NTFY_BAT_STATUS_CHANGE	BIT_ULL(25)
#define UCSI_ENABLE_NTFY_SECURITY_REQ_PARTNER	BIT_ULL(26)
#define UCSI_ENABLE_NTFY_PARTNER_CHANGE		BIT_ULL(27)

Annotation

Implementation Notes