drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c- Extension
.c- Size
- 14774 bytes
- Lines
- 511
- 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/device.hlinux/platform_device.hlinux/phy.hlinux/regmap.hlinux/clk.hlinux/reset.hlinux/of_net.hlinux/mfd/syscon.hlinux/stmmac.hlinux/of_mdio.hlinux/module.hlinux/sys_soc.hlinux/bitfield.hstmmac_platform.h
Detected Declarations
struct ipq806x_gmacfunction get_clk_div_sgmiifunction get_clk_div_rgmiifunction ipq806x_gmac_set_speedfunction ipq806x_gmac_of_parsefunction ipq806x_gmac_set_clk_tx_ratefunction ipq806x_gmac_configure_qsgmii_pcs_speedfunction ipq806x_gmac_configure_qsgmii_paramsfunction ipq806x_gmac_probe
Annotated Snippet
struct ipq806x_gmac {
struct platform_device *pdev;
struct regmap *nss_common;
struct regmap *qsgmii_csr;
uint32_t id;
struct clk *core_clk;
phy_interface_t phy_mode;
};
static int get_clk_div_sgmii(struct ipq806x_gmac *gmac, int speed)
{
struct device *dev = &gmac->pdev->dev;
int div;
switch (speed) {
case SPEED_1000:
div = NSS_COMMON_CLK_DIV_SGMII_1000;
break;
case SPEED_100:
div = NSS_COMMON_CLK_DIV_SGMII_100;
break;
case SPEED_10:
div = NSS_COMMON_CLK_DIV_SGMII_10;
break;
default:
dev_err(dev, "Speed %dMbps not supported in SGMII\n", speed);
return -EINVAL;
}
return div;
}
static int get_clk_div_rgmii(struct ipq806x_gmac *gmac, int speed)
{
struct device *dev = &gmac->pdev->dev;
int div;
switch (speed) {
case SPEED_1000:
div = NSS_COMMON_CLK_DIV_RGMII_1000;
break;
case SPEED_100:
div = NSS_COMMON_CLK_DIV_RGMII_100;
break;
case SPEED_10:
div = NSS_COMMON_CLK_DIV_RGMII_10;
break;
default:
dev_err(dev, "Speed %dMbps not supported in RGMII\n", speed);
return -EINVAL;
}
return div;
}
static int ipq806x_gmac_set_speed(struct ipq806x_gmac *gmac, int speed)
{
uint32_t clk_bits, val;
int div;
switch (gmac->phy_mode) {
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII_RXID:
case PHY_INTERFACE_MODE_RGMII_TXID:
div = get_clk_div_rgmii(gmac, speed);
clk_bits = NSS_COMMON_CLK_GATE_RGMII_RX_EN(gmac->id) |
NSS_COMMON_CLK_GATE_RGMII_TX_EN(gmac->id);
break;
case PHY_INTERFACE_MODE_SGMII:
div = get_clk_div_sgmii(gmac, speed);
clk_bits = NSS_COMMON_CLK_GATE_GMII_RX_EN(gmac->id) |
NSS_COMMON_CLK_GATE_GMII_TX_EN(gmac->id);
break;
default:
dev_err(&gmac->pdev->dev, "Unsupported PHY mode: \"%s\"\n",
phy_modes(gmac->phy_mode));
return -EINVAL;
}
/* Disable the clocks */
regmap_read(gmac->nss_common, NSS_COMMON_CLK_GATE, &val);
Annotation
- Immediate include surface: `linux/device.h`, `linux/platform_device.h`, `linux/phy.h`, `linux/regmap.h`, `linux/clk.h`, `linux/reset.h`, `linux/of_net.h`, `linux/mfd/syscon.h`.
- Detected declarations: `struct ipq806x_gmac`, `function get_clk_div_sgmii`, `function get_clk_div_rgmii`, `function ipq806x_gmac_set_speed`, `function ipq806x_gmac_of_parse`, `function ipq806x_gmac_set_clk_tx_rate`, `function ipq806x_gmac_configure_qsgmii_pcs_speed`, `function ipq806x_gmac_configure_qsgmii_params`, `function ipq806x_gmac_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.