GPIO mapping on Onion Omega2+ (MT7688)

John Thomson lists at johnthomson.fastmail.com.au
Tue Aug 31 05:22:08 PDT 2021


Hi Mike,

On Mon, 30 Aug 2021, at 21:05, Mike Bernardo wrote:

> root at onion1:~# echo 15 > /sys/class/gpio/export
> ash: write error: Invalid argument
> 
> I guess the number I specify to export would need to be at least 416?

Yes, that's it.
You need to add the Linux gpiochip base to the (SoC) GPIO number you want to use.
You may need to try each bank to get the correct one.
See https://openwrt.org/docs/techref/hardware/port.gpio#software

> All of the GPIOs are unlableled, am I missing some type of ACPI mapping 
> table? Or some kind of mapping in U-boot?

If you want these names populated,
you can add the details to your dts file.
The Linux binding documentation shows how (gpio-line-names):
https://elixir.bootlin.com/linux/latest/source/Documentation/devicetree/bindings/gpio/gpio.txt

https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/ramips/dts/mt7628an_onion_omega2.dtsi
shows that GPIO 38 is a reset button, and 44 is the system LED,
so you could have 38 blank names: "", and the 39th as "reset"

> I can create all of the GPIOs from 416-511 and they show in 
> /sys/kernel/debug/gpio but most are labeled with "sysfs", I guess I was 
> looking for one to be labeled like "GPIO15"?

sysfs here is the driver that has claimed this GPIO number,
because you (or something else) has exported that gpio number in /sys/class/gpio/

> It seems crazy it would have 3 GPIO chips with 32 lines each, so 
> something seems wrong.

Expected: This is the way this system on a chip is built.

> Is it possible this might help?
> 
> http://patchwork.ozlabs.org/project/linux-gpio/patch/20210727152026.31019-3-sergio.paracuellos@gmail.com/

That patch is part of a series which fixes lazy labelling:
An incomplete gpio-line-names array (where the number of passed
named are less than ngpios)


Hope that helps.

-- 
  John Thomson



More information about the openwrt-devel mailing list