drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c- Extension
.c- Size
- 21327 bytes
- Lines
- 810
- 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/delay.hlinux/err.hlinux/interrupt.hlinux/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/regmap.hlinux/regulator/consumer.hlinux/slab.hlinux/string_choices.hlinux/usb/tcpm.hlinux/usb/typec_mux.hlinux/workqueue.hqcom_pmic_typec.hqcom_pmic_typec_port.h
Detected Declarations
struct pmic_typec_port_irq_datastruct pmic_typec_portfunction qcom_pmic_typec_port_cc_debouncefunction pmic_typec_port_isrfunction qcom_pmic_typec_port_vbus_detectfunction qcom_pmic_typec_port_vbus_togglefunction qcom_pmic_typec_port_get_vbusfunction qcom_pmic_typec_port_set_vbusfunction qcom_pmic_typec_port_get_ccfunction qcom_pmic_set_cc_debouncefunction qcom_pmic_typec_port_set_ccfunction qcom_pmic_typec_port_set_polarityfunction qcom_pmic_typec_port_set_vconnfunction qcom_pmic_typec_port_start_togglingfunction qcom_pmic_typec_port_startfunction qcom_pmic_typec_port_stopfunction qcom_pmic_typec_port_probe
Annotated Snippet
struct pmic_typec_port_irq_data {
int virq;
int irq;
struct pmic_typec_port *pmic_typec_port;
};
struct pmic_typec_port {
struct device *dev;
struct tcpm_port *tcpm_port;
struct regmap *regmap;
u32 base;
unsigned int nr_irqs;
struct pmic_typec_port_irq_data *irq_data;
struct regulator *vdd_vbus;
bool vbus_enabled;
struct mutex vbus_lock; /* VBUS state serialization */
int cc;
bool debouncing_cc;
struct delayed_work cc_debounce_dwork;
spinlock_t lock; /* Register atomicity */
};
static const char * const typec_cc_status_name[] = {
[TYPEC_CC_OPEN] = "Open",
[TYPEC_CC_RA] = "Ra",
[TYPEC_CC_RD] = "Rd",
[TYPEC_CC_RP_DEF] = "Rp-def",
[TYPEC_CC_RP_1_5] = "Rp-1.5",
[TYPEC_CC_RP_3_0] = "Rp-3.0",
};
static const char *rp_unknown = "unknown";
static const char *cc_to_name(enum typec_cc_status cc)
{
if (cc > TYPEC_CC_RP_3_0)
return rp_unknown;
return typec_cc_status_name[cc];
}
static const char * const rp_sel_name[] = {
[TYPEC_SRC_RP_SEL_80UA] = "Rp-def-80uA",
[TYPEC_SRC_RP_SEL_180UA] = "Rp-1.5-180uA",
[TYPEC_SRC_RP_SEL_330UA] = "Rp-3.0-330uA",
};
static const char *rp_sel_to_name(int rp_sel)
{
if (rp_sel > TYPEC_SRC_RP_SEL_330UA)
return rp_unknown;
return rp_sel_name[rp_sel];
}
#define misc_to_cc(msic) !!(misc & CC_ORIENTATION) ? "cc1" : "cc2"
#define misc_to_vconn(msic) !!(misc & CC_ORIENTATION) ? "cc2" : "cc1"
static void qcom_pmic_typec_port_cc_debounce(struct work_struct *work)
{
struct pmic_typec_port *pmic_typec_port =
container_of(work, struct pmic_typec_port, cc_debounce_dwork.work);
unsigned long flags;
spin_lock_irqsave(&pmic_typec_port->lock, flags);
pmic_typec_port->debouncing_cc = false;
spin_unlock_irqrestore(&pmic_typec_port->lock, flags);
dev_dbg(pmic_typec_port->dev, "Debounce cc complete\n");
}
static irqreturn_t pmic_typec_port_isr(int irq, void *dev_id)
{
struct pmic_typec_port_irq_data *irq_data = dev_id;
struct pmic_typec_port *pmic_typec_port = irq_data->pmic_typec_port;
u32 misc_stat;
bool vbus_change = false;
bool cc_change = false;
unsigned long flags;
int ret;
spin_lock_irqsave(&pmic_typec_port->lock, flags);
ret = regmap_read(pmic_typec_port->regmap,
pmic_typec_port->base + TYPEC_MISC_STATUS_REG,
&misc_stat);
if (ret)
Annotation
- Immediate include surface: `linux/delay.h`, `linux/err.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct pmic_typec_port_irq_data`, `struct pmic_typec_port`, `function qcom_pmic_typec_port_cc_debounce`, `function pmic_typec_port_isr`, `function qcom_pmic_typec_port_vbus_detect`, `function qcom_pmic_typec_port_vbus_toggle`, `function qcom_pmic_typec_port_get_vbus`, `function qcom_pmic_typec_port_set_vbus`, `function qcom_pmic_typec_port_get_cc`, `function qcom_pmic_set_cc_debounce`.
- 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.