drivers/usb/typec/ucsi/ucsi_ccg.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/ucsi/ucsi_ccg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/ucsi/ucsi_ccg.c- Extension
.c- Size
- 37779 bytes
- Lines
- 1598
- 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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/acpi.hlinux/delay.hlinux/firmware.hlinux/hex.hlinux/i2c.hlinux/module.hlinux/pci.hlinux/platform_device.hlinux/pm.hlinux/pm_runtime.hlinux/usb/typec_dp.hlinux/unaligned.hucsi.h
Detected Declarations
struct ccg_dev_infostruct version_formatstruct version_infostruct fw_config_tablestruct ccg_cmdstruct ccg_respstruct ucsi_ccg_altmodestruct op_regionstruct ucsi_ccgenum enum_fw_modeenum enum_flash_modeenum ccg_resp_codefunction ccg_readfunction ccg_writefunction ccg_op_region_updatefunction ucsi_ccg_initfunction ucsi_ccg_update_get_current_cam_cmdfunction ucsi_ccg_update_altmodesfunction ucsi_ccg_update_set_new_cam_cmdfunction ucsi_ccg_nvidia_altmodefunction ucsi_ccg_read_versionfunction ucsi_ccg_read_ccifunction ucsi_ccg_read_message_infunction ucsi_ccg_async_controlfunction ucsi_ccg_sync_controlfunction ccg_irq_handlerfunction ccg_request_irqfunction ccg_pm_workaround_workfunction get_fw_infofunction invalid_async_evtfunction ccg_process_responsefunction ccg_read_responsefunction ccg_send_commandfunction ccg_cmd_enter_flashingfunction ccg_cmd_resetfunction ccg_cmd_port_controlfunction ccg_cmd_jump_boot_modefunction ccg_cmd_write_flash_rowfunction ccg_cmd_validate_fwfunction ccg_check_vendor_versionfunction ccg_check_fw_versionfunction ccg_fw_update_neededfunction do_flashfunction ccg_fw_updatefunction ccg_restartfunction ccg_update_firmwarefunction do_flash_storefunction ucsi_ccg_attrs_is_visible
Annotated Snippet
struct ccg_dev_info {
#define CCG_DEVINFO_FWMODE_SHIFT (0)
#define CCG_DEVINFO_FWMODE_MASK (0x3 << CCG_DEVINFO_FWMODE_SHIFT)
#define CCG_DEVINFO_PDPORTS_SHIFT (2)
#define CCG_DEVINFO_PDPORTS_MASK (0x3 << CCG_DEVINFO_PDPORTS_SHIFT)
u8 mode;
u8 bl_mode;
__le16 silicon_id;
__le16 bl_last_row;
} __packed;
struct version_format {
__le16 build;
u8 patch;
u8 ver;
#define CCG_VERSION_PATCH(x) ((x) << 16)
#define CCG_VERSION(x) ((x) << 24)
#define CCG_VERSION_MIN_SHIFT (0)
#define CCG_VERSION_MIN_MASK (0xf << CCG_VERSION_MIN_SHIFT)
#define CCG_VERSION_MAJ_SHIFT (4)
#define CCG_VERSION_MAJ_MASK (0xf << CCG_VERSION_MAJ_SHIFT)
} __packed;
/*
* Firmware version 3.1.10 or earlier, built for NVIDIA has known issue
* of missing interrupt when a device is connected for runtime resume
*/
#define CCG_FW_BUILD_NVIDIA (('n' << 8) | 'v')
#define CCG_OLD_FW_VERSION (CCG_VERSION(0x31) | CCG_VERSION_PATCH(10))
/* Firmware for Tegra doesn't support UCSI ALT command, built
* for NVIDIA has known issue of reporting wrong capability info
*/
#define CCG_FW_BUILD_NVIDIA_TEGRA (('g' << 8) | 'n')
/* Altmode offset for NVIDIA Function Test Board (FTB) */
#define NVIDIA_FTB_DP_OFFSET (2)
#define NVIDIA_FTB_DBG_OFFSET (3)
struct version_info {
struct version_format base;
struct version_format app;
};
struct fw_config_table {
u32 identity;
u16 table_size;
u8 fwct_version;
u8 is_key_change;
u8 guid[16];
struct version_format base;
struct version_format app;
u8 primary_fw_digest[32];
u32 key_exp_length;
u8 key_modulus[256];
u8 key_exp[4];
};
/* CCGx response codes */
enum ccg_resp_code {
CMD_NO_RESP = 0x00,
CMD_SUCCESS = 0x02,
FLASH_DATA_AVAILABLE = 0x03,
CMD_INVALID = 0x05,
FLASH_UPDATE_FAIL = 0x07,
INVALID_FW = 0x08,
INVALID_ARG = 0x09,
CMD_NOT_SUPPORT = 0x0A,
TRANSACTION_FAIL = 0x0C,
PD_CMD_FAIL = 0x0D,
UNDEF_ERROR = 0x0F,
INVALID_RESP = 0x10,
};
#define CCG_EVENT_MAX (EVENT_INDEX + 43)
struct ccg_cmd {
u16 reg;
u32 data;
int len;
u32 delay; /* ms delay for cmd timeout */
};
struct ccg_resp {
u8 code;
u8 length;
};
struct ucsi_ccg_altmode {
u16 svid;
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/delay.h`, `linux/firmware.h`, `linux/hex.h`, `linux/i2c.h`, `linux/module.h`, `linux/pci.h`, `linux/platform_device.h`.
- Detected declarations: `struct ccg_dev_info`, `struct version_format`, `struct version_info`, `struct fw_config_table`, `struct ccg_cmd`, `struct ccg_resp`, `struct ucsi_ccg_altmode`, `struct op_region`, `struct ucsi_ccg`, `enum enum_fw_mode`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.