[PATCH] net: phy: enhance GPY115 loopback disable function

Subsystems: ethernet phy library, maxlinear ethernet phy driver, networking drivers, the rest

STALE1774d

3 messages, 2 authors, 2021-09-24 · open the first message on its own page

[PATCH] net: phy: enhance GPY115 loopback disable function

From: Xu Liang <lxu@maxlinear.com>
Date: 2021-09-24 09:21:14

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.

Signed-off-by: Xu Liang <lxu@maxlinear.com>
---
 drivers/net/phy/mxl-gpy.c | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/mxl-gpy.c b/drivers/net/phy/mxl-gpy.c
index 2d5d5081c3b6..3ef62d5c4776 100644
--- a/drivers/net/phy/mxl-gpy.c
+++ b/drivers/net/phy/mxl-gpy.c
@@ -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,
-- 
2.17.1

Re: [PATCH] net: phy: enhance GPY115 loopback disable function

From: Andrew Lunn <andrew@lunn.ch>
Date: 2021-09-24 11:59:59

On Fri, Sep 24, 2021 at 05:05:37PM +0800, Xu Liang wrote:
quoted hunk
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.

Signed-off-by: Xu Liang <lxu@maxlinear.com>
---
 drivers/net/phy/mxl-gpy.c | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/mxl-gpy.c b/drivers/net/phy/mxl-gpy.c
index 2d5d5081c3b6..3ef62d5c4776 100644
--- a/drivers/net/phy/mxl-gpy.c
+++ b/drivers/net/phy/mxl-gpy.c
@@ -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 */
You don't show anything.
+	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

Re: [PATCH] net: phy: enhance GPY115 loopback disable function

From: Liang Xu <lxu@maxlinear.com>
Date: 2021-09-24 15:49:02

On 24/9/2021 7:59 pm, Andrew Lunn wrote:
This email was sent from outside of MaxLinear.


On Fri, Sep 24, 2021 at 05:05:37PM +0800, Xu Liang wrote:
quoted
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.

Signed-off-by: Xu Liang <lxu@maxlinear.com>
---
  drivers/net/phy/mxl-gpy.c | 30 ++++++++++++++++++++++++++++--
  1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/mxl-gpy.c b/drivers/net/phy/mxl-gpy.c
index 2d5d5081c3b6..3ef62d5c4776 100644
--- a/drivers/net/phy/mxl-gpy.c
+++ b/drivers/net/phy/mxl-gpy.c
@@ -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 */
You don't show anything.
You are right. Sorry it was a mistake. I will fix it.
quoted
+     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
Yes, I will use genphy_soft_reset instead.


Thanks & Regards,

Xu Liang
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help