drivers/usb/typec/tipd/core.c

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

File Facts

System
Linux kernel
Corpus path
drivers/usb/typec/tipd/core.c
Extension
.c
Size
51353 bytes
Lines
2051
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 tps6598x_rx_identity_reg {
	u8 status;
	struct usb_pd_identity identity;
} __packed;

/* TPS_REG_USB4_STATUS */
struct tps6598x_usb4_status_reg {
	u8 mode_status;
	__le32 eudo;
	__le32 unknown;
} __packed;

/* TPS_REG_DP_SID_STATUS */
struct tps6598x_dp_sid_status_reg {
	u8 mode_status;
	__le32 status_tx;
	__le32 status_rx;
	__le32 configure;
	__le32 mode_data;
} __packed;

/* TPS_REG_INTEL_VID_STATUS */
struct tps6598x_intel_vid_status_reg {
	u8 mode_status;
	__le32 attention_vdo;
	__le16 enter_vdo;
	__le16 device_mode;
	__le16 cable_mode;
} __packed;

/* Standard Task return codes */
#define TPS_TASK_TIMEOUT		1
#define TPS_TASK_REJECTED		3

/* Debounce delay for mode changes, in milliseconds */
#define CD321X_DEBOUNCE_DELAY_MS 500

enum {
	TPS_MODE_APP,
	TPS_MODE_BOOT,
	TPS_MODE_BIST,
	TPS_MODE_DISC,
	TPS_MODE_PTCH,
};

static const char *const modes[] = {
	[TPS_MODE_APP]	= "APP ",
	[TPS_MODE_BOOT]	= "BOOT",
	[TPS_MODE_BIST]	= "BIST",
	[TPS_MODE_DISC]	= "DISC",
	[TPS_MODE_PTCH] = "PTCH",
};

/* Unrecognized commands will be replaced with "!CMD" */
#define INVALID_CMD(_cmd_)		(_cmd_ == 0x444d4321)

struct tps6598x;

struct tipd_data {
	irq_handler_t irq_handler;
	u64 irq_mask1;
	size_t tps_struct_size;
	void (*remove)(struct tps6598x *tps);
	int (*register_port)(struct tps6598x *tps, struct fwnode_handle *node);
	void (*unregister_port)(struct tps6598x *tps);
	void (*trace_data_status)(u32 status);
	void (*trace_power_status)(u16 status);
	void (*trace_status)(u32 status);
	int (*apply_patch)(struct tps6598x *tps);
	int (*init)(struct tps6598x *tps);
	int (*switch_power_state)(struct tps6598x *tps, u8 target_state);
	bool (*read_data_status)(struct tps6598x *tps);
	int (*reset)(struct tps6598x *tps);
	int (*connect)(struct tps6598x *tps, u32 status);
};

struct tps6598x {
	struct device *dev;
	struct regmap *regmap;
	struct mutex lock; /* device lock */
	u8 i2c_protocol:1;

	struct gpio_desc *reset;
	struct typec_port *port;
	struct typec_partner *partner;
	struct usb_pd_identity partner_identity;
	struct usb_role_switch *role_sw;
	struct typec_capability typec_cap;

	struct power_supply *psy;

Annotation

Implementation Notes