How do I expose and control PM_GPIO2 to sysfs?

How do I expose and control PM_GPIO2 to sysfs?

The generic GPIO could be controlled by exporting to sysfs with number + 902
PM_GPIO2 does not know the number.

To find the number in the dtsi file
pm-gpio-tset = <& pm8916_gpios 2 0>;
If added, the output will be “897”.

Export gpio 897 to sysfs.
But I can not control.

Please let us know how to expose and control PM_GPIO2 to sysfs.

pm8916_gpios looks like this:
&pm8916_gpios {
gpio@c100 { /* GPIO 2 /
qcom,mode = <1>; /
Digital output /
qcom,pull = <4>; /
Pull down /
qcom,vin-sel = <2>; /
VIN 2*/
qcom,src-sel = <1>; /* GPIO /
qcom,master-en = <1>; /
Enable GPIO */
status = “okay”;
};

Hi @qqhrqqhr2,

Are you using official release image [1] for Dragonboard410c? If not then I would suggest you to flash the latest release image which has the support for querying a GPIO based on new Chardev interface (using SYSFS for GPIO access is deprecated for kernels > 4.8). Then you can use any userspace library like libgpiod [2] for toggling the pin from userspace based on it’s line-name [3].

As of now, our preferred MRAA library doesn’t have support for accessing PMIC gpio, so you have to rely on libgpiod.

Thanks,
Mani

[1] http://releases.linaro.org/96boards/dragonboard410c/linaro/debian/
[2] libgpiod/libgpiod.git - C library and tools for interacting with the linux GPIO character device
[3] https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi#L486