diff mbox

net/phy: tune get_phy_c45_ids to support more c45 phy

Message ID 1398305856-9761-1-git-send-email-Shengzhou.Liu@freescale.com
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Shengzhou Liu April 24, 2014, 2:17 a.m. UTC
As some C45 10G PHYs(e.g. Cortina CS4315/CS4340 PHY) have
zero Devices In package, current driver can't get correct
devices_in_package value by non-zero Devices In package.
so let's probe more with zero Devices In package to support
more C45 PHYs which have zero Devices In package.

Signed-off-by: Shengzhou Liu <Shengzhou.Liu@freescale.com>
---
Tested with CS4315 on T2080RDB, this patch have no impact on previous XAUI phy with verification. 

 drivers/net/phy/phy_device.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

Comments

David Miller April 25, 2014, 7:50 p.m. UTC | #1
From: Shengzhou Liu <Shengzhou.Liu@freescale.com>
Date: Thu, 24 Apr 2014 10:17:36 +0800

>  		if ((c45_ids->devices_in_package & 0x1fffffff) == 0x1fffffff) {
> -			*phy_id = 0xffffffff;
> -			return 0;
> +			reg_addr = MII_ADDR_C45 | 0 << 16 | 6;
> +			phy_reg = mdiobus_read(bus, addr, reg_addr);
> +			if (phy_reg < 0)
> +				return -EIO;
> +			c45_ids->devices_in_package = (phy_reg & 0xffff) << 16;
> +			reg_addr = MII_ADDR_C45 | 0 << 16 | 5;
> +			phy_reg = mdiobus_read(bus, addr, reg_addr);
> +			if (phy_reg < 0)
> +				return -EIO;
> +			c45_ids->devices_in_package |= (phy_reg & 0xffff);
> +			/* If mostly Fs, there is no device there,
> +			 * let's get out of here.
> +			 */

If ->devices_in_package is zero, we will not get to this code path, so
this comment makes no sense at all to me.

You need to explain the situation more accurately, and clearly.  I have
no idea what exactly the devices report in this situation, nor how your
code is trying to cope with that situation.

Please work slowly, and carefully, to write clear and accurate
comments as well as a commit message which describes (in detail) the
situation here.

Someone in the future will end up having to read this change and
try to understand it as well, so it's not just for me.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index cfb5110..8fd777e 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -244,12 +244,29 @@  static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
 			return -EIO;
 		c45_ids->devices_in_package |= (phy_reg & 0xffff);
 
-		/* If mostly Fs, there is no device there,
-		 * let's get out of here.
+		/* If mostly Fs, let's continue to probe more
+		 * as some 10G PHYs have zero Devices In package
+		 * e.g. Cortina CS4315/CS4340 PHY.
 		 */
 		if ((c45_ids->devices_in_package & 0x1fffffff) == 0x1fffffff) {
-			*phy_id = 0xffffffff;
-			return 0;
+			reg_addr = MII_ADDR_C45 | 0 << 16 | 6;
+			phy_reg = mdiobus_read(bus, addr, reg_addr);
+			if (phy_reg < 0)
+				return -EIO;
+			c45_ids->devices_in_package = (phy_reg & 0xffff) << 16;
+			reg_addr = MII_ADDR_C45 | 0 << 16 | 5;
+			phy_reg = mdiobus_read(bus, addr, reg_addr);
+			if (phy_reg < 0)
+				return -EIO;
+			c45_ids->devices_in_package |= (phy_reg & 0xffff);
+			/* If mostly Fs, there is no device there,
+			 * let's get out of here.
+			 */
+			if ((c45_ids->devices_in_package & 0x1fffffff) ==
+							0x1fffffff) {
+				*phy_id = 0xffffffff;
+				return 0;
+			}
 		}
 	}