drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c- Extension
.c- Size
- 2599 bytes
- Lines
- 94
- 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/clk.hlinux/module.hlinux/property.hlinux/mod_devicetable.hlinux/platform_device.hstmmac_platform.h
Detected Declarations
struct sophgo_dwmac_datafunction sophgo_sg2044_dwmac_initfunction sophgo_dwmac_probe
Annotated Snippet
struct sophgo_dwmac_data {
bool has_internal_rx_delay;
};
static int sophgo_sg2044_dwmac_init(struct platform_device *pdev,
struct plat_stmmacenet_data *plat_dat,
struct stmmac_resources *stmmac_res)
{
plat_dat->clk_tx_i = devm_clk_get_enabled(&pdev->dev, "tx");
if (IS_ERR(plat_dat->clk_tx_i))
return dev_err_probe(&pdev->dev, PTR_ERR(plat_dat->clk_tx_i),
"failed to get tx clock\n");
plat_dat->flags |= STMMAC_FLAG_SPH_DISABLE;
plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
plat_dat->multicast_filter_bins = 0;
return 0;
}
static int sophgo_dwmac_probe(struct platform_device *pdev)
{
struct plat_stmmacenet_data *plat_dat;
const struct sophgo_dwmac_data *data;
struct stmmac_resources stmmac_res;
struct device *dev = &pdev->dev;
int ret;
ret = stmmac_get_platform_resources(pdev, &stmmac_res);
if (ret)
return dev_err_probe(dev, ret,
"failed to get platform resources\n");
plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
if (IS_ERR(plat_dat))
return dev_err_probe(dev, PTR_ERR(plat_dat),
"failed to parse DT parameters\n");
ret = sophgo_sg2044_dwmac_init(pdev, plat_dat, &stmmac_res);
if (ret)
return ret;
data = device_get_match_data(&pdev->dev);
if (data && data->has_internal_rx_delay) {
plat_dat->phy_interface = phy_fix_phy_mode_for_mac_delays(plat_dat->phy_interface,
false, true);
if (plat_dat->phy_interface == PHY_INTERFACE_MODE_NA)
return -EINVAL;
}
return stmmac_dvr_probe(dev, plat_dat, &stmmac_res);
}
static const struct sophgo_dwmac_data sg2042_dwmac_data = {
.has_internal_rx_delay = true,
};
static const struct of_device_id sophgo_dwmac_match[] = {
{ .compatible = "sophgo,sg2042-dwmac", .data = &sg2042_dwmac_data },
{ .compatible = "sophgo,sg2044-dwmac" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, sophgo_dwmac_match);
static struct platform_driver sophgo_dwmac_driver = {
.probe = sophgo_dwmac_probe,
.remove = stmmac_pltfr_remove,
.driver = {
.name = "sophgo-dwmac",
.pm = &stmmac_pltfr_pm_ops,
.of_match_table = sophgo_dwmac_match,
},
};
module_platform_driver(sophgo_dwmac_driver);
MODULE_AUTHOR("Inochi Amaoto <inochiama@gmail.com>");
MODULE_DESCRIPTION("Sophgo DWMAC platform driver");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/clk.h`, `linux/module.h`, `linux/property.h`, `linux/mod_devicetable.h`, `linux/platform_device.h`, `stmmac_platform.h`.
- Detected declarations: `struct sophgo_dwmac_data`, `function sophgo_sg2044_dwmac_init`, `function sophgo_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.