drivers/phy/phy-airoha-pcie.c
Source file repositories/reference/linux-study-clean/drivers/phy/phy-airoha-pcie.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/phy-airoha-pcie.c- Extension
.c- Size
- 50240 bytes
- Lines
- 1291
- 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/delay.hlinux/io.hlinux/module.hlinux/of.hlinux/phy/phy.hlinux/platform_device.hlinux/slab.hphy-airoha-pcie-regs.h
Detected Declarations
struct airoha_pcie_phyenum airoha_pcie_port_genfunction airoha_phy_clear_bitsfunction airoha_phy_set_bitsfunction airoha_phy_update_bitsfunction airoha_phy_init_lane0_rx_fw_pre_calibfunction airoha_phy_init_lane1_rx_fw_pre_calibfunction airoha_pcie_phy_init_defaultfunction airoha_pcie_phy_init_clk_outfunction airoha_pcie_phy_init_csr_2lfunction airoha_pcie_phy_init_rxfunction airoha_pcie_phy_init_jcpllfunction airoha_pcie_phy_txpllfunction airoha_pcie_phy_init_ssc_jcpllfunction airoha_pcie_phy_set_rxlan0_signal_detectfunction airoha_pcie_phy_set_rxlan1_signal_detectfunction airoha_pcie_phy_set_rxflowfunction airoha_pcie_phy_set_prfunction airoha_pcie_phy_set_txflowfunction airoha_pcie_phy_set_rx_modefunction airoha_pcie_phy_load_kflowfunction airoha_pcie_phy_initfunction airoha_pcie_phy_exitfunction airoha_pcie_phy_probe
Annotated Snippet
struct airoha_pcie_phy {
struct device *dev;
struct phy *phy;
void __iomem *csr_2l;
void __iomem *pma0;
void __iomem *pma1;
void __iomem *p0_xr_dtime;
void __iomem *p1_xr_dtime;
void __iomem *rx_aeq;
};
static void airoha_phy_clear_bits(void __iomem *reg, u32 mask)
{
u32 val = readl(reg) & ~mask;
writel(val, reg);
}
static void airoha_phy_set_bits(void __iomem *reg, u32 mask)
{
u32 val = readl(reg) | mask;
writel(val, reg);
}
static void airoha_phy_update_bits(void __iomem *reg, u32 mask, u32 val)
{
u32 tmp = readl(reg);
tmp &= ~mask;
tmp |= val & mask;
writel(tmp, reg);
}
#define airoha_phy_update_field(reg, mask, val) \
do { \
BUILD_BUG_ON_MSG(!__builtin_constant_p((mask)), \
"mask is not constant"); \
airoha_phy_update_bits((reg), (mask), \
FIELD_PREP((mask), (val))); \
} while (0)
#define airoha_phy_csr_2l_clear_bits(pcie_phy, reg, mask) \
airoha_phy_clear_bits((pcie_phy)->csr_2l + (reg), (mask))
#define airoha_phy_csr_2l_set_bits(pcie_phy, reg, mask) \
airoha_phy_set_bits((pcie_phy)->csr_2l + (reg), (mask))
#define airoha_phy_csr_2l_update_field(pcie_phy, reg, mask, val) \
airoha_phy_update_field((pcie_phy)->csr_2l + (reg), (mask), (val))
#define airoha_phy_pma0_clear_bits(pcie_phy, reg, mask) \
airoha_phy_clear_bits((pcie_phy)->pma0 + (reg), (mask))
#define airoha_phy_pma1_clear_bits(pcie_phy, reg, mask) \
airoha_phy_clear_bits((pcie_phy)->pma1 + (reg), (mask))
#define airoha_phy_pma0_set_bits(pcie_phy, reg, mask) \
airoha_phy_set_bits((pcie_phy)->pma0 + (reg), (mask))
#define airoha_phy_pma1_set_bits(pcie_phy, reg, mask) \
airoha_phy_set_bits((pcie_phy)->pma1 + (reg), (mask))
#define airoha_phy_pma0_update_field(pcie_phy, reg, mask, val) \
airoha_phy_update_field((pcie_phy)->pma0 + (reg), (mask), (val))
#define airoha_phy_pma1_update_field(pcie_phy, reg, mask, val) \
airoha_phy_update_field((pcie_phy)->pma1 + (reg), (mask), (val))
static void
airoha_phy_init_lane0_rx_fw_pre_calib(struct airoha_pcie_phy *pcie_phy,
enum airoha_pcie_port_gen gen)
{
u32 fl_out_target = gen == PCIE_PORT_GEN3 ? 41600 : 41941;
u32 lock_cyclecnt = gen == PCIE_PORT_GEN3 ? 26000 : 32767;
u32 pr_idac, val, cdr_pr_idac_tmp = 0;
int i;
airoha_phy_pma0_set_bits(pcie_phy,
REG_PCIE_PMA_SS_LCPLL_PWCTL_SETTING_1,
PCIE_LCPLL_MAN_PWDB);
airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET2,
PCIE_LOCK_TARGET_BEG,
fl_out_target - 100);
airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET2,
PCIE_LOCK_TARGET_END,
fl_out_target + 100);
airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET1,
PCIE_PLL_FT_LOCK_CYCLECNT, lock_cyclecnt);
airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET4,
PCIE_LOCK_LOCKTH, 0x3);
airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET3,
PCIE_UNLOCK_TARGET_BEG,
fl_out_target - 100);
airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET3,
PCIE_UNLOCK_TARGET_END,
fl_out_target + 100);
airoha_phy_pma0_update_field(pcie_phy, REG_PCIE_PMA_SS_RX_FREQ_DET1,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/delay.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`, `linux/phy/phy.h`, `linux/platform_device.h`, `linux/slab.h`.
- Detected declarations: `struct airoha_pcie_phy`, `enum airoha_pcie_port_gen`, `function airoha_phy_clear_bits`, `function airoha_phy_set_bits`, `function airoha_phy_update_bits`, `function airoha_phy_init_lane0_rx_fw_pre_calib`, `function airoha_phy_init_lane1_rx_fw_pre_calib`, `function airoha_pcie_phy_init_default`, `function airoha_pcie_phy_init_clk_out`, `function airoha_pcie_phy_init_csr_2l`.
- 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.