Skip to content

drivers: input: add support for Renesas CTSU #92433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions boards/renesas/ek_ra2a1/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2025 Renesas Electronics Corporation
# SPDX-License-Identifier: Apache-2.0

if !INPUT_RENESAS_RA_QE_TOUCH_CFG

config INPUT_RENESAS_RA_CTSU_NUM_SELF_ELEMENTS
default 1

endif # INPUT_RENESAS_RA_QE_TOUCH_CFG
8 changes: 8 additions & 0 deletions boards/renesas/ek_ra2a1/ek_ra2a1-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,12 @@
renesas,analog-enable;
};
};

ctsu_default: ctsu_default {
group1 {
/* TS01 TSCAP */
psels = <RA_PSEL(RA_PSEL_CTSU, 0, 1)>,
<RA_PSEL(RA_PSEL_CTSU, 4, 9)>;
};
};
};
41 changes: 41 additions & 0 deletions boards/renesas/ek_ra2a1/ek_ra2a1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
status = "okay";
};

&ioport4 {
status = "okay";
};

&port_irq6 {
interrupts = <29 3>;
status = "okay";
Expand Down Expand Up @@ -120,3 +124,40 @@
&wdt {
status = "okay";
};

&ctsu {
pinctrl-0 = <&ctsu_default>;
pinctrl-names = "default";
interrupts = <10 3>, <11 3>, <12 3>;
interrupt-names = "ctsuwr", "ctsurd", "ctsufn";
clock-div = <1>;
pwr-supply-sel = "vcc";
atune1 = "normal";
measure-mode = "self-multi-scan";
tscap-gpios = <&ioport4 9 0>;
status = "okay";

group1 {
ctsuchac = <0x00>, <0x80>, <0x00>, <0x00>, <0x00>;
ctsuchtrc = <0x00>, <0x00>, <0x00>, <0x00>, <0x00>;
rx-count = <1>;
tx-count = <0>;
ssdiv = "1.00";
so = <0x108>;
snum = <0x01>;
sdpa = <0x0B>;
on-freq = <3>;
off-freq = <3>;
drift-freq = <255>;
cancel-freq = <0>;
num-moving-avg = <4>;

ts1: button1 {
compatible = "renesas,ra-ctsu-button";
event-code = <INPUT_KEY_1>;
elements = <0>;
threshold = <2305>;
hysteresis = <115>;
};
};
};
1 change: 1 addition & 0 deletions drivers/input/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ zephyr_library_sources_ifdef(CONFIG_INPUT_PAW32XX input_paw32xx.c)
zephyr_library_sources_ifdef(CONFIG_INPUT_PINNACLE input_pinnacle.c)
zephyr_library_sources_ifdef(CONFIG_INPUT_PMW3610 input_pmw3610.c)
zephyr_library_sources_ifdef(CONFIG_INPUT_REALTEK_RTS5912_KBD input_realtek_rts5912_kbd.c)
zephyr_library_sources_ifdef(CONFIG_INPUT_RENESAS_RA_CTSU input_renesas_ra_ctsu.c)
zephyr_library_sources_ifdef(CONFIG_INPUT_SBUS input_sbus.c)
zephyr_library_sources_ifdef(CONFIG_INPUT_STM32_TSC_KEYS input_tsc_keys.c)
zephyr_library_sources_ifdef(CONFIG_INPUT_STMPE811 input_stmpe811.c)
Expand Down
1 change: 1 addition & 0 deletions drivers/input/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ source "drivers/input/Kconfig.pat912x"
source "drivers/input/Kconfig.paw32xx"
source "drivers/input/Kconfig.pinnacle"
source "drivers/input/Kconfig.pmw3610"
source "drivers/input/Kconfig.renesas_ra"
source "drivers/input/Kconfig.rts5912"
source "drivers/input/Kconfig.sbus"
source "drivers/input/Kconfig.sdl"
Expand Down
96 changes: 96 additions & 0 deletions drivers/input/Kconfig.renesas_ra
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Copyright (c) 2025 Renesas Electronics Corporation
# SPDX-License-Identifier: Apache-2.0

config INPUT_RENESAS_RA_CTSU
bool "Renesas RA Capacitive Touch driver"
default y
depends on DT_HAS_RENESAS_RA_CTSU_ENABLED
select USE_RA_FSP_CTSU
select USE_RA_FSP_TOUCH
select SYS_MEM_BLOCKS
select GPIO
select PINCTRL
help
Enable Renesas RA Touch Sensing driver.

if INPUT_RENESAS_RA_CTSU

config INPUT_RENESAS_RA_DEVICE_VCC
int "SoC VCC input in minivolt"
default 3300
help
SoC VCC input in milivolt.

config INPUT_RENESAS_RA_QE_TOUCH_CFG
bool "Using QE Touch Workflow to config this driver"
help
If this config was enabled, setting for CTSU and Cap
Touch driver will be reflected the setting that generated
from QE Touch Workflow.
Please add the generated C source files into the app CMakeLists
to make the driver can using it.

if !INPUT_RENESAS_RA_QE_TOUCH_CFG

config INPUT_RENESAS_RA_CTSU_NUM_SELF_ELEMENTS
int "Number of self-capacitance elements"
default 0
help
Number of self-capacitance elements in the CTSU.

config INPUT_RENESAS_RA_CTSU_NUM_MUTUAL_ELEMENTS
int "Number of mutual-capacitance elements"
default 0
help
Number of mutual-capacitance elements in the CTSU.

choice INPUT_RENESAS_RA_CTSU_CHATTERING_SUPPRESSION_TYPE
prompt "Type of chattering suppression"
default INPUT_RENESAS_RA_CTSU_CHATTERING_SUPPRESSION_TYPE_A

config INPUT_RENESAS_RA_CTSU_CHATTERING_SUPPRESSION_TYPE_A
bool "Counter of exceed threshold is hold within hysteresis range"
help
Counter of exceed threshold is hold within hysteresis range.

config INPUT_RENESAS_RA_CTSU_CHATTERING_SUPPRESSION_TYPE_B
bool "Counter of exceed threshold is reset within hysteresis range"
help
Counter of exceed threshold is reset within hysteresis range.

endchoice # INPUT_RENESAS_RA_CTSU_CHATTERING_SUPPRESSION_TYPE

endif # !INPUT_RENESAS_RA_QE_TOUCH_CFG

config INPUT_RENESAS_RA_CTSU_POLLING_INTERVAL_MS
int "CTSU debounce interval time"
range 20 500
default 100
help
Debouncing interval time in milliseconds.

config INPUT_RENESAS_RA_CTSU_STABILIZATION_TIME_US
int "CTSU stabilization time"
default 20
help
Stabilization time required to wait between 2 scans.

config INPUT_RENESAS_RA_CTSU_DRV_STACK_SIZE
int "CTSU internal thread stack size"
default 512
help
CTSU driver internal thread stack size.

config INPUT_RENESAS_RA_CTSU_DRV_PRIORITY
int "CTSU internal thread priority"
default 8
help
CTSU driver internal thread priority.

config INPUT_RENESAS_RA_CTSU_MSG_MEM_BLOCK_SIZE
int "CTSU internal sys_mem_blocks allocator size"
default 10
help
CTSU driver internal sys_mem_blocks allocator maximum num blocks.

endif # INPUT_RENESAS_RA_CTSU
Loading
Loading