[openwrt/openwrt] realtek: phy: convert confusing BMCR_PDOWN usage for RTL8214FC

LEDE Commits lede-commits at lists.infradead.org
Sat Jan 24 02:44:13 PST 2026


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/07bb4f51158be149f5bef54faf9dc545ce2c40d5

commit 07bb4f51158be149f5bef54faf9dc545ce2c40d5
Author: Markus Stockhausen <markus.stockhausen at gmx.de>
AuthorDate: Sat Jan 17 19:50:32 2026 +0100

    realtek: phy: convert confusing BMCR_PDOWN usage for RTL8214FC
    
    Bit 11 of registers 16, 19, 20, 21 in page 0x266 denotes if a port
    of a RTL8214FC is set/favoured to fibre (0) or copper (1). For unknown
    reasons the bit was mixed with BMCR_PDOWN. Convert this to a meaningful
    define.
    
    Signed-off-by: Markus Stockhausen <markus.stockhausen at gmx.de>
    Link: https://github.com/openwrt/openwrt/pull/21582
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 target/linux/realtek/files-6.12/drivers/net/phy/rtl83xx-phy.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/target/linux/realtek/files-6.12/drivers/net/phy/rtl83xx-phy.c b/target/linux/realtek/files-6.12/drivers/net/phy/rtl83xx-phy.c
index fad43dd8aa..81fa9799fd 100644
--- a/target/linux/realtek/files-6.12/drivers/net/phy/rtl83xx-phy.c
+++ b/target/linux/realtek/files-6.12/drivers/net/phy/rtl83xx-phy.c
@@ -57,6 +57,8 @@ extern struct rtl83xx_soc_info soc_info;
 #define RTL821X_JOIN_LAST		1
 #define RTL821X_JOIN_OTHER		2
 
+#define RTL8214FC_MEDIA_COPPER		BIT(11)
+
 static const struct firmware rtl838x_8380_fw;
 static const struct firmware rtl838x_8218b_fw;
 
@@ -447,7 +449,7 @@ static bool __rtl8214fc_media_is_fibre(struct phy_device *phydev)
 	__phy_write(basephy, RTL821XEXT_MEDIA_PAGE_SELECT, oldxpage);
 	__phy_write(basephy, RTL8XXX_PAGE_SELECT, oldpage);
 
-	return !(val & BMCR_PDOWN);
+	return !(val & RTL8214FC_MEDIA_COPPER);
 }
 
 static bool rtl8214fc_media_is_fibre(struct phy_device *phydev)
@@ -495,13 +497,13 @@ static int rtl8214fc_resume(struct phy_device *phydev)
 static void rtl8214fc_media_set(struct phy_device *phydev, bool set_fibre)
 {
 	struct phy_device *basephy = get_base_phy(phydev);
-	int pdown = set_fibre ? 0 : BMCR_PDOWN;
+	int copper = set_fibre ? 0 : RTL8214FC_MEDIA_COPPER;
 	static int regs[] = {16, 19, 20, 21};
 	int reg = regs[phydev->mdio.addr & 3];
 
 	phydev_info(phydev, "switch to %s\n", set_fibre ? "fibre" : "copper");
 	phy_write_paged(basephy, RTL838X_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_INTERNAL);
-	phy_modify_paged(basephy, RTL821X_PAGE_PORT, reg, BMCR_PDOWN, pdown);
+	phy_modify_paged(basephy, RTL821X_PAGE_PORT, reg, RTL8214FC_MEDIA_COPPER, copper);
 	phy_write_paged(basephy, RTL838X_PAGE_RAW, RTL821XINT_MEDIA_PAGE_SELECT, RTL821X_MEDIA_PAGE_AUTO);
 
 	if (!phydev->suspended) {




More information about the lede-commits mailing list