LED on GPIO on the port RGMII2

Hi

I connected LED to the RGMI2 PINs that I would like to command like GPIO, but its don't work.

On DST file:

	leds {
		compatible = "gpio-leds";

		led_run: system-red{
			label = "system-red";
			gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
		};
		system-blue{
			label = "system-blue";
			gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
		};
		wifi-red{
			label = "wifi-red";
			gpios = <&gpio 26 GPIO_ACTIVE_LOW>;
		};
		wifi-blue{
			label = "wifi-blue";
			gpios = <&gpio 27 GPIO_ACTIVE_LOW>;
		};
		eth-red{
			label = "eth-red";
			gpios = <&gpio 24 GPIO_ACTIVE_LOW>;
		};
		eth-green{
			label = "eth-green";
			gpios = <&gpio 23 GPIO_ACTIVE_LOW>;
		};
		eth-blue{
			label = "eth-blue";
			gpios = <&gpio 22 GPIO_ACTIVE_LOW>;
		};
	};

They appear correctly in Lucy, but the LEDs are not commanded.

Datasheed reports a register, do I have to set it ?
Where and how?

What's the name of the board?

GEVA batteryPoE bt
My custom board.

Show the complete .dts file

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

#include "mt7621.dtsi"

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

/ {
	compatible = "geva,batteryPoE-at3-bt", "mediatek,mt7621-soc";
	model = "GEVA BatteryPoE at3 bt";

	aliases {
		led-boot = &led_run;
		led-failsafe = &led_run;
		led-running = &led_run;
		led-upgrade = &led_run;
	};

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

	keys {
		compatible = "gpio-keys";

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

	leds {
		compatible = "gpio-leds";

		led_run: system-red{
			label = "system-red";
			gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
		};
		system-blue{
			label = "system-blue";
			gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
		};
		wifi-red{
			label = "wifi-red";
			gpios = <&gpio 26 GPIO_ACTIVE_LOW>;
		};
		wifi-blue{
			label = "wifi-blue";
			gpios = <&gpio 27 GPIO_ACTIVE_LOW>;
		};
		eth-red{
			label = "eth-red";
			gpios = <&gpio 24 GPIO_ACTIVE_LOW>;
		};
		eth-green{
			label = "eth-green";
			gpios = <&gpio 23 GPIO_ACTIVE_LOW>;
		};
		eth-blue{
			label = "eth-blue";
			gpios = <&gpio 22 GPIO_ACTIVE_LOW>;
		};
	};
};

&i2c {
	status = "okay";
};

&sdhci {
	status = "okay";
};

&spi0 {
	status = "okay";

	flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <80000000>;
		m25p,fast-read;
		broken-flash-reset;

		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>;
				read-only;
			};

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

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

&pcie {
	status = "okay";
};

&pcie0 {
	wifi@0,0 {
		compatible = "mediatek,mt76";
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&factory 0x8000>;
	};
};

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

&switch0 {
	ports {
		port@4 {
			status = "okay";
			label = "lan1";
			nvmem-cells = <&macaddr_factory_4000>;
			nvmem-cell-names = "mac-address";
		};
	};
};

&uartlite3 {
	status = "okay";
};

&state_default {
	gpio {
		group = "wdt", "jtag";
		function = "gpio";
	};
};

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

	macaddr_factory_4000: macaddr@4000 {
		reg = <0x4000 0x6>;
	};
};

add rgmii2 to this list: group = "wdt", "jtag", "rgmii2";

Not Work

This full DTS now

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

#include "mt7621.dtsi"

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

/ {
	compatible = "geva,batteryPoE-at3-bt", "mediatek,mt7621-soc";
	model = "GEVA BatteryPoE at3 bt";

	aliases {
		led-boot = &led_run;
		led-failsafe = &led_run;
		led-running = &led_run;
		led-upgrade = &led_run;
	};

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

	keys {
		compatible = "gpio-keys";

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

	leds {
		compatible = "gpio-leds";

		led_run: system-red{
			label = "system-red";
			gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
		};
		system-blue{
			label = "system-blue";
			gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
		};
		wifi-red{
			label = "wifi-red";
			gpios = <&gpio 26 GPIO_ACTIVE_LOW>;
		};
		wifi-blue{
			label = "wifi-blue";
			gpios = <&gpio 27 GPIO_ACTIVE_LOW>;
		};
		eth-red{
			label = "eth-red";
			gpios = <&gpio 24 GPIO_ACTIVE_LOW>;
		};
		eth-green{
			label = "eth-green";
			gpios = <&gpio 23 GPIO_ACTIVE_LOW>;
		};
		eth-blue{
			label = "eth-blue";
			gpios = <&gpio 22 GPIO_ACTIVE_LOW>;
		};
	};
};

&i2c {
	status = "okay";
};

&sdhci {
	status = "okay";
};

&spi0 {
	status = "okay";

	flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <80000000>;
		m25p,fast-read;
		broken-flash-reset;

		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>;
				read-only;
			};

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

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

&pcie {
	status = "okay";
};

&pcie0 {
	wifi@0,0 {
		compatible = "mediatek,mt76";
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&factory 0x8000>;
	};
};

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

&switch0 {
	ports {
		port@4 {
			status = "okay";
			label = "lan1";
			nvmem-cells = <&macaddr_factory_4000>;
			nvmem-cell-names = "mac-address";
		};
	};
};

&uartlite3 {
	status = "okay";
};

&state_default {
	gpio {
		group = "wdt", "jtag", "rgmii2";
		function = "gpio";
	};
};

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

	macaddr_factory_4000: macaddr@4000 {
		reg = <0x4000 0x6>;
	};
};

Do you want to see verbose build ?

Collecting target info: done
make[2]: Entering directory '/home/giorgio/OpenWRT-bt/openwrt/scripts/config'
make[2]: 'conf' is up to date.
make[2]: Leaving directory '/home/giorgio/OpenWRT-bt/openwrt/scripts/config'
time: target/linux/prereq#0.41#0.00#0.41
 make[1] world
 make[2] target/compile
 make[3] -C target/linux compile
 make[2] buildinfo
 make[3] diffconfig buildversion feedsversion
 make[4] scripts/config/conf
 make[2] package/cleanup
 make[2] package/compile
 make[3] -C package/libs/libjson-c host-compile
 make[3] -C package/libs/libubox host-compile
 make[3] -C package/system/opkg host-compile
 make[3] -C package/libs/toolchain compile
 make[3] -C package/libs/libnl-tiny compile
 make[3] -C package/libs/libjson-c compile
 make[3] -C package/utils/lua compile
 make[3] -C package/libs/libubox compile
 make[3] -C package/system/ubus compile
 make[3] -C package/system/uci compile
 make[3] -C package/network/config/netifd compile
 make[3] -C package/firmware/linux-firmware compile
 make[3] -C package/firmware/prism54-firmware compile
 make[3] -C package/kernel/gpio-button-hotplug compile
 make[3] -C package/kernel/linux compile
 make[3] -C package/system/ubox compile
 make[3] -C package/libs/ncurses host-compile
 make[3] -C package/libs/zlib compile
 make[3] -C package/libs/ncurses compile
 make[3] -C package/utils/util-linux compile
 make[3] -C package/utils/mtd-utils compile
 make[3] -C package/system/fstools compile
 make[3] -C package/system/fwtool host-compile
 make[3] -C package/system/fwtool compile
 make[3] -C package/system/usign host-compile
 make[3] -C package/system/ucert host-compile
 make[3] -C package/utils/jsonfilter compile
 make[3] -C package/system/openwrt-keyring compile
 make[3] -C package/system/usign compile
 make[3] -C package/base-files compile
 make[3] -C feeds/luci/modules/luci-base host-compile
 make[3] -C package/utils/lua host-compile
 make[3] -C feeds/luci/contrib/package/csstidy host-compile
 make[3] -C package/libs/jansson compile
 make[3] -C package/libs/libmnl compile
 make[3] -C package/libs/libnftnl compile
 make[3] -C package/network/utils/nftables compile
 make[3] -C package/utils/ucode compile
 make[3] -C package/network/config/firewall4 compile
 make[3] -C feeds/luci/applications/luci-app-firewall compile
 make[3] -C package/libs/mbedtls compile
 make[3] -C package/libs/libiconv compile
 make[3] -C package/libs/libtool compile
 make[3] -C package/libs/wolfssl compile
 make[3] -C package/libs/ustream-ssl compile
 make[3] -C package/libs/uclient compile
 make[3] -C package/system/opkg compile
 make[3] -C feeds/luci/applications/luci-app-opkg compile
 make[3] -C feeds/luci/libs/luci-lib-ip compile
 make[3] -C feeds/luci/libs/luci-lib-jsonc compile
 make[3] -C feeds/luci/libs/luci-lib-nixio compile
 make[3] -C feeds/luci/contrib/package/lucihttp compile
 make[3] -C feeds/luci/libs/luci-lib-base compile
 make[3] -C package/network/utils/iwinfo compile
 make[3] -C package/system/rpcd compile
 make[3] -C feeds/luci/libs/rpcd-mod-luci compile
 make[3] -C feeds/packages/net/cgi-io compile
 make[3] -C feeds/luci/modules/luci-base compile
 make[3] -C feeds/luci/modules/luci-mod-network compile
 make[3] -C feeds/luci/modules/luci-mod-status compile
 make[3] -C feeds/luci/modules/luci-mod-system compile
 make[3] -C feeds/luci/modules/luci-mod-admin-full compile
 make[3] -C feeds/luci/protocols/luci-proto-ppp compile
 make[3] -C feeds/luci/themes/luci-theme-bootstrap compile
 make[3] -C feeds/luci/libs/rpcd-mod-rrdns compile
 make[3] -C package/network/services/uhttpd compile
 make[3] -C feeds/luci/protocols/luci-proto-ipv6 compile
 make[3] -C feeds/luci/collections/luci compile
 make[3] -C feeds/luci/modules/luci-compat compile
 make[3] -C feeds/luci/applications/luci-app-commands compile
 make[3] -C feeds/luci/themes/luci-theme-material compile
 make[3] -C package/system/ca-certificates compile
 make[3] -C feeds/packages/libs/nghttp2 compile
 make[3] -C feeds/packages/net/curl compile
 make[3] -C package/libs/openssl compile
 make[3] -C feeds/packages/net/iperf3 compile
 make[3] -C feeds/packages/libs/libevdev compile
 make[3] -C feeds/packages/libs/libxml2 compile
 make[3] -C feeds/packages/libs/libplist compile
 make[3] -C feeds/packages/libs/libusbmuxd compile
 make[3] -C feeds/packages/libs/libimobiledevice compile
 make[3] -C feeds/packages/libs/libudev-zero compile
 make[3] -C feeds/packages/net/speedtestpp compile
 make[3] -C package/libs/libusb compile
 make[3] -C feeds/packages/utils/usbmuxd compile
 make[3] -C feeds/packages/utils/usbutils compile
 make[3] -C package/firmware/wireless-regdb compile
 make[3] -C package/firmware/b43legacy-firmware compile
 make[3] -C package/network/services/hostapd compile
 make[3] -C package/network/utils/iw compile
 make[3] -C package/kernel/mac80211 compile
 make[3] -C package/kernel/mt76 compile
 make[3] -C package/network/config/swconfig compile
 make[3] -C package/network/ipv6/odhcp6c compile
 make[3] -C package/network/services/dnsmasq compile
 make[3] -C package/network/services/dropbear compile
 make[3] -C package/network/services/odhcpd compile
 make[3] -C package/libs/libpcap compile
 make[3] -C package/network/utils/linux-atm compile
 make[3] -C package/network/utils/resolveip compile
 make[3] -C package/network/services/ppp compile
 make[3] -C package/system/mtd compile
 make[3] -C package/libs/libsepol compile
 make[3] -C package/libs/pcre compile
 make[3] -C package/libs/musl-fts compile
 make[3] -C package/libs/libselinux compile
 make[3] -C package/system/procd compile
 make[3] -C package/system/urandom-seed compile
 make[3] -C package/system/urngd compile
 make[3] -C package/utils/busybox compile
 make[3] -C package/utils/usbmode compile
 make[2] package/install
 make[2] target/install
 make[3] -C target/linux install
 make[6] -C target/linux/ramips/image/lzma-loader compile loader.bin
 make[6] -C target/linux/ramips/image/lzma-loader compile loader.bin
 make[2] package/index
 make[2] json_overview_image_info
 make[2] checksum
giorgio@PC-Ufficio:~/OpenWRT-bt$

Unfortunately I do not currently have access to my notes and don't have a suitable device to play with.
Please check cat /sys/kernel/debug/gpio first, there are some other files to check, but I need my notes to refresh my memory )

root@OpenWrt:/# cat /sys/kernel/debug/gpio
gpiochip2: GPIOs 416-447, parent: platform/1e000600.gpio, 1e000600.gpio-bank2:

gpiochip1: GPIOs 448-479, parent: platform/1e000600.gpio, 1e000600.gpio-bank1:

gpiochip0: GPIOs 480-511, parent: platform/1e000600.gpio, 1e000600.gpio-bank0:
 gpio-493 (                    |reset               ) in  hi IRQ ACTIVE LOW
 gpio-495 (                    |system-blue         ) out hi ACTIVE LOW
 gpio-496 (                    |system-red          ) out lo ACTIVE LOW
 gpio-499 (                    |reset               ) out hi ACTIVE LOW
 gpio-502 (                    |eth-blue            ) out lo ACTIVE LOW
 gpio-503 (                    |eth-green           ) out lo ACTIVE LOW
 gpio-504 (                    |eth-red             ) out lo ACTIVE LOW
 gpio-506 (                    |wifi-red            ) out hi ACTIVE LOW
 gpio-507 (                    |wifi-blue           ) out hi ACTIVE LOW

system led work well
Not o RGMII2

When defined on lucy, it's state change.
Not light

root@OpenWrt:/# cat /sys/kernel/debug/gpio
gpiochip2: GPIOs 416-447, parent: platform/1e000600.gpio, 1e000600.gpio-bank2:

gpiochip1: GPIOs 448-479, parent: platform/1e000600.gpio, 1e000600.gpio-bank1:

gpiochip0: GPIOs 480-511, parent: platform/1e000600.gpio, 1e000600.gpio-bank0:
 gpio-493 (                    |reset               ) in  hi IRQ ACTIVE LOW
 gpio-495 (                    |system-blue         ) out hi ACTIVE LOW
 gpio-496 (                    |system-red          ) out hi ACTIVE LOW
 gpio-499 (                    |reset               ) out hi ACTIVE LOW
 gpio-502 (                    |eth-blue            ) out hi ACTIVE LOW
 gpio-503 (                    |eth-green           ) out hi ACTIVE LOW
 gpio-504 (                    |eth-red             ) out hi ACTIVE LOW
 gpio-506 (                    |wifi-red            ) out hi ACTIVE LOW
 gpio-507 (                    |wifi-blue           ) out hi ACTIVE LOW
root@OpenWrt:/# cat /sys/kernel/debug/gpio
gpiochip2: GPIOs 416-447, parent: platform/1e000600.gpio, 1e000600.gpio-bank2:

gpiochip1: GPIOs 448-479, parent: platform/1e000600.gpio, 1e000600.gpio-bank1:

gpiochip0: GPIOs 480-511, parent: platform/1e000600.gpio, 1e000600.gpio-bank0:
 gpio-493 (                    |reset               ) in  hi IRQ ACTIVE LOW
 gpio-495 (                    |system-blue         ) out lo ACTIVE LOW
 gpio-496 (                    |system-red          ) out lo ACTIVE LOW
 gpio-499 (                    |reset               ) out hi ACTIVE LOW
 gpio-502 (                    |eth-blue            ) out lo ACTIVE LOW
 gpio-503 (                    |eth-green           ) out lo ACTIVE LOW
 gpio-504 (                    |eth-red             ) out lo ACTIVE LOW
 gpio-506 (                    |wifi-red            ) out lo ACTIVE LOW
 gpio-507 (                    |wifi-blue           ) out lo ACTIVE LOW

I would test with the unused gpio25 (505) and a multimeter.

echo "505" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio505/direction
echo "0" > /sys/class/gpio/gpio505/active_low
echo "1" > /sys/class/gpio/gpio505/value
echo "0" > /sys/class/gpio/gpio505/value

Not, Y17 pin is hidden.
But I'm sure the problem is not electrical.
One led are always on, and all other allways off.

This router use same GPIO
There are some difference ?

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

#include "mt7621.dtsi"

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

/ {
	aliases {
		label-mac-device = &gmac0;
		led-boot = &led_power;
		led-failsafe = &led_power;
		led-running = &led_power;
		led-upgrade = &led_power;
	};

	keys {
		compatible = "gpio-keys";

		wps {
			label = "wps";
			gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
			debounce-interval = <60>;
			linux,code = <KEY_WPS_BUTTON>;
		};

		power {
			label = "power";
			gpios = <&gpio 25 GPIO_ACTIVE_LOW>;
			debounce-interval = <60>;
			linux,code = <KEY_POWER>;
		};

		led {
			label = "led";
			gpios = <&gpio 30 GPIO_ACTIVE_LOW>;
			debounce-interval = <60>;
			linux,code = <KEY_LIGHTS_TOGGLE>;
		};

		reset {
			label = "reset";
			gpios = <&gpio 31 GPIO_ACTIVE_LOW>;
			debounce-interval = <60>;
			linux,code = <KEY_RESTART>;
		};
	};

	leds {
		compatible = "gpio-leds";

		led_power: power {
			label = "blue:power";
			gpios = <&gpio 22 GPIO_ACTIVE_LOW>;
		};

		wifi2g {
			label = "blue:wifi2g";
			gpios = <&gpio 23 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy0tpt";
		};

		wifi5g {
			label = "blue:wifi5g";
			gpios = <&gpio 24 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy1tpt";
		};

		wps_red {
			label = "red:wps";
			gpios = <&gpio 26 GPIO_ACTIVE_HIGH>;
		};

		wps_blue {
			label = "blue:wps";
			gpios = <&gpio 27 GPIO_ACTIVE_HIGH>;
		};

		eth_act {
			label = "green:eth_act";
			gpios = <&gpio 28 GPIO_ACTIVE_LOW>;
		};

		eth_link {
			label = "green:eth_link";
			gpios = <&gpio 29 GPIO_ACTIVE_LOW>;
		};
	};
};

&spi0 {
	status = "okay";

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

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

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

			partition@20000 {
				compatible = "tplink,firmware";
				label = "firmware";
				reg = <0x20000 0xde0000>;
			};

			config: partition@e00000 {
				label = "config";
				reg = <0xe00000 0x50000>;
				read-only;
			};

			/* range 0xe50000 to 0xff0000 is empty in vendor
			 * firmware, so we do not use it either
			 */

			radio: partition@ff0000 {
				label = "radio";
				reg = <0xff0000 0x10000>;
				read-only;
			};
		};
	};
};

&state_default {
	gpio {
		groups = "rgmii2", "wdt";
		function = "gpio";
	};
};

&pcie {
	status = "okay";
};

&pcie0 {
	wifi@0,0 {
		compatible = "mediatek,mt76";
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&radio 0x0>;
		nvmem-cells = <&macaddr_config_10008>;
		nvmem-cell-names = "mac-address";
		mac-address-increment = <1>;
		ieee80211-freq-limit = <2400000 2500000>;
	};
};

&pcie1 {
	wifi@0,0 {
		compatible = "mediatek,mt76";
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&radio 0x8000>;
		nvmem-cells = <&macaddr_config_10008>;
		nvmem-cell-names = "mac-address";
		mac-address-increment = <2>;
		ieee80211-freq-limit = <5000000 6000000>;
	};
};

&ethernet {
	pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>;
};

&gmac0 {
	nvmem-cells = <&macaddr_config_10008>;
	nvmem-cell-names = "mac-address";
};

&switch0 {
	ports {
		port@0 {
			status = "okay";
			label = "lan";
		};
	};
};

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

	macaddr_config_10008: macaddr@10008 {
		reg = <0x10008 0x6>;
	};
};

The difference is here:
rgmii2 is mentioned in mt7621.dtsi, so you will probably need to override this:

for override i write:

pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>;

On my dts ?

Yes, I think so. Like in the example you provided:

&ethernet {
	pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>;
};