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

Russell King (Oracle) rmk+kernel at armlinux.org.uk
Tue May 23 08:55:25 PDT 2023


Use the newly introduced phylink_pcs_neg_mode() to configure whether
inband-AN should be used.

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

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);
-- 
2.30.2




More information about the linux-arm-kernel mailing list