I wanted to use a GPIO to put the SOM into sleep mode and again use it to wake it up from the sleep.
I used the below node to configure the SOM to use the GPIO1 18 to wake up from sleep.
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpio_userkeys> ;
gpios = <&gpio1 18 GPIO_ACTIVE_LOW>;
linux,code = <KEY_WAKEUP>;
But again to put into sleep I am unable to read the GPIO state from linux userspace as it is used by driver. I am using libgpiod to read the gpio status for which I am getting device or resource busy error
# gpioget gpiochip0 18
gpioget: error reading GPIO values: Device or resource busy
How to disable the device tree node from linux user space so it is possible to read the GPIO staus. And onces the button is pressed enable the device tree node and enter the sleep mode so the driver will take care of waking of the SOM.
Any other way to force read the status of GPIO status