linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v3 0/3] net: phy: bcm54811: Fix the PHY initialization
@ 2025-06-25 16:34 Kamil Horák - 2N
  2025-06-25 16:34 ` [PATCH net-next v3 1/3] net: phy: MII-Lite PHY interface mode Kamil Horák - 2N
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Kamil Horák - 2N @ 2025-06-25 16:34 UTC (permalink / raw)
  To: florian.fainelli, bcm-kernel-feedback-list, andrew, hkallweit1,
	linux, davem, edumazet, kuba, pabeni, krzk+dt, conor+dt
  Cc: kamilh, netdev, devicetree, linux-kernel, f.fainelli, robh

From: "Kamil Horák (2N)" <kamilh@axis.com>

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 - 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.

Kamil Horák (2N) (3):
  net: phy: MII-Lite PHY interface mode
  dt-bindings: ethernet-phy: add MII-Lite phy interface type
  net: phy: bcm54811: Fix the PHY initialization

 .../bindings/net/ethernet-controller.yaml     |  1 +
 drivers/net/phy/broadcom.c                    | 30 ++++++++++++++++---
 drivers/net/phy/phy-core.c                    |  1 +
 drivers/net/phy/phy_caps.c                    |  4 +++
 drivers/net/phy/phylink.c                     |  1 +
 include/linux/brcmphy.h                       |  7 +++++
 include/linux/phy.h                           |  4 +++
 7 files changed, 44 insertions(+), 4 deletions(-)

-- 
2.39.5


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next v3 1/3] net: phy: MII-Lite PHY interface mode
  2025-06-25 16:34 [PATCH net-next v3 0/3] net: phy: bcm54811: Fix the PHY initialization Kamil Horák - 2N
@ 2025-06-25 16:34 ` Kamil Horák - 2N
  2025-06-25 16:48   ` Andrew Lunn
  2025-06-25 16:34 ` [PATCH net-next v3 2/3] dt-bindings: ethernet-phy: add MII-Lite phy interface type Kamil Horák - 2N
  2025-06-25 16:34 ` [PATCH net-next v3 3/3] net: phy: bcm54811: Fix the PHY initialization Kamil Horák - 2N
  2 siblings, 1 reply; 7+ messages in thread
From: Kamil Horák - 2N @ 2025-06-25 16:34 UTC (permalink / raw)
  To: florian.fainelli, bcm-kernel-feedback-list, andrew, hkallweit1,
	linux, davem, edumazet, kuba, pabeni, krzk+dt, conor+dt
  Cc: kamilh, netdev, devicetree, linux-kernel, f.fainelli, robh

From: Kamil Horák (2N) <kamilh@axis.com>

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.
Add MII-Lite activation for bcm5481x PHYs.

Signed-off-by: Kamil Horák (2N) <kamilh@axis.com>
---
 drivers/net/phy/broadcom.c | 7 +++++++
 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 ++++
 6 files changed, 23 insertions(+)

diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
index 9b1de54fd483..7d3b85a07b8c 100644
--- a/drivers/net/phy/broadcom.c
+++ b/drivers/net/phy/broadcom.c
@@ -423,6 +423,13 @@ static int bcm54811_config_init(struct phy_device *phydev)
 	/* With BCM54811, BroadR-Reach implies no autoneg */
 	if (priv->brr_mode)
 		phydev->autoneg = 0;
+	/* Enable MII Lite (No TXER, RXER, CRS, COL) if configured */
+	err = bcm_phy_modify_exp(phydev, BCM_EXP_SYNC_ETHERNET,
+				 BCM_EXP_SYNC_ETHERNET_MII_LITE,
+				 phydev->interface == PHY_INTERFACE_MODE_MIILITE ?
+				 BCM_EXP_SYNC_ETHERNET_MII_LITE : 0);
+	if (err < 0)
+		return err;
 
 	return bcm5481x_set_brrmode(phydev, priv->brr_mode);
 }
diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
index c480bb40fa73..605ca20ae192 100644
--- a/drivers/net/phy/phy-core.c
+++ b/drivers/net/phy/phy-core.c
@@ -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:
diff --git a/drivers/net/phy/phy_caps.c b/drivers/net/phy/phy_caps.c
index d11ce1c7e712..2cc9ee97e867 100644
--- a/drivers/net/phy/phy_caps.c
+++ b/drivers/net/phy/phy_caps.c
@@ -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:
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 67218d278ce6..5eb0a90cb3d5 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -237,6 +237,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:
diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h
index 028b3e00378e..15c35655f482 100644
--- a/include/linux/brcmphy.h
+++ b/include/linux/brcmphy.h
@@ -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
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 74c1bcf64b3c..70ac7dc795fc 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -106,6 +106,7 @@ extern const int phy_basic_ports_array[3];
  * @PHY_INTERFACE_MODE_50GBASER: 50GBase-R - with Clause 134 FEC
  * @PHY_INTERFACE_MODE_LAUI: 50 Gigabit Attachment Unit Interface
  * @PHY_INTERFACE_MODE_100GBASEP: 100GBase-P - with Clause 134 FEC
+ * @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.
@@ -150,6 +151,7 @@ typedef enum {
 	PHY_INTERFACE_MODE_50GBASER,
 	PHY_INTERFACE_MODE_LAUI,
 	PHY_INTERFACE_MODE_100GBASEP,
+	PHY_INTERFACE_MODE_MIILITE,
 	PHY_INTERFACE_MODE_MAX,
 } phy_interface_t;
 
@@ -272,6 +274,8 @@ static inline const char *phy_modes(phy_interface_t interface)
 		return "laui";
 	case PHY_INTERFACE_MODE_100GBASEP:
 		return "100gbase-p";
+	case PHY_INTERFACE_MODE_MIILITE:
+		return "mii-lite";
 	default:
 		return "unknown";
 	}
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next v3 2/3] dt-bindings: ethernet-phy: add MII-Lite phy interface type
  2025-06-25 16:34 [PATCH net-next v3 0/3] net: phy: bcm54811: Fix the PHY initialization Kamil Horák - 2N
  2025-06-25 16:34 ` [PATCH net-next v3 1/3] net: phy: MII-Lite PHY interface mode Kamil Horák - 2N
@ 2025-06-25 16:34 ` Kamil Horák - 2N
  2025-06-25 16:34 ` [PATCH net-next v3 3/3] net: phy: bcm54811: Fix the PHY initialization Kamil Horák - 2N
  2 siblings, 0 replies; 7+ messages in thread
From: Kamil Horák - 2N @ 2025-06-25 16:34 UTC (permalink / raw)
  To: florian.fainelli, bcm-kernel-feedback-list, andrew, hkallweit1,
	linux, davem, edumazet, kuba, pabeni, krzk+dt, conor+dt
  Cc: kamilh, netdev, devicetree, linux-kernel, f.fainelli, robh

From: Kamil Horák (2N) <kamilh@axis.com>

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 new interface type "mii-lite" to phy-connection-type enum.

Signed-off-by: Kamil Horák (2N) <kamilh@axis.com>
---
 Documentation/devicetree/bindings/net/ethernet-controller.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
index 7cbf11bbe99c..66b1cfbbfe22 100644
--- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml
+++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
@@ -39,6 +39,7 @@ properties:
       # MAC.
       - internal
       - mii
+      - mii-lite
       - gmii
       - sgmii
       - psgmii
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next v3 3/3] net: phy: bcm54811: Fix the PHY initialization
  2025-06-25 16:34 [PATCH net-next v3 0/3] net: phy: bcm54811: Fix the PHY initialization Kamil Horák - 2N
  2025-06-25 16:34 ` [PATCH net-next v3 1/3] net: phy: MII-Lite PHY interface mode Kamil Horák - 2N
  2025-06-25 16:34 ` [PATCH net-next v3 2/3] dt-bindings: ethernet-phy: add MII-Lite phy interface type Kamil Horák - 2N
@ 2025-06-25 16:34 ` Kamil Horák - 2N
  2025-06-25 16:49   ` Andrew Lunn
  2 siblings, 1 reply; 7+ messages in thread
From: Kamil Horák - 2N @ 2025-06-25 16:34 UTC (permalink / raw)
  To: florian.fainelli, bcm-kernel-feedback-list, andrew, hkallweit1,
	linux, davem, edumazet, kuba, pabeni, krzk+dt, conor+dt
  Cc: kamilh, netdev, devicetree, linux-kernel, f.fainelli, robh

From: Kamil Horák (2N) <kamilh@axis.com>

Reset 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.

Signed-off-by: Kamil Horák (2N) <kamilh@axis.com>
---
 drivers/net/phy/broadcom.c | 23 +++++++++++++++++++----
 include/linux/brcmphy.h    |  1 +
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
index 7d3b85a07b8c..9d38aa7f3b45 100644
--- a/drivers/net/phy/broadcom.c
+++ b/drivers/net/phy/broadcom.c
@@ -662,7 +662,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);
@@ -683,9 +683,17 @@ 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.
+		 */
+		aneg = (BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54811) ?
+			(val & LRESR_LDSABILITY) : 0;
+
 		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);
@@ -742,8 +750,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);
diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h
index 15c35655f482..115a964f3006 100644
--- a/include/linux/brcmphy.h
+++ b/include/linux/brcmphy.h
@@ -137,6 +137,7 @@
 
 #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC			0x07
 #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC_WIRESPEED_EN	0x0010
+#define MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RSVD		0x0060
 #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_EN	0x0080
 #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN	0x0100
 #define MII_BCM54XX_AUXCTL_MISC_FORCE_AMDIX		0x0200
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v3 1/3] net: phy: MII-Lite PHY interface mode
  2025-06-25 16:34 ` [PATCH net-next v3 1/3] net: phy: MII-Lite PHY interface mode Kamil Horák - 2N
@ 2025-06-25 16:48   ` Andrew Lunn
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2025-06-25 16:48 UTC (permalink / raw)
  To: Kamil Horák - 2N
  Cc: florian.fainelli, bcm-kernel-feedback-list, hkallweit1, linux,
	davem, edumazet, kuba, pabeni, krzk+dt, conor+dt, netdev,
	devicetree, linux-kernel, f.fainelli, robh

On Wed, Jun 25, 2025 at 06:34:51PM +0200, Kamil Horák - 2N wrote:
> From: Kamil Horák (2N) <kamilh@axis.com>
> 
> 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.
> Add MII-Lite activation for bcm5481x PHYs.

Please split this patch into two. Add PHY_INTERFACE_MODE_MIILITE to
the core first. Then add support for it to the broadcom PHY.

Splitting it allows you to make the commit message more detailed.

>  
> +	case PHY_INTERFACE_MODE_MIILITE:
> +		link_caps |= BIT(LINK_CAPA_10FD) | BIT(LINK_CAPA_100FD);
> +		break;
> +

You could call this out in the commit message.

>   * Describes the interface between the MAC and PHY.
> @@ -150,6 +151,7 @@ typedef enum {
>  	PHY_INTERFACE_MODE_50GBASER,
>  	PHY_INTERFACE_MODE_LAUI,
>  	PHY_INTERFACE_MODE_100GBASEP,
> +	PHY_INTERFACE_MODE_MIILITE,
>  	PHY_INTERFACE_MODE_MAX,
>  } phy_interface_t;

This enum is not part of the ABI. So you can insert MIILITE directly
after MII.

	Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v3 3/3] net: phy: bcm54811: Fix the PHY initialization
  2025-06-25 16:34 ` [PATCH net-next v3 3/3] net: phy: bcm54811: Fix the PHY initialization Kamil Horák - 2N
@ 2025-06-25 16:49   ` Andrew Lunn
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2025-06-25 16:49 UTC (permalink / raw)
  To: Kamil Horák - 2N
  Cc: florian.fainelli, bcm-kernel-feedback-list, hkallweit1, linux,
	davem, edumazet, kuba, pabeni, krzk+dt, conor+dt, netdev,
	devicetree, linux-kernel, f.fainelli, robh

On Wed, Jun 25, 2025 at 06:34:53PM +0200, Kamil Horák - 2N wrote:
> From: Kamil Horák (2N) <kamilh@axis.com>
> 
> Reset 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.

This actually sounds like a fix. Why are not you adding a Fixes: tag
and posting it for net, not net-next?

	Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next v3 2/3] dt-bindings: ethernet-phy: add MII-Lite phy interface type
  2025-06-26 11:16 [PATCH net-next v3 0/3] " Kamil Horák - 2N
@ 2025-06-26 11:16 ` Kamil Horák - 2N
  0 siblings, 0 replies; 7+ messages in thread
From: Kamil Horák - 2N @ 2025-06-26 11:16 UTC (permalink / raw)
  To: florian.fainelli, bcm-kernel-feedback-list, andrew, hkallweit1,
	linux, davem, edumazet, kuba, pabeni, krzk+dt, conor+dt
  Cc: kamilh, netdev, devicetree, linux-kernel, f.fainelli, robh,
	andrew+netdev

From: Kamil Horák (2N) <kamilh@axis.com>

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 new interface type "mii-lite" to phy-connection-type enum.

Signed-off-by: Kamil Horák (2N) <kamilh@axis.com>
---
 Documentation/devicetree/bindings/net/ethernet-controller.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
index 7cbf11bbe99c..66b1cfbbfe22 100644
--- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml
+++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
@@ -39,6 +39,7 @@ properties:
       # MAC.
       - internal
       - mii
+      - mii-lite
       - gmii
       - sgmii
       - psgmii
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-06-26 11:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-25 16:34 [PATCH net-next v3 0/3] net: phy: bcm54811: Fix the PHY initialization Kamil Horák - 2N
2025-06-25 16:34 ` [PATCH net-next v3 1/3] net: phy: MII-Lite PHY interface mode Kamil Horák - 2N
2025-06-25 16:48   ` Andrew Lunn
2025-06-25 16:34 ` [PATCH net-next v3 2/3] dt-bindings: ethernet-phy: add MII-Lite phy interface type Kamil Horák - 2N
2025-06-25 16:34 ` [PATCH net-next v3 3/3] net: phy: bcm54811: Fix the PHY initialization Kamil Horák - 2N
2025-06-25 16:49   ` Andrew Lunn
  -- strict thread matches above, loose matches on Subject: below --
2025-06-26 11:16 [PATCH net-next v3 0/3] " Kamil Horák - 2N
2025-06-26 11:16 ` [PATCH net-next v3 2/3] dt-bindings: ethernet-phy: add MII-Lite phy interface type Kamil Horák - 2N

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).