How to configure user key to generate gpio interrupt?


I want to test GPIO interrupt on TX2. There are four user keys available on board i.e Power, Reset, Recovery and volume. Can I configure any of the key to generate GPIO interrupt? Idea is to generate GPIO interrupt when key is pressed.


I don’t know much about the 4 buttons you have mentioned above, other than their intended purpose. But I did something similar on the TX1, this method should be the same for the TX2.

I followed this guide:
with this software:

Dear david_evans_g ,

Thanks for reply. Customer use case is to generate gpio interrupt using existing keys.

I am trying to achieve following:

Volume down key is configured as gpio-keys in TX2 in dts file arch/arm64/boot/dts/nvidia/hardware/nvidia/platform/t18x/common/kernel-dts/t18x-common-platforms/tegra186-cvb-prod-p2597-b00-p3310-1000-a00-00.dtsi

gpio-keys {
                compatible = "gpio-keys";
                gpio-keys,name = "gpio-keys";

                volume_down {
                        label = "Volume Down";
                        gpios = <&tegra_aon_gpio TEGRA_AON_GPIO(FF, 2) GPIO_ACTIVE_LOW>;
                        linux,code = <KEY_VOLUMEDOWN>;


I want to use above key to generate GPIO interrupt but as it is already mapped I can’t use it. So I commented out volume down key code in dts.
I am able to export GPIO=314 (GPIO number for Volume down is 314 - GPIO3_PFF.02 ) using sysfs file system

root:~# echo 314 > export
root:~# echo "rising" > edge

/* Checking Interrupt status for gpio pin - before Pressing key*/

root:~#cat /proc/interrupts | grep 373
373:          0          0          0          0          0          0  tegra-gpio-aon  58 Edge      gpiolib

/* Interrupt status after pressing volume down key - Pressed 7 times, interrupt generated 7 times

root:gpio314# cat /proc/interrupts | grep 373
373:          7          0          0          0          0          0  tegra-gpio-aon  58 Edge      gpiolib

This works fine. Now I want to achieve same using kernel module. I have written kernel module using following APIS

Allocate specific GPIO using "gpio_request()"
Acquire specific IRQ for GPIO Pin using "gpio_to_irq(GPIO)"
Register IRQ handler using "request_irq()
Set IRQ type Raising/Falling/Level? triggered
Use free_irq() and gpio_free() to release allocated resources.

Module is registered without any error. gpio_to_irq(GPIO) api return IRQ=373, registered interrupt handler with IRQ without any error.


  1. When pressing volume down key interrupt is not generating. Wondering what is the problem. I have read some where we need to assign correct pinmuxing for the GPIO in dtb file to achieve this. I’m not sure how to do this. Any help appreciated.

  2. Can I achieve same without commenting volume down key code in dts file?