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

Commit 22c4c57b authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "regulator: labibb: fix standalone mode configuration"

parents 3e687e4a c4939f02
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -11,14 +11,11 @@ Main node required properties:
- spmi-dev-container:		Must be present.
- qpnp,qpnp-labibb-mode:	A string used to specify the working mode of LAB/IBB
				regulators when bootloader does not turned on the
				display panel. Could be "lcd", "amoled" or
				"stand-alone".
				display panel. Could be "lcd" or "amoled".
				"lcd" means using LAB and IBB regulators are
				configured for LCD mode together.
				configured for LCD mode.
				"amoled" means using LAB and IBB regulators are
				configured for AMOLED mode together.
				"stand-alone" means using LAB and IBB regulators
				as stand alone regulators.
				configured for AMOLED mode.
- qcom,pmic-revid:		Specifies the phandle of the PMIC revid module.
				Used to identify the PMIC subtype.

@@ -42,6 +39,14 @@ Main node optional properties:
					SWIRE command. If not specified this value
					defaults to 20ms. This delay is applied only
					if 'qpnp,skip-2nd-swire-cmd' is defined.
- qcom,labibb-standalone:		A boolean property which forces LAB and
					IBB to operate in standalone mode. If
					this is not specified, then LAB and IBB
					are controlled together in dual mode.
- parent-supply:			Parent supply that is needed for LAB
					and IBB regulators. This will be mostly
					needed when LAB and IBB are operating
					in standalone mode to vote for MBG.

LAB subnode required properties:

+80 −61
Original line number Diff line number Diff line
@@ -257,8 +257,6 @@ enum pmic_subtype {

/**
 * enum qpnp_labibb_mode - working mode of LAB/IBB regulators
 * %QPNP_LABIBB_STANDALONE_MODE:	configure LAB/IBB regulator as a
 * standalone regulator
 * %QPNP_LABIBB_LCD_MODE:		configure LAB and IBB regulators
 * together to provide power supply for LCD
 * %QPNP_LABIBB_AMOLED_MODE:		configure LAB and IBB regulators
@@ -267,7 +265,6 @@ enum pmic_subtype {
 * supported by qpnp_labibb_regulator
 */
enum qpnp_labibb_mode {
	QPNP_LABIBB_STANDALONE_MODE = 1,
	QPNP_LABIBB_LCD_MODE,
	QPNP_LABIBB_AMOLED_MODE,
	QPNP_LABIBB_MAX_MODE,
@@ -477,7 +474,8 @@ struct qpnp_labibb {
	u16				ibb_base;
	struct lab_regulator		lab_vreg;
	struct ibb_regulator		ibb_vreg;
	int				mode;
	enum qpnp_labibb_mode		mode;
	bool				standalone;
	bool				ttw_en;
	bool				in_ttw_mode;
	bool				ibb_settings_saved;
@@ -695,7 +693,6 @@ static int qpnp_lab_dt_init(struct qpnp_labibb *labibb,
	u8 i, val;
	u32 tmp;

	if (labibb->mode != QPNP_LABIBB_STANDALONE_MODE) {
	if (labibb->mode == QPNP_LABIBB_LCD_MODE)
		val = REG_LAB_IBB_LCD_MODE;
	else
@@ -710,17 +707,6 @@ static int qpnp_lab_dt_init(struct qpnp_labibb *labibb,
		return rc;
	}

		val = LAB_IBB_EN_RDY_EN;
		rc = qpnp_labibb_sec_write(labibb, labibb->lab_base,
				REG_LAB_IBB_EN_RDY, &val, 1);

		if (rc) {
			pr_err("qpnp_lab_sec_write register %x failed rc = %d\n",
				REG_LAB_IBB_EN_RDY, rc);
			return rc;
		}
	}

	val = 0;

	if (of_property_read_bool(of_node, "qcom,qpnp-lab-full-pull-down"))
@@ -1463,7 +1449,7 @@ static int qpnp_lab_regulator_enable(struct regulator_dev *rdev)

	if (!labibb->lab_vreg.vreg_enabled && !labibb->swire_control) {

		if (labibb->mode != QPNP_LABIBB_STANDALONE_MODE)
		if (!labibb->standalone)
			return qpnp_labibb_regulator_enable(labibb);

		val = LAB_ENABLE_CTL_EN;
@@ -1504,7 +1490,7 @@ static int qpnp_lab_regulator_disable(struct regulator_dev *rdev)

	if (labibb->lab_vreg.vreg_enabled && !labibb->swire_control) {

		if (labibb->mode != QPNP_LABIBB_STANDALONE_MODE)
		if (!labibb->standalone)
			return qpnp_labibb_regulator_disable(labibb);

		val = 0;
@@ -1818,6 +1804,16 @@ static int register_qpnp_lab_regulator(struct qpnp_labibb *labibb,
		}
	}

	val = (labibb->standalone) ? 0 : LAB_IBB_EN_RDY_EN;
	rc = qpnp_labibb_sec_write(labibb, labibb->lab_base,
			REG_LAB_IBB_EN_RDY, &val, 1);

	if (rc) {
		pr_err("qpnp_lab_sec_write register %x failed rc = %d\n",
			REG_LAB_IBB_EN_RDY, rc);
		return rc;
	}

	rc = qpnp_labibb_read(labibb, &val,
				labibb->ibb_base + REG_IBB_ENABLE_CTL, 1);
	if (rc) {
@@ -1893,8 +1889,7 @@ static int register_qpnp_lab_regulator(struct qpnp_labibb *labibb,
		return rc;
	}

	if (labibb->mode != QPNP_LABIBB_STANDALONE_MODE &&
			!(val & LAB_MODULE_RDY_EN)) {
	if (!(val & LAB_MODULE_RDY_EN)) {
		val = LAB_MODULE_RDY_EN;

		rc = qpnp_labibb_write(labibb, labibb->lab_base +
@@ -1919,6 +1914,10 @@ static int register_qpnp_lab_regulator(struct qpnp_labibb *labibb,
		cfg.driver_data = labibb;
		cfg.of_node = of_node;

		if (of_get_property(labibb->dev->of_node, "parent-supply",
				NULL))
			init_data->supply_regulator = "parent";

		init_data->constraints.valid_ops_mask
				|= REGULATOR_CHANGE_VOLTAGE |
					REGULATOR_CHANGE_STATUS;
@@ -1948,7 +1947,6 @@ static int qpnp_ibb_dt_init(struct qpnp_labibb *labibb,
	u32 i, tmp;
	u8 val;

	if (labibb->mode != QPNP_LABIBB_STANDALONE_MODE) {
	if (labibb->mode == QPNP_LABIBB_LCD_MODE)
		val = REG_LAB_IBB_LCD_MODE;
	else
@@ -1962,7 +1960,6 @@ static int qpnp_ibb_dt_init(struct qpnp_labibb *labibb,
			REG_IBB_LCD_AMOLED_SEL, rc);
		return rc;
	}
	}

	rc = of_property_read_u32(of_node, "qcom,qpnp-ibb-lab-pwrdn-delay",
					&tmp);
@@ -2009,7 +2006,6 @@ static int qpnp_ibb_dt_init(struct qpnp_labibb *labibb,
	if (of_property_read_bool(of_node, "qcom,qpnp-ibb-en-discharge"))
		val |= PWRUP_PWRDN_CTL_1_DISCHARGE_EN;

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

@@ -2229,14 +2225,13 @@ static int qpnp_ibb_dt_init(struct qpnp_labibb *labibb,

static int qpnp_ibb_regulator_enable(struct regulator_dev *rdev)
{
	int rc;
	int rc, delay, retries = 10;
	u8 val;

	struct qpnp_labibb *labibb  = rdev_get_drvdata(rdev);

	if (!labibb->ibb_vreg.vreg_enabled && !labibb->swire_control) {

		if (labibb->mode != QPNP_LABIBB_STANDALONE_MODE)
		if (!labibb->standalone)
			return qpnp_labibb_regulator_enable(labibb);

		rc = qpnp_ibb_set_mode(labibb, IBB_SW_CONTROL_EN);
@@ -2245,7 +2240,10 @@ static int qpnp_ibb_regulator_enable(struct regulator_dev *rdev)
			return rc;
		}

		udelay(labibb->ibb_vreg.soft_start);
		delay = labibb->ibb_vreg.soft_start;
		while (retries--) {
			/* Wait for a small period before reading IBB_STATUS1 */
			usleep_range(delay, delay + 100);

			rc = qpnp_labibb_read(labibb, &val,
					labibb->ibb_base + REG_IBB_STATUS1, 1);
@@ -2255,7 +2253,11 @@ static int qpnp_ibb_regulator_enable(struct regulator_dev *rdev)
				return rc;
			}

		if ((val & IBB_STATUS1_VREG_OK_MASK) != IBB_STATUS1_VREG_OK) {
			if (val & IBB_STATUS1_VREG_OK)
				break;
		}

		if (!(val & IBB_STATUS1_VREG_OK)) {
			pr_err("qpnp_ibb_regulator_enable failed\n");
			return -EINVAL;
		}
@@ -2272,7 +2274,7 @@ static int qpnp_ibb_regulator_disable(struct regulator_dev *rdev)

	if (labibb->ibb_vreg.vreg_enabled && !labibb->swire_control) {

		if (labibb->mode != QPNP_LABIBB_STANDALONE_MODE)
		if (!labibb->standalone)
			return qpnp_labibb_regulator_disable(labibb);

		rc = qpnp_ibb_set_mode(labibb, IBB_SW_CONTROL_DIS);
@@ -2600,6 +2602,19 @@ static int register_qpnp_ibb_regulator(struct qpnp_labibb *labibb,
		}
	}

	if (labibb->standalone) {
		val = 0;
		rc = qpnp_labibb_sec_write(labibb, labibb->ibb_base,
				REG_IBB_PWRUP_PWRDN_CTL_1, &val, 1);
		if (rc) {
			pr_err("qpnp_labibb_sec_write register %x failed rc = %d\n",
				REG_IBB_PWRUP_PWRDN_CTL_1, rc);
			return rc;
		}
		labibb->ibb_vreg.pwrup_dly = 0;
		labibb->ibb_vreg.pwrdn_dly = 0;
	}

	rc = qpnp_labibb_read(labibb, &val,
			labibb->ibb_base + REG_IBB_MODULE_RDY, 1);
	if (rc) {
@@ -2608,8 +2623,7 @@ static int register_qpnp_ibb_regulator(struct qpnp_labibb *labibb,
		return rc;
	}

	if (labibb->mode != QPNP_LABIBB_STANDALONE_MODE &&
			!(val & IBB_MODULE_RDY_EN)) {
	if (!(val & IBB_MODULE_RDY_EN)) {
		val = IBB_MODULE_RDY_EN;

		rc = qpnp_labibb_write(labibb, labibb->ibb_base +
@@ -2634,6 +2648,10 @@ static int register_qpnp_ibb_regulator(struct qpnp_labibb *labibb,
		cfg.driver_data = labibb;
		cfg.of_node = of_node;

		if (of_get_property(labibb->dev->of_node, "parent-supply",
				 NULL))
			init_data->supply_regulator = "parent";

		init_data->constraints.valid_ops_mask
				|= REGULATOR_CHANGE_VOLTAGE |
					REGULATOR_CHANGE_STATUS;
@@ -2749,8 +2767,6 @@ static int qpnp_labibb_regulator_probe(struct spmi_device *spmi)
			labibb->mode = QPNP_LABIBB_LCD_MODE;
		} else if (strcmp("amoled", mode_name) == 0) {
			labibb->mode = QPNP_LABIBB_AMOLED_MODE;
		} else if (strcmp("stand-alone", mode_name) == 0) {
			labibb->mode = QPNP_LABIBB_STANDALONE_MODE;
		} else {
			pr_err("Invalid device property in qpnp,qpnp-labibb-mode: %s\n",
				mode_name);
@@ -2761,6 +2777,9 @@ static int qpnp_labibb_regulator_probe(struct spmi_device *spmi)
		return rc;
	}

	labibb->standalone = of_property_read_bool(labibb->dev->of_node,
				"qcom,labibb-standalone");

	labibb->ttw_en = of_property_read_bool(labibb->dev->of_node,
				"qcom,labibb-touch-to-wake-en");
	if (labibb->ttw_en && labibb->mode != QPNP_LABIBB_LCD_MODE) {