Commit 5d04b0b6 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'net-pcs-lynx-consolidate-gigabit-code'

Russell King says:

====================
net: pcs: lynx: consolidate gigabit code

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.
====================
Tested-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Link: https://lore.kernel.org/r/YrRbjOEEww38JFIK@shell.armlinux.org.ukSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents b4cbd7a9 06f9a614
......@@ -122,38 +122,23 @@ 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,
static int lynx_pcs_config_giga(struct mdio_device *pcs, unsigned int mode,
phy_interface_t interface,
const unsigned long *advertising)
{
u32 link_timer;
u16 if_mode;
int err;
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);
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 = 0;
} else {
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 */
......@@ -161,14 +146,15 @@ static int lynx_pcs_config_sgmii(struct mdio_device *pcs, unsigned int mode,
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,
......
......@@ -2991,6 +2991,7 @@ int phylink_mii_c22_pcs_encode_advertisement(phy_interface_t interface,
adv |= ADVERTISE_1000XPSE_ASYM;
return adv;
case PHY_INTERFACE_MODE_SGMII:
case PHY_INTERFACE_MODE_QSGMII:
return 0x0001;
default:
/* Nothing to do for other modes */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment