DragonBoard 410c read (S3) key value


I try to read the S3-Key press on board with Debian loaded.

I am using following code and it works for other GPIO (e.g. GPIO12) control
except the “107” which is suppose to be the S3-Key.
I checked the “/sys/class/gpio” on board and do not see the “GPIO107” created
Is this because it is used by other application ?

int Export_GPIO(int gpio)
int fd;
char buf[MAX_BUF];

//Export the specific GPIO 
//this will create a new folder with the gpio name 

sprintf(buf, "%d", gpio); 
fd = open("/sys/class/gpio/export", O_WRONLY); 
if(fd < 0) 
	return -1; 
write(fd, buf, strlen(buf));	
return 0; 



Yes, basically the kernel lets you access to gpios that are not used by the kernel drivers (to not interfere with the system). This GPIO (107) is bound to the Linux gpio-key driver as you can see in the device-tree: https://git.linaro.org/landing-teams/working/qualcomm/kernel.git/tree/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi?h=release/qcomlt-4.14#n483

This gpio is then considered as an input key (like a keyboard).
If you read /dev/event2, it should generate event on vol+ key press:
cat /dev/event2

You can either remove the device-tree node to prevent this gpio to be requested by the kernel, or at runtime unbind it from the driver:

$ cd /sys/devices/platform/gpio_keys/driver
$ echo gpio_keys > unbind

This should allow you to export the gpio to userspace.