Commit c689a652 authored by Russell King (Oracle)'s avatar Russell King (Oracle) Committed by Jakub Kicinski

net: pcs: lynx: update PCS driver to use neg_mode

Update the Lynx PCS driver to use neg_mode rather than the mode
argument. This ensures that the link_up() method will always program
the speed and duplex when negotiation is disabled.
Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/r/E1qA8E4-00EaFf-Bf@rmk-PC.armlinux.org.ukSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 3b2de56a
...@@ -149,13 +149,14 @@ static int lynx_pcs_config_giga(struct mdio_device *pcs, ...@@ -149,13 +149,14 @@ static int lynx_pcs_config_giga(struct mdio_device *pcs,
neg_mode); neg_mode);
} }
static int lynx_pcs_config_usxgmii(struct mdio_device *pcs, unsigned int mode, static int lynx_pcs_config_usxgmii(struct mdio_device *pcs,
const unsigned long *advertising) const unsigned long *advertising,
unsigned int neg_mode)
{ {
struct mii_bus *bus = pcs->bus; struct mii_bus *bus = pcs->bus;
int addr = pcs->addr; int addr = pcs->addr;
if (!phylink_autoneg_inband(mode)) { if (neg_mode != PHYLINK_PCS_NEG_INBAND_ENABLED) {
dev_err(&pcs->dev, "USXGMII only supports in-band AN for now\n"); dev_err(&pcs->dev, "USXGMII only supports in-band AN for now\n");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -167,15 +168,11 @@ static int lynx_pcs_config_usxgmii(struct mdio_device *pcs, unsigned int mode, ...@@ -167,15 +168,11 @@ static int lynx_pcs_config_usxgmii(struct mdio_device *pcs, unsigned int mode,
ADVERTISE_SGMII | ADVERTISE_LPACK); ADVERTISE_SGMII | ADVERTISE_LPACK);
} }
static int lynx_pcs_config(struct phylink_pcs *pcs, unsigned int mode, static int lynx_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
phy_interface_t ifmode, phy_interface_t ifmode,
const unsigned long *advertising, const unsigned long *advertising, bool permit)
bool permit)
{ {
struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs);
unsigned int neg_mode;
neg_mode = phylink_pcs_neg_mode(mode, ifmode, advertising);
switch (ifmode) { switch (ifmode) {
case PHY_INTERFACE_MODE_1000BASEX: case PHY_INTERFACE_MODE_1000BASEX:
...@@ -184,14 +181,15 @@ static int lynx_pcs_config(struct phylink_pcs *pcs, unsigned int mode, ...@@ -184,14 +181,15 @@ static int lynx_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
return lynx_pcs_config_giga(lynx->mdio, ifmode, advertising, return lynx_pcs_config_giga(lynx->mdio, ifmode, advertising,
neg_mode); neg_mode);
case PHY_INTERFACE_MODE_2500BASEX: case PHY_INTERFACE_MODE_2500BASEX:
if (phylink_autoneg_inband(mode)) { if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) {
dev_err(&lynx->mdio->dev, dev_err(&lynx->mdio->dev,
"AN not supported on 3.125GHz SerDes lane\n"); "AN not supported on 3.125GHz SerDes lane\n");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
break; break;
case PHY_INTERFACE_MODE_USXGMII: case PHY_INTERFACE_MODE_USXGMII:
return lynx_pcs_config_usxgmii(lynx->mdio, mode, advertising); return lynx_pcs_config_usxgmii(lynx->mdio, advertising,
neg_mode);
case PHY_INTERFACE_MODE_10GBASER: case PHY_INTERFACE_MODE_10GBASER:
/* Nothing to do here for 10GBASER */ /* Nothing to do here for 10GBASER */
break; break;
...@@ -209,7 +207,8 @@ static void lynx_pcs_an_restart(struct phylink_pcs *pcs) ...@@ -209,7 +207,8 @@ static void lynx_pcs_an_restart(struct phylink_pcs *pcs)
phylink_mii_c22_pcs_an_restart(lynx->mdio); phylink_mii_c22_pcs_an_restart(lynx->mdio);
} }
static void lynx_pcs_link_up_sgmii(struct mdio_device *pcs, unsigned int mode, static void lynx_pcs_link_up_sgmii(struct mdio_device *pcs,
unsigned int neg_mode,
int speed, int duplex) int speed, int duplex)
{ {
u16 if_mode = 0, sgmii_speed; u16 if_mode = 0, sgmii_speed;
...@@ -217,7 +216,7 @@ static void lynx_pcs_link_up_sgmii(struct mdio_device *pcs, unsigned int mode, ...@@ -217,7 +216,7 @@ static void lynx_pcs_link_up_sgmii(struct mdio_device *pcs, unsigned int mode,
/* The PCS needs to be configured manually only /* The PCS needs to be configured manually only
* when not operating on in-band mode * when not operating on in-band mode
*/ */
if (mode == MLO_AN_INBAND) if (neg_mode != PHYLINK_PCS_NEG_INBAND_ENABLED)
return; return;
if (duplex == DUPLEX_HALF) if (duplex == DUPLEX_HALF)
...@@ -264,12 +263,12 @@ static void lynx_pcs_link_up_sgmii(struct mdio_device *pcs, unsigned int mode, ...@@ -264,12 +263,12 @@ static void lynx_pcs_link_up_sgmii(struct mdio_device *pcs, unsigned int mode,
* 2500 Mbps and we do rate adaptation through pause frames. * 2500 Mbps and we do rate adaptation through pause frames.
*/ */
static void lynx_pcs_link_up_2500basex(struct mdio_device *pcs, static void lynx_pcs_link_up_2500basex(struct mdio_device *pcs,
unsigned int mode, unsigned int neg_mode,
int speed, int duplex) int speed, int duplex)
{ {
u16 if_mode = 0; u16 if_mode = 0;
if (mode == MLO_AN_INBAND) { if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) {
dev_err(&pcs->dev, "AN not supported for 2500BaseX\n"); dev_err(&pcs->dev, "AN not supported for 2500BaseX\n");
return; return;
} }
...@@ -283,7 +282,7 @@ static void lynx_pcs_link_up_2500basex(struct mdio_device *pcs, ...@@ -283,7 +282,7 @@ static void lynx_pcs_link_up_2500basex(struct mdio_device *pcs,
if_mode); if_mode);
} }
static void lynx_pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, static void lynx_pcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode,
phy_interface_t interface, phy_interface_t interface,
int speed, int duplex) int speed, int duplex)
{ {
...@@ -292,10 +291,10 @@ static void lynx_pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, ...@@ -292,10 +291,10 @@ static void lynx_pcs_link_up(struct phylink_pcs *pcs, unsigned int mode,
switch (interface) { switch (interface) {
case PHY_INTERFACE_MODE_SGMII: case PHY_INTERFACE_MODE_SGMII:
case PHY_INTERFACE_MODE_QSGMII: case PHY_INTERFACE_MODE_QSGMII:
lynx_pcs_link_up_sgmii(lynx->mdio, mode, speed, duplex); lynx_pcs_link_up_sgmii(lynx->mdio, neg_mode, speed, duplex);
break; break;
case PHY_INTERFACE_MODE_2500BASEX: case PHY_INTERFACE_MODE_2500BASEX:
lynx_pcs_link_up_2500basex(lynx->mdio, mode, speed, duplex); lynx_pcs_link_up_2500basex(lynx->mdio, neg_mode, speed, duplex);
break; break;
case PHY_INTERFACE_MODE_USXGMII: case PHY_INTERFACE_MODE_USXGMII:
/* At the moment, only in-band AN is supported for USXGMII /* At the moment, only in-band AN is supported for USXGMII
...@@ -325,6 +324,7 @@ static struct phylink_pcs *lynx_pcs_create(struct mdio_device *mdio) ...@@ -325,6 +324,7 @@ static struct phylink_pcs *lynx_pcs_create(struct mdio_device *mdio)
mdio_device_get(mdio); mdio_device_get(mdio);
lynx->mdio = mdio; lynx->mdio = mdio;
lynx->pcs.ops = &lynx_pcs_phylink_ops; lynx->pcs.ops = &lynx_pcs_phylink_ops;
lynx->pcs.neg_mode = true;
lynx->pcs.poll = true; lynx->pcs.poll = true;
return lynx_to_phylink_pcs(lynx); return lynx_to_phylink_pcs(lynx);
......
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