Matrix keypad sends dual events

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Matrix keypad sends dual events

333 Views
NamnNamnsson
Contributor II

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?

Labels (2)
0 Kudos
2 Replies

305 Views
Dhruvit
NXP TechSupport
NXP TechSupport

Hi @NamnNamnsson,

I hope you are doing well.

Please make sure that there are no issues with the matrix keypad hardware design.

One can refer to the below-mentioned links for similar issues.

http://www.gammon.com.au/forum/?id=14175

https://community.toradex.com/t/adding-a-matrix-keypad-to-verdin-imx8mm-running-torizon/16423/4

Thanks & Regards,
Dhruvit Vasavada

0 Kudos

300 Views
NamnNamnsson
Contributor II

Hi Mr. Vasavada,

I hope you are doing well also. The HW design is the same as when we used an iMX6 so we would expect it to work on iMX8 in a similar fashion.

Your Toradex link was not really helpful as we have succesfully bound the driver in the device tree and do get the key presses in user space, as per my explanation above.

What you could do to help is to specifically recommend the pinmux settings for PU/PD in the pinmux registers.

0 Kudos