net: phy: bcm54811: Fix the PHY initialization
Subsystems (7)
v5 cover net: phy: bcm54811: Fix the PHY initialization
PATCH 1 - Add MII-Lite PHY interface mode as defined by Broadcom for
their two-wire PHYs. It can be used with most Ethernet controllers under certain limitations (no half-duplex link modes etc.).
PATCH 2 - Add MII-Lite PHY interface type
PATCH 3 - Activation of MII-Lite interface mode on Broadcom bcm5481x
PHYs
PATCH 4 - Fix the BCM54811 PHY initialization so that it conforms
to the datasheet regarding a reserved bit in the LRE Control register, which must be written to zero after every device reset. Also fix the LRE Status register reading, there is another bit to be ignored on bcm54811.
Changes in v2:
- Applied reviewers' comments
- Divided into more patches (separated common and Broadcom PHY specific code)
Changes in v3:
- Added MII-Lite documentation
Changes in v4:
- Added missing Fixes headers
Changes in v5:
- Removed unused PHY register bits definition
Kamil Horák - 2N (4):
net: phy: MII-Lite PHY interface mode
dt-bindings: ethernet-phy: add MII-Lite phy interface type
net: phy: bcm5481x: MII-Lite activation
net: phy: bcm54811: Fix the PHY initialization
.../bindings/net/ethernet-controller.yaml | 1 + Documentation/networking/phy.rst | 7 ++++ drivers/net/phy/broadcom.c | 39 ++++++++++++++++--- drivers/net/phy/phy-core.c | 1 + drivers/net/phy/phy_caps.c | 4 ++ drivers/net/phy/phylink.c | 1 + include/linux/brcmphy.h | 6 +++ include/linux/phy.h | 4 ++ 8 files changed, 58 insertions(+), 5 deletions(-)
Signature · 1 line
2.39.5
PATCH v5 1/4 net: phy: MII-Lite PHY interface mode
Some Broadcom PHYs are capable to operate in simplified MII mode, without TXER, RXER, CRS and COL signals as defined for the MII. The MII-Lite mode can be used on most Ethernet controllers with full MII interface by just leaving the input signals (RXER, CRS, COL) inactive. The absence of COL signal makes half-duplex link modes impossible but does not interfere with BroadR-Reach link modes on Broadcom PHYs, because they are all full-duplex only.
Add MII-Lite interface mode, especially for Broadcom two-wire PHYs.
--- Documentation/networking/phy.rst | 7 +++++++ drivers/net/phy/phy-core.c | 1 + drivers/net/phy/phy_caps.c | 4 ++++ drivers/net/phy/phylink.c | 1 + include/linux/phy.h | 4 ++++ 5 files changed, 17 insertions(+)
Documentation/networking/phy.rst +7 -0
@@ -333,6 +333,13 @@ Some of the interface modes are described below: SerDes lane, each port having speeds of 2.5G / 1G / 100M / 10M achieved through symbol replication. The PCS expects the standard USXGMII code word. +``PHY_INTERFACE_MODE_MIILITE`` + Non-standard, simplified MII mode, without TXER, RXER, CRS and COL signals + as defined for the MII. The absence of COL signal makes half-duplex link + modes impossible but does not interfere with BroadR-Reach link modes on + Broadcom (and other two-wire Ethernet) PHYs, because they are full-duplex + only. + Pause frames / flow control ===========================
drivers/net/phy/phy-core.c +1 -0
@@ -115,6 +115,7 @@ int phy_interface_num_ports(phy_interface_t interface)return 0 ;case PHY_INTERFACE_MODE_INTERNAL :case PHY_INTERFACE_MODE_MII : +case PHY_INTERFACE_MODE_MIILITE :case PHY_INTERFACE_MODE_GMII :case PHY_INTERFACE_MODE_TBI :case PHY_INTERFACE_MODE_REVMII :
drivers/net/phy/phy_caps.c +4 -0
@@ -316,6 +316,10 @@ unsigned long phy_caps_from_interface(phy_interface_t interface) link_caps |=BIT (LINK_CAPA_100HD ) |BIT (LINK_CAPA_100FD );break ; +case PHY_INTERFACE_MODE_MIILITE : + link_caps |=BIT (LINK_CAPA_10FD ) |BIT (LINK_CAPA_100FD ); +break ; +case PHY_INTERFACE_MODE_TBI :case PHY_INTERFACE_MODE_MOCA :case PHY_INTERFACE_MODE_RTBI :
drivers/net/phy/phylink.c +1 -0
@@ -234,6 +234,7 @@ static int phylink_interface_max_speed(phy_interface_t interface)case PHY_INTERFACE_MODE_SMII :case PHY_INTERFACE_MODE_REVMII :case PHY_INTERFACE_MODE_MII : +case PHY_INTERFACE_MODE_MIILITE :return SPEED_100 ;case PHY_INTERFACE_MODE_TBI :
include/linux/phy.h +4 -0
@@ -103,6 +103,7 @@ extern const int phy_basic_ports_array[3];* @PHY_INTERFACE_MODE_QUSGMII: Quad Universal SGMII * @PHY_INTERFACE_MODE_1000BASEKX: 1000Base-KX - with Clause 73 AN * @PHY_INTERFACE_MODE_10G_QXGMII: 10G-QXGMII - 4 ports over 10G USXGMII +* @PHY_INTERFACE_MODE_MIILITE: MII-Lite - MII without RXER TXER CRS COL * @PHY_INTERFACE_MODE_MAX: Book keeping * * Describes the interface between the MAC and PHY.
@@ -144,6 +145,7 @@ typedef enum {PHY_INTERFACE_MODE_QUSGMII ,PHY_INTERFACE_MODE_1000BASEKX ,PHY_INTERFACE_MODE_10G_QXGMII , +PHY_INTERFACE_MODE_MIILITE ,PHY_INTERFACE_MODE_MAX , } phy_interface_t;
@@ -260,6 +262,8 @@ static inline const char *phy_modes(phy_interface_t interface)return "qusgmii" ;case PHY_INTERFACE_MODE_10G_QXGMII :return "10g-qxgmii" ; +case PHY_INTERFACE_MODE_MIILITE : +return "mii-lite" ;default :return "unknown" ; }
Signature · 1 line
2.39.5
PATCH v5 2/4 dt-bindings: ethernet-phy: add MII-Lite phy interface type
In reply to Kamil Horák - 2NSome Broadcom PHYs are capable to operate in simplified MII mode, without TXER, RXER, CRS and COL signals as defined for the MII. The MII-Lite mode can be used on most Ethernet controllers with full MII interface by just leaving the input signals (RXER, CRS, COL) inactive. The absence of COL signal makes half-duplex link modes impossible but does not interfere with BroadR-Reach link modes on Broadcom PHYs, because they are all full-duplex only.
Add new interface type "mii-lite" to phy-connection-type enum.
--- Documentation/devicetree/bindings/net/ethernet-controller.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/net/ethernet-controller.yaml +1 -0
@@ -39,6 +39,7 @@ properties: # MAC. - internal - mii + - mii-lite - gmii - sgmii - psgmii
Signature · 1 line
2.39.5
PATCH v5 3/4 net: phy: bcm5481x: MII-Lite activation
In reply to Kamil Horák - 2NBroadcom PHYs featuring the BroadR-Reach two-wire link mode are usually capable to operate in simplified MII mode, without TXER, RXER, CRS and COL signals as defined for the MII. The absence of COL signal makes half-duplex link modes impossible, however, the BroadR-Reach modes are all full-duplex only.
Depending on the IC encapsulation, there exist MII-Lite-only PHYs such as bcm54811 in MLP. The PHY itself is hardware-strapped to select among multiple RGMII and MII-Lite modes, but the MII-Lite mode must be also activated by software.
Add MII-Lite activation for bcm5481x PHYs.
--- drivers/net/phy/broadcom.c | 14 +++++++++++++- include/linux/brcmphy.h | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/net/phy/broadcom.c +13 -1
@@ -407,7 +407,7 @@ static int bcm5481x_set_brrmode(struct phy_device *phydev, bool on)static int bcm54811_config_init (struct phy_device *phydev) {struct bcm54xx_phy_priv *priv = phydev->priv; -int err, reg; +int err, reg, exp_sync_ethernet;/* Enable CLK125 MUX on LED4 if ref clock is enabled. */ if (!(phydev->dev_flags &PHY_BRCM_RX_REFCLK_UNUSED )) {
@@ -424,6 +424,18 @@ static int bcm54811_config_init(struct phy_device *phydev)if (priv->brr_mode) phydev->autoneg =0 ; +/* Enable MII Lite (No TXER, RXER, CRS, COL) if configured */ +if (phydev->interface ==PHY_INTERFACE_MODE_MIILITE ) + exp_sync_ethernet =BCM_EXP_SYNC_ETHERNET_MII_LITE ; +else + exp_sync_ethernet =0 ; + + err =bcm_phy_modify_exp (phydev,BCM_EXP_SYNC_ETHERNET , +BCM_EXP_SYNC_ETHERNET_MII_LITE , + exp_sync_ethernet); +if (err <0 ) +return err; +return bcm5481x_set_brrmode (phydev, priv->brr_mode); }
include/linux/brcmphy.h +6 -0
@@ -182,6 +182,12 @@#define BCM_LED_MULTICOLOR_ACT 0x9#define BCM_LED_MULTICOLOR_PROGRAM 0xa +/* +* Broadcom Synchronous Ethernet Controls (expansion register 0x0E) +*/ +#define BCM_EXP_SYNC_ETHERNET (MII_BCM54XX_EXP_SEL_ER + 0x0E) +#define BCM_EXP_SYNC_ETHERNET_MII_LITE BIT(11) +/* * BCM5482: Shadow registers * Shadow values go into bits [14:10] of register 0x1c to select a shadow
Signature · 1 line
2.39.5
PATCH v5 4/4 net: phy: bcm54811: Fix the PHY initialization
In reply to Kamil Horák - 2NReset the bit 12 in PHY's LRE Control register upon initialization. According to the datasheet, this bit must be written to zero after every device reset.
--- drivers/net/phy/broadcom.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)
drivers/net/phy/broadcom.c +21 -4
@@ -667,7 +667,7 @@ static int bcm5481x_read_abilities(struct phy_device *phydev) {struct device_node *np = phydev->mdio.dev.of_node;struct bcm54xx_phy_priv *priv = phydev->priv; -int i, val, err; +int i, val, err, aneg;for (i =0 ; i <ARRAY_SIZE (bcm54811_linkmodes); i++)linkmode_clear_bit (bcm54811_linkmodes[i], phydev->supported);
@@ -688,9 +688,19 @@ static int bcm5481x_read_abilities(struct phy_device *phydev)if (val <0 )return val; +/* BCM54811 is not capable of LDS but the corresponding bit +* in LRESR is set to 1 and marked "Ignore" in the datasheet. +* So we must read the bcm54811 as unable to auto-negotiate +* in BroadR-Reach mode. +*/ +if (BRCM_PHY_MODEL (phydev) ==PHY_ID_BCM54811 ) + aneg =0 ; +else + aneg = val &LRESR_LDSABILITY ; +linkmode_mod_bit (ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported, - val &LRESR_LDSABILITY ); + aneg);linkmode_mod_bit (ETHTOOL_LINK_MODE_100baseT1_Full_BIT, phydev->supported, val &LRESR_100_1PAIR );
@@ -747,8 +757,15 @@ static int bcm54811_config_aneg(struct phy_device *phydev)/* Aneg firstly. */ if (priv->brr_mode) { -/* BCM54811 is only capable of autonegotiation in IEEE mode */ - phydev->autoneg =0 ; +/* BCM54811 is only capable of autonegotiation in IEEE mode. +* In BroadR-Reach mode, disable the Long Distance Signaling, +* the BRR mode autoneg as supported in other Broadcom PHYs. +* This bit is marked as "Reserved" and "Default 1, must be +* written to 0 after every device reset" in the datasheet. +*/ + ret =phy_modify (phydev,MII_BCM54XX_LRECR ,LRECR_LDSEN ,0 ); +if (ret <0 ) +return ret; ret =bcm_config_lre_aneg (phydev, false); }else { ret =genphy_config_aneg (phydev);
Signature · 1 line
2.39.5
Jakub Kicinski
maintainerQuoted 6 lines · On Tue, 1 Jul 2025 09:50:11 +0200 Kamil Horák - 2N wrote:
PATCH 1 - Add MII-Lite PHY interface mode as defined by Broadcom for
their two-wire PHYs. It can be used with most Ethernet controllers under certain limitations (no half-duplex link modes etc.).PATCH 2 - Add MII-Lite PHY interface type
Quoted 8 lines
PATCH 3 - Activation of MII-Lite interface mode on Broadcom bcm5481x
PHYsPATCH 4 - Fix the BCM54811 PHY initialization so that it conforms
to the datasheet regarding a reserved bit in the LRE Control register, which must be written to zero after every device reset. Also fix the LRE Status register reading, there is another bit to be ignored on bcm54811.
I'm a bit lost why the first 3 patches are included in a series for net. My naive reading is we didn't support this extra mode, now we do, which sounds like a new feature.. Patch 4, sure, but the dependency is not obvious.
Florian Fainelli
maintainerQuoted 16 lines · Jakub Kicinski
Quoted 6 lines · On Tue, 1 Jul 2025 09:50:11 +0200 Kamil Horák - 2N wrote:
PATCH 1 - Add MII-Lite PHY interface mode as defined by Broadcom for
their two-wire PHYs. It can be used with most Ethernet controllers under certain limitations (no half-duplex link modes etc.).PATCH 2 - Add MII-Lite PHY interface type
Quoted 8 lines
PATCH 3 - Activation of MII-Lite interface mode on Broadcom bcm5481x
PHYsPATCH 4 - Fix the BCM54811 PHY initialization so that it conforms
to the datasheet regarding a reserved bit in the LRE Control register, which must be written to zero after every device reset. Also fix the LRE Status register reading, there is another bit to be ignored on bcm54811.
Quoted 4 lines
I'm a bit lost why the first 3 patches are included in a series for net. My naive reading is we didn't support this extra mode, now we do, which sounds like a new feature.. Patch 4, sure, but the dependency is not obvious.
I don't see the dependency either, at least not in an explicit way. Kamil, could patch #4 stand on its own and routed through "net" while patches 1-3 are routed through "net-next"?
Thanks
Signature · 1 line
Florian
Quoted 17 lines · Florian Fainelli
Quoted 16 lines · Jakub Kicinski
Quoted 14 lines · On Tue, 1 Jul 2025 09:50:11 +0200 Kamil Horák - 2N wrote:
PATCH 1 - Add MII-Lite PHY interface mode as defined by Broadcom for their two-wire PHYs. It can be used with most Ethernet controllers under certain limitations (no half-duplex link modes etc.).
PATCH 2 - Add MII-Lite PHY interface type
PATCH 3 - Activation of MII-Lite interface mode on Broadcom bcm5481x PHYs
PATCH 4 - Fix the BCM54811 PHY initialization so that it conforms to the datasheet regarding a reserved bit in the LRE Control register, which must be written to zero after every device reset. Also fix the LRE Status register reading, there is another bit to be ignored on bcm54811.
Quoted 6 lines
Quoted 4 lines
I'm a bit lost why the first 3 patches are included in a series for net. My naive reading is we didn't support this extra mode, now we do, which sounds like a new feature.. Patch 4, sure, but the dependency is not obvious.
I don't see the dependency either, at least not in an explicit way. Kamil, could patch #4 stand on its own and routed through "net" while patches 1-3 are routed through "net-next"?
It can be done this way, however, even the patch #3 is effectively a fix, not new feature, because the bcm54811 PHY in MLP package only has MII-Lite interface available externally. As far I know, there is no BGA casing available for bcm54811 (unlike bcm54810, that one having both MLP and BGA). Thus, it cannot function without being switched to MII-Lite mode. The introduction of MII-Lite itself is clearly a new feature and it is even (theoretically) available for any MII-capable PHY. So if putting it all to net it is really impossible or contrary to the net-next vs. net selection rules, let's divide it.... To get fully functional, bcm54811-based networking, all patches are necessary so any other user out there must wait for both branches to join.
Quoted 2 lines
Thanks
Kamil
Paolo Abeni
maintainerQuoted 26 lines · On 7/3/25 11:03 AM, Kamil Horák (2N) wrote:
Quoted 17 lines · Florian Fainelli
Quoted 16 lines · Jakub Kicinski
Quoted 14 lines · On Tue, 1 Jul 2025 09:50:11 +0200 Kamil Horák - 2N wrote:
PATCH 1 - Add MII-Lite PHY interface mode as defined by Broadcom for their two-wire PHYs. It can be used with most Ethernet controllers under certain limitations (no half-duplex link modes etc.).
PATCH 2 - Add MII-Lite PHY interface type
PATCH 3 - Activation of MII-Lite interface mode on Broadcom bcm5481x PHYs
PATCH 4 - Fix the BCM54811 PHY initialization so that it conforms to the datasheet regarding a reserved bit in the LRE Control register, which must be written to zero after every device reset. Also fix the LRE Status register reading, there is another bit to be ignored on bcm54811.
Quoted 8 lines
Quoted 4 lines
I'm a bit lost why the first 3 patches are included in a series for net. My naive reading is we didn't support this extra mode, now we do, which sounds like a new feature.. Patch 4, sure, but the dependency is not obvious.
I don't see the dependency either, at least not in an explicit way. Kamil, could patch #4 stand on its own and routed through "net" while patches 1-3 are routed through "net-next"?
Quoted 11 lines
It can be done this way, however, even the patch #3 is effectively a fix, not new feature, because the bcm54811 PHY in MLP package only has MII-Lite interface available externally. As far I know, there is no BGA casing available for bcm54811 (unlike bcm54810, that one having both MLP and BGA). Thus, it cannot function without being switched to MII-Lite mode. The introduction of MII-Lite itself is clearly a new feature and it is even (theoretically) available for any MII-capable PHY. So if putting it all to net it is really impossible or contrary to the net-next vs. net selection rules, let's divide it....
To get fully functional, bcm54811-based networking, all patches are necessary so any other user out there must wait for both branches to join.
The above makes sense to me, but I think it would be nice to capture some of this info in the cover letter - the fact that many people were confused by the series is an hint the info was indeed missing and required.
Please resubmit with an extended cover letter, thanks! (unless Florian jumps in and explicitly asks for something different :-P)
Paolo
Quoted 39 lines · Paolo Abeni
Quoted 26 lines · On 7/3/25 11:03 AM, Kamil Horák (2N) wrote:
Quoted 17 lines · Florian Fainelli
Quoted 16 lines · Jakub Kicinski
Quoted 14 lines · On Tue, 1 Jul 2025 09:50:11 +0200 Kamil Horák - 2N wrote:
PATCH 1 - Add MII-Lite PHY interface mode as defined by Broadcom for
their two-wire PHYs. It can be used with most Ethernet controllers under certain limitations (no half-duplex link modes etc.).PATCH 2 - Add MII-Lite PHY interface type
PATCH 3 - Activation of MII-Lite interface mode on Broadcom bcm5481x
PHYsPATCH 4 - Fix the BCM54811 PHY initialization so that it conforms
to the datasheet regarding a reserved bit in the LRE Control register, which must be written to zero after every device reset. Also fix the LRE Status register reading, there is another bit to be ignored on bcm54811.Quoted 8 lines
Quoted 4 lines
I'm a bit lost why the first 3 patches are included in a series for net. My naive reading is we didn't support this extra mode, now we do, which sounds like a new feature.. Patch 4, sure, but the dependency is not obvious.
I don't see the dependency either, at least not in an explicit way. Kamil, could patch #4 stand on its own and routed through "net" while patches 1-3 are routed through "net-next"?
Quoted 11 lines
It can be done this way, however, even the patch #3 is effectively a fix, not new feature, because the bcm54811 PHY in MLP package only has MII-Lite interface available externally. As far I know, there is no BGA casing available for bcm54811 (unlike bcm54810, that one having both MLP and BGA). Thus, it cannot function without being switched to MII-Lite mode. The introduction of MII-Lite itself is clearly a new feature and it is even (theoretically) available for any MII-capable PHY. So if putting it all to net it is really impossible or contrary to the net-next vs. net selection rules, let's divide it....
To get fully functional, bcm54811-based networking, all patches are necessary so any other user out there must wait for both branches to join.
Quoted 3 lines
The above makes sense to me, but I think it would be nice to capture some of this info in the cover letter - the fact that many people were confused by the series is an hint the info was indeed missing and required.
OK, tried to write more about it
Quoted 4 lines
Please resubmit with an extended cover letter, thanks! (unless Florian jumps in and explicitly asks for something different :-P)
No such request appeared since yesterday, so submitting an updated text version
Quoted 2 lines
Paolo
Kamil