MT7628 lan1, lan2, lan4 ports led does not work

I have a board with MT7628 SoC CPU, the board has 1 wan port and 4 lan ports, the dts content of the board is as follows:

/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>;
};

&pcie {
        status = "okay";
};

where the 02_network network 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"
                ;;

...

I used the latest OpenWrt 23.04, compiled and burned it into the device, connected the network cable to test the status of the NIC lights, and found that after the cable is connected, only the led of lan3 is lit, and the led of lan1, lan2, lan4 are not lit.

How can I modify it so that the lan1, lan2, lan4 status LEDs light up when the network cable is connected or when data is being transferred?

Or there are other ways to configure 01_leds so that the led on the network port can blink.

I found the MT7628 lan1-4 gpio pin:

And configure them into dts:

        leds {
                compatible = "gpio-leds";

                wan {
                        label = "green:wan";
                        gpios = <&gpio 43 GPIO_ACTIVE_LOW>;
                };

                lan1 {
                        label = "green:lan1";
                        gpios = <&gpio 42 GPIO_ACTIVE_LOW>;
                };

                lan2 {
                        label = "green:lan2";
                        gpios = <&gpio 41 GPIO_ACTIVE_LOW>;
                };

                lan3 {
                        label = "green:lan3";
                        gpios = <&gpio 40 GPIO_ACTIVE_LOW>;
                };

                lan4 {
                        label = "green:lan4";
                        gpios = <&gpio 39 GPIO_ACTIVE_LOW>;
                };
        }

I want to configure 01_leds so that lan1-4 each blink only when receiving data.

To configure lan1-4, but the only ports are eth0.1 and eth0.2:

# ifconfig
br-lan    Link encap:Ethernet  HWaddr 7A:10:12:44:12:F4
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::7810:12ff:fe44:12f4/64 Scope:Link

eth0      Link encap:Ethernet  HWaddr 7A:10:12:44:12:F4
          inet6 addr: fe80::7810:12ff:fe44:12f4/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1

eth0.1    Link encap:Ethernet  HWaddr 7A:10:12:44:12:F4
          UP BROADCAST MULTICAST  MTU:1500  Metric:1

eth0.2    Link encap:Ethernet  HWaddr 7A:10:12:44:12:F4
          inet6 addr: fe80::7810:12ff:fe44:12f4/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1

wlan0     Link encap:Ethernet  HWaddr 00:0C:0A:08:31:18
          inet6 addr: fe80::20c:aff:fe08:3118/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

How should I configure 01_leds to blink when lan1-4 have data?

Configure 01_leds and reboot the device. After the network cable is connected, the led of lan1-4 can be lit up:

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

board=$(board_name)

board_config_update

case $board in
myboard)
        ucidef_set_led_switch "lan1" "lan1" "green:lan1" "switch0" "0x2"
        ucidef_set_led_switch "lan2" "lan2" "green:lan2" "switch0" "0x4"
        ucidef_set_led_switch "lan3" "lan3" "green:lan3" "switch0" "0x8"
        ucidef_set_led_switch "lan4" "lan4" "green:lan4" "switch0" "0x10"
        ucidef_set_led_switch "wan" "wan" "green:wan" "switch0" "0x01"
        ;;

However, the led's of lan1, lan2, lan4 will not blink when there is data transmission, what do I need to configure to make the led's of the network ports blink when there is data transmission?

That depends on how the manufacturer wired the LEDs.
You should ask them

Try to remove p1led_an, p2led_an ... from gpio group.

1 Like

You are right, I removed "wled_an", "p1led_an", "p2led_an", "p3led_en", "p4led_an" from the gpio groups, and when there is a data transfer, the corresponding led starts to blink, thank you!

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