]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
kernel: fix rtl8261n driver for realtek 19081/head
authorAndrew LaMarche <andrewjlamarche@gmail.com>
Mon, 9 Jun 2025 18:49:28 +0000 (18:49 +0000)
committerRobert Marko <robimarko@gmail.com>
Wed, 9 Jul 2025 12:45:14 +0000 (14:45 +0200)
The RTL8261N driver does not work correctly on non-mediatek devices. Remove
some of the power controls for Realtek chips.

This assumes the network has been started by the bootloader already:
(rtk network on).

Co-authored-by: Sebastian Gottschall
- https://github.com/mirror/dd-wrt/commit/bf45143f03d40bf259d34bba2151aab46ee011f4
- https://github.com/mirror/dd-wrt/commit/2fb02a5745bb538124a7467b399930b5ca79e71d
- https://github.com/mirror/dd-wrt/commit/598a16a8d801869e09c033f8ca35534289d393cf
Signed-off-by: Andrew LaMarche <andrewjlamarche@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/19081
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/generic/files/drivers/net/phy/rtl8261n/phy_patch.c
target/linux/generic/files/drivers/net/phy/rtl8261n/rtk_phy.c

index f9af3ffe022e544eee1489c48d6f7daf164f8774..7563f6705333801f7c8e654ab2a5fd0271438239 100644 (file)
@@ -98,6 +98,11 @@ static int32 _phy_patch_process(uint32 unit, rtk_port_t port, uint8 portOffset,
     return (chk_ret == RT_ERR_CHECK_FAILED) ? chk_ret : RT_ERR_OK;
 }
 
+rtk_hwpatch_t rtl826XB_patch_rtk_conf[] = {
+    {RTK_PATCH_OP_PSDS0   , 0xff , 0x07  , 0x10  , 15, 0, 0x80aa, RTK_PATCH_CMP_WC  , 0, 0, 0, 0},
+    {RTK_PATCH_OP_PSDS0   , 0xff , 0x06  , 0x12  , 15, 0, 0x5078, RTK_PATCH_CMP_WC  , 0, 0, 0, 0},
+};
+
 /* Function Name:
  *      phy_patch
  * Description:
@@ -170,10 +175,14 @@ int32 phy_patch(uint32 unit, rtk_port_t port, uint8 portOffset, uint8 patch_mode
             break;
         }
     }
+    ret = _phy_patch_process(unit, port, portOffset, rtl826XB_patch_rtk_conf, sizeof(rtl826XB_patch_rtk_conf), patch_mode);
+    if (ret == RT_ERR_CHECK_FAILED)
+        chk_ret = ret;
+    else if (ret  != RT_ERR_OK)
+    {
+        RT_LOG(LOG_MAJOR_ERR, (MOD_HAL | MOD_PHY), "U%u P%u patch_mode:%u id:%u patch-%u failed. ret:0x%X\n", unit, port, patch_mode, i, patch_type, ret);
+        return ret;
+    }
 
     return (chk_ret == RT_ERR_CHECK_FAILED) ? chk_ret : RT_ERR_OK;
 }
-
-
-
-
index 23e1d8c4ec0ccad2863e9403e2ec48ded371f264..23916a89efb673e40c6d05a16bc8de863351e7da 100644 (file)
@@ -69,7 +69,9 @@ static int rtkphy_config_init(struct phy_device *phydev)
         case REALTEK_PHY_ID_RTL8264B:
         case REALTEK_PHY_ID_RTL8264:
             phydev_info(phydev, "%s:%u [RTL8261N/RTL8264/RTL826XB] phy_id: 0x%X PHYAD:%d\n", __FUNCTION__, __LINE__, phydev->drv->phy_id, phydev->mdio.addr);
-
+#ifdef CONFIG_MACH_REALTEK_RTL
+            return 0;
+#endif
 
           #if 1 /* toggle reset */
             phy_modify_mmd_changed(phydev, 30, 0x145, BIT(0)  , 1);
@@ -128,7 +130,9 @@ static int rtkphy_c45_suspend(struct phy_device *phydev)
 {
     int ret = 0;
 
+#ifndef CONFIG_MACH_REALTEK_RTL
     ret = rtk_phylib_c45_power_low(phydev);
+#endif
 
     phydev->speed = SPEED_UNKNOWN;
     phydev->duplex = DUPLEX_UNKNOWN;
@@ -140,7 +144,11 @@ static int rtkphy_c45_suspend(struct phy_device *phydev)
 
 static int rtkphy_c45_resume(struct phy_device *phydev)
 {
+#ifndef CONFIG_MACH_REALTEK_RTL
     return rtk_phylib_c45_power_normal(phydev);
+#else
+    return 0;
+#endif
 }
 
 static int rtkphy_c45_config_aneg(struct phy_device *phydev)