Add Novatek NT36xxx touchscreen driver
Subsystems (3)
v7 cover Add Novatek NT36xxx touchscreen driver
From: AngeloGioacchino Del Regno <[email protected]>
This patch series adds support for the Novatek NT36xxx Series' In-Cell touchscreen (integrated into the DriverIC).
This patch series has been tested against the following devices:
- Sony Xperia 10 (SDM630 Ganges Kirin)
- Sony Xperia 10 Plus (SDM636 Ganges Mermaid)
Changes in v2:
- Fixed sparse warnings from lkp kernel test robot
Changes in v3 (as requested by Dmitry Torokhov):
- Using shorthand u16/u32 (sorry for the overlook!)
- Now using more input and touchscreen APIs
- Fixed useless workqueue involvements
- Removed useless locking
- Switched reads and writes to use regmap
- Moved header contents to nt36xxx.c
- Fixed reset gpio handling
- Other cleanups
- P.S.: Thanks, Dmitry!
Changes in v4:
- Fixed regmap read length for CRC_ERR_FLAG final check
- Fixed YAML binding, as requested by Krzysztof Kozlowski
Changes in v5:
- Replaced subsystem maintainer's name with .. mine, usage of additionalProperties to unevaluatedProperties and a typo fix for reset-gpios as per Rob Herring's review
- Changed compatible string as per Krzysztof K. request
- Renamed the novatek,nt36xxx.yaml file to just nt36xxx.yaml in order to now reflect the driver name instead of the DT compatible
- Fixed blank line at EOF
Changes in v6:
- Removed include of_gpio.h, added mod_devicetable.h and gpio/consumer.h
- Added kerneldoc to relevant functions/enum
- Used traditional patterns for error checking where possible
- Documented calls to usleep/msleep
- Using be16_to_cpu / get_unaligned_be16 where possible
- Added helper for CRC error check on retrieved buffer
- Decreased indentation in the CRC reboot recovery function
- Removed instances of error code sum
- Dropped all likely/unlikely optimization as per request
- Removed redundant reset_gpio checks
- Dropped of_match_ptr and ifdefs for CONFIG_OF
Changes in v7:
- Fixed typo in nt36xxx.c
AngeloGioacchino Del Regno (3):
dt-bindings: Add vendor prefix for Novatek Microelectronics Corp.
Input: Add Novatek NT36xxx touchscreen driver
dt-bindings: touchscreen: Add binding for Novatek NT36xxx series
driver
.../bindings/input/touchscreen/nt36xxx.yaml | 59 ++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + drivers/input/touchscreen/Kconfig | 12 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/nt36xxx.c | 895 ++++++++++++++++++ 5 files changed, 969 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/nt36xxx.yaml create mode 100644 drivers/input/touchscreen/nt36xxx.c
Signature · 1 line
2.28.0
PATCH v7 1/3 dt-bindings: Add vendor prefix for Novatek Microelectronics Corp.
From: AngeloGioacchino Del Regno <[email protected]>
Add prefix for Novatek Microelectronics Corp.
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -740,6 +740,8 @@ patternProperties: description: Nokia "^nordic,.*": description: Nordic Semiconductor + "^novatek,.*": + description: Novatek Microelectronics Corp. "^novtech,.*": description: NovTech, Inc. "^nutsboard,.*":
Signature · 1 line
2.28.0
PATCH v7 2/3 Input: Add Novatek NT36xxx touchscreen driver
In reply to [email protected]From: AngeloGioacchino Del Regno <[email protected]>
This is a driver for the Novatek in-cell touch controller and supports various chips from the NT36xxx family, currently including NT36525, NT36672A, NT36676F, NT36772 and NT36870.
Functionality like wake gestures and firmware flashing is not
included: I am not aware of any of these DrIC+Touch combo chips not including a non-volatile memory and it should be highly unlikely to find one, since the touch firmware is embedded into the DriverIC one, which is obviously necessary to drive the display unit.
However, the necessary address for the firmware update procedure was included into the address table in this driver so, in the event that someone finds the need to implement it for a reason or another, it will be pretty straightforward to.
This driver is lightly based on the downstream implementation [1].
[1] https://github.com/Rasenkai/caf-tsoft-Novatek-nt36xxx
--- drivers/input/touchscreen/Kconfig | 12 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/nt36xxx.c | 895 ++++++++++++++++++++++++++++ 3 files changed, 908 insertions(+) create mode 100644 drivers/input/touchscreen/nt36xxx.c
drivers/input/touchscreen/Kconfig +12 -0
@@ -605,6 +605,18 @@ config TOUCHSCREEN_MTOUCH To compile this driver as a module, choose M here: the module will be called mtouch. +config TOUCHSCREEN_NT36XXX + tristate "Novatek NT36XXX In-Cell I2C touchscreen controller" + depends on I2C + help + Say Y here if you have a Novatek NT36xxx series In-Cell + touchscreen connected to your system over I2C. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called nt36xxx. + config TOUCHSCREEN_IMX6UL_TSC tristate "Freescale i.MX6UL touchscreen controller" depends on (OF && GPIOLIB) || COMPILE_TEST
drivers/input/touchscreen/Makefile +1 -0
@@ -61,6 +61,7 @@ obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o obj-$(CONFIG_TOUCHSCREEN_MMS114) += mms114.o obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o +obj-$(CONFIG_TOUCHSCREEN_NT36XXX) += nt36xxx.o obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o obj-$(CONFIG_TOUCHSCREEN_HP7XX) += jornada720_ts.o obj-$(CONFIG_TOUCHSCREEN_IPAQ_MICRO) += ipaq-micro-ts.o
drivers/input/touchscreen/nt36xxx.c new file +895 -0
895 lines not on this page · raw message
Signature · 1 line
2.28.0
Re: [PATCH v7 2/3] Input: Add Novatek NT36xxx touchscreen driver
Quoted 14 lines · On Sat, Oct 24, 2020 at 1:51 PM <[email protected]> wrote:
From: AngeloGioacchino Del Regno <[email protected]>
This is a driver for the Novatek in-cell touch controller and supports various chips from the NT36xxx family, currently including NT36525, NT36672A, NT36676F, NT36772 and NT36870.
Functionality like wake gestures and firmware flashing is not
included: I am not aware of any of these DrIC+Touch combo chips not including a non-volatile memory and it should be highly unlikely to find one, since the touch firmware is embedded into the DriverIC one, which is obviously necessary to drive the display unit.
Quoted 7 lines
However, the necessary address for the firmware update procedure was included into the address table in this driver so, in the event that someone finds the need to implement it for a reason or another, it will be pretty straightforward to.
This driver is lightly based on the downstream implementation [1].
[1] https://github.com/Rasenkai/caf-tsoft-Novatek-nt36xxx
(From drafts, didn't have time to finish and see already v8, so please revisit)
...
drivers/input/touchscreen/nt36xxx.c line 19
Quoted 11 lines
drivers/input/touchscreen/nt36xxx.c new file +11
-0+#include <asm/unaligned.h> +#include <linux/delay.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/regmap.h> +#include <linux/gpio/consumer.h> +#include <linux/input/mt.h> +#include <linux/input/touchscreen.h> +#include <linux/regulator/consumer.h>
Perhaps sorted? Also, asm/* usually go after linux/*.
...
Quoted 1 line
+#define
TOUCH_MAX_PRESSURE1000
Any units?
...
Quoted 1 line
+ ts =
devm_kzalloc(&hw_client->dev, sizeof(struct nt36xxx_i2c), GFP_KERNEL);
sizeof(*ts) ?
drivers/input/touchscreen/nt36xxx.c line 685
Quoted 7 lines
drivers/input/touchscreen/nt36xxx.c new file +6
-0+if (!ts) +return -ENOMEM ; + + ts->supplies = devm_kcalloc(&hw_client->dev, + NT36XXX_NUM_SUPPLIES, + sizeof(struct regulator_bulk_data),
sizeof(*ts->supplies) ?
Quoted 3 lines
drivers/input/touchscreen/nt36xxx.c new file +3
-0+ GFP_KERNEL); +if (!ts->supplies) +return -ENOMEM ;
...
drivers/input/touchscreen/nt36xxx.c line 718
Quoted 5 lines
drivers/input/touchscreen/nt36xxx.c new file +4
-0+ ret =devm_regulator_bulk_get (&hw_client->dev, +NT36XXX_NUM_SUPPLIES , + ts->supplies); +if (ret !=0 ) {
if (ret)
Quoted 5 lines
drivers/input/touchscreen/nt36xxx.c new file +5
-0+if (ret != -EPROBE_DEFER ) +dev_err (&hw_client->dev, +"Cannot get supplies: %d\n" , ret); +return ret; + }
...
drivers/input/touchscreen/nt36xxx.c line 775
Quoted 2 lines
drivers/input/touchscreen/nt36xxx.c new file +2
-0+ input->phys =devm_kasprintf (&hw_client->dev,GFP_KERNEL , +"%s/input0" ,dev_name (&hw_client->dev));
NULL check?
...
drivers/input/touchscreen/nt36xxx.c line 821
Quoted 10 lines
drivers/input/touchscreen/nt36xxx.c new file +9
-0+ ret =devm_request_threaded_irq (&hw_client->dev, hw_client->irq,NULL , + nt36xxx_i2c_irq_handler,IRQF_ONESHOT , + hw_client->name, ts); +if (ret) { +dev_err (&hw_client->dev,"request irq failed: %d\n" , ret); +return ret; + } + +return 0 ;
return ret; ?
Quoted 1 line
+}
--
With Best Regards,
Andy Shevchenko
PATCH v7 3/3 dt-bindings: touchscreen: Add binding for Novatek NT36xxx series driver
In reply to [email protected]From: AngeloGioacchino Del Regno <[email protected]>
Add binding for the Novatek NT36xxx series touchscreen driver.
--- .../bindings/input/touchscreen/nt36xxx.yaml | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/nt36xxx.yaml
Documentation/devicetree/bindings/input/touchscreen/nt36xxx.yaml new file +59 -0
@@ -0,0 +1,59 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/nt36xxx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Novatek NT36xxx series touchscreen controller Bindings + +maintainers: + - AngeloGioacchino Del Regno <[email protected]> + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + const: novatek,nt36525 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + reset-gpios: + maxItems: 1 + + vdd-supply: + description: Power supply regulator for VDD pin + + vio-supply: + description: Power supply regulator on VDD-IO pin + +unevaluatedProperties: false + +required: + - compatible + - reg + - interrupts + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/gpio/gpio.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + touchscreen@62 { + compatible = "novatek,nt36525"; + reg = <0x62>; + interrupt-parent = <&tlmm>; + interrupts = <45 IRQ_TYPE_EDGE_RISING>; + reset-gpio = <&tlmm 102 GPIO_ACTIVE_HIGH>; + }; + }; + +...
Signature · 1 line
2.28.0
Re: [PATCH v7 3/3] dt-bindings: touchscreen: Add binding for Novatek NT36xxx series driver
Quoted 61 lines · On Sat, Oct 24, 2020 at 12:51:11PM +0200, [email protected] wrote:
From: AngeloGioacchino Del Regno <[email protected]>
Add binding for the Novatek NT36xxx series touchscreen driver.
Signed-off-by AngeloGioacchino Del Regno <[email protected]>--- .../bindings/input/touchscreen/nt36xxx.yaml | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/nt36xxx.yamlDocumentation/devicetree/bindings/input/touchscreen/nt36xxx.yaml new file +45
-0@@ -0,0 +1,59 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/nt36xxx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Novatek NT36xxx series touchscreen controller Bindings + +maintainers: + - AngeloGioacchino Del Regno <[email protected]> + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + const: novatek,nt36525 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + reset-gpios: + maxItems: 1 + + vdd-supply: + description: Power supply regulator for VDD pin + + vio-supply: + description: Power supply regulator on VDD-IO pin + +unevaluatedProperties: false + +required: + - compatible + - reg + - interrupts + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/gpio/gpio.h> +
Documentation/devicetree/bindings/input/touchscreen/nt36xxx.yaml line 55
Quoted 10 lines
Documentation/devicetree/bindings/input/touchscreen/nt36xxx.yaml new file +10
-0+ i2c { + #address-cells = <1>; + #size-cells = <0>; + + touchscreen@62 { + compatible = "novatek,nt36525"; + reg = <0x62>; + interrupt-parent = <&tlmm>; + interrupts = <45 IRQ_TYPE_EDGE_RISING>; + reset-gpio = <&tlmm 102 GPIO_ACTIVE_HIGH>;
The same as for v5 - reset-gpios.
Best regards,
Krzysztof