input: Introduce support for SPMI haptics found on Qcom PMICs
Subsystems (5)
v3 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 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 (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 + .../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 | 981 ++++++++++++++++++ include/dt-bindings/input/qcom,spmi-haptics.h | 32 + 9 files changed, 1187 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.32.0
PATCH v3 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
@@ -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 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 play rate in microseconds, 1/f where f + is the resonant frequency of the actuator. + minimum: 0 + maximum: 20475 + + qcom,brake-pattern: + minItems: 4 + maxItems: 4 + description: | + The brake pattern is an array of amplitudes + 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] + items: + enum: [ 0, 1, 2, 3 ] + +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> + + 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,wave-play-rate-us = <4255>; + qcom,play-mode = <HAP_PLAY_BUFFER>; + qcom,brake-pattern = <0x3 0x3 0x2 0x1>; + }; + };
include/dt-bindings/input/qcom,spmi-haptics.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-2-Clause) */ +/* +* This header provides constants for QCOM SPMI haptics hardware configuration. +*/ + +#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.32.0
Rob Herring
maintainerRe: [PATCH v3 1/6] dt-bindings: input: add Qualcomm SPMI haptics driver
Quoted 10 lines · Caleb Connolly
Add bindings for qcom PMIC SPMI haptics driver.
Signed-off-by Caleb Connolly <[email protected]>--- .../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:
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']
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/1517351
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.
PATCH v3 2/6 input: add Qualcomm SPMI haptics driver
In reply to Caleb ConnollyAdd 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
@@ -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
@@ -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.32.0
kernel test robot
build botRe: [PATCH v3 2/6] input: add Qualcomm SPMI haptics driver
Thank you for the patch! Perhaps something to improve:
Hi Caleb,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on robh/for-next]
[also build test WARNING on input/next v5.14-rc6 next-20210816] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Caleb-Connolly/input-Introduce-support-for-SPMI-haptics-found-on-Qcom-PMICs/20210817-062200 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next config: arm64-allyesconfig (attached as .config) compiler: aarch64-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/4fe3986969c516117a071eb5f9df141c6fc95b69
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Caleb-Connolly/input-Introduce-support-for-SPMI-haptics-found-on-Qcom-PMICs/20210817-062200 git checkout 4fe3986969c516117a071eb5f9df141c6fc95b69
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/input/misc/
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
drivers/input/misc/qcom-spmi-haptics.c:196: warning: Function parameter or member 'haptics_input_dev' not described in 'spmi_haptics' drivers/input/misc/qcom-spmi-haptics.c:634: warning: Excess function parameter 'enable' description in 'spmi_haptics_enable'
>> drivers/input/misc/qcom-spmi-haptics.c:679: warning: expecting prototype for spmi_haptics_enable(). Prototype was for spmi_haptics_disable() instead
vim +679 drivers/input/misc/qcom-spmi-haptics.c
671
672 /**
673 * spmi_haptics_enable - handler to start/stop vibration
674 * @haptics: pointer to haptics struct
675 * @enable: state to set
676 * Returns: 0 on success, < 0 on failure
677 */
678 static int spmi_haptics_disable(struct spmi_haptics *haptics)
> 679 { 680 int ret;
681
682 mutex_lock(&haptics->play_lock);
683
684 ret = spmi_haptics_write_play_control(haptics, HAP_STOP);
685 if (ret < 0) {
686 dev_err(haptics->dev, "Error disabling play, ret=%d\n", ret);
687 goto out;
688 }
689
690 ret = spmi_haptics_module_enable(haptics, false);
691 if (ret < 0) {
692 dev_err(haptics->dev, "Error disabling module, ret=%d\n", ret);
693 goto out;
694 }
695
696 out:
697 mutex_unlock(&haptics->play_lock);
698 return ret;
699 }
700
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH v3 3/6 arm64: dts: qcom: pmi8998: introduce spmi haptics
In reply to Caleb ConnollyAdd bindings for Qualcomm SPMI haptics on platforms using pmi8998.
--- arch/arm64/boot/dts/qcom/pmi8998.dtsi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/qcom/pmi8998.dtsi +16 -0
@@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 +#include <dt-bindings/input/qcom,spmi-haptics.h> #include <dt-bindings/interrupt-controller/irq.h> #include <dt-bindings/spmi/spmi.h>
@@ -41,5 +42,20 @@ lab: lab { interrupt-names = "sc-err", "ocp"; }; }; + + 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"; + }; }; };
--
2.32.0
PATCH v3 4/6 arm64: dts: qcom: sdm845-oneplus-common: add haptics
In reply to Caleb ConnollyEnable the pmi8998 SPMI haptics driver and configure the play rate for the hardware.
--- arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi +6 -0
@@ -441,6 +441,12 @@ pinconf { }; }; +&pmi8998_haptics { + status = "okay"; + + qcom,wave-play-rate-us = <4255>; +}; + &qupv3_id_1 { status = "okay"; };
--
2.32.0
PATCH v3 5/6 arm64: dts: qcom: sdm845-xiaomi-beryllium: add haptics
In reply to Caleb ConnollyFrom: Joel Selvaraj <[email protected]>
Enable the pmi8998 SPMI haptics driver and configure the play rate for the hardware.
--- arch/arm64/boot/dts/qcom/sdm845-xiaomi-beryllium.dts | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/qcom/sdm845-xiaomi-beryllium.dts +5 -0
@@ -335,6 +335,11 @@ dai@2 { }; }; +&pmi8998_haptics { + status = "okay"; + qcom,wave-play-rate-us = <4878>; +}; + &qupv3_id_0 { status = "okay"; };
--
2.32.0
PATCH v3 6/6 arm64: dts: qcom: msm8998-oneplus-common: Enable PMI8998 haptics
In reply to Caleb ConnollyFrom: Jami Kettunen <[email protected]>
The OnePlus 5 and 5T both have a haptics engine connected to PMI8998.
--- arch/arm64/boot/dts/qcom/msm8998-oneplus-common.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/qcom/msm8998-oneplus-common.dtsi +6 -0
@@ -257,6 +257,12 @@ pinconf { }; }; +&pmi8998_haptics { + status = "okay"; + + qcom,wave-play-rate-us = <4255>; +}; + &qusb2phy { status = "okay";
--
2.32.0