drivers/thunderbolt/tb.h

Source file repositories/reference/linux-study-clean/drivers/thunderbolt/tb.h

File Facts

System
Linux kernel
Corpus path
drivers/thunderbolt/tb.h
Extension
.h
Size
55175 bytes
Lines
1560
Domain
Driver Families
Bucket
drivers/thunderbolt
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 tb_nvm {
	struct device *dev;
	u32 major;
	u32 minor;
	int id;
	struct nvmem_device *active;
	size_t active_size;
	struct nvmem_device *non_active;
	void *buf;
	void *buf_data_start;
	size_t buf_data_size;
	bool authenticating;
	bool flushed;
	const struct tb_nvm_vendor_ops *vops;
};

enum tb_nvm_write_ops {
	WRITE_AND_AUTHENTICATE = 1,
	WRITE_ONLY = 2,
	AUTHENTICATE_ONLY = 3,
};

#define TB_SWITCH_KEY_SIZE		32
#define TB_SWITCH_MAX_DEPTH		6
#define USB4_SWITCH_MAX_DEPTH		5

/**
 * enum tb_switch_tmu_mode - TMU mode
 * @TB_SWITCH_TMU_MODE_OFF: TMU is off
 * @TB_SWITCH_TMU_MODE_LOWRES: Uni-directional, normal mode
 * @TB_SWITCH_TMU_MODE_HIFI_UNI: Uni-directional, HiFi mode
 * @TB_SWITCH_TMU_MODE_HIFI_BI: Bi-directional, HiFi mode
 * @TB_SWITCH_TMU_MODE_MEDRES_ENHANCED_UNI: Enhanced Uni-directional, MedRes mode
 *
 * Ordering is based on TMU accuracy level (highest last).
 */
enum tb_switch_tmu_mode {
	TB_SWITCH_TMU_MODE_OFF,
	TB_SWITCH_TMU_MODE_LOWRES,
	TB_SWITCH_TMU_MODE_HIFI_UNI,
	TB_SWITCH_TMU_MODE_HIFI_BI,
	TB_SWITCH_TMU_MODE_MEDRES_ENHANCED_UNI,
};

/**
 * struct tb_switch_tmu - Structure holding router TMU configuration
 * @cap: Offset to the TMU capability (%0 if not found)
 * @has_ucap: Does the switch support uni-directional mode
 * @mode: TMU mode related to the upstream router. Reflects the HW
 *	  setting. Don't care for host router.
 * @mode_request: TMU mode requested to set. Related to upstream router.
 *		   Don't care for host router.
 */
struct tb_switch_tmu {
	int cap;
	bool has_ucap;
	enum tb_switch_tmu_mode mode;
	enum tb_switch_tmu_mode mode_request;
};

/**
 * struct tb_switch - a thunderbolt switch
 * @dev: Device for the switch
 * @config: Switch configuration
 * @ports: Ports in this switch
 * @dma_port: If the switch has port supporting DMA configuration based
 *	      mailbox this will hold the pointer to that (%NULL
 *	      otherwise). If set it also means the switch has
 *	      upgradeable NVM.
 * @tmu: The switch TMU configuration
 * @tb: Pointer to the domain the switch belongs to
 * @uid: Unique ID of the switch
 * @uuid: UUID of the switch (or %NULL if not supported)
 * @vendor: Vendor ID of the switch
 * @device: Device ID of the switch
 * @vendor_name: Name of the vendor (or %NULL if not known)
 * @device_name: Name of the device (or %NULL if not known)
 * @link_speed: Speed of the link in Gb/s
 * @link_width: Width of the upstream facing link
 * @preferred_link_width: Router preferred link width (only set for Gen 4 links)
 * @link_usb4: Upstream link is USB4
 * @generation: Switch Thunderbolt generation
 * @cap_plug_events: Offset to the plug events capability (%0 if not found)
 * @cap_vsec_tmu: Offset to the TMU vendor specific capability (%0 if not found)
 * @cap_lc: Offset to the link controller capability (%0 if not found)
 * @cap_lp: Offset to the low power (CLx for TBT) capability (%0 if not found)
 * @is_unplugged: The switch is going away
 * @drom: DROM of the switch (%NULL if not found)
 * @nvm: Pointer to the NVM if the switch has one (%NULL otherwise)
 * @no_nvm_upgrade: Prevent NVM upgrade of this switch

Annotation

Implementation Notes