Mt7628 1-4 lan ports not working

I have a board using MT7628 SoC and want to enable it 1 wan port and 4 lan ports. Below is the dts file contents:

/dts-v1/;

#include "mt7628an.dtsi"

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

/ {
        compatible = "myboard", "mediatek,mt7628an-soc";

        model = "myboard";

        chosen {
                bootargs = "console=ttyS0,115200";
        };

        memory@0 {
                device_type = "memory";
                reg = <0x0 0x8000000>; // 128MB
        };

        leds {
                compatible = "gpio-leds";
        };

        gpio-export {
                compatible = "gpio-export";
                #size-cells = <0>;
        };
};

&state_default {
        gpio {
                groups = "gpio", "wdt", "i2s", "wled_an", "p1led_an", "p2led_an", "p3led_en", "p4led_an";
                function = "gpio";
        };
};

&spi0 {
        status = "okay";

        flash@0 {
                compatible = "jedec,spi-nor";
                reg = <0>;
                spi-max-frequency = <32000000>;

                partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
                        #size-cells = <1>;

                        partition@0 {
                                label = "u-boot";
                                reg = <0x0 0x30000>;
                                read-only;
                        };

                        partition@30000 {
                                label = "u-boot-env";
                                reg = <0x30000 0x10000>;
                        };

                        factory: partition@40000 {
                                label = "factory";
                                reg = <0x40000 0x10000>;
                        };

                        partition@50000 {
                                compatible = "denx,uimage";
                                reg = <0x50000 0x0>;
                                label = "firmware";
                        };
                };
        };
};


&i2c {
       status = "okay";
};

&ethernet {
        status = "okay";

        nvmem-cells = <&macaddr_factory_28>;
        nvmem-cell-names = "mac-address";
        mac-address-increment = <1>;
};

&factory {
        compatible = "nvmem-cells";
        #address-cells = <1>;
        #size-cells = <1>;

        macaddr_factory_28: macaddr@28 {
                reg = <0x28 0x6>;
        };
};

&uart1 {
        status = "okay";
};

&uart2 {
        status = "okay";
};

&wmac {
        status = "okay";
        mediatek,mtd-eeprom = <&factory 0x0>;
};

&esw {
        mediatek,portmap = <0x3e>;
};

&sdhci {
        status = "okay";
};

&pcie {
        status = "okay";
};

The 02_network file is configured as follows:

# head -n 20 ./target/linux/ramips/mt76x8/base-files/etc/board.d/02_network

. /lib/functions.sh
. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh

ramips_setup_interfaces()
{
        local board="$1"

        case $board in
        myboard)
                ucidef_add_switch "switch0" \
                        "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
                ;;

...

After compiling openwrt and flashing it to the device, wan port works, but lan 1-4 ports don't work.

How can I configure it so that lan 1-4 ports can be used normally?

Openwrt has swconfig package.

# swconfig list
Found: switch0 - rt305x

# swconfig dev switch0 show
Global attributes:
        enable_vlan: 1
        alternate_vlan_disable: 0
        bc_storm_protect: 0
        led_frequency: 0
Port 0:
        disable: 0
        doubletag: 0
        untag: 1
        led: 5
        lan: 0
        recv_bad: 0
        recv_good: 0
        tr_bad: 0
        tr_good: 0
        pvid: 2
        link: port:0 link:down
Port 1:
        disable: 0
        doubletag: 0
        untag: 1
        led: 5
        lan: 1
        recv_bad: 0
        recv_good: 0
        tr_bad: 0
        tr_good: 0
        pvid: 1
        link: port:1 link:down
Port 2:
        disable: 0
        doubletag: 0
        untag: 1
        led: 5
        lan: 1
        recv_bad: 0
        recv_good: 0
        tr_bad: 0
        tr_good: 0
        pvid: 1
        link: port:2 link:down
Port 3:
        disable: 0
        doubletag: 0
        untag: 1
        led: 5
        lan: 1
        recv_bad: 0
        recv_good: 0
        tr_bad: 0
        tr_good: 0
        pvid: 1
        link: port:3 link:down
Port 4:
        disable: 0
        doubletag: 0
        untag: 1
        led: 5
        lan: 1
        recv_bad: 0
        recv_good: 0
        tr_bad: 0
        tr_good: 0
        pvid: 1
        link: port:4 link:down
Port 5:
        disable: 1
        doubletag: 0
        untag: 0
        led: ???
        lan: 1
        recv_bad: 0
        recv_good: 0
        tr_bad: 0
        tr_good: 0
        pvid: 0
        link: port:5 link:down
Port 6:
        disable: 0
        doubletag: 0
        untag: 0
        led: ???
        lan: ???
        recv_bad: ???
        recv_good: ???
        tr_bad: ???
        tr_good: ???
        pvid: 0
        link: port:6 link:up speed:1000baseT full-duplex
VLAN 1:
        ports: 1 2 3 4 6t
VLAN 2:
        ports: 0 6t

The brctl command output:

# brctl show
bridge name     bridge id               STP enabled     interfaces
br-lan          7fff.32fc97c69cd7       no              wlan0
                                                        eth0.1

Oh, if use openwrt 23.04 lan 1-4 ports is work, but use openwrt 22.03 lan 1-4 ports don't work.

Is there a fix patch for openwrt 22.03?

Or is the kernel compilation option less turned on?

Disable &sdhci on your device tree, the mt7628 CPU pinmuxes that 4x ethernet ports with the eMMC/SDCard interface, which conflicts with the esw controller.

I found differences between 22.03 and 23.04, mainly a change in mt7628an.dti that fixed the problem:

$ git show 0128d860a0724514256e1a31e24f0515a7b7bd0e
commit 0128d860a0724514256e1a31e24f0515a7b7bd0e
Author: Maxim Anisimov <maxim.anisimov.ua@gmail.com>
Date:   Sun Dec 10 16:40:39 2023 +0100

    ramips: dts: mt7628an: reset FE and ESW cores together

    Failing to do so will cause the DMA engine to not initialize properly
    and fail to forward packets between them, and in some cases will cause
    spurious transmission with size exceeding allowed packet size, causing a
    kernel panic.

    Fixes: 60fadae62b64 ("ramips: ethernet: ralink: move reset of the esw into the esw instead of fe")
    Signed-off-by: Maxim Anisimov <maxim.anisimov.ua@gmail.com>

    [Provide commit description, split into logical changes]
    Signed-off-by: Lech Perczak <lech.perczak@gmail.com>

    (cherry picked from commit f87b66507e9245e6e02dbc76e2e7b27c9e0bf364)
    Signed-off-by: Lech Perczak <lech.perczak@gmail.com>

diff --git a/target/linux/ramips/dts/mt7628an.dtsi b/target/linux/ramips/dts/mt7628an.dtsi
index 8ef73dce80..788e24714f 100644
--- a/target/linux/ramips/dts/mt7628an.dtsi
+++ b/target/linux/ramips/dts/mt7628an.dtsi
@@ -429,8 +429,8 @@
                interrupt-parent = <&cpuintc>;
                interrupts = <5>;

-               resets = <&rstctrl 21>;
-               reset-names = "fe";
+               resets = <&rstctrl 21>, <&rstctrl 23>;
+               reset-names = "fe", "esw";

                mediatek,switch = <&esw>;
        };
@@ -439,8 +439,8 @@
                compatible = "mediatek,mt7628-esw", "ralink,rt3050-esw";
                reg = <0x10110000 0x8000>;

-               resets = <&rstctrl 23 &rstctrl 24>;
-               reset-names = "esw", "ephy";
+               resets = <&rstctrl 24>;
+               reset-names = "ephy";

                interrupt-parent = <&intc>;
                interrupts = <17>;

Applying that fix to 22.03 fixed it, thank you!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.