From: Andrew LaMarche Date: Mon, 9 Jun 2025 18:49:28 +0000 (+0000) Subject: kernel: fix rtl8261n driver for realtek X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F19081%2Fhead;p=thirdparty%2Fopenwrt.git kernel: fix rtl8261n driver for realtek 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 Link: https://github.com/openwrt/openwrt/pull/19081 Signed-off-by: Robert Marko --- diff --git a/target/linux/generic/files/drivers/net/phy/rtl8261n/phy_patch.c b/target/linux/generic/files/drivers/net/phy/rtl8261n/phy_patch.c index f9af3ffe022..7563f670533 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8261n/phy_patch.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8261n/phy_patch.c @@ -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; } - - - - diff --git a/target/linux/generic/files/drivers/net/phy/rtl8261n/rtk_phy.c b/target/linux/generic/files/drivers/net/phy/rtl8261n/rtk_phy.c index 23e1d8c4ec0..23916a89efb 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8261n/rtk_phy.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8261n/rtk_phy.c @@ -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)