* [PATCH 0/3] Add Nsiway NS2009 touchscreen support
@ 2026-10-09 14:47 Miotsuki Mizuno
2026-10-09 14:47 ` [PATCH 1/3] dt-bindings: vendor-prefixes: add Nsiway Miotsuki Mizuno
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Miotsuki Mizuno @ 2026-10-09 14:47 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Icenowy Zheng,
linux-input, devicetree, linux-kernel
Add polling support for the Nsiway NS2009 I2C resistive touchscreen
controller, together with its vendor prefix and DT binding. Coordinates
are 12-bit ADC readings; raw Z1 is used only to detect contact. The driver
uses a 30 ms polling interval and the common touchscreen transforms.
The implementation derives from Icenowy Zheng's 2017 polling driver [1].
It uses the current input polling API and managed input allocation, with
no private copy of the input core's touch-key state. Failed, short or
malformed I2C reads release the current contact and discard coordinates;
a later valid sample can report a new contact. A transient read error can
therefore cause a pen-up rather than retain an indefinitely active contact.
The driver checks the zero padding in the second byte of a 12-bit response,
as specified by the read-command format. Responses with nonzero padding
are rejected before the decoded value is assigned.
The historical Z1 threshold of 80 remains the default. Boards can override
it with touchscreen-min-pressure; the tested UNIHIKER M10 V1.2 uses 150.
IRQ, wakeup and calibrated pressure reporting are outside this series.
Board DTS changes are also separate.
Validation:
- Latest mainline base: ARM64 driver-object build with W=1, and in-tree
dt_binding_check for the unchanged NS2009 binding.
- UNIHIKER M10 V1.2, Linux 6.18: clicks, long presses, directed drags,
axis orientation, release, and three held-contact inhibit/uninhibit
cycles. A validation module changed only the driver registration name
to replace the existing built-in driver; the read/poll/probe code is
the same as this series. The boot Image and DTB were retained.
- Two malformed Z1 responses were rejected during the physical run;
subsequent contacts were reported normally without stuck key state.
- Controlled read/poll/probe tests with ASan/UBSan cover all 4096 valid
ADC values, every nonzero padding nibble on Z1/X/Y, threshold bounds,
malformed properties, core key resets, short/failed reads and recovery.
Physical NACK/short-read fault injection and system suspend/resume were
not tested. This is a new three-patch series, not a continuation of the
board-specific BSP changes.
[1] https://lore.kernel.org/all/20170315155140.54518-4-icenowy@aosc.xyz/
Mizuno Miotsuki (3):
dt-bindings: vendor-prefixes: add Nsiway
dt-bindings: input: touchscreen: add Nsiway NS2009
Input: add Nsiway NS2009 resistive touchscreen driver
.../input/touchscreen/nsiway,ns2009.yaml | 64 +++++++
.../devicetree/bindings/vendor-prefixes.yaml | 2 +
MAINTAINERS | 7 +
drivers/input/touchscreen/Kconfig | 10 +
drivers/input/touchscreen/Makefile | 1 +
drivers/input/touchscreen/ns2009.c | 175 ++++++++++++++++++
6 files changed, 259 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/touchscreen/nsiway,ns2009.yaml
create mode 100644 drivers/input/touchscreen/ns2009.c
base-commit: af32da41b0327b9c6a37856ba82b6760d6c8d10e
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 1/3] dt-bindings: vendor-prefixes: add Nsiway 2026-10-09 14:47 [PATCH 0/3] Add Nsiway NS2009 touchscreen support Miotsuki Mizuno @ 2026-10-09 14:47 ` Miotsuki Mizuno 2026-10-09 14:47 ` [PATCH 2/3] dt-bindings: input: touchscreen: add Nsiway NS2009 Miotsuki Mizuno ` (2 subsequent siblings) 3 siblings, 0 replies; 9+ messages in thread From: Miotsuki Mizuno @ 2026-10-09 14:47 UTC (permalink / raw) To: Dmitry Torokhov Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Icenowy Zheng, linux-input, devicetree, linux-kernel Nsiway manufactures the NS2009 I2C resistive touchscreen controller. Add its vendor prefix for the touchscreen binding. Signed-off-by: Mizuno Miotsuki <founder@crepuse.com> --- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml index ba2002969373..a180012054c9 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -1214,6 +1214,8 @@ patternProperties: description: Novatek "^novtech,.*": description: NovTech, Inc. + "^nsiway,.*": + description: Shenzhen Nsiway Technology Co., Ltd. "^nuclei,.*": description: Nuclei System Technology "^numonyx,.*": ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/3] dt-bindings: input: touchscreen: add Nsiway NS2009 2026-10-09 14:47 [PATCH 0/3] Add Nsiway NS2009 touchscreen support Miotsuki Mizuno 2026-10-09 14:47 ` [PATCH 1/3] dt-bindings: vendor-prefixes: add Nsiway Miotsuki Mizuno @ 2026-10-09 14:47 ` Miotsuki Mizuno 2026-10-11 5:13 ` Dmitry Torokhov 2026-10-09 14:47 ` [PATCH 3/3] Input: add Nsiway NS2009 resistive touchscreen driver Miotsuki Mizuno 2026-10-11 5:42 ` [PATCH v2 0/3] Add Nsiway NS2009 touchscreen support Miotsuki Mizuno 3 siblings, 1 reply; 9+ messages in thread From: Miotsuki Mizuno @ 2026-10-09 14:47 UTC (permalink / raw) To: Dmitry Torokhov Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Icenowy Zheng, linux-input, devicetree, linux-kernel Describe the Nsiway NS2009 four-wire resistive touchscreen controller and the properties used by its polling driver. The controller returns 12-bit ADC coordinates. Use the common touchscreen properties for coordinate ranges and orientation, and allow boards to set the raw Z1 contact threshold through touchscreen-min-pressure. Limit that threshold to 1..4095 because zero cannot distinguish a released contact. Document the historical default of 80 and a board override of 150 in the example. The Z1 threshold is for contact detection, not calibrated pressure. Signed-off-by: Mizuno Miotsuki <founder@crepuse.com> --- .../input/touchscreen/nsiway,ns2009.yaml | 64 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/nsiway,ns2009.yaml diff --git a/Documentation/devicetree/bindings/input/touchscreen/nsiway,ns2009.yaml b/Documentation/devicetree/bindings/input/touchscreen/nsiway,ns2009.yaml new file mode 100644 index 000000000000..04df7ba66a4a --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/nsiway,ns2009.yaml @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/nsiway,ns2009.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nsiway NS2009 resistive touchscreen controller + +maintainers: + - Mizuno Miotsuki <founder@crepuse.com> + +description: | + The NS2009 is a four-wire resistive touchscreen controller connected over + I2C. This binding describes polling operation without a pen interrupt. + Coordinates are 12-bit ADC readings, not display pixel coordinates. + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + const: nsiway,ns2009 + + reg: + maxItems: 1 + + touchscreen-min-pressure: + minimum: 1 + maximum: 4095 + default: 80 + description: + Minimum raw Z1 reading considered a touch. This is a contact detection + threshold, not a calibrated pressure value. Boards may require a higher + empirically determined threshold than the historical driver default. + + touchscreen-min-x: true + touchscreen-min-y: true + touchscreen-size-x: true + touchscreen-size-y: true + touchscreen-fuzz-x: true + touchscreen-fuzz-y: true + touchscreen-inverted-x: true + touchscreen-inverted-y: true + touchscreen-swapped-x-y: true + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + touchscreen@48 { + compatible = "nsiway,ns2009"; + reg = <0x48>; + touchscreen-min-pressure = <150>; + touchscreen-inverted-y; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index f53047aa8d3c..696f2badc49c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19467,6 +19467,12 @@ S: Maintained F: Documentation/core-api/symbol-namespaces.rst F: scripts/nsdeps +NSIWAY NS2009 TOUCHSCREEN CONTROLLER +M: Mizuno Miotsuki <founder@crepuse.com> +L: linux-input@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/input/touchscreen/nsiway,ns2009.yaml + NTB AMD DRIVER M: Basavaraj Natikar <Basavaraj.Natikar@amd.com> M: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] dt-bindings: input: touchscreen: add Nsiway NS2009 2026-10-09 14:47 ` [PATCH 2/3] dt-bindings: input: touchscreen: add Nsiway NS2009 Miotsuki Mizuno @ 2026-10-11 5:13 ` Dmitry Torokhov 0 siblings, 0 replies; 9+ messages in thread From: Dmitry Torokhov @ 2026-10-11 5:13 UTC (permalink / raw) To: Miotsuki Mizuno Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Icenowy Zheng, linux-input, devicetree, linux-kernel Hi Miotsuki, On Fri, Oct 09, 2026 at 02:47:43PM +0000, Miotsuki Mizuno wrote: > Describe the Nsiway NS2009 four-wire resistive touchscreen controller > and the properties used by its polling driver. > > The controller returns 12-bit ADC coordinates. Use the common touchscreen > properties for coordinate ranges and orientation, and allow boards to set > the raw Z1 contact threshold through touchscreen-min-pressure. Limit that > threshold to 1..4095 because zero cannot distinguish a released contact. > > Document the historical default of 80 and a board override of 150 in the > example. The Z1 threshold is for contact detection, not calibrated > pressure. > > Signed-off-by: Mizuno Miotsuki <founder@crepuse.com> > --- ... > +description: | > + The NS2009 is a four-wire resistive touchscreen controller connected over > + I2C. This binding describes polling operation without a pen interrupt. > + Coordinates are 12-bit ADC readings, not display pixel coordinates. Devicetree bindings should describe the hardware itself rather than the subset of features currently used by the Linux driver. According to the NS2009 datasheet, the controller has several hardware signals and capabilities that should be covered in the binding from the start (even if the initial driver operates in polling mode): - interrupts (maxItems: 1) and wakeup-source: the controller provides an active-low pen interrupt output, which can remain optional for boards where the line is left unconnected. - vdd-supply and vref-supply: main power supply and external reference voltage regulators. - touchscreen-x-plate-ohms (along with touchscreen-max-pressure and touchscreen-fuzz-pressure): the NS2009 supports touch resistance calculation from Z1/Z2 and X-plate resistance. Could you expand the binding description and properties (and show an interrupt/supply example as well) so we do not have to revisit the binding when IRQ or pressure support is added later? Thanks. -- Dmitry ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/3] Input: add Nsiway NS2009 resistive touchscreen driver 2026-10-09 14:47 [PATCH 0/3] Add Nsiway NS2009 touchscreen support Miotsuki Mizuno 2026-10-09 14:47 ` [PATCH 1/3] dt-bindings: vendor-prefixes: add Nsiway Miotsuki Mizuno 2026-10-09 14:47 ` [PATCH 2/3] dt-bindings: input: touchscreen: add Nsiway NS2009 Miotsuki Mizuno @ 2026-10-09 14:47 ` Miotsuki Mizuno 2026-10-11 5:42 ` [PATCH v2 0/3] Add Nsiway NS2009 touchscreen support Miotsuki Mizuno 3 siblings, 0 replies; 9+ messages in thread From: Miotsuki Mizuno @ 2026-10-09 14:47 UTC (permalink / raw) To: Dmitry Torokhov Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Icenowy Zheng, linux-input, devicetree, linux-kernel Add polling support for the Nsiway NS2009 I2C touchscreen controller using the input polling API and managed input allocation. Read 12-bit X/Y ADC values and report BTN_TOUCH from the raw Z1 contact threshold. Apply coordinate transforms through the common touchscreen helpers. This implementation derives from Icenowy Zheng's 2017 polling driver. Keep its historical threshold default while allowing a firmware override, and retain the original copyright and author attribution. Report the touch key on every successful sample and let the input core filter repeated values. A private pen-down flag would become stale when the core clears key state during inhibit or reset. On a failed, short or malformed I2C read, discard the coordinates and release the contact so a failed bus cannot leave it stuck down. A later valid sample reports a new contact. Validate the zero padding in the low nibble of the second byte as specified by the 12-bit read-command format. Reject malformed responses before assigning the decoded value, and rate-limit the diagnostic output. Tested on UNIHIKER M10 V1.2 with a Linux 6.18 validation module: clicks, long presses, drags, release, axis orientation and three held-contact inhibit/uninhibit cycles. The validation module only changes the driver registration name to replace the existing built-in driver. Physical NACK/short-read fault injection and system suspend/resume have not been exercised. Link: https://lore.kernel.org/all/20170315155140.54518-4-icenowy@aosc.xyz/ Signed-off-by: Mizuno Miotsuki <founder@crepuse.com> --- MAINTAINERS | 1 + drivers/input/touchscreen/Kconfig | 10 ++ drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/ns2009.c | 175 +++++++++++++++++++++++++++++ 4 files changed, 187 insertions(+) create mode 100644 drivers/input/touchscreen/ns2009.c diff --git a/MAINTAINERS b/MAINTAINERS index 696f2badc49c..e282c02ec13f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19472,6 +19472,7 @@ M: Mizuno Miotsuki <founder@crepuse.com> L: linux-input@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/input/touchscreen/nsiway,ns2009.yaml +F: drivers/input/touchscreen/ns2009.c NTB AMD DRIVER M: Basavaraj Natikar <Basavaraj.Natikar@amd.com> diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 9b9ae8ac3f7f..d4cdf1a7e057 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -691,6 +691,16 @@ config TOUCHSCREEN_MTOUCH To compile this driver as a module, choose M here: the module will be called mtouch. +config TOUCHSCREEN_NS2009 + tristate "Nsiway NS2009 touchscreen controller" + depends on I2C + help + Say Y here if you have a resistive touchscreen using the Nsiway + NS2009 controller connected over I2C. + + To compile this driver as a module, choose M here: the module will be + called ns2009. + config TOUCHSCREEN_NOVATEK_NVT_TS tristate "Novatek NT11205 touchscreen support" depends on I2C diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index bfd9de83389d..c5fc2062d7cf 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -68,6 +68,7 @@ obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o obj-$(CONFIG_TOUCHSCREEN_MMS114) += mms114.o obj-$(CONFIG_TOUCHSCREEN_MSG2638) += msg2638.o obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o +obj-$(CONFIG_TOUCHSCREEN_NS2009) += ns2009.o obj-$(CONFIG_TOUCHSCREEN_NOVATEK_NVT_TS) += novatek-nvt-ts.o obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o obj-$(CONFIG_TOUCHSCREEN_HP7XX) += jornada720_ts.o diff --git a/drivers/input/touchscreen/ns2009.c b/drivers/input/touchscreen/ns2009.c new file mode 100644 index 000000000000..d5c1f9f96bb6 --- /dev/null +++ b/drivers/input/touchscreen/ns2009.c @@ -0,0 +1,175 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Nsiway NS2009 resistive touchscreen controller + * + * Copyright (C) 2017 Icenowy Zheng <icenowy@aosc.xyz> + * Portions derived from silead.c: + * Copyright (C) 2014-2015 Intel Corporation + */ + +#include <linux/i2c.h> +#include <linux/input.h> +#include <linux/input/touchscreen.h> +#include <linux/module.h> +#include <linux/property.h> + +#define NS2009_POLL_INTERVAL_MS 30 +#define NS2009_MAX_12BIT 0xfff + +#define NS2009_READ_X_LOW_POWER_12BIT 0xc0 +#define NS2009_READ_Y_LOW_POWER_12BIT 0xd0 +#define NS2009_READ_Z1_LOW_POWER_12BIT 0xe0 + +/* Historical driver default; boards may override via firmware properties. */ +#define NS2009_DEFAULT_PEN_DOWN_Z1 80 + +struct ns2009_data { + struct i2c_client *client; + struct touchscreen_properties prop; + u16 pen_down_z1; +}; + +static int ns2009_read_data(struct ns2009_data *data, u8 command, u16 *value) +{ + u8 raw[2]; + int error; + + error = i2c_smbus_read_i2c_block_data(data->client, command, + sizeof(raw), raw); + if (error < 0) + return error; + if (error != sizeof(raw)) + return -EIO; + /* The 12-bit result is left-aligned; the remaining bits must be zero. */ + if (raw[1] & 0x0f) { + dev_err_ratelimited(&data->client->dev, + "invalid sample for command %#02x: %02x %02x\n", + command, raw[0], raw[1]); + return -EIO; + } + + *value = (raw[0] << 4) | (raw[1] >> 4); + return 0; +} + +static void ns2009_poll(struct input_dev *input) +{ + struct ns2009_data *data = input_get_drvdata(input); + u16 x, y, z1; + int error; + + error = ns2009_read_data(data, NS2009_READ_Z1_LOW_POWER_12BIT, &z1); + if (error) + goto read_error; + + if (z1 < data->pen_down_z1) + goto release; + + error = ns2009_read_data(data, NS2009_READ_X_LOW_POWER_12BIT, &x); + if (error) + goto read_error; + + error = ns2009_read_data(data, NS2009_READ_Y_LOW_POWER_12BIT, &y); + if (error) + goto read_error; + + /* The input core filters repeats and may independently clear key state. */ + input_report_key(input, BTN_TOUCH, 1); + touchscreen_report_pos(input, &data->prop, x, y, false); + input_sync(input); + return; + +read_error: + dev_err_ratelimited(&data->client->dev, + "failed to poll touch data: %d\n", error); + /* An unreadable sample must not leave an active touch stuck down. */ +release: + input_report_key(input, BTN_TOUCH, 0); + input_sync(input); +} + +static int ns2009_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct ns2009_data *data; + struct input_dev *input; + u32 value; + int error; + + if (!i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) + return dev_err_probe(dev, -EOPNOTSUPP, + "required SMBus block read is unavailable\n"); + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + input = devm_input_allocate_device(dev); + if (!input) + return -ENOMEM; + + data->client = client; + data->pen_down_z1 = NS2009_DEFAULT_PEN_DOWN_Z1; + if (device_property_present(dev, "touchscreen-min-pressure")) { + error = device_property_read_u32(dev, "touchscreen-min-pressure", + &value); + if (error) + return dev_err_probe(dev, error, + "failed to read touchscreen-min-pressure\n"); + if (!value || value > NS2009_MAX_12BIT) + return dev_err_probe(dev, -EINVAL, + "touchscreen-min-pressure must be 1..4095\n"); + data->pen_down_z1 = value; + } + input_set_drvdata(input, data); + + input->name = "ns2009_ts"; + input->phys = "input/ts"; + input->id.bustype = BUS_I2C; + + __set_bit(INPUT_PROP_DIRECT, input->propbit); + input_set_capability(input, EV_KEY, BTN_TOUCH); + input_set_abs_params(input, ABS_X, 0, NS2009_MAX_12BIT, 32, 0); + input_set_abs_params(input, ABS_Y, 0, NS2009_MAX_12BIT, 16, 0); + touchscreen_parse_properties(input, false, &data->prop); + + error = input_setup_polling(input, ns2009_poll); + if (error) + return dev_err_probe(dev, error, "failed to set up polling\n"); + + input_set_poll_interval(input, NS2009_POLL_INTERVAL_MS); + + error = input_register_device(input); + if (error) + return dev_err_probe(dev, error, + "failed to register input device\n"); + + return 0; +} + +static const struct i2c_device_id ns2009_id[] = { + { "ns2009" }, + { } +}; +MODULE_DEVICE_TABLE(i2c, ns2009_id); + +static const struct of_device_id ns2009_of_match[] = { + { .compatible = "nsiway,ns2009" }, + { } +}; +MODULE_DEVICE_TABLE(of, ns2009_of_match); + +static struct i2c_driver ns2009_driver = { + .driver = { + .name = "ns2009", + .of_match_table = ns2009_of_match, + }, + .probe = ns2009_probe, + .id_table = ns2009_id, +}; +module_i2c_driver(ns2009_driver); + +MODULE_AUTHOR("Icenowy Zheng <icenowy@aosc.xyz>"); +MODULE_DESCRIPTION("Nsiway NS2009 resistive touchscreen controller"); +MODULE_LICENSE("GPL"); ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 0/3] Add Nsiway NS2009 touchscreen support 2026-10-09 14:47 [PATCH 0/3] Add Nsiway NS2009 touchscreen support Miotsuki Mizuno ` (2 preceding siblings ...) 2026-10-09 14:47 ` [PATCH 3/3] Input: add Nsiway NS2009 resistive touchscreen driver Miotsuki Mizuno @ 2026-10-11 5:42 ` Miotsuki Mizuno 2026-10-11 5:42 ` [PATCH v2 1/3] dt-bindings: vendor-prefixes: add Nsiway Miotsuki Mizuno ` (2 more replies) 3 siblings, 3 replies; 9+ messages in thread From: Miotsuki Mizuno @ 2026-10-11 5:42 UTC (permalink / raw) To: Dmitry Torokhov Cc: robh, krzk+dt, conor+dt, icenowy, linux-input, devicetree, linux-kernel Add the Nsiway vendor prefix, an NS2009 hardware binding and an initial polling driver for the four-wire resistive touchscreen controller. Changes in v2: - Address Dmitry Torokhov's review by describing NS2009 hardware capabilities independently of the initial polling implementation. - Add optional interrupts, wakeup-source, vdd-supply and vref-supply. - Allow touchscreen-x-plate-ohms, touchscreen-max-pressure and touchscreen-fuzz-pressure via the common touchscreen schema. - Add a second example showing an active-low pen interrupt and supplies; retain the no-interrupt example. The driver and vendor-prefix changes are unchanged from v1. IRQ-based operation, wakeup handling and Z1/Z2 touch resistance calculation will be implemented separately. These features are not claimed to work in the current polling driver. The existing raw Z1 minimum contact threshold is unchanged, including the tested M10 value of 150. Validation: - dt_binding_check for both NS2009 examples: PASS. - M10 DTS rebuild and CHECK_DTBS=y: PASS. - Full-schema direct validation of the rebuilt combined M10 DTB and the existing independent touchscreen DTB: PASS, no diagnostics. - The combined DTB is byte-identical to the previously hardware-tested DTB. No new runtime IRQ or pressure test was performed. NS2009 dependencies are imported only in the independent M10 validation branch; no claim that they are merged. Mizuno Miotsuki (3): dt-bindings: vendor-prefixes: add Nsiway dt-bindings: input: touchscreen: add Nsiway NS2009 Input: add Nsiway NS2009 resistive touchscreen driver .../input/touchscreen/nsiway,ns2009.yaml | 104 +++++++++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + MAINTAINERS | 7 + drivers/input/touchscreen/Kconfig | 10 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/ns2009.c | 175 ++++++++++++++++++ 6 files changed, 299 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/nsiway,ns2009.yaml create mode 100644 drivers/input/touchscreen/ns2009.c base-commit: af32da41b0327b9c6a37856ba82b6760d6c8d10e -- 2.56.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/3] dt-bindings: vendor-prefixes: add Nsiway 2026-10-11 5:42 ` [PATCH v2 0/3] Add Nsiway NS2009 touchscreen support Miotsuki Mizuno @ 2026-10-11 5:42 ` Miotsuki Mizuno 2026-10-11 5:42 ` [PATCH v2 2/3] dt-bindings: input: touchscreen: add Nsiway NS2009 Miotsuki Mizuno 2026-10-11 5:42 ` [PATCH v2 3/3] Input: add Nsiway NS2009 resistive touchscreen driver Miotsuki Mizuno 2 siblings, 0 replies; 9+ messages in thread From: Miotsuki Mizuno @ 2026-10-11 5:42 UTC (permalink / raw) To: Dmitry Torokhov Cc: robh, krzk+dt, conor+dt, icenowy, linux-input, devicetree, linux-kernel Nsiway manufactures the NS2009 I2C resistive touchscreen controller. Add its vendor prefix for the touchscreen binding. Signed-off-by: Mizuno Miotsuki <founder@crepuse.com> --- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml index ba2002969373..a180012054c9 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -1214,6 +1214,8 @@ patternProperties: description: Novatek "^novtech,.*": description: NovTech, Inc. + "^nsiway,.*": + description: Shenzhen Nsiway Technology Co., Ltd. "^nuclei,.*": description: Nuclei System Technology "^numonyx,.*": -- 2.56.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 2/3] dt-bindings: input: touchscreen: add Nsiway NS2009 2026-10-11 5:42 ` [PATCH v2 0/3] Add Nsiway NS2009 touchscreen support Miotsuki Mizuno 2026-10-11 5:42 ` [PATCH v2 1/3] dt-bindings: vendor-prefixes: add Nsiway Miotsuki Mizuno @ 2026-10-11 5:42 ` Miotsuki Mizuno 2026-10-11 5:42 ` [PATCH v2 3/3] Input: add Nsiway NS2009 resistive touchscreen driver Miotsuki Mizuno 2 siblings, 0 replies; 9+ messages in thread From: Miotsuki Mizuno @ 2026-10-11 5:42 UTC (permalink / raw) To: Dmitry Torokhov Cc: robh, krzk+dt, conor+dt, icenowy, linux-input, devicetree, linux-kernel Describe the Nsiway NS2009 four-wire resistive touchscreen controller, including its optional active-low pen interrupt, power and external reference supplies, and touch resistance measurement capabilities. Allow the common X-plate resistance and pressure properties. Include both an interrupt/supply example and a minimal example for a board with an unconnected pen interrupt. Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Mizuno Miotsuki <founder@crepuse.com> --- .../input/touchscreen/nsiway,ns2009.yaml | 104 ++++++++++++++++++ MAINTAINERS | 6 + 2 files changed, 110 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/nsiway,ns2009.yaml diff --git a/Documentation/devicetree/bindings/input/touchscreen/nsiway,ns2009.yaml b/Documentation/devicetree/bindings/input/touchscreen/nsiway,ns2009.yaml new file mode 100644 index 000000000000..43523f40dcb8 --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/nsiway,ns2009.yaml @@ -0,0 +1,104 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/nsiway,ns2009.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nsiway NS2009 resistive touchscreen controller + +maintainers: + - Mizuno Miotsuki <founder@crepuse.com> + +description: | + The NS2009 is a four-wire resistive touchscreen controller connected over + I2C, with a 12-bit ADC, an active-low pen interrupt output, and support + for an external ADC reference voltage. Touch resistance can be calculated + from the X coordinate, Z1 and Z2 measurements, and the X-plate resistance. + Coordinates are 12-bit ADC readings, not display pixel coordinates. + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + const: nsiway,ns2009 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + description: + Active-low pen interrupt output. Optional when the signal is not + connected. + + wakeup-source: true + + vdd-supply: + description: Main power supply. + + vref-supply: + description: External ADC reference voltage supply. + + touchscreen-x-plate-ohms: true + touchscreen-max-pressure: true + touchscreen-fuzz-pressure: true + + touchscreen-min-pressure: + minimum: 1 + maximum: 4095 + default: 80 + description: + Minimum raw Z1 reading considered a touch. This is a contact detection + threshold, not a calibrated pressure value. Boards may require a higher + empirically determined threshold than the historical driver default. + + touchscreen-min-x: true + touchscreen-min-y: true + touchscreen-size-x: true + touchscreen-size-y: true + touchscreen-fuzz-x: true + touchscreen-fuzz-y: true + touchscreen-inverted-x: true + touchscreen-inverted-y: true + touchscreen-swapped-x-y: true + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + touchscreen@48 { + compatible = "nsiway,ns2009"; + reg = <0x48>; + touchscreen-min-pressure = <150>; + touchscreen-inverted-y; + }; + }; + - | + #include <dt-bindings/interrupt-controller/irq.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + touchscreen@48 { + compatible = "nsiway,ns2009"; + reg = <0x48>; + interrupt-parent = <&gpio1>; + interrupts = <7 IRQ_TYPE_LEVEL_LOW>; + wakeup-source; + vdd-supply = <&vdd>; + vref-supply = <&vref>; + touchscreen-x-plate-ohms = <400>; + touchscreen-max-pressure = <4095>; + touchscreen-fuzz-pressure = <16>; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index f53047aa8d3c..696f2badc49c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19467,6 +19467,12 @@ S: Maintained F: Documentation/core-api/symbol-namespaces.rst F: scripts/nsdeps +NSIWAY NS2009 TOUCHSCREEN CONTROLLER +M: Mizuno Miotsuki <founder@crepuse.com> +L: linux-input@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/input/touchscreen/nsiway,ns2009.yaml + NTB AMD DRIVER M: Basavaraj Natikar <Basavaraj.Natikar@amd.com> M: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> -- 2.56.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 3/3] Input: add Nsiway NS2009 resistive touchscreen driver 2026-10-11 5:42 ` [PATCH v2 0/3] Add Nsiway NS2009 touchscreen support Miotsuki Mizuno 2026-10-11 5:42 ` [PATCH v2 1/3] dt-bindings: vendor-prefixes: add Nsiway Miotsuki Mizuno 2026-10-11 5:42 ` [PATCH v2 2/3] dt-bindings: input: touchscreen: add Nsiway NS2009 Miotsuki Mizuno @ 2026-10-11 5:42 ` Miotsuki Mizuno 2 siblings, 0 replies; 9+ messages in thread From: Miotsuki Mizuno @ 2026-10-11 5:42 UTC (permalink / raw) To: Dmitry Torokhov Cc: robh, krzk+dt, conor+dt, icenowy, linux-input, devicetree, linux-kernel Add polling support for the Nsiway NS2009 I2C touchscreen controller using the input polling API and managed input allocation. Read 12-bit X/Y ADC values and report BTN_TOUCH from the raw Z1 contact threshold. Apply coordinate transforms through the common touchscreen helpers. This implementation derives from Icenowy Zheng's 2017 polling driver. Keep its historical threshold default while allowing a firmware override, and retain the original copyright and author attribution. Report the touch key on every successful sample and let the input core filter repeated values. A private pen-down flag would become stale when the core clears key state during inhibit or reset. On a failed, short or malformed I2C read, discard the coordinates and release the contact so a failed bus cannot leave it stuck down. A later valid sample reports a new contact. Validate the zero padding in the low nibble of the second byte as specified by the 12-bit read-command format. Reject malformed responses before assigning the decoded value, and rate-limit the diagnostic output. Tested on UNIHIKER M10 V1.2 with a Linux 6.18 validation module: clicks, long presses, drags, release, axis orientation and three held-contact inhibit/uninhibit cycles. The validation module only changes the driver registration name to replace the existing built-in driver. Physical NACK/short-read fault injection and system suspend/resume have not been exercised. Link: https://lore.kernel.org/all/20170315155140.54518-4-icenowy@aosc.xyz/ Signed-off-by: Mizuno Miotsuki <founder@crepuse.com> --- MAINTAINERS | 1 + drivers/input/touchscreen/Kconfig | 10 ++ drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/ns2009.c | 175 +++++++++++++++++++++++++++++ 4 files changed, 187 insertions(+) create mode 100644 drivers/input/touchscreen/ns2009.c diff --git a/MAINTAINERS b/MAINTAINERS index 696f2badc49c..e282c02ec13f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19472,6 +19472,7 @@ M: Mizuno Miotsuki <founder@crepuse.com> L: linux-input@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/input/touchscreen/nsiway,ns2009.yaml +F: drivers/input/touchscreen/ns2009.c NTB AMD DRIVER M: Basavaraj Natikar <Basavaraj.Natikar@amd.com> diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 9b9ae8ac3f7f..d4cdf1a7e057 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -691,6 +691,16 @@ config TOUCHSCREEN_MTOUCH To compile this driver as a module, choose M here: the module will be called mtouch. +config TOUCHSCREEN_NS2009 + tristate "Nsiway NS2009 touchscreen controller" + depends on I2C + help + Say Y here if you have a resistive touchscreen using the Nsiway + NS2009 controller connected over I2C. + + To compile this driver as a module, choose M here: the module will be + called ns2009. + config TOUCHSCREEN_NOVATEK_NVT_TS tristate "Novatek NT11205 touchscreen support" depends on I2C diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index bfd9de83389d..c5fc2062d7cf 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -68,6 +68,7 @@ obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o obj-$(CONFIG_TOUCHSCREEN_MMS114) += mms114.o obj-$(CONFIG_TOUCHSCREEN_MSG2638) += msg2638.o obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o +obj-$(CONFIG_TOUCHSCREEN_NS2009) += ns2009.o obj-$(CONFIG_TOUCHSCREEN_NOVATEK_NVT_TS) += novatek-nvt-ts.o obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o obj-$(CONFIG_TOUCHSCREEN_HP7XX) += jornada720_ts.o diff --git a/drivers/input/touchscreen/ns2009.c b/drivers/input/touchscreen/ns2009.c new file mode 100644 index 000000000000..d5c1f9f96bb6 --- /dev/null +++ b/drivers/input/touchscreen/ns2009.c @@ -0,0 +1,175 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Nsiway NS2009 resistive touchscreen controller + * + * Copyright (C) 2017 Icenowy Zheng <icenowy@aosc.xyz> + * Portions derived from silead.c: + * Copyright (C) 2014-2015 Intel Corporation + */ + +#include <linux/i2c.h> +#include <linux/input.h> +#include <linux/input/touchscreen.h> +#include <linux/module.h> +#include <linux/property.h> + +#define NS2009_POLL_INTERVAL_MS 30 +#define NS2009_MAX_12BIT 0xfff + +#define NS2009_READ_X_LOW_POWER_12BIT 0xc0 +#define NS2009_READ_Y_LOW_POWER_12BIT 0xd0 +#define NS2009_READ_Z1_LOW_POWER_12BIT 0xe0 + +/* Historical driver default; boards may override via firmware properties. */ +#define NS2009_DEFAULT_PEN_DOWN_Z1 80 + +struct ns2009_data { + struct i2c_client *client; + struct touchscreen_properties prop; + u16 pen_down_z1; +}; + +static int ns2009_read_data(struct ns2009_data *data, u8 command, u16 *value) +{ + u8 raw[2]; + int error; + + error = i2c_smbus_read_i2c_block_data(data->client, command, + sizeof(raw), raw); + if (error < 0) + return error; + if (error != sizeof(raw)) + return -EIO; + /* The 12-bit result is left-aligned; the remaining bits must be zero. */ + if (raw[1] & 0x0f) { + dev_err_ratelimited(&data->client->dev, + "invalid sample for command %#02x: %02x %02x\n", + command, raw[0], raw[1]); + return -EIO; + } + + *value = (raw[0] << 4) | (raw[1] >> 4); + return 0; +} + +static void ns2009_poll(struct input_dev *input) +{ + struct ns2009_data *data = input_get_drvdata(input); + u16 x, y, z1; + int error; + + error = ns2009_read_data(data, NS2009_READ_Z1_LOW_POWER_12BIT, &z1); + if (error) + goto read_error; + + if (z1 < data->pen_down_z1) + goto release; + + error = ns2009_read_data(data, NS2009_READ_X_LOW_POWER_12BIT, &x); + if (error) + goto read_error; + + error = ns2009_read_data(data, NS2009_READ_Y_LOW_POWER_12BIT, &y); + if (error) + goto read_error; + + /* The input core filters repeats and may independently clear key state. */ + input_report_key(input, BTN_TOUCH, 1); + touchscreen_report_pos(input, &data->prop, x, y, false); + input_sync(input); + return; + +read_error: + dev_err_ratelimited(&data->client->dev, + "failed to poll touch data: %d\n", error); + /* An unreadable sample must not leave an active touch stuck down. */ +release: + input_report_key(input, BTN_TOUCH, 0); + input_sync(input); +} + +static int ns2009_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct ns2009_data *data; + struct input_dev *input; + u32 value; + int error; + + if (!i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) + return dev_err_probe(dev, -EOPNOTSUPP, + "required SMBus block read is unavailable\n"); + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + input = devm_input_allocate_device(dev); + if (!input) + return -ENOMEM; + + data->client = client; + data->pen_down_z1 = NS2009_DEFAULT_PEN_DOWN_Z1; + if (device_property_present(dev, "touchscreen-min-pressure")) { + error = device_property_read_u32(dev, "touchscreen-min-pressure", + &value); + if (error) + return dev_err_probe(dev, error, + "failed to read touchscreen-min-pressure\n"); + if (!value || value > NS2009_MAX_12BIT) + return dev_err_probe(dev, -EINVAL, + "touchscreen-min-pressure must be 1..4095\n"); + data->pen_down_z1 = value; + } + input_set_drvdata(input, data); + + input->name = "ns2009_ts"; + input->phys = "input/ts"; + input->id.bustype = BUS_I2C; + + __set_bit(INPUT_PROP_DIRECT, input->propbit); + input_set_capability(input, EV_KEY, BTN_TOUCH); + input_set_abs_params(input, ABS_X, 0, NS2009_MAX_12BIT, 32, 0); + input_set_abs_params(input, ABS_Y, 0, NS2009_MAX_12BIT, 16, 0); + touchscreen_parse_properties(input, false, &data->prop); + + error = input_setup_polling(input, ns2009_poll); + if (error) + return dev_err_probe(dev, error, "failed to set up polling\n"); + + input_set_poll_interval(input, NS2009_POLL_INTERVAL_MS); + + error = input_register_device(input); + if (error) + return dev_err_probe(dev, error, + "failed to register input device\n"); + + return 0; +} + +static const struct i2c_device_id ns2009_id[] = { + { "ns2009" }, + { } +}; +MODULE_DEVICE_TABLE(i2c, ns2009_id); + +static const struct of_device_id ns2009_of_match[] = { + { .compatible = "nsiway,ns2009" }, + { } +}; +MODULE_DEVICE_TABLE(of, ns2009_of_match); + +static struct i2c_driver ns2009_driver = { + .driver = { + .name = "ns2009", + .of_match_table = ns2009_of_match, + }, + .probe = ns2009_probe, + .id_table = ns2009_id, +}; +module_i2c_driver(ns2009_driver); + +MODULE_AUTHOR("Icenowy Zheng <icenowy@aosc.xyz>"); +MODULE_DESCRIPTION("Nsiway NS2009 resistive touchscreen controller"); +MODULE_LICENSE("GPL"); -- 2.56.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-10-11 5:42 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-10-09 14:47 [PATCH 0/3] Add Nsiway NS2009 touchscreen support Miotsuki Mizuno 2026-10-09 14:47 ` [PATCH 1/3] dt-bindings: vendor-prefixes: add Nsiway Miotsuki Mizuno 2026-10-09 14:47 ` [PATCH 2/3] dt-bindings: input: touchscreen: add Nsiway NS2009 Miotsuki Mizuno 2026-10-11 5:13 ` Dmitry Torokhov 2026-10-09 14:47 ` [PATCH 3/3] Input: add Nsiway NS2009 resistive touchscreen driver Miotsuki Mizuno 2026-10-11 5:42 ` [PATCH v2 0/3] Add Nsiway NS2009 touchscreen support Miotsuki Mizuno 2026-10-11 5:42 ` [PATCH v2 1/3] dt-bindings: vendor-prefixes: add Nsiway Miotsuki Mizuno 2026-10-11 5:42 ` [PATCH v2 2/3] dt-bindings: input: touchscreen: add Nsiway NS2009 Miotsuki Mizuno 2026-10-11 5:42 ` [PATCH v2 3/3] Input: add Nsiway NS2009 resistive touchscreen driver Miotsuki Mizuno
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®