Interfacing 4x3 Matrix Keypad with Colibri imx6

I have used the Link here to configure my device tree for supporting a 4x3 Matrix keypad. I am sharing a part of my carrier board level device tree. We are using Row 2, 4, 6, 7 and Cols 2, 4, 5.

           pinctrl_kpp: kppgrp {
			fsl,pins = <
				MX6QDL_PAD_KEY_ROW2__KEY_ROW2    0x1b010
				MX6QDL_PAD_KEY_ROW4__KEY_ROW4    0x1b010
				MX6QDL_PAD_GPIO_2__KEY_ROW6      0x1b010
				MX6QDL_PAD_GPIO_5__KEY_ROW7      0x1b010
				MX6QDL_PAD_KEY_COL2__KEY_COL2    0x110b0
				MX6QDL_PAD_KEY_COL4__KEY_COL4    0x110b0
				MX6QDL_PAD_GPIO_19__KEY_COL5	 0x110b0

&kpp {				/* Keypad */
	compatible = "fsl,imx6qdl-kpp", "fsl,imx21-kpp";
 	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_kpp>;
	clocks = <&clks IMX6QDL_CLK_DUMMY>;
	linux,keymap = <
			MATRIX_KEY(0x0, 0x0, KEY_NUMERIC_1)
			MATRIX_KEY(0x0, 0x1, KEY_NUMERIC_2)       	
			MATRIX_KEY(0x0, 0x2, KEY_NUMERIC_3)      	
			MATRIX_KEY(0x1, 0x0, KEY_KP4)       
			MATRIX_KEY(0x1, 0x1, KEY_KP5)      	
			MATRIX_KEY(0x1, 0x2, KEY_KP6)      
			MATRIX_KEY(0x2, 0x0, KEY_7) 		
			MATRIX_KEY(0x2, 0x1, KEY_8)   		
			MATRIX_KEY(0x2, 0x2, KEY_9)   		
			MATRIX_KEY(0x3, 0x1, KEY_NUMERIC_0)   		
	status = "okay";

I also changed the imx_keypad.c file to have 4x3 (rowsxcolumns) and compiled the uImage.

As of now I am able to see the keypad device in the linux userspace. I am using evtest for testing purpose.

root@colibri-imx6:~# evtest                                                   
No device specified, trying to scan all of /dev/input/event*                    
Available devices:                                                              
/dev/input/event0:      20b8000.kpp                                             
/dev/input/event1:      stmpe-ts                                                
/dev/input/event2:      gpio-keys.29                                            
Select the device event number [0-2]: 0                                         
Input driver version is 1.0.1                                                   
Input device ID: bus 0x19 vendor 0x0 product 0x0 version 0x0                    
Input device name: "20b8000.kpp"                                                
Supported events:                                                               
  Event type 0 (EV_SYN)                                                         
  Event type 1 (EV_KEY)                                                         
    Event code 8 (KEY_7)                                                        
    Event code 9 (KEY_8)                                                        
    Event code 10 (KEY_9)                                                       
    Event code 75 (KEY_KP4)                                                     
    Event code 76 (KEY_KP5)                                                     
    Event code 77 (KEY_KP6)                                                     
    Event code 512 (KEY_NUMERIC_0)                                              
    Event code 513 (KEY_NUMERIC_1)                                              
    Event code 514 (KEY_NUMERIC_2)                                              
    Event code 515 (KEY_NUMERIC_3)                                              
    Event code 522 (KEY_NUMERIC_STAR)                                           
    Event code 523 (KEY_NUMERIC_POUND)                                          
  Event type 4 (EV_MSC)                                                         
    Event code 4 (MSC_SCAN)                                                     
Key repeat handling:                                                            
  Repeat type 20 (EV_REP)                                                       
    Repeat code 0 (REP_DELAY)                                                   
      Value    250                                                              
    Repeat code 1 (REP_PERIOD)                                                  
      Value     33                                                              
Testing ... (interrupt to exit) 

I assume at this point, if I press any key on kepad it should show up in the testing area of evtest. I don’t know what is the problem in this case.

Why in this link the row 2 pad control is different from the first two rows?

Thank you in advance.


You pinmux ROW 2, 4, 6, 7 and COL 2, 4, 5.
However you tell the driver that you are interested in the intersection of ROW,COL
0,0; 0,1; … 2,0; 2.1 … 3,2. While I would expect that this should be 2,2; 2.4; … 6,2; 6,4 … 7,5.

If that is the only reason why it does not work the key MATRIX_KEY(0x2, 0x2, KEY_9)` should actually work as row 2 / column 2 is actually pinmuxed.

I also think that imx_keypad.c must be set so that it scans from ROW0 to ROW7 and COL0 to COL5 even though some of the rows are not muxed and thus left unconnected.

.> Why in this link the row 2 pad control is different from the first two rows?
I don’t know.


Hi Max,

I have the linux keymap as you suggested. I still can’t test any of the key presses on the Matrix Keypad. Is there any other way to test what could be wrong?

I was looking at the .config file in the linux kernel. Do i have to enable any of the drivers in the kernel config file?


Does the kernel output a warning?
e.g. on the module:

dmesg | grep kpp
dmesg | grep keypad
dmesg | grep
dmesg | grep error
dmesg | grep fail
dmesg | grep “already requested”