Enable TCA8418 I2C Keypad Controller in Torizon

I have a TCA8418 I2C Keypad Controller on my Custom carrier board for Verdin iMX8M-Plus.
And I would like using it from Torizon OS.

Is there any suggestion on how to customize a dts file for this?
Some years ago someone else made a request very similar (almost the same but for a different SoM), but with no answer.

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 your detailed question.

To integrate the TCA8418 I2C Keypad Controller with your Verdin iMX8M Plus module running Torizon OS, you will need to create a device tree overlay to properly configure the driver and hardware mapping. Here is a general step-by-step approach tailored for your scenario:


1. Identify I2C Bus and GPIO for IRQ

  • Determine which I2C bus the TCA8418 is connected to on your carrier board (commonly i2c4 on Verdin iMX8M Plus, but confirm with your board schematics).
  • Find out which GPIO is wired to the TCA8418’s interrupt (INT) pin.

2. Create a Device Tree Overlay

Device tree overlays let you easily add your configuration on top of the standard hardware description. Here is an example overlay snippet for i2c4 (replace values as appropriate):

/dts-v1/;
/plugin/;

/ {
    fragment@0 {
        target = <&i2c4>;
        __overlay__ {
            #address-cells = <1>;
            #size-cells = <0>;

            tca8418: keypad@34 {
                compatible = "ti,tca8418";
                reg = <0x34>;                       // I2C address of TCA8418
                interrupt-parent = <&gpio3>;        // GPIO controller (replace as per your wiring)
                interrupts = <4 IRQ_TYPE_LEVEL_LOW>; // GPIO pin and trigger (replace as needed)
                linux,keymap = <
                    // Fill in your key mapping here
                >;
                gpio-controller;
                #gpio-cells = <2>;
                // Add additional properties as required
            };
        };
    };
};
  • Adjust the reg, interrupt-parent, and interrupts values based on your hardware setup.
  • Complete the linux,keymap property according to your keypad matrix.

3. Compile and Deploy the Overlay

4. Enable Overlay on Torizon OS

  • Reference your overlay in the Torizon OS device tree overlays configuration file or through the Torizon OS build system, as documented in the Device Tree Technical Overview.

5. Test I2C Access


Once the device tree overlay is active, the TCA8418 should be detected and the keypad events should be accessible from Linux input devices.

If you’d like, I can help you with a more specific example if you provide your I2C bus number and which GPIO is connected to the TCA8418 INT pin.

Best regards,
Toradex AI Assistant.

How to Use I2C on Torizon
Customizing and Deploying Device Trees

Greetings @vix,

First of all it looks like the CONFIG_KEYBOARD_TCA8418 kernel config needs to be enabled to provide the driver support for this peripheral: Linux Kernel Driver DataBase: CONFIG_KEYBOARD_TCA8418: TCA8418 Keypad Support

We can enable kernel configs as kernel modules on request.

As for device tree, it looks like this is the in-kernel documentation provided: tca8418_keypad.txt « input « bindings « devicetree « Documentation - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

Does not seem very substantial in my opinion. I did also find this device tree from some 3rd-party that uses this peripheral in their device tree: linux/arch/arm/boot/dts/nxp/imx/imx6qdl-gw560x.dtsi at 7586ac7c340c3672f116052c1d150f134810965b · torvalds/linux · GitHub

Could be useful as a reference.

Best Regards,
Jeremias

What do you mean with this sentence?
Is the relevant kernel module included in Torizon OS or not?
Is this an activity that requires Torizon customization from Toradex side? Or can this be done by the customer alone (using torizoncore-builder)?

Hello @vix,

CONFIG_KEYBOARD_TCA8418 is not set on Torizon OS, and therefore the kernel module not available by default.

To add this kernel module, there are different approaches that can be taken:

  • Ask Toradex to include it by default.
    • This is what Jeremias mentioned could be done. It usually takes us a few days to evaluate if it will have any other impacts on the system and to make it available on the following nightly pre-release.
  • Add it as an external kernel module via TorizonCore Builder.
  • Do your own Yocto build of Torizon to enable this kernel config.

Please let us know if you would like us to enable the CONFIG_KEYBOARD_TCA8418 as a module on Torizon OS by default.

Best Regards,
Bruno

For me this is fine, working as described here, if you can provide me the link where I can download the link to the kernel module source code.

Hello @vix,

As this module is available on the Linux kernel, you can find it in the Linux kernel repository: tca8418_keypad.c « keyboard « input « drivers - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

Best Regards,
Bruno

Thanks;
I’ll have a look.

In the meanwhile, let me know if Toradex plans to include the module by default (for whatever reason).

Hello @vix,

As of now we have no plans to include this module by default.
If you want, we can evaluate including it and most likely include it by default.

Best Regards,
Bruno