drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c- Extension
.c- Size
- 17244 bytes
- Lines
- 650
- 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/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/pd.hlinux/usb/tcpm.hqcom_pmic_typec.hqcom_pmic_typec_pdphy.h
Detected Declarations
struct pmic_typec_pdphy_irq_datastruct pmic_typec_pdphyfunction qcom_pmic_typec_pdphy_reset_onfunction qcom_pmic_typec_pdphy_reset_offfunction qcom_pmic_typec_pdphy_sig_reset_workfunction qcom_pmic_typec_pdphy_clear_tx_control_regfunction qcom_pmic_typec_pdphy_pd_transmit_signalfunction qcom_pmic_typec_pdphy_pd_transmit_payloadfunction qcom_pmic_typec_pdphy_pd_transmitfunction qcom_pmic_typec_pdphy_pd_receivefunction qcom_pmic_typec_pdphy_isrfunction qcom_pmic_typec_pdphy_set_pd_rxfunction qcom_pmic_typec_pdphy_set_rolesfunction qcom_pmic_typec_pdphy_enablefunction qcom_pmic_typec_pdphy_disablefunction pmic_typec_pdphy_resetfunction qcom_pmic_typec_pdphy_startfunction qcom_pmic_typec_pdphy_stopfunction qcom_pmic_typec_pdphy_probe
Annotated Snippet
struct pmic_typec_pdphy_irq_data {
int virq;
int irq;
struct pmic_typec_pdphy *pmic_typec_pdphy;
};
struct pmic_typec_pdphy {
struct device *dev;
struct tcpm_port *tcpm_port;
struct regmap *regmap;
u32 base;
unsigned int nr_irqs;
struct pmic_typec_pdphy_irq_data *irq_data;
struct work_struct reset_work;
struct work_struct receive_work;
struct regulator *vdd_pdphy;
spinlock_t lock; /* Register atomicity */
};
static void qcom_pmic_typec_pdphy_reset_on(struct pmic_typec_pdphy *pmic_typec_pdphy)
{
struct device *dev = pmic_typec_pdphy->dev;
int ret;
/* Terminate TX */
ret = regmap_write(pmic_typec_pdphy->regmap,
pmic_typec_pdphy->base + USB_PDPHY_TX_CONTROL_REG, 0);
if (ret)
goto err;
ret = regmap_write(pmic_typec_pdphy->regmap,
pmic_typec_pdphy->base + USB_PDPHY_FRAME_FILTER_REG, 0);
if (ret)
goto err;
return;
err:
dev_err(dev, "pd_reset_on error\n");
}
static void qcom_pmic_typec_pdphy_reset_off(struct pmic_typec_pdphy *pmic_typec_pdphy)
{
struct device *dev = pmic_typec_pdphy->dev;
int ret;
ret = regmap_write(pmic_typec_pdphy->regmap,
pmic_typec_pdphy->base + USB_PDPHY_FRAME_FILTER_REG,
FRAME_FILTER_EN_SOP | FRAME_FILTER_EN_HARD_RESET);
if (ret)
dev_err(dev, "pd_reset_off error\n");
}
static void qcom_pmic_typec_pdphy_sig_reset_work(struct work_struct *work)
{
struct pmic_typec_pdphy *pmic_typec_pdphy = container_of(work, struct pmic_typec_pdphy,
reset_work);
unsigned long flags;
spin_lock_irqsave(&pmic_typec_pdphy->lock, flags);
qcom_pmic_typec_pdphy_reset_on(pmic_typec_pdphy);
qcom_pmic_typec_pdphy_reset_off(pmic_typec_pdphy);
spin_unlock_irqrestore(&pmic_typec_pdphy->lock, flags);
tcpm_pd_hard_reset(pmic_typec_pdphy->tcpm_port);
}
static int
qcom_pmic_typec_pdphy_clear_tx_control_reg(struct pmic_typec_pdphy *pmic_typec_pdphy)
{
struct device *dev = pmic_typec_pdphy->dev;
unsigned int val;
int ret;
/* Clear TX control register */
ret = regmap_write(pmic_typec_pdphy->regmap,
pmic_typec_pdphy->base + USB_PDPHY_TX_CONTROL_REG, 0);
if (ret)
goto done;
/* Perform readback to ensure sufficient delay for command to latch */
ret = regmap_read(pmic_typec_pdphy->regmap,
pmic_typec_pdphy->base + USB_PDPHY_TX_CONTROL_REG, &val);
done:
if (ret)
dev_err(dev, "pd_clear_tx_control_reg: clear tx flag\n");
Annotation
- Immediate include surface: `linux/err.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct pmic_typec_pdphy_irq_data`, `struct pmic_typec_pdphy`, `function qcom_pmic_typec_pdphy_reset_on`, `function qcom_pmic_typec_pdphy_reset_off`, `function qcom_pmic_typec_pdphy_sig_reset_work`, `function qcom_pmic_typec_pdphy_clear_tx_control_reg`, `function qcom_pmic_typec_pdphy_pd_transmit_signal`, `function qcom_pmic_typec_pdphy_pd_transmit_payload`, `function qcom_pmic_typec_pdphy_pd_transmit`, `function qcom_pmic_typec_pdphy_pd_receive`.
- 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.