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 <quic_fenglinw@quicinc.com>
This commit is contained in:
Fenglin Wu 2022-05-25 09:03:04 +08:00
parent 535559a221
commit 65e7bb2861

View File

@ -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)