how to set pins for "gpio-matrix-keypad" in am335x-boneblack-emmc-overlay.dts

I want to use matrix-keypad with beaglebone black.I completed these steps:
1.Modprobe matrix_keypad
output of zcat /proc/config.gz | grep MATRIX

CONFIG_INPUT_MATRIXKMAP=m
CONFIG_KEYBOARD_MATRIX=m

I am looking into am335x-evm.dts
It has pin settings as:

matrix_keypad@0 {
compatible = “gpio-matrix-keypad”;
debounce-delay-ms = <0x5>;
col-scan-delay-us = <0x2>;
row-gpios = <0x5a 0x19 0x0 0x5a 0x1a 0x0 0x5a 0x1b 0x0>;
col-gpios = <0x5a 0x15 0x0 0x5a 0x16 0x0>;
linux,keymap = <0x8b 0x100009e 0x2000069 0x1006a 0x101001c 0x201006c>;
linux,phandle = <0xdd>;
phandle = <0xdd>;
};

How can I use this information in am335x-boneblack-emmc-overlay.dts
Please guide me:

The easiest way is to search Google for "how to use a matrix keyboard in linux”. Here is one example that was listed.

https://wiki.analog.com/resources/tools-software/linux-drivers/input-keyboard/adp5589

Regards,
John

thanks John,
But I need only GPIO based keypad not i2c based. Please help what should be my next step after modprobing the driver. How can I define rows and columns pins.
Someone had posted this link https://groups.google.com/forum/#!searchin/beagleboard/matrix_keypad|sort:relevance/beagleboard/OED_rjD5dVI/lGQ2kynER0kJ
But when I compile this dts file into .dtbo , dtc compiler shows syntax error.

root@beaglebone:/lib/firmware# dtc -O dtb -o keypad-00A0.dtbo -b 0 -@ keypad-00A0.dts
Error: keypad-00A0.dts:18.31-32 syntax error
FATAL ERROR: Unable to parse input tree

I have successfully compiled .dts file into .dtb file including these additions:
1.matrix_keypad@0 {
compatible = “gpio-matrix-keypad”;
debounce-delay-ms = <0x5>;
col-scan-delay-us = <0x2>;
row-gpios = <0x5a 0x19 0x0 0x5a 0x1a 0x0 0x5a 0x1b 0x0>;
col-gpios = <0x5a 0x15 0x0 0x5a 0x16 0x0>;
linux,keymap = <0x8b 0x100009e 0x2000069 0x1006a 0x101001c 0x201006c>;
linux,phandle = <0xdd>;
phandle = <0xdd>;
};

matrix_keypad_s0 {
pinctrl-single,pins = <0x54 0x7 0x58 0x7 0x64 0x27 0x68 0x27 0x6c 0x27>;
linux,phandle = <0x26aa>;
phandle = <0x26aa>;
};

matrix_keypad@0 {
row-gpios = <0x0 0xc 0x18>;
col-gpios = <0x0 0xc>;
};

matrix_keypad_s0 = “/ocp/l4_wkup@44c00000/scm@210000/pinmux@800/matrix_keypad_s0”;
matrix_keypad = “/matrix_keypad@0”;

But I am unable to understand these lines:

row-gpios = <0x5a 0x19 0x0 0x5a 0x1a 0x0 0x5a 0x1b 0x0>;
col-gpios = <0x5a 0x15 0x0 0x5a 0x16 0x0>;
linux,keymap = <0x8b 0x100009e 0x2000069 0x1006a 0x101001c 0x201006c>;

I want to use pins P8_39 - P8_46 as matrix keypad, How can I map these pins to above hex values.

It doesn’t matter if the keyboard is connected via GPIO or I2C, the driver abstracts the interface so that all keyboards act the same way.

Regards,
John

I facing problem while doing keymap for matrix_keypad for beaglebone. I am refering Linux/Documentation/devicetree/bindings/input/matrix-keymap.txt
how to decode linux,keymap = < 0x00030012 >;

I want to write keymap for 16 keys in 4 x 4 matrix.

On Fri, 10 Feb 2017 22:31:42 -0800 (PST), Gurpartap Singh
<gurpartapsingh007@gmail.com> declaimed the
following:

I facing problem while doing keymap for matrix_keypad for beaglebone. I am
refering Linux/Documentation/devicetree/bindings/input/matrix-keymap.txt
*how to decode linux,keymap = < 0x00030012 >;*
I want to write keymap for 16 keys in 4 x 4 matrix.

  And what part of
http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/input/matrix-keymap.txt
are you having trouble understanding? (other than possibly having to fight
big vs little endian -- I'm not going to search for which the BBB uses)

  As defined in line 9: 8-bit row, 8-bit column, 16-bit keycode to be
returned

  Maybe look at
http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/input/matrix-keymap.txt
which gives a GPIO variant showing full keymap for a 3-row 2-column matrix.
You can see the row and column specification easily, where the first link
only shows two keys out of an unknown sized matrix (it is at least 2x4)

I just responded to the latest in the thread, and then decided to look
backwards... This will be a bit of a rambling post as I jump around in
Google looking for stuff.

On Fri, 10 Feb 2017 00:57:59 -0800 (PST), Gurpartap Singh
<gurpartapsingh007@gmail.com> declaimed the
following:

compatible = "gpio-matrix-keypad";
debounce-delay-ms = <0x5>;
col-scan-delay-us = <0x2>;
row-gpios = <0x5a 0x19 0x0 0x5a 0x1a 0x0 0x5a 0x1b 0x0>;
col-gpios = <0x5a 0x15 0x0 0x5a 0x16 0x0>;

  Where did the 0x5A come from? Based on
http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt
where your x5A field is shown with &gpio2; though the documentation does
state the precise form per gpio depends on the system) -- see
http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/gpio/gpio.txt

  Regretably, I've not found a reference for what the BBB uses...
http://www.jumpnowtek.com/beaglebone/BeagleBone-Black-pinmuxing-and-other-device-tree-notes.html
appears to show a definition for gpio banks, but doesn't show anything
later to referencing them... I'm guessing it would be something like
<&gpio0 xx yy> (the yy based on the LED control in another file using a
third field for some mode control){I've found one PDF from two years ago
using 0x5, not 0x5A for the LED definition... I suspect using a hard-coded
integer is not safe as the node may change as the device tree changes --
integers may be the result of running a decompile on the device tree}

  All the references I've found seem to focus on the pinmux in the device
tree, and not on defining a pseudo-device using GPIO pin assignments.

linux,keymap = <0x8b 0x100009e 0x2000069 0x1006a 0x101001c 0x201006c>;

  Well, that much is the same as the first link -- a 3x2 matrix

  0 1
0 8b 6a
1 9e 1c
2 69 6c

I resolved the issue and use correct values according to gpio banks:

matrix_keypad@0 {
compatible = “gpio-matrix-keypad”;
debounce-delay-ms = <0x50>;
col-scan-delay-us = <0x2>;
keypad,num-rows = <4>;
keypad,num-columns= <4>;
row-gpios = <&gpio2 7 0x17
&gpio2 9 0x17
&gpio2 11 0x17
&gpio2 13 0x17>;
col-gpios = <&gpio2 6 0x17
&gpio2 8 0x17
&gpio2 10 0x17
&gpio2 12 0x17>;
linux,keymap = <

/row0/
0x000000002 /* row 0 col 0 KEY_1 */
0x000100003 /*row 0 col 1 KEY_2 */
0x000200004 /*row 0 col 2 KEY_3 */
0x000300005 /*row 0 col 3 KEY_4 */

/row1/
0x01000005 /* row 1 col 0 KEY_4 /
0x01010006 /
row 1 col 1 KEY_5 /
0x01020007 /
row 1 col 2 KEY_6 /
0x01030008 /
row 1 col 3 KEY_7 */

;

}
Now It is working … There are some issues with certain keys… Row0 keys are working But ROW1 keys are not working… IS there anything wrong with my dts settings.

Thank you a lot for solving this in public.

hi gurpartap_Singh I am facing the same problem interfacing keypad with beaglebone black I tried a lot of procedures but not able to get it .can you please help me with this issue?

Thanks in Advance