I2C keyboard ADP5588 and Linux BSP 5.x

My project is migrating from “colibri T20” + i2c keyboard ADP5588 + Linux BSP 2.0.x
to “colibri IMX8X” + i2c keyboard ADP5588 + Linux BSP 5.3.x

In old Linux BSP 2.0.x I used the description from Analog site
https://wiki.analog.com/resources/tools-software/linux-drivers/input-keyboard/adp5588
in kernel “board-colibri_t20.c” add keybord as described by Analog and everything works ok

How to add I2C keyboard to new Linux BSP 5.3.x?
Can my keyboard be connected using a “device tree”? In “Linux BSP 2.0.x” I have “custom keymap” can it be done?

Hi @MariusM

How to add I2C keyboard to new Linux BSP 5.3.x?

You need to enable this config

CONFIG_KEYBOARD_ADP5588 is not set
CONFIG_GPIO_ADP5588 is not set

and build a custom kernel.

Further you will need to define the correct node in the devicetree as explained here.

Best regards,
Jaski

BSP 5.3.x is very different to BSP 2.x :frowning:
CONFIG_KEYBOARD_ADP5588 need extra steps

Declaring I2C devices

Unlike PCI or USB devices, I2C devices are not enumerated at the hardware level. Instead, the software must know which devices are connected on each I2C bus segment, and what address these devices are using. For this reason, the kernel code must instantiate I2C devices explicitly. There are different ways to achieve this, depending on the context and requirements. However the most common method is to declare the I2C devices by bus number.

This method is appropriate when the I2C bus is a system bus, as in many embedded systems, wherein each I2C bus has a number which is known in advance. It is thus possible to pre-declare the I2C devices that inhabit this bus. This is done with an array of struct i2c_board_info, which is registered by calling i2c_register_board_info().

So, to enable such a driver one need only edit the board support file by adding an appropriate entry to i2c_board_info.

Thank you for the link, I am following this path

/* Add TCA8418 Support */
tca8418@34 {
compatible = "ti,tca8418";
reg = <0x34>;
interrupt-parent = <?????>;
interrupts = <?????>;
keypad,num-rows = <8>;
keypad,num-columns = <10>;
linux,keymap = <
    0x0306003b
    0x0203003c
    0x02040057
    0x01080058
    0x06000111>;
};

I don’t know what to enter in the fields: interrupt-parent , interrupts
In old T20 + IRIS it was .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PD5) [IRIS → X16.13 (SODIMM_98)]

Now I have IMX8X + IRIS , when I enter wrong values, I have

root@colibri-imx8x:~# dmesg |grep tca
[ 2.460281] tca8418_keypad 17-0034: Unable to claim irq 0; error -22
[ 2.466689] tca8418_keypad: probe of 17-0034 failed with error -22

I see a light in the tunnel

Hi @MariusM

I see a light in the tunnel

You are on the right way.

In old T20 + IRIS it was .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PD5) [IRIS → X16.13 (SODIMM_98)]

IMX8QXP_QSPI0B_DATA3_LSIO_GPIO3_IO21 0x20 /* SODIMM 98 */

The SODIMM pin 98 is the 21pin from the 3rd Gpio Bank. Thus the interrupt Parent is 3 and Interrupts should be 3 21.

Best regards,
Jaski

Thank you very much !

I will write if it works, if it doesn’t work, it will also write :wink:
There will be feedback tomorrow

You are welcome.

Best regards,
Jaski

Correct version

/* Colibri I2C */
&i2c1 {
        status = "okay";

        /* M41T0M6 real time clock on carrier board */
        rtc_i2c: rtc@68 {
                compatible = "st,m41t0";
                reg = <0x68>;
        };

    /* Add TCA8418 Support */
    /*    ADP5588  works too */    
    /* https://community.toradex.com/t/i2c-keyboard-adp5588-and-linux-bsp-5-x/15228  */
    tca8418@34 {
    compatible = "ti,tca8418";
    reg = <0x34>;
    interrupt-parent = <&lsio_gpio3>;
    interrupts = <21 3>;
    keypad,num-rows = <8>;
    keypad,num-columns = <10>;
    linux,keymap = <
        MATRIX_KEY(0x00, 0x00, KEY_1) /*  row, column, key   */
        MATRIX_KEY(0x00, 0x01, KEY_2) /*  */
        MATRIX_KEY(0x01, 0x00, KEY_3) /*  */
        MATRIX_KEY(0x01, 0x01, KEY_4) /*  */
     >;
    };
};
root@colibri-imx8x:~# dmesg |grep i2c
[    1.825643] i2c /dev entries driver
[    2.435949] i2c i2c-16: LPI2C adapter registered
[    2.463752] input: tca8418 as /devices/platform/bus@5a000000/5a810000.i2c/i2c-17/17-0034/input/input1
[    2.473221] i2c i2c-17: LPI2C adapter registered

Hi @MariusM !

Great that you could make it work!

If your last comment is the solution, please, mark it as solution.

Best regards!

Hi All,
I am using adp5588 keypad with Linux kernel version 5.4 on i.MX8. I am able to use TCA8418 driver for it.
But I want to use ADP5588 driver “drivers/input/keyboard/adp5588-keys.c”
I have updated the device tree as follows:

keypad: adp5588@34 {
                compatible = "adi,adp5588";
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_gpio1>, <&pinctrl_gpio2>;
                reg = <0x34>;
                interrupt-parent = <&lsio_gpio0>;
                interrupts = <9 0>;
                reset-gpios = <&lsio_gpio0 8 GPIO_ACTIVE_LOW>;
                keypad,num-rows = <4>;
                keypad,num-columns = <6>;

                linux,keymap = <
                       MATRIX_KEY(0x00, 0x00, KEY_ESC)
                       MATRIX_KEY(0x00, 0x01, KEY_1)
                       MATRIX_KEY(0x00, 0x02, KEY_2)
                       MATRIX_KEY(0x00, 0x03, KEY_3)
                       MATRIX_KEY(0x00, 0x04, KEY_4)
                       MATRIX_KEY(0x00, 0x05, KEY_5)
                       MATRIX_KEY(0x01, 0x00, KEY_6)
                       MATRIX_KEY(0x01, 0x01, KEY_7)
                       MATRIX_KEY(0x01, 0x02, KEY_8)
                       MATRIX_KEY(0x01, 0x03, KEY_9)
                       MATRIX_KEY(0x01, 0x04, KEY_0)
                       MATRIX_KEY(0x01, 0x05, KEY_MINUS)
                       MATRIX_KEY(0x02, 0x00, KEY_EQUAL)
                       MATRIX_KEY(0x02, 0x01, KEY_BACKSPACE)
                       MATRIX_KEY(0x02, 0x02, KEY_TAB)
                       MATRIX_KEY(0x02, 0x03, KEY_Q)
                       MATRIX_KEY(0x02, 0x04, KEY_W)
                       MATRIX_KEY(0x02, 0x05, KEY_E)
                       MATRIX_KEY(0x03, 0x00, KEY_R)
                       MATRIX_KEY(0x03, 0x01, KEY_T)
                       MATRIX_KEY(0x03, 0x02, KEY_Y)
                       MATRIX_KEY(0x03, 0x03, KEY_U)
                       MATRIX_KEY(0x03, 0x04, KEY_I)
                                       >;

         };

I am able to see the adp5588 module using lsmod after inserting it.

root@apalis-imx8-06958964:~# lsmod | grep adp5
adp5588_keys           24576  0

But I can not see any logs I have added in the driver in kernel logs.
Does anyone have idea if we can use this ADP5588 driver with latest Linux kernel?
If yes could you please share an example?

Regards,
Prathamesh Kulkarni

In my opinion adp5588 don’t support device-tree
I used tca8418 and everything works fine

Thanks @MariusM for your input. I am able to use TCA8418 driver.

  1. We need to generate system wide key events directly from the driver code not from any other application just like USB keyboard. i.e. all the system processes should receive Key events from driver itself. We do not want the application to poll on dev/input/eventx.
    Do we need to make any changes in the driver for it?

  2. Is there any way if we can use ADP5588 driver with device tree?

Regards,
Prathamesh Kulkarni

ad1) I have system with T20 (tegra2) with adp5588 chip and driver adp5588
I have second system IMX8 with adp5588 chip and driver tca8418
everything works the same, it is normal keyboard , I don’t need pool dev/input/eventx

ad2) Yes You Can ! Please compare look at source TCA8418 :slight_smile:

We tried ADP5588 driver with device tree on i.MX8.

        /* Keyapd driver [tca8418] compatible with [adp5588] */
        keypad: adp5588@34 {
                compatible = "adp5587-keys";
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_gpio1>, <&pinctrl_gpio2>;
                reg = <0x34>;
                interrupt-parent = <&lsio_gpio0>;
                interrupts = <9 0>;
                reset-gpios = <&lsio_gpio0 8 GPIO_ACTIVE_LOW>;
                rows = <4>;
                cols = <6>;
                keymapsize = <24>;
                repeat = <0>;

We are getting below error after loading the module.

[ 4699.561083] adp5588_keys 4-0034: no platform data?
[ 4699.565927] adp5588_keys: probe of 4-0034 failed with error -22

After adding TCA8418 driver in i.MX8 device tree. We are not getting error and we are getting key events after polling /dev/input/eventx.
We are not able to get key events to the system automatically.

Regards,
Prathamesh Kulkarni

Hi @prathamesh.kulkarni!

Were you able to solve your issue?

If you still are struggling with this, please create a new thread :slight_smile:

Best regards,

Hi @henrique.tx ,

We did not find any solution for ADP5588 driver, but the TCA8418 driver issue was resolved. So we continued to use the TCA8418 driver.

Thanks,
Prathamesh Kulkarni

Hi @prathamesh.kulkarni !

Thanks for the information.

Have a nice day.