drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c- Extension
.c- Size
- 3462 bytes
- Lines
- 138
- 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.
- 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/io.hlinux/of.hlinux/of_net.hlinux/stmmac.hstmmac.hstmmac_platform.h
Detected Declarations
struct anarion_gmacfunction gmac_read_regfunction gmac_write_regfunction anarion_gmac_initfunction anarion_gmac_exitfunction anarion_config_dtfunction anarion_dwmac_probe
Annotated Snippet
struct anarion_gmac {
void __iomem *ctl_block;
uint32_t phy_intf_sel;
};
static uint32_t gmac_read_reg(struct anarion_gmac *gmac, uint8_t reg)
{
return readl(gmac->ctl_block + reg);
};
static void gmac_write_reg(struct anarion_gmac *gmac, uint8_t reg, uint32_t val)
{
writel(val, gmac->ctl_block + reg);
}
static int anarion_gmac_init(struct device *dev, void *priv)
{
uint32_t sw_config;
struct anarion_gmac *gmac = priv;
/* Reset logic, configure interface mode, then release reset. SIMPLE! */
gmac_write_reg(gmac, GMAC_RESET_CONTROL_REG, 1);
sw_config = gmac_read_reg(gmac, GMAC_SW_CONFIG_REG);
sw_config &= ~GMAC_CONFIG_INTF_SEL_MASK;
sw_config |= (gmac->phy_intf_sel & GMAC_CONFIG_INTF_SEL_MASK);
gmac_write_reg(gmac, GMAC_SW_CONFIG_REG, sw_config);
gmac_write_reg(gmac, GMAC_RESET_CONTROL_REG, 0);
return 0;
}
static void anarion_gmac_exit(struct device *dev, void *priv)
{
struct anarion_gmac *gmac = priv;
gmac_write_reg(gmac, GMAC_RESET_CONTROL_REG, 1);
}
static struct anarion_gmac *
anarion_config_dt(struct platform_device *pdev,
struct plat_stmmacenet_data *plat_dat)
{
struct anarion_gmac *gmac;
void __iomem *ctl_block;
ctl_block = devm_platform_ioremap_resource(pdev, 1);
if (IS_ERR(ctl_block)) {
dev_err(&pdev->dev, "Cannot get reset region (%pe)!\n",
ctl_block);
return ERR_CAST(ctl_block);
}
gmac = devm_kzalloc(&pdev->dev, sizeof(*gmac), GFP_KERNEL);
if (!gmac)
return ERR_PTR(-ENOMEM);
gmac->ctl_block = ctl_block;
if (phy_interface_mode_is_rgmii(plat_dat->phy_interface)) {
gmac->phy_intf_sel = GMAC_CONFIG_INTF_RGMII;
} else {
dev_err(&pdev->dev, "Unsupported phy-mode (%s)\n",
phy_modes(plat_dat->phy_interface));
return ERR_PTR(-ENOTSUPP);
}
return gmac;
}
static int anarion_dwmac_probe(struct platform_device *pdev)
{
int ret;
struct anarion_gmac *gmac;
struct plat_stmmacenet_data *plat_dat;
struct stmmac_resources stmmac_res;
ret = stmmac_get_platform_resources(pdev, &stmmac_res);
if (ret)
return ret;
plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
if (IS_ERR(plat_dat))
return PTR_ERR(plat_dat);
gmac = anarion_config_dt(pdev, plat_dat);
if (IS_ERR(gmac))
return PTR_ERR(gmac);
Annotation
- Immediate include surface: `linux/io.h`, `linux/of.h`, `linux/of_net.h`, `linux/stmmac.h`, `stmmac.h`, `stmmac_platform.h`.
- Detected declarations: `struct anarion_gmac`, `function gmac_read_reg`, `function gmac_write_reg`, `function anarion_gmac_init`, `function anarion_gmac_exit`, `function anarion_config_dt`, `function anarion_dwmac_probe`.
- 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.