How to take ownership of GPIO 6

My board is loosely based on the mangOH green, it is using Legato for wp76xx R12,
Linux kernel 3.18.122.

I want to take control of GPIO6 (Pin 46) but It looks like something else has control of it, via pinctrl.

Both gpio_request(6, “Special Reset”) and gpio_direction_output(6,1) return 0 - indicating success

but “cat /sys/kernel/debug/gpio” shows " gpio6 : out 2 2mA pull down" with no label and the pin output is not affected.

I would have that the call to would have given me an error, though reading the documentation it could be interpreted that I only get an error for repeated calls to gpio_request() for the same gpio.

I’m very new to pinctrl on this , or any other platform. Any Ideas in my best course of action ?

Regards,
Ian

1 Like

debugfs to the rescue:

looking into /sys/kernel/debug/pinctrl/ (instead of /sys/class/gpio) shows that
it was the pinctrl definition itself that had ownership of GPIO6 [via spi1_cs0_active and
spi1_cs0_sleep]

cat /sys/kernel/debug/pinctrl/1000000.pinctrl/pinmux-pins
=>
Pinmux settings per pin
Format: pin (name): mux_owner gpio_owner hog?
.
.
.
pin 6 (GPIO_6): (MUX UNCLAIMED) 1000000.pinctrl:6

Hi Ian

It maybe because GPIO6 is multi-function pin, please refer to PTS and AT cmd guide:

https://source.sierrawireless.com/resources/airprime/software/airprime_wpx5xx_wp76xx_wp77xx_at_command_reference/

Is it possible you can use other GPIO pin?
Or check function configured:

AT+WIOCFG?
AT!CUSTOM?

Hope it helps.
Thx

Hi lotam,

Yes thanks for your suggestion, In a previous question here I discovered that GPIO 6 had not been properly configured via the AT commands, and corrected that.

The root issue is having the correct control of the RESET OUT pin (RESET_OUT_N) = Pin 46 on the chip.

In the Linux kernel pinctrl (pinctrl-mdm9607.c) Pin46 is listed as GPIO46 so I’ve now switched over to using that, I still don’t seem to have the required control.
I have seen posts for other devices where there was an offset in pinctrl so that real_world_pin_x mapps onto pinctrl_pin_y does anyone know if that is the case here ?

yocto/kerneldrivers/pinctrl/qcom/pinctrl-mdm9607.c doesn’t seem op imply such an offset.
Is there anything that I am missing ?

(Can I change the title or should I start another question? As the title is a little misleading)

Best Regards,
Ian

Forgot to say my current config via the AT commands (EXTUIMSWITCHEN = Disabled, GPIO6 = GPIO) :

AT!CUSTOM?
!CUSTOM:
GPSENABLE 0x01
GPSLPM 0x01
IPV6ENABLE 0x01
SIMHOTSWAPDIS 0x02
UIM2ENABLE 0x01
SIMLPM 0x01
USBSERIALENABLE 0x01
SINGLEAPNSWITCH 0x01
TXONINDICATION 0x01
HSICENABLE 0x01
BOOTQUIETDISABLE 0x01
SCRUBEN 0x01
EXTGPSLNAEN 0x01

OK
AT+WIOCFG?
+WIOCFG: 2,16,0,0,1,0,0
+WIOCFG: 4,16,0,0,1,0,0
+WIOCFG: 6,4,0,0,1,0,0
+WIOCFG: 7,16,0,0,1,0,0
+WIOCFG: 8,16,0,0,1,0,0
+WIOCFG: 13,16,0,0,1,0,0
+WIOCFG: 21,16,0,0,1,0,0
+WIOCFG: 22,16,0,0,1,0,0
+WIOCFG: 23,16,0,0,1,0,0
+WIOCFG: 24,16,0,0,1,0,0
+WIOCFG: 25,16,0,0,1,0,0
+WIOCFG: 28,16,0,0,1,0,0
+WIOCFG: 29,16,0,0,1,0,0
+WIOCFG: 30,16,0,0,1,0,0
+WIOCFG: 31,16,0,0,1,0,0
+WIOCFG: 32,16,0,0,1,0,0
+WIOCFG: 33,16,0,0,1,0,0
+WIOCFG: 35,16,0,0,1,0,0
+WIOCFG: 42,16,0,0,1,0,0

Hi Ian,

Thanks for the AT response.
From below, GPIO6 was configured as “4” GPIO (i.e. manage by modem).

As you want to use it from Linux, please set to “16” (Embedded Host GPIO available in Linux) and reset:

AT+WIOCFG=6,16
AT!RESET

Then you could use it from Linux sysfs.

Please update does it work for you. Hope it helps.
Thx

1 Like

Hi Lotam,

Yes! That worked fine, thanks.
It took me a while to reply as I couldn’t confirm until I could confirm that the pin was toggled.
It turns out that under Linux pinctrl hardware GPIO6 (pin 46) is accessible as GPIO 1022 via gpio_direction_output().

Had to try and export all possible GPIOs with echo ${gpio_num} > /sys/class/gpio/export, list which ones were successful, and then toggle the listed GPIOs with

echo -e "\n\n going to toggle /sys/class/gpio/gpio${gpio_id}"
echo out > /sys/class/gpio/gpio${gpio_id}/direction
echo 1 > /sys/class/gpio/gpio${gpio_id}/value
sleep 1

#Now toggle the 'pin'
echo 0 > /sys/class/gpio/gpio${gpio_id}/value
sleep 1
echo 1 > /sys/class/gpio/gpio${gpio_id}/value

And then look throught the dmesg output to see what was being done with $gpio_id, and that’s there GPIO 1022 said “Hello”.

Hopefully there 's a more logical way to work out the pinctrl GPIO mappings (I couldn’t see it at the time though).

Thanks for all your help and suggestions.

Best Regards,
Ian

1 Like