GPIO Interrupts on WP7702 Module

If anyone else stumbles across this… I figured out my issue. It turns out that Sierra Wireless goes to great lengths to hide Linux’s idea of the “real” GPIO number from you. This is “great” if you’re in user space since the GPIO on the schematic matches the number in Linux’s sysfs interface. Unfortunately, if you’re in the kernel, this doesn’t work at all; you need to request the real GPIO number. My hint was when I hit one of the “wakeup” pins (GPIO36) and the message printed to the console talked about GPIO26, not 36. Much code tracing later, I finally found the mapping!

If you are looking to do something like this, the mapping is located in the kernel source. Not sure if there’s an easier way, but I had it as a byproduct of building Yocto so assuming you did what I did, the mapping is located in:
yocto/build_bin/tmp/work/swi_mdm9x28-poky-linux-gnueabi/linux-quic/3.18.20+gitdd8fe1c7affdfb324e1b5db7701dbb69af46a8ec-r1/build/source/drivers/gpio/gpiolib-sysfs.c

Open that file in your favorite editor and look for the table called “ext_gpio_wp”. The first column is the schematic GPIO number which will also appear in /sys/class/gpio/… (and presumably, Legato). The second column is the “real” Linux GPIO number, which is what you need to use to call, say, gpio_reserve() or gpio_to_irq().

@dfrey - would it be possible to get this documented someplace other than the one C file? (Or is it already and I just missed it?) It doesn’t seem to be in the SIerra manual for the module and it also doesn’t seem to be in the mangOH docs. I realize this is more a core Sierra issue than a mangOH one, but anyone on this platform trying to write a GPIO kernel module will likely be interested.

1 Like