Mediatek MT7530 and MT7531 Ethernet Switches

Schema identifier ($id): "http://devicetree.org/schemas/net/dsa/mediatek,mt7530.yaml#"

Schema dialect ($schema): "http://devicetree.org/meta-schemas/core.yaml#"

Maintainers (maintainers): "Arınç ÜNAL <arinc.unal@arinc9.com>", "Landen Chao <Landen.Chao@mediatek.com>", "DENG Qingfang <dqfext@gmail.com>", "Sean Wang <sean.wang@mediatek.com>", "Daniel Golle <daniel@makrotopia.org>"

There are three versions of MT7530, standalone, in a multi-chip module and built-into a SoC.

MT7530 is a part of the multi-chip module in MT7620AN, MT7620DA, MT7620DAN, MT7620NN, MT7621AT, MT7621DAT, MT7621ST and MT7623AI SoCs.

The MT7988 SoC comes with a built-in switch similar to MT7531 as well as four Gigabit Ethernet PHYs. The switch registers are directly mapped into the SoC's memory map rather than using MDIO. The switch has an internally connected 10G CPU port and 4 user ports connected to the built-in Gigabit Ethernet PHYs.

The MT7530 in MT7620AN, MT7620DA, MT7620DAN and MT7620NN SoCs has 10/100 PHYs and the switch registers are directly mapped into SoC's memory map rather than using MDIO. The DSA driver currently doesn't support MT7620 variants.

There is only the standalone version of MT7531.

Port 5 on MT7530 supports various configurations:

  - Port 5 can be used as a CPU port.
  - PHY 0 or 4 of the switch can be muxed to gmac5 of the switch. Therefore,
    the gmac of the SoC which is wired to port 5 can connect to the PHY.
    This is usually used for connecting the wan port directly to the CPU to
    achieve 2 Gbps routing in total.
    The driver looks up the reg on the ethernet-phy node, which the phy-handle
    property on the gmac node refers to, to mux the specified phy.
    The driver requires the gmac of the SoC to have "mediatek,eth-mac" as the
    compatible string and the reg must be 1. So, for now, only gmac1 of a
    MediaTek SoC can benefit this. Banana Pi BPI-R2 suits this.
    For the MT7621 SoCs, rgmii2 group must be claimed with rgmii2 function.
    Check out example 5.
  - For the multi-chip module MT7530, in case of an external phy wired to
    gmac1 of the SoC, port 5 must not be enabled.
    In case of muxing PHY 0 or 4, the external phy must not be enabled.
    For the MT7621 SoCs, rgmii2 group must be claimed with rgmii2 function.
    Check out example 6.
  - Port 5 can be wired to an external phy. Port 5 becomes a DSA user port.
    For the multi-chip module MT7530, the external phy must be wired TX to TX
    to gmac1 of the SoC for this to work. Ubiquiti EdgeRouter X SFP is wired
    this way.
    For the multi-chip module MT7530, muxing PHY 0 or 4 won't work when the
    external phy is connected TX to TX.
    For the MT7621 SoCs, rgmii2 group must be claimed with gpio function.
    Check out example 7.

Properties and child nodes (properties) #

compatible — required here #

Exactly one of these rules must match (oneOf) #

Rule 1

Standalone MT7530 and multi-chip module MT7530 in MT7623AI SoC

Exact value (const): "mediatek,mt7530"

Rule 2

Standalone MT7531

Exact value (const): "mediatek,mt7531"

Rule 3

Multi-chip module MT7530 in MT7621AT, MT7621DAT and MT7621ST SoCs

Exact value (const): "mediatek,mt7621"

Rule 4

Built-in switch of the MT7988 SoC

Exact value (const): "mediatek,mt7988-switch"

Rule 5

Built-in switch of the Airoha EN7581 SoC

Exact value (const): "airoha,en7581-switch"

Rule 6

Built-in switch of the Airoha AN7583 SoC

Exact value (const): "airoha,an7583-switch"

reg — required here #

Maximum number of items (maxItems): 1

core-supply — not listed as required here #

Phandle to the regulator node necessary for the core power.

#gpio-cells — not listed as required here #

Exact value (const): 2

gpio-controller — not listed as required here #

Value type (type): "boolean"

If defined, LED controller of the MT7530 switch will run on GPIO mode.

There are 15 controllable pins. port 0 LED 0..2 as GPIO 0..2 port 1 LED 0..2 as GPIO 3..5 port 2 LED 0..2 as GPIO 6..8 port 3 LED 0..2 as GPIO 9..11 port 4 LED 0..2 as GPIO 12..14

#interrupt-cells — not listed as required here #

Exact value (const): 1

interrupt-controller — not listed as required here #

true — No constraints added by this property rule.

interrupts — not listed as required here #

Maximum number of items (maxItems): 1

io-supply — not listed as required here #

Phandle to the regulator node necessary for the I/O power. See Documentation/devicetree/bindings/regulator/mt6323-regulator.txt for details for the regulator setup on these boards.

mdio — not listed as required here #

Shared schema rule ($ref): /schemas/net/mdio.yaml#

Properties not evaluated by applicable rules (unevaluatedProperties) #

false

Not allowed by this rule.

Properties and child nodes (properties) #

mediatek,pio — not listed as required here

Shared schema rule ($ref): /schemas/types.yaml#/definitions/phandle

Phandle pointing to the mediatek pinctrl node.

mediatek,mcm — not listed as required here #

Value type (type): "boolean"

Used for MT7621AT, MT7621DAT, MT7621ST and MT7623AI SoCs which the MT7530 switch is a part of the multi-chip module.

reset-gpios — not listed as required here #

GPIO to reset the switch. Use this if mediatek,mcm is not used. This property is optional because some boards share the reset line with other components which makes it impossible to probe the switch if the reset line is used.

Maximum number of items (maxItems): 1

reset-names — not listed as required here #

Exact value (const): "mcm"

resets — not listed as required here #

Phandle pointing to the system reset controller with line index for the ethsys.

Maximum number of items (maxItems): 1

Properties matching a name pattern (patternProperties) #

^(ethernet-)?ports$ — name matches this regular expression #

Value type (type): "object"

Properties not matched by properties or patternProperties in this schema (additionalProperties) #

true

Allowed by this rule.

Properties matching a name pattern (patternProperties) #

^(ethernet-)?port@[0-6]$ — name matches this regular expression

Value type (type): "object"

Properties not matched by properties or patternProperties in this schema (additionalProperties)

true

Allowed by this rule.

Properties and child nodes (properties)

reg — not listed as required here

Port address described must be 5 or 6 for CPU port and from 0 to 5 for user ports.

All of these rules must match (allOf)

Rule 1

Condition (if)

Required in this object (required): "ethernet"

When the condition matches (then)

Properties and child nodes (properties)

reg — not listed as required here

Allowed values (enum): 5, 6

Required in this object (required): "compatible", "reg"

Reusable definitions ($defs) #

builtin-dsa-port #

Properties matching a name pattern (patternProperties) #

^(ethernet-)?ports$ — name matches this regular expression

Properties matching a name pattern (patternProperties)

^(ethernet-)?port@[0-6]$ — name matches this regular expression

Condition (if)

Required in this object (required): "ethernet"

When the condition matches (then)

Properties and child nodes (properties)

phy-mode — not listed as required here

Exact value (const): "internal"

mt7530-dsa-port #

Properties matching a name pattern (patternProperties) #

^(ethernet-)?ports$ — name matches this regular expression

Properties matching a name pattern (patternProperties)

^(ethernet-)?port@[0-6]$ — name matches this regular expression

Condition (if)

Required in this object (required): "ethernet"

When the condition matches (then)

Condition (if)

Properties and child nodes (properties)

reg — not listed as required here

Exact value (const): 5

When the condition matches (then)

Properties and child nodes (properties)

phy-mode — not listed as required here

Allowed values (enum): "gmii", "mii", "rgmii"

When the condition does not match (else)

Properties and child nodes (properties)

phy-mode — not listed as required here

Allowed values (enum): "rgmii", "trgmii"

mt7531-dsa-port #

Properties matching a name pattern (patternProperties) #

^(ethernet-)?ports$ — name matches this regular expression

Properties matching a name pattern (patternProperties)

^(ethernet-)?port@[0-6]$ — name matches this regular expression

Condition (if)

Required in this object (required): "ethernet"

When the condition matches (then)

Condition (if)

Properties and child nodes (properties)

reg — not listed as required here

Exact value (const): 5

When the condition matches (then)

Properties and child nodes (properties)

phy-mode — not listed as required here

Allowed values (enum): "1000base-x", "2500base-x", "rgmii", "sgmii"

When the condition does not match (else)

Properties and child nodes (properties)

phy-mode — not listed as required here

Allowed values (enum): "1000base-x", "2500base-x", "sgmii"

All of these rules must match (allOf) #

Rule 1 #

Shared schema rule ($ref): dsa.yaml#/$defs/ethernet-ports

Rule 2 #

Condition (if) #

Required in this object (required): "mediatek,mcm"

When the condition matches (then) #

Properties and child nodes (properties)

reset-gpios — not listed as required here

false — Not permitted by this property rule.

Required in this object (required): "resets", "reset-names"

Rule 3 #

Property dependencies (dependencies) #

interrupt-controller — applies when this property is present

Also requires: "interrupts"

Rule 4 #

Condition (if) #

Properties and child nodes (properties)

compatible — not listed as required here

Exact value (const): "mediatek,mt7530"

When the condition matches (then) #

Shared schema rule ($ref): #/$defs/mt7530-dsa-port

Required in this object (required): "core-supply", "io-supply"

Rule 5 #

Condition (if) #

Properties and child nodes (properties)

compatible — not listed as required here

Exact value (const): "mediatek,mt7531"

When the condition matches (then) #

Shared schema rule ($ref): #/$defs/mt7531-dsa-port

Properties and child nodes (properties)

gpio-controller — not listed as required here

false — Not permitted by this property rule.

mediatek,mcm — not listed as required here

false — Not permitted by this property rule.

Rule 6 #

Condition (if) #

Properties and child nodes (properties)

compatible — not listed as required here

Exact value (const): "mediatek,mt7621"

When the condition matches (then) #

Shared schema rule ($ref): #/$defs/mt7530-dsa-port

Required in this object (required): "mediatek,mcm"

Rule 7 #

Condition (if) #

Properties and child nodes (properties)

compatible — not listed as required here

Allowed values (enum): "mediatek,mt7988-switch", "airoha,en7581-switch", "airoha,an7583-switch"

When the condition matches (then) #

Shared schema rule ($ref): #/$defs/builtin-dsa-port

Properties and child nodes (properties)

gpio-controller — not listed as required here

false — Not permitted by this property rule.

mediatek,mcm — not listed as required here

false — Not permitted by this property rule.

reset-names — not listed as required here

false — Not permitted by this property rule.

Properties not evaluated by applicable rules (unevaluatedProperties) #

false

Not allowed by this rule.

Examples (examples) #

#include <dt-bindings/gpio/gpio.h>

mdio {
    #address-cells = <1>;
    #size-cells = <0>;

    switch@1f {
        compatible = "mediatek,mt7530";
        reg = <0x1f>;

        reset-gpios = <&pio 33 0>;

        core-supply = <&mt6323_vpa_reg>;
        io-supply = <&mt6323_vemc3v3_reg>;

        ethernet-ports {
            #address-cells = <1>;
            #size-cells = <0>;

            port@0 {
                reg = <0>;
                label = "lan1";
            };

            port@1 {
                reg = <1>;
                label = "lan2";
            };

            port@2 {
                reg = <2>;
                label = "lan3";
            };

            port@3 {
                reg = <3>;
                label = "lan4";
            };

            port@4 {
                reg = <4>;
                label = "wan";
            };

            port@6 {
                reg = <6>;
                ethernet = <&gmac0>;
                phy-mode = "rgmii";

                fixed-link {
                    speed = <1000>;
                    full-duplex;
                    pause;
                };
            };
        };
    };
};
#include <dt-bindings/reset/mt2701-resets.h>

mdio {
    #address-cells = <1>;
    #size-cells = <0>;

    switch@1f {
        compatible = "mediatek,mt7530";
        reg = <0x1f>;

        mediatek,mcm;
        resets = <&ethsys MT2701_ETHSYS_MCM_RST>;
        reset-names = "mcm";

        core-supply = <&mt6323_vpa_reg>;
        io-supply = <&mt6323_vemc3v3_reg>;

        ethernet-ports {
            #address-cells = <1>;
            #size-cells = <0>;

            port@0 {
                reg = <0>;
                label = "lan1";
            };

            port@1 {
                reg = <1>;
                label = "lan2";
            };

            port@2 {
                reg = <2>;
                label = "lan3";
            };

            port@3 {
                reg = <3>;
                label = "lan4";
            };

            port@4 {
                reg = <4>;
                label = "wan";
            };

            port@6 {
                reg = <6>;
                ethernet = <&gmac0>;
                phy-mode = "trgmii";

                fixed-link {
                    speed = <1000>;
                    full-duplex;
                    pause;
                };
            };
        };
    };
};
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/irq.h>

mdio {
    #address-cells = <1>;
    #size-cells = <0>;

    switch@0 {
        compatible = "mediatek,mt7531";
        reg = <0>;

        reset-gpios = <&pio 54 0>;

        interrupt-controller;
        #interrupt-cells = <1>;
        interrupt-parent = <&pio>;
        interrupts = <53 IRQ_TYPE_LEVEL_HIGH>;

        ethernet-ports {
            #address-cells = <1>;
            #size-cells = <0>;

            port@0 {
                reg = <0>;
                label = "lan1";
            };

            port@1 {
                reg = <1>;
                label = "lan2";
            };

            port@2 {
                reg = <2>;
                label = "lan3";
            };

            port@3 {
                reg = <3>;
                label = "lan4";
            };

            port@4 {
                reg = <4>;
                label = "wan";
            };

            port@6 {
                reg = <6>;
                ethernet = <&gmac0>;
                phy-mode = "2500base-x";

                fixed-link {
                    speed = <2500>;
                    full-duplex;
                    pause;
                };
            };
        };
    };
};
#include <dt-bindings/interrupt-controller/mips-gic.h>
#include <dt-bindings/reset/mt7621-reset.h>

mdio {
    #address-cells = <1>;
    #size-cells = <0>;

    switch@1f {
        compatible = "mediatek,mt7621";
        reg = <0x1f>;

        mediatek,mcm;
        resets = <&sysc MT7621_RST_MCM>;
        reset-names = "mcm";

        interrupt-controller;
        #interrupt-cells = <1>;
        interrupt-parent = <&gic>;
        interrupts = <GIC_SHARED 23 IRQ_TYPE_LEVEL_HIGH>;

        ethernet-ports {
            #address-cells = <1>;
            #size-cells = <0>;

            port@0 {
                reg = <0>;
                label = "lan1";
            };

            port@1 {
                reg = <1>;
                label = "lan2";
            };

            port@2 {
                reg = <2>;
                label = "lan3";
            };

            port@3 {
                reg = <3>;
                label = "lan4";
            };

            port@4 {
                reg = <4>;
                label = "wan";
            };

            port@6 {
                reg = <6>;
                ethernet = <&gmac0>;
                phy-mode = "trgmii";

                fixed-link {
                    speed = <1000>;
                    full-duplex;
                    pause;
                };
            };
        };
    };
};
#include <dt-bindings/interrupt-controller/mips-gic.h>
#include <dt-bindings/reset/mt7621-reset.h>

ethernet {
    #address-cells = <1>;
    #size-cells = <0>;

    pinctrl-names = "default";
    pinctrl-0 = <&rgmii2_pins>;

    mac@1 {
        compatible = "mediatek,eth-mac";
        reg = <1>;

        phy-mode = "rgmii";
        phy-handle = <&example5_ethphy4>;
    };

    mdio {
        #address-cells = <1>;
        #size-cells = <0>;

        /* MT7530's phy4 */
        example5_ethphy4: ethernet-phy@4 {
            reg = <4>;
        };

        switch@1f {
            compatible = "mediatek,mt7621";
            reg = <0x1f>;

            mediatek,mcm;
            resets = <&sysc MT7621_RST_MCM>;
            reset-names = "mcm";

            interrupt-controller;
            #interrupt-cells = <1>;
            interrupt-parent = <&gic>;
            interrupts = <GIC_SHARED 23 IRQ_TYPE_LEVEL_HIGH>;

            ethernet-ports {
                #address-cells = <1>;
                #size-cells = <0>;

                port@0 {
                    reg = <0>;
                    label = "lan1";
                };

                port@1 {
                    reg = <1>;
                    label = "lan2";
                };

                port@2 {
                    reg = <2>;
                    label = "lan3";
                };

                port@3 {
                    reg = <3>;
                    label = "lan4";
                };

                /* Commented out, phy4 is connected to gmac1.
                port@4 {
                    reg = <4>;
                    label = "wan";
                };
                */

                port@6 {
                    reg = <6>;
                    ethernet = <&gmac0>;
                    phy-mode = "trgmii";

                    fixed-link {
                        speed = <1000>;
                        full-duplex;
                        pause;
                    };
                };
            };
        };
    };
};
#include <dt-bindings/interrupt-controller/mips-gic.h>
#include <dt-bindings/reset/mt7621-reset.h>

ethernet {
    #address-cells = <1>;
    #size-cells = <0>;

    pinctrl-names = "default";
    pinctrl-0 = <&rgmii2_pins>;

    mac@1 {
        compatible = "mediatek,eth-mac";
        reg = <1>;

        phy-mode = "rgmii";
        phy-handle = <&example6_ethphy7>;
    };

    mdio {
        #address-cells = <1>;
        #size-cells = <0>;

        /* External PHY */
        example6_ethphy7: ethernet-phy@7 {
            reg = <7>;
            phy-mode = "rgmii";
        };

        switch@1f {
            compatible = "mediatek,mt7621";
            reg = <0x1f>;

            mediatek,mcm;
            resets = <&sysc MT7621_RST_MCM>;
            reset-names = "mcm";

            interrupt-controller;
            #interrupt-cells = <1>;
            interrupt-parent = <&gic>;
            interrupts = <GIC_SHARED 23 IRQ_TYPE_LEVEL_HIGH>;

            ethernet-ports {
                #address-cells = <1>;
                #size-cells = <0>;

                port@0 {
                    reg = <0>;
                    label = "lan1";
                };

                port@1 {
                    reg = <1>;
                    label = "lan2";
                };

                port@2 {
                    reg = <2>;
                    label = "lan3";
                };

                port@3 {
                    reg = <3>;
                    label = "lan4";
                };

                port@4 {
                    reg = <4>;
                    label = "wan";
                };

                port@6 {
                    reg = <6>;
                    ethernet = <&gmac0>;
                    phy-mode = "trgmii";

                    fixed-link {
                        speed = <1000>;
                        full-duplex;
                        pause;
                    };
                };
            };
        };
    };
};
#include <dt-bindings/interrupt-controller/mips-gic.h>
#include <dt-bindings/reset/mt7621-reset.h>

ethernet {
    #address-cells = <1>;
    #size-cells = <0>;

    pinctrl-names = "default";
    pinctrl-0 = <&rgmii2_pins>;

    mdio {
        #address-cells = <1>;
        #size-cells = <0>;

        /* External PHY */
        example7_ethphy7: ethernet-phy@7 {
            reg = <7>;
            phy-mode = "rgmii";
        };

        switch@1f {
            compatible = "mediatek,mt7621";
            reg = <0x1f>;

            mediatek,mcm;
            resets = <&sysc MT7621_RST_MCM>;
            reset-names = "mcm";

            interrupt-controller;
            #interrupt-cells = <1>;
            interrupt-parent = <&gic>;
            interrupts = <GIC_SHARED 23 IRQ_TYPE_LEVEL_HIGH>;

            ethernet-ports {
                #address-cells = <1>;
                #size-cells = <0>;

                port@0 {
                    reg = <0>;
                    label = "lan1";
                };

                port@1 {
                    reg = <1>;
                    label = "lan2";
                };

                port@2 {
                    reg = <2>;
                    label = "lan3";
                };

                port@3 {
                    reg = <3>;
                    label = "lan4";
                };

                port@4 {
                    reg = <4>;
                    label = "wan";
                };

                port@5 {
                    reg = <5>;
                    label = "extphy";
                    phy-mode = "rgmii-txid";
                    phy-handle = <&example7_ethphy7>;
                };

                port@6 {
                    reg = <6>;
                    ethernet = <&gmac0>;
                    phy-mode = "trgmii";

                    fixed-link {
                        speed = <1000>;
                        full-duplex;
                        pause;
                    };
                };
            };
        };
    };
};

Source notes #

Annotations retained from the schema source

Line 1: SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)

Line 331: Example 1: Standalone MT7530

Line 392: Example 2: MT7530 in MT7623AI SoC

Line 455: Example 3: Standalone MT7531

Line 519: Example 4: MT7530 in MT7621AT, MT7621DAT and MT7621ST SoCs

Line 585: Example 5: MT7621: mux MT7530's phy4 to SoC's gmac1

Line 674: Example 6: MT7621: mux external phy to SoC's gmac1

Line 762: Example 7: MT7621: mux external phy to MT7530's port 5

Edit this page