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

Commit 880868b7 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

regulator: qpnp-labibb-regulator: change the way LAB module is configured



Currently, IBB_EN_RDY bit of LAB_IBB_EN_RDY register is being
used to determine whether LAB module needs to be configured
from HLOS or just to have the settings done by the bootloader
earlier. However, that bit specifies whether or not the LAB
module to be enabled from IBB via MODULE_EN bit in register
ENABLE_CTL of IBB or SWIRE. Hence modify the driver to check
IBB_ENABLE_CTL to see if it has been already enabled or not
before doing the configuration in HLOS based on the device tree.

While at it, fix a minor issue in qpnp_ibb_dt_init() where the
wrong macro was being used, even though the bit position being
configured is same.

Change-Id: I0c691fab2e624eb981fa836f910e0ee69503d74f
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent be08f39f
Loading
Loading
Loading
Loading
+15 −14
Original line number Diff line number Diff line
@@ -1058,7 +1058,7 @@ static int register_qpnp_lab_regulator(struct qpnp_labibb *labibb,
	struct regulator_init_data *init_data;
	struct regulator_desc *rdesc;
	struct regulator_config cfg = {};
	u8 ibb_en_rdy_val, val;
	u8 val;
	const char *current_sense_str;
	bool config_current_sense = false;

@@ -1122,15 +1122,22 @@ static int register_qpnp_lab_regulator(struct qpnp_labibb *labibb,
	labibb->lab_vreg.soft_start = lab_soft_start_plan
				[val & LAB_SOFT_START_CTL_MASK];

	rc = qpnp_labibb_read(labibb, &ibb_en_rdy_val,
				labibb->lab_base + REG_LAB_IBB_EN_RDY, 1);
	rc = qpnp_labibb_read(labibb, &val,
				labibb->ibb_base + REG_IBB_ENABLE_CTL, 1);
	if (rc) {
		pr_err("qpnp_lab_read register %x failed rc = %d\n",
			REG_LAB_IBB_EN_RDY, rc);
		pr_err("qpnp_labibb_read register %x failed rc = %d\n",
			REG_IBB_ENABLE_CTL, rc);
		return rc;
	}

	if (ibb_en_rdy_val == LAB_IBB_EN_RDY_EN) {
	if (!(val & IBB_ENABLE_CTL_EN)) {
		rc = qpnp_lab_dt_init(labibb, of_node);
		if (rc) {
			pr_err("qpnp-lab: wrong DT parameter specified: rc = %d\n",
				rc);
			return rc;
		}
	} else {
		rc = qpnp_labibb_read(labibb, &val,
			labibb->lab_base + REG_LAB_LCD_AMOLED_SEL, 1);
		if (rc) {
@@ -1219,13 +1226,6 @@ static int register_qpnp_lab_regulator(struct qpnp_labibb *labibb,
		}

		labibb->lab_vreg.vreg_enabled = 1;
	} else {
		rc = qpnp_lab_dt_init(labibb, of_node);
		if (rc) {
			pr_err("qpnp-lab: wrong DT parameter specified: rc = %d\n",
				rc);
			return rc;
		}
	}

	rc = qpnp_labibb_read(labibb, &val,
@@ -1601,7 +1601,8 @@ static int qpnp_ibb_dt_init(struct qpnp_labibb *labibb,
		val |= PWRUP_PWRDN_CTL_1_DISCHARGE_EN;

	if (labibb->mode != QPNP_LABIBB_STANDALONE_MODE)
		val |= (IBB_PWRUP_PWRDN_CTL_1_EN_DLY1 | IBB_ENABLE_CTL_EN);
		val |= (IBB_PWRUP_PWRDN_CTL_1_EN_DLY1 |
				IBB_PWRUP_PWRDN_CTL_1_LAB_VREG_OK);

	rc = qpnp_ibb_unlock_sec_access(labibb);