drivers/thunderbolt/eeprom.c
Source file repositories/reference/linux-study-clean/drivers/thunderbolt/eeprom.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thunderbolt/eeprom.c- Extension
.c- Size
- 15357 bytes
- Lines
- 725
- 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.
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/crc32.hlinux/delay.hlinux/property.hlinux/slab.htb.h
Detected Declarations
struct tb_drom_headerstruct tb_drom_entry_headerstruct tb_drom_entry_genericstruct tb_drom_entry_portstruct tb_drom_entry_descenum tb_eeprom_transferenum tb_drom_entry_typefunction Copyrightfunction tb_eeprom_ctl_readfunction tb_eeprom_activefunction tb_eeprom_transferfunction tb_eeprom_outfunction tb_eeprom_infunction tb_eeprom_get_drom_offsetfunction tb_eeprom_read_nfunction tb_crc8function tb_crc32function tb_drom_read_uid_onlyfunction tb_drom_parse_entry_genericfunction tb_drom_parse_entry_portfunction tb_drom_parse_entriesfunction tb_switch_drom_allocfunction tb_switch_drom_freefunction tb_drom_copy_efifunction tb_drom_copy_nvmfunction usb4_copy_dromfunction tb_drom_bit_bangfunction tb_drom_parse_v1function usb4_drom_parsefunction tb_drom_parsefunction tb_drom_host_readfunction tb_drom_device_readfunction tb_drom_read
Annotated Snippet
struct tb_drom_header {
/* BYTE 0 */
u8 uid_crc8; /* checksum for uid */
/* BYTES 1-8 */
u64 uid;
/* BYTES 9-12 */
u32 data_crc32; /* checksum for data_len bytes starting at byte 13 */
/* BYTE 13 */
u8 device_rom_revision; /* should be <= 1 */
u16 data_len:12;
u8 reserved:4;
/* BYTES 16-21 - Only for TBT DROM, nonexistent in USB4 DROM */
u16 vendor_id;
u16 model_id;
u8 model_rev;
u8 eeprom_rev;
} __packed;
enum tb_drom_entry_type {
/* force unsigned to prevent "one-bit signed bitfield" warning */
TB_DROM_ENTRY_GENERIC = 0U,
TB_DROM_ENTRY_PORT,
};
struct tb_drom_entry_header {
u8 len;
u8 index:6;
bool port_disabled:1; /* only valid if type is TB_DROM_ENTRY_PORT */
enum tb_drom_entry_type type:1;
} __packed;
struct tb_drom_entry_generic {
struct tb_drom_entry_header header;
u8 data[];
} __packed;
struct tb_drom_entry_port {
/* BYTES 0-1 */
struct tb_drom_entry_header header;
/* BYTE 2 */
u8 dual_link_port_rid:4;
u8 link_nr:1;
u8 unknown1:2;
bool has_dual_link_port:1;
/* BYTE 3 */
u8 dual_link_port_nr:6;
u8 unknown2:2;
/* BYTES 4 - 5 TODO decode */
u8 micro2:4;
u8 micro1:4;
u8 micro3;
/* BYTES 6-7, TODO: verify (find hardware that has these set) */
u8 peer_port_rid:4;
u8 unknown3:3;
bool has_peer_port:1;
u8 peer_port_nr:6;
u8 unknown4:2;
} __packed;
/* USB4 product descriptor */
struct tb_drom_entry_desc {
struct tb_drom_entry_header header;
u16 bcdUSBSpec;
u16 idVendor;
u16 idProduct;
u16 bcdProductFWRevision;
u32 TID;
u8 productHWRevision;
};
/**
* tb_drom_read_uid_only() - Read UID directly from DROM
* @sw: Router whose UID to read
* @uid: UID is placed here
*
* Does not use the cached copy in sw->drom. Used during resume to check switch
* identity.
*
* Return: %0 on success, negative errno otherwise.
*/
int tb_drom_read_uid_only(struct tb_switch *sw, u64 *uid)
{
u8 data[9];
u8 crc;
int res;
/* read uid */
Annotation
- Immediate include surface: `linux/crc32.h`, `linux/delay.h`, `linux/property.h`, `linux/slab.h`, `tb.h`.
- Detected declarations: `struct tb_drom_header`, `struct tb_drom_entry_header`, `struct tb_drom_entry_generic`, `struct tb_drom_entry_port`, `struct tb_drom_entry_desc`, `enum tb_eeprom_transfer`, `enum tb_drom_entry_type`, `function Copyright`, `function tb_eeprom_ctl_read`, `function tb_eeprom_active`.
- Atlas domain: Driver Families / drivers/thunderbolt.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.