2023-01-06 03:14:15

by yanhong wang

[permalink] [raw]
Subject: [PATCH v3 0/7] Add Ethernet driver for StarFive JH7110 SoC

This series adds ethernet support for the StarFive JH7110 RISC-V SoC. The series
includes MAC driver. The MAC version is dwmac-5.20 (from Synopsys DesignWare).
For more information and support, you can visit RVspace wiki[1].

This patchset should be applied after the patchset [2], [3], [4].
[1] https://wiki.rvspace.org/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/[email protected]/

Changes in v3:
- Renamed the dt-bindings 'starfive,jh71x0-dwmac.yaml' to 'starfive,jh7110-dwmac.yaml'.
- Reworded the commit messages.
- Reworded the example context in the dt-binding 'starfive,jh7110-dwmac.yaml'.
- Removed "starfive,jh7100-dwmac" compatible string and special initialization of jh7100.
- Removed the parts of YT8531,so dropped patch 5 and 6.
- Reworded the maxitems number of resets property in 'snps,dwmac.yaml'.

Previous versions:
v1 - https://patchwork.kernel.org/project/linux-riscv/cover/[email protected]/
v2 - https://patchwork.kernel.org/project/linux-riscv/cover/[email protected]/

Emil Renner Berthing (2):
dt-bindings: net: snps,dwmac: Add dwmac-5.20 version
net: stmmac: platform: Add snps,dwmac-5.20 IP compatible string

Yanhong Wang (5):
dt-bindings: net: snps,dwmac: Update the maxitems number of resets and
reset-names
dt-bindings: net: Add support StarFive dwmac
net: stmmac: Add glue layer for StarFive JH7110 SoCs
riscv: dts: starfive: jh7110: Add ethernet device node
riscv: dts: starfive: visionfive-v2: Enable gmac device tree node

.../devicetree/bindings/net/snps,dwmac.yaml | 41 ++++--
.../bindings/net/starfive,jh7110-dwmac.yaml | 113 ++++++++++++++++
MAINTAINERS | 6 +
.../jh7110-starfive-visionfive-v2.dts | 10 ++
arch/riscv/boot/dts/starfive/jh7110.dtsi | 93 +++++++++++++
drivers/net/ethernet/stmicro/stmmac/Kconfig | 12 ++
drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
.../stmicro/stmmac/dwmac-starfive-plat.c | 123 ++++++++++++++++++
.../ethernet/stmicro/stmmac/stmmac_platform.c | 3 +-
9 files changed, 393 insertions(+), 9 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml
create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-starfive-plat.c


base-commit: 094226ad94f471a9f19e8f8e7140a09c2625abaa
prerequisite-patch-id: 8ebfffa09b478904bf7c516f76e2d824ddb60140
prerequisite-patch-id: e8dd8258a4c4062eee2cf07c4607d52baea71f3a
prerequisite-patch-id: d050d884d7b091ff30508a70f5ce5164bb3b72e5
prerequisite-patch-id: 0e41f8cfd4861fcbf6f2e6a2559ce28f0450299e
prerequisite-patch-id: 6e1652501859b85f101ff3b15ced585d43c71c1b
prerequisite-patch-id: 587628a67adad5c655e5f998bf6c4a368ec07d3c
prerequisite-patch-id: 596490c0e397df6c0249c1306fbb1d5bf00b5b83
prerequisite-patch-id: dc873317826b50364344b25ac5cd74e811403f3d
prerequisite-patch-id: a50150f41d8e874553023187e22eb24dffae8d16
prerequisite-patch-id: 735e62255c75801bdc4c0b4107850bce821ff7f5
prerequisite-patch-id: 9d2e83a2dd43e193f534283fab73e90b4f435043
prerequisite-patch-id: 7a43e0849a9afa3c6f83547fd16d9271b07619e5
prerequisite-patch-id: e7aa6fb05314bad6d94c465f3f59969871bf3d2e
prerequisite-patch-id: 6276b2a23818c65ff2ad3d65b562615690cffee9
prerequisite-patch-id: d834ece14ffb525b8c3e661e78736692f33fca9b
prerequisite-patch-id: 4c17a3ce4dae9b788795d915bf775630f5c43c53
prerequisite-patch-id: dabb913fd478e97593e45c23fee4be9fd807f851
prerequisite-patch-id: ba61df106fbe2ada21e8f22c3d2cfaf7809c84b6
prerequisite-patch-id: 287572fb64f83f5d931034f7c75674907584a087
prerequisite-patch-id: 536114f0732646095ef5302a165672b3290d4c75
prerequisite-patch-id: 258ea5f9b8bf41b6981345dcc81795f25865d38f
prerequisite-patch-id: 8b6f2c9660c0ac0ee4e73e4c21aca8e6b75e81b9
prerequisite-patch-id: e09e995700a814a763aa304ad3881a7222acf556
prerequisite-patch-id: 841cd71b556b480d6a5a5e332eeca70d6a76ec3f
prerequisite-patch-id: d074c7ffa2917a9f754d5801e3f67bc980f9de4c
prerequisite-patch-id: 5f59bc7cbbf1230e5ff4761fa7c1116d4e6e5d71
prerequisite-patch-id: d5da3475c6a3588e11a1678feb565bdd459b548e
--
2.17.1


2023-01-06 03:20:17

by yanhong wang

[permalink] [raw]
Subject: [PATCH v3 2/7] dt-bindings: net: snps,dwmac: Update the maxitems number of resets and reset-names

Some boards(such as StarFive VisionFive v2) require more than one value
which defined by resets property, so the original definition can not
meet the requirements. In order to adapt to different requirements,
adjust the maxitems number definition.

Signed-off-by: Yanhong Wang <[email protected]>
---
.../devicetree/bindings/net/snps,dwmac.yaml | 36 ++++++++++++++-----
1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
index e26c3e76ebb7..f7693e8c8d6d 100644
--- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
+++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
@@ -132,14 +132,6 @@ properties:
- pclk
- ptp_ref

- resets:
- maxItems: 1
- description:
- MAC Reset signal.
-
- reset-names:
- const: stmmaceth
-
power-domains:
maxItems: 1

@@ -463,6 +455,34 @@ allOf:
Enables the TSO feature otherwise it will be managed by
MAC HW capability register.

+ - if:
+ properties:
+ compatible:
+ contains:
+ const: starfive,jh7110-dwmac
+
+ then:
+ properties:
+ resets:
+ minItems: 2
+ maxItems: 2
+ reset-names:
+ items:
+ - const: stmmaceth
+ - const: ahb
+ required:
+ - resets
+ - reset-names
+ else:
+ properties:
+ resets:
+ maxItems: 1
+ description:
+ MAC Reset signal.
+
+ reset-names:
+ const: stmmaceth
+
additionalProperties: true

examples:
--
2.17.1

2023-01-06 12:43:31

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v3 2/7] dt-bindings: net: snps,dwmac: Update the maxitems number of resets and reset-names

On 06/01/2023 03:59, Yanhong Wang wrote:
> Some boards(such as StarFive VisionFive v2) require more than one value
> which defined by resets property, so the original definition can not
> meet the requirements. In order to adapt to different requirements,
> adjust the maxitems number definition.
>
> Signed-off-by: Yanhong Wang <[email protected]>
> ---
> .../devicetree/bindings/net/snps,dwmac.yaml | 36 ++++++++++++++-----
> 1 file changed, 28 insertions(+), 8 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> index e26c3e76ebb7..f7693e8c8d6d 100644
> --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> @@ -132,14 +132,6 @@ properties:
> - pclk
> - ptp_ref
>
> - resets:
> - maxItems: 1
> - description:
> - MAC Reset signal.
> -
> - reset-names:
> - const: stmmaceth

Do not remove properties from top-level properties. Instead these should
have widest constraints which are further constrain in allOf:if:then.

Here you should list items with minItems: 1.

> -

Best regards,
Krzysztof

2023-01-06 12:54:02

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v3 2/7] dt-bindings: net: snps,dwmac: Update the maxitems number of resets and reset-names

On 06/01/2023 03:59, Yanhong Wang wrote:
> Some boards(such as StarFive VisionFive v2) require more than one value
> which defined by resets property, so the original definition can not
> meet the requirements. In order to adapt to different requirements,
> adjust the maxitems number definition.
>
> Signed-off-by: Yanhong Wang <[email protected]>
> ---
> .../devicetree/bindings/net/snps,dwmac.yaml | 36 ++++++++++++++-----
> 1 file changed, 28 insertions(+), 8 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> index e26c3e76ebb7..f7693e8c8d6d 100644
> --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
> @@ -132,14 +132,6 @@ properties:
> - pclk
> - ptp_ref
>
> - resets:
> - maxItems: 1
> - description:
> - MAC Reset signal.
> -
> - reset-names:
> - const: stmmaceth
> -
> power-domains:
> maxItems: 1
>
> @@ -463,6 +455,34 @@ allOf:
> Enables the TSO feature otherwise it will be managed by
> MAC HW capability register.
>
> + - if:
> + properties:
> + compatible:
> + contains:
> + const: starfive,jh7110-dwmac
> +

Looking at your next binding patch, this seems a bit clearer. First of
all, this patch on itself has little sense. It's not usable on its own,
because you need the next one.

Probably the snps,dwmac should be just split into common parts used by
devices. It makes code much less readable and unnecessary complicated to
support in one schema both devices and re-usability.

Otherwise I propose to make the resets/reset-names just like clocks are
made: define here wide constraints and update all other users of this
binding to explicitly restrict resets.


Best regards,
Krzysztof

2023-01-17 07:12:06

by yanhong wang

[permalink] [raw]
Subject: Re: [PATCH v3 2/7] dt-bindings: net: snps,dwmac: Update the maxitems number of resets and reset-names



On 2023/1/6 20:44, Krzysztof Kozlowski wrote:
> On 06/01/2023 03:59, Yanhong Wang wrote:
>> Some boards(such as StarFive VisionFive v2) require more than one value
>> which defined by resets property, so the original definition can not
>> meet the requirements. In order to adapt to different requirements,
>> adjust the maxitems number definition.
>>
>> Signed-off-by: Yanhong Wang <[email protected]>
>> ---
>> .../devicetree/bindings/net/snps,dwmac.yaml | 36 ++++++++++++++-----
>> 1 file changed, 28 insertions(+), 8 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
>> index e26c3e76ebb7..f7693e8c8d6d 100644
>> --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
>> +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
>> @@ -132,14 +132,6 @@ properties:
>> - pclk
>> - ptp_ref
>>
>> - resets:
>> - maxItems: 1
>> - description:
>> - MAC Reset signal.
>> -
>> - reset-names:
>> - const: stmmaceth
>> -
>> power-domains:
>> maxItems: 1
>>
>> @@ -463,6 +455,34 @@ allOf:
>> Enables the TSO feature otherwise it will be managed by
>> MAC HW capability register.
>>
>> + - if:
>> + properties:
>> + compatible:
>> + contains:
>> + const: starfive,jh7110-dwmac
>> +
>
> Looking at your next binding patch, this seems a bit clearer. First of
> all, this patch on itself has little sense. It's not usable on its own,
> because you need the next one.
>
> Probably the snps,dwmac should be just split into common parts used by
> devices. It makes code much less readable and unnecessary complicated to
> support in one schema both devices and re-usability.
>
> Otherwise I propose to make the resets/reset-names just like clocks are
> made: define here wide constraints and update all other users of this
> binding to explicitly restrict resets.
>
>

Thanks, refer to the definition of clocks. If it is defined as follows, is it OK?

properties:
resets:
minItems: 1
maxItems: 3
additionalItems: true
items:
- description: MAC Reset signal.

reset-names:
minItems: 1
maxItems: 3
additionalItems: true
contains:
enum:
- stmmaceth


allOf:
- if:
properties:
compatible:
contains:
const: starfive,jh7110-dwmac
then:
properties:
resets:
minItems: 2
maxItems: 2
reset-names:
items:
- const: stmmaceth
- const: ahb
required:
- resets
- reset-names
else:
properties:
resets:
maxItems: 1
description:
MAC Reset signal.

reset-names:
const: stmmaceth

Do you have any other better suggestions?


> Best regards,
> Krzysztof
>

2023-01-17 07:52:33

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v3 2/7] dt-bindings: net: snps,dwmac: Update the maxitems number of resets and reset-names

On 17/01/2023 07:52, yanhong wang wrote:
>
>
> On 2023/1/6 20:44, Krzysztof Kozlowski wrote:
>> On 06/01/2023 03:59, Yanhong Wang wrote:
>>> Some boards(such as StarFive VisionFive v2) require more than one value
>>> which defined by resets property, so the original definition can not
>>> meet the requirements. In order to adapt to different requirements,
>>> adjust the maxitems number definition.
>>>
>>> Signed-off-by: Yanhong Wang <[email protected]>
>>> ---
>>> .../devicetree/bindings/net/snps,dwmac.yaml | 36 ++++++++++++++-----
>>> 1 file changed, 28 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
>>> index e26c3e76ebb7..f7693e8c8d6d 100644
>>> --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
>>> +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
>>> @@ -132,14 +132,6 @@ properties:
>>> - pclk
>>> - ptp_ref
>>>
>>> - resets:
>>> - maxItems: 1
>>> - description:
>>> - MAC Reset signal.
>>> -
>>> - reset-names:
>>> - const: stmmaceth
>>> -
>>> power-domains:
>>> maxItems: 1
>>>
>>> @@ -463,6 +455,34 @@ allOf:
>>> Enables the TSO feature otherwise it will be managed by
>>> MAC HW capability register.
>>>
>>> + - if:
>>> + properties:
>>> + compatible:
>>> + contains:
>>> + const: starfive,jh7110-dwmac
>>> +
>>
>> Looking at your next binding patch, this seems a bit clearer. First of
>> all, this patch on itself has little sense. It's not usable on its own,
>> because you need the next one.
>>
>> Probably the snps,dwmac should be just split into common parts used by
>> devices. It makes code much less readable and unnecessary complicated to
>> support in one schema both devices and re-usability.
>>
>> Otherwise I propose to make the resets/reset-names just like clocks are
>> made: define here wide constraints and update all other users of this
>> binding to explicitly restrict resets.
>>
>>
>
> Thanks, refer to the definition of clocks. If it is defined as follows, is it OK?
>
> properties:
> resets:
> minItems: 1
> maxItems: 3
> additionalItems: true

Drop

> items:
> - description: MAC Reset signal.

Drop both

>
> reset-names:
> minItems: 1
> maxItems: 3
> additionalItems: true

Drop

> contains:
> enum:
> - stmmaceth

Drop all

>
>
> allOf:
> - if:
> properties:
> compatible:
> contains:
> const: starfive,jh7110-dwmac
> then:
> properties:
> resets:
> minItems: 2
> maxItems: 2
> reset-names:
> items:
> - const: stmmaceth
> - const: ahb
> required:
> - resets
> - reset-names
> else:
> properties:
> resets:
> maxItems: 1
> description:
> MAC Reset signal.
>
> reset-names:
> const: stmmaceth
>
> Do you have any other better suggestions?

More or less like this but the allOf should not be in snps,dwmac schema
but in individual schemas. The snps,dwmac is growing unmaintainable...

Best regards,
Krzysztof

2023-01-17 08:51:17

by yanhong wang

[permalink] [raw]
Subject: Re: [PATCH v3 2/7] dt-bindings: net: snps,dwmac: Update the maxitems number of resets and reset-names



On 2023/1/17 15:46, Krzysztof Kozlowski wrote:
> On 17/01/2023 07:52, yanhong wang wrote:
>>
>>
>> On 2023/1/6 20:44, Krzysztof Kozlowski wrote:
>>> On 06/01/2023 03:59, Yanhong Wang wrote:
>>>> Some boards(such as StarFive VisionFive v2) require more than one value
>>>> which defined by resets property, so the original definition can not
>>>> meet the requirements. In order to adapt to different requirements,
>>>> adjust the maxitems number definition.
>>>>
>>>> Signed-off-by: Yanhong Wang <[email protected]>
>>>> ---
>>>> .../devicetree/bindings/net/snps,dwmac.yaml | 36 ++++++++++++++-----
>>>> 1 file changed, 28 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
>>>> index e26c3e76ebb7..f7693e8c8d6d 100644
>>>> --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml
>>>> +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml
>>>> @@ -132,14 +132,6 @@ properties:
>>>> - pclk
>>>> - ptp_ref
>>>>
>>>> - resets:
>>>> - maxItems: 1
>>>> - description:
>>>> - MAC Reset signal.
>>>> -
>>>> - reset-names:
>>>> - const: stmmaceth
>>>> -
>>>> power-domains:
>>>> maxItems: 1
>>>>
>>>> @@ -463,6 +455,34 @@ allOf:
>>>> Enables the TSO feature otherwise it will be managed by
>>>> MAC HW capability register.
>>>>
>>>> + - if:
>>>> + properties:
>>>> + compatible:
>>>> + contains:
>>>> + const: starfive,jh7110-dwmac
>>>> +
>>>
>>> Looking at your next binding patch, this seems a bit clearer. First of
>>> all, this patch on itself has little sense. It's not usable on its own,
>>> because you need the next one.
>>>
>>> Probably the snps,dwmac should be just split into common parts used by
>>> devices. It makes code much less readable and unnecessary complicated to
>>> support in one schema both devices and re-usability.
>>>
>>> Otherwise I propose to make the resets/reset-names just like clocks are
>>> made: define here wide constraints and update all other users of this
>>> binding to explicitly restrict resets.
>>>
>>>
>>
>> Thanks, refer to the definition of clocks. If it is defined as follows, is it OK?
>>
>> properties:
>> resets:
>> minItems: 1
>> maxItems: 3
>> additionalItems: true
>
> Drop
>
>> items:
>> - description: MAC Reset signal.
>
> Drop both
>
>>
>> reset-names:
>> minItems: 1
>> maxItems: 3
>> additionalItems: true
>
> Drop
>
>> contains:
>> enum:
>> - stmmaceth
>
> Drop all
>
>>
>>
>> allOf:
>> - if:
>> properties:
>> compatible:
>> contains:
>> const: starfive,jh7110-dwmac
>> then:
>> properties:
>> resets:
>> minItems: 2
>> maxItems: 2
>> reset-names:
>> items:
>> - const: stmmaceth
>> - const: ahb
>> required:
>> - resets
>> - reset-names
>> else:
>> properties:
>> resets:
>> maxItems: 1
>> description:
>> MAC Reset signal.
>>
>> reset-names:
>> const: stmmaceth
>>
>> Do you have any other better suggestions?
>
> More or less like this but the allOf should not be in snps,dwmac schema
> but in individual schemas. The snps,dwmac is growing unmaintainable...
>

Thanks, it is defined as follows, is it right?

properties:
resets:
minItems: 1
maxItems: 3
additionalItems: true

reset-names:
minItems: 1
maxItems: 3
additionalItems: true


> Best regards,
> Krzysztof
>

2023-01-17 09:01:03

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v3 2/7] dt-bindings: net: snps,dwmac: Update the maxitems number of resets and reset-names

On 17/01/2023 09:14, yanhong wang wrote:
>>> Thanks, refer to the definition of clocks. If it is defined as follows, is it OK?
>>>
>>> properties:
>>> resets:
>>> minItems: 1
>>> maxItems: 3
>>> additionalItems: true
>>
>> Drop
>>
>>> items:
>>> - description: MAC Reset signal.
>>
>> Drop both
>>
>>>
>>> reset-names:
>>> minItems: 1
>>> maxItems: 3
>>> additionalItems: true
>>
>> Drop
>>
>>> contains:
>>> enum:
>>> - stmmaceth
>>
>> Drop all
>>
>>>
>>>
>>> allOf:
>>> - if:
>>> properties:
>>> compatible:
>>> contains:
>>> const: starfive,jh7110-dwmac
>>> then:
>>> properties:
>>> resets:
>>> minItems: 2
>>> maxItems: 2
>>> reset-names:
>>> items:
>>> - const: stmmaceth
>>> - const: ahb
>>> required:
>>> - resets
>>> - reset-names
>>> else:
>>> properties:
>>> resets:
>>> maxItems: 1
>>> description:
>>> MAC Reset signal.
>>>
>>> reset-names:
>>> const: stmmaceth
>>>
>>> Do you have any other better suggestions?
>>
>> More or less like this but the allOf should not be in snps,dwmac schema
>> but in individual schemas. The snps,dwmac is growing unmaintainable...
>>
>
> Thanks, it is defined as follows, is it right?
>
> properties:
> resets:
> minItems: 1
> maxItems: 3
> additionalItems: true
>

Read my comments above. Drop.

Best regards,
Krzysztof