drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c- Extension
.c- Size
- 5949 bytes
- Lines
- 241
- 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/mfd/syscon.hlinux/module.hlinux/of.hlinux/phy.hlinux/platform_device.hlinux/regmap.hstmmac.hstmmac_platform.h
Detected Declarations
struct ls1x_dwmacstruct ls1x_datafunction ls1b_dwmac_setupfunction ls1b_dwmac_syscon_initfunction ls1c_dwmac_syscon_initfunction ls1x_dwmac_probe
Annotated Snippet
struct ls1x_dwmac {
struct plat_stmmacenet_data *plat_dat;
struct regmap *regmap;
unsigned int id;
};
struct ls1x_data {
int (*setup)(struct platform_device *pdev,
struct plat_stmmacenet_data *plat_dat);
int (*init)(struct device *dev, void *bsp_priv);
};
static int ls1b_dwmac_setup(struct platform_device *pdev,
struct plat_stmmacenet_data *plat_dat)
{
struct ls1x_dwmac *dwmac = plat_dat->bsp_priv;
struct resource *res;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
/* This shouldn't fail - stmmac_get_platform_resources()
* already mapped this resource.
*/
dev_err(&pdev->dev, "Could not get IO_MEM resources\n");
return -EINVAL;
}
if (res->start == LS1B_GMAC0_BASE) {
dwmac->id = 0;
} else if (res->start == LS1B_GMAC1_BASE) {
dwmac->id = 1;
} else {
dev_err(&pdev->dev, "Invalid Ethernet MAC base address %pR",
res);
return -EINVAL;
}
return 0;
}
static int ls1b_dwmac_syscon_init(struct device *dev, void *priv)
{
struct ls1x_dwmac *dwmac = priv;
struct plat_stmmacenet_data *plat = dwmac->plat_dat;
struct regmap *regmap = dwmac->regmap;
if (dwmac->id == 0) {
switch (plat->phy_interface) {
case PHY_INTERFACE_MODE_RGMII_ID:
regmap_update_bits(regmap, LS1X_SYSCON0,
GMAC0_USE_TXCLK | GMAC0_USE_PWM01,
0);
break;
case PHY_INTERFACE_MODE_MII:
regmap_update_bits(regmap, LS1X_SYSCON0,
GMAC0_USE_TXCLK | GMAC0_USE_PWM01,
GMAC0_USE_TXCLK | GMAC0_USE_PWM01);
break;
default:
dev_err(dev, "Unsupported PHY mode %u\n",
plat->phy_interface);
return -EOPNOTSUPP;
}
regmap_update_bits(regmap, LS1X_SYSCON0, GMAC0_SHUT, 0);
} else if (dwmac->id == 1) {
regmap_update_bits(regmap, LS1X_SYSCON0,
GMAC1_USE_UART1 | GMAC1_USE_UART0,
GMAC1_USE_UART1 | GMAC1_USE_UART0);
switch (plat->phy_interface) {
case PHY_INTERFACE_MODE_RGMII_ID:
regmap_update_bits(regmap, LS1X_SYSCON1,
GMAC1_USE_TXCLK | GMAC1_USE_PWM23,
0);
break;
case PHY_INTERFACE_MODE_MII:
regmap_update_bits(regmap, LS1X_SYSCON1,
GMAC1_USE_TXCLK | GMAC1_USE_PWM23,
GMAC1_USE_TXCLK | GMAC1_USE_PWM23);
break;
default:
dev_err(dev, "Unsupported PHY mode %u\n",
plat->phy_interface);
return -EOPNOTSUPP;
}
regmap_update_bits(regmap, LS1X_SYSCON1, GMAC1_SHUT, 0);
}
Annotation
- Immediate include surface: `linux/mfd/syscon.h`, `linux/module.h`, `linux/of.h`, `linux/phy.h`, `linux/platform_device.h`, `linux/regmap.h`, `stmmac.h`, `stmmac_platform.h`.
- Detected declarations: `struct ls1x_dwmac`, `struct ls1x_data`, `function ls1b_dwmac_setup`, `function ls1b_dwmac_syscon_init`, `function ls1c_dwmac_syscon_init`, `function ls1x_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.