Skip to contentSkip to conversation

Add StarFive JHB100 soc SGMII GMAC support

PATCH Superseded Minda Chen 5 participants 16 messages Apr 17 – Apr 21

Subsystems (6)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Minda Chen

author maintainer
#0 lore raw

v2 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 intergrated 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 in 7.0-rc5

changes
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 (5):
dt-bindings: net: starfive,jh7110-dwmac: Remove JH8100
dt-bindings: net: starfive,jh7110-dwmac: Add JHB100 support
dt-bindings: net: starfive,jh7110-dwmac: Add JHB100 sgmii rx clk
net: stmmac: starfive: Add JHB100 SGMII interface
net: stmmac: starfive: Add STMMAC_FLAG_SPH_DISABLE flag

 .../devicetree/bindings/net/snps,dwmac.yaml   |  1 +
 .../bindings/net/starfive,jh7110-dwmac.yaml   | 89 +++++++++++++------
 .../ethernet/stmicro/stmmac/dwmac-starfive.c  | 56 +++++++++---
 3 files changed, 106 insertions(+), 40 deletions(-)

base-commit: c369299895a591d96745d6492d4888259b004a9e

Signature · 1 line
2.17.1
author maintainer
#4 lore raw

PATCH v2 2/5 dt-bindings: net: starfive,jh7110-dwmac: Add JHB100 support

Add StarFive JHB100 dwmac support and compatible.
The JHB100 dwmac shares the same driver code as the JH7110 dwmac, which contains 2 SGMII interfaces, 1 RGMII/RMII interface and 1 RMII interface.
JHB100 dwmac has only one reset signal and one main interrupt line.

Please refer to below:

JHB100: reset-names = "stmmaceth";

Example usage of JHB100 in the device tree:

gmac0: ethernet@11b80000 {
        compatible = "starfive,jhb100-dwmac",
                     "snps,dwmac-5.20";
        interrupts = <225>;
        interrupt-names = "macirq";
        ...
};
---
 .../devicetree/bindings/net/snps,dwmac.yaml   |  1 +
 .../bindings/net/starfive,jh7110-dwmac.yaml   | 23 +++++++++++++++++++
 2 files changed, 24 insertions(+)
Documentation/devicetree/bindings/net/snps,dwmac.yaml +1 -0
index 38bc34dc4f09..85cd3252e8b1 100644
@@ -115,6 +115,7 @@ properties:
         - sophgo,sg2044-dwmac
         - starfive,jh7100-dwmac
         - starfive,jh7110-dwmac
+        - starfive,jhb100-dwmac
         - tesla,fsd-ethqos
         - thead,th1520-gmac
 
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +23 -0
index 0d1962980f57..edc246a71ce3 100644
@@ -18,6 +18,7 @@ select:
         enum:
           - starfive,jh7100-dwmac
           - starfive,jh7110-dwmac
+          - starfive,jhb100-dwmac
   required:
     - compatible
 
@@ -30,6 +31,9 @@ properties:
       - items:
           - const: starfive,jh7110-dwmac
           - const: snps,dwmac-5.20
+      - items:
+          - const: starfive,jhb100-dwmac
+          - const: snps,dwmac-5.20
 
   reg:
     maxItems: 1
@@ -122,6 +126,25 @@ allOf:
         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
+
 unevaluatedProperties: false
 
 examples:
Signature · 1 line
2.17.1
author maintainer
#7 lore raw

PATCH v2 3/5 dt-bindings: net: starfive,jh7110-dwmac: Add JHB100 sgmii rx clk

In reply to Minda Chen

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   | 42 ++++++++++++++++---
 1 file changed, 36 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +36 -6
index edc246a71ce3..3802cdbf1848 100644
@@ -39,20 +39,26 @@ properties:
     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:
-    items:
-      - const: stmmaceth
-      - const: pclk
-      - const: ptp_ref
-      - const: tx
-      - const: gtx
+    minItems: 5
+    maxItems: 6
+    contains:
+      enum:
+       - stmmaceth
+       - pclk
+       - ptp_ref
+       - tx
+       - gtx
+       - sgmii_rx
 
   starfive,tx-use-rgmii-clk:
     description:
@@ -99,6 +105,14 @@ allOf:
           minItems: 2
           maxItems: 2
 
+        clocks:
+          minItems: 5
+          maxItems: 5
+
+        clock-names:
+          minItems: 5
+          maxItems: 5
+
         resets:
           maxItems: 1
 
@@ -120,6 +134,14 @@ allOf:
           minItems: 3
           maxItems: 3
 
+        clocks:
+          minItems: 5
+          maxItems: 5
+
+        clock-names:
+          minItems: 5
+          maxItems: 5
+
         resets:
           minItems: 2
 
@@ -139,6 +161,14 @@ allOf:
         interrupt-names:
           const: macirq
 
+        clocks:
+          minItems: 5
+          maxItems: 6
+
+        clock-names:
+          minItems: 5
+          maxItems: 6
+
         resets:
           maxItems: 1
 
Signature · 1 line
2.17.1
author maintainer
#12 lore raw

PATCH v2 4/5 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  | 54 ++++++++++++++-----
 1 file changed, 42 insertions(+), 12 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +42 -12
index 16b955a6d77b..91698c763dac 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,24 @@ 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 interface, int speed)
+{
+	struct starfive_dwmac *dwmac = (void *)bsp_priv;
+	long rate = rgmii_clock(speed);
+	int ret;
+
+	/* MAC clock rate the same as RGMII */
+	if (rate < 0)
+		return 0;
+
+	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,24 +121,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;
+	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;
+	}
 
 	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;
 
-	err = starfive_dwmac_set_mode(plat_dat);
-	if (err)
-		return err;
-
 	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
 }
 
@@ -130,6 +159,7 @@ static const struct starfive_dwmac_data jh7100_data = {
 static const struct of_device_id starfive_dwmac_match[] = {
 	{ .compatible = "starfive,jh7100-dwmac", .data = &jh7100_data },
 	{ .compatible = "starfive,jh7110-dwmac" },
+	{ .compatible = "starfive,jhb100-dwmac" },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, starfive_dwmac_match);
Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH v2 1/5 dt-bindings: net: starfive,jh7110-dwmac: Remove JH8100

In reply to Minda Chen

Remove JH8100 dt-bindings because do not support it now. StarFive have stopped JH8100 developing and will 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
#8 lore raw

Re: [net-next v2 3/5] dt-bindings: net: starfive,jh7110-dwmac: Add JHB100 sgmii rx clk

In reply to Minda Chen
Quoted 9 lines · Minda Chen

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   | 42 ++++++++++++++++---
 1 file changed, 36 insertions(+), 6 deletions(-)

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:
./Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml:56:8: [warning] wrong indentation: expected 8 but found 7 (indentation)

dtschema/dtc warnings/errors:

doc reference errors (make refcheckdocs):

See https://patchwork.kernel.org/project/devicetree/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

author maintainer
#15 lore raw

PATCH v2 5/5 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 91698c763dac..9146b498658d 100644
@@ -145,7 +145,7 @@ static int starfive_dwmac_probe(struct platform_device *pdev)
 	}
 
 	dwmac->dev = &pdev->dev;
-	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->bsp_priv = dwmac;
 	plat_dat->dma_cfg->dche = true;
 
Signature · 1 line
2.17.1
#2 lore raw

Re: [net-next v2 1/5] dt-bindings: net: starfive,jh7110-dwmac: Remove JH8100

In reply to Minda Chen
Quoted 4 lines · Minda Chen

Remove JH8100 dt-bindings because do not support it now.

StarFive have stopped JH8100 developing and will release it outside.

Is there a missing "not" in that sentence?

Andrew

---
pw-bot: cr

Reviewed-by on v2 4/5
#13 lore raw

RE:[net-next v2 4/5] net: stmmac: starfive: Add JHB100 SGMII interface

In reply to Minda Chen
Quoted 45 lines

-----Original Message-----
From: Minda Chen <[email protected]>
Sent: Friday, April 17, 2026 8:15 AM
To: Alexandre Torgue <[email protected]>; Andrew Lunn <[email protected]>; David S . Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Maxime Coquelin <[email protected]>; Emil Renner Berthing <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; [email protected]
Cc: [email protected]; linux-stm32@st-md- mailman.stormreply.com; [email protected]; Minda Chen <[email protected]>
Subject: [net-next v2 4/5] net: stmmac: starfive: Add JHB100 SGMII interface

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. Signed-off-by:
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  | 54 ++++++++++++++-----
 1 file changed, 42 insertions(+), 12 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +1 -0
index 16b955a6d77b..91698c763dac 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)

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c static int starfive_dwmac_set_mode(struct · line 76

Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +2 -0
@@ -68,6 +69,24 @@ 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 interface, int
 speed) {

phy_interface_t interface is likely unused in stmmac_starfive_sgmii_set_clk_rate → may need __maybe_unused or (void)interface to avoid -Werror=unused-parameter on strict builds.

Quoted 77 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +14 -0
+	struct starfive_dwmac *dwmac = (void *)bsp_priv;
+	long rate = rgmii_clock(speed);
+	int ret;
+
+	/* MAC clock rate the same as RGMII */
+	if (rate < 0)
+		return 0;
+
+	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,24 +121,34 @@

static int starfive_dwmac_probe(struct platform_device *pdev)

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +0 -7
 		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"))

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +2 -1
-		plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
+	if (plat_dat->phy_interface == PHY_INTERFACE_MODE_SGMII) {
+		dwmac->sgmii_rx = devm_clk_get_enabled(&pdev->dev,

"sgmii_rx");

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +5 -0
+		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;

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +3 -0
+	} else {
+		/*
+		 * Generally, the rgmii_tx clock is provided by the internal

clock,

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +1 -0
+		 * which needs to match the corresponding clock frequency

according

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +5 -0
+		 * 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"))

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +7 -5
+			plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
+
+		err = starfive_dwmac_set_mode(plat_dat);
+		if (err)
+			return err;
+	}
 
 	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;
 
-	err = starfive_dwmac_set_mode(plat_dat);
-	if (err)
-		return err;
-
 	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);  }
@@ -130,6 +159,7 @@ static const struct starfive_dwmac_data jh7100_data =
 {  static const struct of_device_id starfive_dwmac_match[] = {
 	{ .compatible = "starfive,jh7100-dwmac", .data = &jh7100_data },
 	{ .compatible = "starfive,jh7110-dwmac" },
+	{ .compatible = "starfive,jhb100-dwmac" },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, starfive_dwmac_match);
--
Quoted 2 lines

2.17.1

author maintainer
#3 lore raw

Re: [net-next v2 1/5] dt-bindings: net: starfive,jh7110-dwmac: Remove JH8100

In reply to Andrew Lunn
Quoted 13 lines · Minda Chen
Quoted 3 lines

Remove JH8100 dt-bindings because do not support it now.

StarFive have stopped JH8100 developing and will release it outside.

Is there a missing "not" in that sentence?

Andrew

---
pw-bot: cr

I will change it next version

author maintainer
#14 lore raw

Re: [net-next v2 4/5] net: stmmac: starfive: Add JHB100 SGMII interface

In reply to Sai Krishna Gajula
Quoted 51 lines
Quoted 51 lines

-----Original Message-----
From: Minda Chen <[email protected]>
Sent: Friday, April 17, 2026 8:15 AM
To: Alexandre Torgue <[email protected]>; Andrew Lunn <[email protected]>; David S . Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Maxime Coquelin <[email protected]>; Emil Renner Berthing <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; [email protected]
Cc: [email protected]; linux-stm32@st-md- mailman.stormreply.com; [email protected]; Minda Chen <[email protected]>
Subject: [net-next v2 4/5] net: stmmac: starfive: Add JHB100 SGMII interface

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. Signed-off-by:
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  | 54
++++++++++++++-----
 1 file changed, 42 insertions(+), 12 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +1 -0
index 16b955a6d77b..91698c763dac 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,24 @@ static int

starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
return 0;
}

Quoted 10 lines
Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +2 -0
+static int stmmac_starfive_sgmii_set_clk_rate(void *bsp_priv, struct
+clk

*clk_tx_i,

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +1 -0
+					      phy_interface_t interface, int

speed) {

phy_interface_t interface is likely unused in stmmac_starfive_sgmii_set_clk_rate → may need __maybe_unused or (void)interface to avoid -Werror=unused-parameter on strict builds.

Okay . Thanks for review!

Quoted 80 lines
Quoted 77 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +14 -0
+	struct starfive_dwmac *dwmac = (void *)bsp_priv;
+	long rate = rgmii_clock(speed);
+	int ret;
+
+	/* MAC clock rate the same as RGMII */
+	if (rate < 0)
+		return 0;
+
+	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,24 +121,34 @@ static

int starfive_dwmac_probe(struct platform_device *pdev)

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +0 -7
 		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"))

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +2 -1
-		plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
+	if (plat_dat->phy_interface == PHY_INTERFACE_MODE_SGMII) {
+		dwmac->sgmii_rx = devm_clk_get_enabled(&pdev->dev,

"sgmii_rx");

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +5 -0
+		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;

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +3 -0
+	} else {
+		/*
+		 * Generally, the rgmii_tx clock is provided by the internal

clock,

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +1 -0
+		 * which needs to match the corresponding clock frequency

according

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +5 -0
+		 * 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"))

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +7 -5
+			plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
+
+		err = starfive_dwmac_set_mode(plat_dat);
+		if (err)
+			return err;
+	}
 
 	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;
 
-	err = starfive_dwmac_set_mode(plat_dat);
-	if (err)
-		return err;
-
 	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);  }
@@ -130,6 +159,7 @@ static const struct starfive_dwmac_data
 jh7100_data = {  static const struct of_device_id starfive_dwmac_match[] = {
 	{ .compatible = "starfive,jh7100-dwmac", .data = &jh7100_data },
 	{ .compatible = "starfive,jh7110-dwmac" },
+	{ .compatible = "starfive,jhb100-dwmac" },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, starfive_dwmac_match);
--
Quoted 2 lines

2.17.1

maintainer
#9 lore raw

Re: [net-next v2 3/5] dt-bindings: net: starfive,jh7110-dwmac: Add JHB100 sgmii rx clk

In reply to Minda Chen
Quoted 33 lines · Minda Chen

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   | 42 ++++++++++++++++---
 1 file changed, 36 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +2 -6
index edc246a71ce3..3802cdbf1848 100644
@@ -39,20 +39,26 @@ properties:
     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:
-    items:
-      - const: stmmaceth
-      - const: pclk
-      - const: ptp_ref
-      - const: tx
-      - const: gtx

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

Quoted 10 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +10 -0
+    minItems: 5
+    maxItems: 6
+    contains:
+      enum:
+       - stmmaceth
+       - pclk
+       - ptp_ref
+       - tx
+       - gtx
+       - sgmii_rx

No, this allows any of the above strings plus any other random strings.

Rob

#5 lore raw

Re: [net-next v2 2/5] dt-bindings: net: starfive,jh7110-dwmac: Add JHB100 support

In reply to Minda Chen
Quoted 2 lines · Minda Chen

Add StarFive JHB100 dwmac support and compatible.
The JHB100 dwmac shares the same driver code as the JH7110 dwmac,

Please describe the hardware or programming interface, not driver code.

Quoted 4 lines

which contains 2 SGMII interfaces, 1 RGMII/RMII interface and 1 RMII interface.
JHB100 dwmac has only one reset signal and one main interrupt line.

Drop all below, not relevant.

Quoted 46 lines

Please refer to below:

JHB100: reset-names = "stmmaceth";

Example usage of JHB100 in the device tree:

gmac0: ethernet@11b80000 {
        compatible = "starfive,jhb100-dwmac",
                     "snps,dwmac-5.20";
        interrupts = <225>;
        interrupt-names = "macirq";
        ...
};
---
 .../devicetree/bindings/net/snps,dwmac.yaml   |  1 +
 .../bindings/net/starfive,jh7110-dwmac.yaml   | 23 +++++++++++++++++++
 2 files changed, 24 insertions(+)
Documentation/devicetree/bindings/net/snps,dwmac.yaml +1 -0
index 38bc34dc4f09..85cd3252e8b1 100644
@@ -115,6 +115,7 @@ properties:
         - sophgo,sg2044-dwmac
         - starfive,jh7100-dwmac
         - starfive,jh7110-dwmac
+        - starfive,jhb100-dwmac
         - tesla,fsd-ethqos
         - thead,th1520-gmac
 
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +1 -0
index 0d1962980f57..edc246a71ce3 100644
@@ -18,6 +18,7 @@ select:
         enum:
           - starfive,jh7100-dwmac
           - starfive,jh7110-dwmac
+          - starfive,jhb100-dwmac
   required:
     - compatible
 

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

Quoted 5 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +2 -0
@@ -30,6 +31,9 @@ properties:
       - items:
           - const: starfive,jh7110-dwmac
           - const: snps,dwmac-5.20
+      - items:
+          - const: starfive,jhb100-dwmac

So that's an enum in previous "items" list.... but your commit msg said your devices are compatible, so confusing.

Best regards,
Krzysztof

author maintainer
#10 lore raw

Re: [net-next v2 3/5] dt-bindings: net: starfive,jh7110-dwmac: Add JHB100 sgmii rx clk

In reply to Rob Herring
Quoted 53 lines · Minda Chen
Quoted 35 lines

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   | 42 ++++++++++++++++---
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml b/Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml index edc246a71ce3..3802cdbf1848 100644

Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +2 -6
@@ -39,20 +39,26 @@ properties:
     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:
-    items:
-      - const: stmmaceth
-      - const: pclk
-      - const: ptp_ref
-      - const: tx
-      - const: gtx

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

Quoted 10 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +10 -0
+    minItems: 5
+    maxItems: 6
+    contains:
+      enum:
+       - stmmaceth
+       - pclk
+       - ptp_ref
+       - tx
+       - gtx
+       - sgmii_rx

No, this allows any of the above strings plus any other random strings.

Quoted 1 line

Rob

Got it. Thanks. In JHB100 I will using "oneOf" 5 clocks or 6 clocks. 7100/7100 are const clock names

author maintainer
#6 lore raw

Re: [net-next v2 2/5] dt-bindings: net: starfive,jh7110-dwmac: Add JHB100 support

In reply to Krzysztof Kozlowski
Quoted 74 lines · Minda Chen
Quoted 2 lines

Add StarFive JHB100 dwmac support and compatible.
The JHB100 dwmac shares the same driver code as the JH7110 dwmac,

Please describe the hardware or programming interface, not driver code.

Quoted 3 lines

which contains 2 SGMII interfaces, 1 RGMII/RMII interface and 1 RMII interface.
JHB100 dwmac has only one reset signal and one main interrupt line.

Drop all below, not relevant.

Quoted 49 lines

Please refer to below:

JHB100: reset-names = "stmmaceth";

Example usage of JHB100 in the device tree:

gmac0: ethernet@11b80000 {
        compatible = "starfive,jhb100-dwmac",
                     "snps,dwmac-5.20";
        interrupts = <225>;
        interrupt-names = "macirq";
        ...
};
---
 .../devicetree/bindings/net/snps,dwmac.yaml   |  1 +
 .../bindings/net/starfive,jh7110-dwmac.yaml   | 23 +++++++++++++++++++
 2 files changed, 24 insertions(+)
Documentation/devicetree/bindings/net/snps,dwmac.yaml +1 -0
index 38bc34dc4f09..85cd3252e8b1 100644
@@ -115,6 +115,7 @@ properties:
         - sophgo,sg2044-dwmac
         - starfive,jh7100-dwmac
         - starfive,jh7110-dwmac
+        - starfive,jhb100-dwmac
         - tesla,fsd-ethqos
         - thead,th1520-gmac
 

diff --git a/Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml b/Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml index 0d1962980f57..edc246a71ce3 100644

Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +1 -0
@@ -18,6 +18,7 @@ select:
         enum:
           - starfive,jh7100-dwmac
           - starfive,jh7110-dwmac
+          - starfive,jhb100-dwmac
   required:
     - compatible
 

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

Quoted 5 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +2 -0
@@ -30,6 +31,9 @@ properties:
       - items:
           - const: starfive,jh7110-dwmac
           - const: snps,dwmac-5.20
+      - items:
+          - const: starfive,jhb100-dwmac

So that's an enum in previous "items" list.... but your commit msg said your devices are compatible, so confusing.

Quoted 2 lines

Best regards,
Krzysztof

Got it . I will correct the commit messages. Thanks

maintainer
#11 lore raw

Re: [net-next v2 3/5] dt-bindings: net: starfive,jh7110-dwmac: Add JHB100 sgmii rx clk

In reply to Minda Chen
Quoted 54 lines · Minda Chen
Quoted 54 lines · Minda Chen
Quoted 35 lines

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   | 42 ++++++++++++++++---
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml b/Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml index edc246a71ce3..3802cdbf1848 100644

Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +2 -6
@@ -39,20 +39,26 @@ properties:
     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:
-    items:
-      - const: stmmaceth
-      - const: pclk
-      - const: ptp_ref
-      - const: tx
-      - const: gtx

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

Quoted 10 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +10 -0
+    minItems: 5
+    maxItems: 6
+    contains:
+      enum:
+       - stmmaceth
+       - pclk
+       - ptp_ref
+       - tx
+       - gtx
+       - sgmii_rx

No, this allows any of the above strings plus any other random strings.

Quoted 3 lines
Quoted 1 line

Rob

Got it. Thanks. In JHB100 I will using "oneOf" 5 clocks or 6 clocks. 7100/7100 are const clock names

No, based on what you did for 'clocks', you just need:

clock-names:
minItems: 5
items:
- const: stmmaceth
- const: pclk
- const: ptp_ref
- const: tx
- const: gtx
- sgmii_rx

Rob