From b3fa11aae9a9bd7fdf981ef7726a201be9c0c323 Mon Sep 17 00:00:00 2001 From: mcc45tr Date: Sun, 13 Sep 2026 23:12:42 +0300 Subject: [PATCH] Input: nt36523: expose runtime double-tap wake control --- .../ABI/testing/sysfs-driver-nt36523 | 13 ++++ drivers/input/touchscreen/nt36523/nt36xxx.c | 62 ++++++++++++++++++- drivers/input/touchscreen/nt36523/nt36xxx.h | 1 + senemos/configs/nabu-minimal.config | 3 + 4 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-driver-nt36523 diff --git a/Documentation/ABI/testing/sysfs-driver-nt36523 b/Documentation/ABI/testing/sysfs-driver-nt36523 new file mode 100644 index 000000000..95416d286 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-driver-nt36523 @@ -0,0 +1,13 @@ +What: /sys/bus/spi/devices/.../double_tap_to_wake +Date: September 2026 +Contact: mcc45tr +Description: + Read or change the Novatek NT36523 touchscreen double-tap wake + policy. Reading returns 1 when enabled and 0 when disabled. + Writing a boolean changes only the gesture policy; while the panel + is suspended the request is deferred until the touchscreen resumes. + + The attribute is present only when firmware describes both + "wakeup-source" and "novatek,double-tap-to-wake". It does not + disable the touchscreen wakeup source itself. +Users: Nabu tablet settings services diff --git a/drivers/input/touchscreen/nt36523/nt36xxx.c b/drivers/input/touchscreen/nt36523/nt36xxx.c index 7560d66af..cd4adaf2b 100644 --- a/drivers/input/touchscreen/nt36523/nt36xxx.c +++ b/drivers/input/touchscreen/nt36523/nt36xxx.c @@ -98,6 +98,56 @@ const uint16_t touch_key_array[TOUCH_KEY_NUM] = { static uint8_t bTouchIsAwake = 0; +static ssize_t double_tap_to_wake_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int enabled; + + (void)dev; + (void)attr; + mutex_lock(&ts->lock); + enabled = ts->gesture_command_delayed >= 0 ? + ts->gesture_command_delayed : ts->db_wakeup; + mutex_unlock(&ts->lock); + + return sysfs_emit(buf, "%d\n", enabled ? 1 : 0); +} + +static ssize_t double_tap_to_wake_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + bool enabled; + bool deferred; + int ret; + + (void)dev; + (void)attr; + if (!ts->double_tap_supported || !ts->wakeup_source) + return -EOPNOTSUPP; + ret = kstrtobool(buf, &enabled); + if (ret) + return ret; + + mutex_lock(&ts->lock); + deferred = !bTouchIsAwake; + if (!deferred) + ts->db_wakeup = enabled; + else + ts->gesture_command_delayed = enabled; + mutex_unlock(&ts->lock); + + NVT_LOG("set double tap wakeup %d%s\n", enabled, + deferred ? " after resume" : ""); + return count; +} +static DEVICE_ATTR_RW(double_tap_to_wake); + +static struct attribute *nvt_runtime_attrs[] = { + &dev_attr_double_tap_to_wake.attr, + NULL, +}; +ATTRIBUTE_GROUPS(nvt_runtime); + /******************************************************* Description: Novatek touchscreen irq enable/disable function. @@ -744,8 +794,9 @@ static int32_t nvt_parse_dt(struct device *dev) NVT_LOG("novatek,wgp-stylus=%d\n", ts->wgp_stylus); ts->wakeup_source = of_property_read_bool(np, "wakeup-source"); - ts->db_wakeup = of_property_read_bool(np, + ts->double_tap_supported = of_property_read_bool(np, "novatek,double-tap-to-wake"); + ts->db_wakeup = ts->double_tap_supported; if (ts->db_wakeup && !ts->wakeup_source) { NVT_ERR("double tap requested without wakeup-source; disabling\n"); ts->db_wakeup = 0; @@ -1644,6 +1695,11 @@ static int32_t nvt_ts_probe(struct spi_device *client) ts->wakeup_source = false; ts->db_wakeup = 0; } + if (ts->double_tap_supported && ts->wakeup_source) { + ret = devm_device_add_group(&client->dev, &nvt_runtime_group); + if (ret) + NVT_ERR("failed to create runtime attributes: %d\n", ret); + } ts->pm_notif.notifier_call = nvt_pm_notifier_callback; ret = register_pm_notifier(&ts->pm_notif); @@ -1979,11 +2035,13 @@ static int32_t nvt_ts_resume(struct device *dev) } else { NVT_ERR("IC state may error,caused by suspend/resume flow, please CHECK!!"); } - if (ts->gesture_command_delayed >= 0){ + mutex_lock(&ts->lock); + if (ts->gesture_command_delayed >= 0) { ts->db_wakeup = ts->gesture_command_delayed; ts->gesture_command_delayed = -1; NVT_LOG("execute delayed command, set double click wakeup %d\n", ts->db_wakeup); } + mutex_unlock(&ts->lock); if (wake_lock_held) pm_relax(dev); diff --git a/drivers/input/touchscreen/nt36523/nt36xxx.h b/drivers/input/touchscreen/nt36523/nt36xxx.h index f062bd431..0e71bb56e 100644 --- a/drivers/input/touchscreen/nt36523/nt36xxx.h +++ b/drivers/input/touchscreen/nt36523/nt36xxx.h @@ -171,6 +171,7 @@ struct nvt_ts_data { int panel_index; uint32_t spi_max_freq; int db_wakeup; + bool double_tap_supported; bool wakeup_source; bool irq_wake_enabled; bool system_suspending; diff --git a/senemos/configs/nabu-minimal.config b/senemos/configs/nabu-minimal.config index fbe5e9964..e6d277409 100644 --- a/senemos/configs/nabu-minimal.config +++ b/senemos/configs/nabu-minimal.config @@ -78,6 +78,9 @@ CONFIG_LRU_GEN_WALKS_MMU=y # Nabu SPI touch, wake gestures and PM8150 fuel gauge. CONFIG_TOUCHSCREEN_NT36523_SPI=m +# The opt-in Sensor DSP bridge exposes only KEY_WAKEUP through this built-in +# input device, so wake remains available before loadable modules are usable. +CONFIG_INPUT_UINPUT=y CONFIG_BATTERY_QCOM_FG=y CONFIG_CHARGER_IDTP9418=m CONFIG_CHARGER_QCOM_SMB2=m -- 2.55.0