Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: matrix_keypad - add option to drive inactive columns

The gpio-matrix-keypad driver normally sets inactive columns as inputs
while scanning. This does not work for all hardware, which may require
the inactive columns to be actively driven in order to overcome any
pull-ups/downs on the columns.

Signed-off-by: David Rivshin <drivshin@allworx.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

David Rivshin and committed by
Dmitry Torokhov
aa0e26bb 4896fb13

+14 -4
+2
Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt
··· 24 24 - debounce-delay-ms: debounce interval in milliseconds 25 25 - col-scan-delay-us: delay, measured in microseconds, that is needed 26 26 before we can scan keypad after activating column gpio 27 + - drive-inactive-cols: drive inactive columns during scan, 28 + default is to turn inactive columns into inputs. 27 29 28 30 Example: 29 31 matrix-keypad {
+9 -4
drivers/input/keyboard/matrix_keypad.c
··· 42 42 }; 43 43 44 44 /* 45 - * NOTE: normally the GPIO has to be put into HiZ when de-activated to cause 46 - * minmal side effect when scanning other columns, here it is configured to 47 - * be input, and it should work on most platforms. 45 + * NOTE: If drive_inactive_cols is false, then the GPIO has to be put into 46 + * HiZ when de-activated to cause minmal side effect when scanning other 47 + * columns. In that case it is configured here to be input, otherwise it is 48 + * driven with the inactive value. 48 49 */ 49 50 static void __activate_col(const struct matrix_keypad_platform_data *pdata, 50 51 int col, bool on) ··· 56 55 gpio_direction_output(pdata->col_gpios[col], level_on); 57 56 } else { 58 57 gpio_set_value_cansleep(pdata->col_gpios[col], !level_on); 59 - gpio_direction_input(pdata->col_gpios[col]); 58 + if (!pdata->drive_inactive_cols) 59 + gpio_direction_input(pdata->col_gpios[col]); 60 60 } 61 61 } 62 62 ··· 433 431 434 432 if (of_get_property(np, "gpio-activelow", NULL)) 435 433 pdata->active_low = true; 434 + 435 + pdata->drive_inactive_cols = 436 + of_property_read_bool(np, "drive-inactive-cols"); 436 437 437 438 of_property_read_u32(np, "debounce-delay-ms", &pdata->debounce_ms); 438 439 of_property_read_u32(np, "col-scan-delay-us",
+3
include/linux/input/matrix_keypad.h
··· 49 49 * @wakeup: controls whether the device should be set up as wakeup 50 50 * source 51 51 * @no_autorepeat: disable key autorepeat 52 + * @drive_inactive_cols: drive inactive columns during scan, rather than 53 + * making them inputs. 52 54 * 53 55 * This structure represents platform-specific data that use used by 54 56 * matrix_keypad driver to perform proper initialization. ··· 75 73 bool active_low; 76 74 bool wakeup; 77 75 bool no_autorepeat; 76 + bool drive_inactive_cols; 78 77 }; 79 78 80 79 int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,