Skip to contentSkip to conversation

input: Introduce support for SPMI haptics found on Qcom PMICs

PATCH RESEND Superseded Caleb Connolly 2 participants 6 messages Jun 18, 2021 – Jul 17, 2021

Subsystems (4)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v2 cover input: Introduce support for SPMI haptics found on Qcom PMICs

This series introduces a driver for the SPMI haptics hardware block found in Qualcomm PMICs. SPMI haptics support LRA (Linear Resonant Actuator) style haptics, as well as ERM (Eccentric Rotating Mass). It also supports several modes of driving the haptics, e.g. by loading the pattern to play into an internal buffer, or using PWM.

More information about the hardware can be found here:

        https://gitlab.com/sdm845-mainline/linux/-/wikis/PMI8998-QPNP-Haptics

This driver has been written based on downstream sources as no public documentation is available. It includes initial support for LRA haptics in buffer mode, this combination seems to be the most common and will enable haptics on the OnePlus 6 and 6T, PocoPhone F1, OnePlus 5 and several other Qualcomm devices with mainline kernel support.

The driver is implemented using the ff-memless (forcefeedback) input framework and makes an attempt to control the strength of vibration relative to the magnitude set from userspace.

~ Caleb

Changes since v1:
- Replace old QPNP naming with SPMI
- Address Bjorn's comments on the driver, various style and code cleanups
- Address Bjorn's comments on the DT bindings and DTS
- Pickup patches from Joel and Jami to enable haptics on the OnePlus 5 and Poco F1.

Caleb Connolly (4):
dt-bindings: input: add Qualcomm SPMI haptics driver
input: add Qualcomm SPMI haptics driver
arm64: dts: qcom: pmi8998: introduce spmi haptics
arm64: dts: qcom: sdm845-oneplus-common: add haptics

Jami Kettunen (1):
arm64: dts: qcom: msm8998-oneplus-common: Enable PMI8998 haptics

Joel Selvaraj (1):
arm64: dts: qcom: sdm845-xiaomi-beryllium: add haptics

 .../bindings/input/qcom,spmi-haptics.yaml          | 128 +++
 .../boot/dts/qcom/msm8998-oneplus-common.dtsi      |   6 +
 arch/arm64/boot/dts/qcom/pmi8998.dtsi              |  16 +
 .../arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi |   6 +
 .../boot/dts/qcom/sdm845-xiaomi-beryllium.dts      |   5 +
 drivers/input/misc/Kconfig                         |  12 +
 drivers/input/misc/Makefile                        |   1 +
 drivers/input/misc/qcom-spmi-haptics.c             | 980 +++++++++++++++++++++
 include/dt-bindings/input/qcom,spmi-haptics.h      |  32 +
 9 files changed, 1186 insertions(+)
#1 lore raw

PATCH RESEND v2 1/6 dt-bindings: input: add Qualcomm SPMI haptics driver

Add bindings for qcom PMIC SPMI haptics driver.

---
 .../bindings/input/qcom,spmi-haptics.yaml     | 128 ++++++++++++++++++
 include/dt-bindings/input/qcom,spmi-haptics.h |  32 +++++
 2 files changed, 160 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml
 create mode 100644 include/dt-bindings/input/qcom,spmi-haptics.h
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +128 -0
new file mode 100644
index 000000000000..8ef9b4ec3a07
@@ -0,0 +1,128 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2020 Unisoc Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/qcom,spmi-haptics.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Technologies Inc PMI8998 spmi haptics
+
+maintainers:
+  - Caleb Connolly <[email protected]>
+
+description: |
+  Qualcomm SPMI haptics is a peripheral on some QTI PMICs. It supports linear resonant
+  actuators and eccentric rotating mass type haptics commonly found in mobile devices.
+  It supports multiple sources of wave data such as an internal buffer, direct play
+  (from kernel or userspace) as well as an audio output mode.
+
+properties:
+  compatible:
+    items:
+      - enum:
+        - qcom,pmi8998-haptics
+        - qcom,pmi8996-haptics
+        - qcom,pmi8941-haptics
+      - const: qcom,spmi-haptics
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    items:
+      - description: short circuit interrupt
+      - description: play interrupt
+
+  interrupt-names:
+    items:
+      - const: short
+      - const: play
+
+  qcom,actuator-type:
+    description: |
+      The type of actuator attached to the hardware.
+      Allowed values are,
+        0 - HAP_TYPE_LRA
+        1 - HAP_TYPE_ERM
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [ 0, 1 ]
+    default: 0
+
+  qcom,wave-shape:
+    description: |
+      Selects the wave shape to use.
+      Allowed values are,
+        0 - HAP_WAVE_SINE
+        1 - HAP_WAVE_SQUARE
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [ 0, 1 ]
+    default: 0
+
+  qcom,play-mode:
+    description: |
+      Selects the play mode to use.
+      Allowed values are,
+        0 - HAP_PLAY_DIRECT
+        1 - HAP_PLAY_BUFFER
+        2 - HAP_PLAY_AUDIO
+        3 - HAP_PLAY_PWM
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [ 0, 1, 2, 3 ]
+    default: 2
+
+  qcom,wave-play-rate-us:
+    description: |
+      Wave sample durection in microseconds, 1/f where f
+      is the resonant frequency of the actuator.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 0
+    maximum: 20475
+
+  qcom,brake-pattern:
+    minItems: 4
+    maxItems: 4
+    description: |
+      The brake pattern are the strengths of the pattern
+      used to brake the haptics. Allowed values are,
+        0 - 0V
+        1 - Vmax/4
+        2 - Vmax/2
+        3 - Vmax
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    default: [0x3, 0x3, 0x2, 0x1]
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - qcom,wave-play-rate-us
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/spmi/spmi.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/input/qcom,spmi-haptics.h>
+
+    pmi8998_lsid1: pmic@3 {
+      compatible = "qcom,pmi8998", "qcom,spmi-pmic";
+      reg = <0x3 SPMI_USID>;
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      pmi8998_haptics: haptics@c000 {
+        compatible = "qcom,pmi8998-haptics", "qcom,spmi-haptics";
+        reg = <0xc000>;
+
+        interrupts = <0x3 0xc0 0x0 IRQ_TYPE_EDGE_BOTH>,
+                     <0x3 0xc0 0x1 IRQ_TYPE_EDGE_BOTH>;
+        interrupt-names = "short", "play";
+
+        qcom,wave-shape = <HAP_WAVE_SINE>;
+        qcom,play-mode = <HAP_PLAY_BUFFER>;
+        qcom,brake-pattern = <0x3 0x3 0x2 0x1>;
+
+        status = "disabled";
+      };
+    };
include/dt-bindings/input/qcom,spmi-haptics.h new file +32 -0
new file mode 100644
index 000000000000..14a7e7d1471e
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * This header provides constants for pmi8998 SPMI haptics options.
+ */
+
+#ifndef _DT_BINDINGS_QCOM_PMIC_SPMI_HAPTICS_
+#define _DT_BINDINGS_QCOM_PMIC_SPMI_HAPTICS_
+
+// Actuator types
+#define HAP_TYPE_LRA		0
+#define HAP_TYPE_ERM		1
+
+// LRA Wave type
+#define HAP_WAVE_SINE		0
+#define HAP_WAVE_SQUARE		1
+
+// Play modes
+#define HAP_PLAY_DIRECT		0
+#define HAP_PLAY_BUFFER		1
+#define HAP_PLAY_AUDIO		2
+#define HAP_PLAY_PWM		3
+
+#define HAP_PLAY_MAX		HAP_PLAY_PWM
+
+// Auto resonance type
+#define HAP_AUTO_RES_NONE	0
+#define HAP_AUTO_RES_ZXD	1
+#define HAP_AUTO_RES_QWD	2
+#define HAP_AUTO_RES_MAX_QWD	3
+#define HAP_AUTO_RES_ZXD_EOP	4
+
+#endif /* _DT_BINDINGS_QCOM_PMIC_SPMI_HAPTICS_ */

--
2.31.1

#5 lore raw

PATCH RESEND v2 2/6 input: add Qualcomm SPMI haptics driver

In reply to Caleb Connolly

Add support for the haptics found in pmi8998 and related PMICs. Based on the ff-memless interface. Currently this driver provides a partial implementation of hardware features.

This driver only supports LRAs (Linear Resonant Actuators) in the "buffer" mode with a single wave pattern.

---
 drivers/input/misc/Kconfig             |  12 +
 drivers/input/misc/Makefile            |   1 +
 drivers/input/misc/qcom-spmi-haptics.c | 981 +++++++++++++++++++++++++
 3 files changed, 994 insertions(+)
 create mode 100644 drivers/input/misc/qcom-spmi-haptics.c
drivers/input/misc/Kconfig +12 -0
index 498cde376981..de422aeb8e5f 100644
@@ -186,6 +186,18 @@ config INPUT_PMIC8XXX_PWRKEY
 	  To compile this driver as a module, choose M here: the
 	  module will be called pmic8xxx-pwrkey.
 
+config INPUT_QCOM_SPMI_HAPTICS
+	tristate "Qualcomm SPMI HAPTICS"
+	depends on ARCH_QCOM
+	depends on SPMI
+	select INPUT_FF_MEMLESS
+	help
+	  This option enables support for the haptics found in pmi8998 and
+	  related PMICs. Based on the ff-memless interface.
+
+	  To compile this driver as module, choose M here: the
+	  module will be called qcom_spmi_haptics.
+
 config INPUT_SPARCSPKR
 	tristate "SPARC Speaker support"
 	depends on PCI && SPARC64
drivers/input/misc/Makefile +1 -0
index f593beed7e05..bf5579f335d5 100644
@@ -65,6 +65,7 @@ obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY)	+= pmic8xxx-pwrkey.o
 obj-$(CONFIG_INPUT_POWERMATE)		+= powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER)		+= pwm-beeper.o
 obj-$(CONFIG_INPUT_PWM_VIBRA)		+= pwm-vibra.o
+obj-$(CONFIG_INPUT_QCOM_SPMI_HAPTICS)	+= qcom-spmi-haptics.o
 obj-$(CONFIG_INPUT_RAVE_SP_PWRBUTTON)	+= rave-sp-pwrbutton.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)	+= rb532_button.o
 obj-$(CONFIG_INPUT_REGULATOR_HAPTIC)	+= regulator-haptic.o
drivers/input/misc/qcom-spmi-haptics.c new file +981 -0

981 lines not on this page · raw message

--
2.31.1

maintainer
#2 lore raw

Re: [RESEND PATCH v2 1/6] dt-bindings: input: add Qualcomm SPMI haptics driver

In reply to Caleb Connolly
Quoted 10 lines · Caleb Connolly

Add bindings for qcom PMIC SPMI haptics driver.

---
 .../bindings/input/qcom,spmi-haptics.yaml     | 128 ++++++++++++++++++
 include/dt-bindings/input/qcom,spmi-haptics.h |  32 +++++
 2 files changed, 160 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml
 create mode 100644 include/dt-bindings/input/qcom,spmi-haptics.h

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:
./Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml:23:9: [warning] wrong indentation: expected 10 but found 8 (indentation)

dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/input/qcom,spmi-haptics.example.dt.yaml:0:0: /example-0/pmic@3: failed to match any schema with compatible: ['qcom,pmi8998', 'qcom,spmi-pmic'] Documentation/devicetree/bindings/input/qcom,spmi-haptics.example.dt.yaml:0:0: /example-0/pmic@3: failed to match any schema with compatible: ['qcom,pmi8998', 'qcom,spmi-pmic'] \ndoc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/1494375

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.

maintainer
#3 lore raw

Re: [RESEND PATCH v2 1/6] dt-bindings: input: add Qualcomm SPMI haptics driver

In reply to Caleb Connolly
Quoted 83 lines · Caleb Connolly

Add bindings for qcom PMIC SPMI haptics driver.

---
 .../bindings/input/qcom,spmi-haptics.yaml     | 128 ++++++++++++++++++
 include/dt-bindings/input/qcom,spmi-haptics.h |  32 +++++
 2 files changed, 160 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml
 create mode 100644 include/dt-bindings/input/qcom,spmi-haptics.h
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +67 -0
new file mode 100644
index 000000000000..8ef9b4ec3a07
@@ -0,0 +1,128 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2020 Unisoc Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/qcom,spmi-haptics.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Technologies Inc PMI8998 spmi haptics
+
+maintainers:
+  - Caleb Connolly <[email protected]>
+
+description: |
+  Qualcomm SPMI haptics is a peripheral on some QTI PMICs. It supports linear resonant
+  actuators and eccentric rotating mass type haptics commonly found in mobile devices.
+  It supports multiple sources of wave data such as an internal buffer, direct play
+  (from kernel or userspace) as well as an audio output mode.
+
+properties:
+  compatible:
+    items:
+      - enum:
+        - qcom,pmi8998-haptics
+        - qcom,pmi8996-haptics
+        - qcom,pmi8941-haptics
+      - const: qcom,spmi-haptics
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    items:
+      - description: short circuit interrupt
+      - description: play interrupt
+
+  interrupt-names:
+    items:
+      - const: short
+      - const: play
+
+  qcom,actuator-type:
+    description: |
+      The type of actuator attached to the hardware.
+      Allowed values are,
+        0 - HAP_TYPE_LRA
+        1 - HAP_TYPE_ERM
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [ 0, 1 ]
+    default: 0
+
+  qcom,wave-shape:
+    description: |
+      Selects the wave shape to use.
+      Allowed values are,
+        0 - HAP_WAVE_SINE
+        1 - HAP_WAVE_SQUARE
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [ 0, 1 ]
+    default: 0
+
+  qcom,play-mode:
+    description: |
+      Selects the play mode to use.
+      Allowed values are,
+        0 - HAP_PLAY_DIRECT
+        1 - HAP_PLAY_BUFFER
+        2 - HAP_PLAY_AUDIO

Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml line 77

Quoted 10 lines
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +10 -0
+        3 - HAP_PLAY_PWM
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [ 0, 1, 2, 3 ]
+    default: 2
+
+  qcom,wave-play-rate-us:
+    description: |
+      Wave sample durection in microseconds, 1/f where f
+      is the resonant frequency of the actuator.
+    $ref: /schemas/types.yaml#/definitions/uint32

Don't need a type for standard units.

Quoted 5 lines
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +5 -0
+    minimum: 0
+    maximum: 20475
+
+  qcom,brake-pattern:
+    minItems: 4

Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml line 92

Quoted 10 lines
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +10 -0
+    maxItems: 4
+    description: |
+      The brake pattern are the strengths of the pattern
+      used to brake the haptics. Allowed values are,
+        0 - 0V
+        1 - Vmax/4
+        2 - Vmax/2
+        3 - Vmax
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    default: [0x3, 0x3, 0x2, 0x1]

To express the constraints on all items:

items:
enum: [ 0, 1, 2, 3 ]

(items is a schema here rather than a list)

Quoted 6 lines
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +6 -0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - qcom,wave-play-rate-us

Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml line 108

Quoted 10 lines
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +10 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/spmi/spmi.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/input/qcom,spmi-haptics.h>
+
+    pmi8998_lsid1: pmic@3 {

Drop unused labels.

Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml line 109

Quoted 1 line
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +1 -0
+      compatible = "qcom,pmi8998", "qcom,spmi-pmic";

Really, this needs to be converted to schema first so we're not adding warnings.

Quoted 7 lines
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +7 -0
+      reg = <0x3 SPMI_USID>;
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      pmi8998_haptics: haptics@c000 {
+        compatible = "qcom,pmi8998-haptics", "qcom,spmi-haptics";
+        reg = <0xc000>;

Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml line 126

Quoted 10 lines
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +10 -0
+
+        interrupts = <0x3 0xc0 0x0 IRQ_TYPE_EDGE_BOTH>,
+                     <0x3 0xc0 0x1 IRQ_TYPE_EDGE_BOTH>;
+        interrupt-names = "short", "play";
+
+        qcom,wave-shape = <HAP_WAVE_SINE>;
+        qcom,play-mode = <HAP_PLAY_BUFFER>;
+        qcom,brake-pattern = <0x3 0x3 0x2 0x1>;
+
+        status = "disabled";

Don't show status in examples.

include/dt-bindings/input/qcom,spmi-haptics.h line 1

Quoted 9 lines
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +2 -0
+      };
+    };
include/dt-bindings/input/qcom,spmi-haptics.h new file +1 -0
new file mode 100644
index 000000000000..14a7e7d1471e
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0-only */

Dual license please. DT files are used elsewhere.

Quoted 36 lines
include/dt-bindings/input/qcom,spmi-haptics.h new file +31 -1
+/*
+ * This header provides constants for pmi8998 SPMI haptics options.
+ */
+
+#ifndef _DT_BINDINGS_QCOM_PMIC_SPMI_HAPTICS_
+#define _DT_BINDINGS_QCOM_PMIC_SPMI_HAPTICS_
+
+// Actuator types
+#define HAP_TYPE_LRA		0
+#define HAP_TYPE_ERM		1
+
+// LRA Wave type
+#define HAP_WAVE_SINE		0
+#define HAP_WAVE_SQUARE		1
+
+// Play modes
+#define HAP_PLAY_DIRECT		0
+#define HAP_PLAY_BUFFER		1
+#define HAP_PLAY_AUDIO		2
+#define HAP_PLAY_PWM		3
+
+#define HAP_PLAY_MAX		HAP_PLAY_PWM
+
+// Auto resonance type
+#define HAP_AUTO_RES_NONE	0
+#define HAP_AUTO_RES_ZXD	1
+#define HAP_AUTO_RES_QWD	2
+#define HAP_AUTO_RES_MAX_QWD	3
+#define HAP_AUTO_RES_ZXD_EOP	4
+
+#endif /* _DT_BINDINGS_QCOM_PMIC_SPMI_HAPTICS_ */
--

2.31.1

#4 lore raw

Re: [RESEND PATCH v2 1/6] dt-bindings: input: add Qualcomm SPMI haptics driver

Hi Rob,

Thanks a lot for your feedback.

I'm still struggling a little to get my head around schema, would you mind clarifying a few things?

Quoted 111 lines · Rob Herring
Quoted 83 lines · Caleb Connolly

Add bindings for qcom PMIC SPMI haptics driver.

---
  .../bindings/input/qcom,spmi-haptics.yaml     | 128 ++++++++++++++++++
  include/dt-bindings/input/qcom,spmi-haptics.h |  32 +++++
  2 files changed, 160 insertions(+)

create mode 100644 Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml create mode 100644 include/dt-bindings/input/qcom,spmi-haptics.h

Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +67 -0
new file mode 100644
index 000000000000..8ef9b4ec3a07
@@ -0,0 +1,128 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2020 Unisoc Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/qcom,spmi-haptics.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Technologies Inc PMI8998 spmi haptics
+
+maintainers:
+  - Caleb Connolly <[email protected]>
+
+description: |
+  Qualcomm SPMI haptics is a peripheral on some QTI PMICs. It supports linear resonant
+  actuators and eccentric rotating mass type haptics commonly found in mobile devices.
+  It supports multiple sources of wave data such as an internal buffer, direct play
+  (from kernel or userspace) as well as an audio output mode.
+
+properties:
+  compatible:
+    items:
+      - enum:
+        - qcom,pmi8998-haptics
+        - qcom,pmi8996-haptics
+        - qcom,pmi8941-haptics
+      - const: qcom,spmi-haptics
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    items:
+      - description: short circuit interrupt
+      - description: play interrupt
+
+  interrupt-names:
+    items:
+      - const: short
+      - const: play
+
+  qcom,actuator-type:
+    description: |
+      The type of actuator attached to the hardware.
+      Allowed values are,
+        0 - HAP_TYPE_LRA
+        1 - HAP_TYPE_ERM
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [ 0, 1 ]
+    default: 0
+
+  qcom,wave-shape:
+    description: |
+      Selects the wave shape to use.
+      Allowed values are,
+        0 - HAP_WAVE_SINE
+        1 - HAP_WAVE_SQUARE
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [ 0, 1 ]
+    default: 0
+
+  qcom,play-mode:
+    description: |
+      Selects the play mode to use.
+      Allowed values are,
+        0 - HAP_PLAY_DIRECT
+        1 - HAP_PLAY_BUFFER
+        2 - HAP_PLAY_AUDIO

Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml line 77

Quoted 10 lines
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +10 -0
+        3 - HAP_PLAY_PWM
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [ 0, 1, 2, 3 ]
+    default: 2
+
+  qcom,wave-play-rate-us:
+    description: |
+      Wave sample durection in microseconds, 1/f where f
+      is the resonant frequency of the actuator.
+    $ref: /schemas/types.yaml#/definitions/uint32

Don't need a type for standard units.

Quoted 5 lines
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +5 -0
+    minimum: 0
+    maximum: 20475
+
+  qcom,brake-pattern:
+    minItems: 4

Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml line 92

Quoted 10 lines
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +10 -0
+    maxItems: 4
+    description: |
+      The brake pattern are the strengths of the pattern
+      used to brake the haptics. Allowed values are,
+        0 - 0V
+        1 - Vmax/4
+        2 - Vmax/2
+        3 - Vmax
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    default: [0x3, 0x3, 0x2, 0x1]
Quoted 6 lines

To express the constraints on all items:

items:

   enum: [ 0, 1, 2, 3 ]

(items is a schema here rather than a list)

Ah, that's exactly what I was looking for! Should I replace one of the other properties with this?

Or should I just add it to the list?

Quoted 19 lines
Quoted 7 lines
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +6 -0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - qcom,wave-play-rate-us

Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml line 108

Quoted 10 lines
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +10 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/spmi/spmi.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/input/qcom,spmi-haptics.h>
+
+    pmi8998_lsid1: pmic@3 {

Drop unused labels.

Quoted 3 lines

Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml line 109

Quoted 1 line
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +1 -0
+      compatible = "qcom,pmi8998", "qcom,spmi-pmic";

Really, this needs to be converted to schema first so we're not adding warnings.

Hmm, is it ok to leave this here? I had a look at converting the spmi-pmic

bindings to schema but it's a bit beyond me in all honestly.

Quoted 20 lines
Quoted 8 lines
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +7 -0
+      reg = <0x3 SPMI_USID>;
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      pmi8998_haptics: haptics@c000 {
+        compatible = "qcom,pmi8998-haptics", "qcom,spmi-haptics";
+        reg = <0xc000>;

Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml line 126

Quoted 10 lines
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +10 -0
+
+        interrupts = <0x3 0xc0 0x0 IRQ_TYPE_EDGE_BOTH>,
+                     <0x3 0xc0 0x1 IRQ_TYPE_EDGE_BOTH>;
+        interrupt-names = "short", "play";
+
+        qcom,wave-shape = <HAP_WAVE_SINE>;
+        qcom,play-mode = <HAP_PLAY_BUFFER>;
+        qcom,brake-pattern = <0x3 0x3 0x2 0x1>;
+
+        status = "disabled";

Don't show status in examples.

Quoted 10 lines

include/dt-bindings/input/qcom,spmi-haptics.h line 1

Quoted 9 lines
Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml new file +2 -0
+      };
+    };
include/dt-bindings/input/qcom,spmi-haptics.h new file +1 -0
new file mode 100644
index 000000000000..14a7e7d1471e
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0-only */

Dual license please. DT files are used elsewhere.

Will do.

Quoted 29 lines
Quoted 29 lines
include/dt-bindings/input/qcom,spmi-haptics.h new file +28 -0
+/*
+ * This header provides constants for pmi8998 SPMI haptics options.
+ */
+
+#ifndef _DT_BINDINGS_QCOM_PMIC_SPMI_HAPTICS_
+#define _DT_BINDINGS_QCOM_PMIC_SPMI_HAPTICS_
+
+// Actuator types
+#define HAP_TYPE_LRA		0
+#define HAP_TYPE_ERM		1
+
+// LRA Wave type
+#define HAP_WAVE_SINE		0
+#define HAP_WAVE_SQUARE		1
+
+// Play modes
+#define HAP_PLAY_DIRECT		0
+#define HAP_PLAY_BUFFER		1
+#define HAP_PLAY_AUDIO		2
+#define HAP_PLAY_PWM		3
+
+#define HAP_PLAY_MAX		HAP_PLAY_PWM
+
+// Auto resonance type
+#define HAP_AUTO_RES_NONE	0
+#define HAP_AUTO_RES_ZXD	1
+#define HAP_AUTO_RES_QWD	2
+#define HAP_AUTO_RES_MAX_QWD	3
Quoted 8 lines
Quoted 8 lines
include/dt-bindings/input/qcom,spmi-haptics.h new file +3 -1
+#define HAP_AUTO_RES_ZXD_EOP	4
+
+#endif /* _DT_BINDINGS_QCOM_PMIC_SPMI_HAPTICS_ */
--

2.31.1

Kind Regards,

Caleb