Registering a gpio-key on an I2C device

I am trying to add a new gpio-key to the device tree of my TX2. I am able to set it to any of the open ports in platform/c2f0000.gpio and platform/2200000.gpio as shown by cat /sys/kernel/debug/gpio. I want to be able to move this key to an I2C IO expander plugged into the board. Before I plug in the expander I am trying to run the key through one of the open gpio pins of the J21 pinout to make sure I can do this over I2C. When I move the key out of a built in GPIO section and into GPIOs 240-255, i2c/0-0074, tca9539 the key does not show up in /sys/kernel/debug/gpio. Here is my key:

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

		power {
			label = "Fake Power";
			gpios = <&gpio_i2c_0_77 14 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_POWER>;

And here is the gpio controller from i2c@3160000:

gpio_i2c_0_77: gpio@77 {
			compatible = "ti,tca9539";
			reg = <0x77>;
			#gpio-cells = <2>;
			vcc-supply = <&battery_reg>;

Am I missing something needed to have a gpio-key in an I2C gpio device?

hello austin.lane,

you may download pinmux spreadsheet and have configuration.
could you please refer to TX2 Configuring Pinmux GPIO and PAD for the customization.

That definitely helps, but I’m still abit stuck. Lets say I am trying to run my key through j21 pin 22 (which is mapped to gpio 254). It appears that pin 22 is mapped to A22 in this spread sheet (I think). That is already listed as a gpio input. What actually tells the kernel that I am trying to use this pin as a gpio input so that a key can be mapped to it?

hello austin.lane,

you may refer to below kernel sources for an example to control “pwdn-gpios”,


BTW, please download [JETSON TX2 PLATFORM ADAPTATION AND BRING-UP GUIDE] from Jetson Download Center,
you may check the [GPIO Changes] chapter for GPIO number calculations.