Skip to contentSkip to conversation

net: phy: enhance GPY115 loopback disable function

PATCH Superseded Xu Liang 2 participants 3 messages Sep 24, 2021

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Xu Liang

author maintainer
#0 lore raw

PATCH 1/1 net: phy: enhance GPY115 loopback disable function

GPY115 need reset PHY when it comes out from loopback mode if the firmware version number (lower 8 bits) is equal to or below 0x76.

---
 drivers/net/phy/mxl-gpy.c | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
drivers/net/phy/mxl-gpy.c +28 -2
index 2d5d5081c3b6..3ef62d5c4776 100644
@@ -493,6 +493,32 @@ static int gpy_loopback(struct phy_device *phydev, bool enable)
 	return ret;
 }
 
+static int gpy115_loopback(struct phy_device *phydev, bool enable)
+{
+	int ret;
+	int fw_minor;
+
+	if (enable)
+		return gpy_loopback(phydev, enable);
+
+	/* Show GPY PHY FW version in dmesg */
+	ret = phy_read(phydev, PHY_FWV);
+	if (ret < 0)
+		return ret;
+
+	fw_minor = FIELD_GET(PHY_FWV_MINOR_MASK, ret);
+	if (fw_minor > 0x0076)
+		return gpy_loopback(phydev, 0);
+
+	ret = phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK, BMCR_RESET);
+	if (!ret) {
+		/* Some delay for the reset complete. */
+		msleep(100);
+	}
+
+	return ret;
+}
+
 static struct phy_driver gpy_drivers[] = {
 	{
 		PHY_ID_MATCH_MODEL(PHY_ID_GPY2xx),
@@ -527,7 +553,7 @@ static struct phy_driver gpy_drivers[] = {
 		.handle_interrupt = gpy_handle_interrupt,
 		.set_wol	= gpy_set_wol,
 		.get_wol	= gpy_get_wol,
-		.set_loopback	= gpy_loopback,
+		.set_loopback	= gpy115_loopback,
 	},
 	{
 		PHY_ID_MATCH_MODEL(PHY_ID_GPY115C),
@@ -544,7 +570,7 @@ static struct phy_driver gpy_drivers[] = {
 		.handle_interrupt = gpy_handle_interrupt,
 		.set_wol	= gpy_set_wol,
 		.get_wol	= gpy_get_wol,
-		.set_loopback	= gpy_loopback,
+		.set_loopback	= gpy115_loopback,
 	},
 	{
 		.phy_id		= PHY_ID_GPY211B,
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 15 lines · Xu Liang

GPY115 need reset PHY when it comes out from loopback mode if the firmware version number (lower 8 bits) is equal to or below 0x76.

---
 drivers/net/phy/mxl-gpy.c | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
drivers/net/phy/mxl-gpy.c +0 -0
index 2d5d5081c3b6..3ef62d5c4776 100644
@@ -493,6 +493,32 @@ static int gpy_loopback(struct phy_device *phydev, bool enable)
 	return ret;
 }

drivers/net/phy/mxl-gpy.c static int gpy_loopback(struct phy_device *phydev, bool enable) · line 504

Quoted 10 lines
drivers/net/phy/mxl-gpy.c +9 -0
 
+static int gpy115_loopback(struct phy_device *phydev, bool enable)
+{
+	int ret;
+	int fw_minor;
+
+	if (enable)
+		return gpy_loopback(phydev, enable);
+
+	/* Show GPY PHY FW version in dmesg */

You don't show anything.

drivers/net/phy/mxl-gpy.c static int gpy_loopback(struct phy_device *phydev, bool enable) · line 517

Quoted 13 lines
drivers/net/phy/mxl-gpy.c +13 -0
+	ret = phy_read(phydev, PHY_FWV);
+	if (ret < 0)
+		return ret;
+
+	fw_minor = FIELD_GET(PHY_FWV_MINOR_MASK, ret);
+	if (fw_minor > 0x0076)
+		return gpy_loopback(phydev, 0);
+
+	ret = phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK, BMCR_RESET);
+	if (!ret) {
+		/* Some delay for the reset complete. */
+		msleep(100);
+	}

genphy_soft_reset() would be better. Does a soft reset clear the BMCR_LOOPBACK bit? It should do, according to C22.

Andrew

author maintainer
#2 lore raw
Quoted 20 lines · Andrew Lunn

This email was sent from outside of MaxLinear.

Quoted 16 lines · Xu Liang

GPY115 need reset PHY when it comes out from loopback mode if the firmware version number (lower 8 bits) is equal to or below 0x76.

---
  drivers/net/phy/mxl-gpy.c | 30 ++++++++++++++++++++++++++++--
  1 file changed, 28 insertions(+), 2 deletions(-)
drivers/net/phy/mxl-gpy.c +0 -0
index 2d5d5081c3b6..3ef62d5c4776 100644
@@ -493,6 +493,32 @@ static int gpy_loopback(struct phy_device *phydev, bool enable)
       return ret;
  }
 
Quoted 10 lines

drivers/net/phy/mxl-gpy.c static int gpy_loopback(struct phy_device *phydev, bool enable) · line 504

Quoted 9 lines
drivers/net/phy/mxl-gpy.c +9 -0
+static int gpy115_loopback(struct phy_device *phydev, bool enable)
+{
+     int ret;
+     int fw_minor;
+
+     if (enable)
+             return gpy_loopback(phydev, enable);
+
+     /* Show GPY PHY FW version in dmesg */

You don't show anything.

You are right. Sorry it was a mistake. I will fix it.

Quoted 17 lines
Quoted 4 lines
drivers/net/phy/mxl-gpy.c +3 -0
+     ret = phy_read(phydev, PHY_FWV);
+     if (ret < 0)
+             return ret;

drivers/net/phy/mxl-gpy.c static int gpy_loopback(struct phy_device *phydev, bool enable) · line 517

Quoted 10 lines
drivers/net/phy/mxl-gpy.c +10 -0
+
+     fw_minor = FIELD_GET(PHY_FWV_MINOR_MASK, ret);
+     if (fw_minor > 0x0076)
+             return gpy_loopback(phydev, 0);
+
+     ret = phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK, BMCR_RESET);
+     if (!ret) {
+             /* Some delay for the reset complete. */
+             msleep(100);
+     }

genphy_soft_reset() would be better. Does a soft reset clear the BMCR_LOOPBACK bit? It should do, according to C22.

Quoted 2 lines

Andrew

Yes, I will use genphy_soft_reset instead.

Thanks & Regards,

Xu Liang