Issue with gpio-export on we826-e

Hi All,
I’m trying to compile OpenWRT 21.04 for a ZBTLink WE826-E (MT7620A-based) using the following custom DTS, but as soon as the GPIO-export driver probes, I get errors like “pin 13 is not set to gpio mux” and “0 gpio(s) exported.” As a result, none of exported GPIO appear under /sys/class/gpio, and the entire GPIO subnodes fail with error –22. I suspect I’m misconfiguring the pinctrl override—but I’m not sure.

can anyone please help.

/dts-v1/;

#include "mt7620a.dtsi"

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

/ {
	compatible = "zbtlink,zbt-we826-32m", "zbtlink,zbt-we826", "ralink,mt7620a-soc";
	model = "Zbtlink ZBT-WE826 (32M)";

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

	gpio-leds {
		compatible = "gpio-leds";
		4g {
			label = "4g";
			gpios = <&gpio0 9 GPIO_ACTIVE_LOW>;
		};
		sim1 {
			label = "sim1";
			gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
		};
		sim2 {
			label = "sim2";
			gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
		};
		ra0 {
			label = "ra0";
			gpios = <&gpio3 0 GPIO_ACTIVE_LOW>;
		};
	};

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

		4g {
			gpio-export,name = "4g";
			gpio-export,output = <1>;
			gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
		};
		sim {
			gpio-export,name = "sim";
			gpio-export,output = <0>;
			gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
		};
	};

	gpio-keys-polled {
		compatible = "gpio-keys-polled";
		#address-cells = <1>;
		#size-cells = <0>;
		poll-interval = <20>;
		reset {
			label = "reset";
			gpios = <&gpio0 1 1>;
			linux,code = <KEY_RESTART>;
		};
	};
};

&gpio0 {
	status = "okay";
};

&gpio1 {
	status = "okay";
};

&gpio3 {
	status = "okay";
};

&spi0 {
	status = "okay";

	flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <10000000>;
		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>;
			};

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


&sdhci {
	status = "okay";
};

&ehci {
	status = "okay";
};

&ohci {
	status = "okay";
};

&ethernet {
	mtd-mac-address = <&factory 0x28>;
	mediatek,portmap = "wllll";
};

&wmac {
	ralink,mtd-eeprom = <&factory 0>;
};

&pinctrl {
	state_default: pinctrl0 {
		default {
			ralink,group = "i2c", "uartf", "wled", "spi refclk", "pa";
			ralink,function = "gpio";
		};
	};
};

&pcie {
	status = "okay";
};

Logs on ROuter

openwrt@openwrt:/sys/class/gpio# dmesg | grep gpio
[    0.477594] rt2880_gpio 10000600.gpio: registering 24 gpios
[    0.488656] rt2880_gpio 10000600.gpio: registering 24 irq handlers
[    0.501264] rt2880_gpio 10000638.gpio: registering 16 gpios
[    0.512284] rt2880_gpio 10000638.gpio: registering 16 irq handlers
[    0.524893] rt2880_gpio 10000688.gpio: registering 1 gpios
[    0.535736] rt2880_gpio 10000688.gpio: registering 1 irq handlers
[    0.784076] rt2880-pinmux pinctrl: pin 14 is not set to gpio mux
[    0.818945] rt2880-pinmux pinctrl: pin 13 is not set to gpio mux
[    0.853876] gpio-export gpio_export: 0 gpio(s) exported
[    7.416933] rt2880-pinmux pinctrl: pin 1 is not set to gpio mux
[    7.434698] gpio-keys-polled: probe of gpio-keys-polled failed with error -22
[    7.622261] rt2880-pinmux pinctrl: pin 9 is not set to gpio mux
[    7.640036] leds-gpio: probe of gpio-leds failed with error -22

Check the datasheet of the SoC and find out which pin groups these pins are in. Then add this pin group to your pinctrl array.

1 Like

If I'm not mistaken starting from openwrt version 21 you must use groups and function instead of ralink,group and ralink,function for default gpio config.

You're probably right. Pins 13 and 14 are in the "uartf" group, which is already in the pinctrl array.

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