From: Steen Hegelund <steen.hegelund@microchip.com>
To: Alexander Couzens <lynxis@fe80.eu>, <netdev@vger.kernel.org>,
<linux-mediatek@lists.infradead.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>
Subject: Re: [PATCH net-next 1/8] net: phy: realtek: rtl8221: allow to configure SERDES mode
Date: Thu, 11 May 2023 09:53:36 +0200 [thread overview]
Message-ID: <60676636bdbeb50e80c02ff24f5b58681689dfba.camel@microchip.com> (raw)
In-Reply-To: <302d982c5550f10d589735fc2e46cf27386c39f4.1683756691.git.daniel@makrotopia.org>
Hi Alexander,
On Thu, 2023-05-11 at 00:53 +0200, Alexander Couzens wrote:
> [You don't often get email from lynxis@fe80.eu. Learn why this is important
> athttps://aka.ms/LearnAboutSenderIdentification ]
>
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the
> content is safe
>
> The rtl8221 supports multiple SERDES modes:
> - SGMII
> - 2500base-x
> - HiSGMII
>
> Further it supports rate adaption on SERDES links to allow
> slow ethernet speeds (10/100/1000mbit) to work on 2500base-x/HiSGMII
> links without reducing the SERDES speed.
>
> When operating without rate adapters the SERDES link will follow the
> ethernet speed.
>
> Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
> ---
> drivers/net/phy/realtek.c | 55 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 55 insertions(+)
>
> diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
> index 3d99fd6664d7..a7dd5a075135 100644
> --- a/drivers/net/phy/realtek.c
> +++ b/drivers/net/phy/realtek.c
> @@ -53,6 +53,15 @@
> RTL8201F_ISR_LINK)
> #define RTL8201F_IER 0x13
>
> +#define RTL8221B_MMD_SERDES_CTRL MDIO_MMD_VEND1
> +#define RTL8221B_MMD_PHY_CTRL MDIO_MMD_VEND2
> +#define RTL8221B_SERDES_OPTION 0x697a
> +#define RTL8221B_SERDES_OPTION_MODE_MASK GENMASK(5, 0)
> +#define RTL8221B_SERDES_OPTION_MODE_2500BASEX_SGMII 0
> +#define RTL8221B_SERDES_OPTION_MODE_HISGMII_SGMII 1
> +#define RTL8221B_SERDES_OPTION_MODE_2500BASEX 2
> +#define RTL8221B_SERDES_OPTION_MODE_HISGMII 3
> +
> #define RTL8366RB_POWER_SAVE 0x15
> #define RTL8366RB_POWER_SAVE_ON BIT(12)
>
> @@ -849,6 +858,48 @@ static irqreturn_t rtl9000a_handle_interrupt(struct
> phy_device *phydev)
> return IRQ_HANDLED;
> }
>
> +static int rtl8221b_config_init(struct phy_device *phydev)
> +{
> + u16 option_mode;
> +
> + switch (phydev->interface) {
> + case PHY_INTERFACE_MODE_2500BASEX:
> + if (!phydev->is_c45) {
> + option_mode = RTL8221B_SERDES_OPTION_MODE_2500BASEX;
> + break;
> + }
> + fallthrough;
> + case PHY_INTERFACE_MODE_SGMII:
> + option_mode = RTL8221B_SERDES_OPTION_MODE_2500BASEX_SGMII;
> + break;
> + default:
> + return 0;
> + }
> +
> + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL,
> + 0x75f3, 0);
Please provide a symbol for the magic value.
> +
> + phy_modify_mmd_changed(phydev, RTL8221B_MMD_SERDES_CTRL,
> + RTL8221B_SERDES_OPTION,
> + RTL8221B_SERDES_OPTION_MODE_MASK, option_mode);
> + switch (option_mode) {
> + case RTL8221B_SERDES_OPTION_MODE_2500BASEX_SGMII:
> + case RTL8221B_SERDES_OPTION_MODE_2500BASEX:
This next section also uses a number of magic values. Please convert to
symbols.
> + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x6a04,
> 0x0503);
> + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x6f10,
> 0xd455);
> + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x6f11,
> 0x8020);
> + break;
> + case RTL8221B_SERDES_OPTION_MODE_HISGMII_SGMII:
> + case RTL8221B_SERDES_OPTION_MODE_HISGMII:
> + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x6a04,
> 0x0503);
> + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x6f10,
> 0xd433);
> + phy_write_mmd(phydev, RTL8221B_MMD_SERDES_CTRL, 0x6f11,
> 0x8020);
> + break;
> + }
> +
> + return 0;
> +}
> +
> static struct phy_driver realtek_drvs[] = {
> {
> PHY_ID_MATCH_EXACT(0x00008201),
> @@ -970,6 +1021,7 @@ static struct phy_driver realtek_drvs[] = {
> .name = "RTL8226B_RTL8221B 2.5Gbps PHY",
> .get_features = rtl822x_get_features,
> .config_aneg = rtl822x_config_aneg,
> + .config_init = rtl8221b_config_init,
> .read_status = rtl822x_read_status,
> .suspend = genphy_suspend,
> .resume = rtlgen_resume,
> @@ -992,6 +1044,7 @@ static struct phy_driver realtek_drvs[] = {
> .name = "RTL8226B-CG_RTL8221B-CG 2.5Gbps PHY",
> .get_features = rtl822x_get_features,
> .config_aneg = rtl822x_config_aneg,
> + .config_init = rtl8221b_config_init,
> .read_status = rtl822x_read_status,
> .suspend = genphy_suspend,
> .resume = rtlgen_resume,
> @@ -1002,6 +1055,7 @@ static struct phy_driver realtek_drvs[] = {
> .name = "RTL8221B-VB-CG 2.5Gbps PHY",
> .get_features = rtl822x_get_features,
> .config_aneg = rtl822x_config_aneg,
> + .config_init = rtl8221b_config_init,
> .read_status = rtl822x_read_status,
> .suspend = genphy_suspend,
> .resume = rtlgen_resume,
> @@ -1012,6 +1066,7 @@ static struct phy_driver realtek_drvs[] = {
> .name = "RTL8221B-VM-CG 2.5Gbps PHY",
> .get_features = rtl822x_get_features,
> .config_aneg = rtl822x_config_aneg,
> + .config_init = rtl8221b_config_init,
> .read_status = rtl822x_read_status,
> .suspend = genphy_suspend,
> .resume = rtlgen_resume,
> --
> 2.40.0
>
>
Otherwise
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Best Regards
Steen
next prev parent reply other threads:[~2023-05-11 7:53 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-10 22:53 [PATCH net-next 0/8] Improvements for RealTek 2.5G Ethernet PHYs Daniel Golle
2023-05-10 22:53 ` [PATCH net-next 1/8] net: phy: realtek: rtl8221: allow to configure SERDES mode Alexander Couzens
2023-05-10 22:56 ` [PATCH " Daniel Golle
2023-05-11 0:34 ` Andrew Lunn
2023-05-11 0:38 ` Andrew Lunn
2023-05-11 11:50 ` Daniel Golle
2023-05-11 0:41 ` Andrew Lunn
2023-05-11 11:53 ` Daniel Golle
2023-05-11 7:53 ` Steen Hegelund [this message]
2023-05-10 22:54 ` [PATCH net-next 2/8] net: phy: realtek: switch interface mode for RTL822x series Chukun Pan
2023-05-10 22:57 ` Daniel Golle
2023-05-10 22:55 ` [PATCH net-next 3/8] net: phy: realtek: use genphy_soft_reset for 2.5G PHYs Daniel Golle
2023-05-10 22:57 ` Daniel Golle
2023-05-10 22:58 ` [PATCH net-next 4/8] net: phy: realtek: disable SGMII in-band AN " Daniel Golle
2023-05-10 22:58 ` [PATCH net-next 5/8] net: phy: realtek: make sure paged read is protected by mutex Daniel Golle
2023-05-10 22:59 ` [PATCH net-next 6/8] net: phy: realtek: use inline functions for 10GbE advertisement Daniel Golle
2023-05-10 22:59 ` [PATCH net-next 7/8] net: phy: realtek: check validity of 10GbE link-partner advertisement Daniel Golle
2023-05-10 23:00 ` [PATCH net-next 8/8] net: phy: realtek: setup ALDPS on RTL8221B Daniel Golle
2023-05-11 0:28 ` [PATCH net-next 0/8] Improvements for RealTek 2.5G Ethernet PHYs Andrew Lunn
2023-05-11 17:14 ` Daniel Golle
2023-05-11 17:30 ` Russell King (Oracle)
2023-05-11 18:09 ` Russell King (Oracle)
2023-05-13 17:52 ` Daniel Golle
2023-05-13 19:24 ` Russell King (Oracle)
2023-05-11 5:29 ` Heiner Kallweit
2023-05-11 11:44 ` Daniel Golle
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=60676636bdbeb50e80c02ff24f5b58681689dfba.camel@microchip.com \
--to=steen.hegelund@microchip.com \
--cc=andrew@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--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