Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 844516d9 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

Revert "input: qcom-hv-haptics: read CAL_TLRA_CL_STS from SDAM after boot up"



This reverts commit 7d3ecfd7.

This change had caused a regression with swr-haptics driver probe
as the soundwire master couldn't enumerate swr haptics. Revert
this until we can understand why soundwire enumeration fails.

Change-Id: Ie5840247013a1a3fab15758e9ace7b131619be49
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 0afd6cbe
Loading
Loading
Loading
Loading
+15 −35
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@
#define TLRA_CL_ERR_MSB_MASK			GENMASK(4, 0)
/* STATUS_DATA_MSB definition in V1 while MOD_STATUS_SEL is 5 */
#define FIFO_REAL_TIME_FILL_STATUS_MASK_V1	GENMASK(6, 0)
/* STATUS_DATA_MSB definition in V2 while MOD_STATUS_SEL is 5 */
/* STATUS DATA_MSB definition in V2 while MOD_STATUS_SEL is 5 */
#define FIFO_REAL_TIME_FILL_STATUS_MSB_MASK_V2	GENMASK(1, 0)

#define HAP_CFG_STATUS_DATA_LSB_REG		0x0A
@@ -791,16 +791,12 @@ static int haptics_get_closeloop_lra_period_v1(
	return 0;
}

/* The offset of SDAM register which saves STATUS_DATA_MSB value */
#define HAP_STATUS_DATA_MSB_SDAM_OFFSET		0x46

/* constant definitions for calculating TLRA */
#define TLRA_AUTO_RES_ERR_NO_CAL_STEP_PSEC	1667000
#define TLRA_AUTO_RES_NO_CAL_STEP_PSEC		3333000
#define TLRA_AUTO_RES_ERR_AUTO_CAL_STEP_PSEC	1627700
#define TLRA_AUTO_RES_AUTO_CAL_STEP_PSEC	813850
static int haptics_get_closeloop_lra_period_v2(
		struct haptics_chip *chip, bool in_boot)
		struct haptics_chip *chip)
{
	struct haptics_hw_config *config = &chip->config;
	u16 cal_tlra_cl_sts, tlra_cl_err_sts, tlra_ol, last_good_tlra_cl_sts;
@@ -817,20 +813,6 @@ static int haptics_get_closeloop_lra_period_v2(

	rc_clk_cal = ((val[0] & CAL_RC_CLK_MASK) >> CAL_RC_CLK_SHIFT);
	/* read auto resonance calibration result */
	if (in_boot) {
		if (chip->hap_cfg_nvmem == NULL) {
			dev_dbg(chip->dev, "nvmem device for hap_cfg is not defined\n");
			return -EINVAL;
		}

		rc = nvmem_device_read(chip->hap_cfg_nvmem,
				HAP_STATUS_DATA_MSB_SDAM_OFFSET, 2, val);
		if (rc < 0) {
			dev_err(chip->dev, "read SDAM %#x failed, rc=%d\n",
					HAP_STATUS_DATA_MSB_SDAM_OFFSET, rc);
			return rc;
		}
	} else {
	val[0] = MOD_STATUS_SEL_CAL_TLRA_CL_STS_VAL;
	rc = haptics_write(chip, chip->cfg_addr_base,
		HAP_CFG_MOD_STATUS_SEL_REG, val, 1);
@@ -841,7 +823,6 @@ static int haptics_get_closeloop_lra_period_v2(
		HAP_CFG_STATUS_DATA_MSB_REG, val, 2);
	if (rc < 0)
		return rc;
	}

	auto_res_done = !!(val[0] & AUTO_RES_CAL_DONE_BIT);
	cal_tlra_cl_sts =
@@ -971,15 +952,14 @@ static int haptics_get_closeloop_lra_period_v2(
	return 0;
}

static int haptics_get_closeloop_lra_period(struct haptics_chip *chip,
						bool in_boot)
static int haptics_get_closeloop_lra_period(struct haptics_chip *chip)
{
	int rc = 0;

	if (chip->ptn_revision == HAP_PTN_V1)
		rc = haptics_get_closeloop_lra_period_v1(chip);
	else
		rc = haptics_get_closeloop_lra_period_v2(chip, in_boot);
		rc = haptics_get_closeloop_lra_period_v2(chip);

	if (rc < 0) {
		dev_err(chip->dev, "get close loop T LRA failed, rc=%d\n",
@@ -2177,7 +2157,7 @@ static int haptics_hw_init(struct haptics_chip *chip)
		return rc;

	/* get calibrated close loop period */
	rc = haptics_get_closeloop_lra_period(chip, true);
	rc = haptics_get_closeloop_lra_period(chip);
	if (rc < 0)
		return rc;

@@ -3609,7 +3589,7 @@ static int haptics_start_lra_calibration(struct haptics_chip *chip)
	/* wait for ~150ms to get the LRA calibration result */
	usleep_range(150000, 155000);

	rc = haptics_get_closeloop_lra_period(chip, false);
	rc = haptics_get_closeloop_lra_period(chip);
	if (rc < 0)
		goto restore;