diff mbox series

[v3,2/4] dt-bindings: net: Add Loongson-1 Ethernet Controller

Message ID 20230824125012.1040288-3-keguang.zhang@gmail.com (mailing list archive)
State Superseded
Headers show
Series Move Loongson1 MAC arch-code to the driver dir | expand

Commit Message

Keguang Zhang Aug. 24, 2023, 12:50 p.m. UTC
Add devicetree binding document for Loongson-1 Ethernet controller.

Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
V2 -> V3: Split the DT-schema file into loongson,ls1b-gmac.yaml
          and loongson,ls1c-emac.yaml (suggested by Serge Semin)
          Change the compatibles to loongson,ls1b-gmac and loongson,ls1c-emac
          Rename loongson,dwmac-syscon to loongson,ls1-syscon
          Amend the title
          Add description
          Add Reviewed-by tag from Krzysztof Kozlowski(Sorry! I'm not sure)
V1 -> V2: Fix "clock-names" and "interrupt-names" property
          Rename the syscon property to "loongson,dwmac-syscon"
          Drop "phy-handle" and "phy-mode" requirement
          Revert adding loongson,ls1b-dwmac/loongson,ls1c-dwmac
          to snps,dwmac.yaml

 .../bindings/net/loongson,ls1b-gmac.yaml      | 115 ++++++++++++++++++
 .../bindings/net/loongson,ls1c-emac.yaml      | 114 +++++++++++++++++
 2 files changed, 229 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
 create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml

Comments

Serge Semin Aug. 26, 2023, 9:04 p.m. UTC | #1
On Thu, Aug 24, 2023 at 08:50:10PM +0800, Keguang Zhang wrote:
> Add devicetree binding document for Loongson-1 Ethernet controller.
> 
> Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
> V2 -> V3: Split the DT-schema file into loongson,ls1b-gmac.yaml
>           and loongson,ls1c-emac.yaml (suggested by Serge Semin)
>           Change the compatibles to loongson,ls1b-gmac and loongson,ls1c-emac
>           Rename loongson,dwmac-syscon to loongson,ls1-syscon
>           Amend the title
>           Add description
>           Add Reviewed-by tag from Krzysztof Kozlowski(Sorry! I'm not sure)
> V1 -> V2: Fix "clock-names" and "interrupt-names" property
>           Rename the syscon property to "loongson,dwmac-syscon"
>           Drop "phy-handle" and "phy-mode" requirement
>           Revert adding loongson,ls1b-dwmac/loongson,ls1c-dwmac
>           to snps,dwmac.yaml
> 
>  .../bindings/net/loongson,ls1b-gmac.yaml      | 115 ++++++++++++++++++
>  .../bindings/net/loongson,ls1c-emac.yaml      | 114 +++++++++++++++++
>  2 files changed, 229 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
>  create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
> 
> diff --git a/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml b/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
> new file mode 100644
> index 000000000000..f661d5b86649
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
> @@ -0,0 +1,115 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/net/loongson,ls1b-gmac.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Loongson-1B Gigabit Ethernet MAC Controller
> +
> +maintainers:
> +  - Keguang Zhang <keguang.zhang@gmail.com>
> +

> +description:

Use "|" to keep the text formatting.
  description: |

> +  Loongson-1B Gigabit Ethernet MAC Controller is based on
> +  Synopsys DesignWare MAC (version 3.50a).
> +

> +  Main features
> +  - Dual 10/100/1000Mbps GMAC controllers
> +  - Full-duplex operation (IEEE 802.3x flow control automatic transmission)
> +  - Half-duplex operation (CSMA/CD Protocol and back-pressure support)
> +  - RX Checksum Offload
> +  - TX Checksum insertion
> +  - MII interface
> +  - RGMII interface

If only all the DW *MAC-based devices have such info in the
bindings the life would have been much easier...

> +
> +select:
> +  properties:
> +    compatible:
> +      contains:
> +        enum:
> +          - loongson,ls1b-gmac
> +  required:
> +    - compatible
> +
> +properties:
> +  compatible:
> +    items:
> +      - enum:
> +          - loongson,ls1b-gmac
> +      - const: snps,dwmac-3.50a
> +
> +  reg:
> +    maxItems: 1
> +
> +  clocks:
> +    maxItems: 1
> +

> +  clock-names:
> +    items:
> +      - const: stmmaceth

since there is a single clock then just:
  clock-names:
    const: stmmaceth

> +
> +  interrupts:
> +    maxItems: 1
> +

> +  interrupt-names:
> +    items:
> +      - const: macirq

ditto. just
  interrupt-names:
    const: macirq

> +
> +  loongson,ls1-syscon:
> +    $ref: /schemas/types.yaml#/definitions/phandle
> +    description:
> +      Phandle to the syscon containing some extra configurations
> +      including PHY interface mode.
> +

> +  phy-mode:
> +    items:
> +      - enum:
> +          - mii
> +          - rgmii-id

it's a single string then just:
  phy-mode:
    enum: ...

> +
> +required:
> +  - compatible
> +  - reg
> +  - clocks
> +  - clock-names
> +  - interrupts
> +  - interrupt-names
> +  - loongson,ls1-syscon
> +
> +allOf:
> +  - $ref: snps,dwmac.yaml#
> +
> +unevaluatedProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/clock/loongson,ls1x-clk.h>
> +    #include <dt-bindings/interrupt-controller/irq.h>
> +
> +    gmac0: ethernet@1fe10000 {
> +        compatible = "loongson,ls1b-gmac", "snps,dwmac-3.50a";
> +        reg = <0x1fe10000 0x10000>;
> +
> +        clocks = <&clkc LS1X_CLKID_AHB>;
> +        clock-names = "stmmaceth";
> +
> +        interrupt-parent = <&intc1>;
> +        interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
> +        interrupt-names = "macirq";
> +
> +        loongson,ls1-syscon = <&syscon>;
> +
> +        phy-handle = <&phy0>;
> +        phy-mode = "mii";
> +        snps,pbl = <1>;
> +
> +        mdio {
> +            #address-cells = <1>;
> +            #size-cells = <0>;
> +            compatible = "snps,dwmac-mdio";
> +
> +            phy0: ethernet-phy@0 {
> +                reg = <0x0>;
> +            };
> +        };
> +    };
> diff --git a/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml b/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
> new file mode 100644
> index 000000000000..1ffad41941bf
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
> @@ -0,0 +1,114 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/net/loongson,ls1c-emac.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Loongson-1C Ethernet MAC Controller
> +
> +maintainers:
> +  - Keguang Zhang <keguang.zhang@gmail.com>
> +

> +description:

the same comment about the "|" modifier.

> +  Loongson-1C Ethernet MAC Controller is based on
> +  Synopsys DesignWare MAC (version 3.50a).
> +

> +  Main features
> +  - 10/100Mbps
> +  - Full-duplex operation (IEEE 802.3x flow control automatic transmission)
> +  - Half-duplex operation (CSMA/CD Protocol and back-pressure support)
> +  - IEEE 802.1Q VLAN tag detection for reception frames
> +  - MII interface
> +  - RMII interface

Based on the plat_stmmacenet_data data defined for the LS1C MAC it
also support support Tx COE. Isn't it? What about Rx COE?

> +
> +select:
> +  properties:
> +    compatible:
> +      contains:
> +        enum:
> +          - loongson,ls1c-emac
> +  required:
> +    - compatible
> +
> +properties:
> +  compatible:
> +    items:
> +      - enum:
> +          - loongson,ls1c-emac
> +      - const: snps,dwmac-3.50a
> +
> +  reg:
> +    maxItems: 1
> +
> +  clocks:
> +    maxItems: 1
> +

> +  clock-names:
> +    items:
> +      - const: stmmaceth

  clock-names:
    const: stmmaceth
?

> +
> +  interrupts:
> +    maxItems: 1
> +

> +  interrupt-names:
> +    items:
> +      - const: macirq

  interrupt-names:
    const: macirq
?

> +
> +  loongson,ls1-syscon:
> +    $ref: /schemas/types.yaml#/definitions/phandle
> +    description:
> +      Phandle to the syscon containing some extra configurations
> +      including PHY interface mode.
> +

> +  phy-mode:
> +    items:
> +      - enum:
> +          - mii
> +          - rmii

  phy-mode:
    enum: ...
?

-Serge(y)

> +
> +required:
> +  - compatible
> +  - reg
> +  - clocks
> +  - clock-names
> +  - interrupts
> +  - interrupt-names
> +  - loongson,ls1-syscon
> +
> +allOf:
> +  - $ref: snps,dwmac.yaml#
> +
> +unevaluatedProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/clock/loongson,ls1x-clk.h>
> +    #include <dt-bindings/interrupt-controller/irq.h>
> +
> +    emac: ethernet@1fe10000 {
> +        compatible = "loongson,ls1c-emac", "snps,dwmac-3.50a";
> +        reg = <0x1fe10000 0x10000>;
> +
> +        clocks = <&clkc LS1X_CLKID_AHB>;
> +        clock-names = "stmmaceth";
> +
> +        interrupt-parent = <&intc1>;
> +        interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
> +        interrupt-names = "macirq";
> +
> +        loongson,ls1-syscon = <&syscon>;
> +
> +        phy-handle = <&phy0>;
> +        phy-mode = "mii";
> +        snps,pbl = <1>;
> +
> +        mdio {
> +            #address-cells = <1>;
> +            #size-cells = <0>;
> +            compatible = "snps,dwmac-mdio";
> +
> +            phy0: ethernet-phy@13 {
> +                reg = <0x13>;
> +            };
> +        };
> +    };
> -- 
> 2.39.2
> 
>
Krzysztof Kozlowski Aug. 27, 2023, 7:56 a.m. UTC | #2
On 26/08/2023 23:04, Serge Semin wrote:
>> +  clock-names:
>> +    items:
>> +      - const: stmmaceth
> 
>   clock-names:
>     const: stmmaceth
> ?

The existing syntax is correct. This is a string array.

> 
>> +
>> +  interrupts:
>> +    maxItems: 1
>> +
> 
>> +  interrupt-names:
>> +    items:
>> +      - const: macirq
> 
>   interrupt-names:
>     const: macirq
> ?

As well.

> 
>> +
>> +  loongson,ls1-syscon:
>> +    $ref: /schemas/types.yaml#/definitions/phandle
>> +    description:
>> +      Phandle to the syscon containing some extra configurations
>> +      including PHY interface mode.
>> +
> 
>> +  phy-mode:
>> +    items:
>> +      - enum:
>> +          - mii
>> +          - rmii
> 
>   phy-mode:
>     enum: ...
> ?

Here indeed, this is a string, not a list, so items are wrong.



Best regards,
Krzysztof
Serge Semin Aug. 27, 2023, 9:01 p.m. UTC | #3
Hi Krzysztof

On Sun, Aug 27, 2023 at 09:56:06AM +0200, Krzysztof Kozlowski wrote:
> On 26/08/2023 23:04, Serge Semin wrote:
> >> +  clock-names:
> >> +    items:
> >> +      - const: stmmaceth
> > 
> >   clock-names:
> >     const: stmmaceth
> > ?
> 

> The existing syntax is correct. This is a string array.

Could you please clarify whether it's a requirement (always specify
items: property for an array) or just an acceptable option (another
one is suggested in my comment)? I am asking because:
1. In this case the "clock-names" array is supposed to have only one
item. Directly setting "const: stmmaceth" with no items: property
shall simplify it.
2. There are single-entry "clock-names" property in the DT-bindings
defined as I suggested.
3. There is a "compatible" property which is also a string array but
it can be defined as I suggested (omitting the items property).

so based on all of that using the "items:"-based constraint here seems
redundant. Am I wrong to think like that? If so in what aspect?

-Serge(y)

> 
> > 
> >> +
> >> +  interrupts:
> >> +    maxItems: 1
> >> +
> > 
> >> +  interrupt-names:
> >> +    items:
> >> +      - const: macirq
> > 
> >   interrupt-names:
> >     const: macirq
> > ?
> 
> As well.
> 
> > 
> >> +
> >> +  loongson,ls1-syscon:
> >> +    $ref: /schemas/types.yaml#/definitions/phandle
> >> +    description:
> >> +      Phandle to the syscon containing some extra configurations
> >> +      including PHY interface mode.
> >> +
> > 
> >> +  phy-mode:
> >> +    items:
> >> +      - enum:
> >> +          - mii
> >> +          - rmii
> > 
> >   phy-mode:
> >     enum: ...
> > ?
> 
> Here indeed, this is a string, not a list, so items are wrong.
> 
> 
> 
> Best regards,
> Krzysztof
>
Keguang Zhang Aug. 28, 2023, 4:38 a.m. UTC | #4
On Sun, Aug 27, 2023 at 5:04 AM Serge Semin <fancer.lancer@gmail.com> wrote:
>
> On Thu, Aug 24, 2023 at 08:50:10PM +0800, Keguang Zhang wrote:
> > Add devicetree binding document for Loongson-1 Ethernet controller.
> >
> > Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
> > Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> > ---
> > V2 -> V3: Split the DT-schema file into loongson,ls1b-gmac.yaml
> >           and loongson,ls1c-emac.yaml (suggested by Serge Semin)
> >           Change the compatibles to loongson,ls1b-gmac and loongson,ls1c-emac
> >           Rename loongson,dwmac-syscon to loongson,ls1-syscon
> >           Amend the title
> >           Add description
> >           Add Reviewed-by tag from Krzysztof Kozlowski(Sorry! I'm not sure)
> > V1 -> V2: Fix "clock-names" and "interrupt-names" property
> >           Rename the syscon property to "loongson,dwmac-syscon"
> >           Drop "phy-handle" and "phy-mode" requirement
> >           Revert adding loongson,ls1b-dwmac/loongson,ls1c-dwmac
> >           to snps,dwmac.yaml
> >
> >  .../bindings/net/loongson,ls1b-gmac.yaml      | 115 ++++++++++++++++++
> >  .../bindings/net/loongson,ls1c-emac.yaml      | 114 +++++++++++++++++
> >  2 files changed, 229 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
> >  create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml b/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
> > new file mode 100644
> > index 000000000000..f661d5b86649
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
> > @@ -0,0 +1,115 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/net/loongson,ls1b-gmac.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Loongson-1B Gigabit Ethernet MAC Controller
> > +
> > +maintainers:
> > +  - Keguang Zhang <keguang.zhang@gmail.com>
> > +
>
> > +description:
>
> Use "|" to keep the text formatting.
>   description: |
>
> > +  Loongson-1B Gigabit Ethernet MAC Controller is based on
> > +  Synopsys DesignWare MAC (version 3.50a).
> > +
>
> > +  Main features
> > +  - Dual 10/100/1000Mbps GMAC controllers
> > +  - Full-duplex operation (IEEE 802.3x flow control automatic transmission)
> > +  - Half-duplex operation (CSMA/CD Protocol and back-pressure support)
> > +  - RX Checksum Offload
> > +  - TX Checksum insertion
> > +  - MII interface
> > +  - RGMII interface
>
> If only all the DW *MAC-based devices have such info in the
> bindings the life would have been much easier...
>
> > +
> > +select:
> > +  properties:
> > +    compatible:
> > +      contains:
> > +        enum:
> > +          - loongson,ls1b-gmac
> > +  required:
> > +    - compatible
> > +
> > +properties:
> > +  compatible:
> > +    items:
> > +      - enum:
> > +          - loongson,ls1b-gmac
> > +      - const: snps,dwmac-3.50a
> > +
> > +  reg:
> > +    maxItems: 1
> > +
> > +  clocks:
> > +    maxItems: 1
> > +
>
> > +  clock-names:
> > +    items:
> > +      - const: stmmaceth
>
> since there is a single clock then just:
>   clock-names:
>     const: stmmaceth
>
> > +
> > +  interrupts:
> > +    maxItems: 1
> > +
>
> > +  interrupt-names:
> > +    items:
> > +      - const: macirq
>
> ditto. just
>   interrupt-names:
>     const: macirq
>
> > +
> > +  loongson,ls1-syscon:
> > +    $ref: /schemas/types.yaml#/definitions/phandle
> > +    description:
> > +      Phandle to the syscon containing some extra configurations
> > +      including PHY interface mode.
> > +
>
> > +  phy-mode:
> > +    items:
> > +      - enum:
> > +          - mii
> > +          - rgmii-id
>
> it's a single string then just:
>   phy-mode:
>     enum: ...
>
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - clocks
> > +  - clock-names
> > +  - interrupts
> > +  - interrupt-names
> > +  - loongson,ls1-syscon
> > +
> > +allOf:
> > +  - $ref: snps,dwmac.yaml#
> > +
> > +unevaluatedProperties: false
> > +
> > +examples:
> > +  - |
> > +    #include <dt-bindings/clock/loongson,ls1x-clk.h>
> > +    #include <dt-bindings/interrupt-controller/irq.h>
> > +
> > +    gmac0: ethernet@1fe10000 {
> > +        compatible = "loongson,ls1b-gmac", "snps,dwmac-3.50a";
> > +        reg = <0x1fe10000 0x10000>;
> > +
> > +        clocks = <&clkc LS1X_CLKID_AHB>;
> > +        clock-names = "stmmaceth";
> > +
> > +        interrupt-parent = <&intc1>;
> > +        interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
> > +        interrupt-names = "macirq";
> > +
> > +        loongson,ls1-syscon = <&syscon>;
> > +
> > +        phy-handle = <&phy0>;
> > +        phy-mode = "mii";
> > +        snps,pbl = <1>;
> > +
> > +        mdio {
> > +            #address-cells = <1>;
> > +            #size-cells = <0>;
> > +            compatible = "snps,dwmac-mdio";
> > +
> > +            phy0: ethernet-phy@0 {
> > +                reg = <0x0>;
> > +            };
> > +        };
> > +    };
> > diff --git a/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml b/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
> > new file mode 100644
> > index 000000000000..1ffad41941bf
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
> > @@ -0,0 +1,114 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/net/loongson,ls1c-emac.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Loongson-1C Ethernet MAC Controller
> > +
> > +maintainers:
> > +  - Keguang Zhang <keguang.zhang@gmail.com>
> > +
>
> > +description:
>
> the same comment about the "|" modifier.
>
> > +  Loongson-1C Ethernet MAC Controller is based on
> > +  Synopsys DesignWare MAC (version 3.50a).
> > +
>
> > +  Main features
> > +  - 10/100Mbps
> > +  - Full-duplex operation (IEEE 802.3x flow control automatic transmission)
> > +  - Half-duplex operation (CSMA/CD Protocol and back-pressure support)
> > +  - IEEE 802.1Q VLAN tag detection for reception frames
> > +  - MII interface
> > +  - RMII interface
>
> Based on the plat_stmmacenet_data data defined for the LS1C MAC it
> also support support Tx COE. Isn't it? What about Rx COE?
>
According to the value read from HW Feature Register(offset 0x1058),
both TXCOESEL an
RXTYP1COE/RXTYP2COE are zero.
Therefore, neither TX COE nor RX COE is supported by LS1C MAC.
Current plat_stmmacenet_data is Inaccurate.

> > +
> > +select:
> > +  properties:
> > +    compatible:
> > +      contains:
> > +        enum:
> > +          - loongson,ls1c-emac
> > +  required:
> > +    - compatible
> > +
> > +properties:
> > +  compatible:
> > +    items:
> > +      - enum:
> > +          - loongson,ls1c-emac
> > +      - const: snps,dwmac-3.50a
> > +
> > +  reg:
> > +    maxItems: 1
> > +
> > +  clocks:
> > +    maxItems: 1
> > +
>
> > +  clock-names:
> > +    items:
> > +      - const: stmmaceth
>
>   clock-names:
>     const: stmmaceth
> ?
>
> > +
> > +  interrupts:
> > +    maxItems: 1
> > +
>
> > +  interrupt-names:
> > +    items:
> > +      - const: macirq
>
>   interrupt-names:
>     const: macirq
> ?
>
> > +
> > +  loongson,ls1-syscon:
> > +    $ref: /schemas/types.yaml#/definitions/phandle
> > +    description:
> > +      Phandle to the syscon containing some extra configurations
> > +      including PHY interface mode.
> > +
>
> > +  phy-mode:
> > +    items:
> > +      - enum:
> > +          - mii
> > +          - rmii
>
>   phy-mode:
>     enum: ...
> ?
>
> -Serge(y)
>
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - clocks
> > +  - clock-names
> > +  - interrupts
> > +  - interrupt-names
> > +  - loongson,ls1-syscon
> > +
> > +allOf:
> > +  - $ref: snps,dwmac.yaml#
> > +
> > +unevaluatedProperties: false
> > +
> > +examples:
> > +  - |
> > +    #include <dt-bindings/clock/loongson,ls1x-clk.h>
> > +    #include <dt-bindings/interrupt-controller/irq.h>
> > +
> > +    emac: ethernet@1fe10000 {
> > +        compatible = "loongson,ls1c-emac", "snps,dwmac-3.50a";
> > +        reg = <0x1fe10000 0x10000>;
> > +
> > +        clocks = <&clkc LS1X_CLKID_AHB>;
> > +        clock-names = "stmmaceth";
> > +
> > +        interrupt-parent = <&intc1>;
> > +        interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
> > +        interrupt-names = "macirq";
> > +
> > +        loongson,ls1-syscon = <&syscon>;
> > +
> > +        phy-handle = <&phy0>;
> > +        phy-mode = "mii";
> > +        snps,pbl = <1>;
> > +
> > +        mdio {
> > +            #address-cells = <1>;
> > +            #size-cells = <0>;
> > +            compatible = "snps,dwmac-mdio";
> > +
> > +            phy0: ethernet-phy@13 {
> > +                reg = <0x13>;
> > +            };
> > +        };
> > +    };
> > --
> > 2.39.2
> >
> >



--
Best regards,

Keguang Zhang
Krzysztof Kozlowski Aug. 28, 2023, 7:15 a.m. UTC | #5
On 27/08/2023 23:01, Serge Semin wrote:
> Hi Krzysztof
> 
> On Sun, Aug 27, 2023 at 09:56:06AM +0200, Krzysztof Kozlowski wrote:
>> On 26/08/2023 23:04, Serge Semin wrote:
>>>> +  clock-names:
>>>> +    items:
>>>> +      - const: stmmaceth
>>>
>>>   clock-names:
>>>     const: stmmaceth
>>> ?
>>
> 
>> The existing syntax is correct. This is a string array.
> 
> Could you please clarify whether it's a requirement (always specify
> items: property for an array) or just an acceptable option (another
> one is suggested in my comment)? I am asking because:
> 1. In this case the "clock-names" array is supposed to have only one
> item. Directly setting "const: stmmaceth" with no items: property
> shall simplify it.
> 2. There are single-entry "clock-names" property in the DT-bindings
> defined as I suggested.
> 3. There is a "compatible" property which is also a string array but
> it can be defined as I suggested (omitting the items property).
> 
> so based on all of that using the "items:"-based constraint here seems
> redundant. Am I wrong to think like that? If so in what aspect?

Syntax is correct in both cases. However the single list compatible
*cannot grow*, while single list clock might, when developer notices
that the binding was incomplete. People add binding matching drivers,
not the hardware, thus having incomplete list of clocks is happening all
the time.

Best regards,
Krzysztof
Serge Semin Aug. 28, 2023, 12:41 p.m. UTC | #6
On Mon, Aug 28, 2023 at 09:15:17AM +0200, Krzysztof Kozlowski wrote:
> On 27/08/2023 23:01, Serge Semin wrote:
> > Hi Krzysztof
> > 
> > On Sun, Aug 27, 2023 at 09:56:06AM +0200, Krzysztof Kozlowski wrote:
> >> On 26/08/2023 23:04, Serge Semin wrote:
> >>>> +  clock-names:
> >>>> +    items:
> >>>> +      - const: stmmaceth
> >>>
> >>>   clock-names:
> >>>     const: stmmaceth
> >>> ?
> >>
> > 
> >> The existing syntax is correct. This is a string array.
> > 
> > Could you please clarify whether it's a requirement (always specify
> > items: property for an array) or just an acceptable option (another
> > one is suggested in my comment)? I am asking because:
> > 1. In this case the "clock-names" array is supposed to have only one
> > item. Directly setting "const: stmmaceth" with no items: property
> > shall simplify it.
> > 2. There are single-entry "clock-names" property in the DT-bindings
> > defined as I suggested.
> > 3. There is a "compatible" property which is also a string array but
> > it can be defined as I suggested (omitting the items property).
> > 
> > so based on all of that using the "items:"-based constraint here seems
> > redundant. Am I wrong to think like that? If so in what aspect?
> 

> Syntax is correct in both cases. However the single list compatible
> *cannot grow*, while single list clock might, when developer notices
> that the binding was incomplete. People add binding matching drivers,
> not the hardware, thus having incomplete list of clocks is happening all
> the time.

So it's just a matter of maintainability. Got it. Thanks.

-Serge(y)

> 
> Best regards,
> Krzysztof
>
Serge Semin Aug. 28, 2023, 12:46 p.m. UTC | #7
On Mon, Aug 28, 2023 at 12:38:37PM +0800, Keguang Zhang wrote:
> On Sun, Aug 27, 2023 at 5:04 AM Serge Semin <fancer.lancer@gmail.com> wrote:
> >
> > On Thu, Aug 24, 2023 at 08:50:10PM +0800, Keguang Zhang wrote:
> > > Add devicetree binding document for Loongson-1 Ethernet controller.
> > >
> > > Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
> > > Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> > > ---
> > > V2 -> V3: Split the DT-schema file into loongson,ls1b-gmac.yaml
> > >           and loongson,ls1c-emac.yaml (suggested by Serge Semin)
> > >           Change the compatibles to loongson,ls1b-gmac and loongson,ls1c-emac
> > >           Rename loongson,dwmac-syscon to loongson,ls1-syscon
> > >           Amend the title
> > >           Add description
> > >           Add Reviewed-by tag from Krzysztof Kozlowski(Sorry! I'm not sure)
> > > V1 -> V2: Fix "clock-names" and "interrupt-names" property
> > >           Rename the syscon property to "loongson,dwmac-syscon"
> > >           Drop "phy-handle" and "phy-mode" requirement
> > >           Revert adding loongson,ls1b-dwmac/loongson,ls1c-dwmac
> > >           to snps,dwmac.yaml
> > >
> > >  .../bindings/net/loongson,ls1b-gmac.yaml      | 115 ++++++++++++++++++
> > >  .../bindings/net/loongson,ls1c-emac.yaml      | 114 +++++++++++++++++
> > >  2 files changed, 229 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
> > >  create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
> > >
> > > diff --git a/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml b/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
> > > new file mode 100644
> > > index 000000000000..f661d5b86649
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
> > > @@ -0,0 +1,115 @@
> > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > > +%YAML 1.2
> > > +---
> > > +$id: http://devicetree.org/schemas/net/loongson,ls1b-gmac.yaml#
> > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > +
> > > +title: Loongson-1B Gigabit Ethernet MAC Controller
> > > +
> > > +maintainers:
> > > +  - Keguang Zhang <keguang.zhang@gmail.com>
> > > +
> >
> > > +description:
> >
> > Use "|" to keep the text formatting.
> >   description: |
> >
> > > +  Loongson-1B Gigabit Ethernet MAC Controller is based on
> > > +  Synopsys DesignWare MAC (version 3.50a).
> > > +
> >
> > > +  Main features
> > > +  - Dual 10/100/1000Mbps GMAC controllers
> > > +  - Full-duplex operation (IEEE 802.3x flow control automatic transmission)
> > > +  - Half-duplex operation (CSMA/CD Protocol and back-pressure support)
> > > +  - RX Checksum Offload
> > > +  - TX Checksum insertion
> > > +  - MII interface
> > > +  - RGMII interface
> >
> > If only all the DW *MAC-based devices have such info in the
> > bindings the life would have been much easier...
> >
> > > +
> > > +select:
> > > +  properties:
> > > +    compatible:
> > > +      contains:
> > > +        enum:
> > > +          - loongson,ls1b-gmac
> > > +  required:
> > > +    - compatible
> > > +
> > > +properties:
> > > +  compatible:
> > > +    items:
> > > +      - enum:
> > > +          - loongson,ls1b-gmac
> > > +      - const: snps,dwmac-3.50a
> > > +
> > > +  reg:
> > > +    maxItems: 1
> > > +
> > > +  clocks:
> > > +    maxItems: 1
> > > +
> >

> > > +  clock-names:
> > > +    items:
> > > +      - const: stmmaceth
> >
> > since there is a single clock then just:
> >   clock-names:
> >     const: stmmaceth

As Krzysztof noted please ignore this comment.

> >
> > > +
> > > +  interrupts:
> > > +    maxItems: 1
> > > +
> >
> > > +  interrupt-names:
> > > +    items:
> > > +      - const: macirq
> >

> > ditto. just
> >   interrupt-names:
> >     const: macirq

ditto.

> >
> > > +
> > > +  loongson,ls1-syscon:
> > > +    $ref: /schemas/types.yaml#/definitions/phandle
> > > +    description:
> > > +      Phandle to the syscon containing some extra configurations
> > > +      including PHY interface mode.
> > > +
> >
> > > +  phy-mode:
> > > +    items:
> > > +      - enum:
> > > +          - mii
> > > +          - rgmii-id
> >
> > it's a single string then just:
> >   phy-mode:
> >     enum: ...
> >
> > > +
> > > +required:
> > > +  - compatible
> > > +  - reg
> > > +  - clocks
> > > +  - clock-names
> > > +  - interrupts
> > > +  - interrupt-names
> > > +  - loongson,ls1-syscon
> > > +
> > > +allOf:
> > > +  - $ref: snps,dwmac.yaml#
> > > +
> > > +unevaluatedProperties: false
> > > +
> > > +examples:
> > > +  - |
> > > +    #include <dt-bindings/clock/loongson,ls1x-clk.h>
> > > +    #include <dt-bindings/interrupt-controller/irq.h>
> > > +
> > > +    gmac0: ethernet@1fe10000 {
> > > +        compatible = "loongson,ls1b-gmac", "snps,dwmac-3.50a";
> > > +        reg = <0x1fe10000 0x10000>;
> > > +
> > > +        clocks = <&clkc LS1X_CLKID_AHB>;
> > > +        clock-names = "stmmaceth";
> > > +
> > > +        interrupt-parent = <&intc1>;
> > > +        interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
> > > +        interrupt-names = "macirq";
> > > +
> > > +        loongson,ls1-syscon = <&syscon>;
> > > +
> > > +        phy-handle = <&phy0>;
> > > +        phy-mode = "mii";
> > > +        snps,pbl = <1>;
> > > +
> > > +        mdio {
> > > +            #address-cells = <1>;
> > > +            #size-cells = <0>;
> > > +            compatible = "snps,dwmac-mdio";
> > > +
> > > +            phy0: ethernet-phy@0 {
> > > +                reg = <0x0>;
> > > +            };
> > > +        };
> > > +    };
> > > diff --git a/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml b/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
> > > new file mode 100644
> > > index 000000000000..1ffad41941bf
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
> > > @@ -0,0 +1,114 @@
> > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > > +%YAML 1.2
> > > +---
> > > +$id: http://devicetree.org/schemas/net/loongson,ls1c-emac.yaml#
> > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > +
> > > +title: Loongson-1C Ethernet MAC Controller
> > > +
> > > +maintainers:
> > > +  - Keguang Zhang <keguang.zhang@gmail.com>
> > > +
> >
> > > +description:
> >
> > the same comment about the "|" modifier.
> >
> > > +  Loongson-1C Ethernet MAC Controller is based on
> > > +  Synopsys DesignWare MAC (version 3.50a).
> > > +
> >
> > > +  Main features
> > > +  - 10/100Mbps
> > > +  - Full-duplex operation (IEEE 802.3x flow control automatic transmission)
> > > +  - Half-duplex operation (CSMA/CD Protocol and back-pressure support)
> > > +  - IEEE 802.1Q VLAN tag detection for reception frames
> > > +  - MII interface
> > > +  - RMII interface
> >
> > Based on the plat_stmmacenet_data data defined for the LS1C MAC it
> > also support support Tx COE. Isn't it? What about Rx COE?
> >

> According to the value read from HW Feature Register(offset 0x1058),
> both TXCOESEL an
> RXTYP1COE/RXTYP2COE are zero.
> Therefore, neither TX COE nor RX COE is supported by LS1C MAC.
> Current plat_stmmacenet_data is Inaccurate.

And since STMMAC probe() procedure overrides the
plat_stmmacenet_data.tx_coe field then no problems the mistaken value
caused. I see. Thanks for clarification.

-Serge(y)

> 
> > > +
> > > +select:
> > > +  properties:
> > > +    compatible:
> > > +      contains:
> > > +        enum:
> > > +          - loongson,ls1c-emac
> > > +  required:
> > > +    - compatible
> > > +
> > > +properties:
> > > +  compatible:
> > > +    items:
> > > +      - enum:
> > > +          - loongson,ls1c-emac
> > > +      - const: snps,dwmac-3.50a
> > > +
> > > +  reg:
> > > +    maxItems: 1
> > > +
> > > +  clocks:
> > > +    maxItems: 1
> > > +
> >
> > > +  clock-names:
> > > +    items:
> > > +      - const: stmmaceth
> >

> >   clock-names:
> >     const: stmmaceth
> > ?

Please ignore this comment.

> >
> > > +
> > > +  interrupts:
> > > +    maxItems: 1
> > > +
> >
> > > +  interrupt-names:
> > > +    items:
> > > +      - const: macirq
> >

> >   interrupt-names:
> >     const: macirq
> > ?

ditto.

-Serge(y)

> >
> > > +
> > > +  loongson,ls1-syscon:
> > > +    $ref: /schemas/types.yaml#/definitions/phandle
> > > +    description:
> > > +      Phandle to the syscon containing some extra configurations
> > > +      including PHY interface mode.
> > > +
> >
> > > +  phy-mode:
> > > +    items:
> > > +      - enum:
> > > +          - mii
> > > +          - rmii
> >
> >   phy-mode:
> >     enum: ...
> > ?
> >
> > -Serge(y)
> >
> > > +
> > > +required:
> > > +  - compatible
> > > +  - reg
> > > +  - clocks
> > > +  - clock-names
> > > +  - interrupts
> > > +  - interrupt-names
> > > +  - loongson,ls1-syscon
> > > +
> > > +allOf:
> > > +  - $ref: snps,dwmac.yaml#
> > > +
> > > +unevaluatedProperties: false
> > > +
> > > +examples:
> > > +  - |
> > > +    #include <dt-bindings/clock/loongson,ls1x-clk.h>
> > > +    #include <dt-bindings/interrupt-controller/irq.h>
> > > +
> > > +    emac: ethernet@1fe10000 {
> > > +        compatible = "loongson,ls1c-emac", "snps,dwmac-3.50a";
> > > +        reg = <0x1fe10000 0x10000>;
> > > +
> > > +        clocks = <&clkc LS1X_CLKID_AHB>;
> > > +        clock-names = "stmmaceth";
> > > +
> > > +        interrupt-parent = <&intc1>;
> > > +        interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
> > > +        interrupt-names = "macirq";
> > > +
> > > +        loongson,ls1-syscon = <&syscon>;
> > > +
> > > +        phy-handle = <&phy0>;
> > > +        phy-mode = "mii";
> > > +        snps,pbl = <1>;
> > > +
> > > +        mdio {
> > > +            #address-cells = <1>;
> > > +            #size-cells = <0>;
> > > +            compatible = "snps,dwmac-mdio";
> > > +
> > > +            phy0: ethernet-phy@13 {
> > > +                reg = <0x13>;
> > > +            };
> > > +        };
> > > +    };
> > > --
> > > 2.39.2
> > >
> > >
> 
> 
> 
> --
> Best regards,
> 
> Keguang Zhang
Keguang Zhang Aug. 28, 2023, 1:09 p.m. UTC | #8
On Sun, Aug 27, 2023 at 5:04 AM Serge Semin <fancer.lancer@gmail.com> wrote:
>
> On Thu, Aug 24, 2023 at 08:50:10PM +0800, Keguang Zhang wrote:
> > Add devicetree binding document for Loongson-1 Ethernet controller.
> >
> > Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
> > Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> > ---
> > V2 -> V3: Split the DT-schema file into loongson,ls1b-gmac.yaml
> >           and loongson,ls1c-emac.yaml (suggested by Serge Semin)
> >           Change the compatibles to loongson,ls1b-gmac and loongson,ls1c-emac
> >           Rename loongson,dwmac-syscon to loongson,ls1-syscon
> >           Amend the title
> >           Add description
> >           Add Reviewed-by tag from Krzysztof Kozlowski(Sorry! I'm not sure)
> > V1 -> V2: Fix "clock-names" and "interrupt-names" property
> >           Rename the syscon property to "loongson,dwmac-syscon"
> >           Drop "phy-handle" and "phy-mode" requirement
> >           Revert adding loongson,ls1b-dwmac/loongson,ls1c-dwmac
> >           to snps,dwmac.yaml
> >
> >  .../bindings/net/loongson,ls1b-gmac.yaml      | 115 ++++++++++++++++++
> >  .../bindings/net/loongson,ls1c-emac.yaml      | 114 +++++++++++++++++
> >  2 files changed, 229 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
> >  create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml b/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
> > new file mode 100644
> > index 000000000000..f661d5b86649
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
> > @@ -0,0 +1,115 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/net/loongson,ls1b-gmac.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Loongson-1B Gigabit Ethernet MAC Controller
> > +
> > +maintainers:
> > +  - Keguang Zhang <keguang.zhang@gmail.com>
> > +
>
> > +description:
>
> Use "|" to keep the text formatting.
>   description: |
>
Will do.

> > +  Loongson-1B Gigabit Ethernet MAC Controller is based on
> > +  Synopsys DesignWare MAC (version 3.50a).
> > +
>
> > +  Main features
> > +  - Dual 10/100/1000Mbps GMAC controllers
> > +  - Full-duplex operation (IEEE 802.3x flow control automatic transmission)
> > +  - Half-duplex operation (CSMA/CD Protocol and back-pressure support)
> > +  - RX Checksum Offload
> > +  - TX Checksum insertion
> > +  - MII interface
> > +  - RGMII interface
>
> If only all the DW *MAC-based devices have such info in the
> bindings the life would have been much easier...
>
> > +
> > +select:
> > +  properties:
> > +    compatible:
> > +      contains:
> > +        enum:
> > +          - loongson,ls1b-gmac
> > +  required:
> > +    - compatible
> > +
> > +properties:
> > +  compatible:
> > +    items:
> > +      - enum:
> > +          - loongson,ls1b-gmac
> > +      - const: snps,dwmac-3.50a
> > +
> > +  reg:
> > +    maxItems: 1
> > +
> > +  clocks:
> > +    maxItems: 1
> > +
>
> > +  clock-names:
> > +    items:
> > +      - const: stmmaceth
>
> since there is a single clock then just:
>   clock-names:
>     const: stmmaceth
>
> > +
> > +  interrupts:
> > +    maxItems: 1
> > +
>
> > +  interrupt-names:
> > +    items:
> > +      - const: macirq
>
> ditto. just
>   interrupt-names:
>     const: macirq
>
> > +
> > +  loongson,ls1-syscon:
> > +    $ref: /schemas/types.yaml#/definitions/phandle
> > +    description:
> > +      Phandle to the syscon containing some extra configurations
> > +      including PHY interface mode.
> > +
>
> > +  phy-mode:
> > +    items:
> > +      - enum:
> > +          - mii
> > +          - rgmii-id
>
> it's a single string then just:
>   phy-mode:
>     enum: ...
>
Will do.

> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - clocks
> > +  - clock-names
> > +  - interrupts
> > +  - interrupt-names
> > +  - loongson,ls1-syscon
> > +
> > +allOf:
> > +  - $ref: snps,dwmac.yaml#
> > +
> > +unevaluatedProperties: false
> > +
> > +examples:
> > +  - |
> > +    #include <dt-bindings/clock/loongson,ls1x-clk.h>
> > +    #include <dt-bindings/interrupt-controller/irq.h>
> > +
> > +    gmac0: ethernet@1fe10000 {
> > +        compatible = "loongson,ls1b-gmac", "snps,dwmac-3.50a";
> > +        reg = <0x1fe10000 0x10000>;
> > +
> > +        clocks = <&clkc LS1X_CLKID_AHB>;
> > +        clock-names = "stmmaceth";
> > +
> > +        interrupt-parent = <&intc1>;
> > +        interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
> > +        interrupt-names = "macirq";
> > +
> > +        loongson,ls1-syscon = <&syscon>;
> > +
> > +        phy-handle = <&phy0>;
> > +        phy-mode = "mii";
> > +        snps,pbl = <1>;
> > +
> > +        mdio {
> > +            #address-cells = <1>;
> > +            #size-cells = <0>;
> > +            compatible = "snps,dwmac-mdio";
> > +
> > +            phy0: ethernet-phy@0 {
> > +                reg = <0x0>;
> > +            };
> > +        };
> > +    };
> > diff --git a/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml b/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
> > new file mode 100644
> > index 000000000000..1ffad41941bf
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
> > @@ -0,0 +1,114 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/net/loongson,ls1c-emac.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Loongson-1C Ethernet MAC Controller
> > +
> > +maintainers:
> > +  - Keguang Zhang <keguang.zhang@gmail.com>
> > +
>
> > +description:
>
> the same comment about the "|" modifier.
>
Will do.

> > +  Loongson-1C Ethernet MAC Controller is based on
> > +  Synopsys DesignWare MAC (version 3.50a).
> > +
>
> > +  Main features
> > +  - 10/100Mbps
> > +  - Full-duplex operation (IEEE 802.3x flow control automatic transmission)
> > +  - Half-duplex operation (CSMA/CD Protocol and back-pressure support)
> > +  - IEEE 802.1Q VLAN tag detection for reception frames
> > +  - MII interface
> > +  - RMII interface
>
> Based on the plat_stmmacenet_data data defined for the LS1C MAC it
> also support support Tx COE. Isn't it? What about Rx COE?
>
> > +
> > +select:
> > +  properties:
> > +    compatible:
> > +      contains:
> > +        enum:
> > +          - loongson,ls1c-emac
> > +  required:
> > +    - compatible
> > +
> > +properties:
> > +  compatible:
> > +    items:
> > +      - enum:
> > +          - loongson,ls1c-emac
> > +      - const: snps,dwmac-3.50a
> > +
> > +  reg:
> > +    maxItems: 1
> > +
> > +  clocks:
> > +    maxItems: 1
> > +
>
> > +  clock-names:
> > +    items:
> > +      - const: stmmaceth
>
>   clock-names:
>     const: stmmaceth
> ?
>
> > +
> > +  interrupts:
> > +    maxItems: 1
> > +
>
> > +  interrupt-names:
> > +    items:
> > +      - const: macirq
>
>   interrupt-names:
>     const: macirq
> ?
>
> > +
> > +  loongson,ls1-syscon:
> > +    $ref: /schemas/types.yaml#/definitions/phandle
> > +    description:
> > +      Phandle to the syscon containing some extra configurations
> > +      including PHY interface mode.
> > +
>
> > +  phy-mode:
> > +    items:
> > +      - enum:
> > +          - mii
> > +          - rmii
>
>   phy-mode:
>     enum: ...
> ?
Will do.
>
> -Serge(y)
>
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - clocks
> > +  - clock-names
> > +  - interrupts
> > +  - interrupt-names
> > +  - loongson,ls1-syscon
> > +
> > +allOf:
> > +  - $ref: snps,dwmac.yaml#
> > +
> > +unevaluatedProperties: false
> > +
> > +examples:
> > +  - |
> > +    #include <dt-bindings/clock/loongson,ls1x-clk.h>
> > +    #include <dt-bindings/interrupt-controller/irq.h>
> > +
> > +    emac: ethernet@1fe10000 {
> > +        compatible = "loongson,ls1c-emac", "snps,dwmac-3.50a";
> > +        reg = <0x1fe10000 0x10000>;
> > +
> > +        clocks = <&clkc LS1X_CLKID_AHB>;
> > +        clock-names = "stmmaceth";
> > +
> > +        interrupt-parent = <&intc1>;
> > +        interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
> > +        interrupt-names = "macirq";
> > +
> > +        loongson,ls1-syscon = <&syscon>;
> > +
> > +        phy-handle = <&phy0>;
> > +        phy-mode = "mii";
> > +        snps,pbl = <1>;
> > +
> > +        mdio {
> > +            #address-cells = <1>;
> > +            #size-cells = <0>;
> > +            compatible = "snps,dwmac-mdio";
> > +
> > +            phy0: ethernet-phy@13 {
> > +                reg = <0x13>;
> > +            };
> > +        };
> > +    };
> > --
> > 2.39.2
> >
> >
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml b/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
new file mode 100644
index 000000000000..f661d5b86649
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
@@ -0,0 +1,115 @@ 
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/loongson,ls1b-gmac.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-1B Gigabit Ethernet MAC Controller
+
+maintainers:
+  - Keguang Zhang <keguang.zhang@gmail.com>
+
+description:
+  Loongson-1B Gigabit Ethernet MAC Controller is based on
+  Synopsys DesignWare MAC (version 3.50a).
+
+  Main features
+  - Dual 10/100/1000Mbps GMAC controllers
+  - Full-duplex operation (IEEE 802.3x flow control automatic transmission)
+  - Half-duplex operation (CSMA/CD Protocol and back-pressure support)
+  - RX Checksum Offload
+  - TX Checksum insertion
+  - MII interface
+  - RGMII interface
+
+select:
+  properties:
+    compatible:
+      contains:
+        enum:
+          - loongson,ls1b-gmac
+  required:
+    - compatible
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - loongson,ls1b-gmac
+      - const: snps,dwmac-3.50a
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: stmmaceth
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-names:
+    items:
+      - const: macirq
+
+  loongson,ls1-syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      Phandle to the syscon containing some extra configurations
+      including PHY interface mode.
+
+  phy-mode:
+    items:
+      - enum:
+          - mii
+          - rgmii-id
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - interrupts
+  - interrupt-names
+  - loongson,ls1-syscon
+
+allOf:
+  - $ref: snps,dwmac.yaml#
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/loongson,ls1x-clk.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    gmac0: ethernet@1fe10000 {
+        compatible = "loongson,ls1b-gmac", "snps,dwmac-3.50a";
+        reg = <0x1fe10000 0x10000>;
+
+        clocks = <&clkc LS1X_CLKID_AHB>;
+        clock-names = "stmmaceth";
+
+        interrupt-parent = <&intc1>;
+        interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
+        interrupt-names = "macirq";
+
+        loongson,ls1-syscon = <&syscon>;
+
+        phy-handle = <&phy0>;
+        phy-mode = "mii";
+        snps,pbl = <1>;
+
+        mdio {
+            #address-cells = <1>;
+            #size-cells = <0>;
+            compatible = "snps,dwmac-mdio";
+
+            phy0: ethernet-phy@0 {
+                reg = <0x0>;
+            };
+        };
+    };
diff --git a/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml b/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
new file mode 100644
index 000000000000..1ffad41941bf
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
@@ -0,0 +1,114 @@ 
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/loongson,ls1c-emac.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-1C Ethernet MAC Controller
+
+maintainers:
+  - Keguang Zhang <keguang.zhang@gmail.com>
+
+description:
+  Loongson-1C Ethernet MAC Controller is based on
+  Synopsys DesignWare MAC (version 3.50a).
+
+  Main features
+  - 10/100Mbps
+  - Full-duplex operation (IEEE 802.3x flow control automatic transmission)
+  - Half-duplex operation (CSMA/CD Protocol and back-pressure support)
+  - IEEE 802.1Q VLAN tag detection for reception frames
+  - MII interface
+  - RMII interface
+
+select:
+  properties:
+    compatible:
+      contains:
+        enum:
+          - loongson,ls1c-emac
+  required:
+    - compatible
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - loongson,ls1c-emac
+      - const: snps,dwmac-3.50a
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: stmmaceth
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-names:
+    items:
+      - const: macirq
+
+  loongson,ls1-syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      Phandle to the syscon containing some extra configurations
+      including PHY interface mode.
+
+  phy-mode:
+    items:
+      - enum:
+          - mii
+          - rmii
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - interrupts
+  - interrupt-names
+  - loongson,ls1-syscon
+
+allOf:
+  - $ref: snps,dwmac.yaml#
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/loongson,ls1x-clk.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    emac: ethernet@1fe10000 {
+        compatible = "loongson,ls1c-emac", "snps,dwmac-3.50a";
+        reg = <0x1fe10000 0x10000>;
+
+        clocks = <&clkc LS1X_CLKID_AHB>;
+        clock-names = "stmmaceth";
+
+        interrupt-parent = <&intc1>;
+        interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
+        interrupt-names = "macirq";
+
+        loongson,ls1-syscon = <&syscon>;
+
+        phy-handle = <&phy0>;
+        phy-mode = "mii";
+        snps,pbl = <1>;
+
+        mdio {
+            #address-cells = <1>;
+            #size-cells = <0>;
+            compatible = "snps,dwmac-mdio";
+
+            phy0: ethernet-phy@13 {
+                reg = <0x13>;
+            };
+        };
+    };