Add an option to call an application specific hook when setting the
column to scan. This makes it possible to handle application specific
quirks.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
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>
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>
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>
Add a Kconfig option to extend the row type to 16 bits, allowing the
library to handle a 16 row matrix.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
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>
Move a couple of automatic variable assignment off the declaration
block, leaves only structure aliases there, makes it a bit easier to
read.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Move the scan_cycles_idx increment in input_kbd_matrix_update_state
as it's only used there, use a modulo operation rather than the if to
handle the index wrapping condition.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Replace the wait_period_us clamping functions using a single CLAMP,
reposition the debug log as well.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Split the common keyboard scanning code out of the ITE specific driver
and use the generic code instead.
Note that this changes few timing defaults, the change is not
significant though so I suspect there's no difference in practice.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Drop the input_ prefix fromthe internal functions. Trying to unify the
input drivers to use the same style for function naming, this makes it a
bit more compact and makes it easier to distinguish the common keyboard
structures and functions from the driver ones.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Move the input_kbd_matrix.h header out of drivers/ and into include/,
this allows external drivers to use it and doxygen to pick it up.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add a input_kbd_matrix doxygen group and add this to the other Input
APIs page, add few missing argument documentation entries.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
The API field of input_kbd_matrix_common_config should have been a
pointer from the start, clang-16 caught this with a compiler warning.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Change the row-count and col-count to be optional in the generic
binding, add a second pair of macro to allow the implementation to
specify the numbers from a different property.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Move all the generic code from the Nuvoton NPCX keyboard scanning driver
into input_kbd_matrix.c. While doing that convert few configs into
devicetree properties and tweak few other things to enable the generic
code to support multiple instances.
This is limited to 8 rows for now, and that's fine for all the current
in-tree drivers, the limit could be removed down the road but this
should be fine for now, added few generic build checks to make sure a
driver does not go over the limit, as well and some more implementation
specific checks.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Convert the ITE keyboard scanning driver from kscan to input, add the
corresponding kscan compatibility node to the current board, build test
only.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This chip uses an active low reset, so the correct behavior here is to
define the pin as ACTIVE_LOW, using GPIO_OUTPUT_ACTIVE to assert the
reset and set to 0 to deassert.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This chip uses an active low reset, so the correct behavior here is to
define the pin as ACTIVE_LOW, using GPIO_OUTPUT_ACTIVE to assert the
reset and set to 0 to deassert.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
The current code deasserts the reset, just to re-assert it immediately.
Just initialize with OUTPUT_ACTIVE, delay and then de-assert.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
We currently have three keyboard scanning drivers in the code base
(npcx, it8xxx2 and mchp_xec, last two yet to be converted to input).
These have been largely copy pasted from each other and share a lot of
the same structure and code.
This PR lays a foundation to start decoupling feature from those drivers
into a common code base, and it is heavily inspired by the current
regulator common data/config one.
Feature wise this only moves the thread struct, stack and initialization
to the common code and declares the thread callback as the only API, but
the intent is to move as much code as possible in there an only abstract
device specific callbacks in the api structures.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Fix CONTAINER_OF usage in gpio_keys_interrupt, this should go first to
struct gpio_keys_callback and then to struct gpio_keys_pin_data. It
happens to work right now because cb_data is the first field.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Fix few instances of delayable work handlers using the k_work pointer
directly in a CONTAINER_OF pointing to a k_work_delayable.
This is harmless since the k_work is the first element in
k_work_delayable, but using k_work_delayable_from_work is the right way
of handling it.
Change a couple of explicit CONTAINER_OF doing the same work as the
macro in the process.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Drop the data data structure and use the pin data one directly, also add
a missing const qualifier in the main conf data structure, both save few
bytes of RAM on some platforms.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Change the gpio-keys and zephyr,gpio-keys so that they can both be used
with the input subsystem driver. Make the zephyr,code property optional
so that existing out of tree board can still use this node with their
custom code, but change everything else so that an existin gpio-keys
node can be used with the input driver as long as the codes are defined.
From the application perspective, this means that the application can
still use the GPIOs directly, the input specific driver only gets
enabled if CONFIG_INPUT is enabled and the driver can always be turned
off manually.
This makes gpio-keys behave the same as gpio-leds with CONFIG_LED.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Previously the driver was retrofitted to the kscan api, handling it as a
input device with one row and three columns. With the move to the input
subsystem each input can have its proper input code instead.
Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
Add support for resetting controller at boot, and update FT5336
documentation to indicate that the FT3267 IC is also supported by this
driver.
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Add few missing check on gpio_add_callback and gpio_add_callback_dt
calls, fixes a coverity warning.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
GT911 IC uses the INT pin to select the correct I2C address during
reset. However, some boards may not route this pin (or may only support
receiving inputs on it). This results in the I2C address selected by the
GT911 IC being arbitrary based on the state of the (floating) INT pin.
To resolve this, introduce an `alt-addr` property for this device. When
set, the INT pin will not be pulled low. Instead, the I2C address will be
probed at runtime, starting with the devicetree address and falling back to
`alt-addr`.
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Convert the GT911 driver to the input subsystem, fix the existing boards
to work in the default config.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Split the SDL input driver in a top and bottom
to enable using it with embedded libCs.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Convert the XPT2046 driver to the input subsystem, change the api,
remove the callback and enable logic.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add a GPIO based quadrature decoder driver that reports relative axes
movements using the input subsystem.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add two error code check for gpio_add_callback functions to avoid
triggering a coverity warning.
Drop a redundant initialization in the process.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>