drivers/usb/typec/tcpm/tcpm.c

Source file repositories/reference/linux-study-clean/drivers/usb/typec/tcpm/tcpm.c

File Facts

System
Linux kernel
Corpus path
drivers/usb/typec/tcpm/tcpm.c
Extension
.c
Size
242755 bytes
Lines
8651
Domain
Driver Families
Bucket
drivers/usb
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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 pd_mode_data {
	int svid_index;		/* current SVID index		*/
	int nsvids;
	u16 svids[SVID_DISCOVERY_MAX];
	int altmodes;		/* number of alternate modes	*/
	struct typec_altmode_desc altmode_desc[ALTMODE_DISCOVERY_MAX];
};

/*
 * @min_volt: Actual min voltage at the local port
 * @req_min_volt: Requested min voltage to the port partner
 * @max_volt: Actual max voltage at the local port
 * @req_max_volt: Requested max voltage to the port partner
 * @max_curr: Actual max current at the local port
 * @req_max_curr: Requested max current of the port partner
 * @req_out_volt: Requested output voltage to the port partner
 * @req_op_curr: Requested operating current to the port partner
 * @supported: Parter has at least one APDO hence supports PPS
 * @active: PPS mode is active
 */
struct pd_pps_data {
	u32 min_volt;
	u32 req_min_volt;
	u32 max_volt;
	u32 req_max_volt;
	u32 max_curr;
	u32 req_max_curr;
	u32 req_out_volt;
	u32 req_op_curr;
	bool supported;
	bool active;
};

enum spr_avs_status {
	SPR_AVS_UNKNOWN,
	SPR_AVS_NOT_SUPPORTED,
	SPR_AVS_SUPPORTED
};

static const char * const spr_avs_status_strings[] = {
	[SPR_AVS_UNKNOWN]	= "Unknown",
	[SPR_AVS_SUPPORTED]	= "Supported",
	[SPR_AVS_NOT_SUPPORTED]	= "Not Supported",
};

/*
 * Standard Power Range Adjustable Voltage Supply (SPR - AVS) data
 * @max_current_ma_9v_to_15v: Max current for 9V to 15V range derived from
 *                            source cap & sink cap
 * @max_current_ma_15v_to_20v: Max current for 15V to 20V range derived from
 *                             source cap & sink cap
 * @req_op_curr_ma: Requested operating current to the port partner acting as source
 * @req_out_volt_mv: Requested output voltage to the port partner acting as source
 * @max_out_volt_mv: Max SPR voltage supported by the port and the port partner
 * @max_current_ma; MAX SPR current supported by the port and the port partner
 * @port_partner_src_status: SPR AVS status of port partner acting as source
 * @port_partner_src_pdo_index: PDO index of SPR AVS cap of the port partner
 *                              acting as source. Valid only when
 *                              port_partner_src_status is SPR_AVS_SUPPORTED.
 * @port_snk_status: SPR AVS status of the local port acting as sink.
 * @port_snk_pdo_index: PDO index of SPR AVS cap of local port acting as sink
 * @active: True when the local port acting as the sink has negotiated SPR AVS
 *          with the partner acting as source.
 */
struct pd_spr_avs_data {
	u32 max_current_ma_9v_to_15v;
	u32 max_current_ma_15v_to_20v;
	u32 req_op_curr_ma;
	u32 req_out_volt_mv;
	u32 max_out_volt_mv;
	u32 max_current_ma;
	enum spr_avs_status port_partner_src_status;
	unsigned int port_partner_src_pdo_index;
	enum spr_avs_status port_snk_status;
	unsigned int port_snk_pdo_index;
	bool active;
};

struct pd_data {
	struct usb_power_delivery *pd;
	struct usb_power_delivery_capabilities *source_cap;
	struct usb_power_delivery_capabilities_desc source_desc;
	struct usb_power_delivery_capabilities *sink_cap;
	struct usb_power_delivery_capabilities_desc sink_desc;
	unsigned int operating_snk_mw;
};

#define PD_CAP_REV10	0x1
#define PD_CAP_REV20	0x2
#define PD_CAP_REV30	0x3

Annotation

Implementation Notes