* [PATCH v4 net-next 0/6] rtl8226b/8221b add C45 instances and SerDes switching
@ 2024-04-09 7:30 Eric Woudstra
2024-04-09 7:30 ` [PATCH v4 net-next 1/6] net: phy: realtek: configure SerDes mode for rtl822xb PHYs Eric Woudstra
` (6 more replies)
0 siblings, 7 replies; 10+ messages in thread
From: Eric Woudstra @ 2024-04-09 7:30 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Marek Behún,
Frank Wunderlich, Daniel Golle
Cc: netdev, Eric Woudstra
Based on the comments in [PATCH net-next]
"Realtek RTL822x PHY rework to c45 and SerDes interface switching"
Adds SerDes switching interface between 2500base-x and sgmii for
rtl8221b and rtl8226b.
Add get_rate_matching() for rtl8226b and rtl8221b, reading the serdes
mode from phy.
Driver instances are added for rtl8226b and rtl8221b for Clause 45
access only. The existing code is not touched, they use newly added
functions. They also use the same rtl822xb_config_init() and
rtl822xb_get_rate_matching() as these functions also can be used for
direct Clause 45 access. Also Adds definition of MMC 31 registers,
which cannot be used through C45-over-C22, only when phydev->is_c45
is set.
Change rtlgen_get_speed() so the register value is passed as argument.
Using Clause 45 access, this value is retrieved differently.
Rename it to rtlgen_decode_speed() and add a call to it in
rtl822x_c45_read_status().
Add rtl822x_c45_get_features() to set supported port for rtl8221b.
Then 1 quirk is added for sfp modules known to have a rtl8221b
behind RollBall, Clause 45 only, protocol.
Changed in PATCH v4:
* Changed switch to if statement in rtl822xb_get_rate_matching()
* Removed setting ETHTOOL_LINK_MODE_MII_BIT in rtl822x_c45_get_features()
Changed in PATCH v3:
* Only apply to rtl8221b and rtl8226b phy's
* Set phydev->rate_matching in .config_init()
* Removed OEM SFP fixup for now, as there are modules with the same
vendor name/PN, but with different PHY's. We found rtl8221b, but
also the ty8821, which is not yet supported.
Changed in PATCH v2:
* Set author to Marek for the commit of the new C45 instances
* Separate commit for setting supported ports
* Renamed rtlgen_get_speed to rtlgen_decode_speed
* Always fill in possible interfaces
* Renamed sfp_fixup_oem_2_5g to sfp_fixup_oem_2_5gbaset
* Only update phydev->interface when link is up
Alexander Couzens (1):
net: phy: realtek: configure SerDes mode for rtl822xb PHYs
Eric Woudstra (3):
net: phy: realtek: add get_rate_matching() for rtl822xb PHYs
net: phy: realtek: Change rtlgen_get_speed() to rtlgen_decode_speed()
net: phy: realtek: add rtl822x_c45_get_features() to set supported
port
Marek Behún (2):
net: phy: realtek: Add driver instances for rtl8221b via Clause 45
net: sfp: add quirk for another multigig RollBall transceiver
drivers/net/phy/realtek.c | 324 +++++++++++++++++++++++++++++++++++---
drivers/net/phy/sfp.c | 1 +
2 files changed, 299 insertions(+), 26 deletions(-)
--
2.42.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 net-next 1/6] net: phy: realtek: configure SerDes mode for rtl822xb PHYs
2024-04-09 7:30 [PATCH v4 net-next 0/6] rtl8226b/8221b add C45 instances and SerDes switching Eric Woudstra
@ 2024-04-09 7:30 ` Eric Woudstra
2024-04-09 12:59 ` Andrew Lunn
2024-04-09 7:30 ` [PATCH v4 net-next 2/6] net: phy: realtek: add get_rate_matching() " Eric Woudstra
` (5 subsequent siblings)
6 siblings, 1 reply; 10+ messages in thread
From: Eric Woudstra @ 2024-04-09 7:30 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Marek Behún,
Frank Wunderlich, Daniel Golle
Cc: netdev, Alexander Couzens, Eric Woudstra, Russell King
From: Alexander Couzens <lynxis@fe80.eu>
The rtl8221b and rtl8226b series support switching SerDes mode between
2500base-x and sgmii based on the negotiated copper speed.
Configure this switching mode according to SerDes modes supported by
host.
There is an additional datasheet for RTL8226B/RTL8221B called
"SERDES MODE SETTING FLOW APPLICATION NOTE" where a sequence is
described to setup interface and rate adapter mode.
However, there is no documentation about the meaning of registers
and bits, it's literally just magic numbers and pseudo-code.
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
[ refactored, dropped HiSGMII mode and changed commit message ]
Signed-off-by: Marek Behún <kabel@kernel.org>
[ changed rtl822x_update_interface() to use vendor register ]
[ always fill in possible interfaces ]
[ only apply to rtl8221b and rtl8226b phy's ]
[ set phydev->rate_matching in .config_init() ]
Signed-off-by: Eric Woudstra <ericwouds@gmail.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/realtek.c | 114 ++++++++++++++++++++++++++++++++++++--
1 file changed, 110 insertions(+), 4 deletions(-)
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 1fa70427b2a2..70cd1834a832 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -54,6 +54,16 @@
RTL8201F_ISR_LINK)
#define RTL8201F_IER 0x13
+#define RTL822X_VND1_SERDES_OPTION 0x697a
+#define RTL822X_VND1_SERDES_OPTION_MODE_MASK GENMASK(5, 0)
+#define RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII 0
+#define RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX 2
+
+#define RTL822X_VND1_SERDES_CTRL3 0x7580
+#define RTL822X_VND1_SERDES_CTRL3_MODE_MASK GENMASK(5, 0)
+#define RTL822X_VND1_SERDES_CTRL3_MODE_SGMII 0x02
+#define RTL822X_VND1_SERDES_CTRL3_MODE_2500BASEX 0x16
+
#define RTL8366RB_POWER_SAVE 0x15
#define RTL8366RB_POWER_SAVE_ON BIT(12)
@@ -659,6 +669,63 @@ static int rtl822x_write_mmd(struct phy_device *phydev, int devnum, u16 regnum,
return ret;
}
+static int rtl822xb_config_init(struct phy_device *phydev)
+{
+ bool has_2500, has_sgmii;
+ u16 mode;
+ int ret;
+
+ has_2500 = test_bit(PHY_INTERFACE_MODE_2500BASEX,
+ phydev->host_interfaces) ||
+ phydev->interface == PHY_INTERFACE_MODE_2500BASEX;
+
+ has_sgmii = test_bit(PHY_INTERFACE_MODE_SGMII,
+ phydev->host_interfaces) ||
+ phydev->interface == PHY_INTERFACE_MODE_SGMII;
+
+ /* fill in possible interfaces */
+ __assign_bit(PHY_INTERFACE_MODE_2500BASEX, phydev->possible_interfaces,
+ has_2500);
+ __assign_bit(PHY_INTERFACE_MODE_SGMII, phydev->possible_interfaces,
+ has_sgmii);
+
+ if (!has_2500 && !has_sgmii)
+ return 0;
+
+ /* determine SerDes option mode */
+ if (has_2500 && !has_sgmii) {
+ mode = RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX;
+ phydev->rate_matching = RATE_MATCH_PAUSE;
+ } else {
+ mode = RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII;
+ phydev->rate_matching = RATE_MATCH_NONE;
+ }
+
+ /* the following sequence with magic numbers sets up the SerDes
+ * option mode
+ */
+ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x75f3, 0);
+ if (ret < 0)
+ return ret;
+
+ ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND1,
+ RTL822X_VND1_SERDES_OPTION,
+ RTL822X_VND1_SERDES_OPTION_MODE_MASK,
+ mode);
+ if (ret < 0)
+ return ret;
+
+ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6a04, 0x0503);
+ if (ret < 0)
+ return ret;
+
+ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f10, 0xd455);
+ if (ret < 0)
+ return ret;
+
+ return phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f11, 0x8020);
+}
+
static int rtl822x_get_features(struct phy_device *phydev)
{
int val;
@@ -695,6 +762,28 @@ static int rtl822x_config_aneg(struct phy_device *phydev)
return __genphy_config_aneg(phydev, ret);
}
+static void rtl822xb_update_interface(struct phy_device *phydev)
+{
+ int val;
+
+ if (!phydev->link)
+ return;
+
+ /* Change interface according to serdes mode */
+ val = phy_read_mmd(phydev, MDIO_MMD_VEND1, RTL822X_VND1_SERDES_CTRL3);
+ if (val < 0)
+ return;
+
+ switch (val & RTL822X_VND1_SERDES_CTRL3_MODE_MASK) {
+ case RTL822X_VND1_SERDES_CTRL3_MODE_2500BASEX:
+ phydev->interface = PHY_INTERFACE_MODE_2500BASEX;
+ break;
+ case RTL822X_VND1_SERDES_CTRL3_MODE_SGMII:
+ phydev->interface = PHY_INTERFACE_MODE_SGMII;
+ break;
+ }
+}
+
static int rtl822x_read_status(struct phy_device *phydev)
{
int ret;
@@ -716,6 +805,19 @@ static int rtl822x_read_status(struct phy_device *phydev)
return rtlgen_get_speed(phydev);
}
+static int rtl822xb_read_status(struct phy_device *phydev)
+{
+ int ret;
+
+ ret = rtl822x_read_status(phydev);
+ if (ret < 0)
+ return ret;
+
+ rtl822xb_update_interface(phydev);
+
+ return 0;
+}
+
static bool rtlgen_supports_2_5gbps(struct phy_device *phydev)
{
int val;
@@ -988,7 +1090,8 @@ static struct phy_driver realtek_drvs[] = {
.name = "RTL8226B_RTL8221B 2.5Gbps PHY",
.get_features = rtl822x_get_features,
.config_aneg = rtl822x_config_aneg,
- .read_status = rtl822x_read_status,
+ .config_init = rtl822xb_config_init,
+ .read_status = rtl822xb_read_status,
.suspend = genphy_suspend,
.resume = rtlgen_resume,
.read_page = rtl821x_read_page,
@@ -1010,7 +1113,8 @@ static struct phy_driver realtek_drvs[] = {
.name = "RTL8226B-CG_RTL8221B-CG 2.5Gbps PHY",
.get_features = rtl822x_get_features,
.config_aneg = rtl822x_config_aneg,
- .read_status = rtl822x_read_status,
+ .config_init = rtl822xb_config_init,
+ .read_status = rtl822xb_read_status,
.suspend = genphy_suspend,
.resume = rtlgen_resume,
.read_page = rtl821x_read_page,
@@ -1020,7 +1124,8 @@ static struct phy_driver realtek_drvs[] = {
.name = "RTL8221B-VB-CG 2.5Gbps PHY",
.get_features = rtl822x_get_features,
.config_aneg = rtl822x_config_aneg,
- .read_status = rtl822x_read_status,
+ .config_init = rtl822xb_config_init,
+ .read_status = rtl822xb_read_status,
.suspend = genphy_suspend,
.resume = rtlgen_resume,
.read_page = rtl821x_read_page,
@@ -1030,7 +1135,8 @@ static struct phy_driver realtek_drvs[] = {
.name = "RTL8221B-VM-CG 2.5Gbps PHY",
.get_features = rtl822x_get_features,
.config_aneg = rtl822x_config_aneg,
- .read_status = rtl822x_read_status,
+ .config_init = rtl822xb_config_init,
+ .read_status = rtl822xb_read_status,
.suspend = genphy_suspend,
.resume = rtlgen_resume,
.read_page = rtl821x_read_page,
--
2.42.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 net-next 2/6] net: phy: realtek: add get_rate_matching() for rtl822xb PHYs
2024-04-09 7:30 [PATCH v4 net-next 0/6] rtl8226b/8221b add C45 instances and SerDes switching Eric Woudstra
2024-04-09 7:30 ` [PATCH v4 net-next 1/6] net: phy: realtek: configure SerDes mode for rtl822xb PHYs Eric Woudstra
@ 2024-04-09 7:30 ` Eric Woudstra
2024-04-09 7:30 ` [PATCH v4 net-next 3/6] net: phy: realtek: Add driver instances for rtl8221b via Clause 45 Eric Woudstra
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Eric Woudstra @ 2024-04-09 7:30 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Marek Behún,
Frank Wunderlich, Daniel Golle
Cc: netdev, Eric Woudstra
Uses vendor register to determine if SerDes is setup in rate-matching mode.
Rate-matching only supported when SerDes is set to 2500base-x.
Signed-off-by: Eric Woudstra <ericwouds@gmail.com>
---
drivers/net/phy/realtek.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 70cd1834a832..08d338271bd0 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -726,6 +726,27 @@ static int rtl822xb_config_init(struct phy_device *phydev)
return phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f11, 0x8020);
}
+static int rtl822xb_get_rate_matching(struct phy_device *phydev,
+ phy_interface_t iface)
+{
+ int val;
+
+ /* Only rate matching at 2500base-x */
+ if (iface != PHY_INTERFACE_MODE_2500BASEX)
+ return RATE_MATCH_NONE;
+
+ val = phy_read_mmd(phydev, MDIO_MMD_VEND1, RTL822X_VND1_SERDES_OPTION);
+ if (val < 0)
+ return val;
+
+ if ((val & RTL822X_VND1_SERDES_OPTION_MODE_MASK) ==
+ RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX)
+ return RATE_MATCH_PAUSE;
+
+ /* RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII */
+ return RATE_MATCH_NONE;
+}
+
static int rtl822x_get_features(struct phy_device *phydev)
{
int val;
@@ -1091,6 +1112,7 @@ static struct phy_driver realtek_drvs[] = {
.get_features = rtl822x_get_features,
.config_aneg = rtl822x_config_aneg,
.config_init = rtl822xb_config_init,
+ .get_rate_matching = rtl822xb_get_rate_matching,
.read_status = rtl822xb_read_status,
.suspend = genphy_suspend,
.resume = rtlgen_resume,
@@ -1114,6 +1136,7 @@ static struct phy_driver realtek_drvs[] = {
.get_features = rtl822x_get_features,
.config_aneg = rtl822x_config_aneg,
.config_init = rtl822xb_config_init,
+ .get_rate_matching = rtl822xb_get_rate_matching,
.read_status = rtl822xb_read_status,
.suspend = genphy_suspend,
.resume = rtlgen_resume,
@@ -1125,6 +1148,7 @@ static struct phy_driver realtek_drvs[] = {
.get_features = rtl822x_get_features,
.config_aneg = rtl822x_config_aneg,
.config_init = rtl822xb_config_init,
+ .get_rate_matching = rtl822xb_get_rate_matching,
.read_status = rtl822xb_read_status,
.suspend = genphy_suspend,
.resume = rtlgen_resume,
@@ -1136,6 +1160,7 @@ static struct phy_driver realtek_drvs[] = {
.get_features = rtl822x_get_features,
.config_aneg = rtl822x_config_aneg,
.config_init = rtl822xb_config_init,
+ .get_rate_matching = rtl822xb_get_rate_matching,
.read_status = rtl822xb_read_status,
.suspend = genphy_suspend,
.resume = rtlgen_resume,
--
2.42.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 net-next 3/6] net: phy: realtek: Add driver instances for rtl8221b via Clause 45
2024-04-09 7:30 [PATCH v4 net-next 0/6] rtl8226b/8221b add C45 instances and SerDes switching Eric Woudstra
2024-04-09 7:30 ` [PATCH v4 net-next 1/6] net: phy: realtek: configure SerDes mode for rtl822xb PHYs Eric Woudstra
2024-04-09 7:30 ` [PATCH v4 net-next 2/6] net: phy: realtek: add get_rate_matching() " Eric Woudstra
@ 2024-04-09 7:30 ` Eric Woudstra
2024-04-09 7:30 ` [PATCH v4 net-next 4/6] net: phy: realtek: Change rtlgen_get_speed() to rtlgen_decode_speed() Eric Woudstra
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Eric Woudstra @ 2024-04-09 7:30 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Marek Behún,
Frank Wunderlich, Daniel Golle
Cc: netdev, Eric Woudstra, Russell King
From: Marek Behún <kabel@kernel.org>
Collected from several commits in [PATCH net-next]
"Realtek RTL822x PHY rework to c45 and SerDes interface switching"
The instances are used by Clause 45 only accessible PHY's on several sfp
modules, which are using RollBall protocol.
Signed-off-by: Marek Behún <kabel@kernel.org>
[ Added matching functions to differentiate C45 instances ]
Signed-off-by: Eric Woudstra <ericwouds@gmail.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/realtek.c | 135 ++++++++++++++++++++++++++++++++++++--
1 file changed, 131 insertions(+), 4 deletions(-)
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 08d338271bd0..f4a6f073a1f7 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -64,6 +64,13 @@
#define RTL822X_VND1_SERDES_CTRL3_MODE_SGMII 0x02
#define RTL822X_VND1_SERDES_CTRL3_MODE_2500BASEX 0x16
+/* RTL822X_VND2_XXXXX registers are only accessible when phydev->is_c45
+ * is set, they cannot be accessed by C45-over-C22.
+ */
+#define RTL822X_VND2_GBCR 0xa412
+
+#define RTL822X_VND2_GANLPAR 0xa414
+
#define RTL8366RB_POWER_SAVE 0x15
#define RTL8366RB_POWER_SAVE_ON BIT(12)
@@ -74,6 +81,9 @@
#define RTL_GENERIC_PHYID 0x001cc800
#define RTL_8211FVD_PHYID 0x001cc878
+#define RTL_8221B_VB_CG 0x001cc849
+#define RTL_8221B_VN_CG 0x001cc84a
+#define RTL_8251B 0x001cc862
MODULE_DESCRIPTION("Realtek PHY driver");
MODULE_AUTHOR("Johnson Leung");
@@ -839,6 +849,67 @@ static int rtl822xb_read_status(struct phy_device *phydev)
return 0;
}
+static int rtl822x_c45_config_aneg(struct phy_device *phydev)
+{
+ bool changed = false;
+ int ret, val;
+
+ if (phydev->autoneg == AUTONEG_DISABLE)
+ return genphy_c45_pma_setup_forced(phydev);
+
+ ret = genphy_c45_an_config_aneg(phydev);
+ if (ret < 0)
+ return ret;
+ if (ret > 0)
+ changed = true;
+
+ val = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising);
+
+ /* Vendor register as C45 has no standardized support for 1000BaseT */
+ ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, RTL822X_VND2_GBCR,
+ ADVERTISE_1000FULL, val);
+ if (ret < 0)
+ return ret;
+ if (ret > 0)
+ changed = true;
+
+ return genphy_c45_check_and_restart_aneg(phydev, changed);
+}
+
+static int rtl822x_c45_read_status(struct phy_device *phydev)
+{
+ int ret, val;
+
+ ret = genphy_c45_read_status(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* Vendor register as C45 has no standardized support for 1000BaseT */
+ if (phydev->autoneg == AUTONEG_ENABLE) {
+ val = phy_read_mmd(phydev, MDIO_MMD_VEND2,
+ RTL822X_VND2_GANLPAR);
+ if (val < 0)
+ return val;
+
+ mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val);
+ }
+
+ return 0;
+}
+
+static int rtl822xb_c45_read_status(struct phy_device *phydev)
+{
+ int ret;
+
+ ret = rtl822x_c45_read_status(phydev);
+ if (ret < 0)
+ return ret;
+
+ rtl822xb_update_interface(phydev);
+
+ return 0;
+}
+
static bool rtlgen_supports_2_5gbps(struct phy_device *phydev)
{
int val;
@@ -862,6 +933,35 @@ static int rtl8226_match_phy_device(struct phy_device *phydev)
rtlgen_supports_2_5gbps(phydev);
}
+static int rtlgen_is_c45_match(struct phy_device *phydev, unsigned int id,
+ bool is_c45)
+{
+ if (phydev->is_c45)
+ return is_c45 && (id == phydev->c45_ids.device_ids[1]);
+ else
+ return !is_c45 && (id == phydev->phy_id);
+}
+
+static int rtl8221b_vb_cg_c22_match_phy_device(struct phy_device *phydev)
+{
+ return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false);
+}
+
+static int rtl8221b_vb_cg_c45_match_phy_device(struct phy_device *phydev)
+{
+ return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, true);
+}
+
+static int rtl8221b_vn_cg_c22_match_phy_device(struct phy_device *phydev)
+{
+ return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, false);
+}
+
+static int rtl8221b_vn_cg_c45_match_phy_device(struct phy_device *phydev)
+{
+ return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, true);
+}
+
static int rtlgen_resume(struct phy_device *phydev)
{
int ret = genphy_resume(phydev);
@@ -872,6 +972,15 @@ static int rtlgen_resume(struct phy_device *phydev)
return ret;
}
+static int rtlgen_c45_resume(struct phy_device *phydev)
+{
+ int ret = genphy_c45_pma_resume(phydev);
+
+ msleep(20);
+
+ return ret;
+}
+
static int rtl9000a_config_init(struct phy_device *phydev)
{
phydev->autoneg = AUTONEG_DISABLE;
@@ -1143,8 +1252,8 @@ static struct phy_driver realtek_drvs[] = {
.read_page = rtl821x_read_page,
.write_page = rtl821x_write_page,
}, {
- PHY_ID_MATCH_EXACT(0x001cc849),
- .name = "RTL8221B-VB-CG 2.5Gbps PHY",
+ .match_phy_device = rtl8221b_vb_cg_c22_match_phy_device,
+ .name = "RTL8221B-VB-CG 2.5Gbps PHY (C22)",
.get_features = rtl822x_get_features,
.config_aneg = rtl822x_config_aneg,
.config_init = rtl822xb_config_init,
@@ -1155,8 +1264,17 @@ static struct phy_driver realtek_drvs[] = {
.read_page = rtl821x_read_page,
.write_page = rtl821x_write_page,
}, {
- PHY_ID_MATCH_EXACT(0x001cc84a),
- .name = "RTL8221B-VM-CG 2.5Gbps PHY",
+ .match_phy_device = rtl8221b_vb_cg_c45_match_phy_device,
+ .name = "RTL8221B-VB-CG 2.5Gbps PHY (C45)",
+ .config_init = rtl822xb_config_init,
+ .get_rate_matching = rtl822xb_get_rate_matching,
+ .config_aneg = rtl822x_c45_config_aneg,
+ .read_status = rtl822xb_c45_read_status,
+ .suspend = genphy_c45_pma_suspend,
+ .resume = rtlgen_c45_resume,
+ }, {
+ .match_phy_device = rtl8221b_vn_cg_c22_match_phy_device,
+ .name = "RTL8221B-VM-CG 2.5Gbps PHY (C22)",
.get_features = rtl822x_get_features,
.config_aneg = rtl822x_config_aneg,
.config_init = rtl822xb_config_init,
@@ -1166,6 +1284,15 @@ static struct phy_driver realtek_drvs[] = {
.resume = rtlgen_resume,
.read_page = rtl821x_read_page,
.write_page = rtl821x_write_page,
+ }, {
+ .match_phy_device = rtl8221b_vn_cg_c45_match_phy_device,
+ .name = "RTL8221B-VN-CG 2.5Gbps PHY (C45)",
+ .config_init = rtl822xb_config_init,
+ .get_rate_matching = rtl822xb_get_rate_matching,
+ .config_aneg = rtl822x_c45_config_aneg,
+ .read_status = rtl822xb_c45_read_status,
+ .suspend = genphy_c45_pma_suspend,
+ .resume = rtlgen_c45_resume,
}, {
PHY_ID_MATCH_EXACT(0x001cc862),
.name = "RTL8251B 5Gbps PHY",
--
2.42.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 net-next 4/6] net: phy: realtek: Change rtlgen_get_speed() to rtlgen_decode_speed()
2024-04-09 7:30 [PATCH v4 net-next 0/6] rtl8226b/8221b add C45 instances and SerDes switching Eric Woudstra
` (2 preceding siblings ...)
2024-04-09 7:30 ` [PATCH v4 net-next 3/6] net: phy: realtek: Add driver instances for rtl8221b via Clause 45 Eric Woudstra
@ 2024-04-09 7:30 ` Eric Woudstra
2024-04-09 7:30 ` [PATCH v4 net-next 5/6] net: phy: realtek: add rtl822x_c45_get_features() to set supported port Eric Woudstra
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Eric Woudstra @ 2024-04-09 7:30 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Marek Behún,
Frank Wunderlich, Daniel Golle
Cc: netdev, Eric Woudstra, Russell King
The value of the register to determine the speed, is retrieved
differently when using Clause 45 only. To use the rtlgen_get_speed()
function in this case, pass the value of the register as argument to
rtlgen_get_speed(). The function would then always return 0, so change it
to void. A better name for this function now is rtlgen_decode_speed().
Replace a call to genphy_read_status() followed by rtlgen_get_speed()
with a call to rtlgen_read_status() in rtl822x_read_status().
Add reading speed to rtl822x_c45_read_status().
Signed-off-by: Eric Woudstra <ericwouds@gmail.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/realtek.c | 46 +++++++++++++++++++++------------------
1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index f4a6f073a1f7..901c6f7b04c2 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -71,6 +71,8 @@
#define RTL822X_VND2_GANLPAR 0xa414
+#define RTL822X_VND2_PHYSR 0xa434
+
#define RTL8366RB_POWER_SAVE 0x15
#define RTL8366RB_POWER_SAVE_ON BIT(12)
@@ -551,17 +553,8 @@ static int rtl8366rb_config_init(struct phy_device *phydev)
}
/* get actual speed to cover the downshift case */
-static int rtlgen_get_speed(struct phy_device *phydev)
+static void rtlgen_decode_speed(struct phy_device *phydev, int val)
{
- int val;
-
- if (!phydev->link)
- return 0;
-
- val = phy_read_paged(phydev, 0xa43, 0x12);
- if (val < 0)
- return val;
-
switch (val & RTLGEN_SPEED_MASK) {
case 0x0000:
phydev->speed = SPEED_10;
@@ -584,19 +577,26 @@ static int rtlgen_get_speed(struct phy_device *phydev)
default:
break;
}
-
- return 0;
}
static int rtlgen_read_status(struct phy_device *phydev)
{
- int ret;
+ int ret, val;
ret = genphy_read_status(phydev);
if (ret < 0)
return ret;
- return rtlgen_get_speed(phydev);
+ if (!phydev->link)
+ return 0;
+
+ val = phy_read_paged(phydev, 0xa43, 0x12);
+ if (val < 0)
+ return val;
+
+ rtlgen_decode_speed(phydev, val);
+
+ return 0;
}
static int rtlgen_read_mmd(struct phy_device *phydev, int devnum, u16 regnum)
@@ -817,8 +817,6 @@ static void rtl822xb_update_interface(struct phy_device *phydev)
static int rtl822x_read_status(struct phy_device *phydev)
{
- int ret;
-
if (phydev->autoneg == AUTONEG_ENABLE) {
int lpadv = phy_read_paged(phydev, 0xa5d, 0x13);
@@ -829,11 +827,7 @@ static int rtl822x_read_status(struct phy_device *phydev)
lpadv);
}
- ret = genphy_read_status(phydev);
- if (ret < 0)
- return ret;
-
- return rtlgen_get_speed(phydev);
+ return rtlgen_read_status(phydev);
}
static int rtl822xb_read_status(struct phy_device *phydev)
@@ -894,6 +888,16 @@ static int rtl822x_c45_read_status(struct phy_device *phydev)
mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val);
}
+ if (!phydev->link)
+ return 0;
+
+ /* Read actual speed from vendor register. */
+ val = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL822X_VND2_PHYSR);
+ if (val < 0)
+ return val;
+
+ rtlgen_decode_speed(phydev, val);
+
return 0;
}
--
2.42.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 net-next 5/6] net: phy: realtek: add rtl822x_c45_get_features() to set supported port
2024-04-09 7:30 [PATCH v4 net-next 0/6] rtl8226b/8221b add C45 instances and SerDes switching Eric Woudstra
` (3 preceding siblings ...)
2024-04-09 7:30 ` [PATCH v4 net-next 4/6] net: phy: realtek: Change rtlgen_get_speed() to rtlgen_decode_speed() Eric Woudstra
@ 2024-04-09 7:30 ` Eric Woudstra
2024-04-09 12:55 ` Andrew Lunn
2024-04-09 7:30 ` [PATCH v4 net-next 6/6] net: sfp: add quirk for another multigig RollBall transceiver Eric Woudstra
2024-04-12 9:20 ` [PATCH v4 net-next 0/6] rtl8226b/8221b add C45 instances and SerDes switching patchwork-bot+netdevbpf
6 siblings, 1 reply; 10+ messages in thread
From: Eric Woudstra @ 2024-04-09 7:30 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Marek Behún,
Frank Wunderlich, Daniel Golle
Cc: netdev, Eric Woudstra
Sets ETHTOOL_LINK_MODE_TP_BIT in phydev->supported.
Signed-off-by: Eric Woudstra <ericwouds@gmail.com>
---
drivers/net/phy/realtek.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 901c6f7b04c2..7ab41f95dae5 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -843,6 +843,14 @@ static int rtl822xb_read_status(struct phy_device *phydev)
return 0;
}
+static int rtl822x_c45_get_features(struct phy_device *phydev)
+{
+ linkmode_set_bit(ETHTOOL_LINK_MODE_TP_BIT,
+ phydev->supported);
+
+ return genphy_c45_pma_read_abilities(phydev);
+}
+
static int rtl822x_c45_config_aneg(struct phy_device *phydev)
{
bool changed = false;
@@ -1272,6 +1280,7 @@ static struct phy_driver realtek_drvs[] = {
.name = "RTL8221B-VB-CG 2.5Gbps PHY (C45)",
.config_init = rtl822xb_config_init,
.get_rate_matching = rtl822xb_get_rate_matching,
+ .get_features = rtl822x_c45_get_features,
.config_aneg = rtl822x_c45_config_aneg,
.read_status = rtl822xb_c45_read_status,
.suspend = genphy_c45_pma_suspend,
@@ -1293,6 +1302,7 @@ static struct phy_driver realtek_drvs[] = {
.name = "RTL8221B-VN-CG 2.5Gbps PHY (C45)",
.config_init = rtl822xb_config_init,
.get_rate_matching = rtl822xb_get_rate_matching,
+ .get_features = rtl822x_c45_get_features,
.config_aneg = rtl822x_c45_config_aneg,
.read_status = rtl822xb_c45_read_status,
.suspend = genphy_c45_pma_suspend,
--
2.42.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 net-next 6/6] net: sfp: add quirk for another multigig RollBall transceiver
2024-04-09 7:30 [PATCH v4 net-next 0/6] rtl8226b/8221b add C45 instances and SerDes switching Eric Woudstra
` (4 preceding siblings ...)
2024-04-09 7:30 ` [PATCH v4 net-next 5/6] net: phy: realtek: add rtl822x_c45_get_features() to set supported port Eric Woudstra
@ 2024-04-09 7:30 ` Eric Woudstra
2024-04-12 9:20 ` [PATCH v4 net-next 0/6] rtl8226b/8221b add C45 instances and SerDes switching patchwork-bot+netdevbpf
6 siblings, 0 replies; 10+ messages in thread
From: Eric Woudstra @ 2024-04-09 7:30 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Marek Behún,
Frank Wunderlich, Daniel Golle
Cc: netdev, Eric Woudstra, Russell King
From: Marek Behún <kabel@kernel.org>
Add quirk for another RollBall copper transceiver: Turris RTSFP-2.5G,
containing 2.5g capable RTL8221B PHY.
Signed-off-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Eric Woudstra <ericwouds@gmail.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/sfp.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index f75c9eb3958e..6e7639fc64dd 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -506,6 +506,7 @@ static const struct sfp_quirk sfp_quirks[] = {
SFP_QUIRK_M("OEM", "SFP-2.5G-T", sfp_quirk_oem_2_5g),
SFP_QUIRK_F("OEM", "RTSFP-10", sfp_fixup_rollball_cc),
SFP_QUIRK_F("OEM", "RTSFP-10G", sfp_fixup_rollball_cc),
+ SFP_QUIRK_F("Turris", "RTSFP-2.5G", sfp_fixup_rollball),
SFP_QUIRK_F("Turris", "RTSFP-10", sfp_fixup_rollball),
SFP_QUIRK_F("Turris", "RTSFP-10G", sfp_fixup_rollball),
};
--
2.42.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v4 net-next 5/6] net: phy: realtek: add rtl822x_c45_get_features() to set supported port
2024-04-09 7:30 ` [PATCH v4 net-next 5/6] net: phy: realtek: add rtl822x_c45_get_features() to set supported port Eric Woudstra
@ 2024-04-09 12:55 ` Andrew Lunn
0 siblings, 0 replies; 10+ messages in thread
From: Andrew Lunn @ 2024-04-09 12:55 UTC (permalink / raw)
To: Eric Woudstra
Cc: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Marek Behún, Frank Wunderlich,
Daniel Golle, netdev
On Tue, Apr 09, 2024 at 09:30:15AM +0200, Eric Woudstra wrote:
> Sets ETHTOOL_LINK_MODE_TP_BIT in phydev->supported.
>
> Signed-off-by: Eric Woudstra <ericwouds@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 net-next 1/6] net: phy: realtek: configure SerDes mode for rtl822xb PHYs
2024-04-09 7:30 ` [PATCH v4 net-next 1/6] net: phy: realtek: configure SerDes mode for rtl822xb PHYs Eric Woudstra
@ 2024-04-09 12:59 ` Andrew Lunn
0 siblings, 0 replies; 10+ messages in thread
From: Andrew Lunn @ 2024-04-09 12:59 UTC (permalink / raw)
To: Eric Woudstra
Cc: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Marek Behún, Frank Wunderlich,
Daniel Golle, netdev, Alexander Couzens, Russell King
On Tue, Apr 09, 2024 at 09:30:11AM +0200, Eric Woudstra wrote:
> From: Alexander Couzens <lynxis@fe80.eu>
>
> The rtl8221b and rtl8226b series support switching SerDes mode between
> 2500base-x and sgmii based on the negotiated copper speed.
>
> Configure this switching mode according to SerDes modes supported by
> host.
>
> There is an additional datasheet for RTL8226B/RTL8221B called
> "SERDES MODE SETTING FLOW APPLICATION NOTE" where a sequence is
> described to setup interface and rate adapter mode.
>
> However, there is no documentation about the meaning of registers
> and bits, it's literally just magic numbers and pseudo-code.
>
> Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
> [ refactored, dropped HiSGMII mode and changed commit message ]
> Signed-off-by: Marek Behún <kabel@kernel.org>
> [ changed rtl822x_update_interface() to use vendor register ]
> [ always fill in possible interfaces ]
> [ only apply to rtl8221b and rtl8226b phy's ]
> [ set phydev->rate_matching in .config_init() ]
> Signed-off-by: Eric Woudstra <ericwouds@gmail.com>
>
> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Hi Eric
The ordering of these tags should put your Signed-off-by last.
Reviewed-by: should come before them, without any blank lines. As the
patch makes it way towards mainline, each Maintainer will add a
Signed-off: by, and it is nice to keep them together.
This is not enough to need a respin, but please remember this for
future patches.
Andrew
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 net-next 0/6] rtl8226b/8221b add C45 instances and SerDes switching
2024-04-09 7:30 [PATCH v4 net-next 0/6] rtl8226b/8221b add C45 instances and SerDes switching Eric Woudstra
` (5 preceding siblings ...)
2024-04-09 7:30 ` [PATCH v4 net-next 6/6] net: sfp: add quirk for another multigig RollBall transceiver Eric Woudstra
@ 2024-04-12 9:20 ` patchwork-bot+netdevbpf
6 siblings, 0 replies; 10+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-04-12 9:20 UTC (permalink / raw)
To: Eric Woudstra
Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, kabel,
frank-w, daniel, netdev
Hello:
This series was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:
On Tue, 9 Apr 2024 09:30:10 +0200 you wrote:
> Based on the comments in [PATCH net-next]
> "Realtek RTL822x PHY rework to c45 and SerDes interface switching"
>
> Adds SerDes switching interface between 2500base-x and sgmii for
> rtl8221b and rtl8226b.
>
> Add get_rate_matching() for rtl8226b and rtl8221b, reading the serdes
> mode from phy.
>
> [...]
Here is the summary with links:
- [v4,net-next,1/6] net: phy: realtek: configure SerDes mode for rtl822xb PHYs
https://git.kernel.org/netdev/net-next/c/deb8af524350
- [v4,net-next,2/6] net: phy: realtek: add get_rate_matching() for rtl822xb PHYs
https://git.kernel.org/netdev/net-next/c/c189dbd73824
- [v4,net-next,3/6] net: phy: realtek: Add driver instances for rtl8221b via Clause 45
https://git.kernel.org/netdev/net-next/c/ad5ce743a6b0
- [v4,net-next,4/6] net: phy: realtek: Change rtlgen_get_speed() to rtlgen_decode_speed()
https://git.kernel.org/netdev/net-next/c/2e4ea707c7e0
- [v4,net-next,5/6] net: phy: realtek: add rtl822x_c45_get_features() to set supported port
https://git.kernel.org/netdev/net-next/c/2d9ce6486270
- [v4,net-next,6/6] net: sfp: add quirk for another multigig RollBall transceiver
https://git.kernel.org/netdev/net-next/c/1c77c721916a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-04-12 9:20 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-09 7:30 [PATCH v4 net-next 0/6] rtl8226b/8221b add C45 instances and SerDes switching Eric Woudstra
2024-04-09 7:30 ` [PATCH v4 net-next 1/6] net: phy: realtek: configure SerDes mode for rtl822xb PHYs Eric Woudstra
2024-04-09 12:59 ` Andrew Lunn
2024-04-09 7:30 ` [PATCH v4 net-next 2/6] net: phy: realtek: add get_rate_matching() " Eric Woudstra
2024-04-09 7:30 ` [PATCH v4 net-next 3/6] net: phy: realtek: Add driver instances for rtl8221b via Clause 45 Eric Woudstra
2024-04-09 7:30 ` [PATCH v4 net-next 4/6] net: phy: realtek: Change rtlgen_get_speed() to rtlgen_decode_speed() Eric Woudstra
2024-04-09 7:30 ` [PATCH v4 net-next 5/6] net: phy: realtek: add rtl822x_c45_get_features() to set supported port Eric Woudstra
2024-04-09 12:55 ` Andrew Lunn
2024-04-09 7:30 ` [PATCH v4 net-next 6/6] net: sfp: add quirk for another multigig RollBall transceiver Eric Woudstra
2024-04-12 9:20 ` [PATCH v4 net-next 0/6] rtl8226b/8221b add C45 instances and SerDes switching patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).