drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c- Extension
.c- Size
- 6995 bytes
- Lines
- 268
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/sched.hlinux/types.hlinux/interrupt.hlinux/string.hlinux/init.hlinux/errno.hlinux/delay.hlinux/pm.hlinux/clk.hlinux/platform_device.hnet/arp.hlinux/mii.hlinux/ethtool.hlinux/netdevice.hlinux/inetdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/in.hlinux/ip.hlinux/ipv6.hlinux/phy.hbcmgenet.h
Detected Declarations
function GENETfunction bcmgenet_set_wolfunction bcmgenet_poll_wol_statusfunction bcmgenet_set_mpd_passwordfunction bcmgenet_wol_power_down_cfgfunction bcmgenet_wol_power_up_cfg
Annotated Snippet
if (priv->wol_irq_disabled) {
enable_irq_wake(priv->wol_irq);
enable_irq_wake(priv->irq0);
}
priv->wol_irq_disabled = false;
} else {
device_set_wakeup_enable(kdev, 0);
/* Avoid unbalanced disable_irq_wake calls */
if (!priv->wol_irq_disabled) {
disable_irq_wake(priv->wol_irq);
disable_irq_wake(priv->irq0);
}
priv->wol_irq_disabled = true;
}
priv->wolopts = wol->wolopts;
return 0;
}
static int bcmgenet_poll_wol_status(struct bcmgenet_priv *priv)
{
struct net_device *dev = priv->dev;
int retries = 0;
while (!(bcmgenet_rbuf_readl(priv, RBUF_STATUS)
& RBUF_STATUS_WOL)) {
retries++;
if (retries > 50) {
netdev_crit(dev, "polling wol mode timeout\n");
return -ETIMEDOUT;
}
mdelay(1);
}
return retries;
}
static void bcmgenet_set_mpd_password(struct bcmgenet_priv *priv)
{
bcmgenet_umac_writel(priv, get_unaligned_be16(&priv->sopass[0]),
UMAC_MPD_PW_MS);
bcmgenet_umac_writel(priv, get_unaligned_be32(&priv->sopass[2]),
UMAC_MPD_PW_LS);
}
int bcmgenet_wol_power_down_cfg(struct bcmgenet_priv *priv,
enum bcmgenet_power_mode mode)
{
struct net_device *dev = priv->dev;
u32 reg, hfb_ctrl_reg;
int retries = 0;
if (mode != GENET_POWER_WOL_MAGIC) {
netif_err(priv, wol, dev, "unsupported mode: %d\n", mode);
return -EINVAL;
}
if (priv->wolopts & (WAKE_MAGIC | WAKE_MAGICSECURE)) {
reg = bcmgenet_umac_readl(priv, UMAC_MPD_CTRL);
reg |= MPD_EN;
if (priv->wolopts & WAKE_MAGICSECURE) {
bcmgenet_set_mpd_password(priv);
reg |= MPD_PW_EN;
}
bcmgenet_umac_writel(priv, reg, UMAC_MPD_CTRL);
}
hfb_ctrl_reg = bcmgenet_hfb_reg_readl(priv, HFB_CTRL);
reg = hfb_ctrl_reg | RBUF_ACPI_EN;
bcmgenet_hfb_reg_writel(priv, reg, HFB_CTRL);
/* Do not leave UniMAC in MPD mode only */
retries = bcmgenet_poll_wol_status(priv);
if (retries < 0) {
reg = bcmgenet_umac_readl(priv, UMAC_MPD_CTRL);
reg &= ~(MPD_EN | MPD_PW_EN);
bcmgenet_umac_writel(priv, reg, UMAC_MPD_CTRL);
bcmgenet_hfb_reg_writel(priv, hfb_ctrl_reg, HFB_CTRL);
return retries;
}
netif_dbg(priv, wol, dev, "MPD WOL-ready status set after %d msec\n",
retries);
/* Disable phy status updates while suspending */
mutex_lock(&dev->phydev->lock);
dev->phydev->state = PHY_READY;
mutex_unlock(&dev->phydev->lock);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/sched.h`, `linux/types.h`, `linux/interrupt.h`, `linux/string.h`, `linux/init.h`, `linux/errno.h`.
- Detected declarations: `function GENET`, `function bcmgenet_set_wol`, `function bcmgenet_poll_wol_status`, `function bcmgenet_set_mpd_password`, `function bcmgenet_wol_power_down_cfg`, `function bcmgenet_wol_power_up_cfg`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.