From e773cf38b84636c91480ea428a803067da1d3cc9 Mon Sep 17 00:00:00 2001 From: Kiran Gunda Date: Fri, 25 Jun 2021 12:12:56 +0530 Subject: [PATCH] input: qcom-hv-haptics: Toggle RC_CAL_EN mode only for PM8350B The incorrect first cycle vibration issue is applicable only for PM8350B PMIC. Hence, make the SW W/A to toggle the CAL_EN mode from disabled to auto mode specific for PM8350B PMIC. Introduce a "wa_flags" variable to handle the SW W/A in a cleaner way. Change-Id: I8f0c31fd21681274081a4d58d589b4ed9a188f34 Signed-off-by: Kiran Gunda --- drivers/input/misc/qcom-hv-haptics.c | 31 ++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/input/misc/qcom-hv-haptics.c b/drivers/input/misc/qcom-hv-haptics.c index f9c679a0808d..d752658b2c93 100644 --- a/drivers/input/misc/qcom-hv-haptics.c +++ b/drivers/input/misc/qcom-hv-haptics.c @@ -364,6 +364,10 @@ enum pmic_type { PM5100, }; +enum wa_flags { + TOGGLE_CAL_RC_CLK = BIT(0), +}; + static const char * const src_str[] = { "FIFO", "DIRECT_PLAY", @@ -511,6 +515,7 @@ struct haptics_chip { u32 cfg_addr_base; u32 ptn_addr_base; u32 hbst_addr_base; + u32 wa_flags; u8 cfg_revision; u8 ptn_revision; u8 hpwr_intf_ctl; @@ -1449,8 +1454,9 @@ static int haptics_open_loop_drive_config(struct haptics_chip *chip, bool en) if (rc < 0) return rc; - if ((val & CAL_RC_CLK_MASK) == - CAL_RC_CLK_AUTO_VAL << CAL_RC_CLK_SHIFT) { + if ((chip->wa_flags & TOGGLE_CAL_RC_CLK) && + ((val & CAL_RC_CLK_MASK) == + CAL_RC_CLK_AUTO_VAL << CAL_RC_CLK_SHIFT)) { val = CAL_RC_CLK_DISABLED_VAL << CAL_RC_CLK_SHIFT; rc = haptics_masked_write(chip, chip->cfg_addr_base, HAP_CFG_CAL_EN_REG, CAL_RC_CLK_MASK, @@ -2578,6 +2584,23 @@ static int haptics_config_openloop_lra_period(struct haptics_chip *chip, HAP_CFG_TLRA_OL_HIGH_REG, val, 2); } +static int haptics_config_wa(struct haptics_chip *chip) +{ + switch (chip->pmic_type) { + case PM8350B: + chip->wa_flags |= TOGGLE_CAL_RC_CLK; + break; + case PM5100: + break; + default: + dev_err(chip->dev, "PMIC type %d does not match\n", + chip->pmic_type); + return -EINVAL; + } + + return 0; +} + static int haptics_hw_init(struct haptics_chip *chip) { struct haptics_hw_config *config = &chip->config; @@ -2586,6 +2609,10 @@ static int haptics_hw_init(struct haptics_chip *chip) u8 val[2]; u32 t_lra_us; + rc = haptics_config_wa(chip); + if (rc < 0) + return rc; + /* Store CL brake settings */ rc = haptics_store_cl_brake_settings(chip); if (rc < 0)