drivers/usb/typec/ucsi/ucsi_acpi.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/ucsi/ucsi_acpi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/ucsi/ucsi_acpi.c- Extension
.c- Size
- 6346 bytes
- Lines
- 278
- 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/platform_device.hlinux/module.hlinux/acpi.hlinux/dmi.hucsi.h
Detected Declarations
struct ucsi_acpifunction ucsi_acpi_dsmfunction ucsi_acpi_read_versionfunction ucsi_acpi_read_ccifunction ucsi_acpi_poll_ccifunction ucsi_acpi_read_message_infunction ucsi_acpi_async_controlfunction ucsi_gram_sync_controlfunction ucsi_acpi_notifyfunction ucsi_acpi_probefunction ucsi_acpi_removefunction ucsi_acpi_resume
Annotated Snippet
struct ucsi_acpi {
struct device *dev;
struct ucsi *ucsi;
void *base;
bool check_bogus_event;
guid_t guid;
u64 cmd;
};
static int ucsi_acpi_dsm(struct ucsi_acpi *ua, int func)
{
union acpi_object *obj;
obj = acpi_evaluate_dsm(ACPI_HANDLE(ua->dev), &ua->guid, 1, func,
NULL);
if (!obj) {
dev_err(ua->dev, "%s: failed to evaluate _DSM %d\n",
__func__, func);
return -EIO;
}
ACPI_FREE(obj);
return 0;
}
static int ucsi_acpi_read_version(struct ucsi *ucsi, u16 *version)
{
struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
int ret;
ret = ucsi_acpi_dsm(ua, UCSI_DSM_FUNC_READ);
if (ret)
return ret;
memcpy(version, ua->base + UCSI_VERSION, sizeof(*version));
return 0;
}
static int ucsi_acpi_read_cci(struct ucsi *ucsi, u32 *cci)
{
struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
memcpy(cci, ua->base + UCSI_CCI, sizeof(*cci));
return 0;
}
static int ucsi_acpi_poll_cci(struct ucsi *ucsi, u32 *cci)
{
struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
int ret;
ret = ucsi_acpi_dsm(ua, UCSI_DSM_FUNC_READ);
if (ret)
return ret;
return ucsi_acpi_read_cci(ucsi, cci);
}
static int ucsi_acpi_read_message_in(struct ucsi *ucsi, void *val, size_t val_len)
{
struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
memcpy(val, ua->base + UCSI_MESSAGE_IN, val_len);
return 0;
}
static int ucsi_acpi_async_control(struct ucsi *ucsi, u64 command)
{
struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
memcpy(ua->base + UCSI_CONTROL, &command, sizeof(command));
ua->cmd = command;
return ucsi_acpi_dsm(ua, UCSI_DSM_FUNC_WRITE);
}
static const struct ucsi_operations ucsi_acpi_ops = {
.read_version = ucsi_acpi_read_version,
.read_cci = ucsi_acpi_read_cci,
.poll_cci = ucsi_acpi_poll_cci,
.read_message_in = ucsi_acpi_read_message_in,
.sync_control = ucsi_sync_control_common,
.async_control = ucsi_acpi_async_control
};
static int ucsi_gram_sync_control(struct ucsi *ucsi, u64 command, u32 *cci,
void *val, size_t len)
Annotation
- Immediate include surface: `linux/platform_device.h`, `linux/module.h`, `linux/acpi.h`, `linux/dmi.h`, `ucsi.h`.
- Detected declarations: `struct ucsi_acpi`, `function ucsi_acpi_dsm`, `function ucsi_acpi_read_version`, `function ucsi_acpi_read_cci`, `function ucsi_acpi_poll_cci`, `function ucsi_acpi_read_message_in`, `function ucsi_acpi_async_control`, `function ucsi_gram_sync_control`, `function ucsi_acpi_notify`, `function ucsi_acpi_probe`.
- 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.