drivers/usb/typec/wusb3801.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/wusb3801.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/wusb3801.c- Extension
.c- Size
- 11770 bytes
- Lines
- 436
- 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.
- 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/i2c.hlinux/module.hlinux/regmap.hlinux/regulator/consumer.hlinux/usb/typec.h
Detected Declarations
struct wusb3801function wusb3801_get_default_rolefunction wusb3801_map_port_typefunction wusb3801_map_pwr_opmodefunction wusb3801_map_try_rolefunction wusb3801_unmap_orientationfunction wusb3801_unmap_pwr_opmodefunction wusb3801_try_rolefunction wusb3801_port_type_setfunction wusb3801_hw_initfunction wusb3801_hw_updatefunction wusb3801_irqfunction wusb3801_probefunction wusb3801_remove
Annotated Snippet
struct wusb3801 {
struct typec_capability cap;
struct device *dev;
struct typec_partner *partner;
struct typec_port *port;
struct regmap *regmap;
struct regulator *vbus_supply;
unsigned int partner_type;
enum typec_port_type port_type;
enum typec_pwr_opmode pwr_opmode;
bool vbus_on;
};
static enum typec_role wusb3801_get_default_role(struct wusb3801 *wusb3801)
{
switch (wusb3801->port_type) {
case TYPEC_PORT_SRC:
return TYPEC_SOURCE;
case TYPEC_PORT_SNK:
return TYPEC_SINK;
case TYPEC_PORT_DRP:
default:
if (wusb3801->cap.prefer_role == TYPEC_SOURCE)
return TYPEC_SOURCE;
return TYPEC_SINK;
}
}
static int wusb3801_map_port_type(enum typec_port_type type)
{
switch (type) {
case TYPEC_PORT_SRC:
return WUSB3801_CTRL0_ROLE_SRC;
case TYPEC_PORT_SNK:
return WUSB3801_CTRL0_ROLE_SNK;
case TYPEC_PORT_DRP:
default:
return WUSB3801_CTRL0_ROLE_DRP;
}
}
static int wusb3801_map_pwr_opmode(enum typec_pwr_opmode mode)
{
switch (mode) {
case TYPEC_PWR_MODE_USB:
default:
return WUSB3801_CTRL0_CURRENT_DEFAULT;
case TYPEC_PWR_MODE_1_5A:
return WUSB3801_CTRL0_CURRENT_1_5A;
case TYPEC_PWR_MODE_3_0A:
return WUSB3801_CTRL0_CURRENT_3_0A;
}
}
static unsigned int wusb3801_map_try_role(int role)
{
switch (role) {
case TYPEC_NO_PREFERRED_ROLE:
default:
return WUSB3801_CTRL0_TRY_NONE;
case TYPEC_SINK:
return WUSB3801_CTRL0_TRY_SNK;
case TYPEC_SOURCE:
return WUSB3801_CTRL0_TRY_SRC;
}
}
static enum typec_orientation wusb3801_unmap_orientation(unsigned int status)
{
switch (status & WUSB3801_STAT_ORIENTATION) {
case WUSB3801_STAT_ORIENTATION_NONE:
case WUSB3801_STAT_ORIENTATION_BOTH:
default:
return TYPEC_ORIENTATION_NONE;
case WUSB3801_STAT_ORIENTATION_CC1:
return TYPEC_ORIENTATION_NORMAL;
case WUSB3801_STAT_ORIENTATION_CC2:
return TYPEC_ORIENTATION_REVERSE;
}
}
static enum typec_pwr_opmode wusb3801_unmap_pwr_opmode(unsigned int status)
{
switch (status & WUSB3801_STAT_CURRENT) {
case WUSB3801_STAT_CURRENT_STANDBY:
case WUSB3801_STAT_CURRENT_DEFAULT:
default:
return TYPEC_PWR_MODE_USB;
case WUSB3801_STAT_CURRENT_1_5A:
return TYPEC_PWR_MODE_1_5A;
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/module.h`, `linux/regmap.h`, `linux/regulator/consumer.h`, `linux/usb/typec.h`.
- Detected declarations: `struct wusb3801`, `function wusb3801_get_default_role`, `function wusb3801_map_port_type`, `function wusb3801_map_pwr_opmode`, `function wusb3801_map_try_role`, `function wusb3801_unmap_orientation`, `function wusb3801_unmap_pwr_opmode`, `function wusb3801_try_role`, `function wusb3801_port_type_set`, `function wusb3801_hw_init`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- 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.