How can I configure SODIMM_101 so that it reads high when released and low when pressed (with internal pull-up enabled)?

I am using Colibri iMX7 with Torizon and trying to configure SODIMM_101 (GPIO4_IO16) as a push button input but it always reads low.

  1. Verified gpio-keys node exists and uses SODIMM_101:
    cat /proc/bus/input/devices
    N: Name=“gpio-keys”
    H: Handlers=kbd event0

2.Checked current GPIO state:
cat /sys/kernel/debug/gpio | grep 112
gpio-112 (SODIMM_101 | push_button_101) in lo ACTIVE LOW

3.Dumped active device tree:
dtc -I fs -O dts /sys/firmware/devicetree/base > /tmp/current.dts
grep -A10 gpiokeysgrp /tmp/current.dts
Found MX7D_PAD_SD1_CLK assigned in gpiokeysgrp.

4.cat /sys/kernel/debug/pinctrl/30330000.pinctrl/pinconf-pins | grep 101
pin 101 (MX7D_PAD_SD1_CLK): 0x19

5.button.dts
/dts-v1/;
/plugin/;

/* Disable conflicting controllers /
&usdhc1 {
status = “disabled”; /
Frees SD2_RESET_B /
};
&ecspi1 {
status = “disabled”; /
Free ECSPI1_SCLK for push button */
};

&pinctrl_gpio2 {
status = “disabled”;
};
&iomuxc {
/* Pinmux for SODIMM_101 (Input for push button) /
pinctrl_sodimm101_button: sodimm101buttongrp {
fsl,pins = <
0x00000168 0x1b1 /
ECSPI1_SCLK → GPIO4_IO16 (SODIMM_101) as input */
>;
};
};
gpio-keys {
compatible = “gpio-keys”;
pinctrl-names = “default”;
pinctrl-0 = <&pinctrl_sodimm101_button>;
status = “okay”;

    button_101 {
        label = "push_button_101";
        gpios = <&gpio4 16 0>;  /* SODIMM_101 */
        linux,code = <28>;  /* KEY_ENTER */
    };
};

6)Tested with evtest and gpiomon. The gpio-keys device is created on event0, but pressing the button gives no event. My hardware works on Colibri iMX6 with the same footswitch on SODIMM_101, so this seems related to the pin configuration on iMX7.
Do I need to override the existing gpiokeysgrp or update pad control differently?

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello! Thank you for outlining your troubleshooting process and sharing detailed information on your Colibri iMX7 setup.

Based on the evidence, your issue is related to the device tree overlay’s pinmux configuration for SODIMM_101 (ECSPI1_SCLK → GPIO4_IO16), not with the generic GPIO or gpio-keys driver logic. Here’s how you can correct your setup:


Key Problems

  • Pinmux Assignments: You’re currently configuring SODIMM_101 using MX7D_PAD_SD1_CLK, which is not correct for the iMX7. On iMX7, SODIMM_101 is ECSPI1_SCLK, mapping to GPIO4_IO16.
  • Raw Pinmux Values: The use of the raw hex value (0x00000168 0x1b1) is not recommended. Use the device-specific macros for clarity and accuracy.
  • Pad Control: The pad control value should be 0x32 (input with pull-up) for a push button, not 0x1b1.

Correct Device Tree Overlay Example

Please update your device tree overlay to the following structure:

/dts-v1/;
/plugin/;

/ {
    compatible = "toradex,colibri-imx7d", "fsl,imx7d";
};

&iomuxc {
    pinctrl_sodimm101_button: sodimm101buttongrp {
        fsl,pins = <
            MX7D_PAD_ECSPI1_SCLK__GPIO4_IO16 0x32
        >;
    };
};

&gpio4 {
    status = "okay";
};

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

        power {
            label = "push_button_101";
            gpios = <&gpio4 16 GPIO_ACTIVE_HIGH>;
            linux,code = <KEY_ENTER>;
            debounce-interval = <10>;
        };
    };
};

&ecspi1 {
    status = "disabled";
};
  • MX7D_PAD_ECSPI1_SCLK__GPIO4_IO16 0x32 selects the correct pin and pad control for a pull-up input.
  • Ensure the gpio4 controller is explicitly set to "okay".
  • Use GPIO_ACTIVE_HIGH or GPIO_ACTIVE_LOW to specify polarity.
  • Disable ECSPI1 to free up the pin.

Additional Steps

Check for Legacy Pin Grouping:
If there is an existing gpiokeysgrp referencing a different pad (like SD1_CLK), you should override or remove it to avoid conflicting pinmux settings.

Double-check SODIMM/SoC Mapping:
Refer to the official pinout for confirmation:
https://developer.toradex.com/hardware/colibri-som-family/modules/colibri-imx7

Power Management Usage:
If using the button for suspend/resume or power functions, confirm your /etc/udev/rules.d contains relevant logic as described here:
https://developer.toradex.com/linux-bsp/application-development/peripheral-access/gpio-linux/#gpio-power-management-keys


Summary

  • Use MX7D_PAD_ECSPI1_SCLK__GPIO4_IO16 0x32 for SODIMM_101
  • Remove or override any node assigning MX7D_PAD_SD1_CLK
  • Explicitly enable &gpio4
  • Disable &ecspi1
  • Use GPIO_ACTIVE_HIGH in your gpio-keys child node

With these changes, your push button input on SODIMM_101 (GPIO4_IO16) should work correctly with the Colibri iMX7.

Let me know if this resolves your issue or if you need further assistance!

Best regards,
Toradex AI Assistant.


Relevant references:

thank you for your answer but when I add this dts file. my imx7 not loaded due to wrong dts file applied error so what other option do i need to use @ToradexAI .

Thanks for your response.

Please remember to tick the “Solution” checkbox below if my response solves your question. If you have follow-up questions, just continue to tag me using @ToradexAI in your new posts.

Did you like my answer? :+1: :-1:


Thank you for your feedback and for clarifying the error. The issue most likely comes from using the macro MX7D_PAD_ECSPI1_SCLK__GPIO4_IO16 in your device tree overlay. On Toradex BSPs and TorizonCore, overlays typically require using raw numerical values for the pinmux instead of the SoC-specific macro, especially within overlays.

Try the raw hex format for overlays as follows:

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

&iomuxc {
    pinctrl_sodimm101_button: sodimm101buttongrp {
        fsl,pins = <
            0x168 0x32  /* ECSPI1_SCLK -> GPIO4_IO16 (SODIMM_101) with input + pull-up */
        >;
    };
};

&ecspi1 {
    status = "disabled";
};

/ {
    gpio-keys {
        compatible = "gpio-keys";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_sodimm101_button>;
        status = "okay";

        button_101 {
            label = "push_button_101";
            gpios = <&gpio4 16 GPIO_ACTIVE_HIGH>;
            linux,code = <KEY_ENTER>;
            debounce-interval = <10>;
        };
    };
};

Why this should work:

  • The pinmux raw hex value 0x168 corresponds to ECSPI1_SCLK (GPIO4_IO16).
  • The pad control 0x32 configures the pin as input with pull-up, suitable for a push button.
  • Raw values are accepted by the device tree compiler (dtc) in overlays—unlike macro names.

Next Steps:

  1. Save this overlay as, e.g., button_sodimm101.dts.
  2. Compile it:
    dtc -I dts -O dtb -o button_sodimm101.dtbo button_sodimm101.dts
    
  3. Deploy the compiled .dtbo overlay following TorizonCore overlay application guides:
    Device Tree Overlays Technical Overview | Toradex Developer Center

Troubleshooting:

  • Always check dmesg after boot for overlay/DT errors.
  • If you continue to experience a boot error, please paste the specific error message.

Let me know how it goes!

Best regards,
Toradex AI Assistant.


References

I applied this and overlay dosen’t showing anything when i do dmesg.also test some commands so it’s shows like this.
root@colibri-imx7-emmc-06673348:/var/rootdirs/home/torizon# grep -i 101 /sys/kernel/debug/pinctrl/*/pinmux-pins
/sys/kernel/debug/pinctrl/30330000.pinctrl/pinmux-pins:pin 101 (MX7D_PAD_SD1_CLK): (MUX UNCLAIMED) (GPIO UNCLAIMED)
root@colibri-imx7-emmc-06673348:/var/rootdirs/home/torizon# cat /sys/kernel/debug/pinctrl/30330000.pinctrl/pinconf-pins | grep “101”
pin 101 (MX7D_PAD_SD1_CLK): 0x19
what i need to do for set it properly @ToradexAI
this is my overlay.txt file
torizon@colibri-imx7-emmc-06673348:~$ cat /boot/ostree/torizon-036f2def1695712e35ea2933fac8c6b9abe44f5afd21c3b3539849a1fbff8d1d/dtb/overlays.txt
fdt_overlays=colibri-imx7_vga-640x480_overlay.dtbo relay_overlay.dtbo
torizon@colibri-imx7-emmc-06673348:~$

Thanks for your response.

Please remember to tick the “Solution” checkbox below if my response solves your question. If you have follow-up questions, just continue to tag me using @ToradexAI in your new posts.

Did you like my answer? :+1: :-1:


Thank you for your tests and the debug info. Based on your output, the overlay for SODIMM_101 is not being applied. Here’s why and how to fix it:


Why is your overlay not applied?

  • Your overlays.txt does not list your button overlay (button_sodimm101.dtbo).
    It only shows:
    fdt_overlays=colibri-imx7_vga-640x480_overlay.dtbo relay_overlay.dtbo
    
  • The pin you’re trying to use is still showing as MUX UNCLAIMED and GPIO UNCLAIMED, meaning your overlay hasn’t taken effect.

What you need to do

1. Make sure the overlay is in the overlays directory

First, copy your compiled button_sodimm101.dtbo file into the overlays folder.
Example:

sudo cp button_sodimm101.dtbo /boot/ostree/torizon-*/dtb/overlays/

2. Edit overlays.txt

Add your overlay to the list.
Edit the file /boot/ostree/torizon-*/dtb/overlays.txt:

fdt_overlays=colibri-imx7_vga-640x480_overlay.dtbo relay_overlay.dtbo button_sodimm101.dtbo

Save the file.

3. Sync and reboot

After copying and editing, do:

sync
sudo reboot

4. Confirm overlay is loaded

Once rebooted, check:

dmesg | grep overlay

and

grep -i 168 /sys/kernel/debug/pinctrl/*/pinmux-pins

You should see ECSPI1_SCLK (pin 168) is claimed and set as GPIO.


Extra Notes

  • If you don’t see your overlay applied, double-check the .dtbo filename spelling, and check for typos in overlays.txt.
  • Only overlays listed in overlays.txt are applied at boot.
  • Make sure the overlay .dtbo compiles without errors.

Full overlay guide:


Summary:
Your overlay isn’t loaded because it’s missing from overlays.txt. Add it as described above and reboot.

Let me know if this resolves your issue!

Best regards,
Toradex AI Assistant.

see even though overlay applied successfully it shows 0x19 insted of 0x32.
root@colibri-imx7-emmc-06673348:/var/rootdirs/home/torizon# ls /proc/device-tree/chosen/overlays/
button_sodimm101.dtbo colibri-imx7_vga-640x480_overlay.dtbo name
root@colibri-imx7-emmc-06673348:/var/rootdirs/home/torizon# cat /sys/kernel/debug/pinctrl/30330000.pinctrl/pinconf-pins | grep “101”
pin 101 (MX7D_PAD_SD1_CLK): 0x19 @ToradexAI so what should I do next in overlay or anything relatedpins?