Skip to contentSkip to conversation

net: phy: broadcom: APD improvements

PATCH In review Florian Fainelli 3 participants 12 messages Feb 12, 2021 – Feb 13, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover net: phy: broadcom: APD improvements

This patch series cleans up the brcmphy.h header and its numerous unused phydev->dev_flags, fixes the RXC/TXC clock disabling bit and allows the BCM54210E PHY to utilize APD.

Thanks!

Florian Fainelli (3):
net: phy: broadcom: Remove unused flags
net: phy: broadcom: Fix RXC/TXC auto disabling
net: phy: broadcom: Allow BCM54210E to configure APD

 drivers/net/phy/broadcom.c |  1 +
 include/linux/brcmphy.h    | 24 ++++++++++--------------
 2 files changed, 11 insertions(+), 14 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/3 net: phy: broadcom: Remove unused flags

We have a number of unused flags defined today and since we are scarce on space and may need to introduce new flags in the future remove and shift every existing flag down into a contiguous assignment. No functional change.

---
 include/linux/brcmphy.h | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)
include/linux/brcmphy.h +9 -13
index de9430d55c90..da7bf9dfef5b 100644
@@ -61,19 +61,15 @@
 #define PHY_BCM_OUI_5			0x03625e00
 #define PHY_BCM_OUI_6			0xae025000
 
-#define PHY_BCM_FLAGS_MODE_COPPER	0x00000001
-#define PHY_BCM_FLAGS_MODE_1000BX	0x00000002
-#define PHY_BCM_FLAGS_INTF_SGMII	0x00000010
-#define PHY_BCM_FLAGS_INTF_XAUI		0x00000020
-#define PHY_BRCM_WIRESPEED_ENABLE	0x00000100
-#define PHY_BRCM_AUTO_PWRDWN_ENABLE	0x00000200
-#define PHY_BRCM_RX_REFCLK_UNUSED	0x00000400
-#define PHY_BRCM_STD_IBND_DISABLE	0x00000800
-#define PHY_BRCM_EXT_IBND_RX_ENABLE	0x00001000
-#define PHY_BRCM_EXT_IBND_TX_ENABLE	0x00002000
-#define PHY_BRCM_CLEAR_RGMII_MODE	0x00004000
-#define PHY_BRCM_DIS_TXCRXC_NOENRGY	0x00008000
-#define PHY_BRCM_EN_MASTER_MODE		0x00010000
+#define PHY_BCM_FLAGS_MODE_1000BX	0x00000001
+#define PHY_BRCM_AUTO_PWRDWN_ENABLE	0x00000002
+#define PHY_BRCM_RX_REFCLK_UNUSED	0x00000004
+#define PHY_BRCM_STD_IBND_DISABLE	0x00000008
+#define PHY_BRCM_EXT_IBND_RX_ENABLE	0x00000010
+#define PHY_BRCM_EXT_IBND_TX_ENABLE	0x00000020
+#define PHY_BRCM_CLEAR_RGMII_MODE	0x00000040
+#define PHY_BRCM_DIS_TXCRXC_NOENRGY	0x00000080
+#define PHY_BRCM_EN_MASTER_MODE		0x00000100
 
 /* Broadcom BCM7xxx specific workarounds */
 #define PHY_BRCM_7XXX_REV(x)		(((x) >> 8) & 0xff)
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH net-next 1/3] net: phy: broadcom: Remove unused flags

Quoted 7 lines · Florian Fainelli

We have a number of unused flags defined today and since we are scarce on space and may need to introduce new flags in the future remove and shift every existing flag down into a contiguous assignment. No functional change.

---

Good to see some of the dev_flags go away!

PHY_BCM_FLAGS_MODE_1000BX is used just from broadcom.c, therefore it can probably be moved to a structure in phydev->priv.

PHY_BRCM_STD_IBND_DISABLE, PHY_BRCM_EXT_IBND_RX_ENABLE and PHY_BRCM_EXT_IBND_TX_ENABLE are set by drivers/net/ethernet/broadcom/tg3.c but not used anywhere.

#3 lore raw

Re: [PATCH net-next 1/3] net: phy: broadcom: Remove unused flags

Quoted 6 lines · Vladimir Oltean
Quoted 5 lines · Florian Fainelli

We have a number of unused flags defined today and since we are scarce on space and may need to introduce new flags in the future remove and shift every existing flag down into a contiguous assignment. No functional change.

Quoted 7 lines
Quoted 2 lines

---

Good to see some of the dev_flags go away!

PHY_BCM_FLAGS_MODE_1000BX is used just from broadcom.c, therefore it can probably be moved to a structure in phydev->priv.

The next step would be to move it to a private flag, indeed.

Quoted 4 lines

PHY_BRCM_STD_IBND_DISABLE, PHY_BRCM_EXT_IBND_RX_ENABLE and PHY_BRCM_EXT_IBND_TX_ENABLE are set by drivers/net/ethernet/broadcom/tg3.c but not used anywhere.

That's right, tg3 drove a lot of the Broadcom PHY driver changes back then, I also would like to rework the way we pass flags towards PHY drivers because tg3 is basically the only driver doing it right, where it checks the PHY ID first, then sets appropriate flags during connect.

Signature · 1 line
Florian
#4 lore raw

Re: [PATCH net-next 1/3] net: phy: broadcom: Remove unused flags

Quoted 4 lines · Florian Fainelli

That's right, tg3 drove a lot of the Broadcom PHY driver changes back then, I also would like to rework the way we pass flags towards PHY drivers because tg3 is basically the only driver doing it right, where it checks the PHY ID first, then sets appropriate flags during connect.

Why does the tg3 controller need to enable the auto power down PHY feature in the first place and the PHY driver can't just enable it by itself?

#5 lore raw

Re: [PATCH net-next 1/3] net: phy: broadcom: Remove unused flags

Quoted 10 lines · Vladimir Oltean
Quoted 4 lines · Florian Fainelli

That's right, tg3 drove a lot of the Broadcom PHY driver changes back then, I also would like to rework the way we pass flags towards PHY drivers because tg3 is basically the only driver doing it right, where it checks the PHY ID first, then sets appropriate flags during connect.

Why does the tg3 controller need to enable the auto power down PHY feature in the first place and the PHY driver can't just enable it by itself?

That would be a question for Michael if he remembers those details from 12 years ago.

Signature · 1 line
Florian
#6 lore raw

PATCH 2/3 net: phy: broadcom: Fix RXC/TXC auto disabling

In reply to Florian Fainelli

When support for optionally disabling the TXC was introduced, bit 2 was used to do that operation but the datasheet for 50610M from 2009 does not show bit 2 as being defined. Bit 8 is the one that allows automatic disabling of the RXC/TXC auto disabling during auto power down.

Fixes 52fae0837153 ("tg3 / broadcom: Optionally disable TXC if no link")
---
 include/linux/brcmphy.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/brcmphy.h +1 -1
index da7bf9dfef5b..3dd8203cf780 100644
@@ -193,7 +193,7 @@
 #define BCM54XX_SHD_SCR3		0x05
 #define  BCM54XX_SHD_SCR3_DEF_CLK125	0x0001
 #define  BCM54XX_SHD_SCR3_DLLAPD_DIS	0x0002
-#define  BCM54XX_SHD_SCR3_TRDDAPD	0x0004
+#define  BCM54XX_SHD_SCR3_TRDDAPD	0x0100
 
 /* 01010: Auto Power-Down */
 #define BCM54XX_SHD_APD			0x0a
Signature · 1 line
2.25.1
#7 lore raw

Re: [PATCH net-next 2/3] net: phy: broadcom: Fix RXC/TXC auto disabling

Quoted 27 lines · Florian Fainelli

When support for optionally disabling the TXC was introduced, bit 2 was used to do that operation but the datasheet for 50610M from 2009 does not show bit 2 as being defined. Bit 8 is the one that allows automatic disabling of the RXC/TXC auto disabling during auto power down.

Fixes 52fae0837153 ("tg3 / broadcom: Optionally disable TXC if no link")
---
 include/linux/brcmphy.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/brcmphy.h +1 -1
index da7bf9dfef5b..3dd8203cf780 100644
@@ -193,7 +193,7 @@
 #define BCM54XX_SHD_SCR3		0x05
 #define  BCM54XX_SHD_SCR3_DEF_CLK125	0x0001
 #define  BCM54XX_SHD_SCR3_DLLAPD_DIS	0x0002
-#define  BCM54XX_SHD_SCR3_TRDDAPD	0x0004
+#define  BCM54XX_SHD_SCR3_TRDDAPD	0x0100
 
 /* 01010: Auto Power-Down */
 #define BCM54XX_SHD_APD			0x0a
Signature · 1 line
2.25.1

We may have a problem here, with the layout of the Spare Control 3 register not being as universal as we think.

Your finding may have been the same as Kevin Lo's from commit b0ed0bbfb304 ("net: phy: broadcom: add support for BCM54811 PHY"), therefore your change is making BCM54XX_SHD_SCR3_TRDDAPD == BCM54810_SHD_SCR3_TRDDAPD, so currently this if condition is redundant and probably something else is wrong too:

	if (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY) {
		if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810 ||
		    BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54811)
			val |= BCM54810_SHD_SCR3_TRDDAPD;
		else
			val |= BCM54XX_SHD_SCR3_TRDDAPD;
	}

I'm not sure what "TRDD" stands for, but my copy of the BCM5464R datasheet shows both bits 2 as well as 8 as being reserved. I have "CLK125 Output" in bit 0, "DLL Auto Power-Down" in bit 1, "SD/Energy Detect Change" in bit 5, "TXC Disable" in bit 6, and that's about it.

But I think it doesn't matter what BCM5464R has, since this feature is gated by PHY_BRCM_DIS_TXCRXC_NOENRGY.

#8 lore raw

Re: [PATCH net-next 2/3] net: phy: broadcom: Fix RXC/TXC auto disabling

Quoted 46 lines · Vladimir Oltean
Quoted 27 lines · Florian Fainelli

When support for optionally disabling the TXC was introduced, bit 2 was used to do that operation but the datasheet for 50610M from 2009 does not show bit 2 as being defined. Bit 8 is the one that allows automatic disabling of the RXC/TXC auto disabling during auto power down.

Fixes 52fae0837153 ("tg3 / broadcom: Optionally disable TXC if no link")
---
 include/linux/brcmphy.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/brcmphy.h +1 -1
index da7bf9dfef5b..3dd8203cf780 100644
@@ -193,7 +193,7 @@
 #define BCM54XX_SHD_SCR3		0x05
 #define  BCM54XX_SHD_SCR3_DEF_CLK125	0x0001
 #define  BCM54XX_SHD_SCR3_DLLAPD_DIS	0x0002
-#define  BCM54XX_SHD_SCR3_TRDDAPD	0x0004
+#define  BCM54XX_SHD_SCR3_TRDDAPD	0x0100
 
 /* 01010: Auto Power-Down */
 #define BCM54XX_SHD_APD			0x0a
Signature · 1 line
2.25.1

We may have a problem here, with the layout of the Spare Control 3 register not being as universal as we think.

Your finding may have been the same as Kevin Lo's from commit b0ed0bbfb304 ("net: phy: broadcom: add support for BCM54811 PHY"), therefore your change is making BCM54XX_SHD_SCR3_TRDDAPD == BCM54810_SHD_SCR3_TRDDAPD, so currently this if condition is redundant and probably something else is wrong too:

	if (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY) {
		if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810 ||
		    BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54811)
			val |= BCM54810_SHD_SCR3_TRDDAPD;
		else
			val |= BCM54XX_SHD_SCR3_TRDDAPD;
	}
Quoted 4 lines

I'm not sure what "TRDD" stands for, but my copy of the BCM5464R datasheet shows both bits 2 as well as 8 as being reserved. I have "CLK125 Output" in bit 0, "DLL Auto Power-Down" in bit 1, "SD/Energy Detect Change" in bit 5, "TXC Disable" in bit 6, and that's about it.

Let me go back to the datasheet of all of the PHYs supported by bcm54xx_adjust_rxrefclk() and make sure we set the right bit.

I also have no idea what TRDD stands for.

Quoted 3 lines

But I think it doesn't matter what BCM5464R has, since this feature is gated by PHY_BRCM_DIS_TXCRXC_NOENRGY.

Yes, but it should be working nonetheless.

Signature · 1 line
Florian
#9 lore raw

Re: [PATCH net-next 2/3] net: phy: broadcom: Fix RXC/TXC auto disabling

Quoted 49 lines · Florian Fainelli
Quoted 46 lines · Vladimir Oltean
Quoted 27 lines · Florian Fainelli

When support for optionally disabling the TXC was introduced, bit 2 was used to do that operation but the datasheet for 50610M from 2009 does not show bit 2 as being defined. Bit 8 is the one that allows automatic disabling of the RXC/TXC auto disabling during auto power down.

Fixes 52fae0837153 ("tg3 / broadcom: Optionally disable TXC if no link")
---
 include/linux/brcmphy.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/brcmphy.h +1 -1
index da7bf9dfef5b..3dd8203cf780 100644
@@ -193,7 +193,7 @@
 #define BCM54XX_SHD_SCR3		0x05
 #define  BCM54XX_SHD_SCR3_DEF_CLK125	0x0001
 #define  BCM54XX_SHD_SCR3_DLLAPD_DIS	0x0002
-#define  BCM54XX_SHD_SCR3_TRDDAPD	0x0004
+#define  BCM54XX_SHD_SCR3_TRDDAPD	0x0100
 
 /* 01010: Auto Power-Down */
 #define BCM54XX_SHD_APD			0x0a
Signature · 1 line
2.25.1

We may have a problem here, with the layout of the Spare Control 3 register not being as universal as we think.

Your finding may have been the same as Kevin Lo's from commit b0ed0bbfb304 ("net: phy: broadcom: add support for BCM54811 PHY"), therefore your change is making BCM54XX_SHD_SCR3_TRDDAPD == BCM54810_SHD_SCR3_TRDDAPD, so currently this if condition is redundant and probably something else is wrong too:

	if (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY) {
		if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810 ||
		    BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54811)
			val |= BCM54810_SHD_SCR3_TRDDAPD;
		else
			val |= BCM54XX_SHD_SCR3_TRDDAPD;
	}
Quoted 7 lines
Quoted 4 lines

I'm not sure what "TRDD" stands for, but my copy of the BCM5464R datasheet shows both bits 2 as well as 8 as being reserved. I have "CLK125 Output" in bit 0, "DLL Auto Power-Down" in bit 1, "SD/Energy Detect Change" in bit 5, "TXC Disable" in bit 6, and that's about it.

Let me go back to the datasheet of all of the PHYs supported by bcm54xx_adjust_rxrefclk() and make sure we set the right bit.

I really don't know what the situation is with the 50610 and 50610M and the datasheet appears to reflect that the latest PHYs should be revision 3 or newer (which we explicitly check for earlier), and that bit 8 is supposed to control the disabling of RXC/TXC during auto-power down. I can only trust that Matt checked with the design team back then and that the datasheet must be wrong (would not be an isolated incident), let's try not to fix something that we do not know for sure is broken.

I will respin without this patch and with another clean up added.

Signature · 1 line
Florian
#10 lore raw

PATCH 3/3 net: phy: broadcom: Allow BCM54210E to configure APD

In reply to Florian Fainelli

BCM54210E/BCM50212E has been verified to work correctly with the auto-power down configuration done by bcm54xx_adjust_rxrefclk(), add it to the list of PHYs working.

---
 drivers/net/phy/broadcom.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/phy/broadcom.c +1 -0
index 0472b3470c59..cb790bd802ff 100644
@@ -195,6 +195,7 @@ static void bcm54xx_adjust_rxrefclk(struct phy_device *phydev)
 	if (BRCM_PHY_MODEL(phydev) != PHY_ID_BCM57780 &&
 	    BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610 &&
 	    BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610M &&
+	    BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54210E &&
 	    BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54810 &&
 	    BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54811)
 		return;
Signature · 1 line
2.25.1
maintainer Reviewed-by on the v1 series
#11 lore raw
In reply to Florian Fainelli
Quoted 5 lines · Florian Fainelli

This patch series cleans up the brcmphy.h header and its numerous unused phydev->dev_flags, fixes the RXC/TXC clock disabling bit and allows the BCM54210E PHY to utilize APD.

Thanks!

Hi Florian

I don't know the hardware, but the descriptions seem to fit the code, and i did not spot anything odd.

Andrew