input: add driver for Hynitron CST816X touchscreen
Subsystems (3)
PATCH 1/2 input: add driver for Hynitron CST816X touchscreen
Introduce support for the Hynitron CST816X touchscreen controller used for 240×240 1.28-inch Round LCD Display Module manufactured by Waveshare Electronics. The driver is designed based on an Arduino implementation marked as under MIT License. This driver is written for a particular round display based on the CST816S controller, which is not compatiable with existing driver for Hynitron controllers.
--- drivers/input/touchscreen/Kconfig | 12 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/hynitron-cst816x.c | 390 +++++++++++++++++++ 3 files changed, 403 insertions(+) create mode 100644 drivers/input/touchscreen/hynitron-cst816x.c
drivers/input/touchscreen/Kconfig +12 -0
@@ -481,6 +481,18 @@ config TOUCHSCREEN_HYNITRON_CSTXXX To compile this driver as a module, choose M here: the module will be called hynitron-cstxxx. +config TOUCHSCREEN_HYNITRON_CST816X + tristate "Hynitron CST816X based touchscreen support" + depends on I2C + help + Say Y here if you have a touchscreen using a Hynitron + cst816x touchscreen controller. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called hynitron-cst816x. + config TOUCHSCREEN_ILI210X tristate "Ilitek ILI210X based touchscreen" depends on I2C
drivers/input/touchscreen/Makefile +1 -0
@@ -51,6 +51,7 @@ obj-$(CONFIG_TOUCHSCREEN_GOODIX_BERLIN_CORE) += goodix_berlin_core.o obj-$(CONFIG_TOUCHSCREEN_GOODIX_BERLIN_I2C) += goodix_berlin_i2c.o obj-$(CONFIG_TOUCHSCREEN_GOODIX_BERLIN_SPI) += goodix_berlin_spi.o obj-$(CONFIG_TOUCHSCREEN_HIDEEP) += hideep.o +obj-$(CONFIG_TOUCHSCREEN_HYNITRON_CST816X) += hynitron-cst816x.o obj-$(CONFIG_TOUCHSCREEN_HYNITRON_CSTXXX) += hynitron_cstxxx.o obj-$(CONFIG_TOUCHSCREEN_ILI210X) += ili210x.o obj-$(CONFIG_TOUCHSCREEN_ILITEK) += ilitek_ts_i2c.o
drivers/input/touchscreen/hynitron-cst816x.c new file +390 -0
390 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 2/2 dt-bindings: input: touchscreen: add Hynitron CST816X
Add documentation for the Hynitron CST816X touchscreen bindings.
--- .../input/touchscreen/hynitron,cst816x.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml new file +57 -0
@@ -0,0 +1,57 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/hynitron,cst816x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Hynitron CST816X series touchscreen controller + +description: | + Bindings for Hynitron CST816X series touchscreen controllers. + +maintainers: + - Oleh Kuzhylnyi <[email protected]> + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + enum: + - hynitron,cst816s + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + reset-gpios: + maxItems: 1 + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + - reset-gpios + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + cst816s: cst816s@15 { + compatible = "hynitron,cst816s"; + reg = <0x15>; + interrupt-parent = <&gpio>; + interrupts = <4 1>; + reset-gpios = <&gpio 17 0>; + status="okay"; + }; + }; + +...
Signature · 1 line
2.34.1
Re: [PATCH 2/2] dt-bindings: input: touchscreen: add Hynitron CST816X
Quoted 1 line · Oleh Kuzhylnyi
Add documentation for the Hynitron CST816X touchscreen bindings.
Please use scripts/get_maintainers.pl to get a list of necessary people and lists to CC. It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel.
Tools like b4 or scripts/get_maintainer.pl provide you proper list of people, so fix your workflow. Tools might also fail if you work on some ancient tree (don't, instead use mainline), work on fork of kernel (don't, instead use mainline) or you ignore some maintainers (really don't). Just use b4 and everything should be fine, although remember about b4 prep --auto-to-cc if you added new patches to the patchset.
You missed at least devicetree list (maybe more), so this won't be tested by automated tooling. Performing review on untested code might be a waste of time, thus I will skip this patch entirely till you follow the process allowing the patch to be tested.
Please kindly resend and include all necessary To/Cc entries.
Also incorrect order - bindings come before users.
...
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml line 47
Quoted 9 lines
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml new file +9
-0+ +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + cst816s: cst816s@15 {
Node names should be generic. See also an explanation and list of examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml line 51
Quoted 4 lines
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml new file +4
-0+ compatible = "hynitron,cst816s"; + reg = <0x15>; + interrupt-parent = <&gpio>; + interrupts = <4 1>;
Use proper defines. Why did you include headers if you are not using them?
Quoted 1 line
+ reset-gpios = <&gpio 17 0>;
Same question.
Quoted 1 line
+ status="okay";
Drop.
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml line 57
Quoted 4 lines
Documentation/devicetree/bindings/input/touchscreen/hynitron,cst816x.yaml new file +4
-0+ }; + }; + +...
Best regards,
Krzysztof
Quoted 7 lines · Oleh Kuzhylnyi
Introduce support for the Hynitron CST816X touchscreen controller used for 240×240 1.28-inch Round LCD Display Module manufactured by Waveshare Electronics. The driver is designed based on an Arduino implementation marked as under MIT License. This driver is written for a particular round display based on the CST816S controller, which is not compatiable with existing driver for Hynitron controllers.
...
Quoted 7 lines
drivers/input/touchscreen/hynitron-cst816x.c new file +7
-0+static int cst816x_process_touch (struct cst816x_priv *priv) +{ +u8 *raw; +int rc; + + rc =cst816x_i2c_read_reg (priv,CST816X_FRAME ); +if (!rc) {
drivers/input/touchscreen/hynitron-cst816x.c line 187
Quoted 10 lines
drivers/input/touchscreen/hynitron-cst816x.c new file +10
-0+ raw = priv->rxtx; + + priv->info.gesture = raw[0 ]; + priv->info.x = ((raw[2 ] &0x0F ) <<8 ) | raw[3 ]; + priv->info.y = ((raw[4 ] &0x0F ) <<8 ) | raw[5 ]; + +dev_dbg (priv->dev,"x: %d, y: %d, gesture: 0x%x\n" , + priv->info.x, priv->info.y, priv->info.gesture); + }else { +dev_warn (priv->dev,"request was dropped\n" );
Not a warn. First, it feels like really spamming the log, second, drivers should be moderately quiet.
drivers/input/touchscreen/hynitron-cst816x.c line 200
Quoted 13 lines
drivers/input/touchscreen/hynitron-cst816x.c new file +13
-0+ } + +return rc; +} + +static int cst816x_register_input (struct cst816x_priv *priv) +{ +int rc; + + priv->input =devm_input_allocate_device (priv->dev); +if (!priv->input) { + rc = -ENOMEM ; +dev_err (priv->dev,"input device alloc err: %d\n" , rc);
Memory allocation errors are *never* printk'ed by drivers.
Quoted 2 lines
(quoted diff) +2
-0+ goto err; + }
...
Quoted 14 lines
drivers/input/touchscreen/hynitron-cst816x.c new file +14
-0+static int cst816x_resume (struct device *dev) +{ +struct cst816x_priv *priv =i2c_get_clientdata (to_i2c_client (dev)); +int rc; + +cst816x_reset (priv); + rc =cst816x_regs_setup (priv); +if (!rc) +enable_irq (priv->irq); + +return rc; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(cst816x_pm_ops, cst816x_suspend, cst816x_resume);
drivers/input/touchscreen/hynitron-cst816x.c line 304
Quoted 10 lines
drivers/input/touchscreen/hynitron-cst816x.c new file +10
-0+ +static int cst816x_probe (struct i2c_client *client) +{ +struct cst816x_priv *priv; +struct device *dev = &client->dev; +int rc; + + priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) { + rc = -ENOMEM ;
No, just return.
drivers/input/touchscreen/hynitron-cst816x.c line 305
Quoted 1 line
drivers/input/touchscreen/hynitron-cst816x.c new file +1
-0+dev_err (dev,"devm alloc failed: %d\n" , rc);
No, drop. This is some ancient, downstream code. Do you see anything like this anywhere else?
drivers/input/touchscreen/hynitron-cst816x.c line 317
Quoted 12 lines
drivers/input/touchscreen/hynitron-cst816x.c new file +12
-0+ goto err; + } + +INIT_DELAYED_WORK (&priv->dw, cst816x_dw_cb); +timer_setup (&priv->timer, cst816x_timer_cb,0 ); + + priv->dev = dev; + priv->client = client; + + priv->reset =devm_gpiod_get (dev,"reset" ,GPIOD_OUT_HIGH ); +if (priv->reset ==NULL ) { + rc = -EIO ;
Syntax is return dev_err_probe().
Same everywhere else.
Best regards,
Krzysztof