1# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2%YAML 1.2
3---
4$id: http://devicetree.org/schemas/net/mediatek,net.yaml#
5$schema: http://devicetree.org/meta-schemas/core.yaml#
6
7title: MediaTek Frame Engine Ethernet controller
8
9maintainers:
10  - Lorenzo Bianconi <lorenzo@kernel.org>
11  - Felix Fietkau <nbd@nbd.name>
12
13description:
14  The frame engine ethernet controller can be found on MediaTek SoCs. These SoCs
15  have dual GMAC ports.
16
17properties:
18  compatible:
19    enum:
20      - mediatek,mt2701-eth
21      - mediatek,mt7623-eth
22      - mediatek,mt7622-eth
23      - mediatek,mt7629-eth
24      - mediatek,mt7981-eth
25      - mediatek,mt7986-eth
26      - ralink,rt5350-eth
27
28  reg:
29    maxItems: 1
30
31  clocks: true
32  clock-names: true
33
34  interrupts:
35    minItems: 3
36    maxItems: 4
37
38  power-domains:
39    maxItems: 1
40
41  resets:
42    maxItems: 3
43
44  reset-names:
45    items:
46      - const: fe
47      - const: gmac
48      - const: ppe
49
50  mediatek,ethsys:
51    $ref: /schemas/types.yaml#/definitions/phandle
52    description:
53      Phandle to the syscon node that handles the port setup.
54
55  cci-control-port: true
56
57  mediatek,hifsys:
58    $ref: /schemas/types.yaml#/definitions/phandle
59    description:
60      Phandle to the mediatek hifsys controller used to provide various clocks
61      and reset to the system.
62
63  mediatek,sgmiisys:
64    $ref: /schemas/types.yaml#/definitions/phandle-array
65    minItems: 1
66    maxItems: 2
67    items:
68      maxItems: 1
69    description:
70      A list of phandle to the syscon node that handles the SGMII setup which is required for
71      those SoCs equipped with SGMII.
72
73  mediatek,wed:
74    $ref: /schemas/types.yaml#/definitions/phandle-array
75    minItems: 2
76    maxItems: 2
77    items:
78      maxItems: 1
79    description:
80      List of phandles to wireless ethernet dispatch nodes.
81
82  mediatek,wed-pcie:
83    $ref: /schemas/types.yaml#/definitions/phandle
84    description:
85      Phandle to the mediatek wed-pcie controller.
86
87  dma-coherent: true
88
89  mdio-bus:
90    $ref: mdio.yaml#
91    unevaluatedProperties: false
92
93  "#address-cells":
94    const: 1
95
96  "#size-cells":
97    const: 0
98
99allOf:
100  - $ref: ethernet-controller.yaml#
101  - if:
102      properties:
103        compatible:
104          contains:
105            enum:
106              - mediatek,mt2701-eth
107              - mediatek,mt7623-eth
108    then:
109      properties:
110        interrupts:
111          maxItems: 3
112
113        clocks:
114          minItems: 4
115          maxItems: 4
116
117        clock-names:
118          items:
119            - const: ethif
120            - const: esw
121            - const: gp1
122            - const: gp2
123
124        mediatek,pctl:
125          $ref: /schemas/types.yaml#/definitions/phandle
126          description:
127            Phandle to the syscon node that handles the ports slew rate and
128            driver current.
129
130        mediatek,wed: false
131
132        mediatek,wed-pcie: false
133
134  - if:
135      properties:
136        compatible:
137          contains:
138            const: mediatek,mt7622-eth
139    then:
140      properties:
141        interrupts:
142          maxItems: 3
143
144        clocks:
145          minItems: 11
146          maxItems: 11
147
148        clock-names:
149          items:
150            - const: ethif
151            - const: esw
152            - const: gp0
153            - const: gp1
154            - const: gp2
155            - const: sgmii_tx250m
156            - const: sgmii_rx250m
157            - const: sgmii_cdr_ref
158            - const: sgmii_cdr_fb
159            - const: sgmii_ck
160            - const: eth2pll
161
162        mediatek,sgmiisys:
163          minItems: 1
164          maxItems: 1
165
166        mediatek,pcie-mirror:
167          $ref: /schemas/types.yaml#/definitions/phandle
168          description:
169            Phandle to the mediatek pcie-mirror controller.
170
171        mediatek,wed-pcie: false
172
173  - if:
174      properties:
175        compatible:
176          contains:
177            const: mediatek,mt7629-eth
178    then:
179      properties:
180        interrupts:
181          maxItems: 3
182
183        clocks:
184          minItems: 17
185          maxItems: 17
186
187        clock-names:
188          items:
189            - const: ethif
190            - const: sgmiitop
191            - const: esw
192            - const: gp0
193            - const: gp1
194            - const: gp2
195            - const: fe
196            - const: sgmii_tx250m
197            - const: sgmii_rx250m
198            - const: sgmii_cdr_ref
199            - const: sgmii_cdr_fb
200            - const: sgmii2_tx250m
201            - const: sgmii2_rx250m
202            - const: sgmii2_cdr_ref
203            - const: sgmii2_cdr_fb
204            - const: sgmii_ck
205            - const: eth2pll
206
207        mediatek,infracfg:
208          $ref: /schemas/types.yaml#/definitions/phandle
209          description:
210            Phandle to the syscon node that handles the path from GMAC to
211            PHY variants.
212
213        mediatek,sgmiisys:
214          minItems: 2
215          maxItems: 2
216
217        mediatek,wed: false
218
219        mediatek,wed-pcie: false
220
221  - if:
222      properties:
223        compatible:
224          contains:
225            const: mediatek,mt7981-eth
226    then:
227      properties:
228        interrupts:
229          minItems: 4
230
231        clocks:
232          minItems: 15
233          maxItems: 15
234
235        clock-names:
236          items:
237            - const: fe
238            - const: gp2
239            - const: gp1
240            - const: wocpu0
241            - const: sgmii_ck
242            - const: sgmii_tx250m
243            - const: sgmii_rx250m
244            - const: sgmii_cdr_ref
245            - const: sgmii_cdr_fb
246            - const: sgmii2_tx250m
247            - const: sgmii2_rx250m
248            - const: sgmii2_cdr_ref
249            - const: sgmii2_cdr_fb
250            - const: netsys0
251            - const: netsys1
252
253        mediatek,sgmiisys:
254          minItems: 2
255          maxItems: 2
256
257  - if:
258      properties:
259        compatible:
260          contains:
261            const: mediatek,mt7986-eth
262    then:
263      properties:
264        interrupts:
265          minItems: 4
266
267        clocks:
268          minItems: 15
269          maxItems: 15
270
271        clock-names:
272          items:
273            - const: fe
274            - const: gp2
275            - const: gp1
276            - const: wocpu1
277            - const: wocpu0
278            - const: sgmii_tx250m
279            - const: sgmii_rx250m
280            - const: sgmii_cdr_ref
281            - const: sgmii_cdr_fb
282            - const: sgmii2_tx250m
283            - const: sgmii2_rx250m
284            - const: sgmii2_cdr_ref
285            - const: sgmii2_cdr_fb
286            - const: netsys0
287            - const: netsys1
288
289        mediatek,sgmiisys:
290          minItems: 2
291          maxItems: 2
292
293patternProperties:
294  "^mac@[0-1]$":
295    type: object
296    additionalProperties: false
297    allOf:
298      - $ref: ethernet-controller.yaml#
299    description:
300      Ethernet MAC node
301    properties:
302      compatible:
303        const: mediatek,eth-mac
304
305      reg:
306        maxItems: 1
307
308      phy-handle: true
309
310      phy-mode: true
311
312    required:
313      - reg
314      - compatible
315      - phy-handle
316
317required:
318  - compatible
319  - reg
320  - interrupts
321  - clocks
322  - clock-names
323  - mediatek,ethsys
324
325unevaluatedProperties: false
326
327examples:
328  - |
329    #include <dt-bindings/interrupt-controller/arm-gic.h>
330    #include <dt-bindings/interrupt-controller/irq.h>
331    #include <dt-bindings/clock/mt7622-clk.h>
332    #include <dt-bindings/power/mt7622-power.h>
333
334    soc {
335      #address-cells = <2>;
336      #size-cells = <2>;
337
338      ethernet: ethernet@1b100000 {
339        compatible = "mediatek,mt7622-eth";
340        reg = <0 0x1b100000 0 0x20000>;
341        interrupts = <GIC_SPI 223 IRQ_TYPE_LEVEL_LOW>,
342                     <GIC_SPI 224 IRQ_TYPE_LEVEL_LOW>,
343                     <GIC_SPI 225 IRQ_TYPE_LEVEL_LOW>;
344        clocks = <&topckgen CLK_TOP_ETH_SEL>,
345                 <&ethsys CLK_ETH_ESW_EN>,
346                 <&ethsys CLK_ETH_GP0_EN>,
347                 <&ethsys CLK_ETH_GP1_EN>,
348                 <&ethsys CLK_ETH_GP2_EN>,
349                 <&sgmiisys CLK_SGMII_TX250M_EN>,
350                 <&sgmiisys CLK_SGMII_RX250M_EN>,
351                 <&sgmiisys CLK_SGMII_CDR_REF>,
352                 <&sgmiisys CLK_SGMII_CDR_FB>,
353                 <&topckgen CLK_TOP_SGMIIPLL>,
354                 <&apmixedsys CLK_APMIXED_ETH2PLL>;
355        clock-names = "ethif", "esw", "gp0", "gp1", "gp2",
356                      "sgmii_tx250m", "sgmii_rx250m",
357                      "sgmii_cdr_ref", "sgmii_cdr_fb", "sgmii_ck",
358                      "eth2pll";
359        power-domains = <&scpsys MT7622_POWER_DOMAIN_ETHSYS>;
360        mediatek,ethsys = <&ethsys>;
361        mediatek,sgmiisys = <&sgmiisys>;
362        cci-control-port = <&cci_control2>;
363        mediatek,pcie-mirror = <&pcie_mirror>;
364        mediatek,hifsys = <&hifsys>;
365        dma-coherent;
366
367        #address-cells = <1>;
368        #size-cells = <0>;
369
370        mdio0: mdio-bus {
371          #address-cells = <1>;
372          #size-cells = <0>;
373
374          phy0: ethernet-phy@0 {
375            reg = <0>;
376          };
377
378          phy1: ethernet-phy@1 {
379            reg = <1>;
380          };
381        };
382
383        gmac0: mac@0 {
384          compatible = "mediatek,eth-mac";
385          phy-mode = "rgmii";
386          phy-handle = <&phy0>;
387          reg = <0>;
388        };
389
390        gmac1: mac@1 {
391          compatible = "mediatek,eth-mac";
392          phy-mode = "rgmii";
393          phy-handle = <&phy1>;
394          reg = <1>;
395        };
396      };
397    };
398
399  - |
400    #include <dt-bindings/interrupt-controller/arm-gic.h>
401    #include <dt-bindings/interrupt-controller/irq.h>
402    #include <dt-bindings/clock/mt7622-clk.h>
403
404    soc {
405      #address-cells = <2>;
406      #size-cells = <2>;
407
408      eth: ethernet@15100000 {
409        #define CLK_ETH_FE_EN               0
410        #define CLK_ETH_WOCPU1_EN           3
411        #define CLK_ETH_WOCPU0_EN           4
412        #define CLK_TOP_NETSYS_SEL          43
413        #define CLK_TOP_NETSYS_500M_SEL     44
414        #define CLK_TOP_NETSYS_2X_SEL       46
415        #define CLK_TOP_SGM_325M_SEL        47
416        #define CLK_APMIXED_NET2PLL         1
417        #define CLK_APMIXED_SGMPLL          3
418
419        compatible = "mediatek,mt7986-eth";
420        reg = <0 0x15100000 0 0x80000>;
421        interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
422                     <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>,
423                     <GIC_SPI 198 IRQ_TYPE_LEVEL_HIGH>,
424                     <GIC_SPI 199 IRQ_TYPE_LEVEL_HIGH>;
425        clocks = <&ethsys CLK_ETH_FE_EN>,
426                 <&ethsys CLK_ETH_GP2_EN>,
427                 <&ethsys CLK_ETH_GP1_EN>,
428                 <&ethsys CLK_ETH_WOCPU1_EN>,
429                 <&ethsys CLK_ETH_WOCPU0_EN>,
430                 <&sgmiisys0 CLK_SGMII_TX250M_EN>,
431                 <&sgmiisys0 CLK_SGMII_RX250M_EN>,
432                 <&sgmiisys0 CLK_SGMII_CDR_REF>,
433                 <&sgmiisys0 CLK_SGMII_CDR_FB>,
434                 <&sgmiisys1 CLK_SGMII_TX250M_EN>,
435                 <&sgmiisys1 CLK_SGMII_RX250M_EN>,
436                 <&sgmiisys1 CLK_SGMII_CDR_REF>,
437                 <&sgmiisys1 CLK_SGMII_CDR_FB>,
438                 <&topckgen CLK_TOP_NETSYS_SEL>,
439                 <&topckgen CLK_TOP_NETSYS_SEL>;
440        clock-names = "fe", "gp2", "gp1", "wocpu1", "wocpu0",
441                      "sgmii_tx250m", "sgmii_rx250m",
442                      "sgmii_cdr_ref", "sgmii_cdr_fb",
443                      "sgmii2_tx250m", "sgmii2_rx250m",
444                      "sgmii2_cdr_ref", "sgmii2_cdr_fb",
445                      "netsys0", "netsys1";
446        mediatek,ethsys = <&ethsys>;
447        mediatek,sgmiisys = <&sgmiisys0>, <&sgmiisys1>;
448        assigned-clocks = <&topckgen CLK_TOP_NETSYS_2X_SEL>,
449                          <&topckgen CLK_TOP_SGM_325M_SEL>;
450        assigned-clock-parents = <&apmixedsys CLK_APMIXED_NET2PLL>,
451                                 <&apmixedsys CLK_APMIXED_SGMPLL>;
452
453        #address-cells = <1>;
454        #size-cells = <0>;
455
456        mdio: mdio-bus {
457          #address-cells = <1>;
458          #size-cells = <0>;
459
460          phy5: ethernet-phy@0 {
461            compatible = "ethernet-phy-id67c9.de0a";
462            phy-mode = "2500base-x";
463            reset-gpios = <&pio 6 1>;
464            reset-deassert-us = <20000>;
465            reg = <5>;
466          };
467
468          phy6: ethernet-phy@1 {
469            compatible = "ethernet-phy-id67c9.de0a";
470            phy-mode = "2500base-x";
471            reg = <6>;
472          };
473        };
474
475        mac0: mac@0 {
476          compatible = "mediatek,eth-mac";
477          phy-mode = "2500base-x";
478          phy-handle = <&phy5>;
479          reg = <0>;
480        };
481
482        mac1: mac@1 {
483          compatible = "mediatek,eth-mac";
484          phy-mode = "2500base-x";
485          phy-handle = <&phy6>;
486          reg = <1>;
487        };
488      };
489    };
490