Skip to contentSkip to conversation

input: introduce support for Qualcomm SPMI haptics

PATCH Superseded Caleb Connolly 2 participants 4 messages Oct 10, 2022

Subsystems (4)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover input: introduce support for Qualcomm SPMI haptics

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.

Changes since v4:
- Significant rewrite and cleanup
- switch to dev_err_probe()
- Run through clang-format

Changes since v3:
- Adjust example DTS to avoid creating new warnings in dt_binding_check
- Address warnings from kernel test robot.

Changes since v2:
- Addressed Rob's comments on dt-bindings (I'm not sure what to do about the pmic compatible?)
- Fixed some typos

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 (2):
dt-bindings: input: add Qualcomm SPMI haptics driver
input: add Qualcomm SPMI haptics driver

 .../bindings/input/qcom,spmi-haptics.yaml     | 123 ++++
 drivers/input/misc/Kconfig                    |  15 +
 drivers/input/misc/Makefile                   |   1 +
 drivers/input/misc/qcom-spmi-haptics.c        | 674 ++++++++++++++++++
 include/dt-bindings/input/qcom,spmi-haptics.h |  32 +
 5 files changed, 845 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/qcom,spmi-haptics.yaml
 create mode 100644 drivers/input/misc/qcom-spmi-haptics.c
 create mode 100644 include/dt-bindings/input/qcom,spmi-haptics.h

--
2.38.0

#1 lore raw

PATCH v5 1/2 dt-bindings: input: document Qualcomm PMI8998 haptics driver

Add bindings for qcom PMIC PMI8998 haptics driver.

---
 .../bindings/input/qcom,pmi8998-haptics.yaml  | 72 +++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/qcom,pmi8998-haptics.yaml
Documentation/devicetree/bindings/input/qcom,pmi8998-haptics.yaml new file +72 -0
new file mode 100644
index 000000000000..cdffe893c77a
@@ -0,0 +1,72 @@
+# 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 PMI8998/PM660 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,pm660-charger
+          - qcom,pmi8996-haptics
+          - qcom,pmi8941-haptics
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 2
+
+  interrupt-names:
+    items:
+      - const: short
+      - const: play
+
+  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
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - qcom,wave-play-rate-us
+
+additionalProperties: false
+
+examples:
+  - |
+      #include <dt-bindings/interrupt-controller/irq.h>
+
+      spmi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        pmi8998_haptics: haptics@c000 {
+          compatible = "qcom,pmi8998-haptics";
+          reg = <0xc000>;
+
+          interrupts = <0x3 0xc0 0x0 IRQ_TYPE_EDGE_BOTH>,
+                      <0x3 0xc0 0x1 IRQ_TYPE_EDGE_BOTH>;
+          interrupt-names = "short", "play";
+
+          qcom,wave-play-rate-us = <4255>;
+        };
+      };

--
2.38.0

#2 lore raw

Re: [PATCH v5 1/2] dt-bindings: input: document Qualcomm PMI8998 haptics driver

Le lundi 10 octobre 2022 à 16:18 +0000, Caleb Connolly a écrit :

Quoted 46 lines

Add bindings for qcom PMIC PMI8998 haptics driver.

---
 .../bindings/input/qcom,pmi8998-haptics.yaml  | 72 +++++++++++++++++++

 1 file changed, 72 insertions(+)

 create mode 100644 Documentation/devicetree/bindings/input/qcom,pmi8998-haptics.yaml

Documentation/devicetree/bindings/input/qcom,pmi8998-haptics.yaml new file +31 -0
new file mode 100644
index 000000000000..cdffe893c77a
@@ -0,0 +1,72 @@
+# 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 PMI8998/PM660 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,pm660-charger
+          - qcom,pmi8996-haptics
+          - qcom,pmi8941-haptics
+
+  reg:
+    maxItems: 1
+
+  interrupts:

Documentation/devicetree/bindings/input/qcom,pmi8998-haptics.yaml line 41

Quoted 10 lines
Documentation/devicetree/bindings/input/qcom,pmi8998-haptics.yaml new file +10 -0
+    maxItems: 2
+
+  interrupt-names:
+    items:
+      - const: short
+      - const: play
+
+  qcom,wave-play-rate-us:
+    description: |
+      Wave sample durection in microseconds, 1/f where f

duration, I guess ?

#3 lore raw

PATCH v5 2/2 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                |  15 +
 drivers/input/misc/Makefile               |   1 +
 drivers/input/misc/qcom-pmi8998-haptics.c | 690 ++++++++++++++++++++++
 3 files changed, 706 insertions(+)
 create mode 100644 drivers/input/misc/qcom-pmi8998-haptics.c
drivers/input/misc/Kconfig +15 -0
index a18ab7358d8f..c3b59ea23144 100644
@@ -186,6 +186,21 @@ config INPUT_PMIC8XXX_PWRKEY
 	  To compile this driver as a module, choose M here: the
 	  module will be called pmic8xxx-pwrkey.
 
+config INPUT_QCOM_PMI8998_HAPTICS
+	tristate "Qualcomm SPMI HAPTICS"
+	depends on ARCH_QCOM
+	depends on MFD_PM8XXX || MFD_SPMI_PMIC
+	select INPUT_FF_MEMLESS
+	help
+	  This option enables support for the haptics found in pmi8998 and
+	  related PMICs. Based on the ff-memless interface.
+
+	  This driver is for hardware too new for the INPUT_PM8XXX_VIBRATOR
+	  driver.
+
+	  To compile this driver as module, choose M here: the
+	  module will be called qcom_pmi8998_haptics.
+
 config INPUT_SPARCSPKR
 	tristate "SPARC Speaker support"
 	depends on PCI && SPARC64
drivers/input/misc/Makefile +1 -0
index 28dfc444f0a9..039d0a97f2f4 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_PMI8998_HAPTICS)+= qcom-pmi8998-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-pmi8998-haptics.c new file +690 -0

690 lines not on this page · raw message

--
2.38.0