diff --git a/drivers/input/misc/qcom-hv-haptics.c b/drivers/input/misc/qcom-hv-haptics.c index cca0c26f8eae..c73c25c35cc6 100644 --- a/drivers/input/misc/qcom-hv-haptics.c +++ b/drivers/input/misc/qcom-hv-haptics.c @@ -1540,6 +1540,40 @@ static int haptics_open_loop_drive_config(struct haptics_chip *chip, bool en) return 0; } +static int haptics_module_enable(struct haptics_chip *chip, bool enable) +{ + u8 val; + int rc; + + val = enable ? HAPTICS_EN_BIT : 0; + rc = haptics_write(chip, chip->cfg_addr_base, + HAP_CFG_EN_CTL_REG, &val, 1); + if (rc < 0) + return rc; + + dev_dbg(chip->dev, "haptics module %s\n", + enable ? "enabled" : "disabled"); + return 0; +} + +static int haptics_toggle_module_enable(struct haptics_chip *chip) +{ + int rc; + + /* + * Updating HAPTICS_EN would vote hBoost enable status. Add 100us + * delay before updating HAPTICS_EN for hBoost to have enough time + * to handle its power transition. + */ + usleep_range(100, 101); + rc = haptics_module_enable(chip, false); + if (rc < 0) + return rc; + + usleep_range(100, 101); + return haptics_module_enable(chip, true); +} + #define BOOST_VREG_OFF_DELAY_SECONDS 2 static int haptics_enable_play(struct haptics_chip *chip, bool en) { @@ -1938,40 +1972,6 @@ static void haptics_fifo_empty_irq_config(struct haptics_chip *chip, } } -static int haptics_module_enable(struct haptics_chip *chip, bool enable) -{ - u8 val; - int rc; - - val = enable ? HAPTICS_EN_BIT : 0; - rc = haptics_write(chip, chip->cfg_addr_base, - HAP_CFG_EN_CTL_REG, &val, 1); - if (rc < 0) - return rc; - - dev_dbg(chip->dev, "haptics module %s\n", - enable ? "enabled" : "disabled"); - return 0; -} - -static int haptics_toggle_module_enable(struct haptics_chip *chip) -{ - int rc; - - /* - * Updating HAPTICS_EN would vote hBoost enable status. Add 100us - * delay before updating HAPTICS_EN for hBoost to have enough time - * to handle its power transition. - */ - usleep_range(100, 101); - rc = haptics_module_enable(chip, false); - if (rc < 0) - return rc; - - usleep_range(100, 101); - return haptics_module_enable(chip, true); -} - static int haptics_set_fifo(struct haptics_chip *chip, struct fifo_cfg *fifo) { struct fifo_play_status *status = &chip->play.fifo_status;