drivers/usb/typec/tcpm/wcove.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/tcpm/wcove.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/tcpm/wcove.c- Extension
.c- Size
- 17449 bytes
- Lines
- 702
- 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/module.hlinux/usb/tcpm.hlinux/interrupt.hlinux/platform_device.hlinux/mfd/intel_soc_pmic.h
Detected Declarations
struct wcove_typecenum wcove_typec_funcenum wcove_typec_orientationenum wcove_typec_rolefunction wcove_typec_funcfunction wcove_initfunction wcove_get_vbusfunction wcove_set_vbusfunction wcove_set_vconnfunction wcove_to_typec_ccfunction wcove_get_ccfunction wcove_set_ccfunction wcove_set_polarityfunction wcove_set_current_limitfunction wcove_set_rolesfunction wcove_set_pd_rxfunction wcove_pd_transmitfunction wcove_start_togglingfunction wcove_read_rx_bufferfunction wcove_typec_irqfunction wcove_typec_probefunction wcove_typec_remove
Annotated Snippet
struct wcove_typec {
struct mutex lock; /* device lock */
struct device *dev;
struct regmap *regmap;
guid_t guid;
bool vbus;
struct tcpc_dev tcpc;
struct tcpm_port *tcpm;
};
#define tcpc_to_wcove(_tcpc_) container_of(_tcpc_, struct wcove_typec, tcpc)
enum wcove_typec_func {
WCOVE_FUNC_DRIVE_VBUS = 1,
WCOVE_FUNC_ORIENTATION,
WCOVE_FUNC_ROLE,
WCOVE_FUNC_DRIVE_VCONN,
};
enum wcove_typec_orientation {
WCOVE_ORIENTATION_NORMAL,
WCOVE_ORIENTATION_REVERSE,
};
enum wcove_typec_role {
WCOVE_ROLE_HOST,
WCOVE_ROLE_DEVICE,
};
#define WCOVE_DSM_UUID "482383f0-2876-4e49-8685-db66211af037"
static int wcove_typec_func(struct wcove_typec *wcove,
enum wcove_typec_func func, int param)
{
union acpi_object *obj;
union acpi_object tmp;
union acpi_object argv4 = ACPI_INIT_DSM_ARGV4(1, &tmp);
tmp.type = ACPI_TYPE_INTEGER;
tmp.integer.value = param;
obj = acpi_evaluate_dsm(ACPI_HANDLE(wcove->dev), &wcove->guid, 1, func,
&argv4);
if (!obj) {
dev_err(wcove->dev, "%s: failed to evaluate _DSM\n", __func__);
return -EIO;
}
ACPI_FREE(obj);
return 0;
}
static int wcove_init(struct tcpc_dev *tcpc)
{
struct wcove_typec *wcove = tcpc_to_wcove(tcpc);
int ret;
ret = regmap_write(wcove->regmap, USBC_CONTROL1, 0);
if (ret)
return ret;
/* Unmask everything */
ret = regmap_write(wcove->regmap, USBC_IRQMASK1, 0);
if (ret)
return ret;
return regmap_write(wcove->regmap, USBC_IRQMASK2, 0);
}
static int wcove_get_vbus(struct tcpc_dev *tcpc)
{
struct wcove_typec *wcove = tcpc_to_wcove(tcpc);
unsigned int cc1ctrl;
int ret;
ret = regmap_read(wcove->regmap, USBC_CC1_CTRL, &cc1ctrl);
if (ret)
return ret;
wcove->vbus = !!(cc1ctrl & USBC_CC_CTRL_VBUSOK);
return wcove->vbus;
}
static int wcove_set_vbus(struct tcpc_dev *tcpc, bool on, bool sink)
{
struct wcove_typec *wcove = tcpc_to_wcove(tcpc);
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/module.h`, `linux/usb/tcpm.h`, `linux/interrupt.h`, `linux/platform_device.h`, `linux/mfd/intel_soc_pmic.h`.
- Detected declarations: `struct wcove_typec`, `enum wcove_typec_func`, `enum wcove_typec_orientation`, `enum wcove_typec_role`, `function wcove_typec_func`, `function wcove_init`, `function wcove_get_vbus`, `function wcove_set_vbus`, `function wcove_set_vconn`, `function wcove_to_typec_cc`.
- 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.