mirror of
https://github.com/openwrt/openwrt.git
synced 2026-12-06 06:25:41 +04:00
generic: harden RTL826x PHY match, EEE and soft-reset
Require PKG_MODEL 0x8261 for RTL8261BE/N probe matching. Extend EEE disable in rtl826x_probe() to multi-G speeds for PHYs without a device-tree node (e.g. SFP cage modules). Wait the datasheet t7 minimum (150 ms) after MMD30 soft-reset before applying firmware patches. Fixes 10G link flapping on Spectrum SBE1V1K (RTL8261BE). Also exercised on BPi-R4 with a ZYOPM SFP+ RTL8261BE module. Tested-by: Andrew LaMarche <andrewjlamarche@gmail.com> Link: https://forum.openwrt.org/t/spectrum-sbe1v1k-ipq9574-openwrt-support/245244/190 Signed-off-by: Daniel Pawlik <pawlik.dan@gmail.com> Link: https://github.com/openwrt/openwrt/pull/24887 Signed-off-by: Jonas Jelonek <jonas@jonasjelonek.de>
This commit is contained in:
1 parent
da415b6a69
commit
76da1ee259
6 files changed
+36
-27
No files matched your search
+23
-14
@@ -64,7 +64,7 @@ Signed-off-by: Balázs Triszka <info@balika011.hu>
|
||||
#include <linux/string_choices.h>
|
||||
#include <net/phy/realtek_phy.h>
|
||||
|
||||
@@ -217,10 +219,27 @@
|
||||
@@ -217,10 +219,33 @@
|
||||
#define RTL_8221B_VM_CG 0x001cc84a
|
||||
#define RTL_8251B 0x001cc862
|
||||
#define RTL_8261C 0x001cc890
|
||||
@@ -80,8 +80,14 @@ Signed-off-by: Balázs Triszka <info@balika011.hu>
|
||||
+#define RTL826X_VEND1_SERDES_GLOBAL_CFG_HSO_INV BIT(7)
|
||||
+
|
||||
+#define RTL826X_VEND1_PKG_MODEL 0x103
|
||||
+#define RTL826X_VEND1_PKG_MODEL_8251 0x8251
|
||||
+#define RTL826X_VEND1_PKG_MODEL_8254 0x8254
|
||||
+#define RTL826X_VEND1_PKG_MODEL_8261 0x8261
|
||||
+#define RTL826X_VEND1_VERSION_ID 0x104
|
||||
+#define RTL826X_VEND1_VERSION_ID_VARIANT GENMASK(2, 0)
|
||||
+/* MODEL_CHAR_1ST/2ND encode "BE" (B=0x2, E=0x5) in bits 15:6 */
|
||||
+#define RTL826X_VEND1_VERSION_ID_MODEL GENMASK(15, 6)
|
||||
+#define RTL826X_VEND1_VERSION_ID_MODEL_BE 0x1140
|
||||
+
|
||||
+#define RTL826X_VND2_INER 0xA424
|
||||
+#define RTL826X_VND2_INER_LINK_STATUS BIT(4)
|
||||
@@ -92,7 +98,7 @@ Signed-off-by: Balázs Triszka <info@balika011.hu>
|
||||
MODULE_DESCRIPTION("Realtek PHY driver");
|
||||
MODULE_AUTHOR("Johnson Leung");
|
||||
MODULE_LICENSE("GPL");
|
||||
@@ -2151,6 +2170,125 @@ static int rtl8251b_c45_match_phy_device
|
||||
@@ -2151,6 +2176,125 @@ static int rtl8251b_c45_match_phy_device
|
||||
return rtlgen_is_c45_match(phydev, RTL_8251B, true);
|
||||
}
|
||||
|
||||
@@ -111,7 +117,7 @@ Signed-off-by: Balázs Triszka <info@balika011.hu>
|
||||
+ if (data < 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (data != 0x8251)
|
||||
+ if (data != RTL826X_VEND1_PKG_MODEL_8251)
|
||||
+ return 0;
|
||||
+
|
||||
+ return 1;
|
||||
@@ -132,7 +138,7 @@ Signed-off-by: Balázs Triszka <info@balika011.hu>
|
||||
+ if (data < 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (data != 0x8254)
|
||||
+ if (data != RTL826X_VEND1_PKG_MODEL_8254)
|
||||
+ return 0;
|
||||
+
|
||||
+ return 1;
|
||||
@@ -153,14 +159,14 @@ Signed-off-by: Balázs Triszka <info@balika011.hu>
|
||||
+ if (data < 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (data == 0x8251)
|
||||
+ if (data != RTL826X_VEND1_PKG_MODEL_8261)
|
||||
+ return 0;
|
||||
+
|
||||
+ data = phy_read_mmd(phydev, MDIO_MMD_VEND1, RTL826X_VEND1_VERSION_ID);
|
||||
+ if (data < 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ if ((data & 0xFFC0) != 0x1140)
|
||||
+ if ((data & RTL826X_VEND1_VERSION_ID_MODEL) != RTL826X_VEND1_VERSION_ID_MODEL_BE)
|
||||
+ return 0;
|
||||
+
|
||||
+ return 1;
|
||||
@@ -181,14 +187,14 @@ Signed-off-by: Balázs Triszka <info@balika011.hu>
|
||||
+ if (data < 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (data == 0x8251)
|
||||
+ if (data != RTL826X_VEND1_PKG_MODEL_8261)
|
||||
+ return 0;
|
||||
+
|
||||
+ data = phy_read_mmd(phydev, MDIO_MMD_VEND1, RTL826X_VEND1_VERSION_ID);
|
||||
+ if (data < 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ if ((data & 0xFFC0) == 0x1140)
|
||||
+ if ((data & RTL826X_VEND1_VERSION_ID_MODEL) == RTL826X_VEND1_VERSION_ID_MODEL_BE)
|
||||
+ return 0;
|
||||
+
|
||||
+ return 1;
|
||||
@@ -209,7 +215,7 @@ Signed-off-by: Balázs Triszka <info@balika011.hu>
|
||||
+ if (data < 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (data == 0x8254)
|
||||
+ if (data == RTL826X_VEND1_PKG_MODEL_8254)
|
||||
+ return 0;
|
||||
+
|
||||
+ return 1;
|
||||
@@ -218,7 +224,7 @@ Signed-off-by: Balázs Triszka <info@balika011.hu>
|
||||
static int rtlgen_resume(struct phy_device *phydev)
|
||||
{
|
||||
int ret = genphy_resume(phydev);
|
||||
@@ -2372,6 +2510,482 @@ static int rtlgen_sfp_config_aneg(struct
|
||||
@@ -2372,6 +2516,485 @@ static int rtlgen_sfp_config_aneg(struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -252,9 +258,12 @@ Signed-off-by: Balázs Triszka <info@balika011.hu>
|
||||
+ if (!priv->enable_pma_low_power)
|
||||
+ phydev_warn(phydev, "PMA low-power suspend disabled\n");
|
||||
+
|
||||
+ /* Disable EEE due to link stability issues */
|
||||
+ /* Disable EEE due to link stability issues (incl. multi-G / rate-adapt) */
|
||||
+ phy_disable_eee_mode(phydev, ETHTOOL_LINK_MODE_100baseT_Full_BIT);
|
||||
+ phy_disable_eee_mode(phydev, ETHTOOL_LINK_MODE_1000baseT_Full_BIT);
|
||||
+ phy_disable_eee_mode(phydev, ETHTOOL_LINK_MODE_2500baseT_Full_BIT);
|
||||
+ phy_disable_eee_mode(phydev, ETHTOOL_LINK_MODE_5000baseT_Full_BIT);
|
||||
+ phy_disable_eee_mode(phydev, ETHTOOL_LINK_MODE_10000baseT_Full_BIT);
|
||||
+
|
||||
+ ret = rtl826x_patch_db_init(phydev);
|
||||
+ if (ret < 0)
|
||||
@@ -318,7 +327,7 @@ Signed-off-by: Balázs Triszka <info@balika011.hu>
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ /* toggle reset */
|
||||
+ /* Soft-reset (MMD30.0x145); after release wait datasheet t7 SMI-ready */
|
||||
+ ret = phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, 0x145, BIT(0));
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
@@ -334,7 +343,7 @@ Signed-off-by: Balázs Triszka <info@balika011.hu>
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ msleep(30);
|
||||
+ msleep(150);
|
||||
+
|
||||
+ ret = rtlgen_phy_patch(phydev);
|
||||
+ if (ret) {
|
||||
@@ -701,7 +710,7 @@ Signed-off-by: Balázs Triszka <info@balika011.hu>
|
||||
static struct phy_driver realtek_drvs[] = {
|
||||
{
|
||||
PHY_ID_MATCH_EXACT(0x00008201),
|
||||
@@ -2686,6 +3300,108 @@ static struct phy_driver realtek_drvs[]
|
||||
@@ -2686,6 +3309,108 @@ static struct phy_driver realtek_drvs[]
|
||||
.resume = genphy_resume,
|
||||
.read_mmd = genphy_read_mmd_unsupported,
|
||||
.write_mmd = genphy_write_mmd_unsupported,
|
||||
|
||||
+6
-6
@@ -65,9 +65,9 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+#define RTL826X_SDS_MAX_RESETS 20
|
||||
+
|
||||
#define RTL826X_VEND1_PKG_MODEL 0x103
|
||||
#define RTL826X_VEND1_VERSION_ID 0x104
|
||||
#define RTL826X_VEND1_VERSION_ID_VARIANT GENMASK(2, 0)
|
||||
@@ -2524,6 +2535,70 @@ static int rtl826x_patch_db_init(struct
|
||||
#define RTL826X_VEND1_PKG_MODEL_8251 0x8251
|
||||
#define RTL826X_VEND1_PKG_MODEL_8254 0x8254
|
||||
@@ -2530,6 +2541,70 @@ static int rtl826x_patch_db_init(struct
|
||||
return rtl8264b_phy_patch_db_init(phydev);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
static int rtl826x_probe(struct phy_device *phydev)
|
||||
{
|
||||
struct device *dev = &phydev->mdio.dev;
|
||||
@@ -2535,8 +2610,14 @@ static int rtl826x_probe(struct phy_devi
|
||||
@@ -2541,8 +2616,14 @@ static int rtl826x_probe(struct phy_devi
|
||||
return -ENOMEM;
|
||||
|
||||
priv->enable_pma_low_power = device_property_read_bool(dev, "realtek,enable-pma-low-power");
|
||||
@@ -153,7 +153,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
if (!priv->enable_pma_low_power)
|
||||
phydev_warn(phydev, "PMA low-power suspend disabled\n");
|
||||
|
||||
@@ -3337,6 +3418,7 @@ static struct phy_driver realtek_drvs[]
|
||||
@@ -3346,6 +3427,7 @@ static struct phy_driver realtek_drvs[]
|
||||
}, {
|
||||
.name = "RTL8261BE 10Gbps PHY",
|
||||
.config_init = rtl826x_config_init,
|
||||
@@ -161,7 +161,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
.probe = rtl826x_probe,
|
||||
.get_features = rtl826x_get_features,
|
||||
.suspend = rtl826x_suspend,
|
||||
@@ -3354,6 +3436,7 @@ static struct phy_driver realtek_drvs[]
|
||||
@@ -3363,6 +3445,7 @@ static struct phy_driver realtek_drvs[]
|
||||
}, {
|
||||
.name = "RTL8261N 10Gbps PHY",
|
||||
.config_init = rtl826x_config_init,
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
#define RTL8366RB_POWER_SAVE 0x15
|
||||
#define RTL8366RB_POWER_SAVE_ON BIT(12)
|
||||
|
||||
@@ -2059,6 +2062,66 @@ static int rtl8224_cable_test_get_status
|
||||
@@ -2065,6 +2068,66 @@ static int rtl8224_cable_test_get_status
|
||||
return rtl8224_cable_test_report(phydev, finished);
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
static bool rtlgen_supports_2_5gbps(struct phy_device *phydev)
|
||||
{
|
||||
int val;
|
||||
@@ -3333,6 +3396,8 @@ static struct phy_driver realtek_drvs[]
|
||||
@@ -3342,6 +3405,8 @@ static struct phy_driver realtek_drvs[]
|
||||
PHY_ID_MATCH_EXACT(0x001ccad0),
|
||||
.name = "RTL8224 2.5Gbps PHY",
|
||||
.flags = PHY_POLL_CABLE_TEST,
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
#define RTL8366RB_POWER_SAVE 0x15
|
||||
#define RTL8366RB_POWER_SAVE_ON BIT(12)
|
||||
@@ -2110,9 +2111,40 @@ static int rtl8224_mdi_config_order(stru
|
||||
@@ -2116,9 +2117,40 @@ static int rtl8224_mdi_config_order(stru
|
||||
order ? BIT(port_offset) : 0);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -60,7 +60,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
#define RTL8366RB_POWER_SAVE 0x15
|
||||
#define RTL8366RB_POWER_SAVE_ON BIT(12)
|
||||
|
||||
@@ -1415,6 +1430,144 @@ static int rtl822x_init_phycr1(struct ph
|
||||
@@ -1421,6 +1436,144 @@ static int rtl822x_init_phycr1(struct ph
|
||||
mask, val);
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
static int rtl822x_set_serdes_option_mode(struct phy_device *phydev, bool gen1)
|
||||
{
|
||||
bool has_2500, has_sgmii;
|
||||
@@ -3312,6 +3465,7 @@ static struct phy_driver realtek_drvs[]
|
||||
@@ -3321,6 +3474,7 @@ static struct phy_driver realtek_drvs[]
|
||||
.soft_reset = rtl822x_c45_soft_reset,
|
||||
.get_features = rtl822x_c45_get_features,
|
||||
.config_aneg = rtl822x_c45_config_aneg,
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#define RTL8221B_PHYCR1 0xa430
|
||||
#define RTL8221B_PHYCR1_ALDPS_EN BIT(2)
|
||||
#define RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN BIT(12)
|
||||
@@ -2239,6 +2274,147 @@ exit:
|
||||
@@ -2245,6 +2280,147 @@ exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@
|
||||
static int rtl8224_mdi_config_order(struct phy_device *phydev)
|
||||
{
|
||||
struct device_node *np = phydev->mdio.dev.of_node;
|
||||
@@ -2293,6 +2469,10 @@ static int rtl8224_config_init(struct ph
|
||||
@@ -2299,6 +2475,10 @@ static int rtl8224_config_init(struct ph
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
||||
Reference in new issue
Block a user