Re: [PATCH 1/4] dt-bindings: input: add Qualcomm QPNP haptics driver

From: Bjorn Andersson
Date: Sun Jun 13 2021 - 00:24:58 EST


On Sat 12 Jun 15:54 CDT 2021, Caleb Connolly wrote:

> Add bindings for pmi8998 qpnp haptics driver.
>
> Signed-off-by: Caleb Connolly <caleb@xxxxxxxxxxxxx>
> ---
> .../bindings/input/qcom,qpnp-haptics.yaml | 123 ++++++++++++++++++
> include/dt-bindings/input/qcom,qpnp-haptics.h | 31 +++++
> 2 files changed, 154 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/input/qcom,qpnp-haptics.yaml
> create mode 100644 include/dt-bindings/input/qcom,qpnp-haptics.h
>
> diff --git a/Documentation/devicetree/bindings/input/qcom,qpnp-haptics.yaml b/Documentation/devicetree/bindings/input/qcom,qpnp-haptics.yaml
> new file mode 100644
> index 000000000000..81dd8d6321f0
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/qcom,qpnp-haptics.yaml
> @@ -0,0 +1,123 @@
> +# 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,qpnp-haptics.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Qualcomm Technologies Inc PMI8998 QPNP haptics
> +
> +maintainers:
> + - Caleb Connolly <caleb@xxxxxxxxxxxxx>
> +
> +description: |
> + QPNP (Qualcomm Technologies, Inc. Plug N Play) Haptics is a peripheral on some
> + QTI PMICs. It supports linear resonant actuators commonly found in mobile devices.

Please avoid the Plug'n Play naming, just go with Qualcomm SPMI Haptics

> +
> +properties:
> + compatible:
> + enum:
> + - qcom,qpnp-haptics

qcom,spmi-haptics

But could we also have some pmic-specific compatibles in the binding?
Even though we might not need them in the driver today.

> +
> + reg:
> + maxItems: 1
> +
> + interrupts:
> + minItems: 2

I don't think you need minItems, when you list the "items"

> + items:
> + - description: short circuit interrupt
> + - description: play interrupt
> +
> + interrupt-names:
> + minItems: 2
> + 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

It's also maxItems: 4, right?

> + 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,qpnp-haptics.h>

Would be nice with a blank line here.

> + pmi8998_lsid1: pmic@3 {
> + compatible = "qcom,pmi8998", "qcom,spmi-pmic";
> + reg = <0x3 SPMI_USID>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + qpnp_haptics: qcom,haptics@c000 {

No "qcom," in the node name please.

> + compatible = "qcom,qpnp-haptics";
> + reg = <0xc000 0x100>;

With #size-cells = <0> this means that you have 2 regs, but binding says
that you may only have one.

> +
> + interrupts = <0x3 0xc0 0x0 IRQ_TYPE_EDGE_BOTH>,
> + <0x3 0xc0 0x1 IRQ_TYPE_EDGE_BOTH>;

I don't think the '<' on those two lines are lining up.

Regards,
Bjorn

> + interrupt-names = "short", "play";
> +
> + qcom,actuator-type = <HAP_TYPE_LRA>;
> + qcom,wave-shape = <HAP_WAVE_SINE>;
> + qcom,play-mode = <HAP_PLAY_BUFFER>;
> + qcom,brake-pattern = <0x3 0x3 0x2 0x1>;
> +
> + qcom,wave-play-rate-us = <4255>;
> + };
> + };
> diff --git a/include/dt-bindings/input/qcom,qpnp-haptics.h b/include/dt-bindings/input/qcom,qpnp-haptics.h
> new file mode 100644
> index 000000000000..bfbec041484c
> --- /dev/null
> +++ b/include/dt-bindings/input/qcom,qpnp-haptics.h
> @@ -0,0 +1,31 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * This header provides constants for pmi8998 qpnp haptics options.
> + */
> +
> +#ifndef _DT_BINDINGS_QCOM_PMIC_QPNP_HAPTICS_
> +#define _DT_BINDINGS_QCOM_PMIC_QPNP_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
> +
> +#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_QPNP_HAPTICS_ */
> --
> 2.31.1
>
>