Add Novatek NT36xxx touchscreen driver
Subsystems (3)
v4 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
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
.../input/touchscreen/novatek,nt36xxx.yaml | 59 ++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + drivers/input/touchscreen/Kconfig | 12 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/nt36xxx.c | 816 ++++++++++++++++++ 5 files changed, 890 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml create mode 100644 drivers/input/touchscreen/nt36xxx.c
Signature · 1 line
2.28.0
PATCH v4 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
Re: [PATCH v4 1/3] dt-bindings: Add vendor prefix for Novatek Microelectronics Corp.
Quoted 9 lines · On Thu, 08 Oct 2020 20:15:12 +0200, [email protected] wrote:
From: AngeloGioacchino Del Regno <[email protected]>
Add prefix for Novatek Microelectronics Corp.
Signed-off-by AngeloGioacchino Del Regno <[email protected]>--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
PATCH v4 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 | 816 ++++++++++++++++++++++++++++ 3 files changed, 829 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 +816 -0
816 lines not on this page · raw message
Signature · 1 line
2.28.0
PATCH v4 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.
--- .../input/touchscreen/novatek,nt36xxx.yaml | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml
Documentation/devicetree/bindings/input/touchscreen/novatek,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/novatek,nt36xxx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Novatek NT36xxx series touchscreen controller Bindings + +maintainers: + - Dmitry Torokhov <[email protected]> + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + const: novatek,nt36xxx + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + reset-gpio: + maxItems: 1 + + vdd-supply: + description: Power supply regulator for VDD pin + + vio-supply: + description: Power supply regulator on VDD-IO pin + +additionalProperties: 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,nt36xxx"; + 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 v4 3/3] dt-bindings: touchscreen: Add binding for Novatek NT36xxx series driver
Quoted 24 lines · On Thu, 8 Oct 2020 at 20:15, <[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]>--- .../input/touchscreen/novatek,nt36xxx.yaml | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yamlDocumentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml new file +7
-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/novatek,nt36xxx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Novatek NT36xxx series touchscreen controller Bindings
Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml line 17
Quoted 10 lines
Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml new file +10
-0+ +maintainers: + - Dmitry Torokhov <[email protected]> + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + const: novatek,nt36xxx
Thanks for the changes, they look good except this part here which I missed before. The compatible should not contain wildcards. If all devices are really compatible, just add here one const, e.g. "const:
novatek,nt36525". If they are different, you could add multiple compatibles in enum.
Best regards,
Krzysztof
Re: [PATCH v4 3/3] dt-bindings: touchscreen: Add binding for Novatek NT36xxx series driver
Il giorno gio 8 ott 2020 alle ore 20:21 Krzysztof Kozlowski <[email protected]> ha scritto:
Quoted 43 lines · On Thu, 8 Oct 2020 at 20:15, <[email protected]> wrote:
Quoted 24 lines
From: AngeloGioacchino Del Regno <[email protected]>
Add binding for the Novatek NT36xxx series touchscreen driver.
Signed-off-by AngeloGioacchino Del Regno <[email protected]>--- .../input/touchscreen/novatek,nt36xxx.yaml | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yamlDocumentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml new file +7
-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/novatek,nt36xxx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Novatek NT36xxx series touchscreen controller BindingsDocumentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml line 17
Quoted 10 lines
Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml new file +10
-0+ +maintainers: + - Dmitry Torokhov <[email protected]> + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + const: novatek,nt36xxxThanks for the changes, they look good except this part here which I missed before. The compatible should not contain wildcards. If all devices are really compatible, just add here one const, e.g. "const:
novatek,nt36525". If they are different, you could add multiple compatibles in enum.
Quoted 2 lines
Best regards,
Krzysztof
They are all managed the same way, but the page addresses are changing between all of them... the driver is reading the chip ID while the TS MCU is in "boot mode", then checking in a ID table if the chip is supported and finally assigning a page address table. This is done for the entire NT36*** series.
If wildcards are not permitted, perhaps I can change it to something like "novatek,nt36" or "novatek,nt36-ts"... as then specifying the specific IC model into the DT means that I would have to logically change the driver itself to also crosscheck a DT-specified model with whatever gets recognized by reading the chip (which then would be a triple check of what's going on, imo overcomplicating the logic).
What would you propose, at this point?
Re: [PATCH v4 3/3] dt-bindings: touchscreen: Add binding for Novatek NT36xxx series driver
Quoted 54 lines · AngeloGioacchino Del Regno
Il giorno gio 8 ott 2020 alle ore 20:21 Krzysztof Kozlowski <[email protected]> ha scritto:
Quoted 43 lines · On Thu, 8 Oct 2020 at 20:15, <[email protected]> wrote:
Quoted 24 lines
From: AngeloGioacchino Del Regno <[email protected]>
Add binding for the Novatek NT36xxx series touchscreen driver.
Signed-off-by AngeloGioacchino Del Regno <[email protected]>--- .../input/touchscreen/novatek,nt36xxx.yaml | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yamlDocumentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml new file +7
-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/novatek,nt36xxx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Novatek NT36xxx series touchscreen controller BindingsDocumentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml line 17
Quoted 10 lines
Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml new file +10
-0+ +maintainers: + - Dmitry Torokhov <[email protected]> + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + const: novatek,nt36xxxThanks for the changes, they look good except this part here which I missed before. The compatible should not contain wildcards. If all devices are really compatible, just add here one const, e.g. "const:
novatek,nt36525". If they are different, you could add multiple compatibles in enum.Quoted 2 lines
Best regards,
KrzysztofThey are all managed the same way, but the page addresses are changing between all of them... the driver is reading the chip ID while the TS MCU is in "boot mode", then checking in a ID table if the chip is supported and finally assigning a page address table. This is done for the entire NT36*** series.
Quoted 8 lines
If wildcards are not permitted, perhaps I can change it to something like "novatek,nt36" or "novatek,nt36-ts"... as then specifying the specific IC model into the DT means that I would have to logically change the driver itself to also crosscheck a DT-specified model with whatever gets recognized by reading the chip (which then would be a triple check of what's going on, imo overcomplicating the logic).
What would you propose, at this point?
If you want the autodetection based on chip ID, then use the oldest/earliest device as compatible, so "novatek,nt36525" and keep everything else as is. In your case the HW description for all devices is the same, thus one compatible is enough. This way if in future you need to bring a difference for a new HW (let's say some imaginary NT36999), you can simply add a new compatible.
Best regards,
Krzysztof
Rob Herring
maintainerRe: [PATCH v4 3/3] dt-bindings: touchscreen: Add binding for Novatek NT36xxx series driver
In reply to AngeloGioacchino Del RegnoQuoted 45 lines · AngeloGioacchino Del Regno
Il giorno gio 8 ott 2020 alle ore 20:21 Krzysztof Kozlowski <[email protected]> ha scritto:
Quoted 43 lines · On Thu, 8 Oct 2020 at 20:15, <[email protected]> wrote:
Quoted 24 lines
From: AngeloGioacchino Del Regno <[email protected]>
Add binding for the Novatek NT36xxx series touchscreen driver.
Signed-off-by AngeloGioacchino Del Regno <[email protected]>--- .../input/touchscreen/novatek,nt36xxx.yaml | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yamlDocumentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml new file +7
-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/novatek,nt36xxx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Novatek NT36xxx series touchscreen controller BindingsDocumentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml line 17
Quoted 10 lines
Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml new file +10
-0+ +maintainers: + - Dmitry Torokhov <[email protected]> + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + const: novatek,nt36xxxThanks for the changes, they look good except this part here which I missed before. The compatible should not contain wildcards. If all devices are really compatible, just add here one const, e.g. "const:
novatek,nt36525". If they are different, you could add multiple compatibles in enum.
Quoted 8 lines
Quoted 2 lines
Best regards,
KrzysztofThey are all managed the same way, but the page addresses are changing between all of them... the driver is reading the chip ID while the TS MCU is in "boot mode", then checking in a ID table if the chip is supported and finally assigning a page address table. This is done for the entire NT36*** series.
The important part is whether everything needed to read the chip ID is identical? Same power supplies and sequencing, clocks, resets, enables, etc.? If any of those vary then you'll need something more specific. You can always have a common fallback.
Rob
Rob Herring
maintainerRe: [PATCH v4 3/3] dt-bindings: touchscreen: Add binding for Novatek NT36xxx series driver
In reply to [email protected]Quoted 16 lines · On Thu, Oct 08, 2020 at 08:15:14PM +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]>--- .../input/touchscreen/novatek,nt36xxx.yaml | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yamlDocumentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml new file +0
-0
Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml line 10
Quoted 10 lines
Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml new file +10
-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/novatek,nt36xxx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Novatek NT36xxx series touchscreen controller Bindings + +maintainers: + - Dmitry Torokhov <[email protected]>
This should be an owner for this device, not subsystem maintainers.
Quoted 5 lines
Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml new file +5
-0+ +allOf: + - $ref: touchscreen.yaml# + +properties:
Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml line 25
Quoted 10 lines
Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml new file +10
-0+ compatible: + const: novatek,nt36xxx + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + reset-gpio:
reset-gpios
Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml line 34
Quoted 9 lines
Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml new file +9
-0+ maxItems: 1 + + vdd-supply: + description: Power supply regulator for VDD pin + + vio-supply: + description: Power supply regulator on VDD-IO pin + +additionalProperties: false
This won't work with the ref to touchscreen.yaml. Use 'unevaluatedProperties: false' instead.
Quoted 28 lines
Documentation/devicetree/bindings/input/touchscreen/novatek,nt36xxx.yaml new file +25
-0+ +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,nt36xxx"; + reg = <0x62>; + interrupt-parent = <&tlmm>; + interrupts = <45 IRQ_TYPE_EDGE_RISING>; + reset-gpio = <&tlmm 102 GPIO_ACTIVE_HIGH>; + }; + }; + +...Signature · 1 line
2.28.0