From 535559a22186ed0cf9269402170446cf5506d940 Mon Sep 17 00:00:00 2001 From: Subbaraman Narayanamurthy Date: Tue, 31 May 2022 19:38:42 -0700 Subject: [PATCH 1/3] input: misc: qcom-hv-haptics: Fix print format identifier Print in hex when a read/write to an address fails. Change-Id: I35dddaa33d18f72079ec3d814a36fd304cd0f331 Signed-off-by: Subbaraman Narayanamurthy --- drivers/input/misc/qcom-hv-haptics.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/input/misc/qcom-hv-haptics.c b/drivers/input/misc/qcom-hv-haptics.c index 57b929b27c03..0948a30c7577 100644 --- a/drivers/input/misc/qcom-hv-haptics.c +++ b/drivers/input/misc/qcom-hv-haptics.c @@ -702,7 +702,7 @@ static int haptics_read(struct haptics_chip *chip, rc = regmap_bulk_read(chip->regmap, addr, val, length); if (rc < 0) - dev_err(chip->dev, "read addr %d failed, rc=%d\n", addr, rc); + dev_err(chip->dev, "read addr %#x failed, rc=%d\n", addr, rc); return rc; } @@ -715,7 +715,7 @@ static int haptics_write(struct haptics_chip *chip, rc = regmap_bulk_write(chip->regmap, addr, val, length); if (rc < 0) - dev_err(chip->dev, "write addr %d failed, rc=%d\n", addr, rc); + dev_err(chip->dev, "write addr %#x failed, rc=%d\n", addr, rc); return rc; } @@ -728,7 +728,7 @@ static int haptics_masked_write(struct haptics_chip *chip, regmap_update_bits(chip->regmap, addr, mask, val); if (rc < 0) - dev_err(chip->dev, "update addr %d failed, rc=%d\n", addr, rc); + dev_err(chip->dev, "update addr %#x failed, rc=%d\n", addr, rc); return rc; } From 65e7bb2861def68ed82bf82c2e21819102e81991 Mon Sep 17 00:00:00 2001 From: Fenglin Wu Date: Wed, 25 May 2022 09:03:04 +0800 Subject: [PATCH 2/3] input: qcom-hv-haptics: ignore disabling hBoost when it's in open-loop When hBoost is working in open-loop mode, it's supposed to be used by other modules like the charger firmware and it shouldn't be turned off by haptics driver. Ignore turning on and off hBoost in such case. Change-Id: Id3eb2c37cf7316b4617872614cc2a7adc50d12d8 Signed-off-by: Fenglin Wu --- drivers/input/misc/qcom-hv-haptics.c | 53 ++++++++++++++++------------ 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/drivers/input/misc/qcom-hv-haptics.c b/drivers/input/misc/qcom-hv-haptics.c index 0948a30c7577..8fc4bda5e2c4 100644 --- a/drivers/input/misc/qcom-hv-haptics.c +++ b/drivers/input/misc/qcom-hv-haptics.c @@ -1266,6 +1266,31 @@ static int haptics_set_direct_play(struct haptics_chip *chip, u8 amplitude) return rc; } +static bool is_boost_vreg_enabled_in_open_loop(struct haptics_chip *chip) +{ + int rc; + u8 val; + + if (is_haptics_external_powered(chip)) + return false; + + rc = haptics_read(chip, chip->hbst_addr_base, HAP_BOOST_VREG_EN_REG, &val, 1); + if (rc < 0) + return false; + + chip->hboost_enabled = (val & VREG_EN_BIT); + rc = haptics_read(chip, chip->hbst_addr_base, HAP_BOOST_HW_CTRL_FOLLOW_REG, &val, 1); + if (rc < 0) + return false; + + if (!(val & FOLLOW_HW_EN_BIT) && chip->hboost_enabled) { + dev_dbg(chip->dev, "HBoost is enabled in open loop condition\n"); + return true; + } + + return false; +} + #define PBS_ARG_REG 0x42 #define HAP_VREG_ON_VAL 0x1 #define HAP_VREG_OFF_VAL 0x2 @@ -1287,6 +1312,12 @@ static int haptics_boost_vreg_enable(struct haptics_chip *chip, bool en) return 0; } + if (is_boost_vreg_enabled_in_open_loop(chip)) { + dev_dbg(chip->dev, "Ignore %s hBoost while it's enabled in open-loop mode\n", + en ? "enabling" : "disabling"); + return 0; + } + if (chip->hboost_enabled == en) return 0; @@ -1327,28 +1358,6 @@ static bool is_swr_play_enabled(struct haptics_chip *chip) return false; } -static bool is_boost_vreg_enabled_in_open_loop(struct haptics_chip *chip) -{ - int rc; - u8 val; - - if (is_haptics_external_powered(chip)) - return false; - - rc = haptics_read(chip, chip->hbst_addr_base, - HAP_BOOST_HW_CTRL_FOLLOW_REG, &val, 1); - if (!rc && !(val & FOLLOW_HW_EN_BIT)) { - rc = haptics_read(chip, chip->hbst_addr_base, - HAP_BOOST_VREG_EN_REG, &val, 1); - if (!rc && (val & VREG_EN_BIT)) { - dev_dbg(chip->dev, "HBoost is enabled in open loop condition\n"); - return true; - } - } - - return false; -} - #define HBOOST_WAIT_READY_COUNT 100 #define HBOOST_WAIT_READY_INTERVAL_US 200 static int haptics_wait_hboost_ready(struct haptics_chip *chip) From 8afead556c6515df23efc43399ec0fdbdb9b0f19 Mon Sep 17 00:00:00 2001 From: Fenglin Wu Date: Mon, 18 Jul 2022 10:56:28 +0800 Subject: [PATCH 3/3] input: qcom-hv-haptics: move predefined effect preload logging Move the logging after calculating Vmax so that the right Vmax value can be printed out. CRs-Fixed: 3227145 Change-Id: I17b64f9e3a230058b7e30ca4c30de4d3000d1f87 Signed-off-by: Fenglin Wu --- drivers/input/misc/qcom-hv-haptics.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/input/misc/qcom-hv-haptics.c b/drivers/input/misc/qcom-hv-haptics.c index 8fc4bda5e2c4..f1ca4a207eef 100644 --- a/drivers/input/misc/qcom-hv-haptics.c +++ b/drivers/input/misc/qcom-hv-haptics.c @@ -2381,9 +2381,6 @@ static int haptics_load_periodic_effect(struct haptics_chip *chip, } mutex_lock(&chip->play.lock); - dev_dbg(chip->dev, "upload effect %d, vmax_mv=%d\n", - chip->effects[i].id, play->vmax_mv); - if (chip->play.in_calibration) { dev_err(chip->dev, "calibration in progress, ignore playing predefined effect\n"); rc = -EBUSY; @@ -2391,6 +2388,7 @@ static int haptics_load_periodic_effect(struct haptics_chip *chip, } play->vmax_mv = (magnitude * chip->effects[i].vmax_mv) / 0x7fff; + dev_dbg(chip->dev, "upload effect %d, vmax_mv=%d\n", chip->effects[i].id, play->vmax_mv); rc = haptics_load_predefined_effect(chip, &chip->effects[i]); if (rc < 0) { dev_err(chip->dev, "Play predefined effect%d failed, rc=%d\n",