drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c- Extension
.c- Size
- 7575 bytes
- Lines
- 305
- 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/phy.hlinux/phy_fixed.hlinux/rtnetlink.hhbg_common.hhbg_hw.hhbg_mdio.hhbg_reg.h
Detected Declarations
function hbg_mdio_set_commandfunction hbg_mdio_get_commandfunction hbg_mdio_set_wdata_regfunction hbg_mdio_get_rdata_regfunction hbg_mdio_wait_readyfunction hbg_mdio_cmd_sendfunction hbg_mdio_read22function hbg_mdio_write22function hbg_mdio_init_hwfunction hbg_flowctrl_cfgfunction hbg_fix_np_link_failfunction hbg_phy_adjust_linkfunction hbg_phy_disconnectfunction hbg_phy_connectfunction hbg_phy_startfunction hbg_phy_stopfunction hbg_fixed_phy_uninitfunction hbg_fixed_phy_initfunction hbg_mdio_init
Annotated Snippet
if (phydev->link) {
switch (phydev->speed) {
case SPEED_10:
speed = HBG_PORT_MODE_SGMII_10M;
break;
case SPEED_100:
speed = HBG_PORT_MODE_SGMII_100M;
break;
case SPEED_1000:
speed = HBG_PORT_MODE_SGMII_1000M;
break;
default:
return;
}
priv->mac.speed = speed;
priv->mac.duplex = phydev->duplex;
priv->mac.autoneg = phydev->autoneg;
hbg_hw_adjust_link(priv, speed, phydev->duplex);
hbg_flowctrl_cfg(priv);
}
priv->mac.link_status = phydev->link;
phy_print_status(phydev);
}
}
static void hbg_phy_disconnect(void *data)
{
phy_disconnect((struct phy_device *)data);
}
static int hbg_phy_connect(struct hbg_priv *priv)
{
struct phy_device *phydev = priv->mac.phydev;
struct device *dev = &priv->pdev->dev;
int ret;
ret = phy_connect_direct(priv->netdev, phydev, hbg_phy_adjust_link,
PHY_INTERFACE_MODE_SGMII);
if (ret)
return dev_err_probe(dev, ret, "failed to connect phy\n");
ret = devm_add_action_or_reset(dev, hbg_phy_disconnect, phydev);
if (ret)
return ret;
phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_1000baseT_Half_BIT);
phy_support_asym_pause(phydev);
phy_attached_info(phydev);
return 0;
}
void hbg_phy_start(struct hbg_priv *priv)
{
phy_start(priv->mac.phydev);
}
void hbg_phy_stop(struct hbg_priv *priv)
{
phy_stop(priv->mac.phydev);
}
static void hbg_fixed_phy_uninit(void *data)
{
fixed_phy_unregister((struct phy_device *)data);
}
static int hbg_fixed_phy_init(struct hbg_priv *priv)
{
struct fixed_phy_status hbg_fixed_phy_status = {
.link = 1,
.speed = SPEED_1000,
.duplex = DUPLEX_FULL,
.pause = 1,
.asym_pause = 1,
};
struct device *dev = &priv->pdev->dev;
struct phy_device *phydev;
int ret;
phydev = fixed_phy_register(&hbg_fixed_phy_status, NULL);
if (IS_ERR(phydev)) {
dev_err_probe(dev, PTR_ERR(phydev),
"failed to register fixed PHY device\n");
return PTR_ERR(phydev);
}
ret = devm_add_action_or_reset(dev, hbg_fixed_phy_uninit, phydev);
Annotation
- Immediate include surface: `linux/phy.h`, `linux/phy_fixed.h`, `linux/rtnetlink.h`, `hbg_common.h`, `hbg_hw.h`, `hbg_mdio.h`, `hbg_reg.h`.
- Detected declarations: `function hbg_mdio_set_command`, `function hbg_mdio_get_command`, `function hbg_mdio_set_wdata_reg`, `function hbg_mdio_get_rdata_reg`, `function hbg_mdio_wait_ready`, `function hbg_mdio_cmd_send`, `function hbg_mdio_read22`, `function hbg_mdio_write22`, `function hbg_mdio_init_hw`, `function hbg_flowctrl_cfg`.
- 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.