]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: phy: convert confusing BMCR_PDOWN usage for RTL8214FC
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Sat, 17 Jan 2026 18:50:32 +0000 (19:50 +0100)
committerRobert Marko <robimarko@gmail.com>
Sat, 24 Jan 2026 10:44:09 +0000 (11:44 +0100)
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@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/21582
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/realtek/files-6.12/drivers/net/phy/rtl83xx-phy.c

index fad43dd8aa047e766b0b779928533d06a94ff376..81fa9799fd25761911c3cb553709363b0b73e66e 100644 (file)
@@ -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) {