drivers/usb/typec/tcpm/tcpci.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/tcpm/tcpci.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/tcpm/tcpci.c- Extension
.c- Size
- 27975 bytes
- Lines
- 1051
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/delay.hlinux/gpio/consumer.hlinux/kernel.hlinux/module.hlinux/i2c.hlinux/interrupt.hlinux/property.hlinux/regmap.hlinux/usb/pd.hlinux/usb/tcpci.hlinux/usb/tcpm.hlinux/usb/typec.hlinux/regulator/consumer.h
Detected Declarations
struct tcpcistruct tcpci_chipfunction tcpci_read16function tcpci_write16function tcpci_check_std_output_capfunction tcpci_set_ccfunction tcpci_apply_rcfunction tcpci_start_togglingfunction tcpci_get_ccfunction tcpci_set_polarityfunction tcpci_set_orientationfunction tcpci_set_partner_usb_comm_capablefunction tcpci_set_vconnfunction tcpci_enable_auto_vbus_dischargefunction tcpci_set_auto_vbus_discharge_thresholdfunction tcpci_enable_frsfunction tcpci_frs_sourcing_vbusfunction tcpci_check_contaminantfunction tcpci_set_bist_datafunction tcpci_set_rolesfunction tcpci_set_pd_rxfunction tcpci_get_vbusfunction tcpci_is_vbus_vsafe0vfunction tcpci_set_vbusfunction tcpci_pd_transmitfunction tcpci_cable_comm_capablefunction tcpci_attempt_vconn_swap_discoveryfunction tcpci_initfunction tcpci_irqfunction _tcpci_irqfunction tcpci_parse_configfunction tcpci_unregister_portfunction tcpci_probefunction tcpci_removefunction tcpci_suspendfunction tcpci_resumeexport tcpci_get_tcpm_portexport tcpci_irqexport tcpci_register_portexport tcpci_unregister_port
Annotated Snippet
struct tcpci {
struct device *dev;
struct tcpm_port *port;
struct regmap *regmap;
unsigned int alert_mask;
bool controls_vbus;
struct tcpc_dev tcpc;
struct tcpci_data *data;
struct gpio_desc *orientation_gpio;
};
struct tcpci_chip {
struct tcpci *tcpci;
struct tcpci_data data;
};
struct tcpm_port *tcpci_get_tcpm_port(struct tcpci *tcpci)
{
return tcpci->port;
}
EXPORT_SYMBOL_GPL(tcpci_get_tcpm_port);
static inline struct tcpci *tcpc_to_tcpci(struct tcpc_dev *tcpc)
{
return container_of(tcpc, struct tcpci, tcpc);
}
static int tcpci_read16(struct tcpci *tcpci, unsigned int reg, u16 *val)
{
return regmap_raw_read(tcpci->regmap, reg, val, sizeof(u16));
}
static int tcpci_write16(struct tcpci *tcpci, unsigned int reg, u16 val)
{
return regmap_raw_write(tcpci->regmap, reg, &val, sizeof(u16));
}
static int tcpci_check_std_output_cap(struct regmap *regmap, u8 mask)
{
unsigned int reg;
int ret;
ret = regmap_read(regmap, TCPC_STD_OUTPUT_CAP, ®);
if (ret < 0)
return ret;
return (reg & mask) == mask;
}
static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc)
{
struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
bool vconn_pres;
enum typec_cc_polarity polarity = TYPEC_POLARITY_CC1;
unsigned int reg;
int ret;
ret = regmap_read(tcpci->regmap, TCPC_POWER_STATUS, ®);
if (ret < 0)
return ret;
vconn_pres = !!(reg & TCPC_POWER_STATUS_VCONN_PRES);
if (vconn_pres) {
ret = regmap_read(tcpci->regmap, TCPC_TCPC_CTRL, ®);
if (ret < 0)
return ret;
if (reg & TCPC_TCPC_CTRL_ORIENTATION)
polarity = TYPEC_POLARITY_CC2;
}
switch (cc) {
case TYPEC_CC_RA:
reg = (FIELD_PREP(TCPC_ROLE_CTRL_CC1, TCPC_ROLE_CTRL_CC_RA)
| FIELD_PREP(TCPC_ROLE_CTRL_CC2, TCPC_ROLE_CTRL_CC_RA));
break;
case TYPEC_CC_RD:
reg = (FIELD_PREP(TCPC_ROLE_CTRL_CC1, TCPC_ROLE_CTRL_CC_RD)
| FIELD_PREP(TCPC_ROLE_CTRL_CC2, TCPC_ROLE_CTRL_CC_RD));
break;
case TYPEC_CC_RP_DEF:
reg = (FIELD_PREP(TCPC_ROLE_CTRL_CC1, TCPC_ROLE_CTRL_CC_RP)
| FIELD_PREP(TCPC_ROLE_CTRL_CC2, TCPC_ROLE_CTRL_CC_RP)
| FIELD_PREP(TCPC_ROLE_CTRL_RP_VAL,
TCPC_ROLE_CTRL_RP_VAL_DEF));
break;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/kernel.h`, `linux/module.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/property.h`.
- Detected declarations: `struct tcpci`, `struct tcpci_chip`, `function tcpci_read16`, `function tcpci_write16`, `function tcpci_check_std_output_cap`, `function tcpci_set_cc`, `function tcpci_apply_rc`, `function tcpci_start_toggling`, `function tcpci_get_cc`, `function tcpci_set_polarity`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: integration 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.