drivers/net/mdio/mdio-moxart.c
Source file repositories/reference/linux-study-clean/drivers/net/mdio/mdio-moxart.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/mdio/mdio-moxart.c- Extension
.c- Size
- 4241 bytes
- Lines
- 186
- 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/mutex.hlinux/of_address.hlinux/of_mdio.hlinux/phy.hlinux/platform_device.h
Detected Declarations
struct moxart_mdio_datafunction moxart_mdio_readfunction moxart_mdio_writefunction moxart_mdio_resetfunction moxart_mdio_probefunction moxart_mdio_remove
Annotated Snippet
struct moxart_mdio_data {
void __iomem *base;
};
static int moxart_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
{
struct moxart_mdio_data *data = bus->priv;
u32 ctrl = 0;
unsigned int count = 5;
dev_dbg(&bus->dev, "%s\n", __func__);
ctrl |= MIIRD | ((mii_id << 16) & PHYAD_MASK) |
((regnum << 21) & REGAD_MASK);
writel(ctrl, data->base + REG_PHY_CTRL);
do {
ctrl = readl(data->base + REG_PHY_CTRL);
if (!(ctrl & MIIRD))
return ctrl & MIIRDATA_MASK;
mdelay(10);
count--;
} while (count > 0);
dev_dbg(&bus->dev, "%s timed out\n", __func__);
return -ETIMEDOUT;
}
static int moxart_mdio_write(struct mii_bus *bus, int mii_id,
int regnum, u16 value)
{
struct moxart_mdio_data *data = bus->priv;
u32 ctrl = 0;
unsigned int count = 5;
dev_dbg(&bus->dev, "%s\n", __func__);
ctrl |= MIIWR | ((mii_id << 16) & PHYAD_MASK) |
((regnum << 21) & REGAD_MASK);
value &= MIIWDATA_MASK;
writel(value, data->base + REG_PHY_WRITE_DATA);
writel(ctrl, data->base + REG_PHY_CTRL);
do {
ctrl = readl(data->base + REG_PHY_CTRL);
if (!(ctrl & MIIWR))
return 0;
mdelay(10);
count--;
} while (count > 0);
dev_dbg(&bus->dev, "%s timed out\n", __func__);
return -ETIMEDOUT;
}
static int moxart_mdio_reset(struct mii_bus *bus)
{
int data, i;
for (i = 0; i < PHY_MAX_ADDR; i++) {
data = moxart_mdio_read(bus, i, MII_BMCR);
if (data < 0)
continue;
data |= BMCR_RESET;
if (moxart_mdio_write(bus, i, MII_BMCR, data) < 0)
continue;
}
return 0;
}
static int moxart_mdio_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct mii_bus *bus;
struct moxart_mdio_data *data;
int ret, i;
bus = mdiobus_alloc_size(sizeof(*data));
if (!bus)
Annotation
- Immediate include surface: `linux/delay.h`, `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`, `linux/of_address.h`, `linux/of_mdio.h`, `linux/phy.h`, `linux/platform_device.h`.
- Detected declarations: `struct moxart_mdio_data`, `function moxart_mdio_read`, `function moxart_mdio_write`, `function moxart_mdio_reset`, `function moxart_mdio_probe`, `function moxart_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.