drivers/net/ethernet/realtek/r8169_phy_config.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/realtek/r8169_phy_config.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/realtek/r8169_phy_config.c
Extension
.c
Size
40599 bytes
Lines
1381
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 phy_reg {
	u16 reg;
	u16 val;
};

static void __rtl_writephy_batch(struct phy_device *phydev,
				 const struct phy_reg *regs, int len)
{
	phy_lock_mdio_bus(phydev);

	while (len-- > 0) {
		__phy_write(phydev, regs->reg, regs->val);
		regs++;
	}

	phy_unlock_mdio_bus(phydev);
}

#define rtl_writephy_batch(p, a) __rtl_writephy_batch(p, a, ARRAY_SIZE(a))

static void rtl8168f_config_eee_phy(struct phy_device *phydev)
{
	r8168d_modify_extpage(phydev, 0x0020, 0x15, 0, BIT(8));
	r8168d_phy_param(phydev, 0x8b85, 0, BIT(13));
}

static void rtl8168g_config_eee_phy(struct phy_device *phydev)
{
	phy_modify_paged(phydev, 0x0a43, 0x11, 0, BIT(4));
}

static void rtl8168h_config_eee_phy(struct phy_device *phydev)
{
	rtl8168g_config_eee_phy(phydev);

	phy_modify_paged(phydev, 0xa4a, 0x11, 0x0000, 0x0200);
	phy_modify_paged(phydev, 0xa42, 0x14, 0x0000, 0x0080);
}

static void rtl8125_common_config_eee_phy(struct phy_device *phydev)
{
	phy_modify_paged(phydev, 0xa6d, 0x14, 0x0010, 0x0000);
	phy_modify_paged(phydev, 0xa42, 0x14, 0x0080, 0x0000);
	phy_modify_paged(phydev, 0xa4a, 0x11, 0x0200, 0x0000);
}

static void rtl8125_config_eee_phy(struct phy_device *phydev)
{
	rtl8168g_config_eee_phy(phydev);
	rtl8125_common_config_eee_phy(phydev);
}

static void rtl8169s_hw_phy_config(struct rtl8169_private *tp,
				   struct phy_device *phydev)
{
	static const struct phy_reg phy_reg_init[] = {
		{ 0x1f, 0x0001 },
		{ 0x06, 0x006e },
		{ 0x08, 0x0708 },
		{ 0x15, 0x4000 },
		{ 0x18, 0x65c7 },

		{ 0x1f, 0x0001 },
		{ 0x03, 0x00a1 },
		{ 0x02, 0x0008 },
		{ 0x01, 0x0120 },
		{ 0x00, 0x1000 },
		{ 0x04, 0x0800 },
		{ 0x04, 0x0000 },

		{ 0x03, 0xff41 },
		{ 0x02, 0xdf60 },
		{ 0x01, 0x0140 },
		{ 0x00, 0x0077 },
		{ 0x04, 0x7800 },
		{ 0x04, 0x7000 },

		{ 0x03, 0x802f },
		{ 0x02, 0x4f02 },
		{ 0x01, 0x0409 },
		{ 0x00, 0xf0f9 },
		{ 0x04, 0x9800 },
		{ 0x04, 0x9000 },

		{ 0x03, 0xdf01 },
		{ 0x02, 0xdf20 },
		{ 0x01, 0xff95 },
		{ 0x00, 0xba00 },
		{ 0x04, 0xa800 },
		{ 0x04, 0xa000 },

Annotation

Implementation Notes