diff mbox series

[net-next,v10,6/6] net: dt-bindings: dwmac: add support for mt8195

Message ID 20211216055328.15953-7-biao.huang@mediatek.com (mailing list archive)
State New, archived
Headers show
Series MediaTek Ethernet Patches on MT8195 | expand

Commit Message

Biao Huang (黄彪) Dec. 16, 2021, 5:53 a.m. UTC
Add binding document for the ethernet on mt8195.

Signed-off-by: Biao Huang <biao.huang@mediatek.com>
---
 .../bindings/net/mediatek-dwmac.yaml          | 29 ++++++++++++++++---
 1 file changed, 25 insertions(+), 4 deletions(-)

Comments

Rob Herring (Arm) Dec. 16, 2021, 1:53 p.m. UTC | #1
On Thu, 16 Dec 2021 13:53:28 +0800, Biao Huang wrote:
> Add binding document for the ethernet on mt8195.
> 
> Signed-off-by: Biao Huang <biao.huang@mediatek.com>
> ---
>  .../bindings/net/mediatek-dwmac.yaml          | 29 ++++++++++++++++---
>  1 file changed, 25 insertions(+), 4 deletions(-)
> 

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/mediatek-dwmac.yaml: properties:clock-names: {'minItems': 5, 'maxItems': 6, 'items': [{'const': 'axi'}, {'const': 'apb'}, {'const': 'mac_main'}, {'const': 'ptp_ref'}, {'const': 'rmii_internal'}, {'const': 'mac_cg'}]} should not be valid under {'required': ['maxItems']}
	hint: "maxItems" is not needed with an "items" list
	from schema $id: http://devicetree.org/meta-schemas/items.yaml#
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/mediatek-dwmac.yaml: ignoring, error in schema: properties: clock-names
warning: no schema found in file: ./Documentation/devicetree/bindings/net/mediatek-dwmac.yaml
Documentation/devicetree/bindings/net/mediatek-dwmac.example.dt.yaml:0:0: /example-0/ethernet@1101c000: failed to match any schema with compatible: ['mediatek,mt2712-gmac', 'snps,dwmac-4.20a']

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/1568902

This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.

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

pip3 install dtschema --upgrade

Please check and re-submit.
Biao Huang (黄彪) Dec. 17, 2021, 2:05 a.m. UTC | #2
Dear Rob,
  Thanks for your comments~

  For mt8195, the eth device node will look like:
  eth: ethernet@11021000 {
    compatible = "mediatek,mt8195-gmac", "snps,dwmac-5.10a";
    ...
    clock-names = "axi",
                  "apb",
                  "mac_cg",
                  "mac_main",
                  "ptp_ref",
                  "rmii_internal";
    clocks = <&pericfg_ao CLK_PERI_AO_ETHERNET>,
             <&pericfg_ao CLK_PERI_AO_ETHERNET_BUS>,
             <&pericfg_ao CLK_PERI_AO_ETHERNET_MAC>,
             <&topckgen CLK_TOP_SNPS_ETH_250M>,
             <&topckgen CLK_TOP_SNPS_ETH_62P4M_PTP>,
             <&topckgen CLK_TOP_SNPS_ETH_50M_RMII>;
    ...
  }

1. "rmii_internal" is a special clock only required for
   RMII phy interface, dwmac-mediatek.c will enable clocks
   invoking clk_bulk_prepare_enable(xx, 6) for RMII,
   and clk_bulk_prepare_enable(xx, 5) for other phy interfaces.
   so, mt2712/mt8195 all put "rmii_internal" clock to the
   end of clock list to simplify clock handling.

   If I put mac_cg as described above, a if condition is required
for clocks description in dt-binding, just like what I do in v7 send:
  - if:
      properties:
        compatible:
          contains:
            enum:
              - mediatek,mt2712-gmac

    then:
      properties:
        clocks:
          minItems: 5
          items:
            - description: AXI clock
            - description: APB clock
            - description: MAC Main clock
            - description: PTP clock
            - description: RMII reference clock provided by MAC

        clock-names:
          minItems: 5
          items:
            - const: axi
            - const: apb
            - const: mac_main
            - const: ptp_ref
            - const: rmii_internal

  - if:
      properties:
        compatible:
          contains:
            enum:
              - mediatek,mt8195-gmac

    then:
      properties:
        clocks:
          minItems: 6
          items:
            - description: AXI clock
            - description: APB clock
            - description: MAC clock gate
            - description: MAC Main clock
            - description: PTP clock
            - description: RMII reference clock provided by MAC

   This introduces some duplicated description.

2. If I put "mac_cg" to the end of clock list,
   the dt-binding file can be simple just like
   what we do in this v10 patch(need fix warnings reported by "make
DT_CHECKER_FLAGS=-m dt_binding_check").

   But for mt8195:
     the eth node in dts should be modified,
     and eth driver clock handling will be complex;

We prefer 1(duplicated description one).
Can we just descirbe clocks/clocks-names for mt2712/mt8195 seperately?
Please kindly comment about this issue.
Thanks in advance.

On Thu, 2021-12-16 at 07:53 -0600, Rob Herring wrote:
> On Thu, 16 Dec 2021 13:53:28 +0800, Biao Huang wrote:
> > Add binding document for the ethernet on mt8195.
> > 
> > Signed-off-by: Biao Huang <biao.huang@mediatek.com>
> > ---
> >  .../bindings/net/mediatek-dwmac.yaml          | 29
> > ++++++++++++++++---
> >  1 file changed, 25 insertions(+), 4 deletions(-)
> > 
> 
> My bot found errors running 'make DT_CHECKER_FLAGS=-m
> dt_binding_check'
> on your patch (DT_CHECKER_FLAGS is new in v5.13):
> 
> yamllint warnings/errors:
> 
> dtschema/dtc warnings/errors:
> /builds/robherring/linux-dt-
> review/Documentation/devicetree/bindings/net/mediatek-dwmac.yaml:
> properties:clock-names: {'minItems': 5, 'maxItems': 6, 'items':
> [{'const': 'axi'}, {'const': 'apb'}, {'const': 'mac_main'}, {'const':
> 'ptp_ref'}, {'const': 'rmii_internal'}, {'const': 'mac_cg'}]} should
> not be valid under {'required': ['maxItems']}
> 	hint: "maxItems" is not needed with an "items" list
> 	from schema $id: http://devicetree.org/meta-schemas/items.yaml#
> /builds/robherring/linux-dt-
> review/Documentation/devicetree/bindings/net/mediatek-dwmac.yaml:
> ignoring, error in schema: properties: clock-names
> warning: no schema found in file:
> ./Documentation/devicetree/bindings/net/mediatek-dwmac.yaml
> Documentation/devicetree/bindings/net/mediatek-
> dwmac.example.dt.yaml:0:0: /example-0/ethernet@1101c000: failed to
> match any schema with compatible: ['mediatek,mt2712-gmac',
> 'snps,dwmac-4.20a']
> 
> doc reference errors (make refcheckdocs):
> 
> See https://patchwork.ozlabs.org/patch/1568902
> 
> This check can fail if there are any dependencies. The base for a
> patch
> series is generally the most recent rc1.
> 
> If you already ran 'make dt_binding_check' and didn't see the above
> error(s), then make sure 'yamllint' is installed and dt-schema is up
> to
> date:
> 
> pip3 install dtschema --upgrade
> 
> Please check and re-submit.
>
Rob Herring (Arm) Jan. 11, 2022, 11:36 p.m. UTC | #3
On Thu, Dec 16, 2021 at 8:06 PM Biao Huang <biao.huang@mediatek.com> wrote:
>
> Dear Rob,
>   Thanks for your comments~
>
>   For mt8195, the eth device node will look like:
>   eth: ethernet@11021000 {
>     compatible = "mediatek,mt8195-gmac", "snps,dwmac-5.10a";
>     ...
>     clock-names = "axi",
>                   "apb",
>                   "mac_cg",
>                   "mac_main",
>                   "ptp_ref",
>                   "rmii_internal";
>     clocks = <&pericfg_ao CLK_PERI_AO_ETHERNET>,
>              <&pericfg_ao CLK_PERI_AO_ETHERNET_BUS>,
>              <&pericfg_ao CLK_PERI_AO_ETHERNET_MAC>,
>              <&topckgen CLK_TOP_SNPS_ETH_250M>,
>              <&topckgen CLK_TOP_SNPS_ETH_62P4M_PTP>,
>              <&topckgen CLK_TOP_SNPS_ETH_50M_RMII>;
>     ...
>   }
>
> 1. "rmii_internal" is a special clock only required for
>    RMII phy interface, dwmac-mediatek.c will enable clocks
>    invoking clk_bulk_prepare_enable(xx, 6) for RMII,
>    and clk_bulk_prepare_enable(xx, 5) for other phy interfaces.
>    so, mt2712/mt8195 all put "rmii_internal" clock to the
>    end of clock list to simplify clock handling.
>
>    If I put mac_cg as described above, a if condition is required
> for clocks description in dt-binding, just like what I do in v7 send:
>   - if:
>       properties:
>         compatible:
>           contains:
>             enum:
>               - mediatek,mt2712-gmac
>
>     then:
>       properties:
>         clocks:
>           minItems: 5
>           items:
>             - description: AXI clock
>             - description: APB clock
>             - description: MAC Main clock
>             - description: PTP clock
>             - description: RMII reference clock provided by MAC
>
>         clock-names:
>           minItems: 5
>           items:
>             - const: axi
>             - const: apb
>             - const: mac_main
>             - const: ptp_ref
>             - const: rmii_internal
>
>   - if:
>       properties:
>         compatible:
>           contains:
>             enum:
>               - mediatek,mt8195-gmac
>
>     then:
>       properties:
>         clocks:
>           minItems: 6
>           items:
>             - description: AXI clock
>             - description: APB clock
>             - description: MAC clock gate
>             - description: MAC Main clock
>             - description: PTP clock
>             - description: RMII reference clock provided by MAC
>
>    This introduces some duplicated description.
>
> 2. If I put "mac_cg" to the end of clock list,
>    the dt-binding file can be simple just like
>    what we do in this v10 patch(need fix warnings reported by "make
> DT_CHECKER_FLAGS=-m dt_binding_check").
>
>    But for mt8195:
>      the eth node in dts should be modified,

I hope you are defining the binding before you use it... That's not
good practice and not a valid argument.

>      and eth driver clock handling will be complex;

How so?

Rob
Biao Huang (黄彪) Jan. 14, 2022, 5:38 a.m. UTC | #4
On Tue, 2022-01-11 at 17:36 -0600, Rob Herring wrote:
> On Thu, Dec 16, 2021 at 8:06 PM Biao Huang <biao.huang@mediatek.com>
> wrote:
> > 
> > Dear Rob,
> >   Thanks for your comments~
> > 
> >   For mt8195, the eth device node will look like:
> >   eth: ethernet@11021000 {
> >     compatible = "mediatek,mt8195-gmac", "snps,dwmac-5.10a";
> >     ...
> >     clock-names = "axi",
> >                   "apb",
> >                   "mac_cg",
> >                   "mac_main",
> >                   "ptp_ref",
> >                   "rmii_internal";
> >     clocks = <&pericfg_ao CLK_PERI_AO_ETHERNET>,
> >              <&pericfg_ao CLK_PERI_AO_ETHERNET_BUS>,
> >              <&pericfg_ao CLK_PERI_AO_ETHERNET_MAC>,
> >              <&topckgen CLK_TOP_SNPS_ETH_250M>,
> >              <&topckgen CLK_TOP_SNPS_ETH_62P4M_PTP>,
> >              <&topckgen CLK_TOP_SNPS_ETH_50M_RMII>;
> >     ...
> >   }
> > 
> > 1. "rmii_internal" is a special clock only required for
> >    RMII phy interface, dwmac-mediatek.c will enable clocks
> >    invoking clk_bulk_prepare_enable(xx, 6) for RMII,
> >    and clk_bulk_prepare_enable(xx, 5) for other phy interfaces.
> >    so, mt2712/mt8195 all put "rmii_internal" clock to the
> >    end of clock list to simplify clock handling.
> > 
> >    If I put mac_cg as described above, a if condition is required
> > for clocks description in dt-binding, just like what I do in v7
> > send:
> >   - if:
> >       properties:
> >         compatible:
> >           contains:
> >             enum:
> >               - mediatek,mt2712-gmac
> > 
> >     then:
> >       properties:
> >         clocks:
> >           minItems: 5
> >           items:
> >             - description: AXI clock
> >             - description: APB clock
> >             - description: MAC Main clock
> >             - description: PTP clock
> >             - description: RMII reference clock provided by MAC
> > 
> >         clock-names:
> >           minItems: 5
> >           items:
> >             - const: axi
> >             - const: apb
> >             - const: mac_main
> >             - const: ptp_ref
> >             - const: rmii_internal
> > 
> >   - if:
> >       properties:
> >         compatible:
> >           contains:
> >             enum:
> >               - mediatek,mt8195-gmac
> > 
> >     then:
> >       properties:
> >         clocks:
> >           minItems: 6
> >           items:
> >             - description: AXI clock
> >             - description: APB clock
> >             - description: MAC clock gate
> >             - description: MAC Main clock
> >             - description: PTP clock
> >             - description: RMII reference clock provided by MAC
> > 
> >    This introduces some duplicated description.
> > 
> > 2. If I put "mac_cg" to the end of clock list,
> >    the dt-binding file can be simple just like
> >    what we do in this v10 patch(need fix warnings reported by "make
> > DT_CHECKER_FLAGS=-m dt_binding_check").
> > 
> >    But for mt8195:
> >      the eth node in dts should be modified,
> 
> I hope you are defining the binding before you use it... That's not
> good practice and not a valid argument.
> 
> >      and eth driver clock handling will be complex;
> 
> How so?
> 
> Rob
OK, I'll add a driver patch to make clock setting more reasonable,
and modify this patch as previous comments.

Thanks for your comments~
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/net/mediatek-dwmac.yaml b/Documentation/devicetree/bindings/net/mediatek-dwmac.yaml
index 8ad6e19661b8..a12f822a9ded 100644
--- a/Documentation/devicetree/bindings/net/mediatek-dwmac.yaml
+++ b/Documentation/devicetree/bindings/net/mediatek-dwmac.yaml
@@ -19,6 +19,7 @@  select:
       contains:
         enum:
           - mediatek,mt2712-gmac
+          - mediatek,mt8195-gmac
   required:
     - compatible
 
@@ -27,26 +28,36 @@  allOf:
 
 properties:
   compatible:
-    items:
-      - enum:
-          - mediatek,mt2712-gmac
-      - const: snps,dwmac-4.20a
+    oneOf:
+      - items:
+          - enum:
+              - mediatek,mt2712-gmac
+          - const: snps,dwmac-4.20a
+      - items:
+          - enum:
+              - mediatek,mt8195-gmac
+          - const: snps,dwmac-5.10a
 
   clocks:
+    minItems: 5
     items:
       - description: AXI clock
       - description: APB clock
       - description: MAC Main clock
       - description: PTP clock
       - description: RMII reference clock provided by MAC
+      - description: MAC clock gate
 
   clock-names:
+    minItems: 5
+    maxItems: 6
     items:
       - const: axi
       - const: apb
       - const: mac_main
       - const: ptp_ref
       - const: rmii_internal
+      - const: mac_cg
 
   mediatek,pericfg:
     $ref: /schemas/types.yaml#/definitions/phandle
@@ -61,6 +72,8 @@  properties:
       or will round down. Range 0~31*170.
       For MT2712 RMII/MII interface, Allowed value need to be a multiple of 550,
       or will round down. Range 0~31*550.
+      For MT8195 RGMII/RMII/MII interface, Allowed value need to be a multiple of 290,
+      or will round down. Range 0~31*290.
 
   mediatek,rx-delay-ps:
     description:
@@ -69,6 +82,8 @@  properties:
       or will round down. Range 0~31*170.
       For MT2712 RMII/MII interface, Allowed value need to be a multiple of 550,
       or will round down. Range 0~31*550.
+      For MT8195 RGMII/RMII/MII interface, Allowed value need to be a multiple
+      of 290, or will round down. Range 0~31*290.
 
   mediatek,rmii-rxc:
     type: boolean
@@ -102,6 +117,12 @@  properties:
       3. the inside clock, which be sent to MAC, will be inversed in RMII case when
          the reference clock is from MAC.
 
+  mediatek,mac-wol:
+    type: boolean
+    description:
+      If present, indicates that MAC supports WOL(Wake-On-LAN), and MAC WOL will be enabled.
+      Otherwise, PHY WOL is perferred.
+
 required:
   - compatible
   - reg