drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c- Extension
.c- Size
- 13047 bytes
- Lines
- 529
- 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.
- 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
drm/bridge/aux-bridge.hlinux/auxiliary_bus.hlinux/bitops.hlinux/completion.hlinux/container_of.hlinux/module.hlinux/notifier.hlinux/of.hlinux/platform_data/huawei-gaokun-ec.hlinux/string.hlinux/usb/pd_vdo.hlinux/usb/typec_altmode.hlinux/usb/typec_dp.hlinux/workqueue_types.hucsi.h
Detected Declarations
struct gaokun_ucsi_regstruct gaokun_ucsi_portstruct gaokun_ucsienum gaokun_ucsi_ccxenum gaokun_ucsi_muxenum gaokun_ucsi_dpam_panfunction gaokun_ucsi_read_versionfunction gaokun_ucsi_read_ccifunction gaokun_ucsi_read_message_infunction gaokun_ucsi_async_controlfunction gaokun_ucsi_update_connectorfunction gaokun_set_orientationfunction gaokun_ucsi_connector_statusfunction gaokun_ucsi_port_updatefunction gaokun_ucsi_refreshfunction gaokun_ucsi_handle_altmodefunction gaokun_ucsi_altmode_notify_indfunction gaokun_ucsi_complete_usb_ackfunction gaokun_ucsi_handle_no_usb_eventfunction gaokun_ucsi_notifyfunction gaokun_ucsi_ports_initfunction device_for_each_child_nodefunction gaokun_ucsi_register_workerfunction gaokun_ucsi_probefunction gaokun_ucsi_remove
Annotated Snippet
struct gaokun_ucsi_reg {
u8 num_ports;
u8 port_updt;
u8 port_data[4];
u8 checksum;
u8 reserved;
} __packed;
struct gaokun_ucsi_port {
struct completion usb_ack;
spinlock_t lock; /* serializing port resource access */
struct gaokun_ucsi *ucsi;
struct auxiliary_device *bridge;
int idx;
enum gaokun_ucsi_ccx ccx;
enum gaokun_ucsi_mux mux;
u8 mode;
u16 svid;
u8 hpd_state;
u8 hpd_irq;
};
struct gaokun_ucsi {
struct gaokun_ec *ec;
struct ucsi *ucsi;
struct gaokun_ucsi_port *ports;
struct device *dev;
struct delayed_work work;
struct notifier_block nb;
u16 version;
u8 num_ports;
};
/* -------------------------------------------------------------------------- */
/* For UCSI */
static int gaokun_ucsi_read_version(struct ucsi *ucsi, u16 *version)
{
struct gaokun_ucsi *uec = ucsi_get_drvdata(ucsi);
*version = uec->version;
return 0;
}
static int gaokun_ucsi_read_cci(struct ucsi *ucsi, u32 *cci)
{
struct gaokun_ucsi *uec = ucsi_get_drvdata(ucsi);
u8 buf[GAOKUN_UCSI_READ_SIZE];
int ret;
ret = gaokun_ec_ucsi_read(uec->ec, buf);
if (ret)
return ret;
memcpy(cci, buf, sizeof(*cci));
return 0;
}
static int gaokun_ucsi_read_message_in(struct ucsi *ucsi,
void *val, size_t val_len)
{
struct gaokun_ucsi *uec = ucsi_get_drvdata(ucsi);
u8 buf[GAOKUN_UCSI_READ_SIZE];
int ret;
ret = gaokun_ec_ucsi_read(uec->ec, buf);
if (ret)
return ret;
memcpy(val, buf + GAOKUN_UCSI_CCI_SIZE,
min(val_len, GAOKUN_UCSI_MSGI_SIZE));
return 0;
}
static int gaokun_ucsi_async_control(struct ucsi *ucsi, u64 command)
{
struct gaokun_ucsi *uec = ucsi_get_drvdata(ucsi);
u8 buf[GAOKUN_UCSI_WRITE_SIZE] = {};
memcpy(buf, &command, sizeof(command));
return gaokun_ec_ucsi_write(uec->ec, buf);
}
static void gaokun_ucsi_update_connector(struct ucsi_connector *con)
Annotation
- Immediate include surface: `drm/bridge/aux-bridge.h`, `linux/auxiliary_bus.h`, `linux/bitops.h`, `linux/completion.h`, `linux/container_of.h`, `linux/module.h`, `linux/notifier.h`, `linux/of.h`.
- Detected declarations: `struct gaokun_ucsi_reg`, `struct gaokun_ucsi_port`, `struct gaokun_ucsi`, `enum gaokun_ucsi_ccx`, `enum gaokun_ucsi_mux`, `enum gaokun_ucsi_dpam_pan`, `function gaokun_ucsi_read_version`, `function gaokun_ucsi_read_cci`, `function gaokun_ucsi_read_message_in`, `function gaokun_ucsi_async_control`.
- 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.
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.