drivers/usb/typec/stusb160x.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/stusb160x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/stusb160x.c- Extension
.c- Size
- 23552 bytes
- Lines
- 880
- 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/bitfield.hlinux/i2c.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/regmap.hlinux/regulator/consumer.hlinux/usb/role.hlinux/usb/typec.h
Detected Declarations
struct stusb160xenum stusb160x_pwr_modeenum stusb160x_attached_modefunction stusb160x_reg_writeablefunction stusb160x_reg_readablefunction stusb160x_reg_volatilefunction stusb160x_reg_preciousfunction stusb160x_get_vconnfunction stusb160x_set_vconnfunction stusb160x_get_pwr_opmodefunction stusb160x_get_accessoryfunction stusb160x_get_vconn_rolefunction stusb160x_set_data_rolefunction stusb160x_attachfunction stusb160x_detachfunction stusb160x_irq_handlerfunction stusb160x_irq_initfunction stusb160x_chip_initfunction stusb160x_get_fw_capsfunction stusb160x_get_capsfunction stusb160x_probefunction stusb160x_removefunction stusb160x_suspendfunction stusb160x_resume
Annotated Snippet
struct stusb160x {
struct device *dev;
struct regmap *regmap;
struct regulator *vdd_supply;
struct regulator *vsys_supply;
struct regulator *vconn_supply;
struct regulator *main_supply;
struct typec_port *port;
struct typec_capability capability;
struct typec_partner *partner;
enum typec_port_type port_type;
enum typec_pwr_opmode pwr_opmode;
bool vbus_on;
struct usb_role_switch *role_sw;
};
static bool stusb160x_reg_writeable(struct device *dev, unsigned int reg)
{
switch (reg) {
case STUSB160X_ALERT_STATUS_MASK_CTRL:
case STUSB160X_CC_CAPABILITY_CTRL:
case STUSB160X_CC_VCONN_SWITCH_CTRL:
case STUSB160X_VCONN_MONITORING_CTRL:
case STUSB160X_VBUS_MONITORING_RANGE_CTRL:
case STUSB160X_RESET_CTRL:
case STUSB160X_VBUS_DISCHARGE_TIME_CTRL:
case STUSB160X_CC_POWER_MODE_CTRL:
case STUSB160X_VBUS_MONITORING_CTRL:
return true;
default:
return false;
}
}
static bool stusb160x_reg_readable(struct device *dev, unsigned int reg)
{
if (reg <= 0x0A ||
(reg >= 0x14 && reg <= 0x17) ||
(reg >= 0x19 && reg <= 0x1D) ||
(reg >= 0x29 && reg <= 0x2D) ||
(reg == 0x1F || reg == 0x21 || reg == 0x24 || reg == 0x2F))
return false;
else
return true;
}
static bool stusb160x_reg_volatile(struct device *dev, unsigned int reg)
{
switch (reg) {
case STUSB160X_ALERT_STATUS:
case STUSB160X_CC_CONNECTION_STATUS_TRANS:
case STUSB160X_CC_CONNECTION_STATUS:
case STUSB160X_MONITORING_STATUS_TRANS:
case STUSB160X_MONITORING_STATUS:
case STUSB160X_CC_OPERATION_STATUS:
case STUSB160X_HW_FAULT_STATUS_TRANS:
case STUSB160X_HW_FAULT_STATUS:
case STUSB160X_VBUS_DISCHARGE_STATUS:
case STUSB160X_VBUS_ENABLE_STATUS:
return true;
default:
return false;
}
}
static bool stusb160x_reg_precious(struct device *dev, unsigned int reg)
{
switch (reg) {
case STUSB160X_ALERT_STATUS:
case STUSB160X_CC_CONNECTION_STATUS_TRANS:
case STUSB160X_MONITORING_STATUS_TRANS:
case STUSB160X_HW_FAULT_STATUS_TRANS:
return true;
default:
return false;
}
}
static const struct regmap_config stusb1600_regmap_config = {
.reg_bits = 8,
.reg_stride = 1,
.val_bits = 8,
.max_register = STUSB1600_REG_MAX,
.writeable_reg = stusb160x_reg_writeable,
.readable_reg = stusb160x_reg_readable,
.volatile_reg = stusb160x_reg_volatile,
.precious_reg = stusb160x_reg_precious,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/regmap.h`, `linux/regulator/consumer.h`, `linux/usb/role.h`.
- Detected declarations: `struct stusb160x`, `enum stusb160x_pwr_mode`, `enum stusb160x_attached_mode`, `function stusb160x_reg_writeable`, `function stusb160x_reg_readable`, `function stusb160x_reg_volatile`, `function stusb160x_reg_precious`, `function stusb160x_get_vconn`, `function stusb160x_set_vconn`, `function stusb160x_get_pwr_opmode`.
- 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.