drivers/phy/qualcomm/phy-qcom-m31-eusb2.c
Source file repositories/reference/linux-study-clean/drivers/phy/qualcomm/phy-qcom-m31-eusb2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/qualcomm/phy-qcom-m31-eusb2.c- Extension
.c- Size
- 8547 bytes
- Lines
- 327
- 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/bitfield.hlinux/clk.hlinux/delay.hlinux/err.hlinux/io.hlinux/kernel.hlinux/module.hlinux/of.hlinux/phy/phy.hlinux/platform_device.hlinux/reset.hlinux/slab.hlinux/regulator/consumer.h
Detected Declarations
struct m31_phy_tbl_entrystruct m31_eusb2_priv_datastruct m31eusb2_phyfunction m31eusb2_phy_write_readbackfunction m31eusb2_phy_write_sequencefunction m31eusb2_phy_set_modefunction m31eusb2_phy_initfunction m31eusb2_phy_exitfunction m31eusb2_phy_probe
Annotated Snippet
struct m31_phy_tbl_entry {
u32 off;
u32 mask;
u32 val;
};
struct m31_eusb2_priv_data {
const struct m31_phy_tbl_entry *setup_seq;
unsigned int setup_seq_nregs;
const struct m31_phy_tbl_entry *override_seq;
unsigned int override_seq_nregs;
const struct m31_phy_tbl_entry *reset_seq;
unsigned int reset_seq_nregs;
unsigned int fsel;
};
static const struct m31_phy_tbl_entry m31_eusb2_setup_tbl[] = {
M31_EUSB_PHY_INIT_CFG(USB_PHY_CFG0, UTMI_PHY_CMN_CTRL_OVERRIDE_EN, 1),
M31_EUSB_PHY_INIT_CFG(USB_PHY_UTMI_CTRL5, POR, 1),
M31_EUSB_PHY_INIT_CFG(USB_PHY_HS_PHY_CTRL_COMMON0, PHY_ENABLE, 1),
M31_EUSB_PHY_INIT_CFG(USB_PHY_CFG1, PLL_EN, 0),
M31_EUSB_PHY_INIT_CFG(USB_PHY_FSEL_SEL, FSEL_SEL, 1),
};
static const struct m31_phy_tbl_entry m31_eusb_phy_override_tbl[] = {
M31_EUSB_PHY_INIT_CFG(USB_PHY_XCFGI_39_32, HSTX_PE, 0),
M31_EUSB_PHY_INIT_CFG(USB_PHY_XCFGI_71_64, HSTX_SWING, 7),
M31_EUSB_PHY_INIT_CFG(USB_PHY_XCFGI_31_24, HSTX_SLEW, 0),
M31_EUSB_PHY_INIT_CFG(USB_PHY_XCFGI_7_0, PLL_LOCK_TIME, 0),
};
static const struct m31_phy_tbl_entry m31_eusb_phy_reset_tbl[] = {
M31_EUSB_PHY_INIT_CFG(USB_PHY_HS_PHY_CTRL2, USB2_SUSPEND_N_SEL, 1),
M31_EUSB_PHY_INIT_CFG(USB_PHY_HS_PHY_CTRL2, USB2_SUSPEND_N, 1),
M31_EUSB_PHY_INIT_CFG(USB_PHY_UTMI_CTRL0, SLEEPM, 1),
M31_EUSB_PHY_INIT_CFG(USB_PHY_HS_PHY_CTRL_COMMON0, SIDDQ_SEL, 1),
M31_EUSB_PHY_INIT_CFG(USB_PHY_HS_PHY_CTRL_COMMON0, SIDDQ, 0),
M31_EUSB_PHY_INIT_CFG(USB_PHY_UTMI_CTRL5, POR, 0),
M31_EUSB_PHY_INIT_CFG(USB_PHY_HS_PHY_CTRL2, USB2_SUSPEND_N_SEL, 0),
M31_EUSB_PHY_INIT_CFG(USB_PHY_CFG0, UTMI_PHY_CMN_CTRL_OVERRIDE_EN, 0),
};
static const struct regulator_bulk_data m31_eusb_phy_vregs[] = {
{ .supply = "vdd" },
{ .supply = "vdda12" },
};
#define M31_EUSB_NUM_VREGS ARRAY_SIZE(m31_eusb_phy_vregs)
struct m31eusb2_phy {
struct phy *phy;
void __iomem *base;
const struct m31_eusb2_priv_data *data;
enum phy_mode mode;
struct regulator_bulk_data *vregs;
struct clk *clk;
struct reset_control *reset;
struct phy *repeater;
};
static int m31eusb2_phy_write_readback(void __iomem *base, u32 offset,
const u32 mask, u32 val)
{
u32 write_val;
u32 tmp;
tmp = readl(base + offset);
tmp &= ~mask;
write_val = tmp | val;
writel(write_val, base + offset);
tmp = readl(base + offset);
tmp &= mask;
if (tmp != val) {
pr_err("write: %x to offset: %x FAILED\n", val, offset);
return -EINVAL;
}
return 0;
}
static int m31eusb2_phy_write_sequence(struct m31eusb2_phy *phy,
const struct m31_phy_tbl_entry *tbl,
int num)
{
int i;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/delay.h`, `linux/err.h`, `linux/io.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct m31_phy_tbl_entry`, `struct m31_eusb2_priv_data`, `struct m31eusb2_phy`, `function m31eusb2_phy_write_readback`, `function m31eusb2_phy_write_sequence`, `function m31eusb2_phy_set_mode`, `function m31eusb2_phy_init`, `function m31eusb2_phy_exit`, `function m31eusb2_phy_probe`.
- 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.