drivers/phy/phy-snps-eusb2.c
Source file repositories/reference/linux-study-clean/drivers/phy/phy-snps-eusb2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/phy-snps-eusb2.c- Extension
.c- Size
- 18250 bytes
- Lines
- 634
- 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/iopoll.hlinux/mod_devicetable.hlinux/phy/phy.hlinux/platform_device.hlinux/regulator/consumer.hlinux/reset.h
Detected Declarations
struct snps_eusb2_phy_drvdatastruct snps_eusb2_hsphystruct snps_eusb2_ref_clkfunction snps_eusb2_hsphy_set_modefunction snps_eusb2_hsphy_write_maskfunction qcom_eusb2_default_parametersfunction exynos_eusb2_ref_clk_initfunction qcom_eusb2_ref_clk_initfunction exynos_snps_eusb2_hsphy_initfunction qcom_snps_eusb2_hsphy_initfunction snps_eusb2_hsphy_initfunction snps_eusb2_hsphy_exitfunction snps_eusb2_hsphy_probe
Annotated Snippet
struct snps_eusb2_phy_drvdata {
int (*phy_init)(struct phy *p);
const char * const *clk_names;
int num_clks;
};
struct snps_eusb2_hsphy {
struct phy *phy;
void __iomem *base;
struct clk *ref_clk;
struct clk_bulk_data *clks;
struct reset_control *phy_reset;
struct regulator_bulk_data vregs[EUSB2_NUM_VREGS];
enum phy_mode mode;
struct phy *repeater;
const struct snps_eusb2_phy_drvdata *data;
};
static int snps_eusb2_hsphy_set_mode(struct phy *p, enum phy_mode mode, int submode)
{
struct snps_eusb2_hsphy *phy = phy_get_drvdata(p);
phy->mode = mode;
return phy_set_mode_ext(phy->repeater, mode, submode);
}
static void snps_eusb2_hsphy_write_mask(void __iomem *base, u32 offset,
u32 mask, u32 val)
{
u32 reg;
reg = readl_relaxed(base + offset);
reg &= ~mask;
reg |= val & mask;
writel_relaxed(reg, base + offset);
/* Ensure above write is completed */
readl_relaxed(base + offset);
}
static void qcom_eusb2_default_parameters(struct snps_eusb2_hsphy *phy)
{
/* default parameters: tx pre-emphasis */
snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_9,
PHY_CFG_TX_PREEMP_TUNE_MASK,
FIELD_PREP(PHY_CFG_TX_PREEMP_TUNE_MASK, 0));
/* tx rise/fall time */
snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_9,
PHY_CFG_TX_RISE_TUNE_MASK,
FIELD_PREP(PHY_CFG_TX_RISE_TUNE_MASK, 0x2));
/* source impedance adjustment */
snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_9,
PHY_CFG_TX_RES_TUNE_MASK,
FIELD_PREP(PHY_CFG_TX_RES_TUNE_MASK, 0x1));
/* dc voltage level adjustement */
snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_8,
PHY_CFG_TX_HS_VREF_TUNE_MASK,
FIELD_PREP(PHY_CFG_TX_HS_VREF_TUNE_MASK, 0x3));
/* transmitter HS crossover adjustement */
snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_8,
PHY_CFG_TX_HS_XV_TUNE_MASK,
FIELD_PREP(PHY_CFG_TX_HS_XV_TUNE_MASK, 0x0));
}
struct snps_eusb2_ref_clk {
unsigned long freq;
u32 fsel_val;
u32 div_7_0_val;
u32 div_11_8_val;
};
static const struct snps_eusb2_ref_clk exynos_eusb2_ref_clk[] = {
{ 19200000, FSEL_19_2_MHZ_VAL, DIV_19_8_19_2_MHZ_VAL, EXYNOS_DIV_11_8_19_2_MHZ_VAL },
{ 20000000, FSEL_20_MHZ_VAL, DIV_19_8_20_MHZ_VAL, EXYNOS_DIV_11_8_20_MHZ_VAL },
{ 24000000, FSEL_24_MHZ_VAL, DIV_19_8_24_MHZ_VAL, EXYNOS_DIV_11_8_24_MHZ_VAL },
{ 26000000, FSEL_26_MHZ_VAL, DIV_19_8_26_MHZ_VAL, EXYNOS_DIV_11_8_26_MHZ_VAL },
{ 48000000, FSEL_48_MHZ_VAL, DIV_19_8_48_MHZ_VAL, EXYNOS_DIV_11_8_48_MHZ_VAL },
};
static int exynos_eusb2_ref_clk_init(struct snps_eusb2_hsphy *phy)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/delay.h`, `linux/iopoll.h`, `linux/mod_devicetable.h`, `linux/phy/phy.h`, `linux/platform_device.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct snps_eusb2_phy_drvdata`, `struct snps_eusb2_hsphy`, `struct snps_eusb2_ref_clk`, `function snps_eusb2_hsphy_set_mode`, `function snps_eusb2_hsphy_write_mask`, `function qcom_eusb2_default_parameters`, `function exynos_eusb2_ref_clk_init`, `function qcom_eusb2_ref_clk_init`, `function exynos_snps_eusb2_hsphy_init`, `function qcom_snps_eusb2_hsphy_init`.
- 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.