Level-triggered GPIO interrupt with NCS 2.7 on nRF9160

Hi,

after upgrading to NCS v2.7.0, I have some trouble with an increased sleep power consumption of our device when I use Zephyr's gpio-keys for the button input.

I was using NCS v2.5.2 before. Initially after upgrading, the button would not work any more at all, when I would compile with `CONFIG_PM_DEVICE` and `CONFIG_PM_DEVICE_RUNTIME`. That could be resolved by calling `pm_device_runtime_get()` on the gpio-keys device during initialization. Now the button would work, but the sleep power consumption would increase by around 15 μA.

With NCS v2.5.2, I also had an increase of the power consumption by about 15 μA when I added the button with gpio-keys to my software and enabled CONFIG_INPUT.
According to this (old) thread on devzone, the nRF9160 would require the use of level-, not edge-triggered GPIO interrupts, for low power consumption.

I then applied a small fix to the Zephyr gpio-keys driver, to use level-triggered instead of edge-triggered interrupts (see https://github.com/senseing-gmbh/sdk-zephyr/commit/7cab2bf5b45c6edf39632d5d0886781a05aaf50d). With this fix, the sleep power consumption would be good again.

Now, with NCS v2.7.0, simply replacing `GPIO_INT_EDGE_BOTH` in `zephr/drivers/input/input_gpio_keys.c` by `GPIO_INT_LEVELS_LOGICAL` again did not do the trick, though. I also tried `GPIO_INT_LEVEL_ACTIVE`, but then the sleep power consumption is still increased and the button would not work any more.

Is my approach to use `pm_device_runtime_get()` right, and how can I reduce the power consumption again with gpio-keys?

Related