drivers/net/ethernet/mediatek/mtk_eth_path.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mediatek/mtk_eth_path.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mediatek/mtk_eth_path.c- Extension
.c- Size
- 7085 bytes
- Lines
- 331
- 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/regmap.hmtk_eth_soc.h
Detected Declarations
struct mtk_eth_muxcfunction set_mux_gdm1_to_gmac1_eswfunction set_mux_gmac2_gmac0_to_gephyfunction set_mux_u3_gmac2_to_qphyfunction set_mux_gmac2_to_2p5gphyfunction set_mux_gmac1_gmac2_to_sgmii_rgmiifunction set_mux_gmac12_to_gephy_sgmiifunction mtk_eth_mux_setupfunction mtk_gmac_sgmii_path_setupfunction mtk_gmac_2p5gphy_path_setupfunction mtk_gmac_gephy_path_setupfunction mtk_gmac_rgmii_path_setup
Annotated Snippet
struct mtk_eth_muxc {
const char *name;
u64 cap_bit;
int (*set_path)(struct mtk_eth *eth, u64 path);
};
static const char *mtk_eth_path_name(u64 path)
{
switch (path) {
case MTK_ETH_PATH_GMAC1_RGMII:
return "gmac1_rgmii";
case MTK_ETH_PATH_GMAC1_TRGMII:
return "gmac1_trgmii";
case MTK_ETH_PATH_GMAC1_SGMII:
return "gmac1_sgmii";
case MTK_ETH_PATH_GMAC2_RGMII:
return "gmac2_rgmii";
case MTK_ETH_PATH_GMAC2_SGMII:
return "gmac2_sgmii";
case MTK_ETH_PATH_GMAC2_2P5GPHY:
return "gmac2_2p5gphy";
case MTK_ETH_PATH_GMAC2_GEPHY:
return "gmac2_gephy";
case MTK_ETH_PATH_GDM1_ESW:
return "gdm1_esw";
default:
return "unknown path";
}
}
static int set_mux_gdm1_to_gmac1_esw(struct mtk_eth *eth, u64 path)
{
bool updated = true;
u32 mask, set, reg;
switch (path) {
case MTK_ETH_PATH_GMAC1_SGMII:
mask = ~(u32)MTK_MUX_TO_ESW;
set = 0;
break;
case MTK_ETH_PATH_GDM1_ESW:
mask = ~(u32)MTK_MUX_TO_ESW;
set = MTK_MUX_TO_ESW;
break;
default:
updated = false;
break;
}
if (mtk_is_netsys_v3_or_greater(eth))
reg = MTK_MAC_MISC_V3;
else
reg = MTK_MAC_MISC;
if (updated)
mtk_m32(eth, mask, set, reg);
dev_dbg(eth->dev, "path %s in %s updated = %d\n",
mtk_eth_path_name(path), __func__, updated);
return 0;
}
static int set_mux_gmac2_gmac0_to_gephy(struct mtk_eth *eth, u64 path)
{
unsigned int val = 0;
bool updated = true;
switch (path) {
case MTK_ETH_PATH_GMAC2_GEPHY:
val = ~(u32)GEPHY_MAC_SEL;
break;
default:
updated = false;
break;
}
if (updated)
regmap_update_bits(eth->infra, INFRA_MISC2, GEPHY_MAC_SEL, val);
dev_dbg(eth->dev, "path %s in %s updated = %d\n",
mtk_eth_path_name(path), __func__, updated);
return 0;
}
static int set_mux_u3_gmac2_to_qphy(struct mtk_eth *eth, u64 path)
{
unsigned int val = 0, mask = 0, reg = 0;
bool updated = true;
Annotation
- Immediate include surface: `linux/phy.h`, `linux/regmap.h`, `mtk_eth_soc.h`.
- Detected declarations: `struct mtk_eth_muxc`, `function set_mux_gdm1_to_gmac1_esw`, `function set_mux_gmac2_gmac0_to_gephy`, `function set_mux_u3_gmac2_to_qphy`, `function set_mux_gmac2_to_2p5gphy`, `function set_mux_gmac1_gmac2_to_sgmii_rgmii`, `function set_mux_gmac12_to_gephy_sgmii`, `function mtk_eth_mux_setup`, `function mtk_gmac_sgmii_path_setup`, `function mtk_gmac_2p5gphy_path_setup`.
- 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.