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)