drivers/net/mdio/mdio-pic64hpsc.c
Source file repositories/reference/linux-study-clean/drivers/net/mdio/mdio-pic64hpsc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/mdio/mdio-pic64hpsc.c- Extension
.c- Size
- 5196 bytes
- Lines
- 191
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/clk.hlinux/io.hlinux/iopoll.hlinux/kernel.hlinux/module.hlinux/of_mdio.hlinux/platform_device.h
Detected Declarations
struct pic64hpsc_mdio_devfunction pic64hpsc_mdio_wait_triggerfunction pic64hpsc_mdio_c22_readfunction pic64hpsc_mdio_c22_writefunction pic64hpsc_mdio_probe
Annotated Snippet
struct pic64hpsc_mdio_dev {
void __iomem *regs;
};
static int pic64hpsc_mdio_wait_trigger(struct mii_bus *bus)
{
struct pic64hpsc_mdio_dev *priv = bus->priv;
u32 val;
int ret;
/* The MDIO_TRIGGER bit returns 0 when a transaction has completed. */
ret = readl_poll_timeout(priv->regs + MDIO_REG_FRAME_CFG_2, val,
!(val & MDIO_TRIGGER_BIT), 50, 10000);
if (ret < 0)
dev_dbg(&bus->dev, "TRIGGER bit timeout: %x\n", val);
return ret;
}
static int pic64hpsc_mdio_c22_read(struct mii_bus *bus, int mii_id, int regnum)
{
struct pic64hpsc_mdio_dev *priv = bus->priv;
u32 val;
int ret;
ret = pic64hpsc_mdio_wait_trigger(bus);
if (ret)
return ret;
writel(MDIO_TRIGGER_BIT | FIELD_PREP(MDIO_REG_DEV_ADDR_MASK, regnum) |
FIELD_PREP(MDIO_PHY_PRT_ADDR_MASK, mii_id) |
FIELD_PREP(MDIO_OPERATION_MASK, MDIO_OPERATION_READ) |
FIELD_PREP(MDIO_START_OF_FRAME_MASK, 1),
priv->regs + MDIO_REG_FRAME_CFG_2);
ret = pic64hpsc_mdio_wait_trigger(bus);
if (ret)
return ret;
val = readl(priv->regs + MDIO_REG_FRAME_STATUS);
/* The MDIO_READOK is a 1-bit value reflecting the inverse of the MDIO
* bus value captured during the 2nd TA cycle. A PHY/Port should drive
* the MDIO bus with a logic 0 on the 2nd TA cycle, however, the
* PHY/Port could optionally drive a logic 1, to communicate a read
* failure. This feature is optional, not defined by the 802.3 standard
* and not supported in standard external PHYs.
*/
if (!(bus->phy_ignore_ta_mask & 1 << mii_id) &&
!FIELD_GET(MDIO_READOK_BIT, val)) {
dev_dbg(&bus->dev, "READOK bit cleared\n");
return -EIO;
}
return FIELD_GET(MDIO_RDATA_MASK, val);
}
static int pic64hpsc_mdio_c22_write(struct mii_bus *bus, int mii_id, int regnum,
u16 value)
{
struct pic64hpsc_mdio_dev *priv = bus->priv;
int ret;
ret = pic64hpsc_mdio_wait_trigger(bus);
if (ret < 0)
return ret;
writel(FIELD_PREP(MDIO_WDATA_MASK, value),
priv->regs + MDIO_REG_FRAME_CFG_1);
writel(MDIO_TRIGGER_BIT | FIELD_PREP(MDIO_REG_DEV_ADDR_MASK, regnum) |
FIELD_PREP(MDIO_PHY_PRT_ADDR_MASK, mii_id) |
FIELD_PREP(MDIO_OPERATION_MASK, MDIO_OPERATION_WRITE) |
FIELD_PREP(MDIO_START_OF_FRAME_MASK, 1),
priv->regs + MDIO_REG_FRAME_CFG_2);
return 0;
}
static int pic64hpsc_mdio_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct device *dev = &pdev->dev;
struct pic64hpsc_mdio_dev *priv;
struct mii_bus *bus;
unsigned long rate;
struct clk *clk;
u32 bus_freq;
u32 div;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/clk.h`, `linux/io.h`, `linux/iopoll.h`, `linux/kernel.h`, `linux/module.h`, `linux/of_mdio.h`, `linux/platform_device.h`.
- Detected declarations: `struct pic64hpsc_mdio_dev`, `function pic64hpsc_mdio_wait_trigger`, `function pic64hpsc_mdio_c22_read`, `function pic64hpsc_mdio_c22_write`, `function pic64hpsc_mdio_probe`.
- Atlas domain: Driver Families / drivers/net.
- 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.