gpio-mt7621 offset fix for 5.10 kernel series

Lukas Zeller luz at plan44.ch
Tue Oct 18 14:10:48 PDT 2022


Hi Peter and Martin,

> On 18 Oct 2022, at 22:02, Peter Naulls <peter at chocky.org> wrote:
> 
> On 10/18/22 15:55, Martin Blumenstingl wrote:
>> [...] my understanding is that the recommended way for
>> accessing GPIOs from userspace (in case that's what you need) should
>> be done through libgpiod.
> 
> Thanks for pointing me at this. Of course, I don't keep tabs on all the
> kernel development.

I did investigate this in June on this list [1] and in the openwrt forum [2]
and tried to ask some questions about the right way to handle this, but
apparently it did not echo for some reason back then.

> I will say the following though:
> 
> It looks a bit odd - the 416 is arbitrary at best, but I'm sure it comes
> from some calculation.

The MT76xx GPIO has 3 banks with 32 GPIOs each, and the driver initializes
them in the order 0,1,2.

The automatic lecagcy GPIO number assignment works by allocating numbers
down from 512 in chunks of 32. So bank 0 gets 512-32 = 480 as base, bank1
gets 448 and bank2 gets 416.

But GPIOs *within* the chunks are counted upwards, so you'll get a very
unintuitive zigzag mapping when comparing with the pin names in the
datasheet.

> All/most of the other ramips use the ramips GPIO driver instead, which
> does specify the base, although that's in the the DTS; there's no
> facility for that in the mt7621 setup at present.

Just not any more - the mt7621 had this too. I currently patch it back into
22.03's gpio-mt7621.c for my builds and set base in the DTS, see [3]

I can follow the rationale to get rid of legacy GPIOs, but in the context
of experimenting platforms, where GPIOs are a thing to work with in
user space, there's just no real replacement yet (see details in [1],[2]).

So IMHO, at least the "base" of property should stay for a while.

Best Regards
Lukas

[1] http://lists.openwrt.org/pipermail/openwrt-devel/2022-June/038912.html
[2] https://forum.openwrt.org/t/state-of-userland-access-to-gpio-based-hardware/130505
[3] https://plan44.ch/downloads/v22.03-metapatch-readd-of-base-to-gpio-mt7621.patch


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.openwrt.org/pipermail/openwrt-devel/attachments/20221018/23749598/attachment.sig>


More information about the openwrt-devel mailing list