Commit Graph

9 Commits

Author SHA1 Message Date
Fabio Baltieri ffbd0397dd input: gpio_kbd_matrix: use edge-to-active interrupt
Change the interrupt setup from both edge to edge to active. Edge to
active is all was needed anyway and it makes this compatible with gpio
controller that only support single edge interrupt.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-12-18 12:25:19 +01:00
Fabio Baltieri f69641f7d2 input: gpio_kbd_matrix: do not enable interrupt if there's no callbacks
Change the gpio_kbd_matrix_set_detect_mode to skip setting gpio
interrupts if we don't have callbacks configured. This is the case if
the driver is running in poll or scan mode.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-12-08 01:07:15 +00:00
Fabio Baltieri c161253287 drivers: input: fix few types
Fix few wrong types in various input drivers.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-12-06 09:25:49 +00:00
Fabio Baltieri 3862c227d4 input: gpio_kbd_matrix: add poll and scan mode support
Add a poll and scan mode for the driver. If any of these are set, the
driver does not use the GPIO interrupts to detect when the matrix has to
switch to polling mode. Instead, it keeps polling it all the time,
either by enabling all the columns and poll the rows for activity, or
just keep scanning all the time.

Poll mode is useful if the specific SoC used does not support GPIO
interrupt on all the row GPIOs at the same time, scan mode if it does
not even support selecting all the columns at the same time.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-12-04 16:40:35 +00:00
Fabio Baltieri ea887af0aa input: gpio_kbd_matrix: drop redundant gpio_kbd_matrix_set_detect_mode
This is called already as soon as the polling thread starts, so the call
in the gpio init function is harmless but redundant, drop it.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-11-22 11:44:48 +00:00
Fabio Baltieri 6cd72493ff input: gpio_kbd_matrix: add direct access support
When the matrix is connected to consecutive pins on the same port, it's
possible to read the whole row or set the whole column in a single
operation. For the column, this is only possible if the matrix is
configured for driving unselected column, as there's no API to configure
multiple pins at the same time at the moment.

This is more efficient than checking the pins individually, and it's
particularly useful if the row or columns are driven from a GPIO port
expander.

Add some code to detect the condition and enable it automatically as
long as the hw configuration supports it.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-11-22 10:34:40 +00:00
Fabio Baltieri 8ec1b5487e input: gpio_kbd_matrix: add column drive mode
Add an option to drive inactive columns to inactive state rather than
high impedance. This is useful if the matrix has isolation diodes for
every key, as it allows the matrix to stabilize faster and the API for
changing the pin value is more efficient than the one to change the pin
configuration.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-11-22 10:34:40 +00:00
Fabio Baltieri adcb2f580c input: gpio_kbd_matrix: define a type for the row data
Add a typedef for the row type rather than using uint8_t directly, this
allow supporting bigger matrix as an option by using a different type.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-11-22 09:52:39 +01:00
Fabio Baltieri 256bc860cf input: add a gpio based keyboard matrix driver
Add a GPIO based keyboard matrix driver using the generic keyboard
matrix code.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-11-15 11:41:25 +01:00