diff mbox series

[RFC,net-next,4/9] net: qca8k: switch PCS driver to use phylink_pcs_neg_mode()

Message ID E1q1UM9-007FSu-A0@rmk-PC.armlinux.org.uk (mailing list archive)
State New, archived
Headers show
Series Add and use helper for PCS negotiation modes | expand

Commit Message

Russell King (Oracle) May 23, 2023, 3:55 p.m. UTC
Use the newly introduced phylink_pcs_neg_mode() to configure whether
inband-AN should be used.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/dsa/qca/qca8k-8xxx.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c
index 6d5ac7588a69..acede9f3c253 100644
--- a/drivers/net/dsa/qca/qca8k-8xxx.c
+++ b/drivers/net/dsa/qca/qca8k-8xxx.c
@@ -1500,6 +1500,7 @@  static int qca8k_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
 {
 	struct qca8k_priv *priv = pcs_to_qca8k_pcs(pcs)->priv;
 	int cpu_port_index, ret, port;
+	unsigned int neg_mode;
 	u32 reg, val;
 
 	port = pcs_to_qca8k_pcs(pcs)->port;
@@ -1519,15 +1520,15 @@  static int qca8k_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
 		return -EINVAL;
 	}
 
+	neg_mode = phylink_pcs_neg_mode(mode, interface, advertising);
+
 	/* Enable/disable SerDes auto-negotiation as necessary */
-	ret = qca8k_read(priv, QCA8K_REG_PWS, &val);
+	val = neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED ?
+		0 : QCA8K_PWS_SERDES_AEN_DIS;
+
+	ret = qca8k_rmw(priv, QCA8K_REG_PWS, QCA8K_PWS_SERDES_AEN_DIS, val);
 	if (ret)
 		return ret;
-	if (phylink_autoneg_inband(mode))
-		val &= ~QCA8K_PWS_SERDES_AEN_DIS;
-	else
-		val |= QCA8K_PWS_SERDES_AEN_DIS;
-	qca8k_write(priv, QCA8K_REG_PWS, val);
 
 	/* Configure the SGMII parameters */
 	ret = qca8k_read(priv, QCA8K_REG_SGMII_CTRL, &val);