drivers/net/mdio/mdio-ipq8064.c
Source file repositories/reference/linux-study-clean/drivers/net/mdio/mdio-ipq8064.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/mdio/mdio-ipq8064.c- Extension
.c- Size
- 4559 bytes
- Lines
- 178
- 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/delay.hlinux/kernel.hlinux/module.hlinux/of_mdio.hlinux/of_address.hlinux/platform_device.hlinux/regmap.h
Detected Declarations
struct ipq8064_mdiofunction ipq8064_mdio_wait_busyfunction ipq8064_mdio_readfunction ipq8064_mdio_writefunction ipq8064_mdio_probefunction ipq8064_mdio_remove
Annotated Snippet
struct ipq8064_mdio {
struct regmap *base; /* NSS_GMAC0_BASE */
};
static int
ipq8064_mdio_wait_busy(struct ipq8064_mdio *priv)
{
u32 busy;
return regmap_read_poll_timeout(priv->base, MII_ADDR_REG_ADDR, busy,
!(busy & MII_BUSY), MII_MDIO_DELAY_USEC,
MII_MDIO_RETRY_MSEC * USEC_PER_MSEC);
}
static int
ipq8064_mdio_read(struct mii_bus *bus, int phy_addr, int reg_offset)
{
u32 miiaddr = MII_BUSY | MII_CLKRANGE_250_300M;
struct ipq8064_mdio *priv = bus->priv;
u32 ret_val;
int err;
miiaddr |= ((phy_addr << MII_ADDR_SHIFT) & MII_ADDR_MASK) |
((reg_offset << MII_REG_SHIFT) & MII_REG_MASK);
regmap_write(priv->base, MII_ADDR_REG_ADDR, miiaddr);
usleep_range(10, 13);
err = ipq8064_mdio_wait_busy(priv);
if (err)
return err;
regmap_read(priv->base, MII_DATA_REG_ADDR, &ret_val);
return (int)ret_val;
}
static int
ipq8064_mdio_write(struct mii_bus *bus, int phy_addr, int reg_offset, u16 data)
{
u32 miiaddr = MII_WRITE | MII_BUSY | MII_CLKRANGE_250_300M;
struct ipq8064_mdio *priv = bus->priv;
regmap_write(priv->base, MII_DATA_REG_ADDR, data);
miiaddr |= ((phy_addr << MII_ADDR_SHIFT) & MII_ADDR_MASK) |
((reg_offset << MII_REG_SHIFT) & MII_REG_MASK);
regmap_write(priv->base, MII_ADDR_REG_ADDR, miiaddr);
/* For the specific reg 31 extra time is needed or the next
* read will produce garbage data.
*/
if (reg_offset == 31)
usleep_range(30, 43);
else
usleep_range(10, 13);
return ipq8064_mdio_wait_busy(priv);
}
static const struct regmap_config ipq8064_mdio_regmap_config = {
.reg_bits = 32,
.reg_stride = 4,
.val_bits = 32,
.can_multi_write = false,
/* the mdio lock is used by any user of this mdio driver */
.disable_locking = true,
.cache_type = REGCACHE_NONE,
};
static int
ipq8064_mdio_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct ipq8064_mdio *priv;
struct resource res;
struct mii_bus *bus;
void __iomem *base;
int ret;
if (of_address_to_resource(np, 0, &res))
return -ENOMEM;
base = devm_ioremap(&pdev->dev, res.start, resource_size(&res));
if (!base)
return -ENOMEM;
bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv));
if (!bus)
Annotation
- Immediate include surface: `linux/delay.h`, `linux/kernel.h`, `linux/module.h`, `linux/of_mdio.h`, `linux/of_address.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct ipq8064_mdio`, `function ipq8064_mdio_wait_busy`, `function ipq8064_mdio_read`, `function ipq8064_mdio_write`, `function ipq8064_mdio_probe`, `function ipq8064_mdio_remove`.
- 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.