From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Frank Wunderlich <frank-w@public-files.de>
Cc: Eric Dumazet <edumazet@google.com>, Felix Fietkau <nbd@nbd.name>,
John Crispin <john@phrozen.org>,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
Mark Lee <Mark-MC.Lee@mediatek.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
Sean Wang <sean.wang@mediatek.com>
Subject: [PATCH net-next 04/11] net: mtk_eth_soc: add pcs_get_state() implementation
Date: Thu, 27 Oct 2022 14:10:52 +0100 [thread overview]
Message-ID: <E1oo2eq-00HF7w-ST@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <Y1qDMw+DJLAJHT40@shell.armlinux.org.uk>
Add a pcs_get_state() implementation which uses the advertisements
to compute the resulting link modes, and BMSR contents to determine
negotiation and link status.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/mediatek/mtk_sgmii.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/net/ethernet/mediatek/mtk_sgmii.c b/drivers/net/ethernet/mediatek/mtk_sgmii.c
index 7637ba16b44b..63785bd9a118 100644
--- a/drivers/net/ethernet/mediatek/mtk_sgmii.c
+++ b/drivers/net/ethernet/mediatek/mtk_sgmii.c
@@ -19,6 +19,20 @@ static struct mtk_pcs *pcs_to_mtk_pcs(struct phylink_pcs *pcs)
return container_of(pcs, struct mtk_pcs, pcs);
}
+static void mtk_pcs_get_state(struct phylink_pcs *pcs,
+ struct phylink_link_state *state)
+{
+ struct mtk_pcs *mpcs = pcs_to_mtk_pcs(pcs);
+ unsigned int bm, adv;
+
+ /* Read the BMSR and LPA */
+ regmap_read(mpcs->regmap, SGMSYS_PCS_CONTROL_1, &bm);
+ regmap_read(mpcs->regmap, SGMSYS_PCS_ADVERTISE, &adv);
+
+ phylink_mii_c22_pcs_decode_state(state, FIELD_GET(SGMII_BMSR, bm),
+ FIELD_GET(SGMII_LPA, adv));
+}
+
/* For SGMII interface mode */
static void mtk_pcs_setup_mode_an(struct mtk_pcs *mpcs)
{
@@ -117,6 +131,7 @@ static void mtk_pcs_link_up(struct phylink_pcs *pcs, unsigned int mode,
}
static const struct phylink_pcs_ops mtk_pcs_ops = {
+ .pcs_get_state = mtk_pcs_get_state,
.pcs_config = mtk_pcs_config,
.pcs_an_restart = mtk_pcs_restart_an,
.pcs_link_up = mtk_pcs_link_up,
--
2.30.2
next prev parent reply other threads:[~2022-10-27 13:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-27 13:10 [PATCH net-next 00/11] net: mtk_eth_soc: improve PCS implementation Russell King (Oracle)
2022-10-27 13:10 ` [PATCH net-next 01/11] net: phylink: add phylink_get_link_timer_ns() helper Russell King (Oracle)
2022-10-27 13:10 ` [PATCH net-next 02/11] net: mtk_eth_soc: add definitions for PCS Russell King (Oracle)
2022-10-27 13:10 ` [PATCH net-next 03/11] net: mtk_eth_soc: eliminate unnecessary error handling Russell King (Oracle)
2022-10-27 13:10 ` Russell King (Oracle) [this message]
2022-10-27 13:10 ` [PATCH net-next 05/11] net: mtk_eth_soc: convert mtk_sgmii to use regmap_update_bits() Russell King (Oracle)
2022-10-27 13:11 ` [PATCH net-next 06/11] net: mtk_eth_soc: add out of band forcing of speed and duplex in pcs_link_up Russell King (Oracle)
2022-10-27 13:11 ` [PATCH net-next 07/11] net: mtk_eth_soc: move PHY power up Russell King (Oracle)
2022-10-27 13:11 ` [PATCH net-next 08/11] net: mtk_eth_soc: move interface speed selection Russell King (Oracle)
2022-10-27 13:11 ` [PATCH net-next 09/11] net: mtk_eth_soc: add advertisement programming Russell King (Oracle)
2022-10-27 13:11 ` [PATCH net-next 10/11] net: mtk_eth_soc: move and correct link timer programming Russell King (Oracle)
2022-10-27 13:11 ` [PATCH net-next 11/11] net: mtk_eth_soc: add support for in-band 802.3z negotiation Russell King (Oracle)
2022-10-27 13:23 ` [PATCH net-next 00/11] net: mtk_eth_soc: improve PCS implementation Russell King (Oracle)
2022-10-29 5:00 ` patchwork-bot+netdevbpf
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=E1oo2eq-00HF7w-ST@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux.org.uk \
--cc=Mark-MC.Lee@mediatek.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=frank-w@public-files.de \
--cc=john@phrozen.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=nbd@nbd.name \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sean.wang@mediatek.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).