drivers/net/ethernet/apm/xgene-v2/mdio.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/apm/xgene-v2/mdio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/apm/xgene-v2/mdio.c- Extension
.c- Size
- 3669 bytes
- Lines
- 153
- 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
main.h
Detected Declarations
function Copyrightfunction xge_mdio_readfunction xge_adjust_linkfunction xge_mdio_removefunction xge_mdio_config
Annotated Snippet
if (pdata->phy_speed != phydev->speed) {
pdata->phy_speed = phydev->speed;
xge_mac_set_speed(pdata);
xge_mac_enable(pdata);
phy_print_status(phydev);
}
} else {
if (pdata->phy_speed != SPEED_UNKNOWN) {
pdata->phy_speed = SPEED_UNKNOWN;
xge_mac_disable(pdata);
phy_print_status(phydev);
}
}
}
void xge_mdio_remove(struct net_device *ndev)
{
struct xge_pdata *pdata = netdev_priv(ndev);
struct mii_bus *mdio_bus = pdata->mdio_bus;
if (ndev->phydev)
phy_disconnect(ndev->phydev);
if (mdio_bus->state == MDIOBUS_REGISTERED)
mdiobus_unregister(mdio_bus);
mdiobus_free(mdio_bus);
}
int xge_mdio_config(struct net_device *ndev)
{
struct xge_pdata *pdata = netdev_priv(ndev);
struct device *dev = &pdata->pdev->dev;
struct mii_bus *mdio_bus;
struct phy_device *phydev;
int ret;
mdio_bus = mdiobus_alloc();
if (!mdio_bus)
return -ENOMEM;
mdio_bus->name = "APM X-Gene Ethernet (v2) MDIO Bus";
mdio_bus->read = xge_mdio_read;
mdio_bus->write = xge_mdio_write;
mdio_bus->priv = pdata;
mdio_bus->parent = dev;
snprintf(mdio_bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(dev));
pdata->mdio_bus = mdio_bus;
mdio_bus->phy_mask = 0x1;
ret = mdiobus_register(mdio_bus);
if (ret)
goto err;
phydev = phy_find_first(mdio_bus);
if (!phydev) {
dev_err(dev, "no PHY found\n");
ret = -ENODEV;
goto err;
}
phydev = phy_connect(ndev, phydev_name(phydev),
&xge_adjust_link,
pdata->resources.phy_mode);
if (IS_ERR(phydev)) {
netdev_err(ndev, "Could not attach to PHY\n");
ret = PTR_ERR(phydev);
goto err;
}
phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT);
phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_10baseT_Full_BIT);
phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_100baseT_Half_BIT);
phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_100baseT_Full_BIT);
phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_1000baseT_Half_BIT);
pdata->phy_speed = SPEED_UNKNOWN;
return 0;
err:
xge_mdio_remove(ndev);
return ret;
}
Annotation
- Immediate include surface: `main.h`.
- Detected declarations: `function Copyright`, `function xge_mdio_read`, `function xge_adjust_link`, `function xge_mdio_remove`, `function xge_mdio_config`.
- 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.