Hi,
We have a matrix keypad on iMX8M that behaves unexpectedly.
When pressing the "ENTER" button, an event for two keys are sent on key down but only sometimes. Single event is sent on key up.
% evtest
Event: time 1667916690.681361, type 4 (EV_MSC), code 4 (MSC_SCAN), value 02
Event: time 1667916690.681361, type 1 (EV_KEY), code 14 (KEY_BACKSPACE), value 0
Event: time 1667916690.681361, type 4 (EV_MSC), code 4 (MSC_SCAN), value 03
Event: time 1667916690.681361, type 1 (EV_KEY), code 28 (KEY_ENTER), value 0
Event: time 1667916690.681361, -------------- SYN_REPORT ------------
Event: time 1667916690.885342, type 4 (EV_MSC), code 4 (MSC_SCAN), value 03
Event: time 1667916690.885342, type 1 (EV_KEY), code 28 (KEY_ENTER), value 1
When pressing the "BACK" button, there is always a dual event sent on both key down and key up.
% evtest
Event: time 1667916583.825343, type 4 (EV_MSC), code 4 (MSC_SCAN), value 02
Event: time 1667916583.825343, type 1 (EV_KEY), code 14 (KEY_BACKSPACE), value 1
Event: time 1667916583.825343, type 4 (EV_MSC), code 4 (MSC_SCAN), value 03
Event: time 1667916583.825343, type 1 (EV_KEY), code 28 (KEY_ENTER), value 1
Event: time 1667916583.825343, -------------- SYN_REPORT ------------
Event: time 1667916583.909345, type 4 (EV_MSC), code 4 (MSC_SCAN), value 02
Event: time 1667916583.909345, type 1 (EV_KEY), code 14 (KEY_BACKSPACE), value 0
Event: time 1667916583.909345, type 4 (EV_MSC), code 4 (MSC_SCAN), value 03
Event: time 1667916583.909345, type 1 (EV_KEY), code 28 (KEY_ENTER), value 0
Event: time 1667916583.909345, -------------- SYN_REPORT ------------
The electrical schematics is as follows:
Skärmavbild 2023-10-12 kl. 09.02.23.png
We are using the driver matrix_keypad.c on Linux 6.1.1, this is our device tree:
matrix-keypad {
compatible = "gpio-matrix-keypad";
pinctrl-0 = <&pinctrl_gpio_keys>;
debounce-delay-ms = <5>;
col-scan-delay-us = <2>;
row-gpios = < &gpio1 7 0
&gpio1 8 0
&gpio1 9 0>;
col-gpios = < &gpio1 5 0
&gpio1 6 0>;
linux,keymap = < 0x00000001 /* UNUSED */
0x0100000e /* BACK */
0x0200003d /* F3 */
0x0001006c /* DOWN */
0x0101001c /* ENTER */
0x02010067>; /* UP */
};
pinctrl_gpio_keys: keys0grp {
fsl,pins = <
MX8MM_IOMUXC_GPIO1_IO05_GPIO1_IO5 0x000 /* COL0_BTN */
MX8MM_IOMUXC_GPIO1_IO06_GPIO1_IO6 0x000 /* COL1_BTN */
MX8MM_IOMUXC_GPIO1_IO07_GPIO1_IO7 0x000 /* ROW0_BTN */
MX8MM_IOMUXC_GPIO1_IO08_GPIO1_IO8 0x000 /* ROW1_BTN */
MX8MM_IOMUXC_GPIO1_IO09_GPIO1_IO9 0x000 /* ROW2_BTN */
>;
};
We have tried different pinctrl settings with PU and PD but the symptoms are the same. We have tried with drive-inactive-cols and the symptoms are the same. We have tried several different debounce-delay-ms and col-scan-delay-us combinations and the symptoms are the same.
This is the output from gpioinfo and sys/kernel/debug/gpio respectively:
% gpioinfo
line 5: unnamed "matrix_kbd_col" output active-high [used]
line 6: unnamed "matrix_kbd_col" output active-high [used]
line 7: unnamed "matrix_kbd_row" input active-high [used]
line 8: unnamed "matrix_kbd_row" input active-high [used]
line 9: unnamed "matrix_kbd_row" input active-high [used]
% cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/30200000.gpio, 30200000.gpio:
gpio-5 ( |matrix_kbd_col ) out hi
gpio-6 ( |matrix_kbd_col ) out hi
gpio-7 ( |matrix_kbd_row ) in lo IRQ
gpio-8 ( |matrix_kbd_row ) in lo IRQ
gpio-9 ( |matrix_kbd_row ) in lo IRQ
How would you recommend we set the pin muxing and pin control to have only single events from any key up and key down press on any button?
Do you have any other solution to propose?