input: convert the ft5336 driver from kscan to input
Convert the ft5336 to the input subsystem, fix all the config in the repository and add the Kscan compatibility driver to the current dts driver instances. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
committed by
Fabio Baltieri
parent
7806d5b28d
commit
57ad325e48
@@ -28,12 +28,15 @@ endif #FLASH
|
||||
config KSCAN
|
||||
default y if LVGL
|
||||
|
||||
if KSCAN
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
||||
config KSCAN_FT5336_INTERRUPT
|
||||
if INPUT
|
||||
|
||||
config INPUT_FT5336_INTERRUPT
|
||||
default y
|
||||
|
||||
endif # KSCAN
|
||||
endif # INPUT
|
||||
|
||||
if NETWORKING
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
aliases {
|
||||
led0 = &green_led;
|
||||
sw0 = &user_button;
|
||||
kscan0 = &touch_controller;
|
||||
kscan0 = &kscan_input;
|
||||
watchdog0 = &wdog0;
|
||||
magn0 = &fxos8700;
|
||||
accel0 = &fxos8700;
|
||||
@@ -33,7 +33,7 @@
|
||||
zephyr,flash = &s26ks512s0;
|
||||
zephyr,code-partition = &slot0_partition;
|
||||
zephyr,display = &lcdif;
|
||||
zephyr,keyboard-scan = &touch_controller;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
|
||||
sdram0: memory@80000000 {
|
||||
@@ -209,10 +209,14 @@ arduino_serial: &lpuart3 {
|
||||
int2-gpios = <&gpio1 11 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
|
||||
touch_controller: ft5336@38 {
|
||||
ft5336@38 {
|
||||
compatible = "focaltech,ft5336";
|
||||
reg = <0x38>;
|
||||
int-gpios = <&gpio1 11 GPIO_ACTIVE_LOW>;
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -31,12 +31,15 @@ endif #FLASH
|
||||
config KSCAN
|
||||
default y if LVGL
|
||||
|
||||
if KSCAN
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
||||
config KSCAN_FT5336_INTERRUPT
|
||||
if INPUT
|
||||
|
||||
config INPUT_FT5336_INTERRUPT
|
||||
default y
|
||||
|
||||
endif # KSCAN
|
||||
endif # INPUT
|
||||
|
||||
if NETWORKING
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
aliases {
|
||||
led0 = &green_led;
|
||||
sw0 = &user_button;
|
||||
kscan0 = &touch_controller;
|
||||
kscan0 = &kscan_input;
|
||||
watchdog0 = &wdog0;
|
||||
sdhc0 = &usdhc1;
|
||||
};
|
||||
@@ -32,7 +32,7 @@
|
||||
zephyr,shell-uart = &lpuart1;
|
||||
zephyr,canbus = &flexcan2;
|
||||
zephyr,display = &lcdif;
|
||||
zephyr,keyboard-scan = &touch_controller;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
|
||||
sdram0: memory@80000000 {
|
||||
@@ -177,10 +177,14 @@ arduino_serial: &lpuart3 {
|
||||
pinctrl-0 = <&pinmux_lpi2c1>;
|
||||
pinctrl-names = "default";
|
||||
|
||||
touch_controller: ft5336@38 {
|
||||
ft5336@38 {
|
||||
compatible = "focaltech,ft5336";
|
||||
reg = <0x38>;
|
||||
int-gpios = <&gpio1 11 GPIO_ACTIVE_LOW>;
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -15,12 +15,15 @@ endchoice
|
||||
config KSCAN
|
||||
default y if LVGL
|
||||
|
||||
if KSCAN
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
||||
config KSCAN_FT5336_INTERRUPT
|
||||
if INPUT
|
||||
|
||||
config INPUT_FT5336_INTERRUPT
|
||||
default y
|
||||
|
||||
endif # KSCAN
|
||||
endif # INPUT
|
||||
|
||||
if NETWORKING
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
led0 = &green_led;
|
||||
pwm-led0 = &green_pwm_led;
|
||||
sw0 = &user_button;
|
||||
kscan0 = &touch_controller;
|
||||
kscan0 = &kscan_input;
|
||||
watchdog0 = &wdog0;
|
||||
sdhc0 = &usdhc1;
|
||||
};
|
||||
@@ -33,7 +33,7 @@
|
||||
zephyr,shell-uart = &lpuart1;
|
||||
zephyr,canbus = &flexcan2;
|
||||
zephyr,display = &lcdif;
|
||||
zephyr,keyboard-scan = &touch_controller;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
|
||||
sdram0: memory@80000000 {
|
||||
@@ -167,10 +167,14 @@ arduino_i2c: &lpi2c1 {};
|
||||
};
|
||||
};
|
||||
|
||||
touch_controller: ft5336@38 {
|
||||
ft5336@38 {
|
||||
compatible = "focaltech,ft5336";
|
||||
reg = <0x38>;
|
||||
int-gpios = <&gpio1 11 GPIO_ACTIVE_LOW>;
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@ config NET_L2_ETHERNET
|
||||
|
||||
endif # NETWORKING
|
||||
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
||||
if DISPLAY
|
||||
|
||||
config KSCAN
|
||||
@@ -27,12 +30,12 @@ config MEMC
|
||||
|
||||
endif # DISPLAY
|
||||
|
||||
if KSCAN
|
||||
if INPUT
|
||||
|
||||
config KSCAN_FT5336_INTERRUPT
|
||||
config INPUT_FT5336_INTERRUPT
|
||||
default y
|
||||
|
||||
endif # KSCAN
|
||||
endif # INPUT
|
||||
|
||||
config DISK_DRIVER_SDMMC
|
||||
default y if DISK_DRIVERS
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
zephyr,dtcm = &dtcm;
|
||||
zephyr,flash-controller = &n25q128a1;
|
||||
zephyr,display = <dc;
|
||||
zephyr,keyboard-scan = &touch_controller;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
|
||||
leds {
|
||||
@@ -51,7 +51,7 @@
|
||||
aliases {
|
||||
led0 = &green_led_1;
|
||||
sw0 = &user_button;
|
||||
kscan0 = &touch_controller;
|
||||
kscan0 = &kscan_input;
|
||||
spi-flash0 = &n25q128a1;
|
||||
};
|
||||
};
|
||||
@@ -95,10 +95,14 @@
|
||||
status = "okay";
|
||||
clock-frequency = <I2C_BITRATE_FAST>;
|
||||
|
||||
touch_controller: ft5336@38 {
|
||||
ft5336@38 {
|
||||
compatible = "focaltech,ft5336";
|
||||
reg = <0x38>;
|
||||
int-gpios = <&gpioi 13 0>;
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -27,12 +27,15 @@ config MEMC
|
||||
|
||||
endif # DISPLAY
|
||||
|
||||
if KSCAN
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
||||
config KSCAN_FT5336_INTERRUPT
|
||||
if INPUT
|
||||
|
||||
config INPUT_FT5336_INTERRUPT
|
||||
default y
|
||||
|
||||
endif # KSCAN
|
||||
endif # INPUT
|
||||
|
||||
config DISK_DRIVER_SDMMC
|
||||
default y if DISK_DRIVERS
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
zephyr,dtcm = &dtcm;
|
||||
zephyr,flash-controller = &n25q128a1;
|
||||
zephyr,display = <dc;
|
||||
zephyr,keyboard-scan = &touch_controller;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
|
||||
leds {
|
||||
@@ -52,7 +52,7 @@
|
||||
aliases {
|
||||
led0 = &green_led_1;
|
||||
sw0 = &user_button;
|
||||
kscan0 = &touch_controller;
|
||||
kscan0 = &kscan_input;
|
||||
spi-flash0 = &n25q128a1;
|
||||
};
|
||||
};
|
||||
@@ -96,10 +96,14 @@
|
||||
status = "okay";
|
||||
clock-frequency = <I2C_BITRATE_FAST>;
|
||||
|
||||
touch_controller: ft5336@38 {
|
||||
ft5336@38 {
|
||||
compatible = "focaltech,ft5336";
|
||||
reg = <0x38>;
|
||||
int-gpios = <&gpioi 13 0>;
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@ config SPI_STM32_INTERRUPT
|
||||
default y
|
||||
depends on SPI
|
||||
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
||||
if NETWORKING
|
||||
|
||||
config NET_L2_ETHERNET
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
zephyr,flash = &flash0;
|
||||
zephyr,dtcm = &dtcm;
|
||||
zephyr,flash-controller = &mx25l51245g;
|
||||
zephyr,keyboard-scan = &touch_controller;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
|
||||
sdram1: sdram@c0000000 {
|
||||
@@ -65,7 +65,7 @@
|
||||
led2 = &green_led_3;
|
||||
led3 = &red_led_4;
|
||||
sw0 = &user_button;
|
||||
kscan0 = &touch_controller;
|
||||
kscan0 = &kscan_input;
|
||||
spi-flash0 = &mx25l51245g;
|
||||
};
|
||||
};
|
||||
@@ -123,10 +123,14 @@ arduino_serial: &usart6 {};
|
||||
status = "okay";
|
||||
clock-frequency = <I2C_BITRATE_FAST>;
|
||||
|
||||
touch_controller: ft6202@2a {
|
||||
ft6202@2a {
|
||||
compatible = "focaltech,ft5336";
|
||||
reg = <0x2a>;
|
||||
int-gpios = <&gpioi 13 0>;
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -11,8 +11,11 @@ config BOARD
|
||||
config KSCAN
|
||||
default y if DISPLAY
|
||||
|
||||
config KSCAN_FT5336_INTERRUPT
|
||||
default y if KSCAN_FT5336
|
||||
config INPUT
|
||||
default y if KSCAN
|
||||
|
||||
config INPUT_FT5336_INTERRUPT
|
||||
default y if INPUT_FT5336
|
||||
|
||||
# MEMC needs to be enabled in order to store
|
||||
# display buffer to external SDRAM connected to FMC
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
zephyr,flash = &flash0;
|
||||
zephyr,display = <dc;
|
||||
zephyr,canbus = &can1;
|
||||
zephyr,keyboard-scan = &touch_controller;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
|
||||
leds {
|
||||
@@ -63,7 +63,7 @@
|
||||
led0 = &blue_led;
|
||||
led1 = &red_led;
|
||||
sw0 = &user_button;
|
||||
kscan0 = &touch_controller;
|
||||
kscan0 = &kscan_input;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -129,10 +129,14 @@
|
||||
clock-frequency = <I2C_BITRATE_FAST>;
|
||||
status = "okay";
|
||||
|
||||
touch_controller: ft5336@38 {
|
||||
ft5336@38 {
|
||||
compatible = "focaltech,ft5336";
|
||||
reg = <0x38>;
|
||||
int-gpios = <&gpioh 2 0>;
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ config GPIO
|
||||
|
||||
if DISPLAY
|
||||
|
||||
if KSCAN
|
||||
if INPUT
|
||||
|
||||
# NOTE: Enable if IRQ line is available (requires to solder jumper)
|
||||
config KSCAN_FT5336_INTERRUPT
|
||||
config INPUT_FT5336_INTERRUPT
|
||||
default n
|
||||
|
||||
endif # KSCAN
|
||||
endif # INPUT
|
||||
|
||||
if LVGL
|
||||
|
||||
@@ -31,6 +31,9 @@ endchoice
|
||||
config KSCAN
|
||||
default y
|
||||
|
||||
config INPUT
|
||||
default y
|
||||
|
||||
config LV_Z_POINTER_KSCAN
|
||||
default y
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/ {
|
||||
chosen {
|
||||
zephyr,display = &ili9340;
|
||||
zephyr,keyboard-scan = &touch_controller;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -49,10 +49,14 @@
|
||||
};
|
||||
|
||||
&arduino_i2c {
|
||||
touch_controller: ft5336@38 {
|
||||
ft5336@38 {
|
||||
compatible = "focaltech,ft5336";
|
||||
reg = <0x38>;
|
||||
/* Uncomment if IRQ line is available (requires to solder jumper) */
|
||||
/* int-gpios = <&arduino_header 13 GPIO_ACTIVE_LOW>; */ /* D7 */
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -5,13 +5,13 @@ if SHIELD_BUYDISPLAY_2_8_TFT_TOUCH_ARDUINO
|
||||
|
||||
if DISPLAY
|
||||
|
||||
if KSCAN
|
||||
if INPUT
|
||||
|
||||
# NOTE: Enable if IRQ line is available (requires to solder jumper)
|
||||
config KSCAN_FT5336_INTERRUPT
|
||||
config INPUT_FT5336_INTERRUPT
|
||||
default n
|
||||
|
||||
endif # KSCAN
|
||||
endif # INPUT
|
||||
|
||||
if LVGL
|
||||
|
||||
@@ -31,6 +31,9 @@ config LV_COLOR_16_SWAP
|
||||
config KSCAN
|
||||
default y
|
||||
|
||||
config INPUT
|
||||
default y
|
||||
|
||||
config LV_Z_POINTER_KSCAN
|
||||
default y
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
/ {
|
||||
chosen {
|
||||
zephyr,display = &ili9340_buydisplay_2_8_tft_touch_arduino;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -36,10 +37,14 @@
|
||||
};
|
||||
|
||||
&arduino_i2c {
|
||||
ft5336_buydisplay_2_8_tft_touch_arduino: ft5336@38 {
|
||||
ft5336@38 {
|
||||
compatible = "focaltech,ft5336";
|
||||
reg = <0x38>;
|
||||
/* Uncomment if IRQ line is available (requires to solder jumper) */
|
||||
/* int-gpios = <&arduino_header 11 GPIO_ACTIVE_LOW>; */ /* D5 */
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -5,13 +5,13 @@ if SHIELD_BUYDISPLAY_3_5_TFT_TOUCH_ARDUINO
|
||||
|
||||
if DISPLAY
|
||||
|
||||
if KSCAN
|
||||
if INPUT
|
||||
|
||||
# NOTE: Enable if IRQ line is available (requires to solder jumper)
|
||||
config KSCAN_FT5336_INTERRUPT
|
||||
config INPUT_FT5336_INTERRUPT
|
||||
default n
|
||||
|
||||
endif # KSCAN
|
||||
endif # INPUT
|
||||
|
||||
if LVGL
|
||||
|
||||
@@ -28,6 +28,9 @@ endchoice
|
||||
config KSCAN
|
||||
default y
|
||||
|
||||
config INPUT
|
||||
default y
|
||||
|
||||
config LV_Z_POINTER_KSCAN
|
||||
default y
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
/ {
|
||||
chosen {
|
||||
zephyr,display = &ili9488_buydisplay_3_5_tft_touch_arduino;
|
||||
zephyr,keyboard-scan = &kscan_input;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -35,10 +36,14 @@
|
||||
};
|
||||
|
||||
&arduino_i2c {
|
||||
ft5336_buydisplay_3_5_tft_touch_arduino: ft5336@38 {
|
||||
ft5336@38 {
|
||||
compatible = "focaltech,ft5336";
|
||||
reg = <0x38>;
|
||||
/* Uncomment if IRQ line is available (requires to solder jumper) */
|
||||
/* int-gpios = <&arduino_header 11 GPIO_ACTIVE_LOW>; */ /* D5 */
|
||||
|
||||
kscan_input: kscan-input {
|
||||
compatible = "zephyr,kscan-input";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -3,4 +3,5 @@
|
||||
zephyr_library()
|
||||
zephyr_library_property(ALLOW_EMPTY TRUE)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_INPUT_FT5336 input_ft5336.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_INPUT_GPIO_KEYS input_gpio_keys.c)
|
||||
|
||||
@@ -5,6 +5,7 @@ if INPUT
|
||||
|
||||
menu "Input drivers"
|
||||
|
||||
source "drivers/input/Kconfig.ft5336"
|
||||
source "drivers/input/Kconfig.gpio_keys"
|
||||
|
||||
endmenu # Input Drivers
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Copyright (c) 2020 Teslabs Engineering S.L.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
menuconfig KSCAN_FT5336
|
||||
menuconfig INPUT_FT5336
|
||||
bool "FT5XX6/FT6XX6 capacitive touch panel driver"
|
||||
default y
|
||||
depends on DT_HAS_FOCALTECH_FT5336_ENABLED
|
||||
@@ -12,18 +12,18 @@ menuconfig KSCAN_FT5336
|
||||
controllers. This driver should support FT5x06, FT5606, FT5x16,
|
||||
FT6x06, Ft6x36, FT5x06i, FT5336, FT3316, FT5436i, FT5336i and FT5x46.
|
||||
|
||||
if KSCAN_FT5336
|
||||
if INPUT_FT5336
|
||||
|
||||
config KSCAN_FT5336_PERIOD
|
||||
config INPUT_FT5336_PERIOD
|
||||
int "Sample period"
|
||||
depends on !KSCAN_FT5336_INTERRUPT
|
||||
depends on !INPUT_FT5336_INTERRUPT
|
||||
default 10
|
||||
help
|
||||
Sample period in milliseconds when in polling mode.
|
||||
|
||||
config KSCAN_FT5336_INTERRUPT
|
||||
config INPUT_FT5336_INTERRUPT
|
||||
bool "Interrupt"
|
||||
help
|
||||
Enable interrupt support (requires GPIO).
|
||||
|
||||
endif # KSCAN_FT5336
|
||||
endif # INPUT_FT5336
|
||||
@@ -8,12 +8,12 @@
|
||||
|
||||
#define DT_DRV_COMPAT focaltech_ft5336
|
||||
|
||||
#include <zephyr/drivers/kscan.h>
|
||||
#include <zephyr/drivers/i2c.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
#include <zephyr/drivers/i2c.h>
|
||||
#include <zephyr/input/input.h>
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(ft5336, CONFIG_KSCAN_LOG_LEVEL);
|
||||
LOG_MODULE_REGISTER(ft5336, CONFIG_INPUT_LOG_LEVEL);
|
||||
|
||||
/* FT5336 used registers */
|
||||
#define REG_TD_STATUS 0x02U
|
||||
@@ -39,7 +39,7 @@ LOG_MODULE_REGISTER(ft5336, CONFIG_KSCAN_LOG_LEVEL);
|
||||
struct ft5336_config {
|
||||
/** I2C bus. */
|
||||
struct i2c_dt_spec bus;
|
||||
#ifdef CONFIG_KSCAN_FT5336_INTERRUPT
|
||||
#ifdef CONFIG_INPUT_FT5336_INTERRUPT
|
||||
/** Interrupt GPIO information. */
|
||||
struct gpio_dt_spec int_gpio;
|
||||
#endif
|
||||
@@ -49,17 +49,17 @@ struct ft5336_config {
|
||||
struct ft5336_data {
|
||||
/** Device pointer. */
|
||||
const struct device *dev;
|
||||
/** KSCAN Callback. */
|
||||
kscan_callback_t callback;
|
||||
/** Work queue (for deferred read). */
|
||||
struct k_work work;
|
||||
#ifdef CONFIG_KSCAN_FT5336_INTERRUPT
|
||||
#ifdef CONFIG_INPUT_FT5336_INTERRUPT
|
||||
/** Interrupt GPIO callback. */
|
||||
struct gpio_callback int_gpio_cb;
|
||||
#else
|
||||
/** Timer (polling mode). */
|
||||
struct k_timer timer;
|
||||
#endif
|
||||
/** Last pressed state. */
|
||||
bool pressed_old;
|
||||
};
|
||||
|
||||
static int ft5336_process(const struct device *dev)
|
||||
@@ -100,7 +100,14 @@ static int ft5336_process(const struct device *dev)
|
||||
|
||||
LOG_DBG("event: %d, row: %d, col: %d", event, row, col);
|
||||
|
||||
data->callback(dev, row, col, pressed);
|
||||
if (pressed) {
|
||||
input_report_abs(dev, INPUT_ABS_X, col, false, K_FOREVER);
|
||||
input_report_abs(dev, INPUT_ABS_Y, row, false, K_FOREVER);
|
||||
input_report_key(dev, INPUT_BTN_TOUCH, 1, true, K_FOREVER);
|
||||
} else if (data->pressed_old && !pressed) {
|
||||
input_report_key(dev, INPUT_BTN_TOUCH, 0, true, K_FOREVER);
|
||||
}
|
||||
data->pressed_old = pressed;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -112,7 +119,7 @@ static void ft5336_work_handler(struct k_work *work)
|
||||
ft5336_process(data->dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KSCAN_FT5336_INTERRUPT
|
||||
#ifdef CONFIG_INPUT_FT5336_INTERRUPT
|
||||
static void ft5336_isr_handler(const struct device *dev,
|
||||
struct gpio_callback *cb, uint32_t pins)
|
||||
{
|
||||
@@ -129,52 +136,6 @@ static void ft5336_timer_handler(struct k_timer *timer)
|
||||
}
|
||||
#endif
|
||||
|
||||
static int ft5336_configure(const struct device *dev,
|
||||
kscan_callback_t callback)
|
||||
{
|
||||
struct ft5336_data *data = dev->data;
|
||||
|
||||
if (!callback) {
|
||||
LOG_ERR("Invalid callback (NULL)");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
data->callback = callback;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ft5336_enable_callback(const struct device *dev)
|
||||
{
|
||||
struct ft5336_data *data = dev->data;
|
||||
|
||||
#ifdef CONFIG_KSCAN_FT5336_INTERRUPT
|
||||
const struct ft5336_config *config = dev->config;
|
||||
|
||||
gpio_add_callback(config->int_gpio.port, &data->int_gpio_cb);
|
||||
#else
|
||||
k_timer_start(&data->timer, K_MSEC(CONFIG_KSCAN_FT5336_PERIOD),
|
||||
K_MSEC(CONFIG_KSCAN_FT5336_PERIOD));
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ft5336_disable_callback(const struct device *dev)
|
||||
{
|
||||
struct ft5336_data *data = dev->data;
|
||||
|
||||
#ifdef CONFIG_KSCAN_FT5336_INTERRUPT
|
||||
const struct ft5336_config *config = dev->config;
|
||||
|
||||
gpio_remove_callback(config->int_gpio.port, &data->int_gpio_cb);
|
||||
#else
|
||||
k_timer_stop(&data->timer);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ft5336_init(const struct device *dev)
|
||||
{
|
||||
const struct ft5336_config *config = dev->config;
|
||||
@@ -189,7 +150,7 @@ static int ft5336_init(const struct device *dev)
|
||||
|
||||
k_work_init(&data->work, ft5336_work_handler);
|
||||
|
||||
#ifdef CONFIG_KSCAN_FT5336_INTERRUPT
|
||||
#ifdef CONFIG_INPUT_FT5336_INTERRUPT
|
||||
int r;
|
||||
|
||||
if (!device_is_ready(config->int_gpio.port)) {
|
||||
@@ -212,29 +173,24 @@ static int ft5336_init(const struct device *dev)
|
||||
|
||||
gpio_init_callback(&data->int_gpio_cb, ft5336_isr_handler,
|
||||
BIT(config->int_gpio.pin));
|
||||
gpio_add_callback(config->int_gpio.port, &data->int_gpio_cb);
|
||||
#else
|
||||
k_timer_init(&data->timer, ft5336_timer_handler, NULL);
|
||||
k_timer_start(&data->timer, K_MSEC(CONFIG_INPUT_FT5336_PERIOD),
|
||||
K_MSEC(CONFIG_INPUT_FT5336_PERIOD));
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct kscan_driver_api ft5336_driver_api = {
|
||||
.config = ft5336_configure,
|
||||
.enable_callback = ft5336_enable_callback,
|
||||
.disable_callback = ft5336_disable_callback,
|
||||
};
|
||||
|
||||
#define FT5336_INIT(index) \
|
||||
static const struct ft5336_config ft5336_config_##index = { \
|
||||
.bus = I2C_DT_SPEC_INST_GET(index), \
|
||||
IF_ENABLED(CONFIG_KSCAN_FT5336_INTERRUPT, \
|
||||
IF_ENABLED(CONFIG_INPUT_FT5336_INTERRUPT, \
|
||||
(.int_gpio = GPIO_DT_SPEC_INST_GET(index, int_gpios),)) \
|
||||
}; \
|
||||
static struct ft5336_data ft5336_data_##index; \
|
||||
DEVICE_DT_INST_DEFINE(index, ft5336_init, NULL, \
|
||||
&ft5336_data_##index, &ft5336_config_##index, \
|
||||
POST_KERNEL, CONFIG_KSCAN_INIT_PRIORITY, \
|
||||
&ft5336_driver_api);
|
||||
POST_KERNEL, CONFIG_INPUT_INIT_PRIORITY, NULL);
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(FT5336_INIT)
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
zephyr_library()
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_KSCAN_FT5336 kscan_ft5336.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_KSCAN_GT911 kscan_gt911.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_KSCAN_ITE_IT8XXX2 kscan_ite_it8xxx2.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_KSCAN_XEC kscan_mchp_xec.c)
|
||||
|
||||
@@ -10,7 +10,6 @@ menuconfig KSCAN
|
||||
|
||||
if KSCAN
|
||||
|
||||
source "drivers/kscan/Kconfig.ft5336"
|
||||
source "drivers/kscan/Kconfig.gt911"
|
||||
source "drivers/kscan/Kconfig.it8xxx2"
|
||||
source "drivers/kscan/Kconfig.xec"
|
||||
|
||||
Reference in New Issue
Block a user