Repurpose RM520N LED_WWAN as GPIO in SDK

Hello, I have a RM520N module and I’m using the Quectel SDK to build images for it.

I would like to change the function of the LED_WWAN signal from its current purpose to acting as a GPIO. I would then like to programmatically control the GPIO.

Please could you let me know if that is possible?

Thank you! Ben.

Hi @ben.campbell

Could you write the FW or SDK verison you are using, and the pin number, do you mean the PIN_STATUS for indicating the module’s operation status?

Thanks

Hi @Puck-Q ,
The SDK version is RM520NGLAAR03A01M4G_OCPU_BETA_20230619C_01.200.01.200
The pin I’m referring to is LED_WWAN, at pin 10 on RM520N.
Thank you.

Hi @ben.campbell

You can try to modify the modem_cfg file in the SDK, and change the AD0100 to AD0101 to release the modem’s control, and make rootfs to update the rootfs image.

at+qagpio=1,3,1 // high level
at+qagpio=1,3,0 // low level

Or using sysfs,
echo 898 > /sys/class/gpio/exprot
cd gpio898
echo out > direction // output
echo 1 > value // high level

Thanks

Thank you for you answer @Puck-Q .

Unfortunately, that did not work. The GPIO state does not change when I control it from userspace. It appears to no longer be controlled by the modem, because the LED no longer turns on when the modem is connected, like it did before.

I changed the model_cfg file, you can see it being loaded in kernel boot log below with value AD0101.

[    0.844164] [modem_cfg] open sucessfully
[    0.844529] [modem_cfg] read_buf A00101A10101A20101A30101A40101A50101A60100A70101A80100A90101AA0101AB0100AC0100AD0101AE0100AF0100MQ
[    0.844564] [modem_cfg] smem copy length=99
[    0.844568] [modem_cfg] smem alloc sucessfully

Performing the steps you identified to control the GPIO from userspace:

/sys/class/gpio # ls
export       gpiochip896  gpiochip912  gpiochip916  unexport
/sys/class/gpio # echo 898 > export
/sys/class/gpio # ls
export       gpio898      gpiochip896  gpiochip912  gpiochip916  unexport
/sys/class/gpio # cd gpio898/
/sys/devices/platform/c440000.qcom,spmi/spmi-0/spmi0-01/c440000.qcom,spmi:qcom,pmx65@1:pinctrl@8800/gpiochip2/gpio/gpio898 # echo out > direction
/sys/devices/platform/c440000.qcom,spmi/spmi-0/spmi0-01/c440000.qcom,spmi:qcom,pmx65@1:pinctrl@8800/gpiochip2/gpio/gpio898 # cat direction
out
/sys/devices/platform/c440000.qcom,spmi/spmi-0/spmi0-01/c440000.qcom,spmi:qcom,pmx65@1:pinctrl@8800/gpiochip2/gpio/gpio898 # echo 1 > value
/sys/devices/platform/c440000.qcom,spmi/spmi-0/spmi0-01/c440000.qcom,spmi:qcom,pmx65@1:pinctrl@8800/gpiochip2/gpio/gpio898 # cat value
1
/sys/devices/platform/c440000.qcom,spmi/spmi-0/spmi0-01/c440000.qcom,spmi:qcom,pmx65@1:pinctrl@8800/gpiochip2/gpio/gpio898 # echo 0 > value
/sys/devices/platform/c440000.qcom,spmi/spmi-0/spmi0-01/c440000.qcom,spmi:qcom,pmx65@1:pinctrl@8800/gpiochip2/gpio/gpio898 # cat value
0

I did notice that 898 is mentioned in the kernel boot log, not sure if that is relevant to this issue?

[    0.384062] quec_key c440000.qcom,spmi:qcom,pmx65@1:ql-pwrkey@8A00: key pmx65_gpio3: gpio=898; irq=101; code=116, wakeup=1, dbc=15
[    0.384203] quec_key c440000.qcom,spmi:qcom,pmx65@1:ql-pwrkey@8A00: key pmx65_gpio14: gpio=909; irq=102; code=408, wakeup=1, dbc=15

Thank you.

Hi @ben.campbell

Thank you for the feedback.
Let me check it internally and back to you ASAP.

Thanks

Hi @ben.campbell

Please change the num 898 to 909(here is typo, it’s 908).

Thanks

Thanks @Puck-Q , unfortunately that did not work, now, the system reboots when setting that GPIO to a low/0 value!

/sys/class/gpio # echo 909 > export
/sys/class/gpio # ls
export       gpio909      gpiochip896  gpiochip912  gpiochip916  unexport
/sys/class/gpio # echo out > gpio909/direction
/sys/class/gpio # echo 1 > gpio909/value
/sys/class/gpio # echo 0 > gpio909/value
/sys/class/gpio #
# System reboots here

Hi @ben.campbell

Sorry for the typo, it’s 908, my test here is normal.

WWAN_LED—PIN10—PMU_GPIO_3(sdx55)and PMU_GPIO_13(sdx6x)

The GPIO pins provided by the power control unit, numbered from 896, and the number of GPIOs
is 16.

Thanks

1 Like

Fantastic - it is working now - thank you very much.