Need help Adding support for ZyXel NBG6503

Hi All

I've been working on adding support for my ZyXel NBG6503, and I think I've been making good progress.
The device consists of a MT7620A + a MT7610E. It has 8MB Flash and 64MB RAM.

I currently am able to build an image for the device and upload the -initramfs version to the device over TFTP from the bootloader.
I have gotten the wired networking to work, as well as the 2.4GHz and 5GHz wireless networks (after adding the MT76x0E driver).

What doesn't work right now is LEDs and buttons.
I have the complete table over which gpio goes to which LEDs and buttons, but I need some help configuring OpenWRT to use them. I think it's my dts file that isn't correct, but I'm not sure, and I don't know how to fix it.
Also, I can control the 2.4GHz LED via GPIO, but not the 5GHz LED. Could it be connected to the MT7610E?

Any pointers would be appreciated :slight_smile:
Thanks

Buttons/LEDs

=== LED ===
+-Name---|-Color-|-Pin-|-Polarity--+
| WPS    | Green | 55  | ActiveLow |
| USB    | Red   | 58  | ActiveLow |
| Power  | Green | 39  | ActiveLow |
| Wifi2G | Green | 72  | ActiveLow |
+--------+-------+-----+-----------+

=== Buttons ===
+-Name---|-Color-|-Pin-|-Polarity--+
| WPS    |       | 2   | ActiveLow |
| WLAN   |       | 57  | ActiveLow |
| Reset  |       | 1   | ActiveLow |
+--------+-------+-----+-----------+

DTS file

/dts-v1/;

#include "mt7620a.dtsi"

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

/ {
	compatible = "zyxel,nbg6503", "ralink,mt7620a-soc";
	model = "ZyXel NBG6503";

	leds {
		compatible = "gpio-leds";

		usb {
			label = "nbg6503:green:usb";
			gpios = <&gpio0 58 GPIO_ACTIVE_LOW>;
			trigger-sources = <&ohci_port1>, <&ehci_port1>;
			linux,default-trigger = "usbport";
		};

		wifi {
			label = "nbg6503:green:wifi";
			gpios = <&gpio3 72 GPIO_ACTIVE_LOW>;
		};
		
/*		led_power_green: power {
			label = "keenetic-viva:green:power";
			gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
		};*/
/*		power {
			label = "nbg6503:green:power";
			gpios = <&gpio0 39 GPIO_ACTIVE_LOW>;
		}*/
	};

	keys {
		compatible = "gpio-keys";

		reset {
			label = "reset";
			gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RESTART>;
		};

		wps {
			label = "wps";
			gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_WPS_BUTTON>;
		};
	};

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

		/*usbpower {
			gpio-export,name = "usbpower";
			gpio-export,output = <1>;
			gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>;
		};*/

		test {
			gpio-export,name = "testname";
			gpio-export,output = <1>;
			gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
		};
	};
};

&gpio0 {
	status = "okay";
};

&gpio1 {
	status = "okay";
};

&gpio2 {
	status = "okay";
};

&gpio3 {
	status = "okay";
};

&spi0 {
	status = "okay";

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

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

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

			partition@30000 {
				label = "Config";
				reg = <0x30000 0x10000>;
				read-only;
			};

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

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

&ehci {
	status = "okay";
};

&ohci {
	status = "okay";
};

&ethernet {
	mtd-mac-address = <&factory 0x28>;

	mediatek,portmap = "llllw";
};

&gsw {
	mediatek,port4 = "ephy";
};

&wmac {
	pinctrl-names = "default";
	pinctrl-0 = <&pa_pins>;

	ralink,mtd-eeprom = <&factory 0x0>;
	mtd-mac-address = <&factory 0x28>;
};

&pcie {
	status = "okay";
};

&state_default {
	gpio {
		groups = "uartf", "nd_sd", "wled";
		function = "gpio";
	};
};

&pcie0 {
	mt76@0,0 {
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&factory 0x8000>;
		ieee80211-freq-limit = <5000000 6000000>;
	};
};

gpiochip0 control gpio0-gpio23
gpiochip1 - gpio24-gpio39
gpiochip2 - gpio40-gpio71
gpiochip3 - gpio72
So gpio72 is gpio number 0 at gpiochip3 or <&gpio3 0 GPIO_ACTIVE_LOW >
And as result:

=== LED ===
+-Name---|-Color-|-Pin-|-Polarity--+
| WPS    | Green | 55  | ActiveLow | <&gpio2 15 GPIO_ACTIVE_LOW >
| USB    | Red   | 58  | ActiveLow | <&gpio2 18 GPIO_ACTIVE_LOW >
| Power  | Green | 39  | ActiveLow | <&gpio1 15 GPIO_ACTIVE_LOW >
| Wifi2G | Green | 72  | ActiveLow | <&gpio3 0 GPIO_ACTIVE_LOW >
+--------+-------+-----+-----------+

=== Buttons ===
+-Name---|-Color-|-Pin-|-Polarity--+
| WPS    |       | 2   | ActiveLow | <&gpio0 2 GPIO_ACTIVE_LOW >
| WLAN   |       | 57  | ActiveLow | <&gpio2 17 GPIO_ACTIVE_LOW >
| Reset  |       | 1   | ActiveLow | <&gpio0 1 GPIO_ACTIVE_LOW >
+--------+-------+-----+-----------+

Hi @123serge123,

I tried changing the GPIO numbers to the ones you suggested.
I changed the DTS to:

		wifi {
			label = "nbg6503:green:wifi";
			gpios = <&gpio3 0 GPIO_ACTIVE_LOW>;
		};

But it still doesn't work.
I'm trying to get the wifi led to turn on when there's wifi activity.

Did you modify target/linux/ramips/mt7620/base-files/etc/board.d/01_leds?
Something like

dlink,dwr-116-a1|\
head-weblink,hdrm200|\
ohyeah,oy-0001|\
planex,mzk-ex300np|\
zbtlink,zbt-wr8305rt|\
zyxel,keenetic-omni|\
zyxel,keenetic-omni-ii|\
zyxel,keenetic-viva|\
zyxel,nbg6503)
	set_wifi_led "$boardname:green:wifi"
	;;

Yes, I did:

zyxel,keenetic-omni-ii|\
zyxel,keenetic-viva)
	set_wifi_led "$boardname:green:wifi"
	;;
zyxel,nbg6503)
	set_wifi_led "$boardname:green:wifi" "wlan1"
	;;
dlink,dwr-118-a1)
	ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0" "0x1f"

I also tried without "wlan1", but that didn't work either

Check wifi led settings in /etc/config/system.
Or in command line in /sys/class/leds/nbg6503:green:wifi

Hi @123serge123

/etc/config/system contains:

config led 'led_wifi_led'
	option name 'wifi'
	option sysfs 'nbg6503:green:wifi'
	option trigger 'netdev'
	option mode 'link tx rx'
	option dev 'wlan1'

And /sys/class/leds contain:

root@OpenWrt:~#  ls -l /sys/class/leds/
lrwxrwxrwx    1 root     root             0 Jul  5 22:16 mt76-phy0 -> ../../devices/pci0000:00/0000:00:00.0/0000:01:00.0/leds/mt76-phy0
lrwxrwxrwx    1 root     root             0 Jul  5 22:16 rt2800soc-phy1::assoc -> ../../devices/platform/10180000.wmac/leds/rt2800soc-phy1::assoc
lrwxrwxrwx    1 root     root             0 Jul  5 22:16 rt2800soc-phy1::quality -> ../../devices/platform/10180000.wmac/leds/rt2800soc-phy1::quality
lrwxrwxrwx    1 root     root             0 Jul  5 22:16 rt2800soc-phy1::radio -> ../../devices/platform/10180000.wmac/leds/rt2800soc-phy1::radio
root@OpenWrt:~#

I don't see the LED in /sys/class/leds...

Check dts-file carefully.