drivers/net/mdio/mdio-xgene.c
Source file repositories/reference/linux-study-clean/drivers/net/mdio/mdio-xgene.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/mdio/mdio-xgene.c- Extension
.c- Size
- 10832 bytes
- Lines
- 452
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/acpi.hlinux/clk.hlinux/device.hlinux/efi.hlinux/if_vlan.hlinux/io.hlinux/mdio/mdio-xgene.hlinux/module.hlinux/of.hlinux/of_mdio.hlinux/of_net.hlinux/phy.hlinux/platform_device.hlinux/prefetch.hlinux/property.hnet/ip.h
Detected Declarations
function Copyrightfunction xgene_mdio_wr_macfunction xgene_mdio_rgmii_readfunction xgene_mdio_rgmii_writefunction xgene_menet_rd_diag_csrfunction xgene_menet_wr_diag_csrfunction xgene_enet_ecc_initfunction xgene_gmac_resetfunction xgene_mdio_resetfunction xgene_enet_rd_mdio_csrfunction xgene_enet_wr_mdio_csrfunction xgene_xfi_mdio_writefunction xgene_xfi_mdio_readfunction acpi_register_phyfunction xgene_mdio_probefunction xgene_mdio_removeexport xgene_mdio_rd_macexport xgene_mdio_wr_macexport xgene_mdio_rgmii_readexport xgene_mdio_rgmii_writeexport xgene_enet_phy_register
Annotated Snippet
if (IS_ERR(pdata->clk)) {
dev_err(dev, "Unable to retrieve clk\n");
return PTR_ERR(pdata->clk);
}
}
ret = xgene_mdio_reset(pdata);
if (ret)
return ret;
mdio_bus = mdiobus_alloc();
if (!mdio_bus) {
ret = -ENOMEM;
goto out_clk;
}
mdio_bus->name = "APM X-Gene MDIO bus";
if (mdio_id == XGENE_MDIO_RGMII) {
mdio_bus->read = xgene_mdio_rgmii_read;
mdio_bus->write = xgene_mdio_rgmii_write;
mdio_bus->priv = (void __force *)pdata;
snprintf(mdio_bus->id, MII_BUS_ID_SIZE, "%s",
"xgene-mii-rgmii");
} else {
mdio_bus->read = xgene_xfi_mdio_read;
mdio_bus->write = xgene_xfi_mdio_write;
mdio_bus->priv = (void __force *)pdata->mdio_csr_addr;
snprintf(mdio_bus->id, MII_BUS_ID_SIZE, "%s",
"xgene-mii-xfi");
}
mdio_bus->parent = dev;
platform_set_drvdata(pdev, pdata);
if (dev->of_node) {
ret = of_mdiobus_register(mdio_bus, dev->of_node);
} else {
#ifdef CONFIG_ACPI
/* Mask out all PHYs from auto probing. */
mdio_bus->phy_mask = ~0;
ret = mdiobus_register(mdio_bus);
if (ret)
goto out_mdiobus;
acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_HANDLE(dev), 1,
acpi_register_phy, NULL, mdio_bus, NULL);
#endif
}
if (ret)
goto out_mdiobus;
pdata->mdio_bus = mdio_bus;
return 0;
out_mdiobus:
mdiobus_free(mdio_bus);
out_clk:
if (dev->of_node)
clk_disable_unprepare(pdata->clk);
return ret;
}
static void xgene_mdio_remove(struct platform_device *pdev)
{
struct xgene_mdio_pdata *pdata = platform_get_drvdata(pdev);
struct mii_bus *mdio_bus = pdata->mdio_bus;
struct device *dev = &pdev->dev;
mdiobus_unregister(mdio_bus);
mdiobus_free(mdio_bus);
if (dev->of_node)
clk_disable_unprepare(pdata->clk);
}
static struct platform_driver xgene_mdio_driver = {
.driver = {
.name = "xgene-mdio",
.of_match_table = xgene_mdio_of_match,
.acpi_match_table = ACPI_PTR(xgene_mdio_acpi_match),
},
.probe = xgene_mdio_probe,
.remove = xgene_mdio_remove,
};
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/clk.h`, `linux/device.h`, `linux/efi.h`, `linux/if_vlan.h`, `linux/io.h`, `linux/mdio/mdio-xgene.h`, `linux/module.h`.
- Detected declarations: `function Copyright`, `function xgene_mdio_wr_mac`, `function xgene_mdio_rgmii_read`, `function xgene_mdio_rgmii_write`, `function xgene_menet_rd_diag_csr`, `function xgene_menet_wr_diag_csr`, `function xgene_enet_ecc_init`, `function xgene_gmac_reset`, `function xgene_mdio_reset`, `function xgene_enet_rd_mdio_csr`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.