drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
Source file repositories/reference/linux-study-clean/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c- Extension
.c- Size
- 15847 bytes
- Lines
- 566
- Domain
- Driver Families
- Bucket
- drivers/phy
- 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.
- 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/clk.hlinux/err.hlinux/io.hlinux/module.hlinux/of.hlinux/phy/phy.hlinux/platform_device.hlinux/delay.hlinux/regmap.hlinux/mfd/syscon.hlinux/bitfield.h
Detected Declarations
struct usb_phystruct phy_drvdatafunction usb_phy_write_readbackfunction wait_for_latchfunction usb_ss_write_phycregfunction usb_ss_read_phycregfunction qcom_ipq806x_usb_hs_phy_initfunction qcom_ipq806x_usb_hs_phy_exitfunction qcom_ipq806x_usb_ss_phy_initfunction qcom_ipq806x_usb_ss_phy_exitfunction qcom_ipq806x_usb_phy_probe
Annotated Snippet
struct usb_phy {
void __iomem *base;
struct device *dev;
struct clk *xo_clk;
struct clk *ref_clk;
u32 rx_eq;
u32 tx_deamp_3_5db;
u32 mpll;
};
struct phy_drvdata {
struct phy_ops ops;
u32 clk_rate;
};
/**
* usb_phy_write_readback() - Write register and read back masked value to
* confirm it is written
*
* @phy_dwc3: QCOM DWC3 phy context
* @offset: register offset.
* @mask: register bitmask specifying what should be updated
* @val: value to write.
*/
static inline void usb_phy_write_readback(struct usb_phy *phy_dwc3,
u32 offset,
const u32 mask, u32 val)
{
u32 write_val, tmp = readl(phy_dwc3->base + offset);
tmp &= ~mask; /* retain other bits */
write_val = tmp | val;
writel(write_val, phy_dwc3->base + offset);
/* Read back to see if val was written */
tmp = readl(phy_dwc3->base + offset);
tmp &= mask; /* clear other bits */
if (tmp != val)
dev_err(phy_dwc3->dev, "write: %x to QSCRATCH: %x FAILED\n", val, offset);
}
static int wait_for_latch(void __iomem *addr)
{
u32 val;
return readl_poll_timeout(addr, val, !val, LATCH_SLEEP, LATCH_TIMEOUT);
}
/**
* usb_ss_write_phycreg() - Write SSPHY register
*
* @phy_dwc3: QCOM DWC3 phy context
* @addr: SSPHY address to write.
* @val: value to write.
*/
static int usb_ss_write_phycreg(struct usb_phy *phy_dwc3,
u32 addr, u32 val)
{
int ret;
writel(addr, phy_dwc3->base + CR_PROTOCOL_DATA_IN_REG);
writel(SS_CR_CAP_ADDR_REG,
phy_dwc3->base + CR_PROTOCOL_CAP_ADDR_REG);
ret = wait_for_latch(phy_dwc3->base + CR_PROTOCOL_CAP_ADDR_REG);
if (ret)
goto err_wait;
writel(val, phy_dwc3->base + CR_PROTOCOL_DATA_IN_REG);
writel(SS_CR_CAP_DATA_REG,
phy_dwc3->base + CR_PROTOCOL_CAP_DATA_REG);
ret = wait_for_latch(phy_dwc3->base + CR_PROTOCOL_CAP_DATA_REG);
if (ret)
goto err_wait;
writel(SS_CR_WRITE_REG, phy_dwc3->base + CR_PROTOCOL_WRITE_REG);
ret = wait_for_latch(phy_dwc3->base + CR_PROTOCOL_WRITE_REG);
err_wait:
if (ret)
dev_err(phy_dwc3->dev, "timeout waiting for latch\n");
return ret;
}
/**
* usb_ss_read_phycreg() - Read SSPHY register.
Annotation
- Immediate include surface: `linux/clk.h`, `linux/err.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`, `linux/phy/phy.h`, `linux/platform_device.h`, `linux/delay.h`.
- Detected declarations: `struct usb_phy`, `struct phy_drvdata`, `function usb_phy_write_readback`, `function wait_for_latch`, `function usb_ss_write_phycreg`, `function usb_ss_read_phycreg`, `function qcom_ipq806x_usb_hs_phy_init`, `function qcom_ipq806x_usb_hs_phy_exit`, `function qcom_ipq806x_usb_ss_phy_init`, `function qcom_ipq806x_usb_ss_phy_exit`.
- Atlas domain: Driver Families / drivers/phy.
- Implementation status: source implementation candidate.
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.