drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c- Extension
.c- Size
- 20906 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/bitfield.hlinux/io.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/of_net.hlinux/platform_device.hlinux/regmap.hlinux/stmmac.hstmmac.hstmmac_platform.h
Detected Declarations
struct mac_delay_structstruct mediatek_dwmac_plat_datastruct mediatek_dwmac_variantfunction mt2712_set_interfacefunction mt2712_delay_ps2stagefunction mt2712_delay_stage2psfunction mt2712_set_delayfunction mt8195_set_interfacefunction mt8195_delay_ps2stagefunction mt8195_delay_stage2psfunction mt8195_set_delayfunction mediatek_dwmac_config_dtfunction mediatek_dwmac_clk_initfunction RMIIfunction mediatek_dwmac_initfunction mediatek_dwmac_clks_configfunction mediatek_dwmac_common_datafunction mediatek_dwmac_probefunction mediatek_dwmac_remove
Annotated Snippet
struct mac_delay_struct {
u32 tx_delay;
u32 rx_delay;
bool tx_inv;
bool rx_inv;
};
struct mediatek_dwmac_plat_data {
const struct mediatek_dwmac_variant *variant;
struct mac_delay_struct mac_delay;
struct clk *rmii_internal_clk;
struct clk_bulk_data *clks;
struct regmap *peri_regmap;
struct device_node *np;
struct device *dev;
phy_interface_t phy_mode;
bool rmii_clk_from_mac;
bool rmii_rxc;
bool mac_wol;
};
struct mediatek_dwmac_variant {
int (*dwmac_set_phy_interface)(struct mediatek_dwmac_plat_data *plat,
u8 phy_intf_sel);
int (*dwmac_set_delay)(struct mediatek_dwmac_plat_data *plat);
/* clock ids to be requested */
const char * const *clk_list;
int num_clks;
u32 rx_delay_max;
u32 tx_delay_max;
u8 dma_bit_mask;
};
/* list of clocks required for mac */
static const char * const mt2712_dwmac_clk_l[] = {
"axi", "apb", "mac_main", "ptp_ref"
};
static const char * const mt8195_dwmac_clk_l[] = {
"axi", "apb", "mac_cg", "mac_main", "ptp_ref"
};
static int mt2712_set_interface(struct mediatek_dwmac_plat_data *plat,
u8 phy_intf_sel)
{
u32 intf_val = phy_intf_sel;
if (phy_intf_sel == PHY_INTF_SEL_RMII) {
if (plat->rmii_clk_from_mac)
intf_val |= RMII_CLK_SRC_INTERNAL;
if (plat->rmii_rxc)
intf_val |= RMII_CLK_SRC_RXC;
}
regmap_write(plat->peri_regmap, PERI_ETH_PHY_INTF_SEL, intf_val);
return 0;
}
static void mt2712_delay_ps2stage(struct mediatek_dwmac_plat_data *plat)
{
struct mac_delay_struct *mac_delay = &plat->mac_delay;
switch (plat->phy_mode) {
case PHY_INTERFACE_MODE_MII:
case PHY_INTERFACE_MODE_RMII:
/* 550ps per stage for MII/RMII */
mac_delay->tx_delay /= 550;
mac_delay->rx_delay /= 550;
break;
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_TXID:
case PHY_INTERFACE_MODE_RGMII_RXID:
case PHY_INTERFACE_MODE_RGMII_ID:
/* 170ps per stage for RGMII */
mac_delay->tx_delay /= 170;
mac_delay->rx_delay /= 170;
break;
default:
dev_err(plat->dev, "phy interface not supported\n");
break;
}
}
static void mt2712_delay_stage2ps(struct mediatek_dwmac_plat_data *plat)
{
struct mac_delay_struct *mac_delay = &plat->mac_delay;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/io.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/of.h`, `linux/of_net.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct mac_delay_struct`, `struct mediatek_dwmac_plat_data`, `struct mediatek_dwmac_variant`, `function mt2712_set_interface`, `function mt2712_delay_ps2stage`, `function mt2712_delay_stage2ps`, `function mt2712_set_delay`, `function mt8195_set_interface`, `function mt8195_delay_ps2stage`, `function mt8195_delay_stage2ps`.
- 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.