* [PATCH net-next 2/2] net: pcs: lynx: consolidate sgmii and 1000base-x config code
2022-06-23 12:24 [PATCH net-next 0/2] net: pcs: lynx: consolidate gigabit code Russell King (Oracle)
2022-06-23 12:25 ` [PATCH net-next 1/2] net: phylink: add QSGMII support to phylink_mii_c22_pcs_encode_advertisement() Russell King (Oracle)
@ 2022-06-23 12:25 ` Russell King (Oracle)
2022-06-23 14:00 ` [PATCH net-next 0/2] net: pcs: lynx: consolidate gigabit code Ioana Ciornei
2022-06-24 18:30 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Russell King (Oracle) @ 2022-06-23 12:25 UTC (permalink / raw)
To: Ioana Ciornei
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Heiner Kallweit,
Jakub Kicinski, netdev, Paolo Abeni
Consolidate lynx_pcs_config_1000basex() and lynx_pcs_config_sgmii() into
a single function. The differences between these two are:
- The value that the link timer is set to.
- The value of the IF_MODE register.
Everything else is identical.
This patch depends on "net: phylink: add QSGMII support to
phylink_mii_c22_pcs_encode_advertisement()".
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/pcs/pcs-lynx.c | 56 ++++++++++++++------------------------
1 file changed, 21 insertions(+), 35 deletions(-)
diff --git a/drivers/net/pcs/pcs-lynx.c b/drivers/net/pcs/pcs-lynx.c
index bdad8e283e97..7d5fc7f54b2f 100644
--- a/drivers/net/pcs/pcs-lynx.c
+++ b/drivers/net/pcs/pcs-lynx.c
@@ -122,53 +122,39 @@ static void lynx_pcs_get_state(struct phylink_pcs *pcs,
state->link, state->an_enabled, state->an_complete);
}
-static int lynx_pcs_config_1000basex(struct mdio_device *pcs,
- unsigned int mode,
- const unsigned long *advertising)
+static int lynx_pcs_config_giga(struct mdio_device *pcs, unsigned int mode,
+ phy_interface_t interface,
+ const unsigned long *advertising)
{
u32 link_timer;
- int err;
-
- link_timer = LINK_TIMER_VAL(IEEE8023_LINK_TIMER_NS);
- mdiodev_write(pcs, LINK_TIMER_LO, link_timer & 0xffff);
- mdiodev_write(pcs, LINK_TIMER_HI, link_timer >> 16);
-
- err = mdiodev_modify(pcs, IF_MODE,
- IF_MODE_SGMII_EN | IF_MODE_USE_SGMII_AN,
- 0);
- if (err)
- return err;
-
- return phylink_mii_c22_pcs_config(pcs, mode,
- PHY_INTERFACE_MODE_1000BASEX,
- advertising);
-}
-
-static int lynx_pcs_config_sgmii(struct mdio_device *pcs, unsigned int mode,
- const unsigned long *advertising)
-{
u16 if_mode;
int err;
- if_mode = IF_MODE_SGMII_EN;
- if (mode == MLO_AN_INBAND) {
- u32 link_timer;
-
- if_mode |= IF_MODE_USE_SGMII_AN;
-
- /* Adjust link timer for SGMII */
- link_timer = LINK_TIMER_VAL(SGMII_AN_LINK_TIMER_NS);
+ if (interface == PHY_INTERFACE_MODE_1000BASEX) {
+ link_timer = LINK_TIMER_VAL(IEEE8023_LINK_TIMER_NS);
mdiodev_write(pcs, LINK_TIMER_LO, link_timer & 0xffff);
mdiodev_write(pcs, LINK_TIMER_HI, link_timer >> 16);
+
+ if_mode = 0;
+ } else {
+ if_mode = IF_MODE_SGMII_EN;
+ if (mode == MLO_AN_INBAND) {
+ if_mode |= IF_MODE_USE_SGMII_AN;
+
+ /* Adjust link timer for SGMII */
+ link_timer = LINK_TIMER_VAL(SGMII_AN_LINK_TIMER_NS);
+ mdiodev_write(pcs, LINK_TIMER_LO, link_timer & 0xffff);
+ mdiodev_write(pcs, LINK_TIMER_HI, link_timer >> 16);
+ }
}
+
err = mdiodev_modify(pcs, IF_MODE,
IF_MODE_SGMII_EN | IF_MODE_USE_SGMII_AN,
if_mode);
if (err)
return err;
- return phylink_mii_c22_pcs_config(pcs, mode, PHY_INTERFACE_MODE_SGMII,
- advertising);
+ return phylink_mii_c22_pcs_config(pcs, mode, interface, advertising);
}
static int lynx_pcs_config_usxgmii(struct mdio_device *pcs, unsigned int mode,
@@ -198,10 +184,10 @@ static int lynx_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
switch (ifmode) {
case PHY_INTERFACE_MODE_1000BASEX:
- return lynx_pcs_config_1000basex(lynx->mdio, mode, advertising);
case PHY_INTERFACE_MODE_SGMII:
case PHY_INTERFACE_MODE_QSGMII:
- return lynx_pcs_config_sgmii(lynx->mdio, mode, advertising);
+ return lynx_pcs_config_giga(lynx->mdio, mode, ifmode,
+ advertising);
case PHY_INTERFACE_MODE_2500BASEX:
if (phylink_autoneg_inband(mode)) {
dev_err(&lynx->mdio->dev,
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH net-next 0/2] net: pcs: lynx: consolidate gigabit code
2022-06-23 12:24 [PATCH net-next 0/2] net: pcs: lynx: consolidate gigabit code Russell King (Oracle)
` (2 preceding siblings ...)
2022-06-23 14:00 ` [PATCH net-next 0/2] net: pcs: lynx: consolidate gigabit code Ioana Ciornei
@ 2022-06-24 18:30 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-06-24 18:30 UTC (permalink / raw)
To: Russell King
Cc: ioana.ciornei, andrew, davem, edumazet, hkallweit1, kuba, netdev,
pabeni
Hello:
This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 23 Jun 2022 13:24:44 +0100 you wrote:
> Hi,
>
> This series consolidates the gigabit setup code in the Lynx PCS driver.
> In order to do this properly, we first need to fix phylink's
> advertisement encoding function to handle QSGMII.
>
> I'd be grateful if someone can test this please.
>
> [...]
Here is the summary with links:
- [net-next,1/2] net: phylink: add QSGMII support to phylink_mii_c22_pcs_encode_advertisement()
https://git.kernel.org/netdev/net-next/c/f56866c486fa
- [net-next,2/2] net: pcs: lynx: consolidate sgmii and 1000base-x config code
https://git.kernel.org/netdev/net-next/c/06f9a6148e28
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] 5+ messages in thread