Commit aa0e26bb authored by David Rivshin's avatar David Rivshin Committed by Dmitry Torokhov

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: default avatarDavid Rivshin <drivshin@allworx.com>
Acked-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 4896fb13
...@@ -24,6 +24,8 @@ Optional Properties: ...@@ -24,6 +24,8 @@ Optional Properties:
- debounce-delay-ms: debounce interval in milliseconds - debounce-delay-ms: debounce interval in milliseconds
- col-scan-delay-us: delay, measured in microseconds, that is needed - col-scan-delay-us: delay, measured in microseconds, that is needed
before we can scan keypad after activating column gpio before we can scan keypad after activating column gpio
- drive-inactive-cols: drive inactive columns during scan,
default is to turn inactive columns into inputs.
Example: Example:
matrix-keypad { matrix-keypad {
......
...@@ -42,9 +42,10 @@ struct matrix_keypad { ...@@ -42,9 +42,10 @@ struct matrix_keypad {
}; };
/* /*
* NOTE: normally the GPIO has to be put into HiZ when de-activated to cause * NOTE: If drive_inactive_cols is false, then the GPIO has to be put into
* minmal side effect when scanning other columns, here it is configured to * HiZ when de-activated to cause minmal side effect when scanning other
* be input, and it should work on most platforms. * columns. In that case it is configured here to be input, otherwise it is
* driven with the inactive value.
*/ */
static void __activate_col(const struct matrix_keypad_platform_data *pdata, static void __activate_col(const struct matrix_keypad_platform_data *pdata,
int col, bool on) int col, bool on)
...@@ -55,7 +56,8 @@ static void __activate_col(const struct matrix_keypad_platform_data *pdata, ...@@ -55,7 +56,8 @@ static void __activate_col(const struct matrix_keypad_platform_data *pdata,
gpio_direction_output(pdata->col_gpios[col], level_on); gpio_direction_output(pdata->col_gpios[col], level_on);
} else { } else {
gpio_set_value_cansleep(pdata->col_gpios[col], !level_on); gpio_set_value_cansleep(pdata->col_gpios[col], !level_on);
gpio_direction_input(pdata->col_gpios[col]); if (!pdata->drive_inactive_cols)
gpio_direction_input(pdata->col_gpios[col]);
} }
} }
...@@ -432,6 +434,9 @@ matrix_keypad_parse_dt(struct device *dev) ...@@ -432,6 +434,9 @@ matrix_keypad_parse_dt(struct device *dev)
if (of_get_property(np, "gpio-activelow", NULL)) if (of_get_property(np, "gpio-activelow", NULL))
pdata->active_low = true; pdata->active_low = true;
pdata->drive_inactive_cols =
of_property_read_bool(np, "drive-inactive-cols");
of_property_read_u32(np, "debounce-delay-ms", &pdata->debounce_ms); of_property_read_u32(np, "debounce-delay-ms", &pdata->debounce_ms);
of_property_read_u32(np, "col-scan-delay-us", of_property_read_u32(np, "col-scan-delay-us",
&pdata->col_scan_delay_us); &pdata->col_scan_delay_us);
......
...@@ -49,6 +49,8 @@ struct matrix_keymap_data { ...@@ -49,6 +49,8 @@ struct matrix_keymap_data {
* @wakeup: controls whether the device should be set up as wakeup * @wakeup: controls whether the device should be set up as wakeup
* source * source
* @no_autorepeat: disable key autorepeat * @no_autorepeat: disable key autorepeat
* @drive_inactive_cols: drive inactive columns during scan, rather than
* making them inputs.
* *
* This structure represents platform-specific data that use used by * This structure represents platform-specific data that use used by
* matrix_keypad driver to perform proper initialization. * matrix_keypad driver to perform proper initialization.
...@@ -73,6 +75,7 @@ struct matrix_keypad_platform_data { ...@@ -73,6 +75,7 @@ struct matrix_keypad_platform_data {
bool active_low; bool active_low;
bool wakeup; bool wakeup;
bool no_autorepeat; bool no_autorepeat;
bool drive_inactive_cols;
}; };
int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data, int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment