drivers/net/pcs/pcs-xpcs-plat.c
Source file repositories/reference/linux-study-clean/drivers/net/pcs/pcs-xpcs-plat.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/pcs/pcs-xpcs-plat.c- Extension
.c- Size
- 11088 bytes
- Lines
- 458
- Domain
- Driver Families
- Bucket
- drivers/net
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/atomic.hlinux/bitfield.hlinux/clk.hlinux/device.hlinux/kernel.hlinux/mdio.hlinux/module.hlinux/pcs/pcs-xpcs.hlinux/phy.hlinux/platform_device.hlinux/pm_runtime.hlinux/property.hlinux/sizes.hpcs-xpcs.h
Detected Declarations
struct dw_xpcs_platfunction xpcs_mmio_addr_formatfunction xpcs_mmio_addr_pagefunction xpcs_mmio_addr_offsetfunction xpcs_mmio_read_reg_indirectfunction xpcs_mmio_write_reg_indirectfunction xpcs_mmio_read_reg_directfunction xpcs_mmio_write_reg_directfunction xpcs_mmio_read_c22function xpcs_mmio_write_c22function xpcs_mmio_read_c45function xpcs_mmio_write_c45function xpcs_plat_init_resfunction xpcs_plat_init_clkfunction xpcs_plat_init_busfunction xpcs_plat_init_devfunction xpcs_plat_probefunction xpcs_plat_pm_runtime_suspendfunction xpcs_plat_pm_runtime_resume
Annotated Snippet
struct dw_xpcs_plat {
struct platform_device *pdev;
struct mii_bus *bus;
bool reg_indir;
int reg_width;
void __iomem *reg_base;
struct clk *cclk;
};
static ptrdiff_t xpcs_mmio_addr_format(int dev, int reg)
{
return FIELD_PREP(0x1f0000, dev) | FIELD_PREP(0xffff, reg);
}
static u16 xpcs_mmio_addr_page(ptrdiff_t csr)
{
return FIELD_GET(0x1fff00, csr);
}
static ptrdiff_t xpcs_mmio_addr_offset(ptrdiff_t csr)
{
return FIELD_GET(0xff, csr);
}
static int xpcs_mmio_read_reg_indirect(struct dw_xpcs_plat *pxpcs,
int dev, int reg)
{
ptrdiff_t csr, ofs;
u16 page;
int ret;
csr = xpcs_mmio_addr_format(dev, reg);
page = xpcs_mmio_addr_page(csr);
ofs = xpcs_mmio_addr_offset(csr);
ret = pm_runtime_resume_and_get(&pxpcs->pdev->dev);
if (ret)
return ret;
switch (pxpcs->reg_width) {
case 4:
writel(page, pxpcs->reg_base + (DW_VR_CSR_VIEWPORT << 2));
ret = readl(pxpcs->reg_base + (ofs << 2)) & 0xffff;
break;
default:
writew(page, pxpcs->reg_base + (DW_VR_CSR_VIEWPORT << 1));
ret = readw(pxpcs->reg_base + (ofs << 1));
break;
}
pm_runtime_put(&pxpcs->pdev->dev);
return ret;
}
static int xpcs_mmio_write_reg_indirect(struct dw_xpcs_plat *pxpcs,
int dev, int reg, u16 val)
{
ptrdiff_t csr, ofs;
u16 page;
int ret;
csr = xpcs_mmio_addr_format(dev, reg);
page = xpcs_mmio_addr_page(csr);
ofs = xpcs_mmio_addr_offset(csr);
ret = pm_runtime_resume_and_get(&pxpcs->pdev->dev);
if (ret)
return ret;
switch (pxpcs->reg_width) {
case 4:
writel(page, pxpcs->reg_base + (DW_VR_CSR_VIEWPORT << 2));
writel(val, pxpcs->reg_base + (ofs << 2));
break;
default:
writew(page, pxpcs->reg_base + (DW_VR_CSR_VIEWPORT << 1));
writew(val, pxpcs->reg_base + (ofs << 1));
break;
}
pm_runtime_put(&pxpcs->pdev->dev);
return 0;
}
static int xpcs_mmio_read_reg_direct(struct dw_xpcs_plat *pxpcs,
int dev, int reg)
{
ptrdiff_t csr;
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/bitfield.h`, `linux/clk.h`, `linux/device.h`, `linux/kernel.h`, `linux/mdio.h`, `linux/module.h`, `linux/pcs/pcs-xpcs.h`.
- Detected declarations: `struct dw_xpcs_plat`, `function xpcs_mmio_addr_format`, `function xpcs_mmio_addr_page`, `function xpcs_mmio_addr_offset`, `function xpcs_mmio_read_reg_indirect`, `function xpcs_mmio_write_reg_indirect`, `function xpcs_mmio_read_reg_direct`, `function xpcs_mmio_write_reg_direct`, `function xpcs_mmio_read_c22`, `function xpcs_mmio_write_c22`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.