drivers/phy/mediatek/phy-mtk-pcie.c
Source file repositories/reference/linux-study-clean/drivers/phy/mediatek/phy-mtk-pcie.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/mediatek/phy-mtk-pcie.c- Extension
.c- Size
- 7249 bytes
- Lines
- 267
- 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/module.hlinux/nvmem-consumer.hlinux/of.hlinux/phy/phy.hlinux/platform_device.hlinux/slab.hphy-mtk-io.h
Detected Declarations
struct mtk_pcie_lane_efusestruct mtk_pcie_phy_datastruct mtk_pcie_phyfunction mtk_pcie_efuse_set_lanefunction mtk_pcie_phy_initfunction mtk_pcie_efuse_read_for_lanefunction mtk_pcie_read_efusefunction mtk_pcie_phy_probe
Annotated Snippet
struct mtk_pcie_lane_efuse {
u32 tx_pmos;
u32 tx_nmos;
u32 rx_data;
bool lane_efuse_supported;
};
/**
* struct mtk_pcie_phy_data - phy data for each SoC
* @num_lanes: supported lane numbers
* @sw_efuse_supported: support software to load eFuse data
*/
struct mtk_pcie_phy_data {
int num_lanes;
bool sw_efuse_supported;
};
/**
* struct mtk_pcie_phy - PCIe phy driver main structure
* @dev: pointer to device
* @phy: pointer to generic phy
* @sif_base: IO mapped register base address of system interface
* @data: pointer to SoC dependent data
* @sw_efuse_en: software eFuse enable status
* @efuse_glb_intr: internal resistor selection of TX bias current data
* @efuse: pointer to eFuse data for each lane
*/
struct mtk_pcie_phy {
struct device *dev;
struct phy *phy;
void __iomem *sif_base;
const struct mtk_pcie_phy_data *data;
bool sw_efuse_en;
u32 efuse_glb_intr;
struct mtk_pcie_lane_efuse *efuse;
};
static void mtk_pcie_efuse_set_lane(struct mtk_pcie_phy *pcie_phy,
unsigned int lane)
{
struct mtk_pcie_lane_efuse *data = &pcie_phy->efuse[lane];
void __iomem *addr;
if (!data->lane_efuse_supported)
return;
addr = pcie_phy->sif_base + PEXTP_ANA_LN0_TRX_REG +
lane * PEXTP_ANA_LANE_OFFSET;
mtk_phy_update_field(addr + PEXTP_ANA_TX_REG, EFUSE_LN_TX_PMOS_SEL,
data->tx_pmos);
mtk_phy_update_field(addr + PEXTP_ANA_TX_REG, EFUSE_LN_TX_NMOS_SEL,
data->tx_nmos);
mtk_phy_update_field(addr + PEXTP_ANA_RX_REG, EFUSE_LN_RX_SEL,
data->rx_data);
}
/**
* mtk_pcie_phy_init() - Initialize the phy
* @phy: the phy to be initialized
*
* Initialize the phy by setting the efuse data.
* The hardware settings will be reset during suspend, it should be
* reinitialized when the consumer calls phy_init() again on resume.
*/
static int mtk_pcie_phy_init(struct phy *phy)
{
struct mtk_pcie_phy *pcie_phy = phy_get_drvdata(phy);
int i;
if (!pcie_phy->sw_efuse_en)
return 0;
/* Set global data */
mtk_phy_update_field(pcie_phy->sif_base + PEXTP_ANA_GLB_00_REG,
EFUSE_GLB_INTR_SEL, pcie_phy->efuse_glb_intr);
for (i = 0; i < pcie_phy->data->num_lanes; i++)
mtk_pcie_efuse_set_lane(pcie_phy, i);
return 0;
}
static const struct phy_ops mtk_pcie_phy_ops = {
.init = mtk_pcie_phy_init,
.owner = THIS_MODULE,
};
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/module.h`, `linux/nvmem-consumer.h`, `linux/of.h`, `linux/phy/phy.h`, `linux/platform_device.h`, `linux/slab.h`, `phy-mtk-io.h`.
- Detected declarations: `struct mtk_pcie_lane_efuse`, `struct mtk_pcie_phy_data`, `struct mtk_pcie_phy`, `function mtk_pcie_efuse_set_lane`, `function mtk_pcie_phy_init`, `function mtk_pcie_efuse_read_for_lane`, `function mtk_pcie_read_efuse`, `function mtk_pcie_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.