drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c- Extension
.c- Size
- 12111 bytes
- Lines
- 419
- 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/iommu.hlinux/platform_device.hlinux/of.hlinux/module.hlinux/stmmac.hlinux/clk.hstmmac_platform.h
Detected Declarations
struct tegra_mgbefunction tegra_mgbe_suspendfunction tegra_mgbe_resumefunction mgbe_uphy_lane_bringup_serdes_upfunction mgbe_uphy_lane_bringup_serdes_downfunction tegra_mgbe_probefunction tegra_mgbe_remove
Annotated Snippet
struct tegra_mgbe {
struct device *dev;
struct clk_bulk_data *clks;
struct reset_control *rst_mac;
struct reset_control *rst_pcs;
u32 iommu_sid;
void __iomem *hv;
void __iomem *regs;
void __iomem *xpcs;
struct mii_bus *mii;
};
#define XPCS_WRAP_UPHY_RX_CONTROL 0x801c
#define XPCS_WRAP_UPHY_RX_CONTROL_RX_SW_OVRD BIT(31)
#define XPCS_WRAP_UPHY_RX_CONTROL_RX_PCS_PHY_RDY BIT(10)
#define XPCS_WRAP_UPHY_RX_CONTROL_RX_CDR_RESET BIT(9)
#define XPCS_WRAP_UPHY_RX_CONTROL_RX_CAL_EN BIT(8)
#define XPCS_WRAP_UPHY_RX_CONTROL_RX_SLEEP (BIT(7) | BIT(6))
#define XPCS_WRAP_UPHY_RX_CONTROL_AUX_RX_IDDQ BIT(5)
#define XPCS_WRAP_UPHY_RX_CONTROL_RX_IDDQ BIT(4)
#define XPCS_WRAP_UPHY_RX_CONTROL_RX_DATA_EN BIT(0)
#define XPCS_WRAP_UPHY_HW_INIT_CTRL 0x8020
#define XPCS_WRAP_UPHY_HW_INIT_CTRL_TX_EN BIT(0)
#define XPCS_WRAP_UPHY_HW_INIT_CTRL_RX_EN BIT(2)
#define XPCS_WRAP_UPHY_STATUS 0x8044
#define XPCS_WRAP_UPHY_STATUS_TX_P_UP BIT(0)
#define XPCS_WRAP_IRQ_STATUS 0x8050
#define XPCS_WRAP_IRQ_STATUS_PCS_LINK_STS BIT(6)
#define XPCS_REG_ADDR_SHIFT 10
#define XPCS_REG_ADDR_MASK 0x1fff
#define XPCS_ADDR 0x3fc
#define MGBE_WRAP_COMMON_INTR_ENABLE 0x8704
#define MAC_SBD_INTR BIT(2)
#define MGBE_WRAP_AXI_ASID0_CTRL 0x8400
static int __maybe_unused tegra_mgbe_suspend(struct device *dev)
{
struct tegra_mgbe *mgbe = get_stmmac_bsp_priv(dev);
int err;
err = stmmac_suspend(dev);
if (err)
return err;
clk_bulk_disable_unprepare(ARRAY_SIZE(mgbe_clks), mgbe->clks);
return reset_control_assert(mgbe->rst_mac);
}
static int __maybe_unused tegra_mgbe_resume(struct device *dev)
{
struct tegra_mgbe *mgbe = get_stmmac_bsp_priv(dev);
u32 value;
int err;
err = clk_bulk_prepare_enable(ARRAY_SIZE(mgbe_clks), mgbe->clks);
if (err < 0)
return err;
err = reset_control_deassert(mgbe->rst_mac);
if (err < 0)
return err;
/* Enable common interrupt at wrapper level */
writel(MAC_SBD_INTR, mgbe->regs + MGBE_WRAP_COMMON_INTR_ENABLE);
/* Program SID */
writel(mgbe->iommu_sid, mgbe->hv + MGBE_WRAP_AXI_ASID0_CTRL);
value = readl(mgbe->xpcs + XPCS_WRAP_UPHY_STATUS);
if ((value & XPCS_WRAP_UPHY_STATUS_TX_P_UP) == 0) {
value = readl(mgbe->xpcs + XPCS_WRAP_UPHY_HW_INIT_CTRL);
value |= XPCS_WRAP_UPHY_HW_INIT_CTRL_TX_EN;
writel(value, mgbe->xpcs + XPCS_WRAP_UPHY_HW_INIT_CTRL);
}
err = readl_poll_timeout(mgbe->xpcs + XPCS_WRAP_UPHY_HW_INIT_CTRL, value,
(value & XPCS_WRAP_UPHY_HW_INIT_CTRL_TX_EN) == 0,
500, 500 * 2000);
if (err < 0) {
dev_err(mgbe->dev, "timeout waiting for TX lane to become enabled\n");
clk_bulk_disable_unprepare(ARRAY_SIZE(mgbe_clks), mgbe->clks);
return err;
Annotation
- Immediate include surface: `linux/iommu.h`, `linux/platform_device.h`, `linux/of.h`, `linux/module.h`, `linux/stmmac.h`, `linux/clk.h`, `stmmac_platform.h`.
- Detected declarations: `struct tegra_mgbe`, `function tegra_mgbe_suspend`, `function tegra_mgbe_resume`, `function mgbe_uphy_lane_bringup_serdes_up`, `function mgbe_uphy_lane_bringup_serdes_down`, `function tegra_mgbe_probe`, `function tegra_mgbe_remove`.
- 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.