Add StarFive jhb100 soc SGMII GMAC support
Subsystems (6)
Minda Chen
maintainerPATCH v3 4/5 net: stmmac: starfive: Add jhb100 SGMII interface
In reply to Minda ChenAdd 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
@@ -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 = (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,23 +122,33 @@ 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; +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); }
@@ -130,6 +160,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
Minda Chen
maintainerPATCH v3 3/5 dt-bindings: net: starfive,jh7110-dwmac: Add jhb100 sgmii rx clk
In reply to Minda Chenjhb100 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.
So in jhb100 SGMII interface contain 6 clocks, RMII/RGMII interface still contail 5 clocks.
--- .../bindings/net/starfive,jh7110-dwmac.yaml | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +36 -6
@@ -39,20 +39,18 @@ 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 starfive,tx-use-rgmii-clk: description:
@@ -99,6 +97,18 @@ allOf: minItems: 2 maxItems: 2 + clocks: + minItems: 5 + maxItems: 5 + + clock-names: + items: + - const: stmmaceth + - const: pclk + - const: ptp_ref + - const: tx + - const: gtx + resets: maxItems: 1
@@ -111,6 +121,26 @@ allOf: contains: const: starfive,jh7110-dwmac then: + properties: + clocks: + minItems: 5 + maxItems: 6 + + clock-names: + oneOf: + - items: + - const: stmmaceth + - const: pclk + - const: ptp_ref + - const: tx + - const: gtx + - items: + - const: stmmaceth + - const: pclk + - const: ptp_ref + - const: tx + - const: gtx + - const: sgmii_rx if: properties: compatible:
Signature · 1 line
2.17.1
Minda Chen
maintainerv3 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 in 7.1-rc2
previous patch link:
v2: https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/
changes
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 (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
.../bindings/net/starfive,jh7110-dwmac.yaml | 67 ++++++++++++++----- .../ethernet/stmicro/stmmac/dwmac-starfive.c | 59 ++++++++++++---- 2 files changed, 96 insertions(+), 30 deletions(-)
base-commit: 74fe02ce122a6103f207d29fafc8b3a53de6abaf
Signature · 1 line
2.17.1
Minda Chen
maintainerPATCH v3 2/5 dt-bindings: net: starfive,jh7110-dwmac: Add jhb100 support
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.
--- .../bindings/net/starfive,jh7110-dwmac.yaml | 51 ++++++++++++++----- 1 file changed, 37 insertions(+), 14 deletions(-)
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +37 -14
@@ -30,6 +30,10 @@ 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
@@ -107,20 +111,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
Minda Chen
maintainerPATCH v3 1/5 dt-bindings: net: starfive,jh7110-dwmac: Remove jh8100
In reply to Minda ChenRemove 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
@@ -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
Minda Chen
maintainerPATCH v3 5/5 net: stmmac: starfive: Add STMMAC_FLAG_SPH_DISABLE flag
In reply to Minda ChenAdd 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
@@ -147,7 +147,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
Quoted 11 lines · Minda Chen
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.chave supported RGMII/RMII interface. So require to add SGMII support todwmac-starfive.cfor JHB100.
Quoted 7 lines
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 in 7.1-rc2
For networking, please base on net-next/main.
https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
Andrew
Re: [net-next v3 1/5] dt-bindings: net: starfive,jh7110-dwmac: Remove jh8100
In reply to Minda ChenQuoted 5 lines · Minda Chen
Remove jh8100 dt-bindings because do not support it now. StarFive have stopped jh8100 developing and will not release it outside.
Signed-off-by Minda Chen <[email protected]>
Andrew
Re: [net-next v3 4/5] net: stmmac: starfive: Add jhb100 SGMII interface
In reply to Minda Chendrivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat) · line 76
Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +5
-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 = (void *)bsp_priv;
Why (void *) when it is already a void *?
Andrew
---
pw-bot: cr
Re: [net-next v3 5/5] net: stmmac: starfive: Add STMMAC_FLAG_SPH_DISABLE flag
In reply to Minda ChenQuoted 4 lines · Minda Chen
Add default disable split header flag in all the starfive soc.
Signed-off-by Minda Chen <[email protected]>
Andrew
Re: [net-next v3 1/5] dt-bindings: net: starfive,jh7110-dwmac: Remove jh8100
In reply to Minda ChenQuoted 5 lines · Minda Chen
Remove jh8100 dt-bindings because do not support it now. StarFive have stopped jh8100 developing and will not release it outside.
Signed-off-by Minda Chen <[email protected]>
Re: [net-next v3 3/5] dt-bindings: net: starfive,jh7110-dwmac: Add jhb100 sgmii rx clk
In reply to Minda ChenQuoted 5 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.
So in jhb100 SGMII interface contain 6 clocks, RMII/RGMII interface still contail 5 clocks.
Why is this not being done in the commit adding the jhb100 in the first place?
Quoted 36 lines
Signed-off-by Minda Chen <[email protected]>--- .../bindings/net/starfive,jh7110-dwmac.yaml | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-)Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +4
-6@@ -39,20 +39,18 @@ 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 starfive,tx-use-rgmii-clk: description:
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml allOf: · line 102
Quoted 6 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +3
-0@@ -99,6 +97,18 @@ allOf: minItems: 2 maxItems: 2 + clocks: + minItems: 5 + maxItems: 5
This can just be "maxItems: 5", since minItems is set outside the conditional to 5.
Quoted 13 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +9
-0+ + clock-names: + items: + - const: stmmaceth + - const: pclk + - const: ptp_ref + - const: tx + - const: gtx + resets: maxItems: 1
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml allOf: · line 127
Quoted 7 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +4
-0@@ -111,6 +121,26 @@ allOf: contains: const: starfive,jh7110-dwmac then: + properties: + clocks: + minItems: 5 + maxItems: 6
Remove these constraints, since they don't do anything more than the outside ones do.
Quoted 6 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +6
-0+ + clock-names: + oneOf: + - items: + - const: stmmaceth + - const: pclk
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml allOf: · line 143
Quoted 10 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +10
-0+ - const: ptp_ref + - const: tx + - const: gtx + - items: + - const: stmmaceth + - const: pclk + - const: ptp_ref + - const: tx + - const: gtx + - const: sgmii_rx
Can't you just leave this list outside the conditional section, and add the extra item to the end? The only difference appears to be the sgmii_rx clock, and it's at the end.
I'm also not really convinced that this flexibility is required, unless there are some controllers on the platform that do not support sgmii.
pw-bot: changes-requested
Cheers,
Conor.
Quoted 6 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +0
-0if: properties: compatible:Signature · 1 line
2.17.1
Re: [net-next v3 4/5] net: stmmac: starfive: Add jhb100 SGMII interface
In reply to Minda Chendrivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c static const struct starfive_dwmac_data jh7100_data = { · line 163
Quoted 12 lines · 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.
Signed-off-by Minda Chen <[email protected]>Reviewed-by Sai Krishna <[email protected]>drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +1
-0@@ -130,6 +160,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" },
You've declared compatibility with the jh7110, why do you also need to add the new comaptible?
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +0
-0{/* sentinel */ } };MODULE_DEVICE_TABLE (of, starfive_dwmac_match);Signature · 1 line
2.17.1
Minda Chen
maintainerRe: [net-next v3 4/5] net: stmmac: starfive: Add jhb100 SGMII interface
Quoted 8 lines · Minda Chen
Quoted 5 lines
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.
Quoted 11 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c static const struct starfive_dwmac_data jh7100_data = { · line 163
Quoted 7 lines
Signed-off-by Minda Chen <[email protected]>static const struct
starfive_dwmac_datajh7100_data= { static const structof_device_idstarfive_dwmac_match[] = {drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +1
-0{ .compatible = "starfive,jh7100-dwmac", .data = &jh7100_data }, { .compatible = "starfive,jh7110-dwmac" }, + { .compatible = "starfive,jhb100-dwmac" },You've declared compatibility with the jh7110, why do you also need to add the new comaptible?
I am sorry, I forget to remove this.
Quoted 6 lines
Quoted 6 lines
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, starfive_dwmac_match);
--
2.17.1
Minda Chen
maintainerRe: [net-next v3 4/5] net: stmmac: starfive: Add jhb100 SGMII interface
In reply to Andrew LunnQuoted 5 lines
Quoted 4 lines
+static int stmmac_starfive_sgmii_set_clk_rate(void
*bsp_priv, struct clk
*clk_tx_i,
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat) · line 76
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +4
-0+ phy_interface_t __maybe_unused interface, + int speed) +{ +struct starfive_dwmac *dwmac = (void *)bsp_priv;Why (void *) when it is already a void *?
Andrew
Okay, Thanks.
[email protected]
AI reviewRe: [net-next v3 2/5] dt-bindings: net: starfive,jh7110-dwmac: Add jhb100 support
In reply to Minda ChenThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] The compatible string 'starfive,jhb100-dwmac' incorrectly uses 'starfive,jh7110-dwmac' as a…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The compatible string 'starfive,jhb100-dwmac' incorrectly uses 'starfive,jh7110-dwmac' as a fallback, violating Device Tree ABI backwards compatibility rules.
- [Medium] The schema logic for 'starfive,jhb100-dwmac' relies on the invalid fallback string, resulting in incorrect nesting and missing 'select' validation. --
commit 99d98f58cde78e6cc89acf897a5b4bac3713e9c4
Author: Minda Chen <[email protected]>
dt-bindings: net: starfive,jh7110-dwmac: Add jhb100 support
This commit adds support for the jhb100 GMAC, which is based on the Synopsys designware GMAC core. It introduces a new compatible string and updates the interrupt and reset constraints, as the jhb100 hardware has only one reset signal and one interrupt line.
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml properties: · line 36
Quoted 11 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +4
-0@@ -30,6 +30,10 @@ 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
The starfive,jhb100-dwmac hardware physically provides only 1 interrupt and 1 reset, but the fallback starfive,jh7110-dwmac strictly requires 3 interrupts and 2 resets. Does this break Device Tree ABI backwards compatibility?
An unmodified legacy operating system matching the fallback would expect the missing resources and might fail to initialize. Should the starfive,jh7110-dwmac fallback be removed from this list?
[ ... ]
Quoted 13 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +0
-9@@ -107,20 +111,39 @@ allOf: contains: const: starfive,jh7110-dwmac then: - properties: - interrupts: - minItems: 3 - maxItems: 3 - - interrupt-names: - minItems: 3 - maxItems: 3 -
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml allOf: · line 118
Quoted 10 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +5
-5- resets: - minItems: 2 - - reset-names: - minItems: 2 + if: + properties: + compatible: + contains: + const: starfive,jhb100-dwmac
These interrupt and reset constraints for jhb100 are nested inside an outer condition checking for starfive,jh7110-dwmac. If the invalid fallback is removed from the compatible array above, will jhb100 nodes fail this outer condition and silently bypass their specific constraints?
Furthermore, if a device tree correctly drops the jh7110 fallback, will dt_binding_check silently ignore the jhb100 node entirely because it is missing from the custom select block at the top of the schema?
Could these constraints be evaluated in an independent if block, and the new compatible string be added to the select block?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
[email protected]
AI reviewRe: [net-next v3 3/5] dt-bindings: net: starfive,jh7110-dwmac: Add jhb100 sgmii rx clk
In reply to Minda ChenThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] The patch erroneously relaxes clock constraints for the base `starfive,jh7110-dwmac` hardware…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The patch erroneously relaxes clock constraints for the base starfive,jh7110-dwmac hardware, incorrectly allowing it to specify 6 clocks.
- [Low] Replacing the global items array for clock-names with duplicated conditional blocks is a binding anti-pattern.
--
commit 868beb354c5de56282a3dbb82e7d79b8745d272e
Author: Minda Chen <[email protected]>
dt-bindings: net: starfive,jh7110-dwmac: Add jhb100 sgmii rx clk
This commit updates the starfive,jh7110-dwmac binding to support the jhb100 SGMII interface. It adds a 6th clock for the new SGMII interface while noting that existing RMII/RGMII interfaces still use 5 clocks.
Quoted 3 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +0
-0@@ -39,20 +39,18 @@ properties:
[ ... ]
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml properties: · line 53
Quoted 9 lines
clock-names:
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +2
-6- items: - - const: stmmaceth - - const: pclk - - const: ptp_ref - - const: tx - - const: gtx + minItems: 5 + maxItems: 6
This isn't a bug, but does it make sense to keep the full 6-element list defined here at the top level and rely purely on minItems and maxItems overrides inside the conditional blocks?
Standard device tree binding practice usually defines the complete items array once at the top level. By removing the items array here and moving it into the conditionals, the string constants are duplicated across multiple blocks.
[ ... ]
Quoted 14 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +10
-0@@ -111,6 +121,26 @@ allOf: contains: const: starfive,jh7110-dwmac then: + properties: + clocks: + minItems: 5 + maxItems: 6 + + clock-names: + oneOf: + - items: + - const: stmmaceth + - const: pclk
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml allOf: · line 143
Quoted 10 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +10
-0+ - const: ptp_ref + - const: tx + - const: gtx + - items: + - const: stmmaceth + - const: pclk + - const: ptp_ref + - const: tx + - const: gtx + - const: sgmii_rx
Does this inadvertently relax the clock constraints for the base starfive,jh7110-dwmac hardware?
The commit message explicitly states that the 6th clock is a requirement only for the new jhb100 SGMII interface, while other interfaces use 5 clocks.
Since jhb100 uses starfive,jh7110-dwmac as a fallback, this outer then block applies to both hardware variants. Because there is no inner else block for the pure starfive,jh7110-dwmac to restrict maxItems back to 5, will a pure jh7110 device tree now be erroneously permitted to specify 6 clocks and silently pass schema validation?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Minda Chen
maintainerRe: [net-next v3 3/5] dt-bindings: net: starfive,jh7110-dwmac: Add jhb100 sgmii rx clk
In reply to Conor DooleyQuoted 24 lines
Quoted 9 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +6
-0+ + clock-names: + oneOf: + - items: + - const: stmmaceth + - const: pclkDocumentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml allOf: · line 143
Quoted 10 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +10
-0+ - const: ptp_ref + - const: tx + - const: gtx + - items: + - const: stmmaceth + - const: pclk + - const: ptp_ref + - const: tx + - const: gtx + - const: sgmii_rxCan't you just leave this list outside the conditional section, and add the extra item to the end? The only difference appears to be the
sgmii_rxclock, and it's at the end.
Quoted 8 lines
I'm also not really convinced that this flexibility is required, unless there are some controllers on the platform that do not support sgmii.
pw-bot: changes-requested
Cheers,
Conor.
Thanks. Yes, can do it more simple . I think change the clocks-names in properties like this is Okay.
clock-names:
+ minItems: 5
items:
- const: stmmaceth
- const: pclk
- const: ptp_ref
- const: tx
- const: gtx
+ - enum:
+ - sgmii_rx
Quoted 6 lines
Quoted 6 lines
if: properties: compatible:--
2.17.1
Re: [net-next v3 3/5] dt-bindings: net: starfive,jh7110-dwmac: Add jhb100 sgmii rx clk
Quoted 36 lines · Minda Chen
Quoted 24 lines
Quoted 9 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +6
-0+ + clock-names: + oneOf: + - items: + - const: stmmaceth + - const: pclkDocumentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml allOf: · line 143
Quoted 10 lines
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml +10
-0+ - const: ptp_ref + - const: tx + - const: gtx + - items: + - const: stmmaceth + - const: pclk + - const: ptp_ref + - const: tx + - const: gtx + - const: sgmii_rxCan't you just leave this list outside the conditional section, and add the extra item to the end? The only difference appears to be the
sgmii_rxclock, and it's at the end.Quoted 8 lines
I'm also not really convinced that this flexibility is required, unless there are some controllers on the platform that do not support sgmii.
pw-bot: changes-requested
Cheers,
Conor.Thanks. Yes, can do it more simple . I think change the clocks-names in properties like this is Okay.
clock-names:
Review
Quoted 9 lines
(quoted diff) +3
-0+ minItems: 5 items: - const: stmmaceth - const: pclk - const: ptp_ref - const: tx - const: gtx + - enum: + - sgmii_rx
This can remain const, only need the enum if there are options.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
if: properties: compatible:--
2.17.1