drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c- Extension
.c- Size
- 19297 bytes
- Lines
- 686
- 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/clk.hlinux/kernel.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/of_net.hlinux/phy.hlinux/platform_device.hlinux/pm_wakeirq.hlinux/regmap.hlinux/slab.hlinux/stmmac.hstmmac_platform.h
Detected Declarations
struct stm32_dwmacstruct stm32_opsfunction stm32_dwmac_clk_enablefunction stm32_dwmac_initfunction stm32mp1_select_ethck_externalfunction stm32mp1_validate_ethck_ratefunction stm32mp1_configure_pmcrfunction stm32mp2_configure_syscfgfunction stm32mp1_set_modefunction stm32mcu_set_modefunction stm32_dwmac_clk_disablefunction stm32_dwmac_parse_datafunction stm32mp1_parse_datafunction stm32_dwmac_suspendfunction stm32_dwmac_resumefunction stm32_dwmac_probefunction stm32_dwmac_removefunction stm32mp1_suspendfunction stm32mp1_resume
Annotated Snippet
struct stm32_dwmac {
struct clk *clk_tx;
struct clk *clk_rx;
struct clk *clk_eth_ck;
struct clk *clk_ethstp;
struct clk *syscfg_clk;
int ext_phyclk;
int enable_eth_ck;
int eth_clk_sel_reg;
int eth_ref_clk_sel_reg;
int irq_pwr_wakeup;
u32 mode_reg; /* MAC glue-logic mode register */
u32 mode_mask;
struct regmap *regmap;
u32 speed;
const struct stm32_ops *ops;
struct device *dev;
};
struct stm32_ops {
int (*set_mode)(struct plat_stmmacenet_data *plat_dat);
int (*suspend)(struct stm32_dwmac *dwmac);
void (*resume)(struct stm32_dwmac *dwmac);
int (*parse_data)(struct stm32_dwmac *dwmac,
struct device *dev);
bool clk_rx_enable_in_suspend;
bool is_mp13, is_mp2;
u32 syscfg_clr_off;
};
static int stm32_dwmac_clk_enable(struct stm32_dwmac *dwmac)
{
int ret;
ret = clk_prepare_enable(dwmac->clk_tx);
if (ret)
goto err_clk_tx;
ret = clk_prepare_enable(dwmac->clk_rx);
if (ret)
goto err_clk_rx;
ret = clk_prepare_enable(dwmac->syscfg_clk);
if (ret)
goto err_syscfg_clk;
if (dwmac->enable_eth_ck) {
ret = clk_prepare_enable(dwmac->clk_eth_ck);
if (ret)
goto err_clk_eth_ck;
}
return ret;
err_clk_eth_ck:
clk_disable_unprepare(dwmac->syscfg_clk);
err_syscfg_clk:
clk_disable_unprepare(dwmac->clk_rx);
err_clk_rx:
clk_disable_unprepare(dwmac->clk_tx);
err_clk_tx:
return ret;
}
static int stm32_dwmac_init(struct plat_stmmacenet_data *plat_dat)
{
struct stm32_dwmac *dwmac = plat_dat->bsp_priv;
int ret;
if (dwmac->ops->set_mode) {
ret = dwmac->ops->set_mode(plat_dat);
if (ret)
return ret;
}
return stm32_dwmac_clk_enable(dwmac);
}
static int stm32mp1_select_ethck_external(struct plat_stmmacenet_data *plat_dat)
{
struct stm32_dwmac *dwmac = plat_dat->bsp_priv;
switch (plat_dat->phy_interface) {
case PHY_INTERFACE_MODE_MII:
dwmac->enable_eth_ck = dwmac->ext_phyclk;
return 0;
case PHY_INTERFACE_MODE_GMII:
dwmac->enable_eth_ck = dwmac->eth_clk_sel_reg ||
dwmac->ext_phyclk;
return 0;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/kernel.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/of.h`, `linux/of_net.h`, `linux/phy.h`, `linux/platform_device.h`.
- Detected declarations: `struct stm32_dwmac`, `struct stm32_ops`, `function stm32_dwmac_clk_enable`, `function stm32_dwmac_init`, `function stm32mp1_select_ethck_external`, `function stm32mp1_validate_ethck_rate`, `function stm32mp1_configure_pmcr`, `function stm32mp2_configure_syscfg`, `function stm32mp1_set_mode`, `function stm32mcu_set_mode`.
- 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.