Input: matrix-keypad - support binary column select gpios
Subsystems (3)
PATCH 1/1 Input: matrix-keypad - support binary column select gpios
On hardware with limited gpios one column select gpio can select two different rows when using some additional hardware logic:
high value selects one row, low value selects another row. Add support for such matrix keyboards and document device tree bindings used to describe them.
Since half of the columns is always not selected, interrupts won't be generated for press events on these columns. To generate interrupts for not selected columns we need to periodicaly switch to these columns in order to catch the potential press events. This is done by additional work function.
--- .../bindings/input/gpio-matrix-keypad.txt | 7 ++ drivers/input/keyboard/matrix_keypad.c | 112 +++++++++++++++++---- include/linux/input/matrix_keypad.h | 6 ++ 3 files changed, 106 insertions(+), 19 deletions(-)
Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt +7 -0
@@ -23,6 +23,13 @@ Optional Properties: - debounce-delay-ms: debounce interval in milliseconds - col-scan-delay-us: delay, measured in microseconds, that is needed before we can scan keypad after activating column gpio +- col-gpios-binary: specify that high and low states of a column gpio + select two different rows (boards with limited gpios + could support this by additional hardware logic) +- col-switch-delay-ms: column gpio switch interval for selecting alternative + rows when using 'col-gpios-binary'. This is needed for + periodical selecting of the alternative rows to be able + to generate keypad interrupts for them Example: matrix-keypad {
drivers/input/keyboard/matrix_keypad.c +93 -19
209 lines not on this page · raw message
include/linux/input/matrix_keypad.h +6 -0
@@ -49,6 +49,10 @@ struct matrix_keymap_data {* @wakeup: controls whether the device should be set up as wakeup * source * @no_autorepeat: disable key autorepeat +* @col_gpios_binary: indicate that one column gpio selects two rows, +* i.e. high selects one row, low selects another row +* @col_switch_delay_ms: switching interval for periodical selecting +* of the alternative rows to generate interrupts for them * * This structure represents platform-specific data that use used by * matrix_keypad driver to perform proper initialization.
@@ -63,6 +67,7 @@ struct matrix_keypad_platform_data {unsigned int num_col_gpios;unsigned int col_scan_delay_us; +unsigned int col_switch_delay_ms;/* key debounce interval in milli-second */ unsigned int debounce_ms;
@@ -73,6 +78,7 @@ struct matrix_keypad_platform_data {bool active_low;bool wakeup;bool no_autorepeat; +bool col_gpios_binary; }; int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,
Signature · 1 line
1.7.11.7
Dmitry Torokhov
maintainerHI Anatolij,
Quoted 11 lines · Anatolij Gustschin
On hardware with limited gpios one column select gpio can select two different rows when using some additional hardware logic:
high value selects one row, low value selects another row. Add support for such matrix keyboards and document device tree bindings used to describe them.Since half of the columns is always not selected, interrupts won't be generated for press events on these columns. To generate interrupts for not selected columns we need to periodicaly switch to these columns in order to catch the potential press events. This is done by additional work function.
So this effectively switches the driver from interrupt driven to polled model, right? The device does not really need an interrupt anymore...
Thanks.
Signature · 1 line
Dmitry
Hi Dmitry,
On Tue, 29 Jan 2013 17:16:29 -0800
Dmitry Torokhov <[email protected]> wrote:
...
Quoted 7 lines · Anatolij Gustschin
Quoted 6 lines
On hardware with limited gpios one column select gpio can select two different rows when using some additional hardware logic:
high value selects one row, low value selects another row. Add support for such matrix keyboards and document device tree bindings used to describe them.
Quoted 8 lines
Quoted 5 lines
Since half of the columns is always not selected, interrupts won't be generated for press events on these columns. To generate interrupts for not selected columns we need to periodicaly switch to these columns in order to catch the potential press events. This is done by additional work function.
So this effectively switches the driver from interrupt driven to polled model, right? The device does not really need an interrupt anymore...
Yes, partially. I do not need to scan the state of the rows right after column switching. The interrupts for press events will only be generated if a key in the affected row was actually pressed. So the device is still interrupt driven and the row state read-out happens in the work scheduled from the interrupt handler.
Thanks,
Anatolij
PATCH v2 1/1 Input: matrix-keypad - support binary column select gpios
In reply to Anatolij GustschinOn hardware with limited gpios one column select gpio can select two different rows when using some additional hardware logic:
high value selects one row, low value selects another row. Add support for such matrix keyboards and document device tree bindings used to describe them.
Since half of the columns is always not selected, interrupts won't be generated for press events on these columns. To generate interrupts for not selected columns we need to periodicaly switch to these columns in order to catch the potential press events. This is done by additional work function.
---
v2:
- do not use inline attribute for matrix_keyboard_row_events(), it causes reporting wrong events for some keys if the kernel was built using gcc 4.7.2.
.../bindings/input/gpio-matrix-keypad.txt | 7 ++ drivers/input/keyboard/matrix_keypad.c | 112 ++++++++++++++++---- include/linux/input/matrix_keypad.h | 6 + 3 files changed, 106 insertions(+), 19 deletions(-)
Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt +7 -0
@@ -23,6 +23,13 @@ Optional Properties: - debounce-delay-ms: debounce interval in milliseconds - col-scan-delay-us: delay, measured in microseconds, that is needed before we can scan keypad after activating column gpio +- col-gpios-binary: specify that high and low states of a column gpio + select two different rows (boards with limited gpios + could support this by additional hardware logic) +- col-switch-delay-ms: column gpio switch interval for selecting alternative + rows when using 'col-gpios-binary'. This is needed for + periodical selecting of the alternative rows to be able + to generate keypad interrupts for them Example: matrix-keypad {
drivers/input/keyboard/matrix_keypad.c +93 -19
209 lines not on this page · raw message
include/linux/input/matrix_keypad.h +6 -0
@@ -49,6 +49,10 @@ struct matrix_keymap_data {* @wakeup: controls whether the device should be set up as wakeup * source * @no_autorepeat: disable key autorepeat +* @col_gpios_binary: indicate that one column gpio selects two rows, +* i.e. high selects one row, low selects another row +* @col_switch_delay_ms: switching interval for periodical selecting +* of the alternative rows to generate interrupts for them * * This structure represents platform-specific data that use used by * matrix_keypad driver to perform proper initialization.
@@ -63,6 +67,7 @@ struct matrix_keypad_platform_data {unsigned int num_col_gpios;unsigned int col_scan_delay_us; +unsigned int col_switch_delay_ms;/* key debounce interval in milli-second */ unsigned int debounce_ms;
@@ -73,6 +78,7 @@ struct matrix_keypad_platform_data {bool active_low;bool wakeup;bool no_autorepeat; +bool col_gpios_binary; }; int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,
Signature · 1 line
1.7.5.4
Quoted 13 lines · Anatolij Gustschin
On hardware with limited gpios one column select gpio can select two different rows when using some additional hardware logic:
high value selects one row, low value selects another row. Add support for such matrix keyboards and document device tree bindings used to describe them.Since half of the columns is always not selected, interrupts won't be generated for press events on these columns. To generate interrupts for not selected columns we need to periodicaly switch to these columns in order to catch the potential press events. This is done by additional work function.
Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt Optional Properties: · line 28
Quoted 4 lines
Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt +3
-0+- col-gpios-binary: specify that high and low states of a column gpio + select two different rows (boards with limited gpios + could support this by additional hardware logic)
1 GPIO and 2 columns is essentially a special case with a 1->2 line decoder.
Do the binding definition and code work fine if you have e.g. 3 GPIOs, and a 3->8 decoder in order to support 8 columns?
Quoted 29 lines · Anatolij Gustschin
On hardware with limited gpios one column select gpio can select two different rows when using some additional hardware logic:
high value selects one row, low value selects another row. Add support for such matrix keyboards and document device tree bindings used to describe them.Since half of the columns is always not selected, interrupts won't be generated for press events on these columns. To generate interrupts for not selected columns we need to periodicaly switch to these columns in order to catch the potential press events. This is done by additional work function.
Signed-off-by Anatolij Gustschin <[email protected]>---
v2:
- do not use inline attribute formatrix_keyboard_row_events(), it causes reporting wrong events for some keys if the kernel was built using gcc 4.7.2..../bindings/input/gpio-matrix-keypad.txt | 7 ++ drivers/input/keyboard/matrix_keypad.c | 112 ++++++++++++++++---- include/linux/input/matrix_keypad.h | 6 + 3 files changed, 106 insertions(+), 19 deletions(-)Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt +0
-0
Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt Optional Properties: · line 32
Quoted 10 lines
Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt +7
-0@@ -23,6 +23,13 @@ Optional Properties: - debounce-delay-ms: debounce interval in milliseconds - col-scan-delay-us: delay, measured in microseconds, that is needed before we can scan keypad after activating column gpio +- col-gpios-binary: specify that high and low states of a column gpio + select two different rows (boards with limited gpios + could support this by additional hardware logic) +- col-switch-delay-ms: column gpio switch interval for selecting alternative + rows when using 'col-gpios-binary'. This is needed for + periodical selecting of the alternative rows to be able + to generate keypad interrupts for them
This seems pretty loosely defined. Which rows are affected by this binary property? How common are matrix keypads wired this way, and do a lot of them use the same method? It seems to me that the device needs to be a lot more specific.
g.