[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1644043492-31307-1-git-send-email-raagjadav@gmail.com>
Date: Sat, 5 Feb 2022 12:14:52 +0530
From: Raag Jadav <raagjadav@...il.com>
To: Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Steen Hegelund <steen.hegelund@...rochip.com>,
Bjarni Jonasson <bjarni.jonasson@...rochip.com>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Raag Jadav <raagjadav@...il.com>
Subject: [PATCH] net: phy: mscc: enable MAC SerDes autonegotiation
Enable MAC SerDes autonegotiation to distinguish between
1000BASE-X, SGMII and QSGMII MAC.
Signed-off-by: Raag Jadav <raagjadav@...il.com>
---
drivers/net/phy/mscc/mscc.h | 2 ++
drivers/net/phy/mscc/mscc_main.c | 24 ++++++++++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/drivers/net/phy/mscc/mscc.h b/drivers/net/phy/mscc/mscc.h
index a50235f..366db14 100644
--- a/drivers/net/phy/mscc/mscc.h
+++ b/drivers/net/phy/mscc/mscc.h
@@ -195,6 +195,8 @@ enum rgmii_clock_delay {
#define MSCC_PHY_EXTENDED_INT_MS_EGR BIT(9)
/* Extended Page 3 Registers */
+#define MSCC_PHY_SERDES_PCS_CTRL 16
+#define MSCC_PHY_SERDES_ANEG BIT(7)
#define MSCC_PHY_SERDES_TX_VALID_CNT 21
#define MSCC_PHY_SERDES_TX_CRC_ERR_CNT 22
#define MSCC_PHY_SERDES_RX_VALID_CNT 28
diff --git a/drivers/net/phy/mscc/mscc_main.c b/drivers/net/phy/mscc/mscc_main.c
index ebfeeb3..6db43a5 100644
--- a/drivers/net/phy/mscc/mscc_main.c
+++ b/drivers/net/phy/mscc/mscc_main.c
@@ -1685,6 +1685,25 @@ static int vsc8574_config_host_serdes(struct phy_device *phydev)
PROC_CMD_RST_CONF_PORT | PROC_CMD_FIBER_1000BASE_X);
}
+static int vsc85xx_config_inband_aneg(struct phy_device *phydev, bool enabled)
+{
+ int rc;
+ u16 reg_val = 0;
+
+ if (enabled)
+ reg_val = MSCC_PHY_SERDES_ANEG;
+
+ mutex_lock(&phydev->lock);
+
+ rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_EXTENDED_3,
+ MSCC_PHY_SERDES_PCS_CTRL, MSCC_PHY_SERDES_ANEG,
+ reg_val);
+
+ mutex_unlock(&phydev->lock);
+
+ return rc;
+}
+
static int vsc8584_config_init(struct phy_device *phydev)
{
struct vsc8531_private *vsc8531 = phydev->priv;
@@ -1772,6 +1791,11 @@ static int vsc8584_config_init(struct phy_device *phydev)
VSC8572_RGMII_TX_DELAY_MASK);
if (ret)
return ret;
+ } else {
+ /* Enable clause 37 */
+ ret = vsc85xx_config_inband_aneg(phydev, true);
+ if (ret)
+ return ret;
}
ret = genphy_soft_reset(phydev);
--
2.7.4
Powered by blists - more mailing lists