Disable gpio-keys in custom dts

I see that inside imx8mp-verdin.dtsi there is a node gpio-keys that defines the key button-wakeup connected to SODIMM_252.
In my custom carrier board I use SODIMM_252 as a GPIO with different function, and so I need to disable button-wakeup (or even the whole gpio-keys since my carrier board doesn’t have any button).
I tried adding

&gpio-keys {
    status = "disabled";
};

to my .dts, as I do for other nodes, but I get “syntax error” while compiling the .dts to build Torizon OS.
What is the reason for the syntax error? The - char in the name of the node?
How can I disable the node gpio-keys, or the button-wakeup only?

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


To address the syntax error you’re encountering when attempting to disable the gpio-keys node in your device tree source file (.dts), it’s important to understand that the syntax error is not due to the - character in the node name. Device tree syntax allows for - in node names without issue.

The problem likely stems from how you reference the gpio-keys node in your custom .dts file. When overriding or modifying an existing node from an included .dtsi file, you must ensure that the node label (e.g., gpio-keys) is correctly defined in the original .dtsi file with a label. If the original gpio-keys node in imx8mp-verdin.dtsi does not have a label, you cannot directly reference it using &gpio-keys.

Here’s how you can correctly disable the gpio-keys node or the specific button-wakeup key within it:

  1. If the gpio-keys node has a label in the imx8mp-verdin.dtsi file:

    • Ensure that the label is correctly used in your .dts file. For example, if the node is defined as gpio_keys: gpio-keys { ... } in the .dtsi file, you should use &gpio_keys { status = "disabled"; }; in your .dts file.
  2. If the gpio-keys node does not have a label:

    • You will need to override the node by path rather than by label. This involves using the full path to the gpio-keys node in your .dts file. For example:
      / {
          gpio-keys {
              status = "disabled";
          };
      };
      
    • This method assumes the gpio-keys node is at the root of the device tree. If it’s nested within another node, you’ll need to adjust the path accordingly.
  3. To disable only the button-wakeup key within the gpio-keys node:

    • If you only want to disable the button-wakeup key but keep other keys active, you would typically modify the properties of that specific key within the gpio-keys node. However, this requires the key to be individually identifiable, which might necessitate custom modifications to the device tree structure.

Remember, after making changes to your .dts file, you should

Please, also check if these links can help you solve your problem:

GPIO (Linux) | Toradex Developer Center.

Greetings @vix,

The ToradexAI here is pretty much on the right path. The issue is that in the source device tree the gpio-keys node is defined like so:

gpio-keys {
		compatible = "gpio-keys";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_gpio_keys>;

		button-wakeup {
			debounce-interval = <10>;
			/* Verdin CTRL_WAKE1_MICO# (SODIMM 252) */
			gpios = <&gpio4 0 GPIO_ACTIVE_LOW>;
			label = "Wake-Up";
			linux,code = <KEY_WAKEUP>;
			wakeup-source;
		};
	};

It has no label. Also labels don’t have the - character which is why you get a syntax error as well. Since there is no label you must refer to this node by it’s literal path in the device tree. The example the ToradexAI provided should work. As an alternative I found the following device tree overlay compiles fine as well:

/dts-v1/;
/plugin/;

/ {
        compatible = "toradex,verdin-imx8mp";
};

&{/gpio-keys} {
    status = "disabled";
};

If you’re writing a full device tree and not just an overlay, then the example from the ToradexAI is probably more suitable.

Best Regards,
Jeremias