drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c- Extension
.c- Size
- 3656 bytes
- Lines
- 152
- 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/ethtool.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/property.hlinux/stmmac.hdwmac4.hstmmac.hstmmac_platform.h
Detected Declarations
struct intel_dwmacstruct intel_dwmac_datafunction intel_eth_plat_probefunction intel_eth_plat_remove
Annotated Snippet
struct intel_dwmac {
struct device *dev;
struct clk *tx_clk;
const struct intel_dwmac_data *data;
};
struct intel_dwmac_data {
unsigned long ptp_ref_clk_rate;
unsigned long tx_clk_rate;
bool tx_clk_en;
};
static const struct intel_dwmac_data kmb_data = {
.ptp_ref_clk_rate = 200000000,
.tx_clk_rate = 125000000,
.tx_clk_en = true,
};
static const struct of_device_id intel_eth_plat_match[] = {
{ .compatible = "intel,keembay-dwmac", .data = &kmb_data },
{ }
};
MODULE_DEVICE_TABLE(of, intel_eth_plat_match);
static int intel_eth_plat_probe(struct platform_device *pdev)
{
struct plat_stmmacenet_data *plat_dat;
struct stmmac_resources stmmac_res;
struct intel_dwmac *dwmac;
unsigned long rate;
int ret;
ret = stmmac_get_platform_resources(pdev, &stmmac_res);
if (ret)
return ret;
plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
if (IS_ERR(plat_dat)) {
dev_err(&pdev->dev, "dt configuration failed\n");
return PTR_ERR(plat_dat);
}
dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
if (!dwmac)
return -ENOMEM;
dwmac->dev = &pdev->dev;
dwmac->tx_clk = NULL;
/*
* This cannot return NULL at this point because the driver’s
* compatibility with the device has already been validated in
* platform_match().
*/
dwmac->data = device_get_match_data(&pdev->dev);
/* Enable TX clock */
if (dwmac->data->tx_clk_en) {
dwmac->tx_clk = devm_clk_get(&pdev->dev, "tx_clk");
if (IS_ERR(dwmac->tx_clk))
return PTR_ERR(dwmac->tx_clk);
ret = clk_prepare_enable(dwmac->tx_clk);
if (ret) {
dev_err(&pdev->dev,
"Failed to enable tx_clk\n");
return ret;
}
/* Check and configure TX clock rate */
rate = clk_get_rate(dwmac->tx_clk);
if (dwmac->data->tx_clk_rate &&
rate != dwmac->data->tx_clk_rate) {
rate = dwmac->data->tx_clk_rate;
ret = clk_set_rate(dwmac->tx_clk, rate);
if (ret) {
dev_err(&pdev->dev,
"Failed to set tx_clk\n");
goto err_tx_clk_disable;
}
}
/* Check and configure PTP ref clock rate */
rate = clk_get_rate(plat_dat->clk_ptp_ref);
if (dwmac->data->ptp_ref_clk_rate &&
rate != dwmac->data->ptp_ref_clk_rate) {
rate = dwmac->data->ptp_ref_clk_rate;
ret = clk_set_rate(plat_dat->clk_ptp_ref, rate);
if (ret) {
dev_err(&pdev->dev,
Annotation
- Immediate include surface: `linux/ethtool.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/property.h`, `linux/stmmac.h`, `dwmac4.h`, `stmmac.h`.
- Detected declarations: `struct intel_dwmac`, `struct intel_dwmac_data`, `function intel_eth_plat_probe`, `function intel_eth_plat_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.