Skip to contentSkip to conversation

Add StarFive jhb100 soc SGMII GMAC support

PATCH Applied Minda Chen 3 participants 7 messages May 27 – Jun 2

Subsystems (6)
lore
Share & tools
lore

Minda Chen

author maintainer
#0 lore raw

v5 cover Add StarFive jhb100 soc SGMII GMAC support

jhb100 is a Starfive new RISC-V SoC for datacenter BMC (BaseBoard Managent Controller). Similar with Aspeed 27x0.

The jhb100 minimal system upstream is in progress:
https://patchwork.kernel.org/project/linux-riscv/cover/[email protected]/

jhb100 GMAC still using designware GMAC core like JH7100 and JH7110, and contains 2 SGMII interfaces, 1 RGMII/RMII interface, 1 RMII interface. In JH7100/JH7110 dwmac-starfive.c have supported RGMII/RMII interface. So require to add SGMII support to dwmac-starfive.c for JHB100.

SGMII serdes PHY has been integrated in JHB100 and do not have driver setting.

In JHB100 EVB board, SGMII connect with motorcomm YT8531s external PHY and support RJ45 ethernet port.

The patch base net-next (base commit list below)

previous patch link:
v2: https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/
v3: https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/
v4: https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/

changes
v5:
patch2 add review tag and squash with v4 patch3
patch3 stmmac_starfive_sgmii_set_clk_rate() not support rate return -EINVAL and claim not support 1000basex

v4: patch1 and patch5 add review tag
patch 3 add sgmii clock dts setting more elegant and simple patch 4 remove redundant compatible and (void *)

v3:
patch2: Add jhb100 attach to jh7110 compatibible, remove redundant commit message. just descript the jhb100 hardware.
patch3: Add oneOf 5 clocks / 6 clocks to claim the clocks and make it pass yaml test.
patch4: Add review tag and unused tag to phy interface.

v2:
1. patch1 Add the remove reason
2. patch2 rename rx clock to sgmii_rx
3. patch4 confirm sgmii rx clock exist, or will probe error sgmii will not call starfive_dwmac_set_mode()

Minda Chen (4):
dt-bindings: net: starfive,jh7110-dwmac: Remove jh8100
dt-bindings: net: starfive,jh7110-dwmac: Add jhb100 support
net: stmmac: starfive: Add jhb100 SGMII interface
net: stmmac: starfive: Add STMMAC_FLAG_SPH_DISABLE flag

 .../bindings/net/starfive,jh7110-dwmac.yaml   | 31 ++++++----
 .../ethernet/stmicro/stmmac/dwmac-starfive.c  | 59 ++++++++++++++-----
 2 files changed, 65 insertions(+), 25 deletions(-)

base-commit: aa064a614efcfa4c300609d1f01134e99a12ad10

Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH v5 1/4 dt-bindings: net: starfive,jh7110-dwmac: Remove jh8100

Remove jh8100 dt-bindings because do not support it now. StarFive have stopped jh8100 developing and will not release it outside.

---
 .../bindings/net/starfive,jh7110-dwmac.yaml   | 28 ++++---------------
 1 file changed, 5 insertions(+), 23 deletions(-)
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +5 -23
index 313a15331661..0d1962980f57 100644
@@ -30,10 +30,6 @@ properties:
       - items:
           - const: starfive,jh7110-dwmac
           - const: snps,dwmac-5.20
-      - items:
-          - const: starfive,jh8100-dwmac
-          - const: starfive,jh7110-dwmac
-          - const: snps,dwmac-5.20
 
   reg:
     maxItems: 1
@@ -120,25 +116,11 @@ allOf:
           minItems: 3
           maxItems: 3
 
-      if:
-        properties:
-          compatible:
-            contains:
-              const: starfive,jh8100-dwmac
-      then:
-        properties:
-          resets:
-            maxItems: 1
-
-          reset-names:
-            const: stmmaceth
-      else:
-        properties:
-          resets:
-            minItems: 2
-
-          reset-names:
-            minItems: 2
+        resets:
+          minItems: 2
+
+        reset-names:
+          minItems: 2
 
 unevaluatedProperties: false
 
Signature · 1 line
2.17.1
author maintainer
#2 lore raw

PATCH v5 2/4 dt-bindings: net: starfive,jh7110-dwmac: Add jhb100 support

In reply to Minda Chen

The jhb100 GMAC still using Synopsys designware GMAC core. hardware features are similar with jh7100.

Add jhb100 GMAC compatible and reset, interrupts features. jhb100 dwmac has only one reset signal and one interrupt line.

jhb100 SGMII interface tx/rx mac clock is split and require to set clock rate in 10M/100M/1000M speed. So dts need to add a new rx clock in code, dts and dt binding doc.

---
 .../bindings/net/starfive,jh7110-dwmac.yaml   | 55 ++++++++++++++-----
 1 file changed, 41 insertions(+), 14 deletions(-)
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +41 -14
index 0d1962980f57..fdcc61c65f87 100644
@@ -30,25 +30,33 @@ properties:
       - items:
           - const: starfive,jh7110-dwmac
           - const: snps,dwmac-5.20
+      - items:
+          - const: starfive,jhb100-dwmac
+          - const: starfive,jh7110-dwmac
+          - const: snps,dwmac-5.20
 
   reg:
     maxItems: 1
 
   clocks:
+    minItems: 5
     items:
       - description: GMAC main clock
       - description: GMAC AHB clock
       - description: PTP clock
       - description: TX clock
       - description: GTX clock
+      - description: SGMII RX clock
 
   clock-names:
+    minItems: 5
     items:
       - const: stmmaceth
       - const: pclk
       - const: ptp_ref
       - const: tx
       - const: gtx
+      - const: sgmii_rx
 
   starfive,tx-use-rgmii-clk:
     description:
@@ -107,20 +115,39 @@ allOf:
           contains:
             const: starfive,jh7110-dwmac
     then:
-      properties:
-        interrupts:
-          minItems: 3
-          maxItems: 3
-
-        interrupt-names:
-          minItems: 3
-          maxItems: 3
-
-        resets:
-          minItems: 2
-
-        reset-names:
-          minItems: 2
+      if:
+        properties:
+          compatible:
+            contains:
+              const: starfive,jhb100-dwmac
+      then:
+        properties:
+          interrupts:
+            maxItems: 1
+
+          interrupt-names:
+            const: macirq
+
+          resets:
+            maxItems: 1
+
+          reset-names:
+            const: stmmaceth
+      else:
+        properties:
+          interrupts:
+            minItems: 3
+            maxItems: 3
+
+          interrupt-names:
+            minItems: 3
+            maxItems: 3
+
+          resets:
+            minItems: 2
+
+          reset-names:
+            minItems: 2
 
 unevaluatedProperties: false
 
Signature · 1 line
2.17.1
#3 lore raw

Re: [net-next v5 2/4] dt-bindings: net: starfive,jh7110-dwmac: Add jhb100 support

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Missing conditional constraints for `clocks` and `clock-names` allows invalid clock…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing conditional constraints for clocks and clock-names allows invalid clock configurations to silently pass schema validation. --

commit 20465cf4546f85d0e237ceacdadbcf9c0b47c74b
Author: Minda Chen <[email protected]>

dt-bindings: net: starfive,jh7110-dwmac: Add jhb100 support

This commit adds support for the jhb100 GMAC, introducing a new compatible string and corresponding single reset and interrupt properties. It also adds a new SGMII RX clock to the global clocks list to support the jhb100 hardware.

Quoted 4 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +0 -0
index 0d1962980f57f..fdcc61c65f87d 100644

[ ... ]

Quoted 9 lines

clocks:

Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +2 -0
+    minItems: 5
     items:
       - description: GMAC main clock
       - description: GMAC AHB clock
       - description: PTP clock
       - description: TX clock
       - description: GTX clock
+      - description: SGMII RX clock

Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml properties: · line 59

Quoted 10 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +2 -0
 
   clock-names:
+    minItems: 5
     items:
       - const: stmmaceth
       - const: pclk
       - const: ptp_ref
       - const: tx
       - const: gtx
+      - const: sgmii_rx

[Severity: Medium]
Since the global definition of clocks and clock-names now implicitly allows 6 items for the new sgmii_rx clock, do the conditionals for older generations need updates?

Without explicitly adding maxItems: 5 to the existing if-then blocks for starfive,jh7110-dwmac and starfive,jh7100-dwmac, it appears device trees for older hardware can now specify 6 clocks and silently pass validation.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
author maintainer
#4 lore raw

PATCH v5 3/4 net: stmmac: starfive: Add jhb100 SGMII interface

In reply to Minda Chen

Add jhb100 compatible and SGMII support. jhb100 soc contains 2 SGMII interfaces and integrated with serdes PHY. SGMII with split TX/RX MAC clock and need to set 2.5M/25M/125M TX/RX clock rate in 10M/100M/1000M speed mode.

---
 .../ethernet/stmicro/stmmac/dwmac-starfive.c  | 59 ++++++++++++++-----
 1 file changed, 45 insertions(+), 14 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +45 -14
index 16b955a6d77b..b1717a6f97f1 100644
@@ -26,6 +26,7 @@ struct starfive_dwmac_data {
 struct starfive_dwmac {
 	struct device *dev;
 	const struct starfive_dwmac_data *data;
+	struct clk *sgmii_rx;
 };
 
 static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
@@ -68,6 +69,25 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
 	return 0;
 }
 
+static int stmmac_starfive_sgmii_set_clk_rate(void *bsp_priv, struct clk *clk_tx_i,
+					      phy_interface_t __maybe_unused interface,
+					      int speed)
+{
+	struct starfive_dwmac *dwmac = bsp_priv;
+	long rate = rgmii_clock(speed);
+	int ret;
+
+	/* MAC clock rate the same as RGMII */
+	if (rate < 0)
+		return -EINVAL;
+
+	ret = clk_set_rate(clk_tx_i, rate);
+	if (ret)
+		return ret;
+
+	return clk_set_rate(dwmac->sgmii_rx, rate);
+}
+
 static int starfive_dwmac_probe(struct platform_device *pdev)
 {
 	struct plat_stmmacenet_data *plat_dat;
@@ -102,23 +122,34 @@ static int starfive_dwmac_probe(struct platform_device *pdev)
 		return dev_err_probe(&pdev->dev, PTR_ERR(clk_gtx),
 				     "error getting gtx clock\n");
 
-	/* Generally, the rgmii_tx clock is provided by the internal clock,
-	 * which needs to match the corresponding clock frequency according
-	 * to different speeds. If the rgmii_tx clock is provided by the
-	 * external rgmii_rxin, there is no need to configure the clock
-	 * internally, because rgmii_rxin will be adaptively adjusted.
-	 */
-	if (!device_property_read_bool(&pdev->dev, "starfive,tx-use-rgmii-clk"))
-		plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
-
 	dwmac->dev = &pdev->dev;
-	plat_dat->flags |= STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP;
 	plat_dat->bsp_priv = dwmac;
-	plat_dat->dma_cfg->dche = true;
+	/* generic sgmii, 1000_BASEX not support yet */
+	if (plat_dat->phy_interface == PHY_INTERFACE_MODE_SGMII) {
+		dwmac->sgmii_rx = devm_clk_get_enabled(&pdev->dev, "sgmii_rx");
+		if (IS_ERR(dwmac->sgmii_rx))
+			return dev_err_probe(&pdev->dev,
+					     PTR_ERR(dwmac->sgmii_rx),
+					     "error getting sgmii rx clock\n");
+		plat_dat->set_clk_tx_rate = stmmac_starfive_sgmii_set_clk_rate;
+	} else {
+		/*
+		 * Generally, the rgmii_tx clock is provided by the internal clock,
+		 * which needs to match the corresponding clock frequency according
+		 * to different speeds. If the rgmii_tx clock is provided by the
+		 * external rgmii_rxin, there is no need to configure the clock
+		 * internally, because rgmii_rxin will be adaptively adjusted.
+		 */
+		if (!device_property_read_bool(&pdev->dev, "starfive,tx-use-rgmii-clk"))
+			plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
+
+		err = starfive_dwmac_set_mode(plat_dat);
+		if (err)
+			return err;
+	}
 
-	err = starfive_dwmac_set_mode(plat_dat);
-	if (err)
-		return err;
+	plat_dat->flags |= STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP;
+	plat_dat->dma_cfg->dche = true;
 
 	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
 }
Signature · 1 line
2.17.1
author maintainer
#5 lore raw

PATCH v5 4/4 net: stmmac: starfive: Add STMMAC_FLAG_SPH_DISABLE flag

In reply to Minda Chen

Add default disable split header flag in all the starfive soc.

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +1 -1
index b1717a6f97f1..b1ea248e3311 100644
@@ -148,7 +148,7 @@ static int starfive_dwmac_probe(struct platform_device *pdev)
 			return err;
 	}
 
-	plat_dat->flags |= STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP;
+	plat_dat->flags |= (STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP | STMMAC_FLAG_SPH_DISABLE);
 	plat_dat->dma_cfg->dche = true;
 
 	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
Signature · 1 line
2.17.1
#6 lore raw
In reply to Minda Chen
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 6 lines · On Wed, 27 May 2026 16:41:04 +0800 you wrote:

jhb100 is a Starfive new RISC-V SoC for datacenter BMC (BaseBoard Managent Controller). Similar with Aspeed 27x0.

The jhb100 minimal system upstream is in progress:
https://patchwork.kernel.org/project/linux-riscv/cover/[email protected]/

Quoted 6 lines

jhb100 GMAC still using designware GMAC core like JH7100 and JH7110, and contains 2 SGMII interfaces, 1 RGMII/RMII interface, 1 RMII interface. In JH7100/JH7110 dwmac-starfive.c have supported RGMII/RMII interface. So require to add SGMII support to dwmac-starfive.c for JHB100.

[...]

Here is the summary with links:
- [net-next,v5,1/4] dt-bindings: net: starfive,jh7110-dwmac: Remove jh8100

    https://git.kernel.org/netdev/net-next/c/106ce4a01c17
  - [net-next,v5,2/4] dt-bindings: net: starfive,jh7110-dwmac: Add jhb100 support
    https://git.kernel.org/netdev/net-next/c/64772e4d06a5
  - [net-next,v5,3/4] net: stmmac: starfive: Add jhb100 SGMII interface
    https://git.kernel.org/netdev/net-next/c/98182c748125
  - [net-next,v5,4/4] net: stmmac: starfive: Add STMMAC_FLAG_SPH_DISABLE flag
    https://git.kernel.org/netdev/net-next/c/7e9ea8de277a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html