* [PATCH 1/3] dt-bindings: Add Hycon Technology vendor prefix [not found] <20210305163834.70924-1-giulio.benetti@benettiengineering.com> @ 2021-03-05 16:38 ` Giulio Benetti 2021-03-05 17:25 ` Jonathan Neuschäfer 2021-03-05 16:38 ` [PATCH 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-03-05 16:38 ` [PATCH " Giulio Benetti 2 siblings, 1 reply; 69+ messages in thread From: Giulio Benetti @ 2021-03-05 16:38 UTC (permalink / raw) To: Rob Herring; +Cc: Giulio Benetti, Rob Herring, devicetree, linux-kernel From: Giulio Benetti <giulio.benetti@micronovasrl.com> Update Documentation/devicetree/bindings/vendor-prefixes.yaml to include "hycon" as a vendor prefix for "Hycon Technology". Company website: http://www.hycontek.com/ Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.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 a1312637d6ff..51b00aa96dff 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -488,6 +488,8 @@ patternProperties: "^hugsun,.*": description: Shenzhen Hugsun Technology Co. Ltd. "^hwacom,.*": + description: Hycon Technology Corp. + "^hycon,.*": description: HwaCom Systems Inc. "^hydis,.*": description: Hydis Technologies -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 1/3] dt-bindings: Add Hycon Technology vendor prefix 2021-03-05 16:38 ` [PATCH 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti @ 2021-03-05 17:25 ` Jonathan Neuschäfer 2021-03-05 17:33 ` Giulio Benetti 0 siblings, 1 reply; 69+ messages in thread From: Jonathan Neuschäfer @ 2021-03-05 17:25 UTC (permalink / raw) To: Giulio Benetti Cc: Rob Herring, Giulio Benetti, Rob Herring, devicetree, linux-kernel [-- Attachment #1: Type: text/plain, Size: 1266 bytes --] Hello, On Fri, Mar 05, 2021 at 05:38:32PM +0100, Giulio Benetti wrote: > From: Giulio Benetti <giulio.benetti@micronovasrl.com> > > Update Documentation/devicetree/bindings/vendor-prefixes.yaml to > include "hycon" as a vendor prefix for "Hycon Technology". > Company website: http://www.hycontek.com/ As far as I can see, https would be possible here. > Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.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 a1312637d6ff..51b00aa96dff 100644 > --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml > +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml > @@ -488,6 +488,8 @@ patternProperties: > "^hugsun,.*": > description: Shenzhen Hugsun Technology Co. Ltd. > "^hwacom,.*": > + description: Hycon Technology Corp. > + "^hycon,.*": > description: HwaCom Systems Inc. This is the wrong way around. You declared "hwacom," to mean "Hycon Technology Corp.", and "hycon," to mean "HwaCom Systems Inc.". Best regards, Jonathan Neuschäfer [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 1/3] dt-bindings: Add Hycon Technology vendor prefix 2021-03-05 17:25 ` Jonathan Neuschäfer @ 2021-03-05 17:33 ` Giulio Benetti 2021-03-05 19:32 ` Giulio Benetti 0 siblings, 1 reply; 69+ messages in thread From: Giulio Benetti @ 2021-03-05 17:33 UTC (permalink / raw) To: Jonathan Neuschäfer, Giulio Benetti Cc: Rob Herring, Rob Herring, devicetree, linux-kernel Hi Jonathan, Il 05/03/2021 18:25, Jonathan Neuschäfer ha scritto: > Hello, > > On Fri, Mar 05, 2021 at 05:38:32PM +0100, Giulio Benetti wrote: >> From: Giulio Benetti <giulio.benetti@micronovasrl.com> >> >> Update Documentation/devicetree/bindings/vendor-prefixes.yaml to >> include "hycon" as a vendor prefix for "Hycon Technology". >> Company website: http://www.hycontek.com/ > > As far as I can see, https would be possible here. +1 >> Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.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 a1312637d6ff..51b00aa96dff 100644 >> --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml >> +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml >> @@ -488,6 +488,8 @@ patternProperties: >> "^hugsun,.*": >> description: Shenzhen Hugsun Technology Co. Ltd. >> "^hwacom,.*": >> + description: Hycon Technology Corp. >> + "^hycon,.*": >> description: HwaCom Systems Inc. > > This is the wrong way around. You declared "hwacom," to mean "Hycon > Technology Corp.", and "hycon," to mean "HwaCom Systems Inc.". > Thank you, I've modified it and I'll send a v2 with the rest of patchset. Best regards -- Giulio Benetti CTO MICRONOVA SRL Sede: Via A. Niedda 3 - 35010 Vigonza (PD) Tel. 049/8931563 - Fax 049/8931346 Cod.Fiscale - P.IVA 02663420285 Capitale Sociale € 26.000 i.v. Iscritta al Reg. Imprese di Padova N. 02663420285 Numero R.E.A. 258642 ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 1/3] dt-bindings: Add Hycon Technology vendor prefix 2021-03-05 17:33 ` Giulio Benetti @ 2021-03-05 19:32 ` Giulio Benetti 0 siblings, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-03-05 19:32 UTC (permalink / raw) To: Giulio Benetti, Jonathan Neuschäfer Cc: Rob Herring, Rob Herring, devicetree, linux-kernel, Dmitry Torokhov +Cc Dmitry On 3/5/21 6:33 PM, Giulio Benetti wrote: > Hi Jonathan, > > Il 05/03/2021 18:25, Jonathan Neuschäfer ha scritto: >> Hello, >> >> On Fri, Mar 05, 2021 at 05:38:32PM +0100, Giulio Benetti wrote: >>> From: Giulio Benetti <giulio.benetti@micronovasrl.com> >>> >>> Update Documentation/devicetree/bindings/vendor-prefixes.yaml to >>> include "hycon" as a vendor prefix for "Hycon Technology". >>> Company website: http://www.hycontek.com/ >> >> As far as I can see, https would be possible here. > > +1 > >>> Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.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 a1312637d6ff..51b00aa96dff 100644 >>> --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml >>> +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml >>> @@ -488,6 +488,8 @@ patternProperties: >>> "^hugsun,.*": >>> description: Shenzhen Hugsun Technology Co. Ltd. >>> "^hwacom,.*": >>> + description: Hycon Technology Corp. >>> + "^hycon,.*": >>> description: HwaCom Systems Inc. >> >> This is the wrong way around. You declared "hwacom," to mean "Hycon >> Technology Corp.", and "hycon," to mean "HwaCom Systems Inc.". >> > > Thank you, I've modified it and I'll send a v2 with the rest of > patchset. > > Best regards > -- Giulio Benetti Benetti Engineering sas ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 2/3] dt-bindings: touchscreen: Add HY46XX bindings [not found] <20210305163834.70924-1-giulio.benetti@benettiengineering.com> 2021-03-05 16:38 ` [PATCH 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti @ 2021-03-05 16:38 ` Giulio Benetti 2021-03-05 19:34 ` Giulio Benetti ` (2 more replies) 2021-03-05 16:38 ` [PATCH " Giulio Benetti 2 siblings, 3 replies; 69+ messages in thread From: Giulio Benetti @ 2021-03-05 16:38 UTC (permalink / raw) To: Giulio Benetti, Dmitry Torokhov, Rob Herring Cc: linux-input, devicetree, linux-kernel From: Giulio Benetti <giulio.benetti@micronovasrl.com> This adds device tree bindings for the Hycon HY46XX touchscreen series. Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com> --- .../input/touchscreen/hycon,hy46xx.yaml | 130 ++++++++++++++++++ MAINTAINERS | 6 + 2 files changed, 136 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml diff --git a/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml new file mode 100644 index 000000000000..cddd5e5bae92 --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml @@ -0,0 +1,130 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/hycon-hy46xx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: hyconon HY46XX series touchscreen controller Bindings + +description: | + There are 6 variants of the chip for various touch panel sizes and coverl len material + Glass: 0.3mm--4.0mm + PET/PMMA: 0.2mm--2.0mm + HY4613(B)-N048 < 6" + HY4614(B)-N068 7" .. 10.1" + HY4621-NS32 < 5" + HY4623-NS48 5.1" .. 7" + Glass: 0.3mm--8.0mm + PET/PMMA: 0.2mm--4.0mm + HY4633(B)-N048 < 6" + HY4635(B)-N048 < 7" .. 10.1" + +maintainers: + - Giulio Benetti <giulio.benetti@micronovasrl.com> + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + enum: + - hycon,hycon-hy4613 + - hycon,hycon-hy4614 + - hycon,hycon-hy4621 + - hycon,hycon-hy4623 + - hycon,hycon-hy4633 + - hycon,hycon-hy4635 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + reset-gpios: + maxItems: 1 + + vcc-supply: true + + threshold: + description: Allows setting the sensitivity in the range from 0 to 255. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 255 + + proximity-sensor-switch: + description: Allows enabling or disabling the Proximity Sensor. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 1 + + glove-enable: + description: Allows enabling or disabling glove setting. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 1 + + report-speed: + description: Allows setting the report speed(i.e 0x64 => 100Hz). + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 255 + + power-noise-enable: + description: Allows enabling or disabling power noise filter. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 1 + + filter-data: + description: Allows setting the filtering data before reporting touch + in the range from 0 to 5. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 5 + + gain: + description: Allows setting the sensitivity distance in the range from 0 to 5. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 5 + + edge-offset: + description: Allows setting the edge compensation in the range from 0 to 16. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 16 + + 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 + interrupt-controller: true + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + hycon-hy4633@1c { + compatible = "hycon,hy4633"; + reg = <0x1c>; + interrupt-parent = <&gpio2>; + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; + }; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index d92f85ca831d..3f83daf6b2bf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8245,6 +8245,12 @@ S: Maintained F: mm/hwpoison-inject.c F: mm/memory-failure.c +HYCON HY46XX TOUCHSCREEN SUPPORT +M: Giulio Benetti <giulio.benetti@micronovasrl.com> +L: linux-input@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml + HYGON PROCESSOR SUPPORT M: Pu Wen <puwen@hygon.cn> L: linux-kernel@vger.kernel.org -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-03-05 16:38 ` [PATCH 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti @ 2021-03-05 19:34 ` Giulio Benetti 2021-03-06 19:28 ` Rob Herring 2021-03-06 19:41 ` Rob Herring 2 siblings, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-03-05 19:34 UTC (permalink / raw) To: Giulio Benetti, Dmitry Torokhov, Rob Herring Cc: linux-input, devicetree, linux-kernel, Dmitry Torokhov Adding +CC Dmitry -- Giulio Benetti CTO MICRONOVA SRL Sede: Via A. Niedda 3 - 35010 Vigonza (PD) Tel. 049/8931563 - Fax 049/8931346 Cod.Fiscale - P.IVA 02663420285 Capitale Sociale € 26.000 i.v. Iscritta al Reg. Imprese di Padova N. 02663420285 Numero R.E.A. 258642 Il 05/03/2021 17:38, Giulio Benetti ha scritto: > From: Giulio Benetti <giulio.benetti@micronovasrl.com> > > This adds device tree bindings for the Hycon HY46XX touchscreen series. > > Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com> > --- > .../input/touchscreen/hycon,hy46xx.yaml | 130 ++++++++++++++++++ > MAINTAINERS | 6 + > 2 files changed, 136 insertions(+) > create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > > diff --git a/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > new file mode 100644 > index 000000000000..cddd5e5bae92 > --- /dev/null > +++ b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > @@ -0,0 +1,130 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/input/touchscreen/hycon-hy46xx.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: hyconon HY46XX series touchscreen controller Bindings > + > +description: | > + There are 6 variants of the chip for various touch panel sizes and coverl len material > + Glass: 0.3mm--4.0mm > + PET/PMMA: 0.2mm--2.0mm > + HY4613(B)-N048 < 6" > + HY4614(B)-N068 7" .. 10.1" > + HY4621-NS32 < 5" > + HY4623-NS48 5.1" .. 7" > + Glass: 0.3mm--8.0mm > + PET/PMMA: 0.2mm--4.0mm > + HY4633(B)-N048 < 6" > + HY4635(B)-N048 < 7" .. 10.1" > + > +maintainers: > + - Giulio Benetti <giulio.benetti@micronovasrl.com> > + > +allOf: > + - $ref: touchscreen.yaml# > + > +properties: > + compatible: > + enum: > + - hycon,hycon-hy4613 > + - hycon,hycon-hy4614 > + - hycon,hycon-hy4621 > + - hycon,hycon-hy4623 > + - hycon,hycon-hy4633 > + - hycon,hycon-hy4635 > + > + reg: > + maxItems: 1 > + > + interrupts: > + maxItems: 1 > + > + reset-gpios: > + maxItems: 1 > + > + vcc-supply: true > + > + threshold: > + description: Allows setting the sensitivity in the range from 0 to 255. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 255 > + > + proximity-sensor-switch: > + description: Allows enabling or disabling the Proximity Sensor. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 1 > + > + glove-enable: > + description: Allows enabling or disabling glove setting. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 1 > + > + report-speed: > + description: Allows setting the report speed(i.e 0x64 => 100Hz). > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 255 > + > + power-noise-enable: > + description: Allows enabling or disabling power noise filter. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 1 > + > + filter-data: > + description: Allows setting the filtering data before reporting touch > + in the range from 0 to 5. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 5 > + > + gain: > + description: Allows setting the sensitivity distance in the range from 0 to 5. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 5 > + > + edge-offset: > + description: Allows setting the edge compensation in the range from 0 to 16. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 16 > + > + 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 > + interrupt-controller: true > + > +additionalProperties: false > + > +required: > + - compatible > + - reg > + - interrupts > + > +examples: > + - | > + #include <dt-bindings/gpio/gpio.h> > + #include <dt-bindings/interrupt-controller/arm-gic.h> > + i2c { > + #address-cells = <1>; > + #size-cells = <0>; > + hycon-hy4633@1c { > + compatible = "hycon,hy4633"; > + reg = <0x1c>; > + interrupt-parent = <&gpio2>; > + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; > + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; > + }; > + }; > + > +... > diff --git a/MAINTAINERS b/MAINTAINERS > index d92f85ca831d..3f83daf6b2bf 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -8245,6 +8245,12 @@ S: Maintained > F: mm/hwpoison-inject.c > F: mm/memory-failure.c > > +HYCON HY46XX TOUCHSCREEN SUPPORT > +M: Giulio Benetti <giulio.benetti@micronovasrl.com> > +L: linux-input@vger.kernel.org > +S: Maintained > +F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > + > HYGON PROCESSOR SUPPORT > M: Pu Wen <puwen@hygon.cn> > L: linux-kernel@vger.kernel.org > ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-03-05 16:38 ` [PATCH 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-03-05 19:34 ` Giulio Benetti @ 2021-03-06 19:28 ` Rob Herring 2021-03-06 19:41 ` Rob Herring 2 siblings, 0 replies; 69+ messages in thread From: Rob Herring @ 2021-03-06 19:28 UTC (permalink / raw) To: Giulio Benetti Cc: linux-input, Rob Herring, devicetree, linux-kernel, Dmitry Torokhov, Giulio Benetti On Fri, 05 Mar 2021 17:38:33 +0100, Giulio Benetti wrote: > From: Giulio Benetti <giulio.benetti@micronovasrl.com> > > This adds device tree bindings for the Hycon HY46XX touchscreen series. > > Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com> > --- > .../input/touchscreen/hycon,hy46xx.yaml | 130 ++++++++++++++++++ > MAINTAINERS | 6 + > 2 files changed, 136 insertions(+) > create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > My bot found errors running 'make dt_binding_check' on your patch: yamllint warnings/errors: dtschema/dtc warnings/errors: ./Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml: $id: relative path/filename doesn't match actual path or filename expected: http://devicetree.org/schemas/input/touchscreen/hycon,hy46xx.yaml# See https://patchwork.ozlabs.org/patch/1448030 This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1. If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date: pip3 install dtschema --upgrade Please check and re-submit. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-03-05 16:38 ` [PATCH 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-03-05 19:34 ` Giulio Benetti 2021-03-06 19:28 ` Rob Herring @ 2021-03-06 19:41 ` Rob Herring 2021-04-01 18:37 ` Giulio Benetti 2021-04-01 23:03 ` [PATCH v2 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2 siblings, 2 replies; 69+ messages in thread From: Rob Herring @ 2021-03-06 19:41 UTC (permalink / raw) To: Giulio Benetti Cc: Giulio Benetti, Dmitry Torokhov, linux-input, devicetree, linux-kernel On Fri, Mar 05, 2021 at 05:38:33PM +0100, Giulio Benetti wrote: > From: Giulio Benetti <giulio.benetti@micronovasrl.com> > > This adds device tree bindings for the Hycon HY46XX touchscreen series. > > Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com> > --- > .../input/touchscreen/hycon,hy46xx.yaml | 130 ++++++++++++++++++ > MAINTAINERS | 6 + > 2 files changed, 136 insertions(+) > create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > > diff --git a/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > new file mode 100644 > index 000000000000..cddd5e5bae92 > --- /dev/null > +++ b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > @@ -0,0 +1,130 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/input/touchscreen/hycon-hy46xx.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: hyconon HY46XX series touchscreen controller Bindings > + > +description: | > + There are 6 variants of the chip for various touch panel sizes and coverl len material > + Glass: 0.3mm--4.0mm > + PET/PMMA: 0.2mm--2.0mm > + HY4613(B)-N048 < 6" > + HY4614(B)-N068 7" .. 10.1" > + HY4621-NS32 < 5" > + HY4623-NS48 5.1" .. 7" > + Glass: 0.3mm--8.0mm > + PET/PMMA: 0.2mm--4.0mm > + HY4633(B)-N048 < 6" > + HY4635(B)-N048 < 7" .. 10.1" > + > +maintainers: > + - Giulio Benetti <giulio.benetti@micronovasrl.com> > + > +allOf: > + - $ref: touchscreen.yaml# > + > +properties: > + compatible: > + enum: > + - hycon,hycon-hy4613 > + - hycon,hycon-hy4614 > + - hycon,hycon-hy4621 > + - hycon,hycon-hy4623 > + - hycon,hycon-hy4633 > + - hycon,hycon-hy4635 > + > + reg: > + maxItems: 1 > + > + interrupts: > + maxItems: 1 > + > + reset-gpios: > + maxItems: 1 > + > + vcc-supply: true > + > + threshold: Needs a vendor prefix here and all the custom properties. One of the touchscreen properties doesn't already address this? > + description: Allows setting the sensitivity in the range from 0 to 255. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 255 > + > + proximity-sensor-switch: Why a switch rather than enable or disable? > + description: Allows enabling or disabling the Proximity Sensor. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 1 Is this a hardware config or something a user would want to change at runtime? The latter shouldn't be in DT. What does not present mean? Unless there is a need for keeping the default setting, then this could be boolean instead. Same questions for the rest of the properties. > + > + glove-enable: > + description: Allows enabling or disabling glove setting. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 1 > + > + report-speed: > + description: Allows setting the report speed(i.e 0x64 => 100Hz). > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 255 > + > + power-noise-enable: > + description: Allows enabling or disabling power noise filter. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 1 > + > + filter-data: > + description: Allows setting the filtering data before reporting touch > + in the range from 0 to 5. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 5 > + > + gain: > + description: Allows setting the sensitivity distance in the range from 0 to 5. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 5 > + > + edge-offset: > + description: Allows setting the edge compensation in the range from 0 to 16. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 16 > + > + 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 > + interrupt-controller: true > + > +additionalProperties: false > + > +required: > + - compatible > + - reg > + - interrupts > + > +examples: > + - | > + #include <dt-bindings/gpio/gpio.h> > + #include <dt-bindings/interrupt-controller/arm-gic.h> > + i2c { > + #address-cells = <1>; > + #size-cells = <0>; > + hycon-hy4633@1c { > + compatible = "hycon,hy4633"; > + reg = <0x1c>; > + interrupt-parent = <&gpio2>; > + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; > + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; > + }; > + }; > + > +... > diff --git a/MAINTAINERS b/MAINTAINERS > index d92f85ca831d..3f83daf6b2bf 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -8245,6 +8245,12 @@ S: Maintained > F: mm/hwpoison-inject.c > F: mm/memory-failure.c > > +HYCON HY46XX TOUCHSCREEN SUPPORT > +M: Giulio Benetti <giulio.benetti@micronovasrl.com> > +L: linux-input@vger.kernel.org > +S: Maintained > +F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > + > HYGON PROCESSOR SUPPORT > M: Pu Wen <puwen@hygon.cn> > L: linux-kernel@vger.kernel.org > -- > 2.25.1 > ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-03-06 19:41 ` Rob Herring @ 2021-04-01 18:37 ` Giulio Benetti 2021-04-01 22:24 ` Giulio Benetti 2021-04-01 23:03 ` [PATCH v2 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 1 sibling, 1 reply; 69+ messages in thread From: Giulio Benetti @ 2021-04-01 18:37 UTC (permalink / raw) To: Rob Herring, Giulio Benetti Cc: Dmitry Torokhov, linux-input, devicetree, linux-kernel Hello Rob, All, Il 06/03/2021 20:41, Rob Herring ha scritto: > On Fri, Mar 05, 2021 at 05:38:33PM +0100, Giulio Benetti wrote: >> From: Giulio Benetti <giulio.benetti@micronovasrl.com> >> >> This adds device tree bindings for the Hycon HY46XX touchscreen series. >> >> Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com> >> --- >> .../input/touchscreen/hycon,hy46xx.yaml | 130 ++++++++++++++++++ >> MAINTAINERS | 6 + >> 2 files changed, 136 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> >> diff --git a/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> new file mode 100644 >> index 000000000000..cddd5e5bae92 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> @@ -0,0 +1,130 @@ >> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) >> +%YAML 1.2 >> +--- >> +$id: http://devicetree.org/schemas/input/touchscreen/hycon-hy46xx.yaml# >> +$schema: http://devicetree.org/meta-schemas/core.yaml# >> + >> +title: hyconon HY46XX series touchscreen controller Bindings >> + >> +description: | >> + There are 6 variants of the chip for various touch panel sizes and coverl len material >> + Glass: 0.3mm--4.0mm >> + PET/PMMA: 0.2mm--2.0mm >> + HY4613(B)-N048 < 6" >> + HY4614(B)-N068 7" .. 10.1" >> + HY4621-NS32 < 5" >> + HY4623-NS48 5.1" .. 7" >> + Glass: 0.3mm--8.0mm >> + PET/PMMA: 0.2mm--4.0mm >> + HY4633(B)-N048 < 6" >> + HY4635(B)-N048 < 7" .. 10.1" >> + >> +maintainers: >> + - Giulio Benetti <giulio.benetti@micronovasrl.com> >> + >> +allOf: >> + - $ref: touchscreen.yaml# >> + >> +properties: >> + compatible: >> + enum: >> + - hycon,hycon-hy4613 >> + - hycon,hycon-hy4614 >> + - hycon,hycon-hy4621 >> + - hycon,hycon-hy4623 >> + - hycon,hycon-hy4633 >> + - hycon,hycon-hy4635 >> + >> + reg: >> + maxItems: 1 >> + >> + interrupts: >> + maxItems: 1 >> + >> + reset-gpios: >> + maxItems: 1 >> + >> + vcc-supply: true >> + >> + threshold: > > Needs a vendor prefix here and all the custom properties. Sorry but I can't understand this ^^^, I've checked a lot of other yaml files but couldn't find something related to this. Can you help me by pointing me an example? > > One of the touchscreen properties doesn't already address this? > >> + description: Allows setting the sensitivity in the range from 0 to 255. >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 255 >> + >> + proximity-sensor-switch: > > Why a switch rather than enable or disable? I've changed its name into enable. > >> + description: Allows enabling or disabling the Proximity Sensor. >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 1 > > Is this a hardware config or something a user would want to change at > runtime? The latter shouldn't be in DT. It's a hardware config that enable the 11th touch point, but I didn't handle it inside the driver, so it's better that I remove it for the moment. > What does not present mean? Unless there is a need for keeping the > default setting, then this could be boolean instead. I've changed all "enable" to boolean and rely on default of the controller. Does this sound ok for you so I can send a v2 patchset? Thank you Best regards -- Giulio Benetti CTO MICRONOVA SRL Sede: Via A. Niedda 3 - 35010 Vigonza (PD) Tel. 049/8931563 - Fax 049/8931346 Cod.Fiscale - P.IVA 02663420285 Capitale Sociale € 26.000 i.v. Iscritta al Reg. Imprese di Padova N. 02663420285 Numero R.E.A. 258642 > Same questions for the rest of the properties. >> + >> + glove-enable: >> + description: Allows enabling or disabling glove setting. >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 1 >> + >> + report-speed: >> + description: Allows setting the report speed(i.e 0x64 => 100Hz). >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 255 >> + >> + power-noise-enable: >> + description: Allows enabling or disabling power noise filter. >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 1 >> + >> + filter-data: >> + description: Allows setting the filtering data before reporting touch >> + in the range from 0 to 5. >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 5 >> + >> + gain: >> + description: Allows setting the sensitivity distance in the range from 0 to 5. >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 5 >> + >> + edge-offset: >> + description: Allows setting the edge compensation in the range from 0 to 16. >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 16 >> + >> + 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 >> + interrupt-controller: true >> + >> +additionalProperties: false >> + >> +required: >> + - compatible >> + - reg >> + - interrupts >> + >> +examples: >> + - | >> + #include <dt-bindings/gpio/gpio.h> >> + #include <dt-bindings/interrupt-controller/arm-gic.h> >> + i2c { >> + #address-cells = <1>; >> + #size-cells = <0>; >> + hycon-hy4633@1c { >> + compatible = "hycon,hy4633"; >> + reg = <0x1c>; >> + interrupt-parent = <&gpio2>; >> + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; >> + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; >> + }; >> + }; >> + >> +... >> diff --git a/MAINTAINERS b/MAINTAINERS >> index d92f85ca831d..3f83daf6b2bf 100644 >> --- a/MAINTAINERS >> +++ b/MAINTAINERS >> @@ -8245,6 +8245,12 @@ S: Maintained >> F: mm/hwpoison-inject.c >> F: mm/memory-failure.c >> >> +HYCON HY46XX TOUCHSCREEN SUPPORT >> +M: Giulio Benetti <giulio.benetti@micronovasrl.com> >> +L: linux-input@vger.kernel.org >> +S: Maintained >> +F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> + >> HYGON PROCESSOR SUPPORT >> M: Pu Wen <puwen@hygon.cn> >> L: linux-kernel@vger.kernel.org >> -- >> 2.25.1 >> ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-01 18:37 ` Giulio Benetti @ 2021-04-01 22:24 ` Giulio Benetti 0 siblings, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-01 22:24 UTC (permalink / raw) To: Rob Herring, Giulio Benetti Cc: Dmitry Torokhov, linux-input, devicetree, linux-kernel Il 01/04/2021 20:37, Giulio Benetti ha scritto: >> >> Needs a vendor prefix here and all the custom properties. > > Sorry but I can't understand this ^^^, I've checked a lot of other yaml > files but couldn't find something related to this. Can you help me by > pointing me an example? > Found in example-schema.yaml, sorry for the noise -- Giulio Benetti CTO MICRONOVA SRL Sede: Via A. Niedda 3 - 35010 Vigonza (PD) Tel. 049/8931563 - Fax 049/8931346 Cod.Fiscale - P.IVA 02663420285 Capitale Sociale € 26.000 i.v. Iscritta al Reg. Imprese di Padova N. 02663420285 Numero R.E.A. 258642 ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v2 0/3] Input: add Hycon HY46XX Touchscreen controller 2021-03-06 19:41 ` Rob Herring 2021-04-01 18:37 ` Giulio Benetti @ 2021-04-01 23:03 ` Giulio Benetti 2021-04-01 23:03 ` [PATCH v2 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti ` (2 more replies) 1 sibling, 3 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-01 23:03 UTC (permalink / raw) To: Dmitry Torokhov, Rob Herring Cc: Giulio Benetti, Henrik Rydberg, linux-input, devicetree, linux-kernel, Jonathan Neuschäfer This patchset adds Hycon vendor, HY46XX touchscreen controller driver and its .yaml binding. --- V1->V2: * changed authorship and SoBs to @benettiengineering.com domain * fixed vendor commit log according to Jonathan Neuschäfer's suggestion * fixed hy46xx bindings according to Rob Herring's suggestions * fixed hy46xx driver according to Dmitry Torokhov's suggestions further details are listed in single patches --- Giulio Benetti (3): dt-bindings: Add Hycon Technology vendor prefix dt-bindings: touchscreen: Add HY46XX bindings Input: add driver for the Hycon HY46XX touchpanel series .../input/touchscreen/hycon,hy46xx.yaml | 120 ++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + MAINTAINERS | 7 + drivers/input/touchscreen/Kconfig | 12 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/hycon-hy46xx.c | 591 ++++++++++++++++++ 6 files changed, 733 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml create mode 100644 drivers/input/touchscreen/hycon-hy46xx.c -- 2.25.1 ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v2 1/3] dt-bindings: Add Hycon Technology vendor prefix 2021-04-01 23:03 ` [PATCH v2 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti @ 2021-04-01 23:03 ` Giulio Benetti 2021-04-01 23:03 ` [PATCH v2 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-04-01 23:03 ` [PATCH v2 3/3] Input: add driver for the Hycon HY46XX touchpanel series Giulio Benetti 2 siblings, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-01 23:03 UTC (permalink / raw) To: Dmitry Torokhov, Rob Herring Cc: Giulio Benetti, Henrik Rydberg, linux-input, devicetree, linux-kernel, Jonathan Neuschäfer Update Documentation/devicetree/bindings/vendor-prefixes.yaml to include "hycon" as a vendor prefix for "Hycon Technology". Company website: https://www.hycontek.com/ Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> --- V1->V2: * updated http:// to https:// in commit log as suggested by Jonathan Neuschäfer --- 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 a1312637d6ff..67f429a757cd 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -489,6 +489,8 @@ patternProperties: description: Shenzhen Hugsun Technology Co. Ltd. "^hwacom,.*": description: HwaCom Systems Inc. + "^hycon,.*": + description: Hycon Technology Corp. "^hydis,.*": description: Hydis Technologies "^hyundai,.*": -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v2 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-01 23:03 ` [PATCH v2 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-01 23:03 ` [PATCH v2 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti @ 2021-04-01 23:03 ` Giulio Benetti 2021-04-02 8:36 ` Jonathan Neuschäfer 2021-04-01 23:03 ` [PATCH v2 3/3] Input: add driver for the Hycon HY46XX touchpanel series Giulio Benetti 2 siblings, 1 reply; 69+ messages in thread From: Giulio Benetti @ 2021-04-01 23:03 UTC (permalink / raw) To: Dmitry Torokhov, Rob Herring Cc: Giulio Benetti, Henrik Rydberg, linux-input, devicetree, linux-kernel, Jonathan Neuschäfer This adds device tree bindings for the Hycon HY46XX touchscreen series. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> --- V1->V2: As suggested by Rob Herring: * fixed $id: address * added "hycon," in front of every custom property * changed all possible property to boolean type * removed proximity-sensor-switch property since it's not handled in driver --- .../input/touchscreen/hycon,hy46xx.yaml | 120 ++++++++++++++++++ MAINTAINERS | 6 + 2 files changed, 126 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml diff --git a/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml new file mode 100644 index 000000000000..71a1dbabcd4f --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml @@ -0,0 +1,120 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/hycon,hy46xx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: hycon HY46XX series touchscreen controller Bindings + +description: | + There are 6 variants of the chip for various touch panel sizes and coverl len material + Glass: 0.3mm--4.0mm + PET/PMMA: 0.2mm--2.0mm + HY4613(B)-N048 < 6" + HY4614(B)-N068 7" .. 10.1" + HY4621-NS32 < 5" + HY4623-NS48 5.1" .. 7" + Glass: 0.3mm--8.0mm + PET/PMMA: 0.2mm--4.0mm + HY4633(B)-N048 < 6" + HY4635(B)-N048 < 7" .. 10.1" + +maintainers: + - Giulio Benetti <giulio.benetti@benettiengineering.com> + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + enum: + - hycon,hycon-hy4613 + - hycon,hycon-hy4614 + - hycon,hycon-hy4621 + - hycon,hycon-hy4623 + - hycon,hycon-hy4633 + - hycon,hycon-hy4635 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + reset-gpios: + maxItems: 1 + + vcc-supply: true + + hycon,threshold: + description: Allows setting the sensitivity in the range from 0 to 255. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 255 + + hycon,glove-enable: + type: boolean + description: Allows enabling or disabling glove setting. + + hycon,report-speed: + description: Allows setting the report speed(i.e 0x64 => 100Hz). + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 255 + + hycon,power-noise-enable: + type: boolean + description: Allows enabling or disabling power noise filter. + + hycon,filter-data: + description: Allows setting the filtering data before reporting touch + in the range from 0 to 5. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 5 + + hycon,gain: + description: Allows setting the sensitivity distance in the range from 0 to 5. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 5 + + hycon,edge-offset: + description: Allows setting the edge compensation in the range from 0 to 16. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 16 + + 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 + interrupt-controller: true + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + hycon-hy4633@1c { + compatible = "hycon,hy4633"; + reg = <0x1c>; + interrupt-parent = <&gpio2>; + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; + }; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index 6e91994b8d3b..5e9cc7e610ce 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8242,6 +8242,12 @@ S: Maintained F: mm/hwpoison-inject.c F: mm/memory-failure.c +HYCON HY46XX TOUCHSCREEN SUPPORT +M: Giulio Benetti <giulio.benetti@benettiengineering.com> +L: linux-input@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml + HYGON PROCESSOR SUPPORT M: Pu Wen <puwen@hygon.cn> L: linux-kernel@vger.kernel.org -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH v2 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-01 23:03 ` [PATCH v2 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti @ 2021-04-02 8:36 ` Jonathan Neuschäfer 2021-04-02 15:17 ` Giulio Benetti 0 siblings, 1 reply; 69+ messages in thread From: Jonathan Neuschäfer @ 2021-04-02 8:36 UTC (permalink / raw) To: Giulio Benetti Cc: Dmitry Torokhov, Rob Herring, Henrik Rydberg, linux-input, devicetree, linux-kernel, Jonathan Neuschäfer [-- Attachment #1: Type: text/plain, Size: 3522 bytes --] On Fri, Apr 02, 2021 at 01:03:57AM +0200, Giulio Benetti wrote: > This adds device tree bindings for the Hycon HY46XX touchscreen series. > > Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> > --- > V1->V2: > As suggested by Rob Herring: > * fixed $id: address > * added "hycon," in front of every custom property > * changed all possible property to boolean type > * removed proximity-sensor-switch property since it's not handled in driver > --- > .../input/touchscreen/hycon,hy46xx.yaml | 120 ++++++++++++++++++ > MAINTAINERS | 6 + > 2 files changed, 126 insertions(+) > create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > > diff --git a/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > new file mode 100644 > index 000000000000..71a1dbabcd4f > --- /dev/null > +++ b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > @@ -0,0 +1,120 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/input/touchscreen/hycon,hy46xx.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: hycon HY46XX series touchscreen controller Bindings hycon -> Hycon (because it's a name) Bindings -> bindings (because it's just a regular word) > + > +description: | > + There are 6 variants of the chip for various touch panel sizes and coverl len material "coverl len material" looks like a typo. What does it mean? > + Glass: 0.3mm--4.0mm > + PET/PMMA: 0.2mm--2.0mm > + HY4613(B)-N048 < 6" > + HY4614(B)-N068 7" .. 10.1" According to the datasheet I was able to find[1], HY4613-N048 supports touch panel sizes smaller than 5.3". Did this change in newer datasheets? What does the (B) part of the part number mean? [1]: https://datasheetspdf.com/pdf/1297773/HYCON/HY4613-N048/1 > + HY4621-NS32 < 5" > + HY4623-NS48 5.1" .. 7" > + Glass: 0.3mm--8.0mm > + PET/PMMA: 0.2mm--4.0mm > + HY4633(B)-N048 < 6" > + HY4635(B)-N048 < 7" .. 10.1" The description block seems unusually far indented. I'm not a YAML expert, but according to the yamllint tool, it would work with much less indentation: description: | There are 6 variants of the chip for various touch panel sizes and coverl len material Glass: 0.3mm--4.0mm [...] > + hycon,glove-enable: > + type: boolean > + description: Allows enabling or disabling glove setting. Small nit: Due to the way boolean properties work in DT, you can't really use the property to disable the glove setting (in order to disable the setting, you would explicitly not use the property). Perhaps: + description: Allows enabling the glove setting. I don't really know :) > + > + hycon,report-speed: > + description: Allows setting the report speed(i.e 0x64 => 100Hz). > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 255 Please add a space before the opening parenthesis: + description: Allows setting the report speed (i.e 0x64 => 100Hz). Or perhaps like this: + description: Allows setting the report speed in Hertz. Thanks, Jonathan Neuschäfer [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v2 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-02 8:36 ` Jonathan Neuschäfer @ 2021-04-02 15:17 ` Giulio Benetti 0 siblings, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-02 15:17 UTC (permalink / raw) To: Jonathan Neuschäfer Cc: Dmitry Torokhov, Rob Herring, Henrik Rydberg, linux-input, devicetree, linux-kernel, Jonathan Neuschäfer Hi Jonathan, thank you for reviewing, On 4/2/21 10:36 AM, Jonathan Neuschäfer wrote: > On Fri, Apr 02, 2021 at 01:03:57AM +0200, Giulio Benetti wrote: >> This adds device tree bindings for the Hycon HY46XX touchscreen series. >> >> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> >> --- >> V1->V2: >> As suggested by Rob Herring: >> * fixed $id: address >> * added "hycon," in front of every custom property >> * changed all possible property to boolean type >> * removed proximity-sensor-switch property since it's not handled in driver >> --- >> .../input/touchscreen/hycon,hy46xx.yaml | 120 ++++++++++++++++++ >> MAINTAINERS | 6 + >> 2 files changed, 126 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> >> diff --git a/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> new file mode 100644 >> index 000000000000..71a1dbabcd4f >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> @@ -0,0 +1,120 @@ >> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) >> +%YAML 1.2 >> +--- >> +$id: http://devicetree.org/schemas/input/touchscreen/hycon,hy46xx.yaml# >> +$schema: http://devicetree.org/meta-schemas/core.yaml# >> + >> +title: hycon HY46XX series touchscreen controller Bindings > > hycon -> Hycon (because it's a name) > Bindings -> bindings (because it's just a regular word) ok >> + >> +description: | >> + There are 6 variants of the chip for various touch panel sizes and coverl len material > > "coverl len material" looks like a typo. What does it mean? yes >> + Glass: 0.3mm--4.0mm >> + PET/PMMA: 0.2mm--2.0mm >> + HY4613(B)-N048 < 6" >> + HY4614(B)-N068 7" .. 10.1" > > According to the datasheet I was able to find[1], HY4613-N048 supports > touch panel sizes smaller than 5.3". Did this change in newer > datasheets? Yes, there is a newer document called "HY46XX Application Notes V4.0", here is the screenshot of models: https://pasteboard.co/JVtOMcO.png > What does the (B) part of the part number mean? It's an upgraded version even if hardware is fully compatible, so (B) means with and without "B". > > [1]: https://datasheetspdf.com/pdf/1297773/HYCON/HY4613-N048/1 >> + HY4621-NS32 < 5" >> + HY4623-NS48 5.1" .. 7" >> + Glass: 0.3mm--8.0mm >> + PET/PMMA: 0.2mm--4.0mm >> + HY4633(B)-N048 < 6" >> + HY4635(B)-N048 < 7" .. 10.1" > > The description block seems unusually far indented. I'm not a YAML > expert, but according to the yamllint tool, it would work with much less > indentation: > > description: | > There are 6 variants of the chip for various touch panel sizes and coverl len material > Glass: 0.3mm--4.0mm > [...] Ah yes, I've started from edt,ft5x06.yaml and there it was indented that way. Anyway I've changed it. > >> + hycon,glove-enable: >> + type: boolean >> + description: Allows enabling or disabling glove setting. > > Small nit: Due to the way boolean properties work in DT, you can't > really use the property to disable the glove setting (in order to > disable the setting, you would explicitly not use the property). > Perhaps: > > + description: Allows enabling the glove setting. > > I don't really know :) Ah yes, it's true. If not specified it's simply not enabled, so I use your suggested form. > >> + >> + hycon,report-speed: >> + description: Allows setting the report speed(i.e 0x64 => 100Hz). >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 255 > > Please add a space before the opening parenthesis: > > + description: Allows setting the report speed (i.e 0x64 => 100Hz). > > Or perhaps like this: > > + description: Allows setting the report speed in Hertz. > Oh yes! I didn't realize it was exactly in Hertz, 0x64 is 100, not only equivalent to 100Hz, so every step is 1 Hz > > Thanks, > Jonathan Neuschäfer > Thanks again! Best regards -- Giulio Benetti Benetti Engineering sas ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v2 3/3] Input: add driver for the Hycon HY46XX touchpanel series 2021-04-01 23:03 ` [PATCH v2 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-01 23:03 ` [PATCH v2 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti 2021-04-01 23:03 ` [PATCH v2 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti @ 2021-04-01 23:03 ` Giulio Benetti 2021-04-02 8:59 ` Jonathan Neuschäfer 2 siblings, 1 reply; 69+ messages in thread From: Giulio Benetti @ 2021-04-01 23:03 UTC (permalink / raw) To: Dmitry Torokhov, Rob Herring Cc: Giulio Benetti, Henrik Rydberg, linux-input, devicetree, linux-kernel, Jonathan Neuschäfer This patch adds support for Hycon HY46XX. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> --- V1->V2: * removed proximity-sensor-switch property according to previous patch As suggested by Dmitry Torokhov * moved i2c communaction to regmap use * added macro to avoid magic number * removed cmd variable that could uninitiliazed since we're using regmap now * removed useless byte masking * removed useless struct hycon_hy46xx_i2c_chip_data * used IRQF_ONESHOT only for isr --- MAINTAINERS | 1 + drivers/input/touchscreen/Kconfig | 12 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/hycon-hy46xx.c | 591 +++++++++++++++++++++++ 4 files changed, 605 insertions(+) create mode 100644 drivers/input/touchscreen/hycon-hy46xx.c diff --git a/MAINTAINERS b/MAINTAINERS index 5e9cc7e610ce..93f22de4b9ee 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8247,6 +8247,7 @@ M: Giulio Benetti <giulio.benetti@benettiengineering.com> L: linux-input@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml +F: drivers/input/touchscreen/hy46xx.c HYGON PROCESSOR SUPPORT M: Pu Wen <puwen@hygon.cn> diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 529614d364fe..5d4751d901cb 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1335,4 +1335,16 @@ config TOUCHSCREEN_ZINITIX To compile this driver as a module, choose M here: the module will be called zinitix. +config TOUCHSCREEN_HYCON_HY46XX + tristate "Hycon hy46xx touchscreen support" + depends on I2C + help + Say Y here if you have a touchscreen using Hycon hy46xx, + or something similar enough. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called hycon-hy46xx. + endif diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 6233541e9173..8b68cf3a3e6d 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -112,3 +112,4 @@ obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o obj-$(CONFIG_TOUCHSCREEN_ZINITIX) += zinitix.o +obj-$(CONFIG_TOUCHSCREEN_HYCON_HY46XX) += hycon-hy46xx.o diff --git a/drivers/input/touchscreen/hycon-hy46xx.c b/drivers/input/touchscreen/hycon-hy46xx.c new file mode 100644 index 000000000000..42d7df86600d --- /dev/null +++ b/drivers/input/touchscreen/hycon-hy46xx.c @@ -0,0 +1,591 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 + * Author(s): Giulio Benetti <giulio.benetti@benettiengineering.com> + */ + +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/input.h> +#include <linux/input/mt.h> +#include <linux/input/touchscreen.h> +#include <linux/irq.h> +#include <linux/regulator/consumer.h> +#include <linux/regmap.h> + +#include <asm/unaligned.h> + +#define HY46XX_CHKSUM_CODE 0x1 +#define HY46XX_FINGER_NUM 0x2 +#define HY46XX_CHKSUM_LEN 0x7 +#define HY46XX_THRESHOLD 0x80 +#define HY46XX_GLOVE_EN 0x84 +#define HY46XX_REPORT_SPEED 0x88 +#define HY46XX_PWR_NOISE_EN 0x89 +#define HY46XX_FILTER_DATA 0x8A +#define HY46XX_GAIN 0x92 +#define HY46XX_EDGE_OFFSET 0x93 +#define HY46XX_RX_NR_USED 0x94 +#define HY46XX_TX_NR_USED 0x95 +#define HY46XX_PWR_MODE 0xA5 +#define HY46XX_FW_VERSION 0xA6 +#define HY46XX_LIB_VERSION 0xA7 +#define HY46XX_TP_INFO 0xA8 +#define HY46XX_TP_CHIP_ID 0xA9 +#define HY46XX_BOOT_VER 0xB0 + +#define HY46XX_TPLEN 0x6 +#define HY46XX_REPORT_PKT_LEN 0x44 + +#define HY46XX_MAX_SUPPORTED_POINTS 11 + +#define TOUCH_EVENT_DOWN 0x00 +#define TOUCH_EVENT_UP 0x01 +#define TOUCH_EVENT_CONTACT 0x02 +#define TOUCH_EVENT_RESERVED 0x03 + +struct hycon_hy46xx_data { + struct i2c_client *client; + struct input_dev *input; + struct touchscreen_properties prop; + struct regulator *vcc; + + struct gpio_desc *reset_gpio; + + struct mutex mutex; + struct regmap *regmap; + + int threshold; + bool glove_enable; + int report_speed; + bool power_noise_enable; + int filter_data; + int gain; + int edge_offset; + int rx_number_used; + int tx_number_used; + int power_mode; + int fw_version; + int lib_version; + int tp_information; + int tp_chip_id; + int bootloader_version; +}; + +static const struct regmap_config hycon_hy46xx_i2c_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; + +static bool hycon_hy46xx_check_checksum(struct hycon_hy46xx_data *tsdata, u8 *buf) +{ + u8 chksum = 0; + int i; + + for (i = 2; i < buf[HY46XX_CHKSUM_LEN]; i++) + chksum += buf[i]; + + if (chksum == buf[HY46XX_CHKSUM_CODE]) + return true; + + dev_err_ratelimited(&tsdata->client->dev, + "checksum error: 0x%02x expected, got 0x%02x\n", + chksum, buf[HY46XX_CHKSUM_CODE]); + + return false; +} + +static irqreturn_t hycon_hy46xx_isr(int irq, void *dev_id) +{ + struct hycon_hy46xx_data *tsdata = dev_id; + struct device *dev = &tsdata->client->dev; + u8 rdbuf[HY46XX_REPORT_PKT_LEN]; + int i, x, y, id; + int error; + + memset(rdbuf, 0, sizeof(rdbuf)); + + error = regmap_bulk_read(tsdata->regmap, 0, rdbuf, sizeof(rdbuf)); + if (error) { + dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n", + error); + goto out; + } + + if (!hycon_hy46xx_check_checksum(tsdata, rdbuf)) + goto out; + + for (i = 0; i < HY46XX_MAX_SUPPORTED_POINTS; i++) { + u8 *buf = &rdbuf[3 + (HY46XX_TPLEN * i)]; + int type = buf[0] >> 6; + + if (type == TOUCH_EVENT_RESERVED) + continue; + + x = get_unaligned_be16(buf) & 0x0fff; + y = get_unaligned_be16(buf + 2) & 0x0fff; + + id = buf[2] >> 4; + + input_mt_slot(tsdata->input, id); + if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, + type != TOUCH_EVENT_UP)) + touchscreen_report_pos(tsdata->input, &tsdata->prop, + x, y, true); + } + + input_mt_report_pointer_emulation(tsdata->input, true); + input_sync(tsdata->input); + +out: + return IRQ_HANDLED; +} + +struct hycon_hy46xx_attribute { + struct device_attribute dattr; + size_t field_offset; + u8 address; + u8 limit_low; + u8 limit_high; +}; + +#define HYCON_ATTR_U8(_field, _mode, _address, _limit_low, _limit_high) \ + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ + .dattr = __ATTR(_field, _mode, \ + hycon_hy46xx_setting_show, \ + hycon_hy46xx_setting_store), \ + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ + .address = _address, \ + .limit_low = _limit_low, \ + .limit_high = _limit_high, \ + } + +#define HYCON_ATTR_BOOL(_field, _mode, _address) \ + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ + .dattr = __ATTR(_field, _mode, \ + hycon_hy46xx_setting_show, \ + hycon_hy46xx_setting_store), \ + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ + .address = _address, \ + .limit_low = false, \ + .limit_high = true, \ + } + +static ssize_t hycon_hy46xx_setting_show(struct device *dev, + struct device_attribute *dattr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); + struct hycon_hy46xx_attribute *attr = + container_of(dattr, struct hycon_hy46xx_attribute, dattr); + u8 *field = (u8 *)tsdata + attr->field_offset; + size_t count = 0; + int error = 0; + int val; + + mutex_lock(&tsdata->mutex); + + error = regmap_read(tsdata->regmap, attr->address, &val); + if (error < 0) { + dev_err(&tsdata->client->dev, + "Failed to fetch attribute %s, error %d\n", + dattr->attr.name, error); + goto out; + } + + if (val != *field) { + dev_warn(&tsdata->client->dev, + "%s: read (%d) and stored value (%d) differ\n", + dattr->attr.name, val, *field); + *field = val; + } + + count = scnprintf(buf, PAGE_SIZE, "%d\n", val); + +out: + mutex_unlock(&tsdata->mutex); + return error ?: count; +} + +static ssize_t hycon_hy46xx_setting_store(struct device *dev, + struct device_attribute *dattr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); + struct hycon_hy46xx_attribute *attr = + container_of(dattr, struct hycon_hy46xx_attribute, dattr); + u8 *field = (u8 *)tsdata + attr->field_offset; + unsigned int val; + int error; + + mutex_lock(&tsdata->mutex); + + error = kstrtouint(buf, 0, &val); + if (error) + goto out; + + if (val < attr->limit_low || val > attr->limit_high) { + error = -ERANGE; + goto out; + } + + error = regmap_write(tsdata->regmap, attr->address, val); + if (error < 0) { + dev_err(&tsdata->client->dev, + "Failed to update attribute %s, error: %d\n", + dattr->attr.name, error); + goto out; + } + *field = val; + +out: + mutex_unlock(&tsdata->mutex); + return error ?: count; +} + +static HYCON_ATTR_U8(threshold, 0644, HY46XX_THRESHOLD, 0, 255); +static HYCON_ATTR_BOOL(glove_enable, 0644, HY46XX_GLOVE_EN); +static HYCON_ATTR_U8(report_speed, 0644, HY46XX_REPORT_SPEED, 0, 255); +static HYCON_ATTR_BOOL(power_noise_enable, 0644, HY46XX_PWR_NOISE_EN); +static HYCON_ATTR_U8(filter_data, 0644, HY46XX_FILTER_DATA, 0, 5); +static HYCON_ATTR_U8(gain, 0644, HY46XX_GAIN, 0, 5); +static HYCON_ATTR_U8(edge_offset, 0644, HY46XX_EDGE_OFFSET, 0, 5); +static HYCON_ATTR_U8(fw_version, 0444, HY46XX_FW_VERSION, 0, 255); +static HYCON_ATTR_U8(lib_version, 0444, HY46XX_LIB_VERSION, 0, 255); +static HYCON_ATTR_U8(tp_information, 0444, HY46XX_TP_INFO, 0, 255); +static HYCON_ATTR_U8(tp_chip_id, 0444, HY46XX_TP_CHIP_ID, 0, 255); +static HYCON_ATTR_U8(bootloader_version, 0444, HY46XX_BOOT_VER, 0, 255); + +static struct attribute *hycon_hy46xx_attrs[] = { + &hycon_hy46xx_attr_threshold.dattr.attr, + &hycon_hy46xx_attr_glove_enable.dattr.attr, + &hycon_hy46xx_attr_report_speed.dattr.attr, + &hycon_hy46xx_attr_power_noise_enable.dattr.attr, + &hycon_hy46xx_attr_filter_data.dattr.attr, + &hycon_hy46xx_attr_gain.dattr.attr, + &hycon_hy46xx_attr_edge_offset.dattr.attr, + &hycon_hy46xx_attr_fw_version.dattr.attr, + &hycon_hy46xx_attr_lib_version.dattr.attr, + &hycon_hy46xx_attr_tp_information.dattr.attr, + &hycon_hy46xx_attr_tp_chip_id.dattr.attr, + &hycon_hy46xx_attr_bootloader_version.dattr.attr, + NULL +}; + +static const struct attribute_group hycon_hy46xx_attr_group = { + .attrs = hycon_hy46xx_attrs, +}; + +static void hycon_hy46xx_get_defaults(struct device *dev, struct hycon_hy46xx_data *tsdata) +{ + bool val_bool; + int error; + u32 val; + + error = device_property_read_u32(dev, "threshold", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_THRESHOLD, val); + if (error < 0) + goto out; + + tsdata->threshold = val; + } + + val_bool = device_property_read_bool(dev, "glove-enable"); + error = regmap_write(tsdata->regmap, HY46XX_GLOVE_EN, val_bool); + if (error < 0) + goto out; + tsdata->glove_enable = val_bool; + + error = device_property_read_u32(dev, "report-speed", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_REPORT_SPEED, val); + if (error < 0) + goto out; + + tsdata->report_speed = val; + } + + val_bool = device_property_read_bool(dev, "power-noise-enable"); + error = regmap_write(tsdata->regmap, HY46XX_PWR_NOISE_EN, val_bool); + if (error < 0) + goto out; + tsdata->power_noise_enable = val_bool; + + error = device_property_read_u32(dev, "filter-data", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_FILTER_DATA, val); + if (error < 0) + goto out; + + tsdata->filter_data = val; + } + + error = device_property_read_u32(dev, "gain", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_GAIN, val); + if (error < 0) + goto out; + + tsdata->gain = val; + } + + error = device_property_read_u32(dev, "edge-offset", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_EDGE_OFFSET, val); + if (error < 0) + goto out; + + tsdata->edge_offset = val; + } + + return; +out: + dev_err(&tsdata->client->dev, "Failed to set default settings"); +} + +static void hycon_hy46xx_get_parameters(struct hycon_hy46xx_data *tsdata) +{ + int error; + u32 val; + + error = regmap_read(tsdata->regmap, HY46XX_THRESHOLD, &val); + if (error < 0) + goto out; + tsdata->threshold = val; + + error = regmap_read(tsdata->regmap, HY46XX_GLOVE_EN, &val); + if (error < 0) + goto out; + tsdata->glove_enable = val; + + error = regmap_read(tsdata->regmap, HY46XX_REPORT_SPEED, &val); + if (error < 0) + goto out; + tsdata->report_speed = val; + + error = regmap_read(tsdata->regmap, HY46XX_PWR_NOISE_EN, &val); + if (error < 0) + goto out; + tsdata->power_noise_enable = val; + + error = regmap_read(tsdata->regmap, HY46XX_FILTER_DATA, &val); + if (error < 0) + goto out; + tsdata->filter_data = val; + + error = regmap_read(tsdata->regmap, HY46XX_GAIN, &val); + if (error < 0) + goto out; + tsdata->gain = val; + + error = regmap_read(tsdata->regmap, HY46XX_EDGE_OFFSET, &val); + if (error < 0) + goto out; + tsdata->edge_offset = val; + + error = regmap_read(tsdata->regmap, HY46XX_RX_NR_USED, &val); + if (error < 0) + goto out; + tsdata->rx_number_used = val; + + error = regmap_read(tsdata->regmap, HY46XX_TX_NR_USED, &val); + if (error < 0) + goto out; + tsdata->tx_number_used = val; + + error = regmap_read(tsdata->regmap, HY46XX_PWR_MODE, &val); + if (error < 0) + goto out; + tsdata->power_mode = val; + + error = regmap_read(tsdata->regmap, HY46XX_FW_VERSION, &val); + if (error < 0) + goto out; + tsdata->fw_version = val; + + error = regmap_read(tsdata->regmap, HY46XX_LIB_VERSION, &val); + if (error < 0) + goto out; + tsdata->lib_version = val; + + error = regmap_read(tsdata->regmap, HY46XX_TP_INFO, &val); + if (error < 0) + goto out; + tsdata->tp_information = val; + + error = regmap_read(tsdata->regmap, HY46XX_TP_CHIP_ID, &val); + if (error < 0) + goto out; + tsdata->tp_chip_id = val; + + error = regmap_read(tsdata->regmap, HY46XX_BOOT_VER, &val); + if (error < 0) + goto out; + tsdata->bootloader_version = val; + + return; +out: + dev_err(&tsdata->client->dev, "Failed to read default settings"); +} + +static void hycon_hy46xx_disable_regulator(void *arg) +{ + struct hycon_hy46xx_data *data = arg; + + regulator_disable(data->vcc); +} + +static int hycon_hy46xx_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct hycon_hy46xx_data *tsdata; + struct input_dev *input; + int error; + + dev_dbg(&client->dev, "probing for HYCON HY46XX I2C\n"); + + tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL); + if (!tsdata) + return -ENOMEM; + + tsdata->vcc = devm_regulator_get(&client->dev, "vcc"); + if (IS_ERR(tsdata->vcc)) { + error = PTR_ERR(tsdata->vcc); + if (error != -EPROBE_DEFER) + dev_err(&client->dev, + "failed to request regulator: %d\n", error); + return error; + } + + error = regulator_enable(tsdata->vcc); + if (error < 0) { + dev_err(&client->dev, "failed to enable vcc: %d\n", error); + return error; + } + + error = devm_add_action_or_reset(&client->dev, + hycon_hy46xx_disable_regulator, + tsdata); + if (error) + return error; + + tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, + "reset", GPIOD_OUT_LOW); + if (IS_ERR(tsdata->reset_gpio)) { + error = PTR_ERR(tsdata->reset_gpio); + dev_err(&client->dev, + "Failed to request GPIO reset pin, error %d\n", error); + return error; + } + + if (tsdata->reset_gpio) { + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->reset_gpio, 1); + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->reset_gpio, 0); + msleep(1000); + } + + input = devm_input_allocate_device(&client->dev); + if (!input) { + dev_err(&client->dev, "failed to allocate input device.\n"); + return -ENOMEM; + } + + mutex_init(&tsdata->mutex); + tsdata->client = client; + tsdata->input = input; + + tsdata->regmap = devm_regmap_init_i2c(client, + &hycon_hy46xx_i2c_regmap_config); + if (IS_ERR(tsdata->regmap)) { + dev_err(&client->dev, "regmap allocation failed\n"); + return PTR_ERR(tsdata->regmap); + } + + hycon_hy46xx_get_defaults(&client->dev, tsdata); + hycon_hy46xx_get_parameters(tsdata); + + input->name = "Hycon Capacitive Touch"; + input->id.bustype = BUS_I2C; + input->dev.parent = &client->dev; + + input_set_abs_params(input, ABS_MT_POSITION_X, 0, -1, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, -1, 0, 0); + + touchscreen_parse_properties(input, true, &tsdata->prop); + + error = input_mt_init_slots(input, HY46XX_MAX_SUPPORTED_POINTS, + INPUT_MT_DIRECT); + if (error) { + dev_err(&client->dev, "Unable to init MT slots.\n"); + return error; + } + + i2c_set_clientdata(client, tsdata); + + error = devm_request_threaded_irq(&client->dev, client->irq, + NULL, hycon_hy46xx_isr, IRQF_ONESHOT, + client->name, tsdata); + if (error) { + dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); + return error; + } + + error = devm_device_add_group(&client->dev, &hycon_hy46xx_attr_group); + if (error) + return error; + + error = input_register_device(input); + if (error) + return error; + + dev_dbg(&client->dev, + "HYCON HY46XX initialized: IRQ %d, Reset pin %d.\n", + client->irq, + tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); + + return 0; +} + +static const struct i2c_device_id hycon_hy46xx_id[] = { + { .name = "hycon-hy4613" }, + { .name = "hycon-hy4614" }, + { .name = "hycon-hy4621" }, + { .name = "hycon-hy4623" }, + { .name = "hycon-hy4633" }, + { .name = "hycon-hy4635" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(i2c, hycon_hy46xx_id); + +static const struct of_device_id hycon_hy46xx_of_match[] = { + { .compatible = "hycon,hycon-hy4613" }, + { .compatible = "hycon,hycon-hy4614" }, + { .compatible = "hycon,hycon-hy4621" }, + { .compatible = "hycon,hycon-hy4623" }, + { .compatible = "hycon,hycon-hy4633" }, + { .compatible = "hycon,hycon-hy4635" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, hycon_hy46xx_of_match); + +static struct i2c_driver hycon_hy46xx_driver = { + .driver = { + .name = "hycon_hy46xx", + .of_match_table = hycon_hy46xx_of_match, + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, + .id_table = hycon_hy46xx_id, + .probe = hycon_hy46xx_probe, +}; + +module_i2c_driver(hycon_hy46xx_driver); + +MODULE_AUTHOR("Giulio Benetti <giulio.benetti@micronovasrl.com>"); +MODULE_DESCRIPTION("HYCON HY46XX I2C Touchscreen Driver"); +MODULE_LICENSE("GPL v2"); -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH v2 3/3] Input: add driver for the Hycon HY46XX touchpanel series 2021-04-01 23:03 ` [PATCH v2 3/3] Input: add driver for the Hycon HY46XX touchpanel series Giulio Benetti @ 2021-04-02 8:59 ` Jonathan Neuschäfer 2021-04-02 15:23 ` Giulio Benetti 2021-04-02 16:16 ` [PATCH v3 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 0 siblings, 2 replies; 69+ messages in thread From: Jonathan Neuschäfer @ 2021-04-02 8:59 UTC (permalink / raw) To: Giulio Benetti Cc: Dmitry Torokhov, Rob Herring, Henrik Rydberg, linux-input, devicetree, linux-kernel, Jonathan Neuschäfer [-- Attachment #1: Type: text/plain, Size: 1811 bytes --] Hi, a few remarks below. On Fri, Apr 02, 2021 at 01:03:58AM +0200, Giulio Benetti wrote: > This patch adds support for Hycon HY46XX. > > Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> > --- > V1->V2: > * removed proximity-sensor-switch property according to previous patch > As suggested by Dmitry Torokhov > * moved i2c communaction to regmap use > * added macro to avoid magic number > * removed cmd variable that could uninitiliazed since we're using regmap now > * removed useless byte masking > * removed useless struct hycon_hy46xx_i2c_chip_data > * used IRQF_ONESHOT only for isr > --- > +config TOUCHSCREEN_HYCON_HY46XX > + tristate "Hycon hy46xx touchscreen support" > + depends on I2C > + help > + Say Y here if you have a touchscreen using Hycon hy46xx, > + or something similar enough. The "something similar enough" part doesn't seem relevant, because the driver only lists HY46xx chips (in the compatible strings), and no chips that are similar enough to work with the driver, but have a different part number. > +static void hycon_hy46xx_get_defaults(struct device *dev, struct hycon_hy46xx_data *tsdata) > +{ > + bool val_bool; > + int error; > + u32 val; > + > + error = device_property_read_u32(dev, "threshold", &val); This seems to follow the old version of the binding, where Hycon-specific properties didn't have the "hycon," prefix. Please check that the driver still works with a devicetree that follows the newest version of the binding. > +MODULE_AUTHOR("Giulio Benetti <giulio.benetti@micronovasrl.com>"); This is a different email address than you used in the DT binding. If this is intentional, no problem (Just letting you know, in case it's unintentional). Thanks, Jonathan Neuschäfer [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v2 3/3] Input: add driver for the Hycon HY46XX touchpanel series 2021-04-02 8:59 ` Jonathan Neuschäfer @ 2021-04-02 15:23 ` Giulio Benetti 2021-04-02 16:16 ` [PATCH v3 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 1 sibling, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-02 15:23 UTC (permalink / raw) To: Jonathan Neuschäfer Cc: Dmitry Torokhov, Rob Herring, Henrik Rydberg, linux-input, devicetree, linux-kernel, Jonathan Neuschäfer Hi Jonathan, On 4/2/21 10:59 AM, Jonathan Neuschäfer wrote: > Hi, > > a few remarks below. > > On Fri, Apr 02, 2021 at 01:03:58AM +0200, Giulio Benetti wrote: >> This patch adds support for Hycon HY46XX. >> >> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> >> --- >> V1->V2: >> * removed proximity-sensor-switch property according to previous patch >> As suggested by Dmitry Torokhov >> * moved i2c communaction to regmap use >> * added macro to avoid magic number >> * removed cmd variable that could uninitiliazed since we're using regmap now >> * removed useless byte masking >> * removed useless struct hycon_hy46xx_i2c_chip_data >> * used IRQF_ONESHOT only for isr >> --- > > >> +config TOUCHSCREEN_HYCON_HY46XX >> + tristate "Hycon hy46xx touchscreen support" >> + depends on I2C >> + help >> + Say Y here if you have a touchscreen using Hycon hy46xx, >> + or something similar enough. > > The "something similar enough" part doesn't seem relevant, because the > driver only lists HY46xx chips (in the compatible strings), and no chips > that are similar enough to work with the driver, but have a different > part number. Right >> +static void hycon_hy46xx_get_defaults(struct device *dev, struct hycon_hy46xx_data *tsdata) >> +{ >> + bool val_bool; >> + int error; >> + u32 val; >> + >> + error = device_property_read_u32(dev, "threshold", &val); > > This seems to follow the old version of the binding, where > Hycon-specific properties didn't have the "hycon," prefix. > Please check that the driver still works with a devicetree that follows > the newest version of the binding. Ah yes, I've forgotten it while changing in bindings. >> +MODULE_AUTHOR("Giulio Benetti <giulio.benetti@micronovasrl.com>"); > > This is a different email address than you used in the DT binding. If > this is intentional, no problem (Just letting you know, in case it's > unintentional). I've missed that > > Thanks, > Jonathan Neuschäfer > Thank you! Best regards -- Giulio Benetti Benetti Engineering sas ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v3 0/3] Input: add Hycon HY46XX Touchscreen controller 2021-04-02 8:59 ` Jonathan Neuschäfer 2021-04-02 15:23 ` Giulio Benetti @ 2021-04-02 16:16 ` Giulio Benetti 2021-04-02 16:16 ` [PATCH v3 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti ` (2 more replies) 1 sibling, 3 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-02 16:16 UTC (permalink / raw) To: Dmitry Torokhov, Rob Herring, Jonathan Neuschäfer Cc: Giulio Benetti, Henrik Rydberg, linux-input, devicetree, linux-kernel This patchset adds Hycon vendor, HY46XX touchscreen controller driver and its .yaml binding. --- V1->V2: * changed authorship and SoBs to @benettiengineering.com domain * fixed vendor commit log according to Jonathan Neuschäfer's suggestion * fixed hy46xx bindings according to Rob Herring's suggestions * fixed hy46xx driver according to Dmitry Torokhov's suggestions further details are listed in single patches V2->V3: * fixed hy46xx bindings according to Jonathan Neuschäfer's suggestion * fixed hy46xx driver according to Jonathan Neuschäfer's suggestion further details are listed in single patches --- Giulio Benetti (3): dt-bindings: Add Hycon Technology vendor prefix dt-bindings: touchscreen: Add HY46XX bindings Input: add driver for the Hycon HY46XX touchpanel series .../input/touchscreen/hycon,hy46xx.yaml | 120 ++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + MAINTAINERS | 7 + drivers/input/touchscreen/Kconfig | 11 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/hycon-hy46xx.c | 591 ++++++++++++++++++ 6 files changed, 732 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml create mode 100644 drivers/input/touchscreen/hycon-hy46xx.c -- 2.25.1 ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v3 1/3] dt-bindings: Add Hycon Technology vendor prefix 2021-04-02 16:16 ` [PATCH v3 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti @ 2021-04-02 16:16 ` Giulio Benetti 2021-04-02 16:16 ` [PATCH v3 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-04-02 16:16 ` [PATCH v3 " Giulio Benetti 2 siblings, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-02 16:16 UTC (permalink / raw) To: Dmitry Torokhov, Rob Herring, Jonathan Neuschäfer Cc: Giulio Benetti, Henrik Rydberg, linux-input, devicetree, linux-kernel, Jonathan Neuschäfer Update Documentation/devicetree/bindings/vendor-prefixes.yaml to include "hycon" as a vendor prefix for "Hycon Technology". Company website: https://www.hycontek.com/ Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> --- 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 a1312637d6ff..67f429a757cd 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -489,6 +489,8 @@ patternProperties: description: Shenzhen Hugsun Technology Co. Ltd. "^hwacom,.*": description: HwaCom Systems Inc. + "^hycon,.*": + description: Hycon Technology Corp. "^hydis,.*": description: Hydis Technologies "^hyundai,.*": -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v3 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-02 16:16 ` [PATCH v3 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-02 16:16 ` [PATCH v3 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti @ 2021-04-02 16:16 ` Giulio Benetti 2021-04-06 13:24 ` Rob Herring 2021-04-06 13:37 ` Jonathan Neuschäfer 2021-04-02 16:16 ` [PATCH v3 " Giulio Benetti 2 siblings, 2 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-02 16:16 UTC (permalink / raw) To: Dmitry Torokhov, Rob Herring, Jonathan Neuschäfer Cc: Giulio Benetti, Henrik Rydberg, linux-input, devicetree, linux-kernel This adds device tree bindings for the Hycon HY46XX touchscreen series. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> --- V1->V2: As suggested by Rob Herring: * fixed $id: address * added "hycon," in front of every custom property * changed all possible property to boolean type * removed proximity-sensor-switch property since it's not handled in driver V2->V3: As suggested by Jonathan Neuschäfer: * fixed some typo * fixed description indentation * improved boolean properties descriptions * improved hycon,report-speed description --- .../input/touchscreen/hycon,hy46xx.yaml | 120 ++++++++++++++++++ MAINTAINERS | 6 + 2 files changed, 126 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml diff --git a/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml new file mode 100644 index 000000000000..dddc6e3e654f --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml @@ -0,0 +1,120 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/hycon,hy46xx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Hycon HY46XX series touchscreen controller bindings + +description: | + There are 6 variants of the chip for various touch panel sizes and cover lens material + Glass: 0.3mm--4.0mm + PET/PMMA: 0.2mm--2.0mm + HY4613(B)-N048 < 6" + HY4614(B)-N068 7" .. 10.1" + HY4621-NS32 < 5" + HY4623-NS48 5.1" .. 7" + Glass: 0.3mm--8.0mm + PET/PMMA: 0.2mm--4.0mm + HY4633(B)-N048 < 6" + HY4635(B)-N048 < 7" .. 10.1" + +maintainers: + - Giulio Benetti <giulio.benetti@benettiengineering.com> + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + enum: + - hycon,hycon-hy4613 + - hycon,hycon-hy4614 + - hycon,hycon-hy4621 + - hycon,hycon-hy4623 + - hycon,hycon-hy4633 + - hycon,hycon-hy4635 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + reset-gpios: + maxItems: 1 + + vcc-supply: true + + hycon,threshold: + description: Allows setting the sensitivity in the range from 0 to 255. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 255 + + hycon,glove-enable: + type: boolean + description: Allows enabling glove setting. + + hycon,report-speed: + description: Allows setting the report speed in Hertz. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 255 + + hycon,power-noise-enable: + type: boolean + description: Allows enabling power noise filter. + + hycon,filter-data: + description: Allows setting the filtering data before reporting touch + in the range from 0 to 5. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 5 + + hycon,gain: + description: Allows setting the sensitivity distance in the range from 0 to 5. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 5 + + hycon,edge-offset: + description: Allows setting the edge compensation in the range from 0 to 16. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 16 + + 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 + interrupt-controller: true + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + hycon-hy4633@1c { + compatible = "hycon,hy4633"; + reg = <0x1c>; + interrupt-parent = <&gpio2>; + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; + }; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index 6e91994b8d3b..5e9cc7e610ce 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8242,6 +8242,12 @@ S: Maintained F: mm/hwpoison-inject.c F: mm/memory-failure.c +HYCON HY46XX TOUCHSCREEN SUPPORT +M: Giulio Benetti <giulio.benetti@benettiengineering.com> +L: linux-input@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml + HYGON PROCESSOR SUPPORT M: Pu Wen <puwen@hygon.cn> L: linux-kernel@vger.kernel.org -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH v3 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-02 16:16 ` [PATCH v3 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti @ 2021-04-06 13:24 ` Rob Herring 2021-04-07 17:57 ` Giulio Benetti 2021-04-06 13:37 ` Jonathan Neuschäfer 1 sibling, 1 reply; 69+ messages in thread From: Rob Herring @ 2021-04-06 13:24 UTC (permalink / raw) To: Giulio Benetti Cc: linux-input, Rob Herring, devicetree, Jonathan Neuschäfer, Henrik Rydberg, Dmitry Torokhov, linux-kernel [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 1598 bytes --] On Fri, 02 Apr 2021 18:16:26 +0200, Giulio Benetti wrote: > This adds device tree bindings for the Hycon HY46XX touchscreen series. > > Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> > --- > V1->V2: > As suggested by Rob Herring: > * fixed $id: address > * added "hycon," in front of every custom property > * changed all possible property to boolean type > * removed proximity-sensor-switch property since it's not handled in driver > V2->V3: > As suggested by Jonathan Neuschäfer: > * fixed some typo > * fixed description indentation > * improved boolean properties descriptions > * improved hycon,report-speed description > --- > .../input/touchscreen/hycon,hy46xx.yaml | 120 ++++++++++++++++++ > MAINTAINERS | 6 + > 2 files changed, 126 insertions(+) > create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > My bot found errors running 'make dt_binding_check' on your patch: yamllint warnings/errors: dtschema/dtc warnings/errors: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.example.dt.yaml:0:0: /example-0/i2c/hycon-hy4633@1c: failed to match any schema with compatible: ['hycon,hy4633'] See https://patchwork.ozlabs.org/patch/1461797 This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1. If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date: pip3 install dtschema --upgrade Please check and re-submit. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v3 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-06 13:24 ` Rob Herring @ 2021-04-07 17:57 ` Giulio Benetti 2021-04-07 18:56 ` Rob Herring 0 siblings, 1 reply; 69+ messages in thread From: Giulio Benetti @ 2021-04-07 17:57 UTC (permalink / raw) To: Rob Herring Cc: linux-input, Rob Herring, devicetree, Jonathan Neuschäfer, Henrik Rydberg, Dmitry Torokhov, linux-kernel Hello Rob, All, On 4/6/21 3:24 PM, Rob Herring wrote: > On Fri, 02 Apr 2021 18:16:26 +0200, Giulio Benetti wrote: >> This adds device tree bindings for the Hycon HY46XX touchscreen series. >> >> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> >> --- >> V1->V2: >> As suggested by Rob Herring: >> * fixed $id: address >> * added "hycon," in front of every custom property >> * changed all possible property to boolean type >> * removed proximity-sensor-switch property since it's not handled in driver >> V2->V3: >> As suggested by Jonathan Neuschäfer: >> * fixed some typo >> * fixed description indentation >> * improved boolean properties descriptions >> * improved hycon,report-speed description >> --- >> .../input/touchscreen/hycon,hy46xx.yaml | 120 ++++++++++++++++++ >> MAINTAINERS | 6 + >> 2 files changed, 126 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> > > My bot found errors running 'make dt_binding_check' on your patch: > > yamllint warnings/errors: > > dtschema/dtc warnings/errors: > Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.example.dt.yaml:0:0: /example-0/i2c/hycon-hy4633@1c: failed to match any schema with compatible: ['hycon,hy4633'] > > See https://patchwork.ozlabs.org/patch/1461797 > > This check can fail if there are any dependencies. The base for a patch > series is generally the most recent rc1. > > If you already ran 'make dt_binding_check' and didn't see the above > error(s), then make sure 'yamllint' is installed and dt-schema is up to > date: I've just send corrected patches. Anyway I'd like to understand how to make dt_binding_check works correctly. I've installed yamllint and 'make dt_binding_check' works but it still doesn't show that error up on compatible string. yamllint I have is version 1.20.0 > pip3 install dtschema --upgrade I've already tried with that too and dtschema version is: 1.3.8 I've read that dtc must be compiled with YAML output enabled and it seems to be so, since when I issue 'make dt_binding_check' from my file: hycon,hy46xx.yaml(with compatible string wrong "hycon,hy4633") these files are generated: hycon,hy46xx.example.dts ``` /dts-v1/; /plugin/; // silence any missing phandle references /{ compatible = "foo"; model = "foo"; interrupt-parent = <&foo>; #address-cells = <1>; #size-cells = <1>; example-0 { #address-cells = <1>; #size-cells = <1>; #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/interrupt-controller/arm-gic.h> i2c { #address-cells = <1>; #size-cells = <0>; hycon-hy4633@1c { compatible = "hycon,hy4633"; reg = <0x1c>; interrupt-parent = <&gpio2>; interrupts = <5 IRQ_TYPE_EDGE_FALLING>; reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; }; }; }; }; ``` AND hycon,hy46xx.example.dt.yaml ``` --- - compatible: ["foo"] model: ["foo"] interrupt-parent: [[!phandle 0xffffffff]] '#address-cells': [[0x1]] '#size-cells': [[0x1]] example-0: '#address-cells': [[0x1]] '#size-cells': [[0x1]] i2c: '#address-cells': [[0x1]] '#size-cells': [[0x0]] hycon-hy4633@1c: compatible: ["hycon,hy4633"] reg: [[0x1c]] interrupt-parent: [[!phandle 0xffffffff]] interrupts: [[0x5, 0x2]] reset-gpios: [[!phandle 0xffffffff, 0x6, 0x1]] __fixups__: foo: ["/:interrupt-parent:0"] gpio2: ["/example-0/i2c/hycon-hy4633@1c:interrupt-parent:0", "/example-0/i2c/hycon-hy4633@1c:reset-gpios:0"] ... ``` So I can't reproduce the problem, can you point me some documentation that I didn't see before? Thank in advance Best regards -- Giulio Benetti Benetti Engineering sas ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v3 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-07 17:57 ` Giulio Benetti @ 2021-04-07 18:56 ` Rob Herring 2021-04-07 19:17 ` Giulio Benetti 0 siblings, 1 reply; 69+ messages in thread From: Rob Herring @ 2021-04-07 18:56 UTC (permalink / raw) To: Giulio Benetti Cc: Linux Input, devicetree, Jonathan Neuschäfer, Henrik Rydberg, Dmitry Torokhov, linux-kernel On Wed, Apr 7, 2021 at 12:57 PM Giulio Benetti <giulio.benetti@benettiengineering.com> wrote: > > Hello Rob, All, > > On 4/6/21 3:24 PM, Rob Herring wrote: > > On Fri, 02 Apr 2021 18:16:26 +0200, Giulio Benetti wrote: > >> This adds device tree bindings for the Hycon HY46XX touchscreen series. > >> > >> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> > >> --- > >> V1->V2: > >> As suggested by Rob Herring: > >> * fixed $id: address > >> * added "hycon," in front of every custom property > >> * changed all possible property to boolean type > >> * removed proximity-sensor-switch property since it's not handled in driver > >> V2->V3: > >> As suggested by Jonathan Neuschäfer: > >> * fixed some typo > >> * fixed description indentation > >> * improved boolean properties descriptions > >> * improved hycon,report-speed description > >> --- > >> .../input/touchscreen/hycon,hy46xx.yaml | 120 ++++++++++++++++++ > >> MAINTAINERS | 6 + > >> 2 files changed, 126 insertions(+) > >> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > >> > > > > My bot found errors running 'make dt_binding_check' on your patch: > > > > yamllint warnings/errors: > > > > dtschema/dtc warnings/errors: > > Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.example.dt.yaml:0:0: /example-0/i2c/hycon-hy4633@1c: failed to match any schema with compatible: ['hycon,hy4633'] > > > > See https://patchwork.ozlabs.org/patch/1461797 > > > > This check can fail if there are any dependencies. The base for a patch > > series is generally the most recent rc1. > > > > If you already ran 'make dt_binding_check' and didn't see the above > > error(s), then make sure 'yamllint' is installed and dt-schema is up to > > date: > > I've just send corrected patches. > > Anyway I'd like to understand how to make dt_binding_check works correctly. > > I've installed yamllint and 'make dt_binding_check' works but it still > doesn't show that error up on compatible string. > > yamllint I have is version 1.20.0 > > > pip3 install dtschema --upgrade > > I've already tried with that too and dtschema version is: > 1.3.8 Huh? dtschema versions are YYYY.MM. > I've read that dtc must be compiled with YAML output enabled and it > seems to be so, since when I issue 'make dt_binding_check' from my file: > hycon,hy46xx.yaml(with compatible string wrong "hycon,hy4633") It's a new check queued for 5.13 in linux-next. See commit c59773d204cc ("kbuild: Enable DT undocumented compatible checks"). I've updated the bot email with this, but after I sent this one. Rob ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v3 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-07 18:56 ` Rob Herring @ 2021-04-07 19:17 ` Giulio Benetti 0 siblings, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-07 19:17 UTC (permalink / raw) To: Rob Herring Cc: Linux Input, devicetree, Jonathan Neuschäfer, Henrik Rydberg, Dmitry Torokhov, linux-kernel On 4/7/21 8:56 PM, Rob Herring wrote: > On Wed, Apr 7, 2021 at 12:57 PM Giulio Benetti > <giulio.benetti@benettiengineering.com> wrote: >> >> Hello Rob, All, >> >> On 4/6/21 3:24 PM, Rob Herring wrote: >>> On Fri, 02 Apr 2021 18:16:26 +0200, Giulio Benetti wrote: >>>> This adds device tree bindings for the Hycon HY46XX touchscreen series. >>>> >>>> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> >>>> --- >>>> V1->V2: >>>> As suggested by Rob Herring: >>>> * fixed $id: address >>>> * added "hycon," in front of every custom property >>>> * changed all possible property to boolean type >>>> * removed proximity-sensor-switch property since it's not handled in driver >>>> V2->V3: >>>> As suggested by Jonathan Neuschäfer: >>>> * fixed some typo >>>> * fixed description indentation >>>> * improved boolean properties descriptions >>>> * improved hycon,report-speed description >>>> --- >>>> .../input/touchscreen/hycon,hy46xx.yaml | 120 ++++++++++++++++++ >>>> MAINTAINERS | 6 + >>>> 2 files changed, 126 insertions(+) >>>> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >>>> >>> >>> My bot found errors running 'make dt_binding_check' on your patch: >>> >>> yamllint warnings/errors: >>> >>> dtschema/dtc warnings/errors: >>> Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.example.dt.yaml:0:0: /example-0/i2c/hycon-hy4633@1c: failed to match any schema with compatible: ['hycon,hy4633'] >>> >>> See https://patchwork.ozlabs.org/patch/1461797 >>> >>> This check can fail if there are any dependencies. The base for a patch >>> series is generally the most recent rc1. >>> >>> If you already ran 'make dt_binding_check' and didn't see the above >>> error(s), then make sure 'yamllint' is installed and dt-schema is up to >>> date: >> >> I've just send corrected patches. >> >> Anyway I'd like to understand how to make dt_binding_check works correctly. >> >> I've installed yamllint and 'make dt_binding_check' works but it still >> doesn't show that error up on compatible string. >> >> yamllint I have is version 1.20.0 >> >>> pip3 install dtschema --upgrade >> >> I've already tried with that too and dtschema version is: >> 1.3.8 > > Huh? dtschema versions are YYYY.MM. Sorry, it is 2021.3 >> I've read that dtc must be compiled with YAML output enabled and it >> seems to be so, since when I issue 'make dt_binding_check' from my file: >> hycon,hy46xx.yaml(with compatible string wrong "hycon,hy4633") > > It's a new check queued for 5.13 in linux-next. See commit > c59773d204cc ("kbuild: Enable DT undocumented compatible checks"). > > I've updated the bot email with this, but after I sent this one. Ah ok, thank you, I'll apply it in my Repos. Best regards -- Giulio Benetti Benetti Engineering sas ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v3 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-02 16:16 ` [PATCH v3 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-04-06 13:24 ` Rob Herring @ 2021-04-06 13:37 ` Jonathan Neuschäfer 2021-04-06 14:07 ` Giulio Benetti 2021-04-07 17:49 ` [PATCH v4 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 1 sibling, 2 replies; 69+ messages in thread From: Jonathan Neuschäfer @ 2021-04-06 13:37 UTC (permalink / raw) To: Giulio Benetti Cc: Dmitry Torokhov, Rob Herring, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel [-- Attachment #1: Type: text/plain, Size: 756 bytes --] In the binding: > +properties: > + compatible: > + enum: > + - hycon,hycon-hy4613 > + - hycon,hycon-hy4614 > + - hycon,hycon-hy4621 > + - hycon,hycon-hy4623 > + - hycon,hycon-hy4633 > + - hycon,hycon-hy4635 In the example: > + hycon-hy4633@1c { > + compatible = "hycon,hy4633"; > + reg = <0x1c>; > + interrupt-parent = <&gpio2>; > + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; > + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; > + }; Rob's devicetree lint bot detected the mismatch in compatible string here. I personally think 'hycon,hy4633' looks better than 'hycon,hycon-hy4633', because it isn't so redundant. Best regards, Jonathan Neuschäfer [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v3 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-06 13:37 ` Jonathan Neuschäfer @ 2021-04-06 14:07 ` Giulio Benetti 2021-04-07 17:49 ` [PATCH v4 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 1 sibling, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-06 14:07 UTC (permalink / raw) To: Jonathan Neuschäfer Cc: Dmitry Torokhov, Rob Herring, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel Hi Jonathan, On 4/6/21 3:37 PM, Jonathan Neuschäfer wrote: > In the binding: >> +properties: >> + compatible: >> + enum: >> + - hycon,hycon-hy4613 >> + - hycon,hycon-hy4614 >> + - hycon,hycon-hy4621 >> + - hycon,hycon-hy4623 >> + - hycon,hycon-hy4633 >> + - hycon,hycon-hy4635 > > In the example: >> + hycon-hy4633@1c { >> + compatible = "hycon,hy4633"; >> + reg = <0x1c>; >> + interrupt-parent = <&gpio2>; >> + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; >> + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; >> + }; > > > Rob's devicetree lint bot detected the mismatch in compatible string > here. > > I personally think 'hycon,hy4633' looks better than 'hycon,hycon-hy4633', > because it isn't so redundant. > Thank you, I've realized it after submitting patches and waited for other comments. I've already fixed it the way you've pointed. Kind regards -- Giulio Benetti Benetti Engineering sas > Best regards, > Jonathan Neuschäfer > ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v4 0/3] Input: add Hycon HY46XX Touchscreen controller 2021-04-06 13:37 ` Jonathan Neuschäfer 2021-04-06 14:07 ` Giulio Benetti @ 2021-04-07 17:49 ` Giulio Benetti 2021-04-07 17:49 ` [PATCH v4 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti ` (2 more replies) 1 sibling, 3 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-07 17:49 UTC (permalink / raw) To: Dmitry Torokhov, Rob Herring, Jonathan Neuschäfer Cc: Henrik Rydberg, linux-input, devicetree, linux-kernel, Giulio Benetti This patchset adds Hycon vendor, HY46XX touchscreen controller driver and its .yaml binding. --- V1->V2: * changed authorship and SoBs to @benettiengineering.com domain * fixed vendor commit log according to Jonathan Neuschäfer's suggestion * fixed hy46xx bindings according to Rob Herring's suggestions * fixed hy46xx driver according to Dmitry Torokhov's suggestions further details are listed in single patches V2->V3: * fixed hy46xx bindings according to Jonathan Neuschäfer's suggestion * fixed hy46xx driver according to Jonathan Neuschäfer's suggestion further details are listed in single patches V3->V4: * fixed binding compatible string as suggested by Jonathan Neuschäfer --- Giulio Benetti (3): dt-bindings: Add Hycon Technology vendor prefix dt-bindings: touchscreen: Add HY46XX bindings Input: add driver for the Hycon HY46XX touchpanel series .../input/touchscreen/hycon,hy46xx.yaml | 120 ++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + MAINTAINERS | 7 + drivers/input/touchscreen/Kconfig | 11 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/hycon-hy46xx.c | 591 ++++++++++++++++++ 6 files changed, 732 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml create mode 100644 drivers/input/touchscreen/hycon-hy46xx.c -- 2.25.1 ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v4 1/3] dt-bindings: Add Hycon Technology vendor prefix 2021-04-07 17:49 ` [PATCH v4 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti @ 2021-04-07 17:49 ` Giulio Benetti 2021-04-08 20:16 ` Rob Herring 2021-04-07 17:49 ` [PATCH v4 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-04-07 17:49 ` [PATCH v4 " Giulio Benetti 2 siblings, 1 reply; 69+ messages in thread From: Giulio Benetti @ 2021-04-07 17:49 UTC (permalink / raw) To: Dmitry Torokhov, Rob Herring, Jonathan Neuschäfer Cc: Henrik Rydberg, linux-input, devicetree, linux-kernel, Giulio Benetti Update Documentation/devicetree/bindings/vendor-prefixes.yaml to include "hycon" as a vendor prefix for "Hycon Technology". Company website: https://www.hycontek.com/ Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> --- 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 a1312637d6ff..67f429a757cd 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -489,6 +489,8 @@ patternProperties: description: Shenzhen Hugsun Technology Co. Ltd. "^hwacom,.*": description: HwaCom Systems Inc. + "^hycon,.*": + description: Hycon Technology Corp. "^hydis,.*": description: Hydis Technologies "^hyundai,.*": -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH v4 1/3] dt-bindings: Add Hycon Technology vendor prefix 2021-04-07 17:49 ` [PATCH v4 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti @ 2021-04-08 20:16 ` Rob Herring 0 siblings, 0 replies; 69+ messages in thread From: Rob Herring @ 2021-04-08 20:16 UTC (permalink / raw) To: Giulio Benetti Cc: Henrik Rydberg, linux-input, Dmitry Torokhov, linux-kernel, Rob Herring, Jonathan Neuschäfer, devicetree On Wed, 07 Apr 2021 19:49:07 +0200, Giulio Benetti wrote: > Update Documentation/devicetree/bindings/vendor-prefixes.yaml to > include "hycon" as a vendor prefix for "Hycon Technology". > Company website: https://www.hycontek.com/ > > Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> > Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> > --- > Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ > 1 file changed, 2 insertions(+) > Acked-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v4 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-07 17:49 ` [PATCH v4 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-07 17:49 ` [PATCH v4 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti @ 2021-04-07 17:49 ` Giulio Benetti 2021-04-08 20:21 ` Rob Herring 2021-04-07 17:49 ` [PATCH v4 " Giulio Benetti 2 siblings, 1 reply; 69+ messages in thread From: Giulio Benetti @ 2021-04-07 17:49 UTC (permalink / raw) To: Dmitry Torokhov, Rob Herring, Jonathan Neuschäfer Cc: Henrik Rydberg, linux-input, devicetree, linux-kernel, Giulio Benetti This adds device tree bindings for the Hycon HY46XX touchscreen series. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> --- V1->V2: As suggested by Rob Herring: * fixed $id: address * added "hycon," in front of every custom property * changed all possible property to boolean type * removed proximity-sensor-switch property since it's not handled in driver V2->V3: As suggested by Jonathan Neuschäfer: * fixed some typo * fixed description indentation * improved boolean properties descriptions * improved hycon,report-speed description V3->V4: * fixed binding compatible string in example as suggested by Jonathan Neuschäfer --- .../input/touchscreen/hycon,hy46xx.yaml | 120 ++++++++++++++++++ MAINTAINERS | 6 + 2 files changed, 126 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml diff --git a/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml new file mode 100644 index 000000000000..8860613a12ad --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml @@ -0,0 +1,120 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/hycon,hy46xx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Hycon HY46XX series touchscreen controller bindings + +description: | + There are 6 variants of the chip for various touch panel sizes and cover lens material + Glass: 0.3mm--4.0mm + PET/PMMA: 0.2mm--2.0mm + HY4613(B)-N048 < 6" + HY4614(B)-N068 7" .. 10.1" + HY4621-NS32 < 5" + HY4623-NS48 5.1" .. 7" + Glass: 0.3mm--8.0mm + PET/PMMA: 0.2mm--4.0mm + HY4633(B)-N048 < 6" + HY4635(B)-N048 < 7" .. 10.1" + +maintainers: + - Giulio Benetti <giulio.benetti@benettiengineering.com> + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + enum: + - hycon,hycon-hy4613 + - hycon,hycon-hy4614 + - hycon,hycon-hy4621 + - hycon,hycon-hy4623 + - hycon,hycon-hy4633 + - hycon,hycon-hy4635 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + reset-gpios: + maxItems: 1 + + vcc-supply: true + + hycon,threshold: + description: Allows setting the sensitivity in the range from 0 to 255. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 255 + + hycon,glove-enable: + type: boolean + description: Allows enabling glove setting. + + hycon,report-speed: + description: Allows setting the report speed in Hertz. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 255 + + hycon,power-noise-enable: + type: boolean + description: Allows enabling power noise filter. + + hycon,filter-data: + description: Allows setting the filtering data before reporting touch + in the range from 0 to 5. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 5 + + hycon,gain: + description: Allows setting the sensitivity distance in the range from 0 to 5. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 5 + + hycon,edge-offset: + description: Allows setting the edge compensation in the range from 0 to 16. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 16 + + 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 + interrupt-controller: true + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + hycon-hy4633@1c { + compatible = "hycon,hycon-hy4633"; + reg = <0x1c>; + interrupt-parent = <&gpio2>; + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; + }; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index c80ad735b384..d022ff09e609 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8243,6 +8243,12 @@ S: Maintained F: mm/hwpoison-inject.c F: mm/memory-failure.c +HYCON HY46XX TOUCHSCREEN SUPPORT +M: Giulio Benetti <giulio.benetti@benettiengineering.com> +L: linux-input@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml + HYGON PROCESSOR SUPPORT M: Pu Wen <puwen@hygon.cn> L: linux-kernel@vger.kernel.org -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH v4 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-07 17:49 ` [PATCH v4 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti @ 2021-04-08 20:21 ` Rob Herring 2021-04-11 11:37 ` Giulio Benetti 2021-04-11 11:48 ` [PATCH v5 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 0 siblings, 2 replies; 69+ messages in thread From: Rob Herring @ 2021-04-08 20:21 UTC (permalink / raw) To: Giulio Benetti Cc: Dmitry Torokhov, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel On Wed, Apr 07, 2021 at 07:49:08PM +0200, Giulio Benetti wrote: > This adds device tree bindings for the Hycon HY46XX touchscreen series. > > Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> > --- > V1->V2: > As suggested by Rob Herring: > * fixed $id: address > * added "hycon," in front of every custom property > * changed all possible property to boolean type > * removed proximity-sensor-switch property since it's not handled in driver > V2->V3: > As suggested by Jonathan Neuschäfer: > * fixed some typo > * fixed description indentation > * improved boolean properties descriptions > * improved hycon,report-speed description > V3->V4: > * fixed binding compatible string in example as suggested by Jonathan Neuschäfer > --- > .../input/touchscreen/hycon,hy46xx.yaml | 120 ++++++++++++++++++ > MAINTAINERS | 6 + > 2 files changed, 126 insertions(+) > create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > > diff --git a/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > new file mode 100644 > index 000000000000..8860613a12ad > --- /dev/null > +++ b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > @@ -0,0 +1,120 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/input/touchscreen/hycon,hy46xx.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Hycon HY46XX series touchscreen controller bindings > + > +description: | > + There are 6 variants of the chip for various touch panel sizes and cover lens material > + Glass: 0.3mm--4.0mm > + PET/PMMA: 0.2mm--2.0mm > + HY4613(B)-N048 < 6" > + HY4614(B)-N068 7" .. 10.1" > + HY4621-NS32 < 5" > + HY4623-NS48 5.1" .. 7" > + Glass: 0.3mm--8.0mm > + PET/PMMA: 0.2mm--4.0mm > + HY4633(B)-N048 < 6" > + HY4635(B)-N048 < 7" .. 10.1" > + > +maintainers: > + - Giulio Benetti <giulio.benetti@benettiengineering.com> > + > +allOf: > + - $ref: touchscreen.yaml# > + > +properties: > + compatible: > + enum: > + - hycon,hycon-hy4613 > + - hycon,hycon-hy4614 > + - hycon,hycon-hy4621 > + - hycon,hycon-hy4623 > + - hycon,hycon-hy4633 > + - hycon,hycon-hy4635 As suggested earlier, drop the 2nd 'hycon'. > + > + reg: > + maxItems: 1 > + > + interrupts: > + maxItems: 1 > + > + reset-gpios: > + maxItems: 1 > + > + vcc-supply: true > + > + hycon,threshold: > + description: Allows setting the sensitivity in the range from 0 to 255. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 255 > + > + hycon,glove-enable: > + type: boolean > + description: Allows enabling glove setting. > + > + hycon,report-speed: > + description: Allows setting the report speed in Hertz. If in Hertz, use standard unit suffix. > + $ref: /schemas/types.yaml#/definitions/uint32 And then you can drop this. > + minimum: 0 0Hz doesn't seem to useful? > + maximum: 255 > + > + hycon,power-noise-enable: hycon,noise-filter-enable No one wants to enable power noise. :) > + type: boolean > + description: Allows enabling power noise filter. > + > + hycon,filter-data: > + description: Allows setting the filtering data before reporting touch > + in the range from 0 to 5. This is averaging samples? Sounds like something common perhaps. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 5 > + > + hycon,gain: > + description: Allows setting the sensitivity distance in the range from 0 to 5. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 5 > + > + hycon,edge-offset: > + description: Allows setting the edge compensation in the range from 0 to 16. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 16 > + > + 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 > + interrupt-controller: true > + > +additionalProperties: false > + > +required: > + - compatible > + - reg > + - interrupts > + > +examples: > + - | > + #include <dt-bindings/gpio/gpio.h> > + #include <dt-bindings/interrupt-controller/arm-gic.h> > + i2c { > + #address-cells = <1>; > + #size-cells = <0>; > + hycon-hy4633@1c { touchscreen@1c > + compatible = "hycon,hycon-hy4633"; > + reg = <0x1c>; > + interrupt-parent = <&gpio2>; > + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; > + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; > + }; > + }; > + > +... > diff --git a/MAINTAINERS b/MAINTAINERS > index c80ad735b384..d022ff09e609 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -8243,6 +8243,12 @@ S: Maintained > F: mm/hwpoison-inject.c > F: mm/memory-failure.c > > +HYCON HY46XX TOUCHSCREEN SUPPORT > +M: Giulio Benetti <giulio.benetti@benettiengineering.com> > +L: linux-input@vger.kernel.org > +S: Maintained > +F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > + > HYGON PROCESSOR SUPPORT > M: Pu Wen <puwen@hygon.cn> > L: linux-kernel@vger.kernel.org > -- > 2.25.1 > ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v4 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-08 20:21 ` Rob Herring @ 2021-04-11 11:37 ` Giulio Benetti 2021-04-11 11:48 ` [PATCH v5 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 1 sibling, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-11 11:37 UTC (permalink / raw) To: Rob Herring Cc: Dmitry Torokhov, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel On 4/8/21 10:21 PM, Rob Herring wrote: > On Wed, Apr 07, 2021 at 07:49:08PM +0200, Giulio Benetti wrote: >> This adds device tree bindings for the Hycon HY46XX touchscreen series. >> >> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> >> --- >> V1->V2: >> As suggested by Rob Herring: >> * fixed $id: address >> * added "hycon," in front of every custom property >> * changed all possible property to boolean type >> * removed proximity-sensor-switch property since it's not handled in driver >> V2->V3: >> As suggested by Jonathan Neuschäfer: >> * fixed some typo >> * fixed description indentation >> * improved boolean properties descriptions >> * improved hycon,report-speed description >> V3->V4: >> * fixed binding compatible string in example as suggested by Jonathan Neuschäfer >> --- >> .../input/touchscreen/hycon,hy46xx.yaml | 120 ++++++++++++++++++ >> MAINTAINERS | 6 + >> 2 files changed, 126 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> >> diff --git a/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> new file mode 100644 >> index 000000000000..8860613a12ad >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> @@ -0,0 +1,120 @@ >> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) >> +%YAML 1.2 >> +--- >> +$id: http://devicetree.org/schemas/input/touchscreen/hycon,hy46xx.yaml# >> +$schema: http://devicetree.org/meta-schemas/core.yaml# >> + >> +title: Hycon HY46XX series touchscreen controller bindings >> + >> +description: | >> + There are 6 variants of the chip for various touch panel sizes and cover lens material >> + Glass: 0.3mm--4.0mm >> + PET/PMMA: 0.2mm--2.0mm >> + HY4613(B)-N048 < 6" >> + HY4614(B)-N068 7" .. 10.1" >> + HY4621-NS32 < 5" >> + HY4623-NS48 5.1" .. 7" >> + Glass: 0.3mm--8.0mm >> + PET/PMMA: 0.2mm--4.0mm >> + HY4633(B)-N048 < 6" >> + HY4635(B)-N048 < 7" .. 10.1" >> + >> +maintainers: >> + - Giulio Benetti <giulio.benetti@benettiengineering.com> >> + >> +allOf: >> + - $ref: touchscreen.yaml# >> + >> +properties: >> + compatible: >> + enum: >> + - hycon,hycon-hy4613 >> + - hycon,hycon-hy4614 >> + - hycon,hycon-hy4621 >> + - hycon,hycon-hy4623 >> + - hycon,hycon-hy4633 >> + - hycon,hycon-hy4635 > > As suggested earlier, drop the 2nd 'hycon'. Ok >> + >> + reg: >> + maxItems: 1 >> + >> + interrupts: >> + maxItems: 1 >> + >> + reset-gpios: >> + maxItems: 1 >> + >> + vcc-supply: true >> + >> + hycon,threshold: >> + description: Allows setting the sensitivity in the range from 0 to 255. >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 255 >> + >> + hycon,glove-enable: >> + type: boolean >> + description: Allows enabling glove setting. >> + >> + hycon,report-speed: >> + description: Allows setting the report speed in Hertz. > > If in Hertz, use standard unit suffix. > >> + $ref: /schemas/types.yaml#/definitions/uint32 > > And then you can drop this. Ok >> + minimum: 0 > > 0Hz doesn't seem to useful? You're right, I've also checked and with 0Hz controller correctly does nothing. I've also tried seeting 1Hz and it actually works, but at 1Hz, so I keep 1Hz as minimum. >> + maximum: 255 >> + >> + hycon,power-noise-enable: > > hycon,noise-filter-enable > > No one wants to enable power noise. :) :-) Yeah > >> + type: boolean >> + description: Allows enabling power noise filter. >> + >> + hycon,filter-data: >> + description: Allows setting the filtering data before reporting touch >> + in the range from 0 to 5. > > This is averaging samples? Sounds like something common perhaps. maybe you mean touchscreen-average-samples property, but this is not the case.In datasheet they state "Before report coordinate throw away the data number, setting range:0--5" and I've tried sweep-setting it 1-5 and what I get with filter-data set to 5 is that touchscreen answers after like 0.5 seconds but keep reporting as fast as set report-speed, so to me it throws away the first samples because it considers them "bad" samples when one is first touching the panel. So I'm going to modify the description as: description: Allows setting how many samples throw before reporting touch in the range from 0 to 5. >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 5 >> + >> + hycon,gain: >> + description: Allows setting the sensitivity distance in the range from 0 to 5. >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 5 >> + >> + hycon,edge-offset: >> + description: Allows setting the edge compensation in the range from 0 to 16. >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 16 >> + >> + 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 >> + interrupt-controller: true >> + >> +additionalProperties: false >> + >> +required: >> + - compatible >> + - reg >> + - interrupts >> + >> +examples: >> + - | >> + #include <dt-bindings/gpio/gpio.h> >> + #include <dt-bindings/interrupt-controller/arm-gic.h> >> + i2c { >> + #address-cells = <1>; >> + #size-cells = <0>; >> + hycon-hy4633@1c { > > touchscreen@1c Ok >> + compatible = "hycon,hycon-hy4633"; >> + reg = <0x1c>; >> + interrupt-parent = <&gpio2>; >> + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; >> + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; >> + }; >> + }; >> + >> +... >> diff --git a/MAINTAINERS b/MAINTAINERS >> index c80ad735b384..d022ff09e609 100644 >> --- a/MAINTAINERS >> +++ b/MAINTAINERS >> @@ -8243,6 +8243,12 @@ S: Maintained >> F: mm/hwpoison-inject.c >> F: mm/memory-failure.c >> >> +HYCON HY46XX TOUCHSCREEN SUPPORT >> +M: Giulio Benetti <giulio.benetti@benettiengineering.com> >> +L: linux-input@vger.kernel.org >> +S: Maintained >> +F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> + >> HYGON PROCESSOR SUPPORT >> M: Pu Wen <puwen@hygon.cn> >> L: linux-kernel@vger.kernel.org >> -- >> 2.25.1 >> Thank you Best regards -- Giulio Benetti Benetti Engineering sas ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v5 0/3] Input: add Hycon HY46XX Touchscreen controller 2021-04-08 20:21 ` Rob Herring 2021-04-11 11:37 ` Giulio Benetti @ 2021-04-11 11:48 ` Giulio Benetti 2021-04-11 11:48 ` [PATCH v5 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti ` (2 more replies) 1 sibling, 3 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-11 11:48 UTC (permalink / raw) To: Rob Herring Cc: Dmitry Torokhov, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel, Giulio Benetti This patchset adds Hycon vendor, HY46XX touchscreen controller driver and its .yaml binding. --- V1->V2: * changed authorship and SoBs to @benettiengineering.com domain * fixed vendor commit log according to Jonathan Neuschäfer's suggestion * fixed hy46xx bindings according to Rob Herring's suggestions * fixed hy46xx driver according to Dmitry Torokhov's suggestions further details are listed in single patches V2->V3: * fixed hy46xx bindings according to Jonathan Neuschäfer's suggestion * fixed hy46xx driver according to Jonathan Neuschäfer's suggestion further details are listed in single patches V3->V4: * fixed binding compatible string as suggested by Jonathan Neuschäfer V4->V5: * fixed hy46xx bindings and driver according to Rob Herring's suggestions further details are listed in single patches --- Giulio Benetti (3): dt-bindings: Add Hycon Technology vendor prefix dt-bindings: touchscreen: Add HY46XX bindings Input: add driver for the Hycon HY46XX touchpanel series .../input/touchscreen/hycon,hy46xx.yaml | 119 ++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + MAINTAINERS | 7 + drivers/input/touchscreen/Kconfig | 11 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/hycon-hy46xx.c | 591 ++++++++++++++++++ 6 files changed, 731 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml create mode 100644 drivers/input/touchscreen/hycon-hy46xx.c -- 2.25.1 ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v5 1/3] dt-bindings: Add Hycon Technology vendor prefix 2021-04-11 11:48 ` [PATCH v5 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti @ 2021-04-11 11:48 ` Giulio Benetti 2021-04-12 15:05 ` Rob Herring 2021-04-11 11:48 ` [PATCH v5 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-04-11 11:48 ` [PATCH v5 3/3] " Giulio Benetti 2 siblings, 1 reply; 69+ messages in thread From: Giulio Benetti @ 2021-04-11 11:48 UTC (permalink / raw) To: Rob Herring Cc: Dmitry Torokhov, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel, Giulio Benetti Update Documentation/devicetree/bindings/vendor-prefixes.yaml to include "hycon" as a vendor prefix for "Hycon Technology". Company website: https://www.hycontek.com/ Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> --- 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 a1312637d6ff..67f429a757cd 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -489,6 +489,8 @@ patternProperties: description: Shenzhen Hugsun Technology Co. Ltd. "^hwacom,.*": description: HwaCom Systems Inc. + "^hycon,.*": + description: Hycon Technology Corp. "^hydis,.*": description: Hydis Technologies "^hyundai,.*": -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH v5 1/3] dt-bindings: Add Hycon Technology vendor prefix 2021-04-11 11:48 ` [PATCH v5 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti @ 2021-04-12 15:05 ` Rob Herring 2021-04-12 15:12 ` Giulio Benetti 0 siblings, 1 reply; 69+ messages in thread From: Rob Herring @ 2021-04-12 15:05 UTC (permalink / raw) To: Giulio Benetti Cc: devicetree, Henrik Rydberg, linux-input, Dmitry Torokhov, Jonathan Neuschäfer, linux-kernel On Sun, 11 Apr 2021 13:48:02 +0200, Giulio Benetti wrote: > Update Documentation/devicetree/bindings/vendor-prefixes.yaml to > include "hycon" as a vendor prefix for "Hycon Technology". > Company website: https://www.hycontek.com/ > > Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> > Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> > --- > Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ > 1 file changed, 2 insertions(+) > Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply. If a tag was not added on purpose, please state why and what changed. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v5 1/3] dt-bindings: Add Hycon Technology vendor prefix 2021-04-12 15:05 ` Rob Herring @ 2021-04-12 15:12 ` Giulio Benetti 2021-04-13 13:35 ` Rob Herring 0 siblings, 1 reply; 69+ messages in thread From: Giulio Benetti @ 2021-04-12 15:12 UTC (permalink / raw) To: Rob Herring Cc: devicetree, Henrik Rydberg, linux-input, Dmitry Torokhov, Jonathan Neuschäfer, linux-kernel On 4/12/21 5:05 PM, Rob Herring wrote: > On Sun, 11 Apr 2021 13:48:02 +0200, Giulio Benetti wrote: >> Update Documentation/devicetree/bindings/vendor-prefixes.yaml to >> include "hycon" as a vendor prefix for "Hycon Technology". >> Company website: https://www.hycontek.com/ >> >> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> >> Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> >> --- >> Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ >> 1 file changed, 2 insertions(+) >> > > > Please add Acked-by/Reviewed-by tags when posting new versions. However, > there's no need to repost patches *only* to add the tags. The upstream > maintainer will do that for acks received on the version they apply. > > If a tag was not added on purpose, please state why and what changed. > Ok, so on V6 series I'll send only patches 2 and 3 without this one. -- Giulio Benetti Benetti Engineering sas ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v5 1/3] dt-bindings: Add Hycon Technology vendor prefix 2021-04-12 15:12 ` Giulio Benetti @ 2021-04-13 13:35 ` Rob Herring 2021-04-13 14:44 ` [PATCH v7 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 0 siblings, 1 reply; 69+ messages in thread From: Rob Herring @ 2021-04-13 13:35 UTC (permalink / raw) To: Giulio Benetti Cc: devicetree, Henrik Rydberg, Linux Input, Dmitry Torokhov, Jonathan Neuschäfer, linux-kernel On Mon, Apr 12, 2021 at 10:12 AM Giulio Benetti <giulio.benetti@benettiengineering.com> wrote: > > On 4/12/21 5:05 PM, Rob Herring wrote: > > On Sun, 11 Apr 2021 13:48:02 +0200, Giulio Benetti wrote: > >> Update Documentation/devicetree/bindings/vendor-prefixes.yaml to > >> include "hycon" as a vendor prefix for "Hycon Technology". > >> Company website: https://www.hycontek.com/ > >> > >> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> > >> Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> > >> --- > >> Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ > >> 1 file changed, 2 insertions(+) > >> > > > > > > Please add Acked-by/Reviewed-by tags when posting new versions. However, > > there's no need to repost patches *only* to add the tags. The upstream > > maintainer will do that for acks received on the version they apply. > > > > If a tag was not added on purpose, please state why and what changed. > > > > Ok, so on V6 series I'll send only patches 2 and 3 without this one. No, send the whole series and add any tags. Just don't resend a series for the sole purpose of adding tags. Rob ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v7 0/3] Input: add Hycon HY46XX Touchscreen controller 2021-04-13 13:35 ` Rob Herring @ 2021-04-13 14:44 ` Giulio Benetti 2021-04-13 14:44 ` [PATCH v7 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti ` (2 more replies) 0 siblings, 3 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-13 14:44 UTC (permalink / raw) To: Rob Herring Cc: Dmitry Torokhov, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel, Giulio Benetti This patchset adds Hycon vendor, HY46XX touchscreen controller driver and its .yaml binding. --- V1->V2: * changed authorship and SoBs to @benettiengineering.com domain * fixed vendor commit log according to Jonathan Neuschäfer's suggestion * fixed hy46xx bindings according to Rob Herring's suggestions * fixed hy46xx driver according to Dmitry Torokhov's suggestions further details are listed in single patches V2->V3: * fixed hy46xx bindings according to Jonathan Neuschäfer's suggestion * fixed hy46xx driver according to Jonathan Neuschäfer's suggestion further details are listed in single patches V3->V4: * fixed binding compatible string as suggested by Jonathan Neuschäfer V4->V5: * fixed hy46xx bindings and driver according to Rob Herring's suggestions further details are listed in single patches V5->V6: * changed report-speed property name into report-speed-hz according to Rob Herring's suggestion V6->V7: * added missing patch to series --- Giulio Benetti (3): dt-bindings: Add Hycon Technology vendor prefix dt-bindings: touchscreen: Add HY46XX bindings Input: add driver for the Hycon HY46XX touchpanel series .../input/touchscreen/hycon,hy46xx.yaml | 119 ++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + MAINTAINERS | 7 + drivers/input/touchscreen/Kconfig | 11 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/hycon-hy46xx.c | 591 ++++++++++++++++++ 6 files changed, 731 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml create mode 100644 drivers/input/touchscreen/hycon-hy46xx.c -- 2.25.1 ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v7 1/3] dt-bindings: Add Hycon Technology vendor prefix 2021-04-13 14:44 ` [PATCH v7 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti @ 2021-04-13 14:44 ` Giulio Benetti 2021-04-14 5:44 ` Dmitry Torokhov 2021-04-13 14:44 ` [PATCH v7 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-04-13 14:44 ` [PATCH v7 3/3] Input: add driver for the Hycon HY46XX touchpanel series Giulio Benetti 2 siblings, 1 reply; 69+ messages in thread From: Giulio Benetti @ 2021-04-13 14:44 UTC (permalink / raw) To: Rob Herring Cc: Dmitry Torokhov, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel, Giulio Benetti Update Documentation/devicetree/bindings/vendor-prefixes.yaml to include "hycon" as a vendor prefix for "Hycon Technology". Company website: https://www.hycontek.com/ Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Acked-by: Rob Herring <robh@kernel.org> --- 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 a1312637d6ff..67f429a757cd 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -489,6 +489,8 @@ patternProperties: description: Shenzhen Hugsun Technology Co. Ltd. "^hwacom,.*": description: HwaCom Systems Inc. + "^hycon,.*": + description: Hycon Technology Corp. "^hydis,.*": description: Hydis Technologies "^hyundai,.*": -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH v7 1/3] dt-bindings: Add Hycon Technology vendor prefix 2021-04-13 14:44 ` [PATCH v7 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti @ 2021-04-14 5:44 ` Dmitry Torokhov 0 siblings, 0 replies; 69+ messages in thread From: Dmitry Torokhov @ 2021-04-14 5:44 UTC (permalink / raw) To: Giulio Benetti Cc: Rob Herring, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel On Tue, Apr 13, 2021 at 04:44:44PM +0200, Giulio Benetti wrote: > Update Documentation/devicetree/bindings/vendor-prefixes.yaml to > include "hycon" as a vendor prefix for "Hycon Technology". > Company website: https://www.hycontek.com/ > > Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> > Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> > Acked-by: Rob Herring <robh@kernel.org> Applied, thank you. -- Dmitry ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v7 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-13 14:44 ` [PATCH v7 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-13 14:44 ` [PATCH v7 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti @ 2021-04-13 14:44 ` Giulio Benetti 2021-04-13 16:36 ` Rob Herring 2021-04-14 5:44 ` Dmitry Torokhov 2021-04-13 14:44 ` [PATCH v7 3/3] Input: add driver for the Hycon HY46XX touchpanel series Giulio Benetti 2 siblings, 2 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-13 14:44 UTC (permalink / raw) To: Rob Herring Cc: Dmitry Torokhov, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel, Giulio Benetti This adds device tree bindings for the Hycon HY46XX touchscreen series. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> --- V1->V2: As suggested by Rob Herring: * fixed $id: address * added "hycon," in front of every custom property * changed all possible property to boolean type * removed proximity-sensor-switch property since it's not handled in driver V2->V3: As suggested by Jonathan Neuschäfer: * fixed some typo * fixed description indentation * improved boolean properties descriptions * improved hycon,report-speed description V3->V4: * fixed binding compatible string in example as suggested by Jonathan Neuschäfer V4->V5: As suggested by Rob Herring: * drop hycon- prefix from compatible * use Hertz unit suffix for hycon,report-speed instead of u32 * set hycon,report-speed minimum to 1Hz, 0Hz make controller to do nothing * change hycon,power-noise-enable property name to hycon,noise-filter-enable * improve hycon,filter-data property description * use generic touchscreen node name in example V5->V6: * changed report-speed property name into report-speed-hz according to Rob Herring's suggestion --- .../input/touchscreen/hycon,hy46xx.yaml | 119 ++++++++++++++++++ MAINTAINERS | 6 + 2 files changed, 125 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml diff --git a/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml new file mode 100644 index 000000000000..942562f1e45b --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml @@ -0,0 +1,119 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/hycon,hy46xx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Hycon HY46XX series touchscreen controller bindings + +description: | + There are 6 variants of the chip for various touch panel sizes and cover lens material + Glass: 0.3mm--4.0mm + PET/PMMA: 0.2mm--2.0mm + HY4613(B)-N048 < 6" + HY4614(B)-N068 7" .. 10.1" + HY4621-NS32 < 5" + HY4623-NS48 5.1" .. 7" + Glass: 0.3mm--8.0mm + PET/PMMA: 0.2mm--4.0mm + HY4633(B)-N048 < 6" + HY4635(B)-N048 < 7" .. 10.1" + +maintainers: + - Giulio Benetti <giulio.benetti@benettiengineering.com> + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + enum: + - hycon,hy4613 + - hycon,hy4614 + - hycon,hy4621 + - hycon,hy4623 + - hycon,hy4633 + - hycon,hy4635 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + reset-gpios: + maxItems: 1 + + vcc-supply: true + + hycon,threshold: + description: Allows setting the sensitivity in the range from 0 to 255. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 255 + + hycon,glove-enable: + type: boolean + description: Allows enabling glove setting. + + hycon,report-speed-hz: + description: Allows setting the report speed in Hertz. + minimum: 1 + maximum: 255 + + hycon,noise-filter-enable: + type: boolean + description: Allows enabling power noise filter. + + hycon,filter-data: + description: Allows setting how many samples throw before reporting touch + in the range from 0 to 5. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 5 + + hycon,gain: + description: Allows setting the sensitivity distance in the range from 0 to 5. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 5 + + hycon,edge-offset: + description: Allows setting the edge compensation in the range from 0 to 16. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 16 + + 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 + interrupt-controller: true + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + touchscreen@1c { + compatible = "hycon,hy4633"; + reg = <0x1c>; + interrupt-parent = <&gpio2>; + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; + }; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index 7fdc513392f4..18a50942c019 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8250,6 +8250,12 @@ S: Maintained F: mm/hwpoison-inject.c F: mm/memory-failure.c +HYCON HY46XX TOUCHSCREEN SUPPORT +M: Giulio Benetti <giulio.benetti@benettiengineering.com> +L: linux-input@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml + HYGON PROCESSOR SUPPORT M: Pu Wen <puwen@hygon.cn> L: linux-kernel@vger.kernel.org -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH v7 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-13 14:44 ` [PATCH v7 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti @ 2021-04-13 16:36 ` Rob Herring 2021-04-14 5:44 ` Dmitry Torokhov 1 sibling, 0 replies; 69+ messages in thread From: Rob Herring @ 2021-04-13 16:36 UTC (permalink / raw) To: Giulio Benetti Cc: devicetree, linux-input, Henrik Rydberg, Dmitry Torokhov, Jonathan Neuschäfer, linux-kernel On Tue, 13 Apr 2021 16:44:45 +0200, Giulio Benetti wrote: > This adds device tree bindings for the Hycon HY46XX touchscreen series. > > Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> > --- > V1->V2: > As suggested by Rob Herring: > * fixed $id: address > * added "hycon," in front of every custom property > * changed all possible property to boolean type > * removed proximity-sensor-switch property since it's not handled in driver > V2->V3: > As suggested by Jonathan Neuschäfer: > * fixed some typo > * fixed description indentation > * improved boolean properties descriptions > * improved hycon,report-speed description > V3->V4: > * fixed binding compatible string in example as suggested by Jonathan Neuschäfer > V4->V5: > As suggested by Rob Herring: > * drop hycon- prefix from compatible > * use Hertz unit suffix for hycon,report-speed instead of u32 > * set hycon,report-speed minimum to 1Hz, 0Hz make controller to do nothing > * change hycon,power-noise-enable property name to hycon,noise-filter-enable > * improve hycon,filter-data property description > * use generic touchscreen node name in example > V5->V6: > * changed report-speed property name into report-speed-hz according to > Rob Herring's suggestion > --- > .../input/touchscreen/hycon,hy46xx.yaml | 119 ++++++++++++++++++ > MAINTAINERS | 6 + > 2 files changed, 125 insertions(+) > create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > Reviewed-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v7 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-13 14:44 ` [PATCH v7 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-04-13 16:36 ` Rob Herring @ 2021-04-14 5:44 ` Dmitry Torokhov 1 sibling, 0 replies; 69+ messages in thread From: Dmitry Torokhov @ 2021-04-14 5:44 UTC (permalink / raw) To: Giulio Benetti Cc: Rob Herring, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel On Tue, Apr 13, 2021 at 04:44:45PM +0200, Giulio Benetti wrote: > This adds device tree bindings for the Hycon HY46XX touchscreen series. > > Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> Applied, thank you. -- Dmitry ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v7 3/3] Input: add driver for the Hycon HY46XX touchpanel series 2021-04-13 14:44 ` [PATCH v7 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-13 14:44 ` [PATCH v7 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti 2021-04-13 14:44 ` [PATCH v7 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti @ 2021-04-13 14:44 ` Giulio Benetti 2021-04-14 5:44 ` Dmitry Torokhov 2 siblings, 1 reply; 69+ messages in thread From: Giulio Benetti @ 2021-04-13 14:44 UTC (permalink / raw) To: Rob Herring Cc: Dmitry Torokhov, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel, Giulio Benetti This patch adds support for Hycon HY46XX. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> --- V1->V2: * removed proximity-sensor-switch property according to previous patch As suggested by Dmitry Torokhov * moved i2c communaction to regmap use * added macro to avoid magic number * removed cmd variable that could uninitiliazed since we're using regmap now * removed useless byte masking * removed useless struct hycon_hy46xx_i2c_chip_data * used IRQF_ONESHOT only for isr V2->V3: As suggested by Jonathan Neuschäfer: * fixed Kconfig description * fixed DT properties by preprending "hycon," * changed MODULE_AUTHOR() e-mail according to SoB and authorship V4->V5: As suggested by Rob Herring according to dt-bindings: * drop hycon- prefix from compatible * change hycon,power-noise-enable property name to hycon,noise-filter-enable and change power_noise_enable variable name to noise_filter_enable V5->V6: * changed report-speed property name into report-speed-hz according to Rob Herring's suggestion --- MAINTAINERS | 1 + drivers/input/touchscreen/Kconfig | 11 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/hycon-hy46xx.c | 591 +++++++++++++++++++++++ 4 files changed, 604 insertions(+) create mode 100644 drivers/input/touchscreen/hycon-hy46xx.c diff --git a/MAINTAINERS b/MAINTAINERS index 18a50942c019..588ca21cfc09 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8255,6 +8255,7 @@ M: Giulio Benetti <giulio.benetti@benettiengineering.com> L: linux-input@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml +F: drivers/input/touchscreen/hy46xx.c HYGON PROCESSOR SUPPORT M: Pu Wen <puwen@hygon.cn> diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 529614d364fe..fe1468b74530 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1335,4 +1335,15 @@ config TOUCHSCREEN_ZINITIX To compile this driver as a module, choose M here: the module will be called zinitix. +config TOUCHSCREEN_HYCON_HY46XX + tristate "Hycon hy46xx touchscreen support" + depends on I2C + help + Say Y here if you have a touchscreen using Hycon hy46xx + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called hycon-hy46xx. + endif diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 6233541e9173..8b68cf3a3e6d 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -112,3 +112,4 @@ obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o obj-$(CONFIG_TOUCHSCREEN_ZINITIX) += zinitix.o +obj-$(CONFIG_TOUCHSCREEN_HYCON_HY46XX) += hycon-hy46xx.o diff --git a/drivers/input/touchscreen/hycon-hy46xx.c b/drivers/input/touchscreen/hycon-hy46xx.c new file mode 100644 index 000000000000..4afc88dd0293 --- /dev/null +++ b/drivers/input/touchscreen/hycon-hy46xx.c @@ -0,0 +1,591 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 + * Author(s): Giulio Benetti <giulio.benetti@benettiengineering.com> + */ + +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/input.h> +#include <linux/input/mt.h> +#include <linux/input/touchscreen.h> +#include <linux/irq.h> +#include <linux/regulator/consumer.h> +#include <linux/regmap.h> + +#include <asm/unaligned.h> + +#define HY46XX_CHKSUM_CODE 0x1 +#define HY46XX_FINGER_NUM 0x2 +#define HY46XX_CHKSUM_LEN 0x7 +#define HY46XX_THRESHOLD 0x80 +#define HY46XX_GLOVE_EN 0x84 +#define HY46XX_REPORT_SPEED 0x88 +#define HY46XX_PWR_NOISE_EN 0x89 +#define HY46XX_FILTER_DATA 0x8A +#define HY46XX_GAIN 0x92 +#define HY46XX_EDGE_OFFSET 0x93 +#define HY46XX_RX_NR_USED 0x94 +#define HY46XX_TX_NR_USED 0x95 +#define HY46XX_PWR_MODE 0xA5 +#define HY46XX_FW_VERSION 0xA6 +#define HY46XX_LIB_VERSION 0xA7 +#define HY46XX_TP_INFO 0xA8 +#define HY46XX_TP_CHIP_ID 0xA9 +#define HY46XX_BOOT_VER 0xB0 + +#define HY46XX_TPLEN 0x6 +#define HY46XX_REPORT_PKT_LEN 0x44 + +#define HY46XX_MAX_SUPPORTED_POINTS 11 + +#define TOUCH_EVENT_DOWN 0x00 +#define TOUCH_EVENT_UP 0x01 +#define TOUCH_EVENT_CONTACT 0x02 +#define TOUCH_EVENT_RESERVED 0x03 + +struct hycon_hy46xx_data { + struct i2c_client *client; + struct input_dev *input; + struct touchscreen_properties prop; + struct regulator *vcc; + + struct gpio_desc *reset_gpio; + + struct mutex mutex; + struct regmap *regmap; + + int threshold; + bool glove_enable; + int report_speed; + bool noise_filter_enable; + int filter_data; + int gain; + int edge_offset; + int rx_number_used; + int tx_number_used; + int power_mode; + int fw_version; + int lib_version; + int tp_information; + int tp_chip_id; + int bootloader_version; +}; + +static const struct regmap_config hycon_hy46xx_i2c_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; + +static bool hycon_hy46xx_check_checksum(struct hycon_hy46xx_data *tsdata, u8 *buf) +{ + u8 chksum = 0; + int i; + + for (i = 2; i < buf[HY46XX_CHKSUM_LEN]; i++) + chksum += buf[i]; + + if (chksum == buf[HY46XX_CHKSUM_CODE]) + return true; + + dev_err_ratelimited(&tsdata->client->dev, + "checksum error: 0x%02x expected, got 0x%02x\n", + chksum, buf[HY46XX_CHKSUM_CODE]); + + return false; +} + +static irqreturn_t hycon_hy46xx_isr(int irq, void *dev_id) +{ + struct hycon_hy46xx_data *tsdata = dev_id; + struct device *dev = &tsdata->client->dev; + u8 rdbuf[HY46XX_REPORT_PKT_LEN]; + int i, x, y, id; + int error; + + memset(rdbuf, 0, sizeof(rdbuf)); + + error = regmap_bulk_read(tsdata->regmap, 0, rdbuf, sizeof(rdbuf)); + if (error) { + dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n", + error); + goto out; + } + + if (!hycon_hy46xx_check_checksum(tsdata, rdbuf)) + goto out; + + for (i = 0; i < HY46XX_MAX_SUPPORTED_POINTS; i++) { + u8 *buf = &rdbuf[3 + (HY46XX_TPLEN * i)]; + int type = buf[0] >> 6; + + if (type == TOUCH_EVENT_RESERVED) + continue; + + x = get_unaligned_be16(buf) & 0x0fff; + y = get_unaligned_be16(buf + 2) & 0x0fff; + + id = buf[2] >> 4; + + input_mt_slot(tsdata->input, id); + if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, + type != TOUCH_EVENT_UP)) + touchscreen_report_pos(tsdata->input, &tsdata->prop, + x, y, true); + } + + input_mt_report_pointer_emulation(tsdata->input, true); + input_sync(tsdata->input); + +out: + return IRQ_HANDLED; +} + +struct hycon_hy46xx_attribute { + struct device_attribute dattr; + size_t field_offset; + u8 address; + u8 limit_low; + u8 limit_high; +}; + +#define HYCON_ATTR_U8(_field, _mode, _address, _limit_low, _limit_high) \ + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ + .dattr = __ATTR(_field, _mode, \ + hycon_hy46xx_setting_show, \ + hycon_hy46xx_setting_store), \ + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ + .address = _address, \ + .limit_low = _limit_low, \ + .limit_high = _limit_high, \ + } + +#define HYCON_ATTR_BOOL(_field, _mode, _address) \ + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ + .dattr = __ATTR(_field, _mode, \ + hycon_hy46xx_setting_show, \ + hycon_hy46xx_setting_store), \ + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ + .address = _address, \ + .limit_low = false, \ + .limit_high = true, \ + } + +static ssize_t hycon_hy46xx_setting_show(struct device *dev, + struct device_attribute *dattr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); + struct hycon_hy46xx_attribute *attr = + container_of(dattr, struct hycon_hy46xx_attribute, dattr); + u8 *field = (u8 *)tsdata + attr->field_offset; + size_t count = 0; + int error = 0; + int val; + + mutex_lock(&tsdata->mutex); + + error = regmap_read(tsdata->regmap, attr->address, &val); + if (error < 0) { + dev_err(&tsdata->client->dev, + "Failed to fetch attribute %s, error %d\n", + dattr->attr.name, error); + goto out; + } + + if (val != *field) { + dev_warn(&tsdata->client->dev, + "%s: read (%d) and stored value (%d) differ\n", + dattr->attr.name, val, *field); + *field = val; + } + + count = scnprintf(buf, PAGE_SIZE, "%d\n", val); + +out: + mutex_unlock(&tsdata->mutex); + return error ?: count; +} + +static ssize_t hycon_hy46xx_setting_store(struct device *dev, + struct device_attribute *dattr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); + struct hycon_hy46xx_attribute *attr = + container_of(dattr, struct hycon_hy46xx_attribute, dattr); + u8 *field = (u8 *)tsdata + attr->field_offset; + unsigned int val; + int error; + + mutex_lock(&tsdata->mutex); + + error = kstrtouint(buf, 0, &val); + if (error) + goto out; + + if (val < attr->limit_low || val > attr->limit_high) { + error = -ERANGE; + goto out; + } + + error = regmap_write(tsdata->regmap, attr->address, val); + if (error < 0) { + dev_err(&tsdata->client->dev, + "Failed to update attribute %s, error: %d\n", + dattr->attr.name, error); + goto out; + } + *field = val; + +out: + mutex_unlock(&tsdata->mutex); + return error ?: count; +} + +static HYCON_ATTR_U8(threshold, 0644, HY46XX_THRESHOLD, 0, 255); +static HYCON_ATTR_BOOL(glove_enable, 0644, HY46XX_GLOVE_EN); +static HYCON_ATTR_U8(report_speed, 0644, HY46XX_REPORT_SPEED, 0, 255); +static HYCON_ATTR_BOOL(noise_filter_enable, 0644, HY46XX_PWR_NOISE_EN); +static HYCON_ATTR_U8(filter_data, 0644, HY46XX_FILTER_DATA, 0, 5); +static HYCON_ATTR_U8(gain, 0644, HY46XX_GAIN, 0, 5); +static HYCON_ATTR_U8(edge_offset, 0644, HY46XX_EDGE_OFFSET, 0, 5); +static HYCON_ATTR_U8(fw_version, 0444, HY46XX_FW_VERSION, 0, 255); +static HYCON_ATTR_U8(lib_version, 0444, HY46XX_LIB_VERSION, 0, 255); +static HYCON_ATTR_U8(tp_information, 0444, HY46XX_TP_INFO, 0, 255); +static HYCON_ATTR_U8(tp_chip_id, 0444, HY46XX_TP_CHIP_ID, 0, 255); +static HYCON_ATTR_U8(bootloader_version, 0444, HY46XX_BOOT_VER, 0, 255); + +static struct attribute *hycon_hy46xx_attrs[] = { + &hycon_hy46xx_attr_threshold.dattr.attr, + &hycon_hy46xx_attr_glove_enable.dattr.attr, + &hycon_hy46xx_attr_report_speed.dattr.attr, + &hycon_hy46xx_attr_noise_filter_enable.dattr.attr, + &hycon_hy46xx_attr_filter_data.dattr.attr, + &hycon_hy46xx_attr_gain.dattr.attr, + &hycon_hy46xx_attr_edge_offset.dattr.attr, + &hycon_hy46xx_attr_fw_version.dattr.attr, + &hycon_hy46xx_attr_lib_version.dattr.attr, + &hycon_hy46xx_attr_tp_information.dattr.attr, + &hycon_hy46xx_attr_tp_chip_id.dattr.attr, + &hycon_hy46xx_attr_bootloader_version.dattr.attr, + NULL +}; + +static const struct attribute_group hycon_hy46xx_attr_group = { + .attrs = hycon_hy46xx_attrs, +}; + +static void hycon_hy46xx_get_defaults(struct device *dev, struct hycon_hy46xx_data *tsdata) +{ + bool val_bool; + int error; + u32 val; + + error = device_property_read_u32(dev, "hycon,threshold", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_THRESHOLD, val); + if (error < 0) + goto out; + + tsdata->threshold = val; + } + + val_bool = device_property_read_bool(dev, "hycon,glove-enable"); + error = regmap_write(tsdata->regmap, HY46XX_GLOVE_EN, val_bool); + if (error < 0) + goto out; + tsdata->glove_enable = val_bool; + + error = device_property_read_u32(dev, "hycon,report-speed-hz", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_REPORT_SPEED, val); + if (error < 0) + goto out; + + tsdata->report_speed = val; + } + + val_bool = device_property_read_bool(dev, "hycon,noise-filter-enable"); + error = regmap_write(tsdata->regmap, HY46XX_PWR_NOISE_EN, val_bool); + if (error < 0) + goto out; + tsdata->noise_filter_enable = val_bool; + + error = device_property_read_u32(dev, "hycon,filter-data", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_FILTER_DATA, val); + if (error < 0) + goto out; + + tsdata->filter_data = val; + } + + error = device_property_read_u32(dev, "hycon,gain", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_GAIN, val); + if (error < 0) + goto out; + + tsdata->gain = val; + } + + error = device_property_read_u32(dev, "hycon,edge-offset", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_EDGE_OFFSET, val); + if (error < 0) + goto out; + + tsdata->edge_offset = val; + } + + return; +out: + dev_err(&tsdata->client->dev, "Failed to set default settings"); +} + +static void hycon_hy46xx_get_parameters(struct hycon_hy46xx_data *tsdata) +{ + int error; + u32 val; + + error = regmap_read(tsdata->regmap, HY46XX_THRESHOLD, &val); + if (error < 0) + goto out; + tsdata->threshold = val; + + error = regmap_read(tsdata->regmap, HY46XX_GLOVE_EN, &val); + if (error < 0) + goto out; + tsdata->glove_enable = val; + + error = regmap_read(tsdata->regmap, HY46XX_REPORT_SPEED, &val); + if (error < 0) + goto out; + tsdata->report_speed = val; + + error = regmap_read(tsdata->regmap, HY46XX_PWR_NOISE_EN, &val); + if (error < 0) + goto out; + tsdata->noise_filter_enable = val; + + error = regmap_read(tsdata->regmap, HY46XX_FILTER_DATA, &val); + if (error < 0) + goto out; + tsdata->filter_data = val; + + error = regmap_read(tsdata->regmap, HY46XX_GAIN, &val); + if (error < 0) + goto out; + tsdata->gain = val; + + error = regmap_read(tsdata->regmap, HY46XX_EDGE_OFFSET, &val); + if (error < 0) + goto out; + tsdata->edge_offset = val; + + error = regmap_read(tsdata->regmap, HY46XX_RX_NR_USED, &val); + if (error < 0) + goto out; + tsdata->rx_number_used = val; + + error = regmap_read(tsdata->regmap, HY46XX_TX_NR_USED, &val); + if (error < 0) + goto out; + tsdata->tx_number_used = val; + + error = regmap_read(tsdata->regmap, HY46XX_PWR_MODE, &val); + if (error < 0) + goto out; + tsdata->power_mode = val; + + error = regmap_read(tsdata->regmap, HY46XX_FW_VERSION, &val); + if (error < 0) + goto out; + tsdata->fw_version = val; + + error = regmap_read(tsdata->regmap, HY46XX_LIB_VERSION, &val); + if (error < 0) + goto out; + tsdata->lib_version = val; + + error = regmap_read(tsdata->regmap, HY46XX_TP_INFO, &val); + if (error < 0) + goto out; + tsdata->tp_information = val; + + error = regmap_read(tsdata->regmap, HY46XX_TP_CHIP_ID, &val); + if (error < 0) + goto out; + tsdata->tp_chip_id = val; + + error = regmap_read(tsdata->regmap, HY46XX_BOOT_VER, &val); + if (error < 0) + goto out; + tsdata->bootloader_version = val; + + return; +out: + dev_err(&tsdata->client->dev, "Failed to read default settings"); +} + +static void hycon_hy46xx_disable_regulator(void *arg) +{ + struct hycon_hy46xx_data *data = arg; + + regulator_disable(data->vcc); +} + +static int hycon_hy46xx_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct hycon_hy46xx_data *tsdata; + struct input_dev *input; + int error; + + dev_dbg(&client->dev, "probing for HYCON HY46XX I2C\n"); + + tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL); + if (!tsdata) + return -ENOMEM; + + tsdata->vcc = devm_regulator_get(&client->dev, "vcc"); + if (IS_ERR(tsdata->vcc)) { + error = PTR_ERR(tsdata->vcc); + if (error != -EPROBE_DEFER) + dev_err(&client->dev, + "failed to request regulator: %d\n", error); + return error; + } + + error = regulator_enable(tsdata->vcc); + if (error < 0) { + dev_err(&client->dev, "failed to enable vcc: %d\n", error); + return error; + } + + error = devm_add_action_or_reset(&client->dev, + hycon_hy46xx_disable_regulator, + tsdata); + if (error) + return error; + + tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, + "reset", GPIOD_OUT_LOW); + if (IS_ERR(tsdata->reset_gpio)) { + error = PTR_ERR(tsdata->reset_gpio); + dev_err(&client->dev, + "Failed to request GPIO reset pin, error %d\n", error); + return error; + } + + if (tsdata->reset_gpio) { + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->reset_gpio, 1); + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->reset_gpio, 0); + msleep(1000); + } + + input = devm_input_allocate_device(&client->dev); + if (!input) { + dev_err(&client->dev, "failed to allocate input device.\n"); + return -ENOMEM; + } + + mutex_init(&tsdata->mutex); + tsdata->client = client; + tsdata->input = input; + + tsdata->regmap = devm_regmap_init_i2c(client, + &hycon_hy46xx_i2c_regmap_config); + if (IS_ERR(tsdata->regmap)) { + dev_err(&client->dev, "regmap allocation failed\n"); + return PTR_ERR(tsdata->regmap); + } + + hycon_hy46xx_get_defaults(&client->dev, tsdata); + hycon_hy46xx_get_parameters(tsdata); + + input->name = "Hycon Capacitive Touch"; + input->id.bustype = BUS_I2C; + input->dev.parent = &client->dev; + + input_set_abs_params(input, ABS_MT_POSITION_X, 0, -1, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, -1, 0, 0); + + touchscreen_parse_properties(input, true, &tsdata->prop); + + error = input_mt_init_slots(input, HY46XX_MAX_SUPPORTED_POINTS, + INPUT_MT_DIRECT); + if (error) { + dev_err(&client->dev, "Unable to init MT slots.\n"); + return error; + } + + i2c_set_clientdata(client, tsdata); + + error = devm_request_threaded_irq(&client->dev, client->irq, + NULL, hycon_hy46xx_isr, IRQF_ONESHOT, + client->name, tsdata); + if (error) { + dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); + return error; + } + + error = devm_device_add_group(&client->dev, &hycon_hy46xx_attr_group); + if (error) + return error; + + error = input_register_device(input); + if (error) + return error; + + dev_dbg(&client->dev, + "HYCON HY46XX initialized: IRQ %d, Reset pin %d.\n", + client->irq, + tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); + + return 0; +} + +static const struct i2c_device_id hycon_hy46xx_id[] = { + { .name = "hy4613" }, + { .name = "hy4614" }, + { .name = "hy4621" }, + { .name = "hy4623" }, + { .name = "hy4633" }, + { .name = "hy4635" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(i2c, hycon_hy46xx_id); + +static const struct of_device_id hycon_hy46xx_of_match[] = { + { .compatible = "hycon,hy4613" }, + { .compatible = "hycon,hy4614" }, + { .compatible = "hycon,hy4621" }, + { .compatible = "hycon,hy4623" }, + { .compatible = "hycon,hy4633" }, + { .compatible = "hycon,hy4635" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, hycon_hy46xx_of_match); + +static struct i2c_driver hycon_hy46xx_driver = { + .driver = { + .name = "hycon_hy46xx", + .of_match_table = hycon_hy46xx_of_match, + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, + .id_table = hycon_hy46xx_id, + .probe = hycon_hy46xx_probe, +}; + +module_i2c_driver(hycon_hy46xx_driver); + +MODULE_AUTHOR("Giulio Benetti <giulio.benetti@benettiengineering.com>"); +MODULE_DESCRIPTION("HYCON HY46XX I2C Touchscreen Driver"); +MODULE_LICENSE("GPL v2"); -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH v7 3/3] Input: add driver for the Hycon HY46XX touchpanel series 2021-04-13 14:44 ` [PATCH v7 3/3] Input: add driver for the Hycon HY46XX touchpanel series Giulio Benetti @ 2021-04-14 5:44 ` Dmitry Torokhov 2021-04-14 6:46 ` Peter Hutterer 2021-04-14 11:24 ` Giulio Benetti 0 siblings, 2 replies; 69+ messages in thread From: Dmitry Torokhov @ 2021-04-14 5:44 UTC (permalink / raw) To: Giulio Benetti Cc: Rob Herring, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel Hi Giulio, On Tue, Apr 13, 2021 at 04:44:46PM +0200, Giulio Benetti wrote: > + > + input_mt_report_pointer_emulation(tsdata->input, true); For touchscreens it does not make much sense to report BTN_DOUBLETAP, BTN_TRIPLETAP, etc, events (they are really for touchpads), so I changed this to input_mt_report_pointer_emulation(tsdata->input, false); to only report ABS_X, ABS_Y, and BTN_TOUCH, and applied. Thanks. -- Dmitry ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v7 3/3] Input: add driver for the Hycon HY46XX touchpanel series 2021-04-14 5:44 ` Dmitry Torokhov @ 2021-04-14 6:46 ` Peter Hutterer 2021-04-14 11:22 ` Giulio Benetti 2021-04-14 11:24 ` Giulio Benetti 1 sibling, 1 reply; 69+ messages in thread From: Peter Hutterer @ 2021-04-14 6:46 UTC (permalink / raw) To: Dmitry Torokhov Cc: Giulio Benetti, Rob Herring, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel On Tue, Apr 13, 2021 at 10:44:07PM -0700, Dmitry Torokhov wrote: > Hi Giulio, > > On Tue, Apr 13, 2021 at 04:44:46PM +0200, Giulio Benetti wrote: > > + > > + input_mt_report_pointer_emulation(tsdata->input, true); > > For touchscreens it does not make much sense to report BTN_DOUBLETAP, > BTN_TRIPLETAP, etc, events (they are really for touchpads), so I changed > this to > > input_mt_report_pointer_emulation(tsdata->input, false); > > to only report ABS_X, ABS_Y, and BTN_TOUCH, and applied. Can you expand on this please, just to make sure I'm not misinterpreting those codes? Those bits are just for how many fingers are down (but without position), dropping those bits means you restrict the device to a pure single-touch screen. Or am I missing something here? then again, MT support has been in the kernel for long enough that by now everything should understand it, so there's a certain "meh" factor. Cheers, Peter ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v7 3/3] Input: add driver for the Hycon HY46XX touchpanel series 2021-04-14 6:46 ` Peter Hutterer @ 2021-04-14 11:22 ` Giulio Benetti 2021-04-14 17:26 ` Dmitry Torokhov 0 siblings, 1 reply; 69+ messages in thread From: Giulio Benetti @ 2021-04-14 11:22 UTC (permalink / raw) To: Peter Hutterer, Dmitry Torokhov Cc: Rob Herring, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel Hi Peter, Dmitry, On 4/14/21 8:46 AM, Peter Hutterer wrote: > On Tue, Apr 13, 2021 at 10:44:07PM -0700, Dmitry Torokhov wrote: >> Hi Giulio, >> >> On Tue, Apr 13, 2021 at 04:44:46PM +0200, Giulio Benetti wrote: >>> + >>> + input_mt_report_pointer_emulation(tsdata->input, true); >> >> For touchscreens it does not make much sense to report BTN_DOUBLETAP, >> BTN_TRIPLETAP, etc, events (they are really for touchpads), so I changed >> this to >> >> input_mt_report_pointer_emulation(tsdata->input, false); >> >> to only report ABS_X, ABS_Y, and BTN_TOUCH, and applied. > > Can you expand on this please, just to make sure I'm not misinterpreting > those codes? Those bits are just for how many fingers are down (but without > position), dropping those bits means you restrict the device to a pure > single-touch screen. Or am I missing something here? I've re-tested the driver after setting input_mt_report_pointer_emulation() use_count to false. It works correctly with all touch points expected. That use_count refers to finger count of Touchpad[1]. Also you can see that even with use_count=false this for loop[2] is entered by counting all the mt->slots and then input_event() reports all of them. I hope I've understood correctly :-) [1]: https://elixir.bootlin.com/linux/v5.12-rc7/source/drivers/input/input-mt.c#L190 [2]: https://elixir.bootlin.com/linux/v5.12-rc7/source/drivers/input/input-mt.c#L208 > then again, MT support has been in the kernel for long enough that by now > everything should understand it, so there's a certain "meh" factor. > > Cheers, > Peter > Best regards -- Giulio Benetti Benetti Engineering sas ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v7 3/3] Input: add driver for the Hycon HY46XX touchpanel series 2021-04-14 11:22 ` Giulio Benetti @ 2021-04-14 17:26 ` Dmitry Torokhov 2021-04-15 6:16 ` Peter Hutterer 0 siblings, 1 reply; 69+ messages in thread From: Dmitry Torokhov @ 2021-04-14 17:26 UTC (permalink / raw) To: Giulio Benetti Cc: Peter Hutterer, Rob Herring, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel Hi Giulio, Peter, On Wed, Apr 14, 2021 at 01:22:55PM +0200, Giulio Benetti wrote: > Hi Peter, Dmitry, > > On 4/14/21 8:46 AM, Peter Hutterer wrote: > > On Tue, Apr 13, 2021 at 10:44:07PM -0700, Dmitry Torokhov wrote: > > > Hi Giulio, > > > > > > On Tue, Apr 13, 2021 at 04:44:46PM +0200, Giulio Benetti wrote: > > > > + > > > > + input_mt_report_pointer_emulation(tsdata->input, true); > > > > > > For touchscreens it does not make much sense to report BTN_DOUBLETAP, > > > BTN_TRIPLETAP, etc, events (they are really for touchpads), so I changed > > > this to > > > > > > input_mt_report_pointer_emulation(tsdata->input, false); > > > > > > to only report ABS_X, ABS_Y, and BTN_TOUCH, and applied. > > > > Can you expand on this please, just to make sure I'm not misinterpreting > > those codes? Those bits are just for how many fingers are down (but without > > position), dropping those bits means you restrict the device to a pure > > single-touch screen. Or am I missing something here? They are indeed represent number of fingers on the surface. I think I over-simplified this a bit by saying these events are only for touchpads, as there is allowance for BTN_TOOL_*TAP in Documentation/input/multi-touch-protocol.rst for MT devices that may report more contacts than what they can distinctly track, and it is not restricted to touchpads (but I believe in reality only used by a couple of "semi-MT" touchpad drivers). What I meant to say that for ST fallback of MT-capable devices we typically provide BTN_TOOL_*TAP for devices declared as INPUT_MT_POINTER (which is touchpads) and for INPUT_MT_DIRECT and others we only provide ABS_X, ABS_Y, ABS_PRESSURE and BTN_TOUCH (see input_mt_sync_frame()), and I think this driver should follow the suit. > > I've re-tested the driver after setting input_mt_report_pointer_emulation() > use_count to false. It works correctly with all touch points expected. That > use_count refers to finger count of Touchpad[1]. Also you can see that even > with use_count=false this for loop[2] is entered by counting all the > mt->slots and then input_event() reports all of them. That is not quite true. The loop in question locates the oldest contact still on the surface and MT->ST mapping uses it as the "primary" point for ST events. It is reported in addition to sending all contacts via MT protocol as ABS_MT_SLOT, ABS_MT_POSITION_X, ABS_MT_POSITION_Y, ... > > I hope I've understood correctly :-) > > [1]: https://elixir.bootlin.com/linux/v5.12-rc7/source/drivers/input/input-mt.c#L190 > [2]: https://elixir.bootlin.com/linux/v5.12-rc7/source/drivers/input/input-mt.c#L208 > > > then again, MT support has been in the kernel for long enough that by now > > everything should understand it, so there's a certain "meh" factor. Yeah, there is that too. Thanks. -- Dmitry ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v7 3/3] Input: add driver for the Hycon HY46XX touchpanel series 2021-04-14 17:26 ` Dmitry Torokhov @ 2021-04-15 6:16 ` Peter Hutterer 0 siblings, 0 replies; 69+ messages in thread From: Peter Hutterer @ 2021-04-15 6:16 UTC (permalink / raw) To: Dmitry Torokhov Cc: Giulio Benetti, Rob Herring, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel On Wed, Apr 14, 2021 at 10:26:13AM -0700, Dmitry Torokhov wrote: > Hi Giulio, Peter, > > On Wed, Apr 14, 2021 at 01:22:55PM +0200, Giulio Benetti wrote: > > Hi Peter, Dmitry, > > > > On 4/14/21 8:46 AM, Peter Hutterer wrote: > > > On Tue, Apr 13, 2021 at 10:44:07PM -0700, Dmitry Torokhov wrote: > > > > Hi Giulio, > > > > > > > > On Tue, Apr 13, 2021 at 04:44:46PM +0200, Giulio Benetti wrote: > > > > > + > > > > > + input_mt_report_pointer_emulation(tsdata->input, true); > > > > > > > > For touchscreens it does not make much sense to report BTN_DOUBLETAP, > > > > BTN_TRIPLETAP, etc, events (they are really for touchpads), so I changed > > > > this to > > > > > > > > input_mt_report_pointer_emulation(tsdata->input, false); > > > > > > > > to only report ABS_X, ABS_Y, and BTN_TOUCH, and applied. > > > > > > Can you expand on this please, just to make sure I'm not misinterpreting > > > those codes? Those bits are just for how many fingers are down (but without > > > position), dropping those bits means you restrict the device to a pure > > > single-touch screen. Or am I missing something here? > > They are indeed represent number of fingers on the surface. I think I > over-simplified this a bit by saying these events are only for > touchpads, as there is allowance for BTN_TOOL_*TAP in > Documentation/input/multi-touch-protocol.rst for MT devices that may > report more contacts than what they can distinctly track, and it is > not restricted to touchpads (but I believe in reality only used by a > couple of "semi-MT" touchpad drivers). fwiw, almost all touchpads on ps2 use that functionality - they can track 2 touchpoints but *detect* up to 5. There's significant insanity in libinput to deal with that because it is so common :) semi-mt is orthogonal to that, it's the an inability to track two touchpoints correctly (only get top-left and bottom-right, but it's guesswork which finger is in which corner). > What I meant to say that for ST fallback of MT-capable devices we > typically provide BTN_TOOL_*TAP for devices declared as INPUT_MT_POINTER > (which is touchpads) and for INPUT_MT_DIRECT and others we only provide > ABS_X, ABS_Y, ABS_PRESSURE and BTN_TOUCH (see input_mt_sync_frame()), > and I think this driver should follow the suit. ah, right. that makes sense, thanks for the clarification. Cheers, Peter ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v7 3/3] Input: add driver for the Hycon HY46XX touchpanel series 2021-04-14 5:44 ` Dmitry Torokhov 2021-04-14 6:46 ` Peter Hutterer @ 2021-04-14 11:24 ` Giulio Benetti 1 sibling, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-14 11:24 UTC (permalink / raw) To: Dmitry Torokhov Cc: Rob Herring, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel On 4/14/21 7:44 AM, Dmitry Torokhov wrote: > Hi Giulio, > > On Tue, Apr 13, 2021 at 04:44:46PM +0200, Giulio Benetti wrote: >> + >> + input_mt_report_pointer_emulation(tsdata->input, true); > > For touchscreens it does not make much sense to report BTN_DOUBLETAP, > BTN_TRIPLETAP, etc, events (they are really for touchpads), so I changed > this to > > input_mt_report_pointer_emulation(tsdata->input, false); > > to only report ABS_X, ABS_Y, and BTN_TOUCH, and applied. > > Thanks. > Thank you, I've re-tested and it works correctly, I've answered to Peter Hutterer with what I've understood about that. Please correct me if I'm wrong. Thanks a lot for reviewing Best regards -- Giulio Benetti Benetti Engineering sas ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v5 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-11 11:48 ` [PATCH v5 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-11 11:48 ` [PATCH v5 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti @ 2021-04-11 11:48 ` Giulio Benetti 2021-04-12 13:20 ` Rob Herring 2021-04-12 14:46 ` Rob Herring 2021-04-11 11:48 ` [PATCH v5 3/3] " Giulio Benetti 2 siblings, 2 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-11 11:48 UTC (permalink / raw) To: Rob Herring Cc: Dmitry Torokhov, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel, Giulio Benetti This adds device tree bindings for the Hycon HY46XX touchscreen series. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> --- V1->V2: As suggested by Rob Herring: * fixed $id: address * added "hycon," in front of every custom property * changed all possible property to boolean type * removed proximity-sensor-switch property since it's not handled in driver V2->V3: As suggested by Jonathan Neuschäfer: * fixed some typo * fixed description indentation * improved boolean properties descriptions * improved hycon,report-speed description V3->V4: * fixed binding compatible string in example as suggested by Jonathan Neuschäfer V4->V5: As suggested by Rob Herring: * drop hycon- prefix from compatible * use Hertz unit suffix for hycon,report-speed instead of u32 * set hycon,report-speed minimum to 1Hz, 0Hz make controller to do nothing * change hycon,power-noise-enable property name to hycon,noise-filter-enable * improve hycon,filter-data property description * use generic touchscreen node name in example --- .../input/touchscreen/hycon,hy46xx.yaml | 119 ++++++++++++++++++ MAINTAINERS | 6 + 2 files changed, 125 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml diff --git a/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml new file mode 100644 index 000000000000..ae792e3716ff --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml @@ -0,0 +1,119 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/hycon,hy46xx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Hycon HY46XX series touchscreen controller bindings + +description: | + There are 6 variants of the chip for various touch panel sizes and cover lens material + Glass: 0.3mm--4.0mm + PET/PMMA: 0.2mm--2.0mm + HY4613(B)-N048 < 6" + HY4614(B)-N068 7" .. 10.1" + HY4621-NS32 < 5" + HY4623-NS48 5.1" .. 7" + Glass: 0.3mm--8.0mm + PET/PMMA: 0.2mm--4.0mm + HY4633(B)-N048 < 6" + HY4635(B)-N048 < 7" .. 10.1" + +maintainers: + - Giulio Benetti <giulio.benetti@benettiengineering.com> + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + enum: + - hycon,hy4613 + - hycon,hy4614 + - hycon,hy4621 + - hycon,hy4623 + - hycon,hy4633 + - hycon,hy4635 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + reset-gpios: + maxItems: 1 + + vcc-supply: true + + hycon,threshold: + description: Allows setting the sensitivity in the range from 0 to 255. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 255 + + hycon,glove-enable: + type: boolean + description: Allows enabling glove setting. + + hycon,report-speed: + description: Allows setting the report speed in Hertz. + minimum: 1 + maximum: 255 + + hycon,noise-filter-enable: + type: boolean + description: Allows enabling power noise filter. + + hycon,filter-data: + description: Allows setting how many samples throw before reporting touch + in the range from 0 to 5. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 5 + + hycon,gain: + description: Allows setting the sensitivity distance in the range from 0 to 5. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 5 + + hycon,edge-offset: + description: Allows setting the edge compensation in the range from 0 to 16. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 16 + + 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 + interrupt-controller: true + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + touchscreen@1c { + compatible = "hycon,hy4633"; + reg = <0x1c>; + interrupt-parent = <&gpio2>; + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; + }; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index 7fdc513392f4..18a50942c019 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8250,6 +8250,12 @@ S: Maintained F: mm/hwpoison-inject.c F: mm/memory-failure.c +HYCON HY46XX TOUCHSCREEN SUPPORT +M: Giulio Benetti <giulio.benetti@benettiengineering.com> +L: linux-input@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml + HYGON PROCESSOR SUPPORT M: Pu Wen <puwen@hygon.cn> L: linux-kernel@vger.kernel.org -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH v5 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-11 11:48 ` [PATCH v5 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti @ 2021-04-12 13:20 ` Rob Herring 2021-04-12 14:46 ` Rob Herring 1 sibling, 0 replies; 69+ messages in thread From: Rob Herring @ 2021-04-12 13:20 UTC (permalink / raw) To: Giulio Benetti Cc: Dmitry Torokhov, linux-input, devicetree, linux-kernel, Henrik Rydberg, Jonathan Neuschäfer [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 3209 bytes --] On Sun, 11 Apr 2021 13:48:03 +0200, Giulio Benetti wrote: > This adds device tree bindings for the Hycon HY46XX touchscreen series. > > Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> > --- > V1->V2: > As suggested by Rob Herring: > * fixed $id: address > * added "hycon," in front of every custom property > * changed all possible property to boolean type > * removed proximity-sensor-switch property since it's not handled in driver > V2->V3: > As suggested by Jonathan Neuschäfer: > * fixed some typo > * fixed description indentation > * improved boolean properties descriptions > * improved hycon,report-speed description > V3->V4: > * fixed binding compatible string in example as suggested by Jonathan Neuschäfer > V4->V5: > As suggested by Rob Herring: > * drop hycon- prefix from compatible > * use Hertz unit suffix for hycon,report-speed instead of u32 > * set hycon,report-speed minimum to 1Hz, 0Hz make controller to do nothing > * change hycon,power-noise-enable property name to hycon,noise-filter-enable > * improve hycon,filter-data property description > * use generic touchscreen node name in example > --- > .../input/touchscreen/hycon,hy46xx.yaml | 119 ++++++++++++++++++ > MAINTAINERS | 6 + > 2 files changed, 125 insertions(+) > create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13): yamllint warnings/errors: dtschema/dtc warnings/errors: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml: properties:hycon,report-speed: 'oneOf' conditional failed, one must be fixed: 'type' is a required property Additional properties are not allowed ('minimum', 'maximum' were unexpected) /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml: properties:hycon,report-speed: 'oneOf' conditional failed, one must be fixed: 'enum' is a required property 'const' is a required property /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml: properties:hycon,report-speed: 'oneOf' conditional failed, one must be fixed: '$ref' is a required property 'allOf' is a required property /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml: ignoring, error in schema: properties: hycon,report-speed warning: no schema found in file: ./Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.example.dt.yaml:0:0: /example-0/i2c/touchscreen@1c: failed to match any schema with compatible: ['hycon,hy4633'] See https://patchwork.ozlabs.org/patch/1464803 This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1. If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date: pip3 install dtschema --upgrade Please check and re-submit. ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v5 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-11 11:48 ` [PATCH v5 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-04-12 13:20 ` Rob Herring @ 2021-04-12 14:46 ` Rob Herring 2021-04-12 14:49 ` Giulio Benetti 2021-04-12 15:23 ` [PATCH v6 0/2] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 1 sibling, 2 replies; 69+ messages in thread From: Rob Herring @ 2021-04-12 14:46 UTC (permalink / raw) To: Giulio Benetti Cc: Dmitry Torokhov, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel On Sun, Apr 11, 2021 at 01:48:03PM +0200, Giulio Benetti wrote: > This adds device tree bindings for the Hycon HY46XX touchscreen series. > > Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> > --- > V1->V2: > As suggested by Rob Herring: > * fixed $id: address > * added "hycon," in front of every custom property > * changed all possible property to boolean type > * removed proximity-sensor-switch property since it's not handled in driver > V2->V3: > As suggested by Jonathan Neuschäfer: > * fixed some typo > * fixed description indentation > * improved boolean properties descriptions > * improved hycon,report-speed description > V3->V4: > * fixed binding compatible string in example as suggested by Jonathan Neuschäfer > V4->V5: > As suggested by Rob Herring: > * drop hycon- prefix from compatible > * use Hertz unit suffix for hycon,report-speed instead of u32 hycon,report-speed-hz > * set hycon,report-speed minimum to 1Hz, 0Hz make controller to do nothing > * change hycon,power-noise-enable property name to hycon,noise-filter-enable > * improve hycon,filter-data property description > * use generic touchscreen node name in example > --- > .../input/touchscreen/hycon,hy46xx.yaml | 119 ++++++++++++++++++ > MAINTAINERS | 6 + > 2 files changed, 125 insertions(+) > create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > > diff --git a/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > new file mode 100644 > index 000000000000..ae792e3716ff > --- /dev/null > +++ b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > @@ -0,0 +1,119 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/input/touchscreen/hycon,hy46xx.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Hycon HY46XX series touchscreen controller bindings > + > +description: | > + There are 6 variants of the chip for various touch panel sizes and cover lens material > + Glass: 0.3mm--4.0mm > + PET/PMMA: 0.2mm--2.0mm > + HY4613(B)-N048 < 6" > + HY4614(B)-N068 7" .. 10.1" > + HY4621-NS32 < 5" > + HY4623-NS48 5.1" .. 7" > + Glass: 0.3mm--8.0mm > + PET/PMMA: 0.2mm--4.0mm > + HY4633(B)-N048 < 6" > + HY4635(B)-N048 < 7" .. 10.1" > + > +maintainers: > + - Giulio Benetti <giulio.benetti@benettiengineering.com> > + > +allOf: > + - $ref: touchscreen.yaml# > + > +properties: > + compatible: > + enum: > + - hycon,hy4613 > + - hycon,hy4614 > + - hycon,hy4621 > + - hycon,hy4623 > + - hycon,hy4633 > + - hycon,hy4635 > + > + reg: > + maxItems: 1 > + > + interrupts: > + maxItems: 1 > + > + reset-gpios: > + maxItems: 1 > + > + vcc-supply: true > + > + hycon,threshold: > + description: Allows setting the sensitivity in the range from 0 to 255. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 255 > + > + hycon,glove-enable: > + type: boolean > + description: Allows enabling glove setting. > + > + hycon,report-speed: > + description: Allows setting the report speed in Hertz. > + minimum: 1 > + maximum: 255 > + > + hycon,noise-filter-enable: > + type: boolean > + description: Allows enabling power noise filter. > + > + hycon,filter-data: > + description: Allows setting how many samples throw before reporting touch > + in the range from 0 to 5. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 5 > + > + hycon,gain: > + description: Allows setting the sensitivity distance in the range from 0 to 5. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 5 > + > + hycon,edge-offset: > + description: Allows setting the edge compensation in the range from 0 to 16. > + $ref: /schemas/types.yaml#/definitions/uint32 > + minimum: 0 > + maximum: 16 > + > + 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 > + interrupt-controller: true > + > +additionalProperties: false > + > +required: > + - compatible > + - reg > + - interrupts > + > +examples: > + - | > + #include <dt-bindings/gpio/gpio.h> > + #include <dt-bindings/interrupt-controller/arm-gic.h> > + i2c { > + #address-cells = <1>; > + #size-cells = <0>; > + touchscreen@1c { > + compatible = "hycon,hy4633"; > + reg = <0x1c>; > + interrupt-parent = <&gpio2>; > + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; > + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; > + }; > + }; > + > +... > diff --git a/MAINTAINERS b/MAINTAINERS > index 7fdc513392f4..18a50942c019 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -8250,6 +8250,12 @@ S: Maintained > F: mm/hwpoison-inject.c > F: mm/memory-failure.c > > +HYCON HY46XX TOUCHSCREEN SUPPORT > +M: Giulio Benetti <giulio.benetti@benettiengineering.com> > +L: linux-input@vger.kernel.org > +S: Maintained > +F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > + > HYGON PROCESSOR SUPPORT > M: Pu Wen <puwen@hygon.cn> > L: linux-kernel@vger.kernel.org > -- > 2.25.1 > ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v5 2/3] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-12 14:46 ` Rob Herring @ 2021-04-12 14:49 ` Giulio Benetti 2021-04-12 15:23 ` [PATCH v6 0/2] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 1 sibling, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-12 14:49 UTC (permalink / raw) To: Rob Herring Cc: Dmitry Torokhov, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel > Il giorno 12 apr 2021, alle ore 16:46, Rob Herring <robh@kernel.org> ha scritto: > > On Sun, Apr 11, 2021 at 01:48:03PM +0200, Giulio Benetti wrote: >> This adds device tree bindings for the Hycon HY46XX touchscreen series. >> >> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> >> --- >> V1->V2: >> As suggested by Rob Herring: >> * fixed $id: address >> * added "hycon," in front of every custom property >> * changed all possible property to boolean type >> * removed proximity-sensor-switch property since it's not handled in driver >> V2->V3: >> As suggested by Jonathan Neuschäfer: >> * fixed some typo >> * fixed description indentation >> * improved boolean properties descriptions >> * improved hycon,report-speed description >> V3->V4: >> * fixed binding compatible string in example as suggested by Jonathan Neuschäfer >> V4->V5: >> As suggested by Rob Herring: >> * drop hycon- prefix from compatible >> * use Hertz unit suffix for hycon,report-speed instead of u32 > > hycon,report-speed-hz Thank you, I’m going to send V6 series. Giulio > >> * set hycon,report-speed minimum to 1Hz, 0Hz make controller to do nothing >> * change hycon,power-noise-enable property name to hycon,noise-filter-enable >> * improve hycon,filter-data property description >> * use generic touchscreen node name in example >> --- >> .../input/touchscreen/hycon,hy46xx.yaml | 119 ++++++++++++++++++ >> MAINTAINERS | 6 + >> 2 files changed, 125 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> >> diff --git a/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> new file mode 100644 >> index 000000000000..ae792e3716ff >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> @@ -0,0 +1,119 @@ >> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) >> +%YAML 1.2 >> +--- >> +$id: http://devicetree.org/schemas/input/touchscreen/hycon,hy46xx.yaml# >> +$schema: http://devicetree.org/meta-schemas/core.yaml# >> + >> +title: Hycon HY46XX series touchscreen controller bindings >> + >> +description: | >> + There are 6 variants of the chip for various touch panel sizes and cover lens material >> + Glass: 0.3mm--4.0mm >> + PET/PMMA: 0.2mm--2.0mm >> + HY4613(B)-N048 < 6" >> + HY4614(B)-N068 7" .. 10.1" >> + HY4621-NS32 < 5" >> + HY4623-NS48 5.1" .. 7" >> + Glass: 0.3mm--8.0mm >> + PET/PMMA: 0.2mm--4.0mm >> + HY4633(B)-N048 < 6" >> + HY4635(B)-N048 < 7" .. 10.1" >> + >> +maintainers: >> + - Giulio Benetti <giulio.benetti@benettiengineering.com> >> + >> +allOf: >> + - $ref: touchscreen.yaml# >> + >> +properties: >> + compatible: >> + enum: >> + - hycon,hy4613 >> + - hycon,hy4614 >> + - hycon,hy4621 >> + - hycon,hy4623 >> + - hycon,hy4633 >> + - hycon,hy4635 >> + >> + reg: >> + maxItems: 1 >> + >> + interrupts: >> + maxItems: 1 >> + >> + reset-gpios: >> + maxItems: 1 >> + >> + vcc-supply: true >> + >> + hycon,threshold: >> + description: Allows setting the sensitivity in the range from 0 to 255. >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 255 >> + >> + hycon,glove-enable: >> + type: boolean >> + description: Allows enabling glove setting. >> + >> + hycon,report-speed: >> + description: Allows setting the report speed in Hertz. >> + minimum: 1 >> + maximum: 255 >> + >> + hycon,noise-filter-enable: >> + type: boolean >> + description: Allows enabling power noise filter. >> + >> + hycon,filter-data: >> + description: Allows setting how many samples throw before reporting touch >> + in the range from 0 to 5. >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 5 >> + >> + hycon,gain: >> + description: Allows setting the sensitivity distance in the range from 0 to 5. >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 5 >> + >> + hycon,edge-offset: >> + description: Allows setting the edge compensation in the range from 0 to 16. >> + $ref: /schemas/types.yaml#/definitions/uint32 >> + minimum: 0 >> + maximum: 16 >> + >> + 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 >> + interrupt-controller: true >> + >> +additionalProperties: false >> + >> +required: >> + - compatible >> + - reg >> + - interrupts >> + >> +examples: >> + - | >> + #include <dt-bindings/gpio/gpio.h> >> + #include <dt-bindings/interrupt-controller/arm-gic.h> >> + i2c { >> + #address-cells = <1>; >> + #size-cells = <0>; >> + touchscreen@1c { >> + compatible = "hycon,hy4633"; >> + reg = <0x1c>; >> + interrupt-parent = <&gpio2>; >> + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; >> + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; >> + }; >> + }; >> + >> +... >> diff --git a/MAINTAINERS b/MAINTAINERS >> index 7fdc513392f4..18a50942c019 100644 >> --- a/MAINTAINERS >> +++ b/MAINTAINERS >> @@ -8250,6 +8250,12 @@ S: Maintained >> F: mm/hwpoison-inject.c >> F: mm/memory-failure.c >> >> +HYCON HY46XX TOUCHSCREEN SUPPORT >> +M: Giulio Benetti <giulio.benetti@benettiengineering.com> >> +L: linux-input@vger.kernel.org >> +S: Maintained >> +F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> + >> HYGON PROCESSOR SUPPORT >> M: Pu Wen <puwen@hygon.cn> >> L: linux-kernel@vger.kernel.org >> -- >> 2.25.1 >> ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v6 0/2] Input: add Hycon HY46XX Touchscreen controller 2021-04-12 14:46 ` Rob Herring 2021-04-12 14:49 ` Giulio Benetti @ 2021-04-12 15:23 ` Giulio Benetti 2021-04-12 15:23 ` [PATCH v6 1/2] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-04-12 15:24 ` [PATCH v6 2/2] Input: add driver for the Hycon HY46XX touchpanel series Giulio Benetti 1 sibling, 2 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-12 15:23 UTC (permalink / raw) To: Rob Herring Cc: Dmitry Torokhov, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel, Giulio Benetti This patchset adds Hycon vendor, HY46XX touchscreen controller driver and its .yaml binding. --- V1->V2: * changed authorship and SoBs to @benettiengineering.com domain * fixed vendor commit log according to Jonathan Neuschäfer's suggestion * fixed hy46xx bindings according to Rob Herring's suggestions * fixed hy46xx driver according to Dmitry Torokhov's suggestions further details are listed in single patches V2->V3: * fixed hy46xx bindings according to Jonathan Neuschäfer's suggestion * fixed hy46xx driver according to Jonathan Neuschäfer's suggestion further details are listed in single patches V3->V4: * fixed binding compatible string as suggested by Jonathan Neuschäfer V4->V5: * fixed hy46xx bindings and driver according to Rob Herring's suggestions further details are listed in single patches V5->V6: * changed report-speed property name into report-speed-hz according to Rob Herring's suggestion --- Giulio Benetti (2): dt-bindings: touchscreen: Add HY46XX bindings Input: add driver for the Hycon HY46XX touchpanel series .../input/touchscreen/hycon,hy46xx.yaml | 119 ++++ MAINTAINERS | 7 + drivers/input/touchscreen/Kconfig | 11 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/hycon-hy46xx.c | 591 ++++++++++++++++++ 5 files changed, 729 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml create mode 100644 drivers/input/touchscreen/hycon-hy46xx.c -- 2.25.1 ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v6 1/2] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-12 15:23 ` [PATCH v6 0/2] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti @ 2021-04-12 15:23 ` Giulio Benetti 2021-04-13 15:07 ` Rob Herring 2021-04-12 15:24 ` [PATCH v6 2/2] Input: add driver for the Hycon HY46XX touchpanel series Giulio Benetti 1 sibling, 1 reply; 69+ messages in thread From: Giulio Benetti @ 2021-04-12 15:23 UTC (permalink / raw) To: Rob Herring Cc: Dmitry Torokhov, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel, Giulio Benetti This adds device tree bindings for the Hycon HY46XX touchscreen series. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> --- V1->V2: As suggested by Rob Herring: * fixed $id: address * added "hycon," in front of every custom property * changed all possible property to boolean type * removed proximity-sensor-switch property since it's not handled in driver V2->V3: As suggested by Jonathan Neuschäfer: * fixed some typo * fixed description indentation * improved boolean properties descriptions * improved hycon,report-speed description V3->V4: * fixed binding compatible string in example as suggested by Jonathan Neuschäfer V4->V5: As suggested by Rob Herring: * drop hycon- prefix from compatible * use Hertz unit suffix for hycon,report-speed instead of u32 * set hycon,report-speed minimum to 1Hz, 0Hz make controller to do nothing * change hycon,power-noise-enable property name to hycon,noise-filter-enable * improve hycon,filter-data property description * use generic touchscreen node name in example V5->V6: * changed report-speed property name into report-speed-hz according to Rob Herring's suggestion --- .../input/touchscreen/hycon,hy46xx.yaml | 119 ++++++++++++++++++ MAINTAINERS | 6 + 2 files changed, 125 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml diff --git a/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml new file mode 100644 index 000000000000..942562f1e45b --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml @@ -0,0 +1,119 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/hycon,hy46xx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Hycon HY46XX series touchscreen controller bindings + +description: | + There are 6 variants of the chip for various touch panel sizes and cover lens material + Glass: 0.3mm--4.0mm + PET/PMMA: 0.2mm--2.0mm + HY4613(B)-N048 < 6" + HY4614(B)-N068 7" .. 10.1" + HY4621-NS32 < 5" + HY4623-NS48 5.1" .. 7" + Glass: 0.3mm--8.0mm + PET/PMMA: 0.2mm--4.0mm + HY4633(B)-N048 < 6" + HY4635(B)-N048 < 7" .. 10.1" + +maintainers: + - Giulio Benetti <giulio.benetti@benettiengineering.com> + +allOf: + - $ref: touchscreen.yaml# + +properties: + compatible: + enum: + - hycon,hy4613 + - hycon,hy4614 + - hycon,hy4621 + - hycon,hy4623 + - hycon,hy4633 + - hycon,hy4635 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + reset-gpios: + maxItems: 1 + + vcc-supply: true + + hycon,threshold: + description: Allows setting the sensitivity in the range from 0 to 255. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 255 + + hycon,glove-enable: + type: boolean + description: Allows enabling glove setting. + + hycon,report-speed-hz: + description: Allows setting the report speed in Hertz. + minimum: 1 + maximum: 255 + + hycon,noise-filter-enable: + type: boolean + description: Allows enabling power noise filter. + + hycon,filter-data: + description: Allows setting how many samples throw before reporting touch + in the range from 0 to 5. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 5 + + hycon,gain: + description: Allows setting the sensitivity distance in the range from 0 to 5. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 5 + + hycon,edge-offset: + description: Allows setting the edge compensation in the range from 0 to 16. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 16 + + 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 + interrupt-controller: true + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + touchscreen@1c { + compatible = "hycon,hy4633"; + reg = <0x1c>; + interrupt-parent = <&gpio2>; + interrupts = <5 IRQ_TYPE_EDGE_FALLING>; + reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>; + }; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index 7fdc513392f4..18a50942c019 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8250,6 +8250,12 @@ S: Maintained F: mm/hwpoison-inject.c F: mm/memory-failure.c +HYCON HY46XX TOUCHSCREEN SUPPORT +M: Giulio Benetti <giulio.benetti@benettiengineering.com> +L: linux-input@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml + HYGON PROCESSOR SUPPORT M: Pu Wen <puwen@hygon.cn> L: linux-kernel@vger.kernel.org -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH v6 1/2] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-12 15:23 ` [PATCH v6 1/2] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti @ 2021-04-13 15:07 ` Rob Herring 2021-04-13 15:27 ` Giulio Benetti 0 siblings, 1 reply; 69+ messages in thread From: Rob Herring @ 2021-04-13 15:07 UTC (permalink / raw) To: Giulio Benetti Cc: linux-input, Dmitry Torokhov, Henrik Rydberg, devicetree, Jonathan Neuschäfer, linux-kernel On Mon, 12 Apr 2021 17:23:59 +0200, Giulio Benetti wrote: > This adds device tree bindings for the Hycon HY46XX touchscreen series. > > Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> > --- > V1->V2: > As suggested by Rob Herring: > * fixed $id: address > * added "hycon," in front of every custom property > * changed all possible property to boolean type > * removed proximity-sensor-switch property since it's not handled in driver > V2->V3: > As suggested by Jonathan Neuschäfer: > * fixed some typo > * fixed description indentation > * improved boolean properties descriptions > * improved hycon,report-speed description > V3->V4: > * fixed binding compatible string in example as suggested by Jonathan Neuschäfer > V4->V5: > As suggested by Rob Herring: > * drop hycon- prefix from compatible > * use Hertz unit suffix for hycon,report-speed instead of u32 > * set hycon,report-speed minimum to 1Hz, 0Hz make controller to do nothing > * change hycon,power-noise-enable property name to hycon,noise-filter-enable > * improve hycon,filter-data property description > * use generic touchscreen node name in example > V5->V6: > * changed report-speed property name into report-speed-hz according to > Rob Herring's suggestion > --- > .../input/touchscreen/hycon,hy46xx.yaml | 119 ++++++++++++++++++ > MAINTAINERS | 6 + > 2 files changed, 125 insertions(+) > create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > Reviewed-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v6 1/2] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-13 15:07 ` Rob Herring @ 2021-04-13 15:27 ` Giulio Benetti 2021-04-13 17:58 ` Rob Herring 0 siblings, 1 reply; 69+ messages in thread From: Giulio Benetti @ 2021-04-13 15:27 UTC (permalink / raw) To: Rob Herring Cc: linux-input, Dmitry Torokhov, Henrik Rydberg, devicetree, Jonathan Neuschäfer, linux-kernel On 4/13/21 5:07 PM, Rob Herring wrote: > On Mon, 12 Apr 2021 17:23:59 +0200, Giulio Benetti wrote: >> This adds device tree bindings for the Hycon HY46XX touchscreen series. >> >> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> >> --- >> V1->V2: >> As suggested by Rob Herring: >> * fixed $id: address >> * added "hycon," in front of every custom property >> * changed all possible property to boolean type >> * removed proximity-sensor-switch property since it's not handled in driver >> V2->V3: >> As suggested by Jonathan Neuschäfer: >> * fixed some typo >> * fixed description indentation >> * improved boolean properties descriptions >> * improved hycon,report-speed description >> V3->V4: >> * fixed binding compatible string in example as suggested by Jonathan Neuschäfer >> V4->V5: >> As suggested by Rob Herring: >> * drop hycon- prefix from compatible >> * use Hertz unit suffix for hycon,report-speed instead of u32 >> * set hycon,report-speed minimum to 1Hz, 0Hz make controller to do nothing >> * change hycon,power-noise-enable property name to hycon,noise-filter-enable >> * improve hycon,filter-data property description >> * use generic touchscreen node name in example >> V5->V6: >> * changed report-speed property name into report-speed-hz according to >> Rob Herring's suggestion >> --- >> .../input/touchscreen/hycon,hy46xx.yaml | 119 ++++++++++++++++++ >> MAINTAINERS | 6 + >> 2 files changed, 125 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> > > Reviewed-by: Rob Herring <robh@kernel.org> I've sent v7[1] before receiving your Reviewed-by. Do I have to re-submit it once and if I receive a Reviewed-by from you as a v8 with all your Reviewed-by's? Sorry for the noise. [1]: https://patchwork.kernel.org/project/linux-input/list/?series=466405 -- Giulio Benetti Benetti Engineering sas ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v6 1/2] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-13 15:27 ` Giulio Benetti @ 2021-04-13 17:58 ` Rob Herring 2021-04-13 18:34 ` Giulio Benetti 0 siblings, 1 reply; 69+ messages in thread From: Rob Herring @ 2021-04-13 17:58 UTC (permalink / raw) To: Giulio Benetti Cc: Linux Input, Dmitry Torokhov, Henrik Rydberg, devicetree, Jonathan Neuschäfer, linux-kernel On Tue, Apr 13, 2021 at 10:27 AM Giulio Benetti <giulio.benetti@benettiengineering.com> wrote: > > On 4/13/21 5:07 PM, Rob Herring wrote: > > On Mon, 12 Apr 2021 17:23:59 +0200, Giulio Benetti wrote: > >> This adds device tree bindings for the Hycon HY46XX touchscreen series. > >> > >> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> > >> --- > >> V1->V2: > >> As suggested by Rob Herring: > >> * fixed $id: address > >> * added "hycon," in front of every custom property > >> * changed all possible property to boolean type > >> * removed proximity-sensor-switch property since it's not handled in driver > >> V2->V3: > >> As suggested by Jonathan Neuschäfer: > >> * fixed some typo > >> * fixed description indentation > >> * improved boolean properties descriptions > >> * improved hycon,report-speed description > >> V3->V4: > >> * fixed binding compatible string in example as suggested by Jonathan Neuschäfer > >> V4->V5: > >> As suggested by Rob Herring: > >> * drop hycon- prefix from compatible > >> * use Hertz unit suffix for hycon,report-speed instead of u32 > >> * set hycon,report-speed minimum to 1Hz, 0Hz make controller to do nothing > >> * change hycon,power-noise-enable property name to hycon,noise-filter-enable > >> * improve hycon,filter-data property description > >> * use generic touchscreen node name in example > >> V5->V6: > >> * changed report-speed property name into report-speed-hz according to > >> Rob Herring's suggestion > >> --- > >> .../input/touchscreen/hycon,hy46xx.yaml | 119 ++++++++++++++++++ > >> MAINTAINERS | 6 + > >> 2 files changed, 125 insertions(+) > >> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > >> > > > > Reviewed-by: Rob Herring <robh@kernel.org> > > I've sent v7[1] before receiving your Reviewed-by. > Do I have to re-submit it once and if I receive a Reviewed-by from you > as a v8 with all your Reviewed-by's? I gave it on v7 too, so only if there are other changes on any of the patches. The tools will generally pick up any tags on the version applied. You just can't expect maintainers to go rummage thru old versions to find any tags. Rob ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH v6 1/2] dt-bindings: touchscreen: Add HY46XX bindings 2021-04-13 17:58 ` Rob Herring @ 2021-04-13 18:34 ` Giulio Benetti 0 siblings, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-13 18:34 UTC (permalink / raw) To: Rob Herring Cc: Linux Input, Dmitry Torokhov, Henrik Rydberg, devicetree, Jonathan Neuschäfer, linux-kernel > Il giorno 13 apr 2021, alle ore 19:58, Rob Herring <robh@kernel.org> ha scritto: > > On Tue, Apr 13, 2021 at 10:27 AM Giulio Benetti > <giulio.benetti@benettiengineering.com> wrote: >> >>> On 4/13/21 5:07 PM, Rob Herring wrote: >>> On Mon, 12 Apr 2021 17:23:59 +0200, Giulio Benetti wrote: >>>> This adds device tree bindings for the Hycon HY46XX touchscreen series. >>>> >>>> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> >>>> --- >>>> V1->V2: >>>> As suggested by Rob Herring: >>>> * fixed $id: address >>>> * added "hycon," in front of every custom property >>>> * changed all possible property to boolean type >>>> * removed proximity-sensor-switch property since it's not handled in driver >>>> V2->V3: >>>> As suggested by Jonathan Neuschäfer: >>>> * fixed some typo >>>> * fixed description indentation >>>> * improved boolean properties descriptions >>>> * improved hycon,report-speed description >>>> V3->V4: >>>> * fixed binding compatible string in example as suggested by Jonathan Neuschäfer >>>> V4->V5: >>>> As suggested by Rob Herring: >>>> * drop hycon- prefix from compatible >>>> * use Hertz unit suffix for hycon,report-speed instead of u32 >>>> * set hycon,report-speed minimum to 1Hz, 0Hz make controller to do nothing >>>> * change hycon,power-noise-enable property name to hycon,noise-filter-enable >>>> * improve hycon,filter-data property description >>>> * use generic touchscreen node name in example >>>> V5->V6: >>>> * changed report-speed property name into report-speed-hz according to >>>> Rob Herring's suggestion >>>> --- >>>> .../input/touchscreen/hycon,hy46xx.yaml | 119 ++++++++++++++++++ >>>> MAINTAINERS | 6 + >>>> 2 files changed, 125 insertions(+) >>>> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >>>> >>> >>> Reviewed-by: Rob Herring <robh@kernel.org> >> >> I've sent v7[1] before receiving your Reviewed-by. >> Do I have to re-submit it once and if I receive a Reviewed-by from you >> as a v8 with all your Reviewed-by's? > > I gave it on v7 too, so only if there are other changes on any of the > patches. Ah ok, thank you. > The tools will generally pick up any tags on the version > applied. You just can't expect maintainers to go rummage thru old > versions to find any tags. Sure not, this is the reason why I’ve asked, I’ve forgotten to add some tag to my commits that I usually do, that’s why I’ve messed things up. Thank you again for reviewing and explaining me. Best regards Giulio Benetti > > Rob ^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH v6 2/2] Input: add driver for the Hycon HY46XX touchpanel series 2021-04-12 15:23 ` [PATCH v6 0/2] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-12 15:23 ` [PATCH v6 1/2] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti @ 2021-04-12 15:24 ` Giulio Benetti 1 sibling, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-12 15:24 UTC (permalink / raw) To: Rob Herring Cc: Dmitry Torokhov, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel, Giulio Benetti This patch adds support for Hycon HY46XX. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> --- V1->V2: * removed proximity-sensor-switch property according to previous patch As suggested by Dmitry Torokhov * moved i2c communaction to regmap use * added macro to avoid magic number * removed cmd variable that could uninitiliazed since we're using regmap now * removed useless byte masking * removed useless struct hycon_hy46xx_i2c_chip_data * used IRQF_ONESHOT only for isr V2->V3: As suggested by Jonathan Neuschäfer: * fixed Kconfig description * fixed DT properties by preprending "hycon," * changed MODULE_AUTHOR() e-mail according to SoB and authorship V4->V5: As suggested by Rob Herring according to dt-bindings: * drop hycon- prefix from compatible * change hycon,power-noise-enable property name to hycon,noise-filter-enable and change power_noise_enable variable name to noise_filter_enable V5->V6: * changed report-speed property name into report-speed-hz according to Rob Herring's suggestion --- MAINTAINERS | 1 + drivers/input/touchscreen/Kconfig | 11 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/hycon-hy46xx.c | 591 +++++++++++++++++++++++ 4 files changed, 604 insertions(+) create mode 100644 drivers/input/touchscreen/hycon-hy46xx.c diff --git a/MAINTAINERS b/MAINTAINERS index 18a50942c019..588ca21cfc09 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8255,6 +8255,7 @@ M: Giulio Benetti <giulio.benetti@benettiengineering.com> L: linux-input@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml +F: drivers/input/touchscreen/hy46xx.c HYGON PROCESSOR SUPPORT M: Pu Wen <puwen@hygon.cn> diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 529614d364fe..fe1468b74530 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1335,4 +1335,15 @@ config TOUCHSCREEN_ZINITIX To compile this driver as a module, choose M here: the module will be called zinitix. +config TOUCHSCREEN_HYCON_HY46XX + tristate "Hycon hy46xx touchscreen support" + depends on I2C + help + Say Y here if you have a touchscreen using Hycon hy46xx + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called hycon-hy46xx. + endif diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 6233541e9173..8b68cf3a3e6d 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -112,3 +112,4 @@ obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o obj-$(CONFIG_TOUCHSCREEN_ZINITIX) += zinitix.o +obj-$(CONFIG_TOUCHSCREEN_HYCON_HY46XX) += hycon-hy46xx.o diff --git a/drivers/input/touchscreen/hycon-hy46xx.c b/drivers/input/touchscreen/hycon-hy46xx.c new file mode 100644 index 000000000000..4afc88dd0293 --- /dev/null +++ b/drivers/input/touchscreen/hycon-hy46xx.c @@ -0,0 +1,591 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 + * Author(s): Giulio Benetti <giulio.benetti@benettiengineering.com> + */ + +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/input.h> +#include <linux/input/mt.h> +#include <linux/input/touchscreen.h> +#include <linux/irq.h> +#include <linux/regulator/consumer.h> +#include <linux/regmap.h> + +#include <asm/unaligned.h> + +#define HY46XX_CHKSUM_CODE 0x1 +#define HY46XX_FINGER_NUM 0x2 +#define HY46XX_CHKSUM_LEN 0x7 +#define HY46XX_THRESHOLD 0x80 +#define HY46XX_GLOVE_EN 0x84 +#define HY46XX_REPORT_SPEED 0x88 +#define HY46XX_PWR_NOISE_EN 0x89 +#define HY46XX_FILTER_DATA 0x8A +#define HY46XX_GAIN 0x92 +#define HY46XX_EDGE_OFFSET 0x93 +#define HY46XX_RX_NR_USED 0x94 +#define HY46XX_TX_NR_USED 0x95 +#define HY46XX_PWR_MODE 0xA5 +#define HY46XX_FW_VERSION 0xA6 +#define HY46XX_LIB_VERSION 0xA7 +#define HY46XX_TP_INFO 0xA8 +#define HY46XX_TP_CHIP_ID 0xA9 +#define HY46XX_BOOT_VER 0xB0 + +#define HY46XX_TPLEN 0x6 +#define HY46XX_REPORT_PKT_LEN 0x44 + +#define HY46XX_MAX_SUPPORTED_POINTS 11 + +#define TOUCH_EVENT_DOWN 0x00 +#define TOUCH_EVENT_UP 0x01 +#define TOUCH_EVENT_CONTACT 0x02 +#define TOUCH_EVENT_RESERVED 0x03 + +struct hycon_hy46xx_data { + struct i2c_client *client; + struct input_dev *input; + struct touchscreen_properties prop; + struct regulator *vcc; + + struct gpio_desc *reset_gpio; + + struct mutex mutex; + struct regmap *regmap; + + int threshold; + bool glove_enable; + int report_speed; + bool noise_filter_enable; + int filter_data; + int gain; + int edge_offset; + int rx_number_used; + int tx_number_used; + int power_mode; + int fw_version; + int lib_version; + int tp_information; + int tp_chip_id; + int bootloader_version; +}; + +static const struct regmap_config hycon_hy46xx_i2c_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; + +static bool hycon_hy46xx_check_checksum(struct hycon_hy46xx_data *tsdata, u8 *buf) +{ + u8 chksum = 0; + int i; + + for (i = 2; i < buf[HY46XX_CHKSUM_LEN]; i++) + chksum += buf[i]; + + if (chksum == buf[HY46XX_CHKSUM_CODE]) + return true; + + dev_err_ratelimited(&tsdata->client->dev, + "checksum error: 0x%02x expected, got 0x%02x\n", + chksum, buf[HY46XX_CHKSUM_CODE]); + + return false; +} + +static irqreturn_t hycon_hy46xx_isr(int irq, void *dev_id) +{ + struct hycon_hy46xx_data *tsdata = dev_id; + struct device *dev = &tsdata->client->dev; + u8 rdbuf[HY46XX_REPORT_PKT_LEN]; + int i, x, y, id; + int error; + + memset(rdbuf, 0, sizeof(rdbuf)); + + error = regmap_bulk_read(tsdata->regmap, 0, rdbuf, sizeof(rdbuf)); + if (error) { + dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n", + error); + goto out; + } + + if (!hycon_hy46xx_check_checksum(tsdata, rdbuf)) + goto out; + + for (i = 0; i < HY46XX_MAX_SUPPORTED_POINTS; i++) { + u8 *buf = &rdbuf[3 + (HY46XX_TPLEN * i)]; + int type = buf[0] >> 6; + + if (type == TOUCH_EVENT_RESERVED) + continue; + + x = get_unaligned_be16(buf) & 0x0fff; + y = get_unaligned_be16(buf + 2) & 0x0fff; + + id = buf[2] >> 4; + + input_mt_slot(tsdata->input, id); + if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, + type != TOUCH_EVENT_UP)) + touchscreen_report_pos(tsdata->input, &tsdata->prop, + x, y, true); + } + + input_mt_report_pointer_emulation(tsdata->input, true); + input_sync(tsdata->input); + +out: + return IRQ_HANDLED; +} + +struct hycon_hy46xx_attribute { + struct device_attribute dattr; + size_t field_offset; + u8 address; + u8 limit_low; + u8 limit_high; +}; + +#define HYCON_ATTR_U8(_field, _mode, _address, _limit_low, _limit_high) \ + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ + .dattr = __ATTR(_field, _mode, \ + hycon_hy46xx_setting_show, \ + hycon_hy46xx_setting_store), \ + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ + .address = _address, \ + .limit_low = _limit_low, \ + .limit_high = _limit_high, \ + } + +#define HYCON_ATTR_BOOL(_field, _mode, _address) \ + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ + .dattr = __ATTR(_field, _mode, \ + hycon_hy46xx_setting_show, \ + hycon_hy46xx_setting_store), \ + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ + .address = _address, \ + .limit_low = false, \ + .limit_high = true, \ + } + +static ssize_t hycon_hy46xx_setting_show(struct device *dev, + struct device_attribute *dattr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); + struct hycon_hy46xx_attribute *attr = + container_of(dattr, struct hycon_hy46xx_attribute, dattr); + u8 *field = (u8 *)tsdata + attr->field_offset; + size_t count = 0; + int error = 0; + int val; + + mutex_lock(&tsdata->mutex); + + error = regmap_read(tsdata->regmap, attr->address, &val); + if (error < 0) { + dev_err(&tsdata->client->dev, + "Failed to fetch attribute %s, error %d\n", + dattr->attr.name, error); + goto out; + } + + if (val != *field) { + dev_warn(&tsdata->client->dev, + "%s: read (%d) and stored value (%d) differ\n", + dattr->attr.name, val, *field); + *field = val; + } + + count = scnprintf(buf, PAGE_SIZE, "%d\n", val); + +out: + mutex_unlock(&tsdata->mutex); + return error ?: count; +} + +static ssize_t hycon_hy46xx_setting_store(struct device *dev, + struct device_attribute *dattr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); + struct hycon_hy46xx_attribute *attr = + container_of(dattr, struct hycon_hy46xx_attribute, dattr); + u8 *field = (u8 *)tsdata + attr->field_offset; + unsigned int val; + int error; + + mutex_lock(&tsdata->mutex); + + error = kstrtouint(buf, 0, &val); + if (error) + goto out; + + if (val < attr->limit_low || val > attr->limit_high) { + error = -ERANGE; + goto out; + } + + error = regmap_write(tsdata->regmap, attr->address, val); + if (error < 0) { + dev_err(&tsdata->client->dev, + "Failed to update attribute %s, error: %d\n", + dattr->attr.name, error); + goto out; + } + *field = val; + +out: + mutex_unlock(&tsdata->mutex); + return error ?: count; +} + +static HYCON_ATTR_U8(threshold, 0644, HY46XX_THRESHOLD, 0, 255); +static HYCON_ATTR_BOOL(glove_enable, 0644, HY46XX_GLOVE_EN); +static HYCON_ATTR_U8(report_speed, 0644, HY46XX_REPORT_SPEED, 0, 255); +static HYCON_ATTR_BOOL(noise_filter_enable, 0644, HY46XX_PWR_NOISE_EN); +static HYCON_ATTR_U8(filter_data, 0644, HY46XX_FILTER_DATA, 0, 5); +static HYCON_ATTR_U8(gain, 0644, HY46XX_GAIN, 0, 5); +static HYCON_ATTR_U8(edge_offset, 0644, HY46XX_EDGE_OFFSET, 0, 5); +static HYCON_ATTR_U8(fw_version, 0444, HY46XX_FW_VERSION, 0, 255); +static HYCON_ATTR_U8(lib_version, 0444, HY46XX_LIB_VERSION, 0, 255); +static HYCON_ATTR_U8(tp_information, 0444, HY46XX_TP_INFO, 0, 255); +static HYCON_ATTR_U8(tp_chip_id, 0444, HY46XX_TP_CHIP_ID, 0, 255); +static HYCON_ATTR_U8(bootloader_version, 0444, HY46XX_BOOT_VER, 0, 255); + +static struct attribute *hycon_hy46xx_attrs[] = { + &hycon_hy46xx_attr_threshold.dattr.attr, + &hycon_hy46xx_attr_glove_enable.dattr.attr, + &hycon_hy46xx_attr_report_speed.dattr.attr, + &hycon_hy46xx_attr_noise_filter_enable.dattr.attr, + &hycon_hy46xx_attr_filter_data.dattr.attr, + &hycon_hy46xx_attr_gain.dattr.attr, + &hycon_hy46xx_attr_edge_offset.dattr.attr, + &hycon_hy46xx_attr_fw_version.dattr.attr, + &hycon_hy46xx_attr_lib_version.dattr.attr, + &hycon_hy46xx_attr_tp_information.dattr.attr, + &hycon_hy46xx_attr_tp_chip_id.dattr.attr, + &hycon_hy46xx_attr_bootloader_version.dattr.attr, + NULL +}; + +static const struct attribute_group hycon_hy46xx_attr_group = { + .attrs = hycon_hy46xx_attrs, +}; + +static void hycon_hy46xx_get_defaults(struct device *dev, struct hycon_hy46xx_data *tsdata) +{ + bool val_bool; + int error; + u32 val; + + error = device_property_read_u32(dev, "hycon,threshold", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_THRESHOLD, val); + if (error < 0) + goto out; + + tsdata->threshold = val; + } + + val_bool = device_property_read_bool(dev, "hycon,glove-enable"); + error = regmap_write(tsdata->regmap, HY46XX_GLOVE_EN, val_bool); + if (error < 0) + goto out; + tsdata->glove_enable = val_bool; + + error = device_property_read_u32(dev, "hycon,report-speed-hz", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_REPORT_SPEED, val); + if (error < 0) + goto out; + + tsdata->report_speed = val; + } + + val_bool = device_property_read_bool(dev, "hycon,noise-filter-enable"); + error = regmap_write(tsdata->regmap, HY46XX_PWR_NOISE_EN, val_bool); + if (error < 0) + goto out; + tsdata->noise_filter_enable = val_bool; + + error = device_property_read_u32(dev, "hycon,filter-data", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_FILTER_DATA, val); + if (error < 0) + goto out; + + tsdata->filter_data = val; + } + + error = device_property_read_u32(dev, "hycon,gain", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_GAIN, val); + if (error < 0) + goto out; + + tsdata->gain = val; + } + + error = device_property_read_u32(dev, "hycon,edge-offset", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_EDGE_OFFSET, val); + if (error < 0) + goto out; + + tsdata->edge_offset = val; + } + + return; +out: + dev_err(&tsdata->client->dev, "Failed to set default settings"); +} + +static void hycon_hy46xx_get_parameters(struct hycon_hy46xx_data *tsdata) +{ + int error; + u32 val; + + error = regmap_read(tsdata->regmap, HY46XX_THRESHOLD, &val); + if (error < 0) + goto out; + tsdata->threshold = val; + + error = regmap_read(tsdata->regmap, HY46XX_GLOVE_EN, &val); + if (error < 0) + goto out; + tsdata->glove_enable = val; + + error = regmap_read(tsdata->regmap, HY46XX_REPORT_SPEED, &val); + if (error < 0) + goto out; + tsdata->report_speed = val; + + error = regmap_read(tsdata->regmap, HY46XX_PWR_NOISE_EN, &val); + if (error < 0) + goto out; + tsdata->noise_filter_enable = val; + + error = regmap_read(tsdata->regmap, HY46XX_FILTER_DATA, &val); + if (error < 0) + goto out; + tsdata->filter_data = val; + + error = regmap_read(tsdata->regmap, HY46XX_GAIN, &val); + if (error < 0) + goto out; + tsdata->gain = val; + + error = regmap_read(tsdata->regmap, HY46XX_EDGE_OFFSET, &val); + if (error < 0) + goto out; + tsdata->edge_offset = val; + + error = regmap_read(tsdata->regmap, HY46XX_RX_NR_USED, &val); + if (error < 0) + goto out; + tsdata->rx_number_used = val; + + error = regmap_read(tsdata->regmap, HY46XX_TX_NR_USED, &val); + if (error < 0) + goto out; + tsdata->tx_number_used = val; + + error = regmap_read(tsdata->regmap, HY46XX_PWR_MODE, &val); + if (error < 0) + goto out; + tsdata->power_mode = val; + + error = regmap_read(tsdata->regmap, HY46XX_FW_VERSION, &val); + if (error < 0) + goto out; + tsdata->fw_version = val; + + error = regmap_read(tsdata->regmap, HY46XX_LIB_VERSION, &val); + if (error < 0) + goto out; + tsdata->lib_version = val; + + error = regmap_read(tsdata->regmap, HY46XX_TP_INFO, &val); + if (error < 0) + goto out; + tsdata->tp_information = val; + + error = regmap_read(tsdata->regmap, HY46XX_TP_CHIP_ID, &val); + if (error < 0) + goto out; + tsdata->tp_chip_id = val; + + error = regmap_read(tsdata->regmap, HY46XX_BOOT_VER, &val); + if (error < 0) + goto out; + tsdata->bootloader_version = val; + + return; +out: + dev_err(&tsdata->client->dev, "Failed to read default settings"); +} + +static void hycon_hy46xx_disable_regulator(void *arg) +{ + struct hycon_hy46xx_data *data = arg; + + regulator_disable(data->vcc); +} + +static int hycon_hy46xx_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct hycon_hy46xx_data *tsdata; + struct input_dev *input; + int error; + + dev_dbg(&client->dev, "probing for HYCON HY46XX I2C\n"); + + tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL); + if (!tsdata) + return -ENOMEM; + + tsdata->vcc = devm_regulator_get(&client->dev, "vcc"); + if (IS_ERR(tsdata->vcc)) { + error = PTR_ERR(tsdata->vcc); + if (error != -EPROBE_DEFER) + dev_err(&client->dev, + "failed to request regulator: %d\n", error); + return error; + } + + error = regulator_enable(tsdata->vcc); + if (error < 0) { + dev_err(&client->dev, "failed to enable vcc: %d\n", error); + return error; + } + + error = devm_add_action_or_reset(&client->dev, + hycon_hy46xx_disable_regulator, + tsdata); + if (error) + return error; + + tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, + "reset", GPIOD_OUT_LOW); + if (IS_ERR(tsdata->reset_gpio)) { + error = PTR_ERR(tsdata->reset_gpio); + dev_err(&client->dev, + "Failed to request GPIO reset pin, error %d\n", error); + return error; + } + + if (tsdata->reset_gpio) { + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->reset_gpio, 1); + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->reset_gpio, 0); + msleep(1000); + } + + input = devm_input_allocate_device(&client->dev); + if (!input) { + dev_err(&client->dev, "failed to allocate input device.\n"); + return -ENOMEM; + } + + mutex_init(&tsdata->mutex); + tsdata->client = client; + tsdata->input = input; + + tsdata->regmap = devm_regmap_init_i2c(client, + &hycon_hy46xx_i2c_regmap_config); + if (IS_ERR(tsdata->regmap)) { + dev_err(&client->dev, "regmap allocation failed\n"); + return PTR_ERR(tsdata->regmap); + } + + hycon_hy46xx_get_defaults(&client->dev, tsdata); + hycon_hy46xx_get_parameters(tsdata); + + input->name = "Hycon Capacitive Touch"; + input->id.bustype = BUS_I2C; + input->dev.parent = &client->dev; + + input_set_abs_params(input, ABS_MT_POSITION_X, 0, -1, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, -1, 0, 0); + + touchscreen_parse_properties(input, true, &tsdata->prop); + + error = input_mt_init_slots(input, HY46XX_MAX_SUPPORTED_POINTS, + INPUT_MT_DIRECT); + if (error) { + dev_err(&client->dev, "Unable to init MT slots.\n"); + return error; + } + + i2c_set_clientdata(client, tsdata); + + error = devm_request_threaded_irq(&client->dev, client->irq, + NULL, hycon_hy46xx_isr, IRQF_ONESHOT, + client->name, tsdata); + if (error) { + dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); + return error; + } + + error = devm_device_add_group(&client->dev, &hycon_hy46xx_attr_group); + if (error) + return error; + + error = input_register_device(input); + if (error) + return error; + + dev_dbg(&client->dev, + "HYCON HY46XX initialized: IRQ %d, Reset pin %d.\n", + client->irq, + tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); + + return 0; +} + +static const struct i2c_device_id hycon_hy46xx_id[] = { + { .name = "hy4613" }, + { .name = "hy4614" }, + { .name = "hy4621" }, + { .name = "hy4623" }, + { .name = "hy4633" }, + { .name = "hy4635" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(i2c, hycon_hy46xx_id); + +static const struct of_device_id hycon_hy46xx_of_match[] = { + { .compatible = "hycon,hy4613" }, + { .compatible = "hycon,hy4614" }, + { .compatible = "hycon,hy4621" }, + { .compatible = "hycon,hy4623" }, + { .compatible = "hycon,hy4633" }, + { .compatible = "hycon,hy4635" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, hycon_hy46xx_of_match); + +static struct i2c_driver hycon_hy46xx_driver = { + .driver = { + .name = "hycon_hy46xx", + .of_match_table = hycon_hy46xx_of_match, + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, + .id_table = hycon_hy46xx_id, + .probe = hycon_hy46xx_probe, +}; + +module_i2c_driver(hycon_hy46xx_driver); + +MODULE_AUTHOR("Giulio Benetti <giulio.benetti@benettiengineering.com>"); +MODULE_DESCRIPTION("HYCON HY46XX I2C Touchscreen Driver"); +MODULE_LICENSE("GPL v2"); -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v5 3/3] Input: add driver for the Hycon HY46XX touchpanel series 2021-04-11 11:48 ` [PATCH v5 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-11 11:48 ` [PATCH v5 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti 2021-04-11 11:48 ` [PATCH v5 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti @ 2021-04-11 11:48 ` Giulio Benetti 2 siblings, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-11 11:48 UTC (permalink / raw) To: Rob Herring Cc: Dmitry Torokhov, Jonathan Neuschäfer, Henrik Rydberg, linux-input, devicetree, linux-kernel, Giulio Benetti This patch adds support for Hycon HY46XX. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> --- V1->V2: * removed proximity-sensor-switch property according to previous patch As suggested by Dmitry Torokhov * moved i2c communaction to regmap use * added macro to avoid magic number * removed cmd variable that could uninitiliazed since we're using regmap now * removed useless byte masking * removed useless struct hycon_hy46xx_i2c_chip_data * used IRQF_ONESHOT only for isr V2->V3: As suggested by Jonathan Neuschäfer: * fixed Kconfig description * fixed DT properties by preprending "hycon," * changed MODULE_AUTHOR() e-mail according to SoB and authorship V4->V5: As suggested by Rob Herring according to dt-bindings: * drop hycon- prefix from compatible * change hycon,power-noise-enable property name to hycon,noise-filter-enable and change power_noise_enable variable name to noise_filter_enable --- MAINTAINERS | 1 + drivers/input/touchscreen/Kconfig | 11 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/hycon-hy46xx.c | 591 +++++++++++++++++++++++ 4 files changed, 604 insertions(+) create mode 100644 drivers/input/touchscreen/hycon-hy46xx.c diff --git a/MAINTAINERS b/MAINTAINERS index 18a50942c019..588ca21cfc09 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8255,6 +8255,7 @@ M: Giulio Benetti <giulio.benetti@benettiengineering.com> L: linux-input@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml +F: drivers/input/touchscreen/hy46xx.c HYGON PROCESSOR SUPPORT M: Pu Wen <puwen@hygon.cn> diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 529614d364fe..fe1468b74530 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1335,4 +1335,15 @@ config TOUCHSCREEN_ZINITIX To compile this driver as a module, choose M here: the module will be called zinitix. +config TOUCHSCREEN_HYCON_HY46XX + tristate "Hycon hy46xx touchscreen support" + depends on I2C + help + Say Y here if you have a touchscreen using Hycon hy46xx + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called hycon-hy46xx. + endif diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 6233541e9173..8b68cf3a3e6d 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -112,3 +112,4 @@ obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o obj-$(CONFIG_TOUCHSCREEN_ZINITIX) += zinitix.o +obj-$(CONFIG_TOUCHSCREEN_HYCON_HY46XX) += hycon-hy46xx.o diff --git a/drivers/input/touchscreen/hycon-hy46xx.c b/drivers/input/touchscreen/hycon-hy46xx.c new file mode 100644 index 000000000000..5db3a4c4a472 --- /dev/null +++ b/drivers/input/touchscreen/hycon-hy46xx.c @@ -0,0 +1,591 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 + * Author(s): Giulio Benetti <giulio.benetti@benettiengineering.com> + */ + +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/input.h> +#include <linux/input/mt.h> +#include <linux/input/touchscreen.h> +#include <linux/irq.h> +#include <linux/regulator/consumer.h> +#include <linux/regmap.h> + +#include <asm/unaligned.h> + +#define HY46XX_CHKSUM_CODE 0x1 +#define HY46XX_FINGER_NUM 0x2 +#define HY46XX_CHKSUM_LEN 0x7 +#define HY46XX_THRESHOLD 0x80 +#define HY46XX_GLOVE_EN 0x84 +#define HY46XX_REPORT_SPEED 0x88 +#define HY46XX_PWR_NOISE_EN 0x89 +#define HY46XX_FILTER_DATA 0x8A +#define HY46XX_GAIN 0x92 +#define HY46XX_EDGE_OFFSET 0x93 +#define HY46XX_RX_NR_USED 0x94 +#define HY46XX_TX_NR_USED 0x95 +#define HY46XX_PWR_MODE 0xA5 +#define HY46XX_FW_VERSION 0xA6 +#define HY46XX_LIB_VERSION 0xA7 +#define HY46XX_TP_INFO 0xA8 +#define HY46XX_TP_CHIP_ID 0xA9 +#define HY46XX_BOOT_VER 0xB0 + +#define HY46XX_TPLEN 0x6 +#define HY46XX_REPORT_PKT_LEN 0x44 + +#define HY46XX_MAX_SUPPORTED_POINTS 11 + +#define TOUCH_EVENT_DOWN 0x00 +#define TOUCH_EVENT_UP 0x01 +#define TOUCH_EVENT_CONTACT 0x02 +#define TOUCH_EVENT_RESERVED 0x03 + +struct hycon_hy46xx_data { + struct i2c_client *client; + struct input_dev *input; + struct touchscreen_properties prop; + struct regulator *vcc; + + struct gpio_desc *reset_gpio; + + struct mutex mutex; + struct regmap *regmap; + + int threshold; + bool glove_enable; + int report_speed; + bool noise_filter_enable; + int filter_data; + int gain; + int edge_offset; + int rx_number_used; + int tx_number_used; + int power_mode; + int fw_version; + int lib_version; + int tp_information; + int tp_chip_id; + int bootloader_version; +}; + +static const struct regmap_config hycon_hy46xx_i2c_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; + +static bool hycon_hy46xx_check_checksum(struct hycon_hy46xx_data *tsdata, u8 *buf) +{ + u8 chksum = 0; + int i; + + for (i = 2; i < buf[HY46XX_CHKSUM_LEN]; i++) + chksum += buf[i]; + + if (chksum == buf[HY46XX_CHKSUM_CODE]) + return true; + + dev_err_ratelimited(&tsdata->client->dev, + "checksum error: 0x%02x expected, got 0x%02x\n", + chksum, buf[HY46XX_CHKSUM_CODE]); + + return false; +} + +static irqreturn_t hycon_hy46xx_isr(int irq, void *dev_id) +{ + struct hycon_hy46xx_data *tsdata = dev_id; + struct device *dev = &tsdata->client->dev; + u8 rdbuf[HY46XX_REPORT_PKT_LEN]; + int i, x, y, id; + int error; + + memset(rdbuf, 0, sizeof(rdbuf)); + + error = regmap_bulk_read(tsdata->regmap, 0, rdbuf, sizeof(rdbuf)); + if (error) { + dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n", + error); + goto out; + } + + if (!hycon_hy46xx_check_checksum(tsdata, rdbuf)) + goto out; + + for (i = 0; i < HY46XX_MAX_SUPPORTED_POINTS; i++) { + u8 *buf = &rdbuf[3 + (HY46XX_TPLEN * i)]; + int type = buf[0] >> 6; + + if (type == TOUCH_EVENT_RESERVED) + continue; + + x = get_unaligned_be16(buf) & 0x0fff; + y = get_unaligned_be16(buf + 2) & 0x0fff; + + id = buf[2] >> 4; + + input_mt_slot(tsdata->input, id); + if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, + type != TOUCH_EVENT_UP)) + touchscreen_report_pos(tsdata->input, &tsdata->prop, + x, y, true); + } + + input_mt_report_pointer_emulation(tsdata->input, true); + input_sync(tsdata->input); + +out: + return IRQ_HANDLED; +} + +struct hycon_hy46xx_attribute { + struct device_attribute dattr; + size_t field_offset; + u8 address; + u8 limit_low; + u8 limit_high; +}; + +#define HYCON_ATTR_U8(_field, _mode, _address, _limit_low, _limit_high) \ + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ + .dattr = __ATTR(_field, _mode, \ + hycon_hy46xx_setting_show, \ + hycon_hy46xx_setting_store), \ + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ + .address = _address, \ + .limit_low = _limit_low, \ + .limit_high = _limit_high, \ + } + +#define HYCON_ATTR_BOOL(_field, _mode, _address) \ + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ + .dattr = __ATTR(_field, _mode, \ + hycon_hy46xx_setting_show, \ + hycon_hy46xx_setting_store), \ + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ + .address = _address, \ + .limit_low = false, \ + .limit_high = true, \ + } + +static ssize_t hycon_hy46xx_setting_show(struct device *dev, + struct device_attribute *dattr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); + struct hycon_hy46xx_attribute *attr = + container_of(dattr, struct hycon_hy46xx_attribute, dattr); + u8 *field = (u8 *)tsdata + attr->field_offset; + size_t count = 0; + int error = 0; + int val; + + mutex_lock(&tsdata->mutex); + + error = regmap_read(tsdata->regmap, attr->address, &val); + if (error < 0) { + dev_err(&tsdata->client->dev, + "Failed to fetch attribute %s, error %d\n", + dattr->attr.name, error); + goto out; + } + + if (val != *field) { + dev_warn(&tsdata->client->dev, + "%s: read (%d) and stored value (%d) differ\n", + dattr->attr.name, val, *field); + *field = val; + } + + count = scnprintf(buf, PAGE_SIZE, "%d\n", val); + +out: + mutex_unlock(&tsdata->mutex); + return error ?: count; +} + +static ssize_t hycon_hy46xx_setting_store(struct device *dev, + struct device_attribute *dattr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); + struct hycon_hy46xx_attribute *attr = + container_of(dattr, struct hycon_hy46xx_attribute, dattr); + u8 *field = (u8 *)tsdata + attr->field_offset; + unsigned int val; + int error; + + mutex_lock(&tsdata->mutex); + + error = kstrtouint(buf, 0, &val); + if (error) + goto out; + + if (val < attr->limit_low || val > attr->limit_high) { + error = -ERANGE; + goto out; + } + + error = regmap_write(tsdata->regmap, attr->address, val); + if (error < 0) { + dev_err(&tsdata->client->dev, + "Failed to update attribute %s, error: %d\n", + dattr->attr.name, error); + goto out; + } + *field = val; + +out: + mutex_unlock(&tsdata->mutex); + return error ?: count; +} + +static HYCON_ATTR_U8(threshold, 0644, HY46XX_THRESHOLD, 0, 255); +static HYCON_ATTR_BOOL(glove_enable, 0644, HY46XX_GLOVE_EN); +static HYCON_ATTR_U8(report_speed, 0644, HY46XX_REPORT_SPEED, 0, 255); +static HYCON_ATTR_BOOL(noise_filter_enable, 0644, HY46XX_PWR_NOISE_EN); +static HYCON_ATTR_U8(filter_data, 0644, HY46XX_FILTER_DATA, 0, 5); +static HYCON_ATTR_U8(gain, 0644, HY46XX_GAIN, 0, 5); +static HYCON_ATTR_U8(edge_offset, 0644, HY46XX_EDGE_OFFSET, 0, 5); +static HYCON_ATTR_U8(fw_version, 0444, HY46XX_FW_VERSION, 0, 255); +static HYCON_ATTR_U8(lib_version, 0444, HY46XX_LIB_VERSION, 0, 255); +static HYCON_ATTR_U8(tp_information, 0444, HY46XX_TP_INFO, 0, 255); +static HYCON_ATTR_U8(tp_chip_id, 0444, HY46XX_TP_CHIP_ID, 0, 255); +static HYCON_ATTR_U8(bootloader_version, 0444, HY46XX_BOOT_VER, 0, 255); + +static struct attribute *hycon_hy46xx_attrs[] = { + &hycon_hy46xx_attr_threshold.dattr.attr, + &hycon_hy46xx_attr_glove_enable.dattr.attr, + &hycon_hy46xx_attr_report_speed.dattr.attr, + &hycon_hy46xx_attr_noise_filter_enable.dattr.attr, + &hycon_hy46xx_attr_filter_data.dattr.attr, + &hycon_hy46xx_attr_gain.dattr.attr, + &hycon_hy46xx_attr_edge_offset.dattr.attr, + &hycon_hy46xx_attr_fw_version.dattr.attr, + &hycon_hy46xx_attr_lib_version.dattr.attr, + &hycon_hy46xx_attr_tp_information.dattr.attr, + &hycon_hy46xx_attr_tp_chip_id.dattr.attr, + &hycon_hy46xx_attr_bootloader_version.dattr.attr, + NULL +}; + +static const struct attribute_group hycon_hy46xx_attr_group = { + .attrs = hycon_hy46xx_attrs, +}; + +static void hycon_hy46xx_get_defaults(struct device *dev, struct hycon_hy46xx_data *tsdata) +{ + bool val_bool; + int error; + u32 val; + + error = device_property_read_u32(dev, "hycon,threshold", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_THRESHOLD, val); + if (error < 0) + goto out; + + tsdata->threshold = val; + } + + val_bool = device_property_read_bool(dev, "hycon,glove-enable"); + error = regmap_write(tsdata->regmap, HY46XX_GLOVE_EN, val_bool); + if (error < 0) + goto out; + tsdata->glove_enable = val_bool; + + error = device_property_read_u32(dev, "hycon,report-speed", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_REPORT_SPEED, val); + if (error < 0) + goto out; + + tsdata->report_speed = val; + } + + val_bool = device_property_read_bool(dev, "hycon,noise-filter-enable"); + error = regmap_write(tsdata->regmap, HY46XX_PWR_NOISE_EN, val_bool); + if (error < 0) + goto out; + tsdata->noise_filter_enable = val_bool; + + error = device_property_read_u32(dev, "hycon,filter-data", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_FILTER_DATA, val); + if (error < 0) + goto out; + + tsdata->filter_data = val; + } + + error = device_property_read_u32(dev, "hycon,gain", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_GAIN, val); + if (error < 0) + goto out; + + tsdata->gain = val; + } + + error = device_property_read_u32(dev, "hycon,edge-offset", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_EDGE_OFFSET, val); + if (error < 0) + goto out; + + tsdata->edge_offset = val; + } + + return; +out: + dev_err(&tsdata->client->dev, "Failed to set default settings"); +} + +static void hycon_hy46xx_get_parameters(struct hycon_hy46xx_data *tsdata) +{ + int error; + u32 val; + + error = regmap_read(tsdata->regmap, HY46XX_THRESHOLD, &val); + if (error < 0) + goto out; + tsdata->threshold = val; + + error = regmap_read(tsdata->regmap, HY46XX_GLOVE_EN, &val); + if (error < 0) + goto out; + tsdata->glove_enable = val; + + error = regmap_read(tsdata->regmap, HY46XX_REPORT_SPEED, &val); + if (error < 0) + goto out; + tsdata->report_speed = val; + + error = regmap_read(tsdata->regmap, HY46XX_PWR_NOISE_EN, &val); + if (error < 0) + goto out; + tsdata->noise_filter_enable = val; + + error = regmap_read(tsdata->regmap, HY46XX_FILTER_DATA, &val); + if (error < 0) + goto out; + tsdata->filter_data = val; + + error = regmap_read(tsdata->regmap, HY46XX_GAIN, &val); + if (error < 0) + goto out; + tsdata->gain = val; + + error = regmap_read(tsdata->regmap, HY46XX_EDGE_OFFSET, &val); + if (error < 0) + goto out; + tsdata->edge_offset = val; + + error = regmap_read(tsdata->regmap, HY46XX_RX_NR_USED, &val); + if (error < 0) + goto out; + tsdata->rx_number_used = val; + + error = regmap_read(tsdata->regmap, HY46XX_TX_NR_USED, &val); + if (error < 0) + goto out; + tsdata->tx_number_used = val; + + error = regmap_read(tsdata->regmap, HY46XX_PWR_MODE, &val); + if (error < 0) + goto out; + tsdata->power_mode = val; + + error = regmap_read(tsdata->regmap, HY46XX_FW_VERSION, &val); + if (error < 0) + goto out; + tsdata->fw_version = val; + + error = regmap_read(tsdata->regmap, HY46XX_LIB_VERSION, &val); + if (error < 0) + goto out; + tsdata->lib_version = val; + + error = regmap_read(tsdata->regmap, HY46XX_TP_INFO, &val); + if (error < 0) + goto out; + tsdata->tp_information = val; + + error = regmap_read(tsdata->regmap, HY46XX_TP_CHIP_ID, &val); + if (error < 0) + goto out; + tsdata->tp_chip_id = val; + + error = regmap_read(tsdata->regmap, HY46XX_BOOT_VER, &val); + if (error < 0) + goto out; + tsdata->bootloader_version = val; + + return; +out: + dev_err(&tsdata->client->dev, "Failed to read default settings"); +} + +static void hycon_hy46xx_disable_regulator(void *arg) +{ + struct hycon_hy46xx_data *data = arg; + + regulator_disable(data->vcc); +} + +static int hycon_hy46xx_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct hycon_hy46xx_data *tsdata; + struct input_dev *input; + int error; + + dev_dbg(&client->dev, "probing for HYCON HY46XX I2C\n"); + + tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL); + if (!tsdata) + return -ENOMEM; + + tsdata->vcc = devm_regulator_get(&client->dev, "vcc"); + if (IS_ERR(tsdata->vcc)) { + error = PTR_ERR(tsdata->vcc); + if (error != -EPROBE_DEFER) + dev_err(&client->dev, + "failed to request regulator: %d\n", error); + return error; + } + + error = regulator_enable(tsdata->vcc); + if (error < 0) { + dev_err(&client->dev, "failed to enable vcc: %d\n", error); + return error; + } + + error = devm_add_action_or_reset(&client->dev, + hycon_hy46xx_disable_regulator, + tsdata); + if (error) + return error; + + tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, + "reset", GPIOD_OUT_LOW); + if (IS_ERR(tsdata->reset_gpio)) { + error = PTR_ERR(tsdata->reset_gpio); + dev_err(&client->dev, + "Failed to request GPIO reset pin, error %d\n", error); + return error; + } + + if (tsdata->reset_gpio) { + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->reset_gpio, 1); + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->reset_gpio, 0); + msleep(1000); + } + + input = devm_input_allocate_device(&client->dev); + if (!input) { + dev_err(&client->dev, "failed to allocate input device.\n"); + return -ENOMEM; + } + + mutex_init(&tsdata->mutex); + tsdata->client = client; + tsdata->input = input; + + tsdata->regmap = devm_regmap_init_i2c(client, + &hycon_hy46xx_i2c_regmap_config); + if (IS_ERR(tsdata->regmap)) { + dev_err(&client->dev, "regmap allocation failed\n"); + return PTR_ERR(tsdata->regmap); + } + + hycon_hy46xx_get_defaults(&client->dev, tsdata); + hycon_hy46xx_get_parameters(tsdata); + + input->name = "Hycon Capacitive Touch"; + input->id.bustype = BUS_I2C; + input->dev.parent = &client->dev; + + input_set_abs_params(input, ABS_MT_POSITION_X, 0, -1, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, -1, 0, 0); + + touchscreen_parse_properties(input, true, &tsdata->prop); + + error = input_mt_init_slots(input, HY46XX_MAX_SUPPORTED_POINTS, + INPUT_MT_DIRECT); + if (error) { + dev_err(&client->dev, "Unable to init MT slots.\n"); + return error; + } + + i2c_set_clientdata(client, tsdata); + + error = devm_request_threaded_irq(&client->dev, client->irq, + NULL, hycon_hy46xx_isr, IRQF_ONESHOT, + client->name, tsdata); + if (error) { + dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); + return error; + } + + error = devm_device_add_group(&client->dev, &hycon_hy46xx_attr_group); + if (error) + return error; + + error = input_register_device(input); + if (error) + return error; + + dev_dbg(&client->dev, + "HYCON HY46XX initialized: IRQ %d, Reset pin %d.\n", + client->irq, + tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); + + return 0; +} + +static const struct i2c_device_id hycon_hy46xx_id[] = { + { .name = "hy4613" }, + { .name = "hy4614" }, + { .name = "hy4621" }, + { .name = "hy4623" }, + { .name = "hy4633" }, + { .name = "hy4635" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(i2c, hycon_hy46xx_id); + +static const struct of_device_id hycon_hy46xx_of_match[] = { + { .compatible = "hycon,hy4613" }, + { .compatible = "hycon,hy4614" }, + { .compatible = "hycon,hy4621" }, + { .compatible = "hycon,hy4623" }, + { .compatible = "hycon,hy4633" }, + { .compatible = "hycon,hy4635" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, hycon_hy46xx_of_match); + +static struct i2c_driver hycon_hy46xx_driver = { + .driver = { + .name = "hycon_hy46xx", + .of_match_table = hycon_hy46xx_of_match, + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, + .id_table = hycon_hy46xx_id, + .probe = hycon_hy46xx_probe, +}; + +module_i2c_driver(hycon_hy46xx_driver); + +MODULE_AUTHOR("Giulio Benetti <giulio.benetti@benettiengineering.com>"); +MODULE_DESCRIPTION("HYCON HY46XX I2C Touchscreen Driver"); +MODULE_LICENSE("GPL v2"); -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v4 3/3] Input: add driver for the Hycon HY46XX touchpanel series 2021-04-07 17:49 ` [PATCH v4 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-07 17:49 ` [PATCH v4 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti 2021-04-07 17:49 ` [PATCH v4 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti @ 2021-04-07 17:49 ` Giulio Benetti 2 siblings, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-07 17:49 UTC (permalink / raw) To: Dmitry Torokhov, Rob Herring, Jonathan Neuschäfer Cc: Henrik Rydberg, linux-input, devicetree, linux-kernel, Giulio Benetti This patch adds support for Hycon HY46XX. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> --- V1->V2: * removed proximity-sensor-switch property according to previous patch As suggested by Dmitry Torokhov * moved i2c communaction to regmap use * added macro to avoid magic number * removed cmd variable that could uninitiliazed since we're using regmap now * removed useless byte masking * removed useless struct hycon_hy46xx_i2c_chip_data * used IRQF_ONESHOT only for isr V2->V3: As suggested by Jonathan Neuschäfer: * fixed Kconfig description * fixed DT properties by preprending "hycon," * changed MODULE_AUTHOR() e-mail according to SoB and authorship --- MAINTAINERS | 1 + drivers/input/touchscreen/Kconfig | 11 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/hycon-hy46xx.c | 591 +++++++++++++++++++++++ 4 files changed, 604 insertions(+) create mode 100644 drivers/input/touchscreen/hycon-hy46xx.c diff --git a/MAINTAINERS b/MAINTAINERS index d022ff09e609..2a90237e93c6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8248,6 +8248,7 @@ M: Giulio Benetti <giulio.benetti@benettiengineering.com> L: linux-input@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml +F: drivers/input/touchscreen/hy46xx.c HYGON PROCESSOR SUPPORT M: Pu Wen <puwen@hygon.cn> diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 529614d364fe..fe1468b74530 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1335,4 +1335,15 @@ config TOUCHSCREEN_ZINITIX To compile this driver as a module, choose M here: the module will be called zinitix. +config TOUCHSCREEN_HYCON_HY46XX + tristate "Hycon hy46xx touchscreen support" + depends on I2C + help + Say Y here if you have a touchscreen using Hycon hy46xx + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called hycon-hy46xx. + endif diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 6233541e9173..8b68cf3a3e6d 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -112,3 +112,4 @@ obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o obj-$(CONFIG_TOUCHSCREEN_ZINITIX) += zinitix.o +obj-$(CONFIG_TOUCHSCREEN_HYCON_HY46XX) += hycon-hy46xx.o diff --git a/drivers/input/touchscreen/hycon-hy46xx.c b/drivers/input/touchscreen/hycon-hy46xx.c new file mode 100644 index 000000000000..a7e7a9d8ee79 --- /dev/null +++ b/drivers/input/touchscreen/hycon-hy46xx.c @@ -0,0 +1,591 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 + * Author(s): Giulio Benetti <giulio.benetti@benettiengineering.com> + */ + +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/input.h> +#include <linux/input/mt.h> +#include <linux/input/touchscreen.h> +#include <linux/irq.h> +#include <linux/regulator/consumer.h> +#include <linux/regmap.h> + +#include <asm/unaligned.h> + +#define HY46XX_CHKSUM_CODE 0x1 +#define HY46XX_FINGER_NUM 0x2 +#define HY46XX_CHKSUM_LEN 0x7 +#define HY46XX_THRESHOLD 0x80 +#define HY46XX_GLOVE_EN 0x84 +#define HY46XX_REPORT_SPEED 0x88 +#define HY46XX_PWR_NOISE_EN 0x89 +#define HY46XX_FILTER_DATA 0x8A +#define HY46XX_GAIN 0x92 +#define HY46XX_EDGE_OFFSET 0x93 +#define HY46XX_RX_NR_USED 0x94 +#define HY46XX_TX_NR_USED 0x95 +#define HY46XX_PWR_MODE 0xA5 +#define HY46XX_FW_VERSION 0xA6 +#define HY46XX_LIB_VERSION 0xA7 +#define HY46XX_TP_INFO 0xA8 +#define HY46XX_TP_CHIP_ID 0xA9 +#define HY46XX_BOOT_VER 0xB0 + +#define HY46XX_TPLEN 0x6 +#define HY46XX_REPORT_PKT_LEN 0x44 + +#define HY46XX_MAX_SUPPORTED_POINTS 11 + +#define TOUCH_EVENT_DOWN 0x00 +#define TOUCH_EVENT_UP 0x01 +#define TOUCH_EVENT_CONTACT 0x02 +#define TOUCH_EVENT_RESERVED 0x03 + +struct hycon_hy46xx_data { + struct i2c_client *client; + struct input_dev *input; + struct touchscreen_properties prop; + struct regulator *vcc; + + struct gpio_desc *reset_gpio; + + struct mutex mutex; + struct regmap *regmap; + + int threshold; + bool glove_enable; + int report_speed; + bool power_noise_enable; + int filter_data; + int gain; + int edge_offset; + int rx_number_used; + int tx_number_used; + int power_mode; + int fw_version; + int lib_version; + int tp_information; + int tp_chip_id; + int bootloader_version; +}; + +static const struct regmap_config hycon_hy46xx_i2c_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; + +static bool hycon_hy46xx_check_checksum(struct hycon_hy46xx_data *tsdata, u8 *buf) +{ + u8 chksum = 0; + int i; + + for (i = 2; i < buf[HY46XX_CHKSUM_LEN]; i++) + chksum += buf[i]; + + if (chksum == buf[HY46XX_CHKSUM_CODE]) + return true; + + dev_err_ratelimited(&tsdata->client->dev, + "checksum error: 0x%02x expected, got 0x%02x\n", + chksum, buf[HY46XX_CHKSUM_CODE]); + + return false; +} + +static irqreturn_t hycon_hy46xx_isr(int irq, void *dev_id) +{ + struct hycon_hy46xx_data *tsdata = dev_id; + struct device *dev = &tsdata->client->dev; + u8 rdbuf[HY46XX_REPORT_PKT_LEN]; + int i, x, y, id; + int error; + + memset(rdbuf, 0, sizeof(rdbuf)); + + error = regmap_bulk_read(tsdata->regmap, 0, rdbuf, sizeof(rdbuf)); + if (error) { + dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n", + error); + goto out; + } + + if (!hycon_hy46xx_check_checksum(tsdata, rdbuf)) + goto out; + + for (i = 0; i < HY46XX_MAX_SUPPORTED_POINTS; i++) { + u8 *buf = &rdbuf[3 + (HY46XX_TPLEN * i)]; + int type = buf[0] >> 6; + + if (type == TOUCH_EVENT_RESERVED) + continue; + + x = get_unaligned_be16(buf) & 0x0fff; + y = get_unaligned_be16(buf + 2) & 0x0fff; + + id = buf[2] >> 4; + + input_mt_slot(tsdata->input, id); + if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, + type != TOUCH_EVENT_UP)) + touchscreen_report_pos(tsdata->input, &tsdata->prop, + x, y, true); + } + + input_mt_report_pointer_emulation(tsdata->input, true); + input_sync(tsdata->input); + +out: + return IRQ_HANDLED; +} + +struct hycon_hy46xx_attribute { + struct device_attribute dattr; + size_t field_offset; + u8 address; + u8 limit_low; + u8 limit_high; +}; + +#define HYCON_ATTR_U8(_field, _mode, _address, _limit_low, _limit_high) \ + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ + .dattr = __ATTR(_field, _mode, \ + hycon_hy46xx_setting_show, \ + hycon_hy46xx_setting_store), \ + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ + .address = _address, \ + .limit_low = _limit_low, \ + .limit_high = _limit_high, \ + } + +#define HYCON_ATTR_BOOL(_field, _mode, _address) \ + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ + .dattr = __ATTR(_field, _mode, \ + hycon_hy46xx_setting_show, \ + hycon_hy46xx_setting_store), \ + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ + .address = _address, \ + .limit_low = false, \ + .limit_high = true, \ + } + +static ssize_t hycon_hy46xx_setting_show(struct device *dev, + struct device_attribute *dattr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); + struct hycon_hy46xx_attribute *attr = + container_of(dattr, struct hycon_hy46xx_attribute, dattr); + u8 *field = (u8 *)tsdata + attr->field_offset; + size_t count = 0; + int error = 0; + int val; + + mutex_lock(&tsdata->mutex); + + error = regmap_read(tsdata->regmap, attr->address, &val); + if (error < 0) { + dev_err(&tsdata->client->dev, + "Failed to fetch attribute %s, error %d\n", + dattr->attr.name, error); + goto out; + } + + if (val != *field) { + dev_warn(&tsdata->client->dev, + "%s: read (%d) and stored value (%d) differ\n", + dattr->attr.name, val, *field); + *field = val; + } + + count = scnprintf(buf, PAGE_SIZE, "%d\n", val); + +out: + mutex_unlock(&tsdata->mutex); + return error ?: count; +} + +static ssize_t hycon_hy46xx_setting_store(struct device *dev, + struct device_attribute *dattr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); + struct hycon_hy46xx_attribute *attr = + container_of(dattr, struct hycon_hy46xx_attribute, dattr); + u8 *field = (u8 *)tsdata + attr->field_offset; + unsigned int val; + int error; + + mutex_lock(&tsdata->mutex); + + error = kstrtouint(buf, 0, &val); + if (error) + goto out; + + if (val < attr->limit_low || val > attr->limit_high) { + error = -ERANGE; + goto out; + } + + error = regmap_write(tsdata->regmap, attr->address, val); + if (error < 0) { + dev_err(&tsdata->client->dev, + "Failed to update attribute %s, error: %d\n", + dattr->attr.name, error); + goto out; + } + *field = val; + +out: + mutex_unlock(&tsdata->mutex); + return error ?: count; +} + +static HYCON_ATTR_U8(threshold, 0644, HY46XX_THRESHOLD, 0, 255); +static HYCON_ATTR_BOOL(glove_enable, 0644, HY46XX_GLOVE_EN); +static HYCON_ATTR_U8(report_speed, 0644, HY46XX_REPORT_SPEED, 0, 255); +static HYCON_ATTR_BOOL(power_noise_enable, 0644, HY46XX_PWR_NOISE_EN); +static HYCON_ATTR_U8(filter_data, 0644, HY46XX_FILTER_DATA, 0, 5); +static HYCON_ATTR_U8(gain, 0644, HY46XX_GAIN, 0, 5); +static HYCON_ATTR_U8(edge_offset, 0644, HY46XX_EDGE_OFFSET, 0, 5); +static HYCON_ATTR_U8(fw_version, 0444, HY46XX_FW_VERSION, 0, 255); +static HYCON_ATTR_U8(lib_version, 0444, HY46XX_LIB_VERSION, 0, 255); +static HYCON_ATTR_U8(tp_information, 0444, HY46XX_TP_INFO, 0, 255); +static HYCON_ATTR_U8(tp_chip_id, 0444, HY46XX_TP_CHIP_ID, 0, 255); +static HYCON_ATTR_U8(bootloader_version, 0444, HY46XX_BOOT_VER, 0, 255); + +static struct attribute *hycon_hy46xx_attrs[] = { + &hycon_hy46xx_attr_threshold.dattr.attr, + &hycon_hy46xx_attr_glove_enable.dattr.attr, + &hycon_hy46xx_attr_report_speed.dattr.attr, + &hycon_hy46xx_attr_power_noise_enable.dattr.attr, + &hycon_hy46xx_attr_filter_data.dattr.attr, + &hycon_hy46xx_attr_gain.dattr.attr, + &hycon_hy46xx_attr_edge_offset.dattr.attr, + &hycon_hy46xx_attr_fw_version.dattr.attr, + &hycon_hy46xx_attr_lib_version.dattr.attr, + &hycon_hy46xx_attr_tp_information.dattr.attr, + &hycon_hy46xx_attr_tp_chip_id.dattr.attr, + &hycon_hy46xx_attr_bootloader_version.dattr.attr, + NULL +}; + +static const struct attribute_group hycon_hy46xx_attr_group = { + .attrs = hycon_hy46xx_attrs, +}; + +static void hycon_hy46xx_get_defaults(struct device *dev, struct hycon_hy46xx_data *tsdata) +{ + bool val_bool; + int error; + u32 val; + + error = device_property_read_u32(dev, "hycon,threshold", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_THRESHOLD, val); + if (error < 0) + goto out; + + tsdata->threshold = val; + } + + val_bool = device_property_read_bool(dev, "hycon,glove-enable"); + error = regmap_write(tsdata->regmap, HY46XX_GLOVE_EN, val_bool); + if (error < 0) + goto out; + tsdata->glove_enable = val_bool; + + error = device_property_read_u32(dev, "hycon,report-speed", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_REPORT_SPEED, val); + if (error < 0) + goto out; + + tsdata->report_speed = val; + } + + val_bool = device_property_read_bool(dev, "hycon,power-noise-enable"); + error = regmap_write(tsdata->regmap, HY46XX_PWR_NOISE_EN, val_bool); + if (error < 0) + goto out; + tsdata->power_noise_enable = val_bool; + + error = device_property_read_u32(dev, "hycon,filter-data", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_FILTER_DATA, val); + if (error < 0) + goto out; + + tsdata->filter_data = val; + } + + error = device_property_read_u32(dev, "hycon,gain", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_GAIN, val); + if (error < 0) + goto out; + + tsdata->gain = val; + } + + error = device_property_read_u32(dev, "hycon,edge-offset", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_EDGE_OFFSET, val); + if (error < 0) + goto out; + + tsdata->edge_offset = val; + } + + return; +out: + dev_err(&tsdata->client->dev, "Failed to set default settings"); +} + +static void hycon_hy46xx_get_parameters(struct hycon_hy46xx_data *tsdata) +{ + int error; + u32 val; + + error = regmap_read(tsdata->regmap, HY46XX_THRESHOLD, &val); + if (error < 0) + goto out; + tsdata->threshold = val; + + error = regmap_read(tsdata->regmap, HY46XX_GLOVE_EN, &val); + if (error < 0) + goto out; + tsdata->glove_enable = val; + + error = regmap_read(tsdata->regmap, HY46XX_REPORT_SPEED, &val); + if (error < 0) + goto out; + tsdata->report_speed = val; + + error = regmap_read(tsdata->regmap, HY46XX_PWR_NOISE_EN, &val); + if (error < 0) + goto out; + tsdata->power_noise_enable = val; + + error = regmap_read(tsdata->regmap, HY46XX_FILTER_DATA, &val); + if (error < 0) + goto out; + tsdata->filter_data = val; + + error = regmap_read(tsdata->regmap, HY46XX_GAIN, &val); + if (error < 0) + goto out; + tsdata->gain = val; + + error = regmap_read(tsdata->regmap, HY46XX_EDGE_OFFSET, &val); + if (error < 0) + goto out; + tsdata->edge_offset = val; + + error = regmap_read(tsdata->regmap, HY46XX_RX_NR_USED, &val); + if (error < 0) + goto out; + tsdata->rx_number_used = val; + + error = regmap_read(tsdata->regmap, HY46XX_TX_NR_USED, &val); + if (error < 0) + goto out; + tsdata->tx_number_used = val; + + error = regmap_read(tsdata->regmap, HY46XX_PWR_MODE, &val); + if (error < 0) + goto out; + tsdata->power_mode = val; + + error = regmap_read(tsdata->regmap, HY46XX_FW_VERSION, &val); + if (error < 0) + goto out; + tsdata->fw_version = val; + + error = regmap_read(tsdata->regmap, HY46XX_LIB_VERSION, &val); + if (error < 0) + goto out; + tsdata->lib_version = val; + + error = regmap_read(tsdata->regmap, HY46XX_TP_INFO, &val); + if (error < 0) + goto out; + tsdata->tp_information = val; + + error = regmap_read(tsdata->regmap, HY46XX_TP_CHIP_ID, &val); + if (error < 0) + goto out; + tsdata->tp_chip_id = val; + + error = regmap_read(tsdata->regmap, HY46XX_BOOT_VER, &val); + if (error < 0) + goto out; + tsdata->bootloader_version = val; + + return; +out: + dev_err(&tsdata->client->dev, "Failed to read default settings"); +} + +static void hycon_hy46xx_disable_regulator(void *arg) +{ + struct hycon_hy46xx_data *data = arg; + + regulator_disable(data->vcc); +} + +static int hycon_hy46xx_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct hycon_hy46xx_data *tsdata; + struct input_dev *input; + int error; + + dev_dbg(&client->dev, "probing for HYCON HY46XX I2C\n"); + + tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL); + if (!tsdata) + return -ENOMEM; + + tsdata->vcc = devm_regulator_get(&client->dev, "vcc"); + if (IS_ERR(tsdata->vcc)) { + error = PTR_ERR(tsdata->vcc); + if (error != -EPROBE_DEFER) + dev_err(&client->dev, + "failed to request regulator: %d\n", error); + return error; + } + + error = regulator_enable(tsdata->vcc); + if (error < 0) { + dev_err(&client->dev, "failed to enable vcc: %d\n", error); + return error; + } + + error = devm_add_action_or_reset(&client->dev, + hycon_hy46xx_disable_regulator, + tsdata); + if (error) + return error; + + tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, + "reset", GPIOD_OUT_LOW); + if (IS_ERR(tsdata->reset_gpio)) { + error = PTR_ERR(tsdata->reset_gpio); + dev_err(&client->dev, + "Failed to request GPIO reset pin, error %d\n", error); + return error; + } + + if (tsdata->reset_gpio) { + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->reset_gpio, 1); + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->reset_gpio, 0); + msleep(1000); + } + + input = devm_input_allocate_device(&client->dev); + if (!input) { + dev_err(&client->dev, "failed to allocate input device.\n"); + return -ENOMEM; + } + + mutex_init(&tsdata->mutex); + tsdata->client = client; + tsdata->input = input; + + tsdata->regmap = devm_regmap_init_i2c(client, + &hycon_hy46xx_i2c_regmap_config); + if (IS_ERR(tsdata->regmap)) { + dev_err(&client->dev, "regmap allocation failed\n"); + return PTR_ERR(tsdata->regmap); + } + + hycon_hy46xx_get_defaults(&client->dev, tsdata); + hycon_hy46xx_get_parameters(tsdata); + + input->name = "Hycon Capacitive Touch"; + input->id.bustype = BUS_I2C; + input->dev.parent = &client->dev; + + input_set_abs_params(input, ABS_MT_POSITION_X, 0, -1, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, -1, 0, 0); + + touchscreen_parse_properties(input, true, &tsdata->prop); + + error = input_mt_init_slots(input, HY46XX_MAX_SUPPORTED_POINTS, + INPUT_MT_DIRECT); + if (error) { + dev_err(&client->dev, "Unable to init MT slots.\n"); + return error; + } + + i2c_set_clientdata(client, tsdata); + + error = devm_request_threaded_irq(&client->dev, client->irq, + NULL, hycon_hy46xx_isr, IRQF_ONESHOT, + client->name, tsdata); + if (error) { + dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); + return error; + } + + error = devm_device_add_group(&client->dev, &hycon_hy46xx_attr_group); + if (error) + return error; + + error = input_register_device(input); + if (error) + return error; + + dev_dbg(&client->dev, + "HYCON HY46XX initialized: IRQ %d, Reset pin %d.\n", + client->irq, + tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); + + return 0; +} + +static const struct i2c_device_id hycon_hy46xx_id[] = { + { .name = "hycon-hy4613" }, + { .name = "hycon-hy4614" }, + { .name = "hycon-hy4621" }, + { .name = "hycon-hy4623" }, + { .name = "hycon-hy4633" }, + { .name = "hycon-hy4635" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(i2c, hycon_hy46xx_id); + +static const struct of_device_id hycon_hy46xx_of_match[] = { + { .compatible = "hycon,hycon-hy4613" }, + { .compatible = "hycon,hycon-hy4614" }, + { .compatible = "hycon,hycon-hy4621" }, + { .compatible = "hycon,hycon-hy4623" }, + { .compatible = "hycon,hycon-hy4633" }, + { .compatible = "hycon,hycon-hy4635" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, hycon_hy46xx_of_match); + +static struct i2c_driver hycon_hy46xx_driver = { + .driver = { + .name = "hycon_hy46xx", + .of_match_table = hycon_hy46xx_of_match, + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, + .id_table = hycon_hy46xx_id, + .probe = hycon_hy46xx_probe, +}; + +module_i2c_driver(hycon_hy46xx_driver); + +MODULE_AUTHOR("Giulio Benetti <giulio.benetti@benettiengineering.com>"); +MODULE_DESCRIPTION("HYCON HY46XX I2C Touchscreen Driver"); +MODULE_LICENSE("GPL v2"); -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH v3 3/3] Input: add driver for the Hycon HY46XX touchpanel series 2021-04-02 16:16 ` [PATCH v3 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-02 16:16 ` [PATCH v3 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti 2021-04-02 16:16 ` [PATCH v3 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti @ 2021-04-02 16:16 ` Giulio Benetti 2 siblings, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-04-02 16:16 UTC (permalink / raw) To: Dmitry Torokhov, Rob Herring, Jonathan Neuschäfer Cc: Giulio Benetti, Henrik Rydberg, linux-input, devicetree, linux-kernel This patch adds support for Hycon HY46XX. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> --- V1->V2: * removed proximity-sensor-switch property according to previous patch As suggested by Dmitry Torokhov * moved i2c communaction to regmap use * added macro to avoid magic number * removed cmd variable that could uninitiliazed since we're using regmap now * removed useless byte masking * removed useless struct hycon_hy46xx_i2c_chip_data * used IRQF_ONESHOT only for isr V2->V3: As suggested by Jonathan Neuschäfer: * fixed Kconfig description * fixed DT properties by preprending "hycon," * changed MODULE_AUTHOR() e-mail according to SoB and authorship --- MAINTAINERS | 1 + drivers/input/touchscreen/Kconfig | 11 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/hycon-hy46xx.c | 591 +++++++++++++++++++++++ 4 files changed, 604 insertions(+) create mode 100644 drivers/input/touchscreen/hycon-hy46xx.c diff --git a/MAINTAINERS b/MAINTAINERS index 5e9cc7e610ce..93f22de4b9ee 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8247,6 +8247,7 @@ M: Giulio Benetti <giulio.benetti@benettiengineering.com> L: linux-input@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml +F: drivers/input/touchscreen/hy46xx.c HYGON PROCESSOR SUPPORT M: Pu Wen <puwen@hygon.cn> diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 529614d364fe..fe1468b74530 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1335,4 +1335,15 @@ config TOUCHSCREEN_ZINITIX To compile this driver as a module, choose M here: the module will be called zinitix. +config TOUCHSCREEN_HYCON_HY46XX + tristate "Hycon hy46xx touchscreen support" + depends on I2C + help + Say Y here if you have a touchscreen using Hycon hy46xx + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called hycon-hy46xx. + endif diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 6233541e9173..8b68cf3a3e6d 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -112,3 +112,4 @@ obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o obj-$(CONFIG_TOUCHSCREEN_ZINITIX) += zinitix.o +obj-$(CONFIG_TOUCHSCREEN_HYCON_HY46XX) += hycon-hy46xx.o diff --git a/drivers/input/touchscreen/hycon-hy46xx.c b/drivers/input/touchscreen/hycon-hy46xx.c new file mode 100644 index 000000000000..a7e7a9d8ee79 --- /dev/null +++ b/drivers/input/touchscreen/hycon-hy46xx.c @@ -0,0 +1,591 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 + * Author(s): Giulio Benetti <giulio.benetti@benettiengineering.com> + */ + +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/input.h> +#include <linux/input/mt.h> +#include <linux/input/touchscreen.h> +#include <linux/irq.h> +#include <linux/regulator/consumer.h> +#include <linux/regmap.h> + +#include <asm/unaligned.h> + +#define HY46XX_CHKSUM_CODE 0x1 +#define HY46XX_FINGER_NUM 0x2 +#define HY46XX_CHKSUM_LEN 0x7 +#define HY46XX_THRESHOLD 0x80 +#define HY46XX_GLOVE_EN 0x84 +#define HY46XX_REPORT_SPEED 0x88 +#define HY46XX_PWR_NOISE_EN 0x89 +#define HY46XX_FILTER_DATA 0x8A +#define HY46XX_GAIN 0x92 +#define HY46XX_EDGE_OFFSET 0x93 +#define HY46XX_RX_NR_USED 0x94 +#define HY46XX_TX_NR_USED 0x95 +#define HY46XX_PWR_MODE 0xA5 +#define HY46XX_FW_VERSION 0xA6 +#define HY46XX_LIB_VERSION 0xA7 +#define HY46XX_TP_INFO 0xA8 +#define HY46XX_TP_CHIP_ID 0xA9 +#define HY46XX_BOOT_VER 0xB0 + +#define HY46XX_TPLEN 0x6 +#define HY46XX_REPORT_PKT_LEN 0x44 + +#define HY46XX_MAX_SUPPORTED_POINTS 11 + +#define TOUCH_EVENT_DOWN 0x00 +#define TOUCH_EVENT_UP 0x01 +#define TOUCH_EVENT_CONTACT 0x02 +#define TOUCH_EVENT_RESERVED 0x03 + +struct hycon_hy46xx_data { + struct i2c_client *client; + struct input_dev *input; + struct touchscreen_properties prop; + struct regulator *vcc; + + struct gpio_desc *reset_gpio; + + struct mutex mutex; + struct regmap *regmap; + + int threshold; + bool glove_enable; + int report_speed; + bool power_noise_enable; + int filter_data; + int gain; + int edge_offset; + int rx_number_used; + int tx_number_used; + int power_mode; + int fw_version; + int lib_version; + int tp_information; + int tp_chip_id; + int bootloader_version; +}; + +static const struct regmap_config hycon_hy46xx_i2c_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; + +static bool hycon_hy46xx_check_checksum(struct hycon_hy46xx_data *tsdata, u8 *buf) +{ + u8 chksum = 0; + int i; + + for (i = 2; i < buf[HY46XX_CHKSUM_LEN]; i++) + chksum += buf[i]; + + if (chksum == buf[HY46XX_CHKSUM_CODE]) + return true; + + dev_err_ratelimited(&tsdata->client->dev, + "checksum error: 0x%02x expected, got 0x%02x\n", + chksum, buf[HY46XX_CHKSUM_CODE]); + + return false; +} + +static irqreturn_t hycon_hy46xx_isr(int irq, void *dev_id) +{ + struct hycon_hy46xx_data *tsdata = dev_id; + struct device *dev = &tsdata->client->dev; + u8 rdbuf[HY46XX_REPORT_PKT_LEN]; + int i, x, y, id; + int error; + + memset(rdbuf, 0, sizeof(rdbuf)); + + error = regmap_bulk_read(tsdata->regmap, 0, rdbuf, sizeof(rdbuf)); + if (error) { + dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n", + error); + goto out; + } + + if (!hycon_hy46xx_check_checksum(tsdata, rdbuf)) + goto out; + + for (i = 0; i < HY46XX_MAX_SUPPORTED_POINTS; i++) { + u8 *buf = &rdbuf[3 + (HY46XX_TPLEN * i)]; + int type = buf[0] >> 6; + + if (type == TOUCH_EVENT_RESERVED) + continue; + + x = get_unaligned_be16(buf) & 0x0fff; + y = get_unaligned_be16(buf + 2) & 0x0fff; + + id = buf[2] >> 4; + + input_mt_slot(tsdata->input, id); + if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, + type != TOUCH_EVENT_UP)) + touchscreen_report_pos(tsdata->input, &tsdata->prop, + x, y, true); + } + + input_mt_report_pointer_emulation(tsdata->input, true); + input_sync(tsdata->input); + +out: + return IRQ_HANDLED; +} + +struct hycon_hy46xx_attribute { + struct device_attribute dattr; + size_t field_offset; + u8 address; + u8 limit_low; + u8 limit_high; +}; + +#define HYCON_ATTR_U8(_field, _mode, _address, _limit_low, _limit_high) \ + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ + .dattr = __ATTR(_field, _mode, \ + hycon_hy46xx_setting_show, \ + hycon_hy46xx_setting_store), \ + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ + .address = _address, \ + .limit_low = _limit_low, \ + .limit_high = _limit_high, \ + } + +#define HYCON_ATTR_BOOL(_field, _mode, _address) \ + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ + .dattr = __ATTR(_field, _mode, \ + hycon_hy46xx_setting_show, \ + hycon_hy46xx_setting_store), \ + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ + .address = _address, \ + .limit_low = false, \ + .limit_high = true, \ + } + +static ssize_t hycon_hy46xx_setting_show(struct device *dev, + struct device_attribute *dattr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); + struct hycon_hy46xx_attribute *attr = + container_of(dattr, struct hycon_hy46xx_attribute, dattr); + u8 *field = (u8 *)tsdata + attr->field_offset; + size_t count = 0; + int error = 0; + int val; + + mutex_lock(&tsdata->mutex); + + error = regmap_read(tsdata->regmap, attr->address, &val); + if (error < 0) { + dev_err(&tsdata->client->dev, + "Failed to fetch attribute %s, error %d\n", + dattr->attr.name, error); + goto out; + } + + if (val != *field) { + dev_warn(&tsdata->client->dev, + "%s: read (%d) and stored value (%d) differ\n", + dattr->attr.name, val, *field); + *field = val; + } + + count = scnprintf(buf, PAGE_SIZE, "%d\n", val); + +out: + mutex_unlock(&tsdata->mutex); + return error ?: count; +} + +static ssize_t hycon_hy46xx_setting_store(struct device *dev, + struct device_attribute *dattr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); + struct hycon_hy46xx_attribute *attr = + container_of(dattr, struct hycon_hy46xx_attribute, dattr); + u8 *field = (u8 *)tsdata + attr->field_offset; + unsigned int val; + int error; + + mutex_lock(&tsdata->mutex); + + error = kstrtouint(buf, 0, &val); + if (error) + goto out; + + if (val < attr->limit_low || val > attr->limit_high) { + error = -ERANGE; + goto out; + } + + error = regmap_write(tsdata->regmap, attr->address, val); + if (error < 0) { + dev_err(&tsdata->client->dev, + "Failed to update attribute %s, error: %d\n", + dattr->attr.name, error); + goto out; + } + *field = val; + +out: + mutex_unlock(&tsdata->mutex); + return error ?: count; +} + +static HYCON_ATTR_U8(threshold, 0644, HY46XX_THRESHOLD, 0, 255); +static HYCON_ATTR_BOOL(glove_enable, 0644, HY46XX_GLOVE_EN); +static HYCON_ATTR_U8(report_speed, 0644, HY46XX_REPORT_SPEED, 0, 255); +static HYCON_ATTR_BOOL(power_noise_enable, 0644, HY46XX_PWR_NOISE_EN); +static HYCON_ATTR_U8(filter_data, 0644, HY46XX_FILTER_DATA, 0, 5); +static HYCON_ATTR_U8(gain, 0644, HY46XX_GAIN, 0, 5); +static HYCON_ATTR_U8(edge_offset, 0644, HY46XX_EDGE_OFFSET, 0, 5); +static HYCON_ATTR_U8(fw_version, 0444, HY46XX_FW_VERSION, 0, 255); +static HYCON_ATTR_U8(lib_version, 0444, HY46XX_LIB_VERSION, 0, 255); +static HYCON_ATTR_U8(tp_information, 0444, HY46XX_TP_INFO, 0, 255); +static HYCON_ATTR_U8(tp_chip_id, 0444, HY46XX_TP_CHIP_ID, 0, 255); +static HYCON_ATTR_U8(bootloader_version, 0444, HY46XX_BOOT_VER, 0, 255); + +static struct attribute *hycon_hy46xx_attrs[] = { + &hycon_hy46xx_attr_threshold.dattr.attr, + &hycon_hy46xx_attr_glove_enable.dattr.attr, + &hycon_hy46xx_attr_report_speed.dattr.attr, + &hycon_hy46xx_attr_power_noise_enable.dattr.attr, + &hycon_hy46xx_attr_filter_data.dattr.attr, + &hycon_hy46xx_attr_gain.dattr.attr, + &hycon_hy46xx_attr_edge_offset.dattr.attr, + &hycon_hy46xx_attr_fw_version.dattr.attr, + &hycon_hy46xx_attr_lib_version.dattr.attr, + &hycon_hy46xx_attr_tp_information.dattr.attr, + &hycon_hy46xx_attr_tp_chip_id.dattr.attr, + &hycon_hy46xx_attr_bootloader_version.dattr.attr, + NULL +}; + +static const struct attribute_group hycon_hy46xx_attr_group = { + .attrs = hycon_hy46xx_attrs, +}; + +static void hycon_hy46xx_get_defaults(struct device *dev, struct hycon_hy46xx_data *tsdata) +{ + bool val_bool; + int error; + u32 val; + + error = device_property_read_u32(dev, "hycon,threshold", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_THRESHOLD, val); + if (error < 0) + goto out; + + tsdata->threshold = val; + } + + val_bool = device_property_read_bool(dev, "hycon,glove-enable"); + error = regmap_write(tsdata->regmap, HY46XX_GLOVE_EN, val_bool); + if (error < 0) + goto out; + tsdata->glove_enable = val_bool; + + error = device_property_read_u32(dev, "hycon,report-speed", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_REPORT_SPEED, val); + if (error < 0) + goto out; + + tsdata->report_speed = val; + } + + val_bool = device_property_read_bool(dev, "hycon,power-noise-enable"); + error = regmap_write(tsdata->regmap, HY46XX_PWR_NOISE_EN, val_bool); + if (error < 0) + goto out; + tsdata->power_noise_enable = val_bool; + + error = device_property_read_u32(dev, "hycon,filter-data", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_FILTER_DATA, val); + if (error < 0) + goto out; + + tsdata->filter_data = val; + } + + error = device_property_read_u32(dev, "hycon,gain", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_GAIN, val); + if (error < 0) + goto out; + + tsdata->gain = val; + } + + error = device_property_read_u32(dev, "hycon,edge-offset", &val); + if (!error) { + error = regmap_write(tsdata->regmap, HY46XX_EDGE_OFFSET, val); + if (error < 0) + goto out; + + tsdata->edge_offset = val; + } + + return; +out: + dev_err(&tsdata->client->dev, "Failed to set default settings"); +} + +static void hycon_hy46xx_get_parameters(struct hycon_hy46xx_data *tsdata) +{ + int error; + u32 val; + + error = regmap_read(tsdata->regmap, HY46XX_THRESHOLD, &val); + if (error < 0) + goto out; + tsdata->threshold = val; + + error = regmap_read(tsdata->regmap, HY46XX_GLOVE_EN, &val); + if (error < 0) + goto out; + tsdata->glove_enable = val; + + error = regmap_read(tsdata->regmap, HY46XX_REPORT_SPEED, &val); + if (error < 0) + goto out; + tsdata->report_speed = val; + + error = regmap_read(tsdata->regmap, HY46XX_PWR_NOISE_EN, &val); + if (error < 0) + goto out; + tsdata->power_noise_enable = val; + + error = regmap_read(tsdata->regmap, HY46XX_FILTER_DATA, &val); + if (error < 0) + goto out; + tsdata->filter_data = val; + + error = regmap_read(tsdata->regmap, HY46XX_GAIN, &val); + if (error < 0) + goto out; + tsdata->gain = val; + + error = regmap_read(tsdata->regmap, HY46XX_EDGE_OFFSET, &val); + if (error < 0) + goto out; + tsdata->edge_offset = val; + + error = regmap_read(tsdata->regmap, HY46XX_RX_NR_USED, &val); + if (error < 0) + goto out; + tsdata->rx_number_used = val; + + error = regmap_read(tsdata->regmap, HY46XX_TX_NR_USED, &val); + if (error < 0) + goto out; + tsdata->tx_number_used = val; + + error = regmap_read(tsdata->regmap, HY46XX_PWR_MODE, &val); + if (error < 0) + goto out; + tsdata->power_mode = val; + + error = regmap_read(tsdata->regmap, HY46XX_FW_VERSION, &val); + if (error < 0) + goto out; + tsdata->fw_version = val; + + error = regmap_read(tsdata->regmap, HY46XX_LIB_VERSION, &val); + if (error < 0) + goto out; + tsdata->lib_version = val; + + error = regmap_read(tsdata->regmap, HY46XX_TP_INFO, &val); + if (error < 0) + goto out; + tsdata->tp_information = val; + + error = regmap_read(tsdata->regmap, HY46XX_TP_CHIP_ID, &val); + if (error < 0) + goto out; + tsdata->tp_chip_id = val; + + error = regmap_read(tsdata->regmap, HY46XX_BOOT_VER, &val); + if (error < 0) + goto out; + tsdata->bootloader_version = val; + + return; +out: + dev_err(&tsdata->client->dev, "Failed to read default settings"); +} + +static void hycon_hy46xx_disable_regulator(void *arg) +{ + struct hycon_hy46xx_data *data = arg; + + regulator_disable(data->vcc); +} + +static int hycon_hy46xx_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct hycon_hy46xx_data *tsdata; + struct input_dev *input; + int error; + + dev_dbg(&client->dev, "probing for HYCON HY46XX I2C\n"); + + tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL); + if (!tsdata) + return -ENOMEM; + + tsdata->vcc = devm_regulator_get(&client->dev, "vcc"); + if (IS_ERR(tsdata->vcc)) { + error = PTR_ERR(tsdata->vcc); + if (error != -EPROBE_DEFER) + dev_err(&client->dev, + "failed to request regulator: %d\n", error); + return error; + } + + error = regulator_enable(tsdata->vcc); + if (error < 0) { + dev_err(&client->dev, "failed to enable vcc: %d\n", error); + return error; + } + + error = devm_add_action_or_reset(&client->dev, + hycon_hy46xx_disable_regulator, + tsdata); + if (error) + return error; + + tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, + "reset", GPIOD_OUT_LOW); + if (IS_ERR(tsdata->reset_gpio)) { + error = PTR_ERR(tsdata->reset_gpio); + dev_err(&client->dev, + "Failed to request GPIO reset pin, error %d\n", error); + return error; + } + + if (tsdata->reset_gpio) { + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->reset_gpio, 1); + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->reset_gpio, 0); + msleep(1000); + } + + input = devm_input_allocate_device(&client->dev); + if (!input) { + dev_err(&client->dev, "failed to allocate input device.\n"); + return -ENOMEM; + } + + mutex_init(&tsdata->mutex); + tsdata->client = client; + tsdata->input = input; + + tsdata->regmap = devm_regmap_init_i2c(client, + &hycon_hy46xx_i2c_regmap_config); + if (IS_ERR(tsdata->regmap)) { + dev_err(&client->dev, "regmap allocation failed\n"); + return PTR_ERR(tsdata->regmap); + } + + hycon_hy46xx_get_defaults(&client->dev, tsdata); + hycon_hy46xx_get_parameters(tsdata); + + input->name = "Hycon Capacitive Touch"; + input->id.bustype = BUS_I2C; + input->dev.parent = &client->dev; + + input_set_abs_params(input, ABS_MT_POSITION_X, 0, -1, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, -1, 0, 0); + + touchscreen_parse_properties(input, true, &tsdata->prop); + + error = input_mt_init_slots(input, HY46XX_MAX_SUPPORTED_POINTS, + INPUT_MT_DIRECT); + if (error) { + dev_err(&client->dev, "Unable to init MT slots.\n"); + return error; + } + + i2c_set_clientdata(client, tsdata); + + error = devm_request_threaded_irq(&client->dev, client->irq, + NULL, hycon_hy46xx_isr, IRQF_ONESHOT, + client->name, tsdata); + if (error) { + dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); + return error; + } + + error = devm_device_add_group(&client->dev, &hycon_hy46xx_attr_group); + if (error) + return error; + + error = input_register_device(input); + if (error) + return error; + + dev_dbg(&client->dev, + "HYCON HY46XX initialized: IRQ %d, Reset pin %d.\n", + client->irq, + tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); + + return 0; +} + +static const struct i2c_device_id hycon_hy46xx_id[] = { + { .name = "hycon-hy4613" }, + { .name = "hycon-hy4614" }, + { .name = "hycon-hy4621" }, + { .name = "hycon-hy4623" }, + { .name = "hycon-hy4633" }, + { .name = "hycon-hy4635" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(i2c, hycon_hy46xx_id); + +static const struct of_device_id hycon_hy46xx_of_match[] = { + { .compatible = "hycon,hycon-hy4613" }, + { .compatible = "hycon,hycon-hy4614" }, + { .compatible = "hycon,hycon-hy4621" }, + { .compatible = "hycon,hycon-hy4623" }, + { .compatible = "hycon,hycon-hy4633" }, + { .compatible = "hycon,hycon-hy4635" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, hycon_hy46xx_of_match); + +static struct i2c_driver hycon_hy46xx_driver = { + .driver = { + .name = "hycon_hy46xx", + .of_match_table = hycon_hy46xx_of_match, + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, + .id_table = hycon_hy46xx_id, + .probe = hycon_hy46xx_probe, +}; + +module_i2c_driver(hycon_hy46xx_driver); + +MODULE_AUTHOR("Giulio Benetti <giulio.benetti@benettiengineering.com>"); +MODULE_DESCRIPTION("HYCON HY46XX I2C Touchscreen Driver"); +MODULE_LICENSE("GPL v2"); -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* [PATCH 3/3] Input: add driver for the Hycon HY46XX touchpanel series [not found] <20210305163834.70924-1-giulio.benetti@benettiengineering.com> 2021-03-05 16:38 ` [PATCH 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti 2021-03-05 16:38 ` [PATCH 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti @ 2021-03-05 16:38 ` Giulio Benetti 2021-03-05 19:00 ` Dmitry Torokhov 2 siblings, 1 reply; 69+ messages in thread From: Giulio Benetti @ 2021-03-05 16:38 UTC (permalink / raw) To: Dmitry Torokhov, Henrik Rydberg; +Cc: Giulio Benetti, linux-kernel, linux-input From: Giulio Benetti <giulio.benetti@micronovasrl.com> This patch adds support for Hycon HY46XX. Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com> --- MAINTAINERS | 1 + drivers/input/touchscreen/Kconfig | 12 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/hycon-hy46xx.c | 571 +++++++++++++++++++++++ 4 files changed, 585 insertions(+) create mode 100644 drivers/input/touchscreen/hycon-hy46xx.c diff --git a/MAINTAINERS b/MAINTAINERS index 3f83daf6b2bf..7a1331657e4b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8250,6 +8250,7 @@ M: Giulio Benetti <giulio.benetti@micronovasrl.com> L: linux-input@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml +F: drivers/input/touchscreen/hy46xx.c HYGON PROCESSOR SUPPORT M: Pu Wen <puwen@hygon.cn> diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 529614d364fe..5d4751d901cb 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1335,4 +1335,16 @@ config TOUCHSCREEN_ZINITIX To compile this driver as a module, choose M here: the module will be called zinitix. +config TOUCHSCREEN_HYCON_HY46XX + tristate "Hycon hy46xx touchscreen support" + depends on I2C + help + Say Y here if you have a touchscreen using Hycon hy46xx, + or something similar enough. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called hycon-hy46xx. + endif diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 6233541e9173..8b68cf3a3e6d 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -112,3 +112,4 @@ obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o obj-$(CONFIG_TOUCHSCREEN_ZINITIX) += zinitix.o +obj-$(CONFIG_TOUCHSCREEN_HYCON_HY46XX) += hycon-hy46xx.o diff --git a/drivers/input/touchscreen/hycon-hy46xx.c b/drivers/input/touchscreen/hycon-hy46xx.c new file mode 100644 index 000000000000..ef0dee9a43a9 --- /dev/null +++ b/drivers/input/touchscreen/hycon-hy46xx.c @@ -0,0 +1,571 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 + * Author(s): Giulio Benetti <giulio.benetti@micronovasrl.com> + */ + +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/input.h> +#include <linux/input/mt.h> +#include <linux/input/touchscreen.h> +#include <linux/irq.h> +#include <linux/regulator/consumer.h> + +#include <asm/unaligned.h> + +#define HY46XX_CHKSUM_CODE 0x1 +#define HY46XX_FINGER_NUM 0x2 +#define HY46XX_CHKSUM_LEN 0x7 +#define HY46XX_THRESHOLD 0x80 +#define HY46XX_PROX_SENS_SW 0x81 +#define HY46XX_GLOVE_EN 0x84 +#define HY46XX_REPORT_SPEED 0x88 +#define HY46XX_PWR_NOISE_EN 0x89 +#define HY46XX_FILTER_DATA 0x8A +#define HY46XX_GAIN 0x92 +#define HY46XX_EDGE_OFFSET 0x93 +#define HY46XX_RX_NR_USED 0x94 +#define HY46XX_TX_NR_USED 0x95 +#define HY46XX_PWR_MODE 0xA5 +#define HY46XX_FW_VERSION 0xA6 +#define HY46XX_LIB_VERSION 0xA7 +#define HY46XX_TP_INFO 0xA8 +#define HY46XX_TP_CHIP_ID 0xA9 +#define HY46XX_BOOT_VER 0xB0 + +#define HY46XX_TPLEN 0x6 + +#define HY46XX_MAX_SUPPORTED_POINTS 11 + +#define TOUCH_EVENT_DOWN 0x00 +#define TOUCH_EVENT_UP 0x01 +#define TOUCH_EVENT_CONTACT 0x02 +#define TOUCH_EVENT_RESERVED 0x03 + +struct hycon_hy46xx_data { + struct i2c_client *client; + struct input_dev *input; + struct touchscreen_properties prop; + struct regulator *vcc; + + struct gpio_desc *reset_gpio; + + struct mutex mutex; + + int threshold; + int proximity_sensor_switch; + int glove_enable; + int report_speed; + int power_noise_enable; + int filter_data; + int gain; + int edge_offset; + int rx_number_used; + int tx_number_used; + int power_mode; + int fw_version; + int lib_version; + int tp_information; + int tp_chip_id; + int bootloader_version; +}; + +static int hycon_hy46xx_readwrite(struct i2c_client *client, u16 wr_len, u8 *wr_buf, + u16 rd_len, u8 *rd_buf) +{ + struct i2c_msg msgs[2]; + int i = 0; + int ret; + + if (wr_len) { + msgs[i].addr = client->addr; + msgs[i].flags = 0; + msgs[i].len = wr_len; + msgs[i].buf = wr_buf; + i++; + } + if (rd_len) { + msgs[i].addr = client->addr; + msgs[i].flags = I2C_M_RD; + msgs[i].len = rd_len; + msgs[i].buf = rd_buf; + i++; + } + + ret = i2c_transfer(client->adapter, msgs, i); + if (ret < 0) + return ret; + if (ret != i) + return -EIO; + + return 0; +} + +static bool hycon_hy46xx_check_checksum(struct hycon_hy46xx_data *tsdata, u8 *buf) +{ + u8 chksum = 0; + int i; + + for (i = 2; i < buf[HY46XX_CHKSUM_LEN]; i++) + chksum += buf[i]; + + if (chksum == buf[HY46XX_CHKSUM_CODE]) + return true; + + dev_err_ratelimited(&tsdata->client->dev, + "checksum error: 0x%02x expected, got 0x%02x\n", + chksum, buf[HY46XX_CHKSUM_CODE]); + + return false; +} + +static irqreturn_t hycon_hy46xx_isr(int irq, void *dev_id) +{ + struct hycon_hy46xx_data *tsdata = dev_id; + struct device *dev = &tsdata->client->dev; + u8 rdbuf[0x44]; + u8 cmd; + int i, x, y, id; + int error; + + memset(rdbuf, 0, sizeof(rdbuf)); + + error = hycon_hy46xx_readwrite(tsdata->client, 1, &cmd, sizeof(rdbuf), rdbuf); + if (error) { + dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n", + error); + goto out; + } + + if (!hycon_hy46xx_check_checksum(tsdata, rdbuf)) + goto out; + + for (i = 0; i < HY46XX_MAX_SUPPORTED_POINTS; i++) { + u8 *buf = &rdbuf[3 + (HY46XX_TPLEN * i)]; + int type = buf[0] >> 6; + + if (type == TOUCH_EVENT_RESERVED) + continue; + + x = get_unaligned_be16(buf) & 0x0fff; + y = get_unaligned_be16(buf + 2) & 0x0fff; + + id = (buf[2] >> 4) & 0x0f; + + input_mt_slot(tsdata->input, id); + if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, + type != TOUCH_EVENT_UP)) + touchscreen_report_pos(tsdata->input, &tsdata->prop, + x, y, true); + } + + input_mt_report_pointer_emulation(tsdata->input, true); + input_sync(tsdata->input); + +out: + return IRQ_HANDLED; +} + +static int hycon_hy46xx_register_write(struct hycon_hy46xx_data *tsdata, u8 addr, u8 value) +{ + u8 wrbuf[2]; + + wrbuf[0] = addr; + wrbuf[1] = value; + + return hycon_hy46xx_readwrite(tsdata->client, 2, wrbuf, 0, NULL); +} + +static int hycon_hy46xx_register_read(struct hycon_hy46xx_data *tsdata, u8 addr) +{ + u8 wrbyte, rdbyte; + int error; + + wrbyte = addr; + error = hycon_hy46xx_readwrite(tsdata->client, 1, &wrbyte, 1, &rdbyte); + if (error) + return error; + + return rdbyte; +} + +struct hycon_hy46xx_attribute { + struct device_attribute dattr; + size_t field_offset; + u8 address; + u8 limit_low; + u8 limit_high; +}; + +#define HYCON_ATTR(_field, _mode, _address, _limit_low, _limit_high) \ + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ + .dattr = __ATTR(_field, _mode, \ + hycon_hy46xx_setting_show, \ + hycon_hy46xx_setting_store), \ + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ + .address = _address, \ + .limit_low = _limit_low, \ + .limit_high = _limit_high, \ + } + +static ssize_t hycon_hy46xx_setting_show(struct device *dev, + struct device_attribute *dattr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); + struct hycon_hy46xx_attribute *attr = + container_of(dattr, struct hycon_hy46xx_attribute, dattr); + u8 *field = (u8 *)tsdata + attr->field_offset; + int val; + size_t count = 0; + int error = 0; + u8 addr = attr->address; + + mutex_lock(&tsdata->mutex); + + val = hycon_hy46xx_register_read(tsdata, addr); + if (val < 0) { + error = val; + dev_err(&tsdata->client->dev, + "Failed to fetch attribute %s, error %d\n", + dattr->attr.name, error); + goto out; + } + + if (val != *field) { + dev_warn(&tsdata->client->dev, + "%s: read (%d) and stored value (%d) differ\n", + dattr->attr.name, val, *field); + *field = val; + } + + count = scnprintf(buf, PAGE_SIZE, "%d\n", val); +out: + mutex_unlock(&tsdata->mutex); + return error ?: count; +} + +static ssize_t hycon_hy46xx_setting_store(struct device *dev, + struct device_attribute *dattr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); + struct hycon_hy46xx_attribute *attr = + container_of(dattr, struct hycon_hy46xx_attribute, dattr); + u8 *field = (u8 *)tsdata + attr->field_offset; + unsigned int val; + int error; + u8 addr = attr->address; + + mutex_lock(&tsdata->mutex); + + error = kstrtouint(buf, 0, &val); + if (error) + goto out; + + if (val < attr->limit_low || val > attr->limit_high) { + error = -ERANGE; + goto out; + } + + error = hycon_hy46xx_register_write(tsdata, addr, val); + if (error) { + dev_err(&tsdata->client->dev, + "Failed to update attribute %s, error: %d\n", + dattr->attr.name, error); + goto out; + } + *field = val; + +out: + mutex_unlock(&tsdata->mutex); + return error ?: count; +} + +static HYCON_ATTR(threshold, 0644, HY46XX_THRESHOLD, 0, 255); +static HYCON_ATTR(proximity_sensor_switch, 0644, HY46XX_PROX_SENS_SW, 0, 1); +static HYCON_ATTR(glove_enable, 0644, HY46XX_GLOVE_EN, 0, 1); +static HYCON_ATTR(report_speed, 0644, HY46XX_REPORT_SPEED, 0, 255); +static HYCON_ATTR(power_noise_enable, 0644, HY46XX_PWR_NOISE_EN, 0, 1); +static HYCON_ATTR(filter_data, 0644, HY46XX_FILTER_DATA, 0, 5); +static HYCON_ATTR(gain, 0644, HY46XX_GAIN, 0, 5); +static HYCON_ATTR(edge_offset, 0644, HY46XX_EDGE_OFFSET, 0, 5); +static HYCON_ATTR(fw_version, 0444, HY46XX_FW_VERSION, 0, 255); +static HYCON_ATTR(lib_version, 0444, HY46XX_LIB_VERSION, 0, 255); +static HYCON_ATTR(tp_information, 0444, HY46XX_TP_INFO, 0, 255); +static HYCON_ATTR(tp_chip_id, 0444, HY46XX_TP_CHIP_ID, 0, 255); +static HYCON_ATTR(bootloader_version, 0444, HY46XX_BOOT_VER, 0, 255); + +static struct attribute *hycon_hy46xx_attrs[] = { + &hycon_hy46xx_attr_threshold.dattr.attr, + &hycon_hy46xx_attr_proximity_sensor_switch.dattr.attr, + &hycon_hy46xx_attr_glove_enable.dattr.attr, + &hycon_hy46xx_attr_report_speed.dattr.attr, + &hycon_hy46xx_attr_power_noise_enable.dattr.attr, + &hycon_hy46xx_attr_filter_data.dattr.attr, + &hycon_hy46xx_attr_gain.dattr.attr, + &hycon_hy46xx_attr_edge_offset.dattr.attr, + &hycon_hy46xx_attr_fw_version.dattr.attr, + &hycon_hy46xx_attr_lib_version.dattr.attr, + &hycon_hy46xx_attr_tp_information.dattr.attr, + &hycon_hy46xx_attr_tp_chip_id.dattr.attr, + &hycon_hy46xx_attr_bootloader_version.dattr.attr, + NULL +}; + +static const struct attribute_group hycon_hy46xx_attr_group = { + .attrs = hycon_hy46xx_attrs, +}; + +static void hycon_hy46xx_get_defaults(struct device *dev, struct hycon_hy46xx_data *tsdata) +{ + u32 val; + int error; + + error = device_property_read_u32(dev, "threshold", &val); + if (!error) { + hycon_hy46xx_register_write(tsdata, HY46XX_THRESHOLD, val); + tsdata->threshold = val; + } + + error = device_property_read_u32(dev, "proximity-sensor-switch", &val); + if (!error) { + hycon_hy46xx_register_write(tsdata, HY46XX_PROX_SENS_SW, val); + tsdata->proximity_sensor_switch = val; + } + + error = device_property_read_u32(dev, "glove-enable", &val); + if (!error) { + hycon_hy46xx_register_write(tsdata, HY46XX_GLOVE_EN, val); + tsdata->glove_enable = val; + } + + error = device_property_read_u32(dev, "report-speed", &val); + if (!error) { + hycon_hy46xx_register_write(tsdata, HY46XX_REPORT_SPEED, val); + tsdata->report_speed = val; + } + + error = device_property_read_u32(dev, "power-noise-enable", &val); + if (!error) { + hycon_hy46xx_register_write(tsdata, HY46XX_PWR_NOISE_EN, val); + tsdata->report_speed = val; + } + + error = device_property_read_u32(dev, "filter-data", &val); + if (!error) { + hycon_hy46xx_register_write(tsdata, HY46XX_FILTER_DATA, val); + tsdata->report_speed = val; + } + + error = device_property_read_u32(dev, "gain", &val); + if (!error) { + hycon_hy46xx_register_write(tsdata, HY46XX_GAIN, val); + tsdata->report_speed = val; + } + + error = device_property_read_u32(dev, "edge-offset", &val); + if (!error) { + hycon_hy46xx_register_write(tsdata, HY46XX_EDGE_OFFSET, val); + tsdata->report_speed = val; + } +} + +static void hycon_hy46xx_get_parameters(struct hycon_hy46xx_data *tsdata) +{ + tsdata->threshold = hycon_hy46xx_register_read(tsdata, HY46XX_THRESHOLD); + tsdata->proximity_sensor_switch = + hycon_hy46xx_register_read(tsdata, HY46XX_PROX_SENS_SW); + tsdata->glove_enable = hycon_hy46xx_register_read(tsdata, HY46XX_GLOVE_EN); + tsdata->report_speed = + hycon_hy46xx_register_read(tsdata, HY46XX_REPORT_SPEED); + tsdata->power_noise_enable = + hycon_hy46xx_register_read(tsdata, HY46XX_PWR_NOISE_EN); + tsdata->filter_data = hycon_hy46xx_register_read(tsdata, HY46XX_FILTER_DATA); + tsdata->gain = hycon_hy46xx_register_read(tsdata, HY46XX_GAIN); + tsdata->edge_offset = hycon_hy46xx_register_read(tsdata, HY46XX_EDGE_OFFSET); + tsdata->rx_number_used = + hycon_hy46xx_register_read(tsdata, HY46XX_RX_NR_USED); + tsdata->tx_number_used = + hycon_hy46xx_register_read(tsdata, HY46XX_TX_NR_USED); + tsdata->power_mode = hycon_hy46xx_register_read(tsdata, HY46XX_PWR_MODE); + tsdata->fw_version = hycon_hy46xx_register_read(tsdata, HY46XX_FW_VERSION); + tsdata->lib_version = hycon_hy46xx_register_read(tsdata, HY46XX_LIB_VERSION); + tsdata->tp_information = hycon_hy46xx_register_read(tsdata, HY46XX_TP_INFO); + tsdata->tp_chip_id = hycon_hy46xx_register_read(tsdata, HY46XX_TP_CHIP_ID); + tsdata->bootloader_version = + hycon_hy46xx_register_read(tsdata, HY46XX_BOOT_VER); +} + +static void hycon_hy46xx_disable_regulator(void *arg) +{ + struct hycon_hy46xx_data *data = arg; + + regulator_disable(data->vcc); +} + +static int hycon_hy46xx_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + const struct hycon_hy46xx_i2c_chip_data *chip_data; + struct hycon_hy46xx_data *tsdata; + struct input_dev *input; + unsigned long irq_flags; + int error; + + dev_dbg(&client->dev, "probing for HYCON HY46XX I2C\n"); + + tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL); + if (!tsdata) + return -ENOMEM; + + chip_data = device_get_match_data(&client->dev); + if (!chip_data) + chip_data = (const struct hycon_hy46xx_i2c_chip_data *) + id->driver_data; + if (!chip_data) { + dev_err(&client->dev, "invalid or missing chip data\n"); + return -EINVAL; + } + + tsdata->vcc = devm_regulator_get(&client->dev, "vcc"); + if (IS_ERR(tsdata->vcc)) { + error = PTR_ERR(tsdata->vcc); + if (error != -EPROBE_DEFER) + dev_err(&client->dev, + "failed to request regulator: %d\n", error); + return error; + } + + error = regulator_enable(tsdata->vcc); + if (error < 0) { + dev_err(&client->dev, "failed to enable vcc: %d\n", error); + return error; + } + + error = devm_add_action_or_reset(&client->dev, + hycon_hy46xx_disable_regulator, + tsdata); + if (error) + return error; + + tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, + "reset", GPIOD_OUT_LOW); + if (IS_ERR(tsdata->reset_gpio)) { + error = PTR_ERR(tsdata->reset_gpio); + dev_err(&client->dev, + "Failed to request GPIO reset pin, error %d\n", error); + return error; + } + + if (tsdata->reset_gpio) { + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->reset_gpio, 1); + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->reset_gpio, 0); + msleep(1000); + } + + input = devm_input_allocate_device(&client->dev); + if (!input) { + dev_err(&client->dev, "failed to allocate input device.\n"); + return -ENOMEM; + } + + mutex_init(&tsdata->mutex); + tsdata->client = client; + tsdata->input = input; + + hycon_hy46xx_get_defaults(&client->dev, tsdata); + hycon_hy46xx_get_parameters(tsdata); + + input->name = "Hycon Capacitive Touch"; + input->id.bustype = BUS_I2C; + input->dev.parent = &client->dev; + + input_set_abs_params(input, ABS_MT_POSITION_X, + 0, -1, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, + 0, -1, 0, 0); + + touchscreen_parse_properties(input, true, &tsdata->prop); + + error = input_mt_init_slots(input, HY46XX_MAX_SUPPORTED_POINTS, + INPUT_MT_DIRECT); + if (error) { + dev_err(&client->dev, "Unable to init MT slots.\n"); + return error; + } + + i2c_set_clientdata(client, tsdata); + + irq_flags = irq_get_trigger_type(client->irq); + if (irq_flags == IRQF_TRIGGER_NONE) + irq_flags = IRQF_TRIGGER_FALLING; + irq_flags |= IRQF_ONESHOT; + + error = devm_request_threaded_irq(&client->dev, client->irq, + NULL, hycon_hy46xx_isr, irq_flags, + client->name, tsdata); + if (error) { + dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); + return error; + } + + error = devm_device_add_group(&client->dev, &hycon_hy46xx_attr_group); + if (error) + return error; + + error = input_register_device(input); + if (error) + return error; + + dev_dbg(&client->dev, + "HYCON HY46XX initialized: IRQ %d, Reset pin %d.\n", + client->irq, + tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); + + return 0; +} + +static const struct i2c_device_id hycon_hy46xx_id[] = { + { .name = "hycon-hy4613" }, + { .name = "hycon-hy4614" }, + { .name = "hycon-hy4621" }, + { .name = "hycon-hy4623" }, + { .name = "hycon-hy4633" }, + { .name = "hycon-hy4635" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(i2c, hycon_hy46xx_id); + +static const struct of_device_id hycon_hy46xx_of_match[] = { + { .compatible = "hycon,hycon-hy4613" }, + { .compatible = "hycon,hycon-hy4614" }, + { .compatible = "hycon,hycon-hy4621" }, + { .compatible = "hycon,hycon-hy4623" }, + { .compatible = "hycon,hycon-hy4633" }, + { .compatible = "hycon,hycon-hy4635" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, hycon_hy46xx_of_match); + +static struct i2c_driver hycon_hy46xx_driver = { + .driver = { + .name = "hycon_hy46xx", + .of_match_table = hycon_hy46xx_of_match, + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, + .id_table = hycon_hy46xx_id, + .probe = hycon_hy46xx_probe, +}; + +module_i2c_driver(hycon_hy46xx_driver); + +MODULE_AUTHOR("Giulio Benetti <giulio.benetti@micronovasrl.com>"); +MODULE_DESCRIPTION("HYCON HY46XX I2C Touchscreen Driver"); +MODULE_LICENSE("GPL v2"); -- 2.25.1 ^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 3/3] Input: add driver for the Hycon HY46XX touchpanel series 2021-03-05 16:38 ` [PATCH " Giulio Benetti @ 2021-03-05 19:00 ` Dmitry Torokhov 2021-03-05 19:31 ` Giulio Benetti 2021-03-05 19:54 ` Giulio Benetti 0 siblings, 2 replies; 69+ messages in thread From: Dmitry Torokhov @ 2021-03-05 19:00 UTC (permalink / raw) To: Giulio Benetti; +Cc: Henrik Rydberg, Giulio Benetti, linux-kernel, linux-input Hi Giulio, On Fri, Mar 05, 2021 at 05:38:34PM +0100, Giulio Benetti wrote: > From: Giulio Benetti <giulio.benetti@micronovasrl.com> > > This patch adds support for Hycon HY46XX. Could you please tell me where patches 1/3 and 2/3. I am guessing they are dealing with DT bindings and are most likely to go through my tree after Rob's ACK. > > Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com> > --- > MAINTAINERS | 1 + > drivers/input/touchscreen/Kconfig | 12 + > drivers/input/touchscreen/Makefile | 1 + > drivers/input/touchscreen/hycon-hy46xx.c | 571 +++++++++++++++++++++++ > 4 files changed, 585 insertions(+) > create mode 100644 drivers/input/touchscreen/hycon-hy46xx.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index 3f83daf6b2bf..7a1331657e4b 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -8250,6 +8250,7 @@ M: Giulio Benetti <giulio.benetti@micronovasrl.com> > L: linux-input@vger.kernel.org > S: Maintained > F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml > +F: drivers/input/touchscreen/hy46xx.c > > HYGON PROCESSOR SUPPORT > M: Pu Wen <puwen@hygon.cn> > diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig > index 529614d364fe..5d4751d901cb 100644 > --- a/drivers/input/touchscreen/Kconfig > +++ b/drivers/input/touchscreen/Kconfig > @@ -1335,4 +1335,16 @@ config TOUCHSCREEN_ZINITIX > To compile this driver as a module, choose M here: the > module will be called zinitix. > > +config TOUCHSCREEN_HYCON_HY46XX > + tristate "Hycon hy46xx touchscreen support" > + depends on I2C > + help > + Say Y here if you have a touchscreen using Hycon hy46xx, > + or something similar enough. > + > + If unsure, say N. > + > + To compile this driver as a module, choose M here: the > + module will be called hycon-hy46xx. > + > endif > diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile > index 6233541e9173..8b68cf3a3e6d 100644 > --- a/drivers/input/touchscreen/Makefile > +++ b/drivers/input/touchscreen/Makefile > @@ -112,3 +112,4 @@ obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o > obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o > obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o > obj-$(CONFIG_TOUCHSCREEN_ZINITIX) += zinitix.o > +obj-$(CONFIG_TOUCHSCREEN_HYCON_HY46XX) += hycon-hy46xx.o > diff --git a/drivers/input/touchscreen/hycon-hy46xx.c b/drivers/input/touchscreen/hycon-hy46xx.c > new file mode 100644 > index 000000000000..ef0dee9a43a9 > --- /dev/null > +++ b/drivers/input/touchscreen/hycon-hy46xx.c > @@ -0,0 +1,571 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (C) 2021 > + * Author(s): Giulio Benetti <giulio.benetti@micronovasrl.com> > + */ > + > +#include <linux/delay.h> > +#include <linux/gpio/consumer.h> > +#include <linux/i2c.h> > +#include <linux/interrupt.h> > +#include <linux/input.h> > +#include <linux/input/mt.h> > +#include <linux/input/touchscreen.h> > +#include <linux/irq.h> > +#include <linux/regulator/consumer.h> > + > +#include <asm/unaligned.h> > + > +#define HY46XX_CHKSUM_CODE 0x1 > +#define HY46XX_FINGER_NUM 0x2 > +#define HY46XX_CHKSUM_LEN 0x7 > +#define HY46XX_THRESHOLD 0x80 > +#define HY46XX_PROX_SENS_SW 0x81 > +#define HY46XX_GLOVE_EN 0x84 > +#define HY46XX_REPORT_SPEED 0x88 > +#define HY46XX_PWR_NOISE_EN 0x89 > +#define HY46XX_FILTER_DATA 0x8A > +#define HY46XX_GAIN 0x92 > +#define HY46XX_EDGE_OFFSET 0x93 > +#define HY46XX_RX_NR_USED 0x94 > +#define HY46XX_TX_NR_USED 0x95 > +#define HY46XX_PWR_MODE 0xA5 > +#define HY46XX_FW_VERSION 0xA6 > +#define HY46XX_LIB_VERSION 0xA7 > +#define HY46XX_TP_INFO 0xA8 > +#define HY46XX_TP_CHIP_ID 0xA9 > +#define HY46XX_BOOT_VER 0xB0 > + > +#define HY46XX_TPLEN 0x6 > + > +#define HY46XX_MAX_SUPPORTED_POINTS 11 > + > +#define TOUCH_EVENT_DOWN 0x00 > +#define TOUCH_EVENT_UP 0x01 > +#define TOUCH_EVENT_CONTACT 0x02 > +#define TOUCH_EVENT_RESERVED 0x03 > + > +struct hycon_hy46xx_data { > + struct i2c_client *client; > + struct input_dev *input; > + struct touchscreen_properties prop; > + struct regulator *vcc; > + > + struct gpio_desc *reset_gpio; > + > + struct mutex mutex; > + > + int threshold; > + int proximity_sensor_switch; > + int glove_enable; > + int report_speed; > + int power_noise_enable; > + int filter_data; > + int gain; > + int edge_offset; > + int rx_number_used; > + int tx_number_used; > + int power_mode; > + int fw_version; > + int lib_version; > + int tp_information; > + int tp_chip_id; > + int bootloader_version; > +}; > + > +static int hycon_hy46xx_readwrite(struct i2c_client *client, u16 wr_len, u8 *wr_buf, > + u16 rd_len, u8 *rd_buf) > +{ > + struct i2c_msg msgs[2]; > + int i = 0; > + int ret; > + > + if (wr_len) { > + msgs[i].addr = client->addr; > + msgs[i].flags = 0; > + msgs[i].len = wr_len; > + msgs[i].buf = wr_buf; > + i++; > + } > + if (rd_len) { > + msgs[i].addr = client->addr; > + msgs[i].flags = I2C_M_RD; > + msgs[i].len = rd_len; > + msgs[i].buf = rd_buf; > + i++; > + } > + > + ret = i2c_transfer(client->adapter, msgs, i); > + if (ret < 0) > + return ret; > + if (ret != i) > + return -EIO; > + > + return 0; > +} Please see if your driver could be converted to regmap API instead of "maked" i2c. It will allow using write-gather when system supports it, etc. > + > +static bool hycon_hy46xx_check_checksum(struct hycon_hy46xx_data *tsdata, u8 *buf) > +{ > + u8 chksum = 0; > + int i; > + > + for (i = 2; i < buf[HY46XX_CHKSUM_LEN]; i++) > + chksum += buf[i]; > + > + if (chksum == buf[HY46XX_CHKSUM_CODE]) > + return true; > + > + dev_err_ratelimited(&tsdata->client->dev, > + "checksum error: 0x%02x expected, got 0x%02x\n", > + chksum, buf[HY46XX_CHKSUM_CODE]); > + > + return false; > +} > + > +static irqreturn_t hycon_hy46xx_isr(int irq, void *dev_id) > +{ > + struct hycon_hy46xx_data *tsdata = dev_id; > + struct device *dev = &tsdata->client->dev; > + u8 rdbuf[0x44]; A #define here would be nice. A #define here would be nice. > + u8 cmd; > + int i, x, y, id; > + int error; > + > + memset(rdbuf, 0, sizeof(rdbuf)); > + > + error = hycon_hy46xx_readwrite(tsdata->client, 1, &cmd, sizeof(rdbuf), rdbuf); cmd could be any garbage (as it is uninitialized)? This requires a nice comment as to why it is OK. > + if (error) { > + dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n", > + error); > + goto out; > + } > + > + if (!hycon_hy46xx_check_checksum(tsdata, rdbuf)) > + goto out; > + > + for (i = 0; i < HY46XX_MAX_SUPPORTED_POINTS; i++) { > + u8 *buf = &rdbuf[3 + (HY46XX_TPLEN * i)]; > + int type = buf[0] >> 6; > + > + if (type == TOUCH_EVENT_RESERVED) > + continue; > + > + x = get_unaligned_be16(buf) & 0x0fff; > + y = get_unaligned_be16(buf + 2) & 0x0fff; > + > + id = (buf[2] >> 4) & 0x0f; buf is u8 so no need to additionally mask after shifting. > + > + input_mt_slot(tsdata->input, id); > + if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, > + type != TOUCH_EVENT_UP)) > + touchscreen_report_pos(tsdata->input, &tsdata->prop, > + x, y, true); > + } > + > + input_mt_report_pointer_emulation(tsdata->input, true); > + input_sync(tsdata->input); > + > +out: > + return IRQ_HANDLED; > +} > + > +static int hycon_hy46xx_register_write(struct hycon_hy46xx_data *tsdata, u8 addr, u8 value) > +{ > + u8 wrbuf[2]; > + > + wrbuf[0] = addr; > + wrbuf[1] = value; > + > + return hycon_hy46xx_readwrite(tsdata->client, 2, wrbuf, 0, NULL); > +} > + > +static int hycon_hy46xx_register_read(struct hycon_hy46xx_data *tsdata, u8 addr) > +{ > + u8 wrbyte, rdbyte; > + int error; > + > + wrbyte = addr; > + error = hycon_hy46xx_readwrite(tsdata->client, 1, &wrbyte, 1, &rdbyte); > + if (error) > + return error; > + > + return rdbyte; > +} > + > +struct hycon_hy46xx_attribute { > + struct device_attribute dattr; > + size_t field_offset; > + u8 address; > + u8 limit_low; > + u8 limit_high; > +}; > + > +#define HYCON_ATTR(_field, _mode, _address, _limit_low, _limit_high) \ > + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ > + .dattr = __ATTR(_field, _mode, \ > + hycon_hy46xx_setting_show, \ > + hycon_hy46xx_setting_store), \ > + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ > + .address = _address, \ > + .limit_low = _limit_low, \ > + .limit_high = _limit_high, \ > + } > + > +static ssize_t hycon_hy46xx_setting_show(struct device *dev, > + struct device_attribute *dattr, char *buf) > +{ > + struct i2c_client *client = to_i2c_client(dev); > + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); > + struct hycon_hy46xx_attribute *attr = > + container_of(dattr, struct hycon_hy46xx_attribute, dattr); > + u8 *field = (u8 *)tsdata + attr->field_offset; > + int val; > + size_t count = 0; > + int error = 0; > + u8 addr = attr->address; > + > + mutex_lock(&tsdata->mutex); > + > + val = hycon_hy46xx_register_read(tsdata, addr); > + if (val < 0) { > + error = val; > + dev_err(&tsdata->client->dev, > + "Failed to fetch attribute %s, error %d\n", > + dattr->attr.name, error); > + goto out; > + } > + > + if (val != *field) { > + dev_warn(&tsdata->client->dev, > + "%s: read (%d) and stored value (%d) differ\n", > + dattr->attr.name, val, *field); > + *field = val; > + } > + > + count = scnprintf(buf, PAGE_SIZE, "%d\n", val); > +out: > + mutex_unlock(&tsdata->mutex); > + return error ?: count; > +} > + > +static ssize_t hycon_hy46xx_setting_store(struct device *dev, > + struct device_attribute *dattr, > + const char *buf, size_t count) > +{ > + struct i2c_client *client = to_i2c_client(dev); > + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); > + struct hycon_hy46xx_attribute *attr = > + container_of(dattr, struct hycon_hy46xx_attribute, dattr); > + u8 *field = (u8 *)tsdata + attr->field_offset; > + unsigned int val; > + int error; > + u8 addr = attr->address; > + > + mutex_lock(&tsdata->mutex); > + > + error = kstrtouint(buf, 0, &val); > + if (error) > + goto out; > + > + if (val < attr->limit_low || val > attr->limit_high) { > + error = -ERANGE; > + goto out; > + } > + > + error = hycon_hy46xx_register_write(tsdata, addr, val); > + if (error) { > + dev_err(&tsdata->client->dev, > + "Failed to update attribute %s, error: %d\n", > + dattr->attr.name, error); > + goto out; > + } > + *field = val; I am not sure why you want this check (I see that we have it in one other driver and I really do not recall why we have it there either). > + > +out: > + mutex_unlock(&tsdata->mutex); > + return error ?: count; > +} > + > +static HYCON_ATTR(threshold, 0644, HY46XX_THRESHOLD, 0, 255); > +static HYCON_ATTR(proximity_sensor_switch, 0644, HY46XX_PROX_SENS_SW, 0, 1); > +static HYCON_ATTR(glove_enable, 0644, HY46XX_GLOVE_EN, 0, 1); > +static HYCON_ATTR(report_speed, 0644, HY46XX_REPORT_SPEED, 0, 255); > +static HYCON_ATTR(power_noise_enable, 0644, HY46XX_PWR_NOISE_EN, 0, 1); > +static HYCON_ATTR(filter_data, 0644, HY46XX_FILTER_DATA, 0, 5); > +static HYCON_ATTR(gain, 0644, HY46XX_GAIN, 0, 5); > +static HYCON_ATTR(edge_offset, 0644, HY46XX_EDGE_OFFSET, 0, 5); > +static HYCON_ATTR(fw_version, 0444, HY46XX_FW_VERSION, 0, 255); > +static HYCON_ATTR(lib_version, 0444, HY46XX_LIB_VERSION, 0, 255); > +static HYCON_ATTR(tp_information, 0444, HY46XX_TP_INFO, 0, 255); > +static HYCON_ATTR(tp_chip_id, 0444, HY46XX_TP_CHIP_ID, 0, 255); > +static HYCON_ATTR(bootloader_version, 0444, HY46XX_BOOT_VER, 0, 255); > + > +static struct attribute *hycon_hy46xx_attrs[] = { > + &hycon_hy46xx_attr_threshold.dattr.attr, > + &hycon_hy46xx_attr_proximity_sensor_switch.dattr.attr, > + &hycon_hy46xx_attr_glove_enable.dattr.attr, > + &hycon_hy46xx_attr_report_speed.dattr.attr, > + &hycon_hy46xx_attr_power_noise_enable.dattr.attr, > + &hycon_hy46xx_attr_filter_data.dattr.attr, > + &hycon_hy46xx_attr_gain.dattr.attr, > + &hycon_hy46xx_attr_edge_offset.dattr.attr, > + &hycon_hy46xx_attr_fw_version.dattr.attr, > + &hycon_hy46xx_attr_lib_version.dattr.attr, > + &hycon_hy46xx_attr_tp_information.dattr.attr, > + &hycon_hy46xx_attr_tp_chip_id.dattr.attr, > + &hycon_hy46xx_attr_bootloader_version.dattr.attr, > + NULL > +}; > + > +static const struct attribute_group hycon_hy46xx_attr_group = { > + .attrs = hycon_hy46xx_attrs, > +}; > + > +static void hycon_hy46xx_get_defaults(struct device *dev, struct hycon_hy46xx_data *tsdata) > +{ > + u32 val; > + int error; > + > + error = device_property_read_u32(dev, "threshold", &val); > + if (!error) { > + hycon_hy46xx_register_write(tsdata, HY46XX_THRESHOLD, val); > + tsdata->threshold = val; > + } > + > + error = device_property_read_u32(dev, "proximity-sensor-switch", &val); > + if (!error) { > + hycon_hy46xx_register_write(tsdata, HY46XX_PROX_SENS_SW, val); > + tsdata->proximity_sensor_switch = val; > + } > + > + error = device_property_read_u32(dev, "glove-enable", &val); > + if (!error) { > + hycon_hy46xx_register_write(tsdata, HY46XX_GLOVE_EN, val); > + tsdata->glove_enable = val; > + } > + > + error = device_property_read_u32(dev, "report-speed", &val); > + if (!error) { > + hycon_hy46xx_register_write(tsdata, HY46XX_REPORT_SPEED, val); > + tsdata->report_speed = val; > + } > + > + error = device_property_read_u32(dev, "power-noise-enable", &val); > + if (!error) { > + hycon_hy46xx_register_write(tsdata, HY46XX_PWR_NOISE_EN, val); > + tsdata->report_speed = val; > + } > + > + error = device_property_read_u32(dev, "filter-data", &val); > + if (!error) { > + hycon_hy46xx_register_write(tsdata, HY46XX_FILTER_DATA, val); > + tsdata->report_speed = val; > + } > + > + error = device_property_read_u32(dev, "gain", &val); > + if (!error) { > + hycon_hy46xx_register_write(tsdata, HY46XX_GAIN, val); > + tsdata->report_speed = val; > + } > + > + error = device_property_read_u32(dev, "edge-offset", &val); > + if (!error) { > + hycon_hy46xx_register_write(tsdata, HY46XX_EDGE_OFFSET, val); > + tsdata->report_speed = val; > + } > +} > + > +static void hycon_hy46xx_get_parameters(struct hycon_hy46xx_data *tsdata) > +{ > + tsdata->threshold = hycon_hy46xx_register_read(tsdata, HY46XX_THRESHOLD); > + tsdata->proximity_sensor_switch = > + hycon_hy46xx_register_read(tsdata, HY46XX_PROX_SENS_SW); > + tsdata->glove_enable = hycon_hy46xx_register_read(tsdata, HY46XX_GLOVE_EN); > + tsdata->report_speed = > + hycon_hy46xx_register_read(tsdata, HY46XX_REPORT_SPEED); > + tsdata->power_noise_enable = > + hycon_hy46xx_register_read(tsdata, HY46XX_PWR_NOISE_EN); > + tsdata->filter_data = hycon_hy46xx_register_read(tsdata, HY46XX_FILTER_DATA); > + tsdata->gain = hycon_hy46xx_register_read(tsdata, HY46XX_GAIN); > + tsdata->edge_offset = hycon_hy46xx_register_read(tsdata, HY46XX_EDGE_OFFSET); > + tsdata->rx_number_used = > + hycon_hy46xx_register_read(tsdata, HY46XX_RX_NR_USED); > + tsdata->tx_number_used = > + hycon_hy46xx_register_read(tsdata, HY46XX_TX_NR_USED); > + tsdata->power_mode = hycon_hy46xx_register_read(tsdata, HY46XX_PWR_MODE); > + tsdata->fw_version = hycon_hy46xx_register_read(tsdata, HY46XX_FW_VERSION); > + tsdata->lib_version = hycon_hy46xx_register_read(tsdata, HY46XX_LIB_VERSION); > + tsdata->tp_information = hycon_hy46xx_register_read(tsdata, HY46XX_TP_INFO); > + tsdata->tp_chip_id = hycon_hy46xx_register_read(tsdata, HY46XX_TP_CHIP_ID); > + tsdata->bootloader_version = > + hycon_hy46xx_register_read(tsdata, HY46XX_BOOT_VER); > +} > + > +static void hycon_hy46xx_disable_regulator(void *arg) > +{ > + struct hycon_hy46xx_data *data = arg; > + > + regulator_disable(data->vcc); > +} > + > +static int hycon_hy46xx_probe(struct i2c_client *client, > + const struct i2c_device_id *id) > +{ > + const struct hycon_hy46xx_i2c_chip_data *chip_data; Where is this defined?? > + struct hycon_hy46xx_data *tsdata; > + struct input_dev *input; > + unsigned long irq_flags; > + int error; > + > + dev_dbg(&client->dev, "probing for HYCON HY46XX I2C\n"); > + > + tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL); > + if (!tsdata) > + return -ENOMEM; > + > + chip_data = device_get_match_data(&client->dev); > + if (!chip_data) > + chip_data = (const struct hycon_hy46xx_i2c_chip_data *) > + id->driver_data; > + if (!chip_data) { > + dev_err(&client->dev, "invalid or missing chip data\n"); > + return -EINVAL; > + } You are not attaching any additional data to OF or legacy match tables, so why are you doing this? > + > + tsdata->vcc = devm_regulator_get(&client->dev, "vcc"); > + if (IS_ERR(tsdata->vcc)) { > + error = PTR_ERR(tsdata->vcc); > + if (error != -EPROBE_DEFER) > + dev_err(&client->dev, > + "failed to request regulator: %d\n", error); > + return error; > + } > + > + error = regulator_enable(tsdata->vcc); > + if (error < 0) { > + dev_err(&client->dev, "failed to enable vcc: %d\n", error); > + return error; > + } > + > + error = devm_add_action_or_reset(&client->dev, > + hycon_hy46xx_disable_regulator, > + tsdata); > + if (error) > + return error; > + > + tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, > + "reset", GPIOD_OUT_LOW); > + if (IS_ERR(tsdata->reset_gpio)) { > + error = PTR_ERR(tsdata->reset_gpio); > + dev_err(&client->dev, > + "Failed to request GPIO reset pin, error %d\n", error); > + return error; > + } > + > + if (tsdata->reset_gpio) { > + usleep_range(5000, 6000); > + gpiod_set_value_cansleep(tsdata->reset_gpio, 1); > + usleep_range(5000, 6000); > + gpiod_set_value_cansleep(tsdata->reset_gpio, 0); > + msleep(1000); > + } > + > + input = devm_input_allocate_device(&client->dev); > + if (!input) { > + dev_err(&client->dev, "failed to allocate input device.\n"); > + return -ENOMEM; > + } > + > + mutex_init(&tsdata->mutex); > + tsdata->client = client; > + tsdata->input = input; > + > + hycon_hy46xx_get_defaults(&client->dev, tsdata); > + hycon_hy46xx_get_parameters(tsdata); > + > + input->name = "Hycon Capacitive Touch"; > + input->id.bustype = BUS_I2C; > + input->dev.parent = &client->dev; > + > + input_set_abs_params(input, ABS_MT_POSITION_X, > + 0, -1, 0, 0); > + input_set_abs_params(input, ABS_MT_POSITION_Y, > + 0, -1, 0, 0); > + > + touchscreen_parse_properties(input, true, &tsdata->prop); > + > + error = input_mt_init_slots(input, HY46XX_MAX_SUPPORTED_POINTS, > + INPUT_MT_DIRECT); > + if (error) { > + dev_err(&client->dev, "Unable to init MT slots.\n"); > + return error; > + } > + > + i2c_set_clientdata(client, tsdata); > + > + irq_flags = irq_get_trigger_type(client->irq); > + if (irq_flags == IRQF_TRIGGER_NONE) > + irq_flags = IRQF_TRIGGER_FALLING; > + irq_flags |= IRQF_ONESHOT; Just use IRQF_ONESHOT. The construct above is for compatibility when we had drivers in the tree that were hard-coding trigger, and then we moved to specify trigger in platform code/ACPI/DT and wanted to limit regressions. Given this driver is brand new simply pass IRQF_ONESHOT into devm_request_threaded_irq() below and call it a day. > + > + error = devm_request_threaded_irq(&client->dev, client->irq, > + NULL, hycon_hy46xx_isr, irq_flags, > + client->name, tsdata); > + if (error) { > + dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); > + return error; > + } > + > + error = devm_device_add_group(&client->dev, &hycon_hy46xx_attr_group); > + if (error) > + return error; > + > + error = input_register_device(input); > + if (error) > + return error; > + > + dev_dbg(&client->dev, > + "HYCON HY46XX initialized: IRQ %d, Reset pin %d.\n", > + client->irq, > + tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); > + > + return 0; > +} > + > +static const struct i2c_device_id hycon_hy46xx_id[] = { > + { .name = "hycon-hy4613" }, > + { .name = "hycon-hy4614" }, > + { .name = "hycon-hy4621" }, > + { .name = "hycon-hy4623" }, > + { .name = "hycon-hy4633" }, > + { .name = "hycon-hy4635" }, > + { /* sentinel */ } > +}; > +MODULE_DEVICE_TABLE(i2c, hycon_hy46xx_id); > + > +static const struct of_device_id hycon_hy46xx_of_match[] = { > + { .compatible = "hycon,hycon-hy4613" }, > + { .compatible = "hycon,hycon-hy4614" }, > + { .compatible = "hycon,hycon-hy4621" }, > + { .compatible = "hycon,hycon-hy4623" }, > + { .compatible = "hycon,hycon-hy4633" }, > + { .compatible = "hycon,hycon-hy4635" }, > + { /* sentinel */ } > +}; > +MODULE_DEVICE_TABLE(of, hycon_hy46xx_of_match); > + > +static struct i2c_driver hycon_hy46xx_driver = { > + .driver = { > + .name = "hycon_hy46xx", > + .of_match_table = hycon_hy46xx_of_match, > + .probe_type = PROBE_PREFER_ASYNCHRONOUS, > + }, > + .id_table = hycon_hy46xx_id, > + .probe = hycon_hy46xx_probe, > +}; > + > +module_i2c_driver(hycon_hy46xx_driver); > + > +MODULE_AUTHOR("Giulio Benetti <giulio.benetti@micronovasrl.com>"); > +MODULE_DESCRIPTION("HYCON HY46XX I2C Touchscreen Driver"); > +MODULE_LICENSE("GPL v2"); > -- > 2.25.1 > Thanks. -- Dmitry ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 3/3] Input: add driver for the Hycon HY46XX touchpanel series 2021-03-05 19:00 ` Dmitry Torokhov @ 2021-03-05 19:31 ` Giulio Benetti 2021-03-05 19:54 ` Giulio Benetti 1 sibling, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-03-05 19:31 UTC (permalink / raw) To: Dmitry Torokhov, Giulio Benetti; +Cc: Henrik Rydberg, linux-kernel, linux-input Hi Dmitry, Il 05/03/2021 20:00, Dmitry Torokhov ha scritto: > Hi Giulio, > > On Fri, Mar 05, 2021 at 05:38:34PM +0100, Giulio Benetti wrote: >> From: Giulio Benetti <giulio.benetti@micronovasrl.com> >> >> This patch adds support for Hycon HY46XX. > > Could you please tell me where patches 1/3 and 2/3. I am guessing they > are dealing with DT bindings and are most likely to go through my tree > after Rob's ACK. Sorry, this was a buggy script I've used to list contacts and git send-email. I'm going to add you +Cc. Going to answer below soon. Thank you Best regards -- Giulio Benetti CTO MICRONOVA SRL Sede: Via A. Niedda 3 - 35010 Vigonza (PD) Tel. 049/8931563 - Fax 049/8931346 Cod.Fiscale - P.IVA 02663420285 Capitale Sociale € 26.000 i.v. Iscritta al Reg. Imprese di Padova N. 02663420285 Numero R.E.A. 258642 >> >> Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com> >> --- >> MAINTAINERS | 1 + >> drivers/input/touchscreen/Kconfig | 12 + >> drivers/input/touchscreen/Makefile | 1 + >> drivers/input/touchscreen/hycon-hy46xx.c | 571 +++++++++++++++++++++++ >> 4 files changed, 585 insertions(+) >> create mode 100644 drivers/input/touchscreen/hycon-hy46xx.c >> >> diff --git a/MAINTAINERS b/MAINTAINERS >> index 3f83daf6b2bf..7a1331657e4b 100644 >> --- a/MAINTAINERS >> +++ b/MAINTAINERS >> @@ -8250,6 +8250,7 @@ M: Giulio Benetti <giulio.benetti@micronovasrl.com> >> L: linux-input@vger.kernel.org >> S: Maintained >> F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> +F: drivers/input/touchscreen/hy46xx.c >> >> HYGON PROCESSOR SUPPORT >> M: Pu Wen <puwen@hygon.cn> >> diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig >> index 529614d364fe..5d4751d901cb 100644 >> --- a/drivers/input/touchscreen/Kconfig >> +++ b/drivers/input/touchscreen/Kconfig >> @@ -1335,4 +1335,16 @@ config TOUCHSCREEN_ZINITIX >> To compile this driver as a module, choose M here: the >> module will be called zinitix. >> >> +config TOUCHSCREEN_HYCON_HY46XX >> + tristate "Hycon hy46xx touchscreen support" >> + depends on I2C >> + help >> + Say Y here if you have a touchscreen using Hycon hy46xx, >> + or something similar enough. >> + >> + If unsure, say N. >> + >> + To compile this driver as a module, choose M here: the >> + module will be called hycon-hy46xx. >> + >> endif >> diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile >> index 6233541e9173..8b68cf3a3e6d 100644 >> --- a/drivers/input/touchscreen/Makefile >> +++ b/drivers/input/touchscreen/Makefile >> @@ -112,3 +112,4 @@ obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o >> obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o >> obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o >> obj-$(CONFIG_TOUCHSCREEN_ZINITIX) += zinitix.o >> +obj-$(CONFIG_TOUCHSCREEN_HYCON_HY46XX) += hycon-hy46xx.o >> diff --git a/drivers/input/touchscreen/hycon-hy46xx.c b/drivers/input/touchscreen/hycon-hy46xx.c >> new file mode 100644 >> index 000000000000..ef0dee9a43a9 >> --- /dev/null >> +++ b/drivers/input/touchscreen/hycon-hy46xx.c >> @@ -0,0 +1,571 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * Copyright (C) 2021 >> + * Author(s): Giulio Benetti <giulio.benetti@micronovasrl.com> >> + */ >> + >> +#include <linux/delay.h> >> +#include <linux/gpio/consumer.h> >> +#include <linux/i2c.h> >> +#include <linux/interrupt.h> >> +#include <linux/input.h> >> +#include <linux/input/mt.h> >> +#include <linux/input/touchscreen.h> >> +#include <linux/irq.h> >> +#include <linux/regulator/consumer.h> >> + >> +#include <asm/unaligned.h> >> + >> +#define HY46XX_CHKSUM_CODE 0x1 >> +#define HY46XX_FINGER_NUM 0x2 >> +#define HY46XX_CHKSUM_LEN 0x7 >> +#define HY46XX_THRESHOLD 0x80 >> +#define HY46XX_PROX_SENS_SW 0x81 >> +#define HY46XX_GLOVE_EN 0x84 >> +#define HY46XX_REPORT_SPEED 0x88 >> +#define HY46XX_PWR_NOISE_EN 0x89 >> +#define HY46XX_FILTER_DATA 0x8A >> +#define HY46XX_GAIN 0x92 >> +#define HY46XX_EDGE_OFFSET 0x93 >> +#define HY46XX_RX_NR_USED 0x94 >> +#define HY46XX_TX_NR_USED 0x95 >> +#define HY46XX_PWR_MODE 0xA5 >> +#define HY46XX_FW_VERSION 0xA6 >> +#define HY46XX_LIB_VERSION 0xA7 >> +#define HY46XX_TP_INFO 0xA8 >> +#define HY46XX_TP_CHIP_ID 0xA9 >> +#define HY46XX_BOOT_VER 0xB0 >> + >> +#define HY46XX_TPLEN 0x6 >> + >> +#define HY46XX_MAX_SUPPORTED_POINTS 11 >> + >> +#define TOUCH_EVENT_DOWN 0x00 >> +#define TOUCH_EVENT_UP 0x01 >> +#define TOUCH_EVENT_CONTACT 0x02 >> +#define TOUCH_EVENT_RESERVED 0x03 >> + >> +struct hycon_hy46xx_data { >> + struct i2c_client *client; >> + struct input_dev *input; >> + struct touchscreen_properties prop; >> + struct regulator *vcc; >> + >> + struct gpio_desc *reset_gpio; >> + >> + struct mutex mutex; >> + >> + int threshold; >> + int proximity_sensor_switch; >> + int glove_enable; >> + int report_speed; >> + int power_noise_enable; >> + int filter_data; >> + int gain; >> + int edge_offset; >> + int rx_number_used; >> + int tx_number_used; >> + int power_mode; >> + int fw_version; >> + int lib_version; >> + int tp_information; >> + int tp_chip_id; >> + int bootloader_version; >> +}; >> + >> +static int hycon_hy46xx_readwrite(struct i2c_client *client, u16 wr_len, u8 *wr_buf, >> + u16 rd_len, u8 *rd_buf) >> +{ >> + struct i2c_msg msgs[2]; >> + int i = 0; >> + int ret; >> + >> + if (wr_len) { >> + msgs[i].addr = client->addr; >> + msgs[i].flags = 0; >> + msgs[i].len = wr_len; >> + msgs[i].buf = wr_buf; >> + i++; >> + } >> + if (rd_len) { >> + msgs[i].addr = client->addr; >> + msgs[i].flags = I2C_M_RD; >> + msgs[i].len = rd_len; >> + msgs[i].buf = rd_buf; >> + i++; >> + } >> + >> + ret = i2c_transfer(client->adapter, msgs, i); >> + if (ret < 0) >> + return ret; >> + if (ret != i) >> + return -EIO; >> + >> + return 0; >> +} > > Please see if your driver could be converted to regmap API instead of > "maked" i2c. It will allow using write-gather when system supports it, > etc. > >> + >> +static bool hycon_hy46xx_check_checksum(struct hycon_hy46xx_data *tsdata, u8 *buf) >> +{ >> + u8 chksum = 0; >> + int i; >> + >> + for (i = 2; i < buf[HY46XX_CHKSUM_LEN]; i++) >> + chksum += buf[i]; >> + >> + if (chksum == buf[HY46XX_CHKSUM_CODE]) >> + return true; >> + >> + dev_err_ratelimited(&tsdata->client->dev, >> + "checksum error: 0x%02x expected, got 0x%02x\n", >> + chksum, buf[HY46XX_CHKSUM_CODE]); >> + >> + return false; >> +} >> + >> +static irqreturn_t hycon_hy46xx_isr(int irq, void *dev_id) >> +{ >> + struct hycon_hy46xx_data *tsdata = dev_id; >> + struct device *dev = &tsdata->client->dev; >> + u8 rdbuf[0x44]; > A #define here would be nice. > A #define here would be nice. > >> + u8 cmd; >> + int i, x, y, id; >> + int error; >> + >> + memset(rdbuf, 0, sizeof(rdbuf)); >> + >> + error = hycon_hy46xx_readwrite(tsdata->client, 1, &cmd, sizeof(rdbuf), rdbuf); > > cmd could be any garbage (as it is uninitialized)? This requires a nice > comment as to why it is OK. > >> + if (error) { >> + dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n", >> + error); >> + goto out; >> + } >> + >> + if (!hycon_hy46xx_check_checksum(tsdata, rdbuf)) >> + goto out; >> + >> + for (i = 0; i < HY46XX_MAX_SUPPORTED_POINTS; i++) { >> + u8 *buf = &rdbuf[3 + (HY46XX_TPLEN * i)]; >> + int type = buf[0] >> 6; >> + >> + if (type == TOUCH_EVENT_RESERVED) >> + continue; >> + >> + x = get_unaligned_be16(buf) & 0x0fff; >> + y = get_unaligned_be16(buf + 2) & 0x0fff; >> + >> + id = (buf[2] >> 4) & 0x0f; > > buf is u8 so no need to additionally mask after shifting. > >> + >> + input_mt_slot(tsdata->input, id); >> + if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, >> + type != TOUCH_EVENT_UP)) >> + touchscreen_report_pos(tsdata->input, &tsdata->prop, >> + x, y, true); >> + } >> + >> + input_mt_report_pointer_emulation(tsdata->input, true); >> + input_sync(tsdata->input); >> + >> +out: >> + return IRQ_HANDLED; >> +} >> + >> +static int hycon_hy46xx_register_write(struct hycon_hy46xx_data *tsdata, u8 addr, u8 value) >> +{ >> + u8 wrbuf[2]; >> + >> + wrbuf[0] = addr; >> + wrbuf[1] = value; >> + >> + return hycon_hy46xx_readwrite(tsdata->client, 2, wrbuf, 0, NULL); >> +} >> + >> +static int hycon_hy46xx_register_read(struct hycon_hy46xx_data *tsdata, u8 addr) >> +{ >> + u8 wrbyte, rdbyte; >> + int error; >> + >> + wrbyte = addr; >> + error = hycon_hy46xx_readwrite(tsdata->client, 1, &wrbyte, 1, &rdbyte); >> + if (error) >> + return error; >> + >> + return rdbyte; >> +} >> + >> +struct hycon_hy46xx_attribute { >> + struct device_attribute dattr; >> + size_t field_offset; >> + u8 address; >> + u8 limit_low; >> + u8 limit_high; >> +}; >> + >> +#define HYCON_ATTR(_field, _mode, _address, _limit_low, _limit_high) \ >> + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ >> + .dattr = __ATTR(_field, _mode, \ >> + hycon_hy46xx_setting_show, \ >> + hycon_hy46xx_setting_store), \ >> + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ >> + .address = _address, \ >> + .limit_low = _limit_low, \ >> + .limit_high = _limit_high, \ >> + } >> + >> +static ssize_t hycon_hy46xx_setting_show(struct device *dev, >> + struct device_attribute *dattr, char *buf) >> +{ >> + struct i2c_client *client = to_i2c_client(dev); >> + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); >> + struct hycon_hy46xx_attribute *attr = >> + container_of(dattr, struct hycon_hy46xx_attribute, dattr); >> + u8 *field = (u8 *)tsdata + attr->field_offset; >> + int val; >> + size_t count = 0; >> + int error = 0; >> + u8 addr = attr->address; >> + >> + mutex_lock(&tsdata->mutex); >> + >> + val = hycon_hy46xx_register_read(tsdata, addr); >> + if (val < 0) { >> + error = val; >> + dev_err(&tsdata->client->dev, >> + "Failed to fetch attribute %s, error %d\n", >> + dattr->attr.name, error); >> + goto out; >> + } >> + >> + if (val != *field) { >> + dev_warn(&tsdata->client->dev, >> + "%s: read (%d) and stored value (%d) differ\n", >> + dattr->attr.name, val, *field); >> + *field = val; >> + } >> + >> + count = scnprintf(buf, PAGE_SIZE, "%d\n", val); >> +out: >> + mutex_unlock(&tsdata->mutex); >> + return error ?: count; >> +} >> + >> +static ssize_t hycon_hy46xx_setting_store(struct device *dev, >> + struct device_attribute *dattr, >> + const char *buf, size_t count) >> +{ >> + struct i2c_client *client = to_i2c_client(dev); >> + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); >> + struct hycon_hy46xx_attribute *attr = >> + container_of(dattr, struct hycon_hy46xx_attribute, dattr); >> + u8 *field = (u8 *)tsdata + attr->field_offset; >> + unsigned int val; >> + int error; >> + u8 addr = attr->address; >> + >> + mutex_lock(&tsdata->mutex); >> + >> + error = kstrtouint(buf, 0, &val); >> + if (error) >> + goto out; >> + >> + if (val < attr->limit_low || val > attr->limit_high) { >> + error = -ERANGE; >> + goto out; >> + } >> + >> + error = hycon_hy46xx_register_write(tsdata, addr, val); >> + if (error) { >> + dev_err(&tsdata->client->dev, >> + "Failed to update attribute %s, error: %d\n", >> + dattr->attr.name, error); >> + goto out; >> + } >> + *field = val; > > I am not sure why you want this check (I see that we have it in one > other driver and I really do not recall why we have it there either). > >> + >> +out: >> + mutex_unlock(&tsdata->mutex); >> + return error ?: count; >> +} >> + >> +static HYCON_ATTR(threshold, 0644, HY46XX_THRESHOLD, 0, 255); >> +static HYCON_ATTR(proximity_sensor_switch, 0644, HY46XX_PROX_SENS_SW, 0, 1); >> +static HYCON_ATTR(glove_enable, 0644, HY46XX_GLOVE_EN, 0, 1); >> +static HYCON_ATTR(report_speed, 0644, HY46XX_REPORT_SPEED, 0, 255); >> +static HYCON_ATTR(power_noise_enable, 0644, HY46XX_PWR_NOISE_EN, 0, 1); >> +static HYCON_ATTR(filter_data, 0644, HY46XX_FILTER_DATA, 0, 5); >> +static HYCON_ATTR(gain, 0644, HY46XX_GAIN, 0, 5); >> +static HYCON_ATTR(edge_offset, 0644, HY46XX_EDGE_OFFSET, 0, 5); >> +static HYCON_ATTR(fw_version, 0444, HY46XX_FW_VERSION, 0, 255); >> +static HYCON_ATTR(lib_version, 0444, HY46XX_LIB_VERSION, 0, 255); >> +static HYCON_ATTR(tp_information, 0444, HY46XX_TP_INFO, 0, 255); >> +static HYCON_ATTR(tp_chip_id, 0444, HY46XX_TP_CHIP_ID, 0, 255); >> +static HYCON_ATTR(bootloader_version, 0444, HY46XX_BOOT_VER, 0, 255); >> + >> +static struct attribute *hycon_hy46xx_attrs[] = { >> + &hycon_hy46xx_attr_threshold.dattr.attr, >> + &hycon_hy46xx_attr_proximity_sensor_switch.dattr.attr, >> + &hycon_hy46xx_attr_glove_enable.dattr.attr, >> + &hycon_hy46xx_attr_report_speed.dattr.attr, >> + &hycon_hy46xx_attr_power_noise_enable.dattr.attr, >> + &hycon_hy46xx_attr_filter_data.dattr.attr, >> + &hycon_hy46xx_attr_gain.dattr.attr, >> + &hycon_hy46xx_attr_edge_offset.dattr.attr, >> + &hycon_hy46xx_attr_fw_version.dattr.attr, >> + &hycon_hy46xx_attr_lib_version.dattr.attr, >> + &hycon_hy46xx_attr_tp_information.dattr.attr, >> + &hycon_hy46xx_attr_tp_chip_id.dattr.attr, >> + &hycon_hy46xx_attr_bootloader_version.dattr.attr, >> + NULL >> +}; >> + >> +static const struct attribute_group hycon_hy46xx_attr_group = { >> + .attrs = hycon_hy46xx_attrs, >> +}; >> + >> +static void hycon_hy46xx_get_defaults(struct device *dev, struct hycon_hy46xx_data *tsdata) >> +{ >> + u32 val; >> + int error; >> + >> + error = device_property_read_u32(dev, "threshold", &val); >> + if (!error) { >> + hycon_hy46xx_register_write(tsdata, HY46XX_THRESHOLD, val); >> + tsdata->threshold = val; >> + } >> + >> + error = device_property_read_u32(dev, "proximity-sensor-switch", &val); >> + if (!error) { >> + hycon_hy46xx_register_write(tsdata, HY46XX_PROX_SENS_SW, val); >> + tsdata->proximity_sensor_switch = val; >> + } >> + >> + error = device_property_read_u32(dev, "glove-enable", &val); >> + if (!error) { >> + hycon_hy46xx_register_write(tsdata, HY46XX_GLOVE_EN, val); >> + tsdata->glove_enable = val; >> + } >> + >> + error = device_property_read_u32(dev, "report-speed", &val); >> + if (!error) { >> + hycon_hy46xx_register_write(tsdata, HY46XX_REPORT_SPEED, val); >> + tsdata->report_speed = val; >> + } >> + >> + error = device_property_read_u32(dev, "power-noise-enable", &val); >> + if (!error) { >> + hycon_hy46xx_register_write(tsdata, HY46XX_PWR_NOISE_EN, val); >> + tsdata->report_speed = val; >> + } >> + >> + error = device_property_read_u32(dev, "filter-data", &val); >> + if (!error) { >> + hycon_hy46xx_register_write(tsdata, HY46XX_FILTER_DATA, val); >> + tsdata->report_speed = val; >> + } >> + >> + error = device_property_read_u32(dev, "gain", &val); >> + if (!error) { >> + hycon_hy46xx_register_write(tsdata, HY46XX_GAIN, val); >> + tsdata->report_speed = val; >> + } >> + >> + error = device_property_read_u32(dev, "edge-offset", &val); >> + if (!error) { >> + hycon_hy46xx_register_write(tsdata, HY46XX_EDGE_OFFSET, val); >> + tsdata->report_speed = val; >> + } >> +} >> + >> +static void hycon_hy46xx_get_parameters(struct hycon_hy46xx_data *tsdata) >> +{ >> + tsdata->threshold = hycon_hy46xx_register_read(tsdata, HY46XX_THRESHOLD); >> + tsdata->proximity_sensor_switch = >> + hycon_hy46xx_register_read(tsdata, HY46XX_PROX_SENS_SW); >> + tsdata->glove_enable = hycon_hy46xx_register_read(tsdata, HY46XX_GLOVE_EN); >> + tsdata->report_speed = >> + hycon_hy46xx_register_read(tsdata, HY46XX_REPORT_SPEED); >> + tsdata->power_noise_enable = >> + hycon_hy46xx_register_read(tsdata, HY46XX_PWR_NOISE_EN); >> + tsdata->filter_data = hycon_hy46xx_register_read(tsdata, HY46XX_FILTER_DATA); >> + tsdata->gain = hycon_hy46xx_register_read(tsdata, HY46XX_GAIN); >> + tsdata->edge_offset = hycon_hy46xx_register_read(tsdata, HY46XX_EDGE_OFFSET); >> + tsdata->rx_number_used = >> + hycon_hy46xx_register_read(tsdata, HY46XX_RX_NR_USED); >> + tsdata->tx_number_used = >> + hycon_hy46xx_register_read(tsdata, HY46XX_TX_NR_USED); >> + tsdata->power_mode = hycon_hy46xx_register_read(tsdata, HY46XX_PWR_MODE); >> + tsdata->fw_version = hycon_hy46xx_register_read(tsdata, HY46XX_FW_VERSION); >> + tsdata->lib_version = hycon_hy46xx_register_read(tsdata, HY46XX_LIB_VERSION); >> + tsdata->tp_information = hycon_hy46xx_register_read(tsdata, HY46XX_TP_INFO); >> + tsdata->tp_chip_id = hycon_hy46xx_register_read(tsdata, HY46XX_TP_CHIP_ID); >> + tsdata->bootloader_version = >> + hycon_hy46xx_register_read(tsdata, HY46XX_BOOT_VER); >> +} >> + >> +static void hycon_hy46xx_disable_regulator(void *arg) >> +{ >> + struct hycon_hy46xx_data *data = arg; >> + >> + regulator_disable(data->vcc); >> +} >> + >> +static int hycon_hy46xx_probe(struct i2c_client *client, >> + const struct i2c_device_id *id) >> +{ >> + const struct hycon_hy46xx_i2c_chip_data *chip_data; > > Where is this defined?? > >> + struct hycon_hy46xx_data *tsdata; >> + struct input_dev *input; >> + unsigned long irq_flags; >> + int error; >> + >> + dev_dbg(&client->dev, "probing for HYCON HY46XX I2C\n"); >> + >> + tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL); >> + if (!tsdata) >> + return -ENOMEM; >> + >> + chip_data = device_get_match_data(&client->dev); >> + if (!chip_data) >> + chip_data = (const struct hycon_hy46xx_i2c_chip_data *) >> + id->driver_data; >> + if (!chip_data) { >> + dev_err(&client->dev, "invalid or missing chip data\n"); >> + return -EINVAL; >> + } > > You are not attaching any additional data to OF or legacy match tables, > so why are you doing this? > >> + >> + tsdata->vcc = devm_regulator_get(&client->dev, "vcc"); >> + if (IS_ERR(tsdata->vcc)) { >> + error = PTR_ERR(tsdata->vcc); >> + if (error != -EPROBE_DEFER) >> + dev_err(&client->dev, >> + "failed to request regulator: %d\n", error); >> + return error; >> + } >> + >> + error = regulator_enable(tsdata->vcc); >> + if (error < 0) { >> + dev_err(&client->dev, "failed to enable vcc: %d\n", error); >> + return error; >> + } >> + >> + error = devm_add_action_or_reset(&client->dev, >> + hycon_hy46xx_disable_regulator, >> + tsdata); >> + if (error) >> + return error; >> + >> + tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, >> + "reset", GPIOD_OUT_LOW); >> + if (IS_ERR(tsdata->reset_gpio)) { >> + error = PTR_ERR(tsdata->reset_gpio); >> + dev_err(&client->dev, >> + "Failed to request GPIO reset pin, error %d\n", error); >> + return error; >> + } >> + >> + if (tsdata->reset_gpio) { >> + usleep_range(5000, 6000); >> + gpiod_set_value_cansleep(tsdata->reset_gpio, 1); >> + usleep_range(5000, 6000); >> + gpiod_set_value_cansleep(tsdata->reset_gpio, 0); >> + msleep(1000); >> + } >> + >> + input = devm_input_allocate_device(&client->dev); >> + if (!input) { >> + dev_err(&client->dev, "failed to allocate input device.\n"); >> + return -ENOMEM; >> + } >> + >> + mutex_init(&tsdata->mutex); >> + tsdata->client = client; >> + tsdata->input = input; >> + >> + hycon_hy46xx_get_defaults(&client->dev, tsdata); >> + hycon_hy46xx_get_parameters(tsdata); >> + >> + input->name = "Hycon Capacitive Touch"; >> + input->id.bustype = BUS_I2C; >> + input->dev.parent = &client->dev; >> + >> + input_set_abs_params(input, ABS_MT_POSITION_X, >> + 0, -1, 0, 0); >> + input_set_abs_params(input, ABS_MT_POSITION_Y, >> + 0, -1, 0, 0); >> + >> + touchscreen_parse_properties(input, true, &tsdata->prop); >> + >> + error = input_mt_init_slots(input, HY46XX_MAX_SUPPORTED_POINTS, >> + INPUT_MT_DIRECT); >> + if (error) { >> + dev_err(&client->dev, "Unable to init MT slots.\n"); >> + return error; >> + } >> + >> + i2c_set_clientdata(client, tsdata); >> + >> + irq_flags = irq_get_trigger_type(client->irq); >> + if (irq_flags == IRQF_TRIGGER_NONE) >> + irq_flags = IRQF_TRIGGER_FALLING; >> + irq_flags |= IRQF_ONESHOT; > > Just use IRQF_ONESHOT. The construct above is for compatibility when we > had drivers in the tree that were hard-coding trigger, and then we moved > to specify trigger in platform code/ACPI/DT and wanted to limit > regressions. Given this driver is brand new simply pass IRQF_ONESHOT > into devm_request_threaded_irq() below and call it a day. > >> + >> + error = devm_request_threaded_irq(&client->dev, client->irq, >> + NULL, hycon_hy46xx_isr, irq_flags, >> + client->name, tsdata); >> + if (error) { >> + dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); >> + return error; >> + } >> + >> + error = devm_device_add_group(&client->dev, &hycon_hy46xx_attr_group); >> + if (error) >> + return error; >> + >> + error = input_register_device(input); >> + if (error) >> + return error; >> + >> + dev_dbg(&client->dev, >> + "HYCON HY46XX initialized: IRQ %d, Reset pin %d.\n", >> + client->irq, >> + tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); >> + >> + return 0; >> +} >> + >> +static const struct i2c_device_id hycon_hy46xx_id[] = { >> + { .name = "hycon-hy4613" }, >> + { .name = "hycon-hy4614" }, >> + { .name = "hycon-hy4621" }, >> + { .name = "hycon-hy4623" }, >> + { .name = "hycon-hy4633" }, >> + { .name = "hycon-hy4635" }, >> + { /* sentinel */ } >> +}; >> +MODULE_DEVICE_TABLE(i2c, hycon_hy46xx_id); >> + >> +static const struct of_device_id hycon_hy46xx_of_match[] = { >> + { .compatible = "hycon,hycon-hy4613" }, >> + { .compatible = "hycon,hycon-hy4614" }, >> + { .compatible = "hycon,hycon-hy4621" }, >> + { .compatible = "hycon,hycon-hy4623" }, >> + { .compatible = "hycon,hycon-hy4633" }, >> + { .compatible = "hycon,hycon-hy4635" }, >> + { /* sentinel */ } >> +}; >> +MODULE_DEVICE_TABLE(of, hycon_hy46xx_of_match); >> + >> +static struct i2c_driver hycon_hy46xx_driver = { >> + .driver = { >> + .name = "hycon_hy46xx", >> + .of_match_table = hycon_hy46xx_of_match, >> + .probe_type = PROBE_PREFER_ASYNCHRONOUS, >> + }, >> + .id_table = hycon_hy46xx_id, >> + .probe = hycon_hy46xx_probe, >> +}; >> + >> +module_i2c_driver(hycon_hy46xx_driver); >> + >> +MODULE_AUTHOR("Giulio Benetti <giulio.benetti@micronovasrl.com>"); >> +MODULE_DESCRIPTION("HYCON HY46XX I2C Touchscreen Driver"); >> +MODULE_LICENSE("GPL v2"); >> -- >> 2.25.1 >> > > Thanks. > ^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 3/3] Input: add driver for the Hycon HY46XX touchpanel series 2021-03-05 19:00 ` Dmitry Torokhov 2021-03-05 19:31 ` Giulio Benetti @ 2021-03-05 19:54 ` Giulio Benetti 1 sibling, 0 replies; 69+ messages in thread From: Giulio Benetti @ 2021-03-05 19:54 UTC (permalink / raw) To: Dmitry Torokhov, Giulio Benetti; +Cc: Henrik Rydberg, linux-kernel, linux-input Hi Dmitry, Il 05/03/2021 20:00, Dmitry Torokhov ha scritto: > Hi Giulio, > > On Fri, Mar 05, 2021 at 05:38:34PM +0100, Giulio Benetti wrote: >> From: Giulio Benetti <giulio.benetti@micronovasrl.com> >> >> This patch adds support for Hycon HY46XX. > > Could you please tell me where patches 1/3 and 2/3. I am guessing they > are dealing with DT bindings and are most likely to go through my tree > after Rob's ACK. I've just added you +Cc on both 1-2/3 >> >> Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com> >> --- >> MAINTAINERS | 1 + >> drivers/input/touchscreen/Kconfig | 12 + >> drivers/input/touchscreen/Makefile | 1 + >> drivers/input/touchscreen/hycon-hy46xx.c | 571 +++++++++++++++++++++++ >> 4 files changed, 585 insertions(+) >> create mode 100644 drivers/input/touchscreen/hycon-hy46xx.c >> >> diff --git a/MAINTAINERS b/MAINTAINERS >> index 3f83daf6b2bf..7a1331657e4b 100644 >> --- a/MAINTAINERS >> +++ b/MAINTAINERS >> @@ -8250,6 +8250,7 @@ M: Giulio Benetti <giulio.benetti@micronovasrl.com> >> L: linux-input@vger.kernel.org >> S: Maintained >> F: Documentation/devicetree/bindings/input/touchscreen/hycon,hy46xx.yaml >> +F: drivers/input/touchscreen/hy46xx.c >> >> HYGON PROCESSOR SUPPORT >> M: Pu Wen <puwen@hygon.cn> >> diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig >> index 529614d364fe..5d4751d901cb 100644 >> --- a/drivers/input/touchscreen/Kconfig >> +++ b/drivers/input/touchscreen/Kconfig >> @@ -1335,4 +1335,16 @@ config TOUCHSCREEN_ZINITIX >> To compile this driver as a module, choose M here: the >> module will be called zinitix. >> >> +config TOUCHSCREEN_HYCON_HY46XX >> + tristate "Hycon hy46xx touchscreen support" >> + depends on I2C >> + help >> + Say Y here if you have a touchscreen using Hycon hy46xx, >> + or something similar enough. >> + >> + If unsure, say N. >> + >> + To compile this driver as a module, choose M here: the >> + module will be called hycon-hy46xx. >> + >> endif >> diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile >> index 6233541e9173..8b68cf3a3e6d 100644 >> --- a/drivers/input/touchscreen/Makefile >> +++ b/drivers/input/touchscreen/Makefile >> @@ -112,3 +112,4 @@ obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023) += rohm_bu21023.o >> obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o >> obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o >> obj-$(CONFIG_TOUCHSCREEN_ZINITIX) += zinitix.o >> +obj-$(CONFIG_TOUCHSCREEN_HYCON_HY46XX) += hycon-hy46xx.o >> diff --git a/drivers/input/touchscreen/hycon-hy46xx.c b/drivers/input/touchscreen/hycon-hy46xx.c >> new file mode 100644 >> index 000000000000..ef0dee9a43a9 >> --- /dev/null >> +++ b/drivers/input/touchscreen/hycon-hy46xx.c >> @@ -0,0 +1,571 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * Copyright (C) 2021 >> + * Author(s): Giulio Benetti <giulio.benetti@micronovasrl.com> >> + */ >> + >> +#include <linux/delay.h> >> +#include <linux/gpio/consumer.h> >> +#include <linux/i2c.h> >> +#include <linux/interrupt.h> >> +#include <linux/input.h> >> +#include <linux/input/mt.h> >> +#include <linux/input/touchscreen.h> >> +#include <linux/irq.h> >> +#include <linux/regulator/consumer.h> >> + >> +#include <asm/unaligned.h> >> + >> +#define HY46XX_CHKSUM_CODE 0x1 >> +#define HY46XX_FINGER_NUM 0x2 >> +#define HY46XX_CHKSUM_LEN 0x7 >> +#define HY46XX_THRESHOLD 0x80 >> +#define HY46XX_PROX_SENS_SW 0x81 >> +#define HY46XX_GLOVE_EN 0x84 >> +#define HY46XX_REPORT_SPEED 0x88 >> +#define HY46XX_PWR_NOISE_EN 0x89 >> +#define HY46XX_FILTER_DATA 0x8A >> +#define HY46XX_GAIN 0x92 >> +#define HY46XX_EDGE_OFFSET 0x93 >> +#define HY46XX_RX_NR_USED 0x94 >> +#define HY46XX_TX_NR_USED 0x95 >> +#define HY46XX_PWR_MODE 0xA5 >> +#define HY46XX_FW_VERSION 0xA6 >> +#define HY46XX_LIB_VERSION 0xA7 >> +#define HY46XX_TP_INFO 0xA8 >> +#define HY46XX_TP_CHIP_ID 0xA9 >> +#define HY46XX_BOOT_VER 0xB0 >> + >> +#define HY46XX_TPLEN 0x6 >> + >> +#define HY46XX_MAX_SUPPORTED_POINTS 11 >> + >> +#define TOUCH_EVENT_DOWN 0x00 >> +#define TOUCH_EVENT_UP 0x01 >> +#define TOUCH_EVENT_CONTACT 0x02 >> +#define TOUCH_EVENT_RESERVED 0x03 >> + >> +struct hycon_hy46xx_data { >> + struct i2c_client *client; >> + struct input_dev *input; >> + struct touchscreen_properties prop; >> + struct regulator *vcc; >> + >> + struct gpio_desc *reset_gpio; >> + >> + struct mutex mutex; >> + >> + int threshold; >> + int proximity_sensor_switch; >> + int glove_enable; >> + int report_speed; >> + int power_noise_enable; >> + int filter_data; >> + int gain; >> + int edge_offset; >> + int rx_number_used; >> + int tx_number_used; >> + int power_mode; >> + int fw_version; >> + int lib_version; >> + int tp_information; >> + int tp_chip_id; >> + int bootloader_version; >> +}; >> + >> +static int hycon_hy46xx_readwrite(struct i2c_client *client, u16 wr_len, u8 *wr_buf, >> + u16 rd_len, u8 *rd_buf) >> +{ >> + struct i2c_msg msgs[2]; >> + int i = 0; >> + int ret; >> + >> + if (wr_len) { >> + msgs[i].addr = client->addr; >> + msgs[i].flags = 0; >> + msgs[i].len = wr_len; >> + msgs[i].buf = wr_buf; >> + i++; >> + } >> + if (rd_len) { >> + msgs[i].addr = client->addr; >> + msgs[i].flags = I2C_M_RD; >> + msgs[i].len = rd_len; >> + msgs[i].buf = rd_buf; >> + i++; >> + } >> + >> + ret = i2c_transfer(client->adapter, msgs, i); >> + if (ret < 0) >> + return ret; >> + if (ret != i) >> + return -EIO; >> + >> + return 0; >> +} > > Please see if your driver could be converted to regmap API instead of > "maked" i2c. It will allow using write-gather when system supports it, > etc. Ah yes, I've already used regmap in ds1307 rtc, they are very useful. > >> + >> +static bool hycon_hy46xx_check_checksum(struct hycon_hy46xx_data *tsdata, u8 *buf) >> +{ >> + u8 chksum = 0; >> + int i; >> + >> + for (i = 2; i < buf[HY46XX_CHKSUM_LEN]; i++) >> + chksum += buf[i]; >> + >> + if (chksum == buf[HY46XX_CHKSUM_CODE]) >> + return true; >> + >> + dev_err_ratelimited(&tsdata->client->dev, >> + "checksum error: 0x%02x expected, got 0x%02x\n", >> + chksum, buf[HY46XX_CHKSUM_CODE]); >> + >> + return false; >> +} >> + >> +static irqreturn_t hycon_hy46xx_isr(int irq, void *dev_id) >> +{ >> + struct hycon_hy46xx_data *tsdata = dev_id; >> + struct device *dev = &tsdata->client->dev; >> + u8 rdbuf[0x44]; > A #define here would be nice. Ok > >> + u8 cmd; >> + int i, x, y, id; >> + int error; >> + >> + memset(rdbuf, 0, sizeof(rdbuf)); >> + >> + error = hycon_hy46xx_readwrite(tsdata->client, 1, &cmd, sizeof(rdbuf), rdbuf); > > cmd could be any garbage (as it is uninitialized)? This requires a nice > comment as to why it is OK. I've forgotten to init it to 0. It must be done because it is the i2c register address to read. > >> + if (error) { >> + dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n", >> + error); >> + goto out; >> + } >> + >> + if (!hycon_hy46xx_check_checksum(tsdata, rdbuf)) >> + goto out; >> + >> + for (i = 0; i < HY46XX_MAX_SUPPORTED_POINTS; i++) { >> + u8 *buf = &rdbuf[3 + (HY46XX_TPLEN * i)]; >> + int type = buf[0] >> 6; >> + >> + if (type == TOUCH_EVENT_RESERVED) >> + continue; >> + >> + x = get_unaligned_be16(buf) & 0x0fff; >> + y = get_unaligned_be16(buf + 2) & 0x0fff; >> + >> + id = (buf[2] >> 4) & 0x0f; > > buf is u8 so no need to additionally mask after shifting. Ok > >> + >> + input_mt_slot(tsdata->input, id); >> + if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, >> + type != TOUCH_EVENT_UP)) >> + touchscreen_report_pos(tsdata->input, &tsdata->prop, >> + x, y, true); >> + } >> + >> + input_mt_report_pointer_emulation(tsdata->input, true); >> + input_sync(tsdata->input); >> + >> +out: >> + return IRQ_HANDLED; >> +} >> + >> +static int hycon_hy46xx_register_write(struct hycon_hy46xx_data *tsdata, u8 addr, u8 value) >> +{ >> + u8 wrbuf[2]; >> + >> + wrbuf[0] = addr; >> + wrbuf[1] = value; >> + >> + return hycon_hy46xx_readwrite(tsdata->client, 2, wrbuf, 0, NULL); >> +} >> + >> +static int hycon_hy46xx_register_read(struct hycon_hy46xx_data *tsdata, u8 addr) >> +{ >> + u8 wrbyte, rdbyte; >> + int error; >> + >> + wrbyte = addr; >> + error = hycon_hy46xx_readwrite(tsdata->client, 1, &wrbyte, 1, &rdbyte); >> + if (error) >> + return error; >> + >> + return rdbyte; >> +} >> + >> +struct hycon_hy46xx_attribute { >> + struct device_attribute dattr; >> + size_t field_offset; >> + u8 address; >> + u8 limit_low; >> + u8 limit_high; >> +}; >> + >> +#define HYCON_ATTR(_field, _mode, _address, _limit_low, _limit_high) \ >> + struct hycon_hy46xx_attribute hycon_hy46xx_attr_##_field = { \ >> + .dattr = __ATTR(_field, _mode, \ >> + hycon_hy46xx_setting_show, \ >> + hycon_hy46xx_setting_store), \ >> + .field_offset = offsetof(struct hycon_hy46xx_data, _field), \ >> + .address = _address, \ >> + .limit_low = _limit_low, \ >> + .limit_high = _limit_high, \ >> + } >> + >> +static ssize_t hycon_hy46xx_setting_show(struct device *dev, >> + struct device_attribute *dattr, char *buf) >> +{ >> + struct i2c_client *client = to_i2c_client(dev); >> + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); >> + struct hycon_hy46xx_attribute *attr = >> + container_of(dattr, struct hycon_hy46xx_attribute, dattr); >> + u8 *field = (u8 *)tsdata + attr->field_offset; >> + int val; >> + size_t count = 0; >> + int error = 0; >> + u8 addr = attr->address; >> + >> + mutex_lock(&tsdata->mutex); >> + >> + val = hycon_hy46xx_register_read(tsdata, addr); >> + if (val < 0) { >> + error = val; >> + dev_err(&tsdata->client->dev, >> + "Failed to fetch attribute %s, error %d\n", >> + dattr->attr.name, error); >> + goto out; >> + } >> + >> + if (val != *field) { >> + dev_warn(&tsdata->client->dev, >> + "%s: read (%d) and stored value (%d) differ\n", >> + dattr->attr.name, val, *field); >> + *field = val; >> + } >> + >> + count = scnprintf(buf, PAGE_SIZE, "%d\n", val); >> +out: >> + mutex_unlock(&tsdata->mutex); >> + return error ?: count; >> +} >> + >> +static ssize_t hycon_hy46xx_setting_store(struct device *dev, >> + struct device_attribute *dattr, >> + const char *buf, size_t count) >> +{ >> + struct i2c_client *client = to_i2c_client(dev); >> + struct hycon_hy46xx_data *tsdata = i2c_get_clientdata(client); >> + struct hycon_hy46xx_attribute *attr = >> + container_of(dattr, struct hycon_hy46xx_attribute, dattr); >> + u8 *field = (u8 *)tsdata + attr->field_offset; >> + unsigned int val; >> + int error; >> + u8 addr = attr->address; >> + >> + mutex_lock(&tsdata->mutex); >> + >> + error = kstrtouint(buf, 0, &val); >> + if (error) >> + goto out; >> + >> + if (val < attr->limit_low || val > attr->limit_high) { >> + error = -ERANGE; >> + goto out; >> + } >> + >> + error = hycon_hy46xx_register_write(tsdata, addr, val); >> + if (error) { >> + dev_err(&tsdata->client->dev, >> + "Failed to update attribute %s, error: %d\n", >> + dattr->attr.name, error); >> + goto out; >> + } >> + *field = val; > > I am not sure why you want this check (I see that we have it in one > other driver and I really do not recall why we have it there either). Do you mean the check or *field = val; assignment? It there's an error it must return(goto out) otherwise if it has succesfully written to controller then it alignes local fields contained in struct hycon_hy46xx_data. It makes sense for me, since variables in struct hycon_hy46xx_data should be the ones the driver rely on. And now I remember why they did that way, because they will rely on them during suspend/resume. At the moment it's no implemented but one day yes. > >> + >> +out: >> + mutex_unlock(&tsdata->mutex); >> + return error ?: count; >> +} >> + >> +static HYCON_ATTR(threshold, 0644, HY46XX_THRESHOLD, 0, 255); >> +static HYCON_ATTR(proximity_sensor_switch, 0644, HY46XX_PROX_SENS_SW, 0, 1); >> +static HYCON_ATTR(glove_enable, 0644, HY46XX_GLOVE_EN, 0, 1); >> +static HYCON_ATTR(report_speed, 0644, HY46XX_REPORT_SPEED, 0, 255); >> +static HYCON_ATTR(power_noise_enable, 0644, HY46XX_PWR_NOISE_EN, 0, 1); >> +static HYCON_ATTR(filter_data, 0644, HY46XX_FILTER_DATA, 0, 5); >> +static HYCON_ATTR(gain, 0644, HY46XX_GAIN, 0, 5); >> +static HYCON_ATTR(edge_offset, 0644, HY46XX_EDGE_OFFSET, 0, 5); >> +static HYCON_ATTR(fw_version, 0444, HY46XX_FW_VERSION, 0, 255); >> +static HYCON_ATTR(lib_version, 0444, HY46XX_LIB_VERSION, 0, 255); >> +static HYCON_ATTR(tp_information, 0444, HY46XX_TP_INFO, 0, 255); >> +static HYCON_ATTR(tp_chip_id, 0444, HY46XX_TP_CHIP_ID, 0, 255); >> +static HYCON_ATTR(bootloader_version, 0444, HY46XX_BOOT_VER, 0, 255); >> + >> +static struct attribute *hycon_hy46xx_attrs[] = { >> + &hycon_hy46xx_attr_threshold.dattr.attr, >> + &hycon_hy46xx_attr_proximity_sensor_switch.dattr.attr, >> + &hycon_hy46xx_attr_glove_enable.dattr.attr, >> + &hycon_hy46xx_attr_report_speed.dattr.attr, >> + &hycon_hy46xx_attr_power_noise_enable.dattr.attr, >> + &hycon_hy46xx_attr_filter_data.dattr.attr, >> + &hycon_hy46xx_attr_gain.dattr.attr, >> + &hycon_hy46xx_attr_edge_offset.dattr.attr, >> + &hycon_hy46xx_attr_fw_version.dattr.attr, >> + &hycon_hy46xx_attr_lib_version.dattr.attr, >> + &hycon_hy46xx_attr_tp_information.dattr.attr, >> + &hycon_hy46xx_attr_tp_chip_id.dattr.attr, >> + &hycon_hy46xx_attr_bootloader_version.dattr.attr, >> + NULL >> +}; >> + >> +static const struct attribute_group hycon_hy46xx_attr_group = { >> + .attrs = hycon_hy46xx_attrs, >> +}; >> + >> +static void hycon_hy46xx_get_defaults(struct device *dev, struct hycon_hy46xx_data *tsdata) >> +{ >> + u32 val; >> + int error; >> + >> + error = device_property_read_u32(dev, "threshold", &val); >> + if (!error) { >> + hycon_hy46xx_register_write(tsdata, HY46XX_THRESHOLD, val); >> + tsdata->threshold = val; >> + } >> + >> + error = device_property_read_u32(dev, "proximity-sensor-switch", &val); >> + if (!error) { >> + hycon_hy46xx_register_write(tsdata, HY46XX_PROX_SENS_SW, val); >> + tsdata->proximity_sensor_switch = val; >> + } >> + >> + error = device_property_read_u32(dev, "glove-enable", &val); >> + if (!error) { >> + hycon_hy46xx_register_write(tsdata, HY46XX_GLOVE_EN, val); >> + tsdata->glove_enable = val; >> + } >> + >> + error = device_property_read_u32(dev, "report-speed", &val); >> + if (!error) { >> + hycon_hy46xx_register_write(tsdata, HY46XX_REPORT_SPEED, val); >> + tsdata->report_speed = val; >> + } >> + >> + error = device_property_read_u32(dev, "power-noise-enable", &val); >> + if (!error) { >> + hycon_hy46xx_register_write(tsdata, HY46XX_PWR_NOISE_EN, val); >> + tsdata->report_speed = val; >> + } >> + >> + error = device_property_read_u32(dev, "filter-data", &val); >> + if (!error) { >> + hycon_hy46xx_register_write(tsdata, HY46XX_FILTER_DATA, val); >> + tsdata->report_speed = val; >> + } >> + >> + error = device_property_read_u32(dev, "gain", &val); >> + if (!error) { >> + hycon_hy46xx_register_write(tsdata, HY46XX_GAIN, val); >> + tsdata->report_speed = val; >> + } >> + >> + error = device_property_read_u32(dev, "edge-offset", &val); >> + if (!error) { >> + hycon_hy46xx_register_write(tsdata, HY46XX_EDGE_OFFSET, val); >> + tsdata->report_speed = val; >> + } >> +} >> + >> +static void hycon_hy46xx_get_parameters(struct hycon_hy46xx_data *tsdata) >> +{ >> + tsdata->threshold = hycon_hy46xx_register_read(tsdata, HY46XX_THRESHOLD); >> + tsdata->proximity_sensor_switch = >> + hycon_hy46xx_register_read(tsdata, HY46XX_PROX_SENS_SW); >> + tsdata->glove_enable = hycon_hy46xx_register_read(tsdata, HY46XX_GLOVE_EN); >> + tsdata->report_speed = >> + hycon_hy46xx_register_read(tsdata, HY46XX_REPORT_SPEED); >> + tsdata->power_noise_enable = >> + hycon_hy46xx_register_read(tsdata, HY46XX_PWR_NOISE_EN); >> + tsdata->filter_data = hycon_hy46xx_register_read(tsdata, HY46XX_FILTER_DATA); >> + tsdata->gain = hycon_hy46xx_register_read(tsdata, HY46XX_GAIN); >> + tsdata->edge_offset = hycon_hy46xx_register_read(tsdata, HY46XX_EDGE_OFFSET); >> + tsdata->rx_number_used = >> + hycon_hy46xx_register_read(tsdata, HY46XX_RX_NR_USED); >> + tsdata->tx_number_used = >> + hycon_hy46xx_register_read(tsdata, HY46XX_TX_NR_USED); >> + tsdata->power_mode = hycon_hy46xx_register_read(tsdata, HY46XX_PWR_MODE); >> + tsdata->fw_version = hycon_hy46xx_register_read(tsdata, HY46XX_FW_VERSION); >> + tsdata->lib_version = hycon_hy46xx_register_read(tsdata, HY46XX_LIB_VERSION); >> + tsdata->tp_information = hycon_hy46xx_register_read(tsdata, HY46XX_TP_INFO); >> + tsdata->tp_chip_id = hycon_hy46xx_register_read(tsdata, HY46XX_TP_CHIP_ID); >> + tsdata->bootloader_version = >> + hycon_hy46xx_register_read(tsdata, HY46XX_BOOT_VER); >> +} >> + >> +static void hycon_hy46xx_disable_regulator(void *arg) >> +{ >> + struct hycon_hy46xx_data *data = arg; >> + >> + regulator_disable(data->vcc); >> +} >> + >> +static int hycon_hy46xx_probe(struct i2c_client *client, >> + const struct i2c_device_id *id) >> +{ >> + const struct hycon_hy46xx_i2c_chip_data *chip_data; > > Where is this defined?? Oh, it was there while basing the driver starting from edt,ft5x, but what is strange is that compiler doesn't fail on it. I remove it from driver. > >> + struct hycon_hy46xx_data *tsdata; >> + struct input_dev *input; >> + unsigned long irq_flags; >> + int error; >> + >> + dev_dbg(&client->dev, "probing for HYCON HY46XX I2C\n"); >> + >> + tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL); >> + if (!tsdata) >> + return -ENOMEM; >> + >> + chip_data = device_get_match_data(&client->dev); >> + if (!chip_data) >> + chip_data = (const struct hycon_hy46xx_i2c_chip_data *) >> + id->driver_data; >> + if (!chip_data) { >> + dev_err(&client->dev, "invalid or missing chip data\n"); >> + return -EINVAL; >> + } > > You are not attaching any additional data to OF or legacy match tables, > so why are you doing this? This is due to above, I remove it > >> + >> + tsdata->vcc = devm_regulator_get(&client->dev, "vcc"); >> + if (IS_ERR(tsdata->vcc)) { >> + error = PTR_ERR(tsdata->vcc); >> + if (error != -EPROBE_DEFER) >> + dev_err(&client->dev, >> + "failed to request regulator: %d\n", error); >> + return error; >> + } >> + >> + error = regulator_enable(tsdata->vcc); >> + if (error < 0) { >> + dev_err(&client->dev, "failed to enable vcc: %d\n", error); >> + return error; >> + } >> + >> + error = devm_add_action_or_reset(&client->dev, >> + hycon_hy46xx_disable_regulator, >> + tsdata); >> + if (error) >> + return error; >> + >> + tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, >> + "reset", GPIOD_OUT_LOW); >> + if (IS_ERR(tsdata->reset_gpio)) { >> + error = PTR_ERR(tsdata->reset_gpio); >> + dev_err(&client->dev, >> + "Failed to request GPIO reset pin, error %d\n", error); >> + return error; >> + } >> + >> + if (tsdata->reset_gpio) { >> + usleep_range(5000, 6000); >> + gpiod_set_value_cansleep(tsdata->reset_gpio, 1); >> + usleep_range(5000, 6000); >> + gpiod_set_value_cansleep(tsdata->reset_gpio, 0); >> + msleep(1000); >> + } >> + >> + input = devm_input_allocate_device(&client->dev); >> + if (!input) { >> + dev_err(&client->dev, "failed to allocate input device.\n"); >> + return -ENOMEM; >> + } >> + >> + mutex_init(&tsdata->mutex); >> + tsdata->client = client; >> + tsdata->input = input; >> + >> + hycon_hy46xx_get_defaults(&client->dev, tsdata); >> + hycon_hy46xx_get_parameters(tsdata); >> + >> + input->name = "Hycon Capacitive Touch"; >> + input->id.bustype = BUS_I2C; >> + input->dev.parent = &client->dev; >> + >> + input_set_abs_params(input, ABS_MT_POSITION_X, >> + 0, -1, 0, 0); >> + input_set_abs_params(input, ABS_MT_POSITION_Y, >> + 0, -1, 0, 0); >> + >> + touchscreen_parse_properties(input, true, &tsdata->prop); >> + >> + error = input_mt_init_slots(input, HY46XX_MAX_SUPPORTED_POINTS, >> + INPUT_MT_DIRECT); >> + if (error) { >> + dev_err(&client->dev, "Unable to init MT slots.\n"); >> + return error; >> + } >> + >> + i2c_set_clientdata(client, tsdata); >> + >> + irq_flags = irq_get_trigger_type(client->irq); >> + if (irq_flags == IRQF_TRIGGER_NONE) >> + irq_flags = IRQF_TRIGGER_FALLING; >> + irq_flags |= IRQF_ONESHOT; > > Just use IRQF_ONESHOT. The construct above is for compatibility when we > had drivers in the tree that were hard-coding trigger, and then we moved > to specify trigger in platform code/ACPI/DT and wanted to limit > regressions. Given this driver is brand new simply pass IRQF_ONESHOT > into devm_request_threaded_irq() below and call it a day. Ok > >> + >> + error = devm_request_threaded_irq(&client->dev, client->irq, >> + NULL, hycon_hy46xx_isr, irq_flags, >> + client->name, tsdata); >> + if (error) { >> + dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); >> + return error; >> + } >> + >> + error = devm_device_add_group(&client->dev, &hycon_hy46xx_attr_group); >> + if (error) >> + return error; >> + >> + error = input_register_device(input); >> + if (error) >> + return error; >> + >> + dev_dbg(&client->dev, >> + "HYCON HY46XX initialized: IRQ %d, Reset pin %d.\n", >> + client->irq, >> + tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); >> + >> + return 0; >> +} >> + >> +static const struct i2c_device_id hycon_hy46xx_id[] = { >> + { .name = "hycon-hy4613" }, >> + { .name = "hycon-hy4614" }, >> + { .name = "hycon-hy4621" }, >> + { .name = "hycon-hy4623" }, >> + { .name = "hycon-hy4633" }, >> + { .name = "hycon-hy4635" }, >> + { /* sentinel */ } >> +}; >> +MODULE_DEVICE_TABLE(i2c, hycon_hy46xx_id); >> + >> +static const struct of_device_id hycon_hy46xx_of_match[] = { >> + { .compatible = "hycon,hycon-hy4613" }, >> + { .compatible = "hycon,hycon-hy4614" }, >> + { .compatible = "hycon,hycon-hy4621" }, >> + { .compatible = "hycon,hycon-hy4623" }, >> + { .compatible = "hycon,hycon-hy4633" }, >> + { .compatible = "hycon,hycon-hy4635" }, >> + { /* sentinel */ } >> +}; >> +MODULE_DEVICE_TABLE(of, hycon_hy46xx_of_match); >> + >> +static struct i2c_driver hycon_hy46xx_driver = { >> + .driver = { >> + .name = "hycon_hy46xx", >> + .of_match_table = hycon_hy46xx_of_match, >> + .probe_type = PROBE_PREFER_ASYNCHRONOUS, >> + }, >> + .id_table = hycon_hy46xx_id, >> + .probe = hycon_hy46xx_probe, >> +}; >> + >> +module_i2c_driver(hycon_hy46xx_driver); >> + >> +MODULE_AUTHOR("Giulio Benetti <giulio.benetti@micronovasrl.com>"); >> +MODULE_DESCRIPTION("HYCON HY46XX I2C Touchscreen Driver"); >> +MODULE_LICENSE("GPL v2"); >> -- >> 2.25.1 >> > > Thanks. Thank you for reviewing! I'm going to test it again with these changes and send a v2. Best regards -- Giulio Benetti CTO MICRONOVA SRL Sede: Via A. Niedda 3 - 35010 Vigonza (PD) Tel. 049/8931563 - Fax 049/8931346 Cod.Fiscale - P.IVA 02663420285 Capitale Sociale € 26.000 i.v. Iscritta al Reg. Imprese di Padova N. 02663420285 Numero R.E.A. 258642 ^ permalink raw reply [flat|nested] 69+ messages in thread
end of thread, other threads:[~2021-04-15 6:16 UTC | newest] Thread overview: 69+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20210305163834.70924-1-giulio.benetti@benettiengineering.com> 2021-03-05 16:38 ` [PATCH 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti 2021-03-05 17:25 ` Jonathan Neuschäfer 2021-03-05 17:33 ` Giulio Benetti 2021-03-05 19:32 ` Giulio Benetti 2021-03-05 16:38 ` [PATCH 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-03-05 19:34 ` Giulio Benetti 2021-03-06 19:28 ` Rob Herring 2021-03-06 19:41 ` Rob Herring 2021-04-01 18:37 ` Giulio Benetti 2021-04-01 22:24 ` Giulio Benetti 2021-04-01 23:03 ` [PATCH v2 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-01 23:03 ` [PATCH v2 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti 2021-04-01 23:03 ` [PATCH v2 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-04-02 8:36 ` Jonathan Neuschäfer 2021-04-02 15:17 ` Giulio Benetti 2021-04-01 23:03 ` [PATCH v2 3/3] Input: add driver for the Hycon HY46XX touchpanel series Giulio Benetti 2021-04-02 8:59 ` Jonathan Neuschäfer 2021-04-02 15:23 ` Giulio Benetti 2021-04-02 16:16 ` [PATCH v3 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-02 16:16 ` [PATCH v3 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti 2021-04-02 16:16 ` [PATCH v3 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-04-06 13:24 ` Rob Herring 2021-04-07 17:57 ` Giulio Benetti 2021-04-07 18:56 ` Rob Herring 2021-04-07 19:17 ` Giulio Benetti 2021-04-06 13:37 ` Jonathan Neuschäfer 2021-04-06 14:07 ` Giulio Benetti 2021-04-07 17:49 ` [PATCH v4 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-07 17:49 ` [PATCH v4 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti 2021-04-08 20:16 ` Rob Herring 2021-04-07 17:49 ` [PATCH v4 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-04-08 20:21 ` Rob Herring 2021-04-11 11:37 ` Giulio Benetti 2021-04-11 11:48 ` [PATCH v5 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-11 11:48 ` [PATCH v5 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti 2021-04-12 15:05 ` Rob Herring 2021-04-12 15:12 ` Giulio Benetti 2021-04-13 13:35 ` Rob Herring 2021-04-13 14:44 ` [PATCH v7 0/3] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-13 14:44 ` [PATCH v7 1/3] dt-bindings: Add Hycon Technology vendor prefix Giulio Benetti 2021-04-14 5:44 ` Dmitry Torokhov 2021-04-13 14:44 ` [PATCH v7 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-04-13 16:36 ` Rob Herring 2021-04-14 5:44 ` Dmitry Torokhov 2021-04-13 14:44 ` [PATCH v7 3/3] Input: add driver for the Hycon HY46XX touchpanel series Giulio Benetti 2021-04-14 5:44 ` Dmitry Torokhov 2021-04-14 6:46 ` Peter Hutterer 2021-04-14 11:22 ` Giulio Benetti 2021-04-14 17:26 ` Dmitry Torokhov 2021-04-15 6:16 ` Peter Hutterer 2021-04-14 11:24 ` Giulio Benetti 2021-04-11 11:48 ` [PATCH v5 2/3] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-04-12 13:20 ` Rob Herring 2021-04-12 14:46 ` Rob Herring 2021-04-12 14:49 ` Giulio Benetti 2021-04-12 15:23 ` [PATCH v6 0/2] Input: add Hycon HY46XX Touchscreen controller Giulio Benetti 2021-04-12 15:23 ` [PATCH v6 1/2] dt-bindings: touchscreen: Add HY46XX bindings Giulio Benetti 2021-04-13 15:07 ` Rob Herring 2021-04-13 15:27 ` Giulio Benetti 2021-04-13 17:58 ` Rob Herring 2021-04-13 18:34 ` Giulio Benetti 2021-04-12 15:24 ` [PATCH v6 2/2] Input: add driver for the Hycon HY46XX touchpanel series Giulio Benetti 2021-04-11 11:48 ` [PATCH v5 3/3] " Giulio Benetti 2021-04-07 17:49 ` [PATCH v4 " Giulio Benetti 2021-04-02 16:16 ` [PATCH v3 " Giulio Benetti 2021-03-05 16:38 ` [PATCH " Giulio Benetti 2021-03-05 19:00 ` Dmitry Torokhov 2021-03-05 19:31 ` Giulio Benetti 2021-03-05 19:54 ` Giulio Benetti
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).