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

Commit e11725b3 authored by Anirudh Ghayal's avatar Anirudh Ghayal
Browse files

regulator: qpnp-labibb: Add support for SWIRE control



In the SWIRE configuration, the SWIRE signal from the display
panel controls the LAB/IBB voltage and MODULE_EN directly.

Skip the voltage/MODULE_EN configuration during initialization
and suspend/resume if SWIRE control is enabled.

CRs-Fixed: 923651
Change-Id: I425711ef46511816d2ad0f2a34189b7dc47c00c3
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent 41747adc
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -28,6 +28,10 @@ Main node optional properties:
					in LAB and IBB modules. Make sure the
					hardware has needed support before
					enabling this property.
- qpnp,swire-control:			A bool property which indicates if the LAB/IBB is
					controlled by the SWIRE interface. Enable only
					if qpnp,qpnp-labibb-mode = "amoled".

LAB subnode required properties:

- reg:				Specifies the SPMI address and size for this peripheral.
+48 −6
Original line number Diff line number Diff line
@@ -428,6 +428,7 @@ struct qpnp_labibb {
	bool				ttw_en;
	bool				in_ttw_mode;
	bool				ibb_settings_saved;
	bool				swire_control;
};

enum ibb_settings_index {
@@ -827,6 +828,14 @@ static int qpnp_lab_dt_init(struct qpnp_labibb *labibb,
		return rc;
	}

	if (labibb->swire_control) {
		val = IBB_ENABLE_CTL_SWIRE_RDY;
		rc = qpnp_labibb_write(labibb,
			labibb->ibb_base + REG_IBB_ENABLE_CTL, &val, 1);
		if (rc)
			pr_err("Unable to set SWIRE_RDY rc=%d\n", rc);
	}

	return rc;
}

@@ -1179,7 +1188,7 @@ static int qpnp_lab_regulator_enable(struct regulator_dev *rdev)

	struct qpnp_labibb *labibb  = rdev_get_drvdata(rdev);

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

		if (labibb->mode != QPNP_LABIBB_STANDALONE_MODE)
			return qpnp_labibb_regulator_enable(labibb);
@@ -1220,7 +1229,7 @@ static int qpnp_lab_regulator_disable(struct regulator_dev *rdev)
	u8 val;
	struct qpnp_labibb *labibb  = rdev_get_drvdata(rdev);

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

		if (labibb->mode != QPNP_LABIBB_STANDALONE_MODE)
			return qpnp_labibb_regulator_disable(labibb);
@@ -1243,6 +1252,9 @@ static int qpnp_lab_regulator_is_enabled(struct regulator_dev *rdev)
{
	struct qpnp_labibb *labibb  = rdev_get_drvdata(rdev);

	if (labibb->swire_control)
		return 0;

	return labibb->lab_vreg.vreg_enabled;
}

@@ -1253,6 +1265,9 @@ static int qpnp_lab_regulator_set_voltage(struct regulator_dev *rdev,
	u8 val;
	struct qpnp_labibb *labibb = rdev_get_drvdata(rdev);

	if (labibb->swire_control)
		return 0;

	if (min_uV < labibb->lab_vreg.min_volt) {
		pr_err("qpnp_lab_regulator_set_voltage failed, min_uV %d is less than min_volt %d",
			min_uV, labibb->lab_vreg.min_volt);
@@ -1292,6 +1307,9 @@ static int qpnp_lab_regulator_get_voltage(struct regulator_dev *rdev)
{
	struct qpnp_labibb *labibb  = rdev_get_drvdata(rdev);

	if (labibb->swire_control)
		return 0;

	return labibb->lab_vreg.curr_volt;
}

@@ -1412,7 +1430,8 @@ static int register_qpnp_lab_regulator(struct qpnp_labibb *labibb,
		return rc;
	}

	if (!(val & IBB_ENABLE_CTL_MODULE_EN)) {
	if (!(val & (IBB_ENABLE_CTL_SWIRE_RDY | IBB_ENABLE_CTL_MODULE_EN))) {
		/* SWIRE_RDY and IBB_MODULE_EN not enabled */
		rc = qpnp_lab_dt_init(labibb, of_node);
		if (rc) {
			pr_err("qpnp-lab: wrong DT parameter specified: rc = %d\n",
@@ -2081,7 +2100,7 @@ static int qpnp_ibb_regulator_enable(struct regulator_dev *rdev)

	struct qpnp_labibb *labibb  = rdev_get_drvdata(rdev);

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

		if (labibb->mode != QPNP_LABIBB_STANDALONE_MODE)
			return qpnp_labibb_regulator_enable(labibb);
@@ -2121,7 +2140,7 @@ static int qpnp_ibb_regulator_disable(struct regulator_dev *rdev)
	u8 val;
	struct qpnp_labibb *labibb  = rdev_get_drvdata(rdev);

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

		if (labibb->mode != QPNP_LABIBB_STANDALONE_MODE)
			return qpnp_labibb_regulator_disable(labibb);
@@ -2144,6 +2163,9 @@ static int qpnp_ibb_regulator_is_enabled(struct regulator_dev *rdev)
{
	struct qpnp_labibb *labibb  = rdev_get_drvdata(rdev);

	if (labibb->swire_control)
		return 0;

	return labibb->ibb_vreg.vreg_enabled;
}

@@ -2154,6 +2176,9 @@ static int qpnp_ibb_regulator_set_voltage(struct regulator_dev *rdev,
	u8 val;
	struct qpnp_labibb *labibb = rdev_get_drvdata(rdev);

	if (labibb->swire_control)
		return 0;

	if (min_uV < labibb->ibb_vreg.min_volt) {
		pr_err("qpnp_ibb_regulator_set_voltage failed, min_uV %d is less than min_volt %d",
			min_uV, labibb->ibb_vreg.min_volt);
@@ -2194,6 +2219,9 @@ static int qpnp_ibb_regulator_get_voltage(struct regulator_dev *rdev)
{
	struct qpnp_labibb *labibb  = rdev_get_drvdata(rdev);

	if (labibb->swire_control)
		return 0;

	return labibb->ibb_vreg.curr_volt;
}

@@ -2314,7 +2342,9 @@ static int register_qpnp_ibb_regulator(struct qpnp_labibb *labibb,
		return rc;
	}

	if (ibb_enable_ctl != 0) {
	if (ibb_enable_ctl &
		(IBB_ENABLE_CTL_SWIRE_RDY | IBB_ENABLE_CTL_MODULE_EN)) {
		/* SWIRE_RDY or IBB_MODULE_EN enabled */
		rc = qpnp_labibb_read(labibb, &val,
			labibb->ibb_base + REG_IBB_LCD_AMOLED_SEL, 1);
		if (rc) {
@@ -2379,6 +2409,7 @@ static int register_qpnp_ibb_regulator(struct qpnp_labibb *labibb,

		labibb->ibb_vreg.vreg_enabled = 1;
	} else {
		/* SWIRE_RDY and IBB_MODULE_EN not enabled */
		rc = qpnp_ibb_dt_init(labibb, of_node);
		if (rc) {
			pr_err("qpnp-ibb: wrong DT parameter specified: rc = %d\n",
@@ -2482,6 +2513,17 @@ static int qpnp_labibb_regulator_probe(struct spmi_device *spmi)

	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) {
		pr_err("Invalid mode for TTW\n");
		return -EINVAL;
	}

	labibb->swire_control = of_property_read_bool(labibb->dev->of_node,
							"qpnp,swire-control");
	if (labibb->swire_control && labibb->mode != QPNP_LABIBB_AMOLED_MODE) {
		pr_err("Invalid mode for SWIRE control\n");
		return -EINVAL;
	}

	spmi_for_each_container_dev(spmi_resource, spmi) {
		if (!spmi_resource) {