drivers/usb/typec/ucsi/ucsi_yoga_c630.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/ucsi/ucsi_yoga_c630.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/ucsi/ucsi_yoga_c630.c- Extension
.c- Size
- 8209 bytes
- Lines
- 334
- 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.
- 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/auxiliary_bus.hlinux/bitops.hlinux/bitfield.hlinux/completion.hlinux/container_of.hlinux/module.hlinux/notifier.hlinux/of.hlinux/property.hlinux/string.hlinux/platform_data/lenovo-yoga-c630.hlinux/usb/typec_dp.hdrm/bridge/aux-bridge.hucsi.h
Detected Declarations
struct yoga_c630_ucsifunction yoga_c630_ucsi_read_versionfunction yoga_c630_ucsi_read_ccifunction yoga_c630_ucsi_read_message_infunction yoga_c630_ucsi_async_controlfunction yoga_c630_ucsi_sync_controlfunction UCSI_GET_ALTMODE_GET_CONNECTOR_NUMBERfunction CON1function yoga_c630_ucsi_update_altmodesfunction yoga_c630_ucsi_update_connectorfunction yoga_c630_ucsi_read_port0_statusfunction yoga_c630_ucsi_notifyfunction yoga_c630_ucsi_probefunction device_for_each_child_node_scopedfunction yoga_c630_ucsi_remove
Annotated Snippet
struct yoga_c630_ucsi {
struct yoga_c630_ec *ec;
struct ucsi *ucsi;
struct auxiliary_device *bridge;
struct notifier_block nb;
u16 version;
};
static int yoga_c630_ucsi_read_version(struct ucsi *ucsi, u16 *version)
{
struct yoga_c630_ucsi *uec = ucsi_get_drvdata(ucsi);
*version = uec->version;
return 0;
}
static int yoga_c630_ucsi_read_cci(struct ucsi *ucsi, u32 *cci)
{
struct yoga_c630_ucsi *uec = ucsi_get_drvdata(ucsi);
u8 buf[YOGA_C630_UCSI_READ_SIZE];
int ret;
ret = yoga_c630_ec_ucsi_read(uec->ec, buf);
if (ret)
return ret;
memcpy(cci, buf, sizeof(*cci));
return 0;
}
static int yoga_c630_ucsi_read_message_in(struct ucsi *ucsi,
void *val, size_t val_len)
{
struct yoga_c630_ucsi *uec = ucsi_get_drvdata(ucsi);
u8 buf[YOGA_C630_UCSI_READ_SIZE];
int ret;
ret = yoga_c630_ec_ucsi_read(uec->ec, buf);
if (ret)
return ret;
memcpy(val, buf + YOGA_C630_UCSI_CCI_SIZE,
min(val_len, YOGA_C630_UCSI_DATA_SIZE));
return 0;
}
static int yoga_c630_ucsi_async_control(struct ucsi *ucsi, u64 command)
{
struct yoga_c630_ucsi *uec = ucsi_get_drvdata(ucsi);
return yoga_c630_ec_ucsi_write(uec->ec, (u8*)&command);
}
static int yoga_c630_ucsi_sync_control(struct ucsi *ucsi,
u64 command,
u32 *cci,
void *data, size_t size)
{
int ret;
/*
* EC doesn't return connector's DP mode even though it is supported.
* Fake it.
*/
if (UCSI_COMMAND(command) == UCSI_GET_ALTERNATE_MODES &&
UCSI_GET_ALTMODE_GET_CONNECTOR_NUMBER(command) == 1 &&
UCSI_ALTMODE_RECIPIENT(command) == UCSI_RECIPIENT_CON &&
UCSI_ALTMODE_OFFSET(command) == 0) {
static const struct ucsi_altmode alt = {
.svid = USB_TYPEC_DP_SID,
.mid = USB_TYPEC_DP_MODE,
};
dev_dbg(ucsi->dev, "faking DP altmode for con1\n");
memset(data, 0, size);
memcpy(data, &alt, min(sizeof(alt), size));
*cci = UCSI_CCI_COMMAND_COMPLETE | UCSI_SET_CCI_LENGTH(sizeof(alt));
return 0;
}
/*
* EC can return AltModes present on CON1 (port0, right) for CON2
* (port1, left) too. Ignore all requests going to CON2 (it doesn't
* support DP anyway).
*/
if (UCSI_COMMAND(command) == UCSI_GET_ALTERNATE_MODES &&
UCSI_GET_ALTMODE_GET_CONNECTOR_NUMBER(command) == 2) {
Annotation
- Immediate include surface: `linux/auxiliary_bus.h`, `linux/bitops.h`, `linux/bitfield.h`, `linux/completion.h`, `linux/container_of.h`, `linux/module.h`, `linux/notifier.h`, `linux/of.h`.
- Detected declarations: `struct yoga_c630_ucsi`, `function yoga_c630_ucsi_read_version`, `function yoga_c630_ucsi_read_cci`, `function yoga_c630_ucsi_read_message_in`, `function yoga_c630_ucsi_async_control`, `function yoga_c630_ucsi_sync_control`, `function UCSI_GET_ALTMODE_GET_CONNECTOR_NUMBER`, `function CON1`, `function yoga_c630_ucsi_update_altmodes`, `function yoga_c630_ucsi_update_connector`.
- Atlas domain: Driver Families / drivers/usb.
- 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.