Skip to content

Commit

Permalink
Add ERM actuator support in QCOM spmi-haptics driver and enable it fo…
Browse files Browse the repository at this point in the history
…r pmi8950
  • Loading branch information
archeYR committed Nov 22, 2023
1 parent 39e2ba2 commit c7a641e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 14 deletions.
4 changes: 4 additions & 0 deletions arch/arm64/boot/dts/qcom/msm8937-lenovo-l38011.dts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@
};
};

&pmi8950_haptics {
status = "okay";
};

&rpm_requests {
regulators-0 {
compatible = "qcom,rpm-pm8937-regulators";
Expand Down
19 changes: 19 additions & 0 deletions arch/arm64/boot/dts/qcom/pmi8950.dtsi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2019, AngeloGioacchino Del Regno <[email protected]>

#include <dt-bindings/input/qcom,spmi-haptics.h>
#include <dt-bindings/iio/qcom,spmi-vadc.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/spmi/spmi.h>
Expand Down Expand Up @@ -108,5 +109,23 @@

status = "disabled";
};

pmi8950_haptics: haptics@c000 {
compatible = "qcom,pmi8941-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,actuator-type = <HAP_TYPE_ERM>;
qcom,wave-shape = <HAP_WAVE_SQUARE>;

/* Downstream defines direct play mode */
qcom,play-mode = <HAP_PLAY_BUFFER>;
qcom,brake-pattern = <0x3 0x3 0x0 0x0>;

status = "disabled";
};
};
};
38 changes: 24 additions & 14 deletions drivers/input/misc/qcom-spmi-haptics.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,19 +528,29 @@ static int spmi_haptics_init(struct spmi_haptics *haptics)
if (ret < 0)
return ret;

/*
* Configure auto resonance
* see spmi_haptics_lra_auto_res_config downstream
* This is greatly simplified.
*/
val = FIELD_PREP(LRA_RES_CAL_MASK, ilog2(32 / HAP_RES_CAL_PERIOD_MIN)) |
FIELD_PREP(LRA_AUTO_RES_MODE_MASK, HAP_AUTO_RES_ZXD_EOP) |
FIELD_PREP(LRA_HIGH_Z_MASK, 1);

mask = LRA_AUTO_RES_MODE_MASK | LRA_HIGH_Z_MASK | LRA_RES_CAL_MASK;

ret = spmi_haptics_write_masked(haptics, haptics->base + HAP_LRA_AUTO_RES_REG,
mask, val);
if (haptics->actuator_type == HAP_TYPE_LRA)
{
/*
* Configure auto resonance
* see spmi_haptics_lra_auto_res_config downstream
* This is greatly simplified.
*/
val = FIELD_PREP(LRA_RES_CAL_MASK, ilog2(32 / HAP_RES_CAL_PERIOD_MIN)) |
FIELD_PREP(LRA_AUTO_RES_MODE_MASK, HAP_AUTO_RES_ZXD_EOP) |
FIELD_PREP(LRA_HIGH_Z_MASK, 1);

mask = LRA_AUTO_RES_MODE_MASK | LRA_HIGH_Z_MASK | LRA_RES_CAL_MASK;

ret = spmi_haptics_write_masked(haptics, haptics->base + HAP_LRA_AUTO_RES_REG,
mask, val);
}
else
{
/* Disable auto resonance */
val = HAP_AUTO_RES_NONE;
ret = spmi_haptics_write(haptics, haptics->base + HAP_LRA_AUTO_RES_REG,
&val, 1);
}

/* Configure the PLAY MODE register */
ret = spmi_haptics_write_play_mode(haptics);
Expand Down Expand Up @@ -817,7 +827,7 @@ static int spmi_haptics_probe(struct platform_device *pdev)
haptics->actuator_type = HAP_TYPE_LRA;
ret = of_property_read_u32(node, "qcom,actuator-type", &val);
if (!ret) {
if (val != HAP_TYPE_LRA) {
if (val != HAP_TYPE_LRA && val != HAP_TYPE_ERM) {
dev_err(&pdev->dev, "qcom,actuator-type (%d) isn't supported\n", val);
ret = -EINVAL;
goto register_fail;
Expand Down

0 comments on commit c7a641e

Please sign in to comment.