drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
Extension
.c
Size
34500 bytes
Lines
1300
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct emac_variant {
	const struct reg_field *syscon_field;
	bool soc_has_internal_phy;
	bool support_mii;
	bool support_rmii;
	bool support_rgmii;
	u8 rx_delay_max;
	u8 tx_delay_max;
};

/* struct sunxi_priv_data - hold all sunxi private data
 * @ephy_clk:	reference to the optional EPHY clock for the internal PHY
 * @regulator:	reference to the optional regulator
 * @rst_ephy:	reference to the optional EPHY reset for the internal PHY
 * @variant:	reference to the current board variant
 * @regmap:	regmap for using the syscon
 * @internal_phy_powered: Does the internal PHY is enabled
 * @use_internal_phy: Is the internal PHY selected for use
 * @mux_handle:	Internal pointer used by mdio-mux lib
 */
struct sunxi_priv_data {
	struct clk *ephy_clk;
	struct regulator *regulator;
	struct reset_control *rst_ephy;
	const struct emac_variant *variant;
	struct regmap_field *regmap_field;
	bool internal_phy_powered;
	bool use_internal_phy;
	void *mux_handle;
};

/* EMAC clock register @ 0x30 in the "system control" address range */
static const struct reg_field sun8i_syscon_reg_field = {
	.reg = 0x30,
	.lsb = 0,
	.msb = 31,
};

/* EMAC clock register @ 0x164 in the CCU address range */
static const struct reg_field sun8i_ccu_reg_field = {
	.reg = 0x164,
	.lsb = 0,
	.msb = 31,
};

static const struct emac_variant emac_variant_h3 = {
	.syscon_field = &sun8i_syscon_reg_field,
	.soc_has_internal_phy = true,
	.support_mii = true,
	.support_rmii = true,
	.support_rgmii = true,
	.rx_delay_max = 31,
	.tx_delay_max = 7,
};

static const struct emac_variant emac_variant_v3s = {
	.syscon_field = &sun8i_syscon_reg_field,
	.soc_has_internal_phy = true,
	.support_mii = true
};

static const struct emac_variant emac_variant_a83t = {
	.syscon_field = &sun8i_syscon_reg_field,
	.soc_has_internal_phy = false,
	.support_mii = true,
	.support_rgmii = true,
	.rx_delay_max = 31,
	.tx_delay_max = 7,
};

static const struct emac_variant emac_variant_r40 = {
	.syscon_field = &sun8i_ccu_reg_field,
	.support_mii = true,
	.support_rgmii = true,
	.rx_delay_max = 7,
};

static const struct emac_variant emac_variant_a64 = {
	.syscon_field = &sun8i_syscon_reg_field,
	.soc_has_internal_phy = false,
	.support_mii = true,
	.support_rmii = true,
	.support_rgmii = true,
	.rx_delay_max = 31,
	.tx_delay_max = 7,
};

static const struct emac_variant emac_variant_h6 = {
	.syscon_field = &sun8i_syscon_reg_field,
	/* The "Internal PHY" of H6 is not on the die. It's on the

Annotation

Implementation Notes