2023-04-30 18:22:50

by Luca Weiss

[permalink] [raw]
Subject: [PATCH 0/5] Improvements for drv260x driver and add to Huawei Watch

Clean up some issues with the driver I've noticed while working on it,
then fix the magnitude handling which previously resulted the driver
discarding the upper 8 bits of the magnitude value, and finally we can
add the drv260x to the APQ8026 Huawei Watch.

While the "fix magnitude handling" commit technically changes behavior
and could change behavior of existing user space applications that deal
with this quirky behavior, it's definitely not correct and results in
very unexpected behavior if the user space doesn't look out for it
(meaning only use 0x00-0xFF magnitude, and also know that the magnitude
was interpreted as signed value, see more details in the commit message
there).

There's currently only one other upstream user of the driver,
qcom/msm8996-xiaomi-gemini where I've added the dts authors to this
patch series (Raffaele & Yassine) and some tests on that device would be
nice since it's operating in LRA mode, mine does in ERM mode.

Signed-off-by: Luca Weiss <[email protected]>
---
Luca Weiss (5):
Input: drv260x - fix typo in register value define
Input: drv260x - sleep between polling GO bit
Input: drv260x - remove unused .reg_defaults
Input: drv260x - fix magnitude handling
ARM: dts: qcom: apq8026-huawei-sturgeon: Add vibrator

arch/arm/boot/dts/qcom-apq8026-huawei-sturgeon.dts | 28 +++++++++++
drivers/input/misc/drv260x.c | 56 ++++------------------
2 files changed, 37 insertions(+), 47 deletions(-)
---
base-commit: fa55d47c433364df7361fd4f9b169b5845b06914
change-id: 20230430-drv260x-improvements-e218894a0c5c

Best regards,
--
Luca Weiss <[email protected]>


2023-04-30 18:24:19

by Luca Weiss

[permalink] [raw]
Subject: [PATCH 1/5] Input: drv260x - fix typo in register value define

ANANLOG should be ANALOG. Fix the typo.

Fixes: 7132fe4f5687 ("Input: drv260x - add TI drv260x haptics driver")
Signed-off-by: Luca Weiss <[email protected]>
---
drivers/input/misc/drv260x.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/input/misc/drv260x.c b/drivers/input/misc/drv260x.c
index 8a9ebfc04a2d..e95c4e775b5d 100644
--- a/drivers/input/misc/drv260x.c
+++ b/drivers/input/misc/drv260x.c
@@ -149,7 +149,7 @@

/* Control 3 Register */
#define DRV260X_LRA_OPEN_LOOP (1 << 0)
-#define DRV260X_ANANLOG_IN (1 << 1)
+#define DRV260X_ANALOG_IN (1 << 1)
#define DRV260X_LRA_DRV_MODE (1 << 2)
#define DRV260X_RTP_UNSIGNED_DATA (1 << 3)
#define DRV260X_SUPPLY_COMP_DIS (1 << 4)
@@ -322,7 +322,7 @@ static const struct reg_sequence drv260x_lra_init_regs[] = {
DRV260X_BEMF_GAIN_3 },
{ DRV260X_CTRL1, DRV260X_STARTUP_BOOST },
{ DRV260X_CTRL2, DRV260X_SAMP_TIME_250 },
- { DRV260X_CTRL3, DRV260X_NG_THRESH_2 | DRV260X_ANANLOG_IN },
+ { DRV260X_CTRL3, DRV260X_NG_THRESH_2 | DRV260X_ANALOG_IN },
{ DRV260X_CTRL4, DRV260X_AUTOCAL_TIME_500MS },
};


--
2.40.1

2023-04-30 18:24:26

by Luca Weiss

[permalink] [raw]
Subject: [PATCH 3/5] Input: drv260x - remove unused .reg_defaults

Since the driver has disabled regmap caching with REGCACHE_NONE, it's
warning us that we provide defaults that are not used. Remove them.

[ 0.561159] drv260x-haptics 0-005a: No cache used with register defaults set!

Fixes: 7132fe4f5687 ("Input: drv260x - add TI drv260x haptics driver")
Signed-off-by: Luca Weiss <[email protected]>
---
drivers/input/misc/drv260x.c | 40 ----------------------------------------
1 file changed, 40 deletions(-)

diff --git a/drivers/input/misc/drv260x.c b/drivers/input/misc/drv260x.c
index 884d43eb4b61..a7e3120bdc13 100644
--- a/drivers/input/misc/drv260x.c
+++ b/drivers/input/misc/drv260x.c
@@ -193,44 +193,6 @@ struct drv260x_data {
int overdrive_voltage;
};

-static const struct reg_default drv260x_reg_defs[] = {
- { DRV260X_STATUS, 0xe0 },
- { DRV260X_MODE, 0x40 },
- { DRV260X_RT_PB_IN, 0x00 },
- { DRV260X_LIB_SEL, 0x00 },
- { DRV260X_WV_SEQ_1, 0x01 },
- { DRV260X_WV_SEQ_2, 0x00 },
- { DRV260X_WV_SEQ_3, 0x00 },
- { DRV260X_WV_SEQ_4, 0x00 },
- { DRV260X_WV_SEQ_5, 0x00 },
- { DRV260X_WV_SEQ_6, 0x00 },
- { DRV260X_WV_SEQ_7, 0x00 },
- { DRV260X_WV_SEQ_8, 0x00 },
- { DRV260X_GO, 0x00 },
- { DRV260X_OVERDRIVE_OFF, 0x00 },
- { DRV260X_SUSTAIN_P_OFF, 0x00 },
- { DRV260X_SUSTAIN_N_OFF, 0x00 },
- { DRV260X_BRAKE_OFF, 0x00 },
- { DRV260X_A_TO_V_CTRL, 0x05 },
- { DRV260X_A_TO_V_MIN_INPUT, 0x19 },
- { DRV260X_A_TO_V_MAX_INPUT, 0xff },
- { DRV260X_A_TO_V_MIN_OUT, 0x19 },
- { DRV260X_A_TO_V_MAX_OUT, 0xff },
- { DRV260X_RATED_VOLT, 0x3e },
- { DRV260X_OD_CLAMP_VOLT, 0x8c },
- { DRV260X_CAL_COMP, 0x0c },
- { DRV260X_CAL_BACK_EMF, 0x6c },
- { DRV260X_FEEDBACK_CTRL, 0x36 },
- { DRV260X_CTRL1, 0x93 },
- { DRV260X_CTRL2, 0xfa },
- { DRV260X_CTRL3, 0xa0 },
- { DRV260X_CTRL4, 0x20 },
- { DRV260X_CTRL5, 0x80 },
- { DRV260X_LRA_LOOP_PERIOD, 0x33 },
- { DRV260X_VBAT_MON, 0x00 },
- { DRV260X_LRA_RES_PERIOD, 0x00 },
-};
-
#define DRV260X_DEF_RATED_VOLT 0x90
#define DRV260X_DEF_OD_CLAMP_VOLT 0x90

@@ -453,8 +415,6 @@ static const struct regmap_config drv260x_regmap_config = {
.val_bits = 8,

.max_register = DRV260X_MAX_REG,
- .reg_defaults = drv260x_reg_defs,
- .num_reg_defaults = ARRAY_SIZE(drv260x_reg_defs),
.cache_type = REGCACHE_NONE,
};


--
2.40.1

2023-04-30 18:24:39

by Luca Weiss

[permalink] [raw]
Subject: [PATCH 5/5] ARM: dts: qcom: apq8026-huawei-sturgeon: Add vibrator

The watch has a DRV2605 for haptics. Add a node for it based on the
values found in the downstream board file.

Signed-off-by: Luca Weiss <[email protected]>
---
arch/arm/boot/dts/qcom-apq8026-huawei-sturgeon.dts | 28 ++++++++++++++++++++++
1 file changed, 28 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-apq8026-huawei-sturgeon.dts b/arch/arm/boot/dts/qcom-apq8026-huawei-sturgeon.dts
index d64096028ab1..eb73b992a696 100644
--- a/arch/arm/boot/dts/qcom-apq8026-huawei-sturgeon.dts
+++ b/arch/arm/boot/dts/qcom-apq8026-huawei-sturgeon.dts
@@ -7,6 +7,7 @@

#include "qcom-msm8226.dtsi"
#include "qcom-pm8226.dtsi"
+#include <dt-bindings/input/ti-drv260x.h>

/delete-node/ &adsp_region;

@@ -68,6 +69,26 @@ &adsp {
status = "okay";
};

+&blsp1_i2c2 {
+ clock-frequency = <384000>;
+
+ status = "okay";
+
+ vibrator@5a {
+ compatible = "ti,drv2605";
+ reg = <0x5a>;
+ enable-gpios = <&tlmm 60 GPIO_ACTIVE_HIGH>;
+
+ mode = <DRV260X_ERM_MODE>;
+ library-sel = <DRV260X_ERM_LIB_D>;
+ vib-rated-mv = <2765>;
+ vib-overdrive-mv = <3525>;
+
+ pinctrl-0 = <&vibrator_default_state>;
+ pinctrl-names = "default";
+ };
+};
+
&blsp1_i2c5 {
clock-frequency = <384000>;

@@ -347,6 +368,13 @@ reset-pins {
};
};

+ vibrator_default_state: vibrator-default-state {
+ pins = "gpio59", "gpio60";
+ function = "gpio";
+ drive-strength = <2>;
+ bias-pull-down;
+ };
+
wlan_hostwake_default_state: wlan-hostwake-default-state {
pins = "gpio66";
function = "gpio";

--
2.40.1

2023-05-02 00:31:23

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH 0/5] Improvements for drv260x driver and add to Huawei Watch

On Sun, Apr 30, 2023 at 08:20:52PM +0200, Luca Weiss wrote:
> Clean up some issues with the driver I've noticed while working on it,
> then fix the magnitude handling which previously resulted the driver
> discarding the upper 8 bits of the magnitude value, and finally we can
> add the drv260x to the APQ8026 Huawei Watch.
>
> While the "fix magnitude handling" commit technically changes behavior
> and could change behavior of existing user space applications that deal
> with this quirky behavior, it's definitely not correct and results in
> very unexpected behavior if the user space doesn't look out for it
> (meaning only use 0x00-0xFF magnitude, and also know that the magnitude
> was interpreted as signed value, see more details in the commit message
> there).
>
> There's currently only one other upstream user of the driver,
> qcom/msm8996-xiaomi-gemini where I've added the dts authors to this
> patch series (Raffaele & Yassine) and some tests on that device would be
> nice since it's operating in LRA mode, mine does in ERM mode.
>
> Signed-off-by: Luca Weiss <[email protected]>
> ---
> Luca Weiss (5):
> Input: drv260x - fix typo in register value define
> Input: drv260x - sleep between polling GO bit
> Input: drv260x - remove unused .reg_defaults
> Input: drv260x - fix magnitude handling
> ARM: dts: qcom: apq8026-huawei-sturgeon: Add vibrator

Applied patches 1-4.

Thanks.

--
Dmitry

2023-05-02 10:24:52

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 5/5] ARM: dts: qcom: apq8026-huawei-sturgeon: Add vibrator



On 30.04.2023 20:20, Luca Weiss wrote:
> The watch has a DRV2605 for haptics. Add a node for it based on the
> values found in the downstream board file.
>
> Signed-off-by: Luca Weiss <[email protected]>
> ---
Reviewed-by: Konrad Dybcio <[email protected]>

Konrad
> arch/arm/boot/dts/qcom-apq8026-huawei-sturgeon.dts | 28 ++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/arch/arm/boot/dts/qcom-apq8026-huawei-sturgeon.dts b/arch/arm/boot/dts/qcom-apq8026-huawei-sturgeon.dts
> index d64096028ab1..eb73b992a696 100644
> --- a/arch/arm/boot/dts/qcom-apq8026-huawei-sturgeon.dts
> +++ b/arch/arm/boot/dts/qcom-apq8026-huawei-sturgeon.dts
> @@ -7,6 +7,7 @@
>
> #include "qcom-msm8226.dtsi"
> #include "qcom-pm8226.dtsi"
> +#include <dt-bindings/input/ti-drv260x.h>
>
> /delete-node/ &adsp_region;
>
> @@ -68,6 +69,26 @@ &adsp {
> status = "okay";
> };
>
> +&blsp1_i2c2 {
> + clock-frequency = <384000>;
> +
> + status = "okay";
> +
> + vibrator@5a {
> + compatible = "ti,drv2605";
> + reg = <0x5a>;
> + enable-gpios = <&tlmm 60 GPIO_ACTIVE_HIGH>;
> +
> + mode = <DRV260X_ERM_MODE>;
> + library-sel = <DRV260X_ERM_LIB_D>;
> + vib-rated-mv = <2765>;
> + vib-overdrive-mv = <3525>;
> +
> + pinctrl-0 = <&vibrator_default_state>;
> + pinctrl-names = "default";
> + };
> +};
> +
> &blsp1_i2c5 {
> clock-frequency = <384000>;
>
> @@ -347,6 +368,13 @@ reset-pins {
> };
> };
>
> + vibrator_default_state: vibrator-default-state {
> + pins = "gpio59", "gpio60";
> + function = "gpio";
> + drive-strength = <2>;
> + bias-pull-down;
> + };
> +
> wlan_hostwake_default_state: wlan-hostwake-default-state {
> pins = "gpio66";
> function = "gpio";
>

2023-05-27 01:05:41

by Bjorn Andersson

[permalink] [raw]
Subject: Re: (subset) [PATCH 0/5] Improvements for drv260x driver and add to Huawei Watch

On Sun, 30 Apr 2023 20:20:52 +0200, Luca Weiss wrote:
> Clean up some issues with the driver I've noticed while working on it,
> then fix the magnitude handling which previously resulted the driver
> discarding the upper 8 bits of the magnitude value, and finally we can
> add the drv260x to the APQ8026 Huawei Watch.
>
> While the "fix magnitude handling" commit technically changes behavior
> and could change behavior of existing user space applications that deal
> with this quirky behavior, it's definitely not correct and results in
> very unexpected behavior if the user space doesn't look out for it
> (meaning only use 0x00-0xFF magnitude, and also know that the magnitude
> was interpreted as signed value, see more details in the commit message
> there).
>
> [...]

Applied, thanks!

[5/5] ARM: dts: qcom: apq8026-huawei-sturgeon: Add vibrator
commit: ad318f9ce5a2e815816bfcf7f187a3ac32905523

Best regards,
--
Bjorn Andersson <[email protected]>