From: Simon Horman <horms@kernel.org>
To: Daniel Golle <daniel@makrotopia.org>
Cc: Felix Fietkau <nbd@nbd.name>, John Crispin <john@phrozen.org>,
Sean Wang <sean.wang@mediatek.com>,
Mark Lee <Mark-MC.Lee@mediatek.com>,
Lorenzo Bianconi <lorenzo@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Russell King <linux@armlinux.org.uk>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, llvm@lists.linux.dev,
ndesaulniers@google.com, nathan@kernel.org, trix@redhat.com
Subject: Re: [PATCH net-next] net: ethernet: mtk_eth_soc: add paths and SerDes modes for MT7988
Date: Sat, 16 Sep 2023 20:00:51 +0200 [thread overview]
Message-ID: <20230916180051.GH1125562@kernel.org> (raw)
In-Reply-To: <675b5abd8b40a71c177e9e4e4c92d2d6b1413b9b.1694527316.git.daniel@makrotopia.org>
On Tue, Sep 12, 2023 at 03:54:40PM +0100, Daniel Golle wrote:
> MT7988 comes with a built-in 2.5G PHY as well as SerDes lanes to
> connect external PHYs or transceivers in USXGMII, 10GBase-R, 5GBase-R,
> 2500Base-X, 1000Base-X and Cisco SGMII interface modes.
>
> Implement support for configuring for the new paths to SerDes interfaces
> and the internal 2.5G PHY.
>
> Add USXGMII PCS driver for 10GBase-R, 5GBase-R and USXGMII mode, and
> setup the new PHYA on MT7988 to access the also still existing old
> LynxI PCS for 1000Base-X, 2500Base-X and Cisco SGMII interface modes.
>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
> Changes since RFC v2:
> * read PCS_RX_STATUS0 register to avoid bogus link-up
> (recommended by mtk devs)
> * use parenthese to fix evaluation order
> (Simon Horman reported clang warning)
> * fix allocation size of usxgmii_pcs
> (Simon Horman reported Smatch warning)
> * always set USXGMII_AN_ENABLE bit in USXGMII mode
> (it's what the vendor driver does and USXGMII doesn't seem to work
> at all otherwise, we may need to manually set rate matching registers
> if we don't use AN, but this isn't implemented at this point)
>
> Changes since initial RFC:
> * set missing neg_mode = true for usxgmii pcs
> * use phylink_decode_usxgmii_word instead of open coding
>
> drivers/net/ethernet/mediatek/Kconfig | 16 +
> drivers/net/ethernet/mediatek/Makefile | 1 +
> drivers/net/ethernet/mediatek/mtk_eth_path.c | 123 +++-
> drivers/net/ethernet/mediatek/mtk_eth_soc.c | 182 ++++-
> drivers/net/ethernet/mediatek/mtk_eth_soc.h | 232 +++++-
> drivers/net/ethernet/mediatek/mtk_usxgmii.c | 702 +++++++++++++++++++
> 6 files changed, 1225 insertions(+), 31 deletions(-)
> create mode 100644 drivers/net/ethernet/mediatek/mtk_usxgmii.c
>
> diff --git a/drivers/net/ethernet/mediatek/Kconfig b/drivers/net/ethernet/mediatek/Kconfig
> index da0db417ab690..b942b4622d146 100644
> --- a/drivers/net/ethernet/mediatek/Kconfig
> +++ b/drivers/net/ethernet/mediatek/Kconfig
> @@ -25,6 +25,22 @@ config NET_MEDIATEK_SOC
> This driver supports the gigabit ethernet MACs in the
> MediaTek SoC family.
>
> +config NET_MEDIATEK_SOC_USXGMII
> + bool "Support USXGMII SerDes on MT7988"
> + depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST
> + def_bool NET_MEDIATEK_SOC != n
> + help
> + Include support for 10GE SerDes which can be found on MT7988.
> + If this kernel should run on SoCs with 10 GBit/s Ethernet you
> + will need to select this option to use GMAC2 and GMAC3 with
> + external PHYs, SFP(+) cages in 10GBase-R, 5GBase-R or USXGMII
> + interface modes.
> +
> + Note that as the 2500Base-X/1000Base-X/Cisco SGMII SerDes PCS
> + unit (MediaTek LynxI) in MT7988 is connected via the new 10GE
> + SerDes, you will also need to select this option in case you
> + want to use any of those SerDes modes.
> +
> config NET_MEDIATEK_STAR_EMAC
> tristate "MediaTek STAR Ethernet MAC support"
> select PHYLIB
...
> diff --git a/drivers/net/ethernet/mediatek/mtk_usxgmii.c b/drivers/net/ethernet/mediatek/mtk_usxgmii.c
...
> +static void mtk_usxgmii_pcs_get_state(struct phylink_pcs *pcs,
> + struct phylink_link_state *state)
> +{
> + struct mtk_usxgmii_pcs *mpcs = pcs_to_mtk_usxgmii_pcs(pcs);
> + struct mtk_eth *eth = mpcs->eth;
> + struct mtk_mac *mac = eth->mac[mtk_xgmii2mac_id(eth, mpcs->id)];
> + u32 val = 0;
> +
> + regmap_read(mpcs->regmap, RG_PCS_AN_CTRL0, &val);
> + if (FIELD_GET(USXGMII_AN_ENABLE, val)) {
> + /* Refresh LPA by inverting LPA_LATCH */
> + regmap_read(mpcs->regmap, RG_PCS_AN_STS0, &val);
> + regmap_update_bits(mpcs->regmap, RG_PCS_AN_STS0,
> + USXGMII_LPA_LATCH,
> + !(val & USXGMII_LPA_LATCH));
> +
> + regmap_read(mpcs->regmap, RG_PCS_AN_STS0, &val);
> +
> + phylink_decode_usxgmii_word(state, FIELD_GET(USXGMII_PCS_AN_WORD,
> + val));
> +
> + state->interface = mpcs->interface;
> + } else {
> + val = mtk_r32(mac->hw, MTK_XGMAC_STS(mac->id));
> +
> + if (mac->id == MTK_GMAC2_ID)
> + val >>= 16;
> +
> + switch (FIELD_GET(MTK_USXGMII_PCS_MODE, val)) {
> + case 0:
> + state->speed = SPEED_10000;
> + break;
> + case 1:
> + state->speed = SPEED_5000;
> + break;
> + case 2:
> + state->speed = SPEED_2500;
> + break;
> + case 3:
> + state->speed = SPEED_1000;
> + break;
> + }
> +
> + state->interface = mpcs->interface;
> + state->link = FIELD_GET(MTK_USXGMII_PCS_LINK, val);
> + state->duplex = DUPLEX_FULL;
> + }
> +
> + /* Refresh USXGMII link status by toggling RG_PCS_RX_STATUS_UPDATE */
> + regmap_set_bits(mpcs->regmap, RG_PCS_RX_STATUS0, RG_PCS_RX_STATUS_UPDATE);
> + ndelay(1020);
> + regmap_clear_bits(mpcs->regmap, RG_PCS_RX_STATUS0, RG_PCS_RX_STATUS_UPDATE);
> + ndelay(1020);
> +
> + /* Read USXGMII link status */
> + regmap_read(mpcs->regmap, RG_PCS_RX_STATUS0, &val);
> + state->link = state->link && FIELD_GET(RG_PCS_RX_LINK_STATUS, val);
> +
> + /* Continuously repeat re-configuration sequence until link comes up */
> + if (!state->link)
> + mtk_usxgmii_pcs_config(pcs, mpcs->neg_mode,
> + state->interface, NULL, false);
> +}
Hi Daniel,
I feel that I'm missing something obvious, but with this patch applied,
when building with allmodconfig for both x86_64 and arm64 the build fails
reporting that RG_PCS_RX_STATUS0, RG_PCS_RX_STATUS_UPDATE and
RG_PCS_RX_LINK_STATUS are undefined.
...
WARNING: multiple messages have this Message-ID (diff)
From: Simon Horman <horms@kernel.org>
To: Daniel Golle <daniel@makrotopia.org>
Cc: Felix Fietkau <nbd@nbd.name>, John Crispin <john@phrozen.org>,
Sean Wang <sean.wang@mediatek.com>,
Mark Lee <Mark-MC.Lee@mediatek.com>,
Lorenzo Bianconi <lorenzo@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Russell King <linux@armlinux.org.uk>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, llvm@lists.linux.dev,
ndesaulniers@google.com, nathan@kernel.org, trix@redhat.com
Subject: Re: [PATCH net-next] net: ethernet: mtk_eth_soc: add paths and SerDes modes for MT7988
Date: Sat, 16 Sep 2023 20:00:51 +0200 [thread overview]
Message-ID: <20230916180051.GH1125562@kernel.org> (raw)
In-Reply-To: <675b5abd8b40a71c177e9e4e4c92d2d6b1413b9b.1694527316.git.daniel@makrotopia.org>
On Tue, Sep 12, 2023 at 03:54:40PM +0100, Daniel Golle wrote:
> MT7988 comes with a built-in 2.5G PHY as well as SerDes lanes to
> connect external PHYs or transceivers in USXGMII, 10GBase-R, 5GBase-R,
> 2500Base-X, 1000Base-X and Cisco SGMII interface modes.
>
> Implement support for configuring for the new paths to SerDes interfaces
> and the internal 2.5G PHY.
>
> Add USXGMII PCS driver for 10GBase-R, 5GBase-R and USXGMII mode, and
> setup the new PHYA on MT7988 to access the also still existing old
> LynxI PCS for 1000Base-X, 2500Base-X and Cisco SGMII interface modes.
>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
> Changes since RFC v2:
> * read PCS_RX_STATUS0 register to avoid bogus link-up
> (recommended by mtk devs)
> * use parenthese to fix evaluation order
> (Simon Horman reported clang warning)
> * fix allocation size of usxgmii_pcs
> (Simon Horman reported Smatch warning)
> * always set USXGMII_AN_ENABLE bit in USXGMII mode
> (it's what the vendor driver does and USXGMII doesn't seem to work
> at all otherwise, we may need to manually set rate matching registers
> if we don't use AN, but this isn't implemented at this point)
>
> Changes since initial RFC:
> * set missing neg_mode = true for usxgmii pcs
> * use phylink_decode_usxgmii_word instead of open coding
>
> drivers/net/ethernet/mediatek/Kconfig | 16 +
> drivers/net/ethernet/mediatek/Makefile | 1 +
> drivers/net/ethernet/mediatek/mtk_eth_path.c | 123 +++-
> drivers/net/ethernet/mediatek/mtk_eth_soc.c | 182 ++++-
> drivers/net/ethernet/mediatek/mtk_eth_soc.h | 232 +++++-
> drivers/net/ethernet/mediatek/mtk_usxgmii.c | 702 +++++++++++++++++++
> 6 files changed, 1225 insertions(+), 31 deletions(-)
> create mode 100644 drivers/net/ethernet/mediatek/mtk_usxgmii.c
>
> diff --git a/drivers/net/ethernet/mediatek/Kconfig b/drivers/net/ethernet/mediatek/Kconfig
> index da0db417ab690..b942b4622d146 100644
> --- a/drivers/net/ethernet/mediatek/Kconfig
> +++ b/drivers/net/ethernet/mediatek/Kconfig
> @@ -25,6 +25,22 @@ config NET_MEDIATEK_SOC
> This driver supports the gigabit ethernet MACs in the
> MediaTek SoC family.
>
> +config NET_MEDIATEK_SOC_USXGMII
> + bool "Support USXGMII SerDes on MT7988"
> + depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST
> + def_bool NET_MEDIATEK_SOC != n
> + help
> + Include support for 10GE SerDes which can be found on MT7988.
> + If this kernel should run on SoCs with 10 GBit/s Ethernet you
> + will need to select this option to use GMAC2 and GMAC3 with
> + external PHYs, SFP(+) cages in 10GBase-R, 5GBase-R or USXGMII
> + interface modes.
> +
> + Note that as the 2500Base-X/1000Base-X/Cisco SGMII SerDes PCS
> + unit (MediaTek LynxI) in MT7988 is connected via the new 10GE
> + SerDes, you will also need to select this option in case you
> + want to use any of those SerDes modes.
> +
> config NET_MEDIATEK_STAR_EMAC
> tristate "MediaTek STAR Ethernet MAC support"
> select PHYLIB
...
> diff --git a/drivers/net/ethernet/mediatek/mtk_usxgmii.c b/drivers/net/ethernet/mediatek/mtk_usxgmii.c
...
> +static void mtk_usxgmii_pcs_get_state(struct phylink_pcs *pcs,
> + struct phylink_link_state *state)
> +{
> + struct mtk_usxgmii_pcs *mpcs = pcs_to_mtk_usxgmii_pcs(pcs);
> + struct mtk_eth *eth = mpcs->eth;
> + struct mtk_mac *mac = eth->mac[mtk_xgmii2mac_id(eth, mpcs->id)];
> + u32 val = 0;
> +
> + regmap_read(mpcs->regmap, RG_PCS_AN_CTRL0, &val);
> + if (FIELD_GET(USXGMII_AN_ENABLE, val)) {
> + /* Refresh LPA by inverting LPA_LATCH */
> + regmap_read(mpcs->regmap, RG_PCS_AN_STS0, &val);
> + regmap_update_bits(mpcs->regmap, RG_PCS_AN_STS0,
> + USXGMII_LPA_LATCH,
> + !(val & USXGMII_LPA_LATCH));
> +
> + regmap_read(mpcs->regmap, RG_PCS_AN_STS0, &val);
> +
> + phylink_decode_usxgmii_word(state, FIELD_GET(USXGMII_PCS_AN_WORD,
> + val));
> +
> + state->interface = mpcs->interface;
> + } else {
> + val = mtk_r32(mac->hw, MTK_XGMAC_STS(mac->id));
> +
> + if (mac->id == MTK_GMAC2_ID)
> + val >>= 16;
> +
> + switch (FIELD_GET(MTK_USXGMII_PCS_MODE, val)) {
> + case 0:
> + state->speed = SPEED_10000;
> + break;
> + case 1:
> + state->speed = SPEED_5000;
> + break;
> + case 2:
> + state->speed = SPEED_2500;
> + break;
> + case 3:
> + state->speed = SPEED_1000;
> + break;
> + }
> +
> + state->interface = mpcs->interface;
> + state->link = FIELD_GET(MTK_USXGMII_PCS_LINK, val);
> + state->duplex = DUPLEX_FULL;
> + }
> +
> + /* Refresh USXGMII link status by toggling RG_PCS_RX_STATUS_UPDATE */
> + regmap_set_bits(mpcs->regmap, RG_PCS_RX_STATUS0, RG_PCS_RX_STATUS_UPDATE);
> + ndelay(1020);
> + regmap_clear_bits(mpcs->regmap, RG_PCS_RX_STATUS0, RG_PCS_RX_STATUS_UPDATE);
> + ndelay(1020);
> +
> + /* Read USXGMII link status */
> + regmap_read(mpcs->regmap, RG_PCS_RX_STATUS0, &val);
> + state->link = state->link && FIELD_GET(RG_PCS_RX_LINK_STATUS, val);
> +
> + /* Continuously repeat re-configuration sequence until link comes up */
> + if (!state->link)
> + mtk_usxgmii_pcs_config(pcs, mpcs->neg_mode,
> + state->interface, NULL, false);
> +}
Hi Daniel,
I feel that I'm missing something obvious, but with this patch applied,
when building with allmodconfig for both x86_64 and arm64 the build fails
reporting that RG_PCS_RX_STATUS0, RG_PCS_RX_STATUS_UPDATE and
RG_PCS_RX_LINK_STATUS are undefined.
...
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-09-16 18:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-12 14:54 [PATCH net-next] net: ethernet: mtk_eth_soc: add paths and SerDes modes for MT7988 Daniel Golle
2023-09-12 14:54 ` Daniel Golle
2023-09-16 18:00 ` Simon Horman [this message]
2023-09-16 18:00 ` Simon Horman
2023-09-16 18:24 ` Russell King (Oracle)
2023-09-16 18:24 ` Russell King (Oracle)
-- strict thread matches above, loose matches on Subject: below --
2023-08-28 0:56 Daniel Golle
2023-08-28 0:56 ` Daniel Golle
2023-08-28 19:47 ` Jakub Kicinski
2023-08-28 19:47 ` Jakub Kicinski
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=20230916180051.GH1125562@kernel.org \
--to=horms@kernel.org \
--cc=Mark-MC.Lee@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=john@phrozen.org \
--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=llvm@lists.linux.dev \
--cc=lorenzo@kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=nathan@kernel.org \
--cc=nbd@nbd.name \
--cc=ndesaulniers@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sean.wang@mediatek.com \
--cc=trix@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.