From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Eric Woudstra <ericwouds@gmail.com>
Cc: "Andrew Lunn" <andrew@lunn.ch>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Marek Behún" <kabel@kernel.org>,
"Frank Wunderlich" <frank-w@public-files.de>,
"Daniel Golle" <daniel@makrotopia.org>,
netdev@vger.kernel.org, "Alexander Couzens" <lynxis@fe80.eu>
Subject: Re: [PATCH RFC net-next 1/6] net: phy: realtek: configure SerDes mode for rtl822x/8251b PHYs
Date: Tue, 27 Feb 2024 10:36:05 +0000 [thread overview]
Message-ID: <Zd27FaFlVqaQVV9B@shell.armlinux.org.uk> (raw)
In-Reply-To: <20240227075151.793496-2-ericwouds@gmail.com>
On Tue, Feb 27, 2024 at 08:51:46AM +0100, Eric Woudstra wrote:
> From: Alexander Couzens <lynxis@fe80.eu>
>
> The rtl822x series and rtl8251b 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.
>
> 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 ]
> Signed-off-by: Eric Woudstra <ericwouds@gmail.com>
> ---
> drivers/net/phy/realtek.c | 96 ++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 94 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
> index 1fa70427b2a2..67cffe9b7d5d 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,60 @@ static int rtl822x_write_mmd(struct phy_device *phydev, int devnum, u16 regnum,
> return ret;
> }
>
> +static int rtl822x_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;
> +
> + if (!has_2500 && !has_sgmii)
> + return 0;
> +
> + /* 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);
It would be nice to fill phydev->possible_interfaces even if
phydev->host_interfaces has not been populated. That means that the
"newer" paths in phylink can be always used during validation.
In other words, move the if() test just above this to below it.
> +
> + /* determine SerDes option mode */
> + if (has_2500 && !has_sgmii)
> + mode = RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX;
> + else
> + mode = RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII;
> +
> + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x75f3, 0);
> + if (ret < 0)
> + return ret;
It would be nice to know what this is doing.
> +
> + 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;
> +
> + /* the following 3 writes into SerDes control are needed for 2500base-x
> + * mode to work properly
> + */
> + 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);
Also for these. "to work properly" is too vague - is it to do with the
inband signalling?
> +}
> +
> static int rtl822x_get_features(struct phy_device *phydev)
> {
> int val;
> @@ -695,6 +759,25 @@ static int rtl822x_config_aneg(struct phy_device *phydev)
> return __genphy_config_aneg(phydev, ret);
> }
>
> +static void rtl822x_update_interface(struct phy_device *phydev)
> +{
> + int val;
> +
> + /* 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;
> + }
Just to confirm that this doesn't change existing device behaviour?
Thanks.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2024-02-27 10:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 7:51 [PATCH RFC net-next 0/6] rtl8221b/8251b add C45 instances and SerDes switching Eric Woudstra
2024-02-27 7:51 ` [PATCH RFC net-next 1/6] net: phy: realtek: configure SerDes mode for rtl822x/8251b PHYs Eric Woudstra
2024-02-27 10:36 ` Russell King (Oracle) [this message]
2024-02-27 13:34 ` Eric Woudstra
2024-02-29 12:50 ` Marek Behún
2024-02-29 16:34 ` Daniel Golle
2024-03-01 9:24 ` Marek Behún
2024-02-27 7:51 ` [PATCH RFC net-next 2/6] net: phy: realtek: add get_rate_matching() " Eric Woudstra
2024-02-27 10:37 ` Russell King (Oracle)
2024-02-27 7:51 ` [PATCH RFC net-next 3/6] net: phy: realtek: rtlgen_get_speed(): Pass register value as argument Eric Woudstra
2024-02-27 10:38 ` Russell King (Oracle)
2024-02-27 7:51 ` [PATCH RFC net-next 4/6] net: phy: realtek: Add driver instances for rtl8221b/8251b via Clause 45 Eric Woudstra
2024-02-27 10:41 ` Russell King (Oracle)
2024-03-01 9:29 ` Marek Behún
2024-02-27 7:51 ` [PATCH RFC net-next 5/6] net: phy: sfp: Fixup for OEM SFP-2.5G-T module Eric Woudstra
2024-02-27 10:42 ` Russell King (Oracle)
2024-02-27 7:51 ` [PATCH RFC net-next 6/6] net: sfp: add quirk for another multigig RollBall transceiver Eric Woudstra
2024-02-27 10:42 ` Russell King (Oracle)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zd27FaFlVqaQVV9B@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=ericwouds@gmail.com \
--cc=frank-w@public-files.de \
--cc=hkallweit1@gmail.com \
--cc=kabel@kernel.org \
--cc=kuba@kernel.org \
--cc=lynxis@fe80.eu \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).