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

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

Merge "regulator: qpnp-labibb: add secure writing functions for LAB/IBB registers"

parents a12a34c3 d80d832f
Loading
Loading
Loading
Loading
+159 −75
Original line number Diff line number Diff line
@@ -5,91 +5,175 @@ applications. IBB can be used as a standalone negative power supply for general
applications. Also, LAB and IBB can be used together to provide power supply for
display panels, LCD or AMOLED.

Required properties:
Main node required properties:

- compatible:			Must be "qcom,qpnp-labibb-regulator"
- 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".
				"lcd" means using LAB and IBB regulators together as lcd mode.
				"amoled" means using LAB and IBB regulators together as amoled mode.
				"stand-alone" means using LAB and IBB regulators as stand alone regulators.

Sub LAB node required structure:
- reg:				Specifies the SPMI address and size for this peripheral
- reg-names:			Register names. Must be "lab"
- regulator-name:		A string used to describe the regulator
- 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".
				"lcd" means using LAB and IBB regulators are
				configured for LCD mode together.
				"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.

LAB subnode required properties:

- reg:				Specifies the SPMI address and size for this peripheral.
- reg-names:			Register names. Must be "lab".
- regulator-name:		A string used to describe the regulator.
- regulator-min-microvolt:	Minimum voltage in microvolts supported by this regulator.
- regulator-max-microvolt:	Maximum voltage in microvolts supported by this regulator.

- qcom,qpnp-lab-min-voltage:	The voltage in microvolts this LAB regulator suppored
- qcom,qpnp-lab-step-size:	The step size in microvolts of LAB regulator
- qcom,qpnp-lab-slew-rate:	The time in us it takes for the regulator to change votlage value in one step.

- qcom,qpnp-lab-init-voltage:	The default initial voltage when the bootloader does not turn on LAB regulator.
- qcom,qpnp-lab-init-amoled-voltage: The default voltage when LAB regualtor working in amoled mode and the output voltage register of value 0
- qcom,qpnp-lab-init-lcd-voltage: The default voltage when LAB regulator working in lcd mode and the output voltage register of value 0
- qcom,qpnp-lab-soft-start:	The soft start time in us of LAB regulator. Supported value are 200, 400, 600 and 800.

- qcom,qpnp-lab-switching-clock-frequency:	The PWM switching clock frequency in kHz of Lab regulator, supported value are
						3200, 	2740, 	2400,  	2130, 	1920, 	1750,	1600,	1480,	1370,	1280,
						1200,	1130,	1070,	1010,	960,	910.
- qcom,qpnp-lab-limit-maximum-current:		The maximum inductor current limit in mA of LAB regulator. Supported value are 200, 400, 600 and 800.

- qcom,qpnp-lab-ps-threshold:	The threshold in mA of Pulse Skipe Mode for LAB regulator, supported value are 20, 30, 40 and 50.
- qcom,qpnp-lab-pfet-size:	FET size in percentage of PFET. Supported value are 25, 50, 75, 100.
- qcom,qpnp-lab-nfet-size:	FET size in percentage of NFET. Supported value are 25, 50, 75, 100.
- qcom,qpnp-lab-max-precharge-time:	Precharge time in us of LAB regulator. Supproted value are 200, 300, 400 and 500.

Sub LAB node optional structure:
- qcom,qpnp-lab-max-precharge-enable:		If this propert is present, fast precharge is enabled. Otherwise, it is disabled.
- qcom,qpnp-lab-ring-suppression-enable:	If this property is present, low noise PS mode will be enabled for LAB regulator. Otherwise, it will be disabled.
- qcom,qpnp-lab-ps-enable:		If this proerty is present, pulse skip mode will be enabled for LAB regulator. Othwise, pulse skip mode will be disabled for LAB regulator.
- qcom,qpnp-lab-full-pull-down:		If this property, the pull down strength of LAB regulator will full. Otherwise, the pull down strength will be half.
- qcom,qpnp-lab-pull-down-enable:	If this property is present, pull down is enabled for LAB regulator. Otherwise, pull down is disabled for LAB regulator.
- qcom,qpnp-lab-limit-max-current-enable:	If this property is present, maximum inductor current constraint is put for LAB regulator. Otherwise, There is no maximum current constraint.
- qcom,qpnp-lab-use-default-voltage:		When bootloader does not turn on LAB regulator and this property is present, value specified in qcom,qpnp-lab-init-voltage is the default init voltage when the voltage output register is of value 0. Otherwise, we need to enable the output override bit in voltage output register.
- qpnp,qpnp-lab-current-sense:	If this property is present, the LAB current sense gain will be programmed for LAB regulator.
				Otherwise, LAB current sense gain will be default to "1x". A string uses to specify the LAB current sense gain.
				Could be "0.5x" or "1x" or "1.5x" or "2x". For ex: "0.5x" means current sense gain is 0.5.


Sub IBB node required structure:
- reg:				Specifies the SPMI address and size for this peripheral
- reg-names:			Register names. Must be "ibb"
- regulator-name:		A string used to describe the regulator
- qcom,qpnp-lab-min-voltage:	The minimum voltage in microvolts LAB regulator can support.
- qcom,qpnp-lab-step-size:	The step size in microvolts of LAB regulator.
- qcom,qpnp-lab-slew-rate:	The time in us taken by the regulator to change
				voltage value in one step.

- qcom,qpnp-lab-init-voltage:		The default initial voltage when the bootloader
					does not turn on LAB regulator.
- qcom,qpnp-lab-init-amoled-voltage:	The default output voltage when LAB regulator
					is configured in amoled mode.
- qcom,qpnp-lab-init-lcd-voltage: 	The default output voltage when LAB regulator
					is configured in lcd mode.
- qcom,qpnp-lab-soft-start:		The soft start time in us of LAB regulator.
					Supported value are 200, 400, 600 and 800.

- qcom,qpnp-lab-ps-threshold:		The threshold in mA of Pulse Skip Mode for
					LAB regulator. Supported values are 20, 30,
					40 and 50.
- qcom,qpnp-lab-pfet-size:		PFET size in percentage. Supported values
					are 25, 50, 75 and 100.
- qcom,qpnp-lab-nfet-size:		NFET size in percentage. Supported values
					are 25, 50, 75 and 100.
- qcom,qpnp-lab-max-precharge-time:	Precharge time in us of LAB regulator.
					Supported values are 200, 300, 400 and 500.
- qcom,qpnp-lab-switching-clock-frequency:	The PWM switching clock frequency in
						kHz of Lab regulator, Supported values
						are: 3200, 2740, 2400, 2130, 1920,
						1750, 1600, 1480, 1370, 1280, 1200,
						1130, 1070, 1010, 960, 910.
- qcom,qpnp-lab-limit-maximum-current:		The maximum inductor current limit in
						mA of LAB regulator. Supported values
						are 200, 400, 600 and 800.

LAB subnode optional properties:

- qpnp,qpnp-lab-current-sense:		If this property is specified, the LAB current
					sense gain will be programmed for LAB regulator.
					Otherwise, LAB current sense gain will be
					default to "1x". A string is used to specify the
					LAB current sense gain. Could be "0.5x" or "1x"
					or "1.5x" or "2x". For e.g. "0.5x" means current
					sense gain is 0.5.
- qcom,qpnp-lab-ps-enable:		A boolean proerty which upon set will enable
					pulse skip mode for LAB regulator. Otherwise,
					it is disabled.
- qcom,qpnp-lab-full-pull-down:		A boolean property which upon set will enable
					the pull down strength of LAB regulator to
					full. Otherwise, the pull down strength is
					configured to half.
- qcom,qpnp-lab-pull-down-enable:	A boolean property which upon set will enable
					the pull down for LAB regulator. Otherwise,
					it is disabled.
- qcom,qpnp-lab-max-precharge-enable:		A boolean property which upon set will
						enable fast precharge. Otherwise, it is
						disabled.
- qcom,qpnp-lab-ring-suppression-enable:	A boolean property which upon set will
						enable ring suppression for LAB
						regulator. Otherwise, it is disabled.
- qcom,qpnp-lab-limit-max-current-enable:	A boolean property which upon set will
						enforce maximum inductor current constraint
						for LAB regulator. Otherwise, there is no
						maximum current constraint.
- qcom,qpnp-lab-use-default-voltage:		A boolean property which upon set will
						use the value specified in
						qcom,qpnp-lab-init-voltage property.
						This will be used only if the bootloader
						doesn't configure the output voltage
						already. If it it not specified, then
						output voltage can be configured to
						any value in the allowed limit.

IBB subnode required properties:

- reg:				Specifies the SPMI address and size for this peripheral.
- reg-names:			Register names. Must be "ibb".
- regulator-name:		A string used to describe the regulator.
- regulator-min-microvolt:	Minimum voltage in microvolts supported by this regulator.
- regulator-max-microvolt:	Maximum voltage in microvolts supported by this regulator.

- qcom,qpnp-ibb-min-voltage:	The voltage in microvolts this IBB regulator suppored
- qcom,qpnp-ibb-step-size:	The step size in microvolts of IBB regulator
- qcom,qpnp-ibb-slew-rate:	The time in us it takes for the regulator to change votlage value in one step.
- qcom,qpnp-ibb-min-voltage:	The minimum voltage in microvolts IBB regulator can support.
- qcom,qpnp-ibb-step-size:	The step size in microvolts of IBB regulator.
- qcom,qpnp-ibb-slew-rate:	The time in us taken by the regulator to change
				voltage value in one step.
- qcom,qpnp-ibb-soft-start:	The soft start time in us of IBB regulator.

- qcom,qpnp-ibb-init-voltage:	The default initial voltage  when the bootloader does not turn on LAB regulator.
- qcom,qpnp-lab-init-amoled-voltage: The default voltage when IBB regulator working in amoled mode and the output voltage register of value 0
- qcom,qpnp-lab-init-lcd-voltage: The default voltage when IBB regulator working in lcd mode and the output voltage register of value 0

- qcom,qpnp-ibb-discharge-resistor:	The discharge resistor in Kilo Ohm who controls the soft start time. Supported values are 300, 64, 32 and 16.
- qcom,qpnp-ibb-lab-pwrup-delay:	Power up delay (in us) for IBB regulator when it is enabled or turned on. Supported value are 1000, 2000, 4000 and 8000.
- qcom,qpnp-ibb-lab-pwrdn-delay:	Power down delay (in us) for IBB regulator when it is disabled or turned off. Supported value are 1000, 2000, 4000 and 8000.

- qcom,qpnp-ibb-switching-clock-frequency:	The PWM switching clock frequency in kHz of IBB regulator, supported value are
						3200, 	2740, 	2400,  	2130, 	1920, 	1750,	1600,	1480,	1370,	1280,
						1200,	1130,	1070,	1010,	960,	910.
- qcom,qpnp-ibb-limit-maximum-current:		The maximum inductor current limit in mA of IBB regulator. Supported value are
						0,	50,	100,	150,	200,	250,	300,	350,	400,	450,
						500,	550,	600,	650,	700,	750,	800,	850,	900,	950,
						1000,	1050,	1100,	1150,	1200,	1250,	1300,	1350,	1400,	1450,	1500,	1550.
- qcom,qpnp-ibb-debounce-cycle:			The debounce cycle of IBB regulator. Supported value are 8, 16, 32 and 64.

Sub IBB node optional structure:
- qcom,qpnp-ibb-en-discharge:			If this property is present, discharge will be enabled for IBB regulator. Otherwise, it will be disabled.
- qcom,qpnp-ibb-ring-suppression-enable:	If this property is present, low noise PS mode will be enabled for IBB regulator. Otherwise, it will be disabled.
- qcom,qpnp-ibb-ps-enable:		If this proerty is present, pulse skip mode will be enabled for IBB regulator. Othwise, pulse skip mode will be disabled for IBB regulator.
- qcom,qpnp-ibb-full-pull-down:		If this property is present, the pull down strength of IBB regulator will full. Otherwise, the pull down strength will be half.
- qcom,qpnp-ibb-pull-down-enable:	If this property is present, pull down is enabled for IBB regulator. Otherwise, pull down is disabled for IBB regulator.
- qcom,qpnp-ibb-limit-max-current-enable:	If this property is present, maximum inductor current constraint is put for IBB regulator. Otherwise, There is no maximum current constraint.
- qcom,qpnp-ibb-use-default-voltage:		When bootloader does not turn on IBB regulator and this property is present, value specified in qcom,qpnp-ibb-init-voltage is the default init voltage when the voltage output register is of value 0. Otherwise, we need to enable the output override bit in voltage output register.
- qcom,qpnp-ibb-init-voltage:	The default initial voltage when the bootloader does
				not turn on IBB regulator.
- qcom,qpnp-ibb-init-amoled-voltage:	The default output voltage when IBB regulator
					is configured in amoled mode.
- qcom,qpnp-ibb-init-lcd-voltage: 	The default output voltage when IBB regulator
					is configured in lcd mode.

- qcom,qpnp-ibb-discharge-resistor:	The discharge resistor in Kilo Ohms which
					controls the soft start time. Supported values
					are 300, 64, 32 and 16.
- qcom,qpnp-ibb-lab-pwrup-delay:	Power up delay (in us) for IBB regulator when
					it is enabled or turned on. Supported values
					are 1000, 2000, 4000 and 8000.
- qcom,qpnp-ibb-lab-pwrdn-delay:	Power down delay (in us) for IBB regulator
					when it is disabled or turned off. Supported
					values are 1000, 2000, 4000 and 8000.

- qcom,qpnp-ibb-switching-clock-frequency:	The PWM switching clock frequency in
						kHz of IBB regulator. Supported values
						are: 3200, 2740, 2400, 2130, 1920,
						1750, 1600, 1480, 1370, 1280, 1200,
						1130, 1070, 1010, 960, 910.
- qcom,qpnp-ibb-limit-maximum-current:		The maximum inductor current limit in
						mA of IBB regulator. Supported values
						are: 0,	50, 100, 150, 200, 250,	300,
						350, 400, 450, 500, 550, 600, 650, 700,
						750, 800, 850, 900, 950, 1000, 1050,
						1100, 1150, 1200, 1250,	1300, 1350,
						1400, 1450, 1500 and 1550.
- qcom,qpnp-ibb-debounce-cycle:			The debounce cycle of IBB regulator.
						Supported values are 8, 16, 32 and 64.

IBB subnode optional properties:

- qcom,qpnp-ibb-ps-enable:		A boolean property which upon set will enable
					pulse skip mode for IBB regulator. Otherwise,
					it is disabled.
- qcom,qpnp-ibb-full-pull-down:		A boolean property which upon set will enable
					the pull down strength of IBB regulator to
					full. Otherwise, the pull down strength is
					configured to half.
- qcom,qpnp-ibb-pull-down-enable:	A boolean property which upon set will enable
					the pull down for IBB regulator. Otherwise,
					it is disabled.
- qcom,qpnp-ibb-en-discharge:			A boolean property which upon set will
						enable discharge for IBB regulator.
						Otherwise, it is kept disabled.
- qcom,qpnp-ibb-ring-suppression-enable:	A boolean property which upon set will
						enable ring suppression for IBB
						regulator. Otherwise, it is disabled.
- qcom,qpnp-ibb-limit-max-current-enable:	A boolean property which upon set will
						enforce maximum inductor current constraint
						for IBB regulator. Otherwise, there is no
						maximum current constraint.
- qcom,qpnp-ibb-use-default-voltage:		A boolean property which upon set will
						use the value specified in
						qcom,qpnp-ibb-init-voltage property.
						This will be used only if the bootloader
						doesn't configure the output voltage
						already. If it it not specified, then
						output voltage can be configured to
						any value in the allowed limit.

Example:
	qcom,pmi8994@3 {
+62 −93
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@
 * GNU General Public License for more details.
 */

#define pr_fmt(fmt)	"%s: " fmt, __func__

#include <linux/init.h>
#include <linux/delay.h>
#include <linux/err.h>
@@ -33,6 +35,7 @@
/* Common register value for LAB/IBB */
#define REG_LAB_IBB_LCD_MODE		0x0
#define REG_LAB_IBB_AMOLED_MODE		BIT(7)
#define REG_LAB_IBB_SEC_ACCESS		0xD0
#define REG_LAB_IBB_SEC_UNLOCK_CODE	0xA5

/* LAB register offset definitions */
@@ -51,7 +54,6 @@
#define REG_LAB_RDSON_MNGMNT		0x53
#define REG_LAB_PRECHARGE_CTL		0x5E
#define REG_LAB_SOFT_START_CTL		0x5F
#define REG_LAB_SEC_ACCESS		0xD0

/* LAB register bits definitions */

@@ -129,7 +131,6 @@
#define REG_IBB_PWRUP_PWRDN_CTL_1	0x58
#define REG_IBB_SOFT_START_CTL		0x5F
#define REG_IBB_NLIMIT_DAC		0x61
#define REG_IBB_SEC_ACCESS		0xD0

/* IBB register bits definition */

@@ -468,30 +469,47 @@ qpnp_labibb_masked_write(struct qpnp_labibb *labibb, u16 base,
	return 0;
}

static int qpnp_lab_unlock_sec_access(struct qpnp_labibb *labibb)
static int qpnp_labibb_sec_write(struct qpnp_labibb *labibb, u16 base,
					u8 offset, u8 *val, int count)
{
	int rc;
	u8 val = REG_LAB_IBB_SEC_UNLOCK_CODE;
	u8 sec_val = REG_LAB_IBB_SEC_UNLOCK_CODE;

	rc = qpnp_labibb_write(labibb, labibb->lab_base + REG_LAB_SEC_ACCESS,
		&val, 1);
	rc = qpnp_labibb_write(labibb, base + REG_LAB_IBB_SEC_ACCESS, &sec_val,
				1);
	if (rc) {
		pr_err("qpnp_lab_write register %x failed rc = %d\n",
			base + REG_LAB_IBB_SEC_ACCESS, rc);
		return rc;
	}

	rc = qpnp_labibb_write(labibb, base + offset, val, count);
	if (rc)
		pr_err("qpnp_lab_unlock_sec_access write register %x failed rc = %d\n",
			REG_LAB_SEC_ACCESS, rc);
		pr_err("qpnp_labibb_write failed: addr=%03X, rc=%d\n",
			base + offset, rc);

	return rc;
}

static int qpnp_ibb_unlock_sec_access(struct qpnp_labibb *labibb)
static int qpnp_labibb_sec_masked_write(struct qpnp_labibb *labibb, u16 base,
					u8 offset, u8 mask, u8 val, int count)
{
	int rc;
	u8 val = REG_LAB_IBB_SEC_UNLOCK_CODE;
	u8 sec_val = REG_LAB_IBB_SEC_UNLOCK_CODE;

	rc = qpnp_labibb_write(labibb,
			labibb->ibb_base + REG_IBB_SEC_ACCESS, &val, 1);
	rc = qpnp_labibb_write(labibb, base + REG_LAB_IBB_SEC_ACCESS, &sec_val,
				1);
	if (rc) {
		pr_err("qpnp_lab_write register %x failed rc = %d\n",
			base + REG_LAB_IBB_SEC_ACCESS, rc);
		return rc;
	}

	rc = qpnp_labibb_masked_write(labibb, base + offset, mask, val, count);
	if (rc)
		pr_err("qpnp_ibb_unlock_sec_access write register %x failed rc = %d\n",
			REG_IBB_SEC_ACCESS, rc);
		pr_err("qpnp_lab_write register %x failed rc = %d\n",
			base + offset, rc);

	return rc;
}

@@ -514,42 +532,26 @@ static int qpnp_lab_dt_init(struct qpnp_labibb *labibb,
	u32 tmp;

	if (labibb->mode != QPNP_LABIBB_STANDALONE_MODE) {
		rc = qpnp_lab_unlock_sec_access(labibb);

		if (rc) {
			pr_err("unlock lab secure register failed rc = %d\n",
				rc);
			return rc;
		}

		if (labibb->mode == QPNP_LABIBB_LCD_MODE)
			val = REG_LAB_IBB_LCD_MODE;
		else
			val = REG_LAB_IBB_AMOLED_MODE;

		rc = qpnp_labibb_write(labibb, labibb->lab_base +
		rc = qpnp_labibb_sec_write(labibb, labibb->lab_base,
				REG_LAB_LCD_AMOLED_SEL, &val, 1);

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

		rc = qpnp_lab_unlock_sec_access(labibb);

		if (rc) {
			pr_err("unlock lab secure register failed rc = %d\n",
				rc);
			return rc;
		}

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

		if (rc) {
			pr_err("qpnp_lab_dt_init write register %x failed rc = %d\n",
			pr_err("qpnp_lab_sec_write register %x failed rc = %d\n",
				REG_LAB_IBB_EN_RDY, rc);
			return rc;
		}
@@ -778,8 +780,8 @@ static int qpnp_labibb_regulator_enable(struct qpnp_labibb *labibb)
		&val, 1);

	if (rc) {
		pr_err("%s: write register %x failed rc = %d\n",
				__func__, REG_IBB_ENABLE_CTL, rc);
		pr_err("write register %x failed rc = %d\n",
			REG_IBB_ENABLE_CTL, rc);
		return rc;
	}

@@ -792,17 +794,17 @@ static int qpnp_labibb_regulator_enable(struct qpnp_labibb *labibb)
	rc = qpnp_labibb_read(labibb, &val,
			labibb->lab_base + REG_LAB_STATUS1, 1);
	if (rc) {
		pr_err("%s: read register %x failed rc = %d\n",
				__func__, REG_LAB_STATUS1, rc);
		pr_err("read register %x failed rc = %d\n",
			REG_LAB_STATUS1, rc);
		goto err_out;
	}

	pr_debug("%s: soft=%d %d up=%d dly=%d\n", __func__,
	pr_debug("soft=%d %d up=%d dly=%d\n",
		labibb->lab_vreg.soft_start, labibb->ibb_vreg.soft_start,
				labibb->ibb_vreg.pwrup_dly, dly);

	if (!(val & LAB_STATUS1_VREG_OK)) {
		pr_err("%s:  failed for LAB %x\n", __func__, val);
		pr_err("failed for LAB %x\n", val);
		goto err_out;
	}

@@ -813,8 +815,8 @@ static int qpnp_labibb_regulator_enable(struct qpnp_labibb *labibb)
		rc = qpnp_labibb_read(labibb, &val,
				labibb->ibb_base + REG_IBB_STATUS1, 1);
		if (rc) {
			pr_err("%s: read register %x failed rc = %d\n",
				__func__, REG_IBB_STATUS1, rc);
			pr_err("read register %x failed rc = %d\n",
				REG_IBB_STATUS1, rc);
			goto err_out;
		}

@@ -826,7 +828,7 @@ static int qpnp_labibb_regulator_enable(struct qpnp_labibb *labibb)
	}

	if (!enabled) {
		pr_err("%s:  failed for IBB %x\n", __func__, val);
		pr_err("failed for IBB %x\n", val);
		goto err_out;
	}

@@ -839,8 +841,8 @@ err_out:
	rc = qpnp_labibb_write(labibb, labibb->ibb_base + REG_IBB_ENABLE_CTL,
		&val, 1);
	if (rc)
		pr_err("%s: write register %x failed rc = %d\n",
				__func__, REG_IBB_ENABLE_CTL, rc);
		pr_err("write register %x failed rc = %d\n",
				REG_IBB_ENABLE_CTL, rc);
	return -EINVAL;
}

@@ -856,8 +858,8 @@ static int qpnp_labibb_regulator_disable(struct qpnp_labibb *labibb)
	rc = qpnp_labibb_write(labibb,
			labibb->ibb_base + REG_IBB_ENABLE_CTL, &val, 1);
	if (rc) {
		pr_err("%s: write register %x failed rc = %d\n",
			__func__, REG_IBB_ENABLE_CTL, rc);
		pr_err("write register %x failed rc = %d\n",
			REG_IBB_ENABLE_CTL, rc);
		return rc;
	}

@@ -869,8 +871,8 @@ static int qpnp_labibb_regulator_disable(struct qpnp_labibb *labibb)
		rc = qpnp_labibb_read(labibb, &val,
				labibb->ibb_base + REG_IBB_STATUS1, 1);
		if (rc) {
			pr_err("%s: read register %x failed rc = %d\n",
				__func__, REG_IBB_STATUS1, rc);
			pr_err("read register %x failed rc = %d\n",
				REG_IBB_STATUS1, rc);
			return rc;
		}

@@ -881,7 +883,7 @@ static int qpnp_labibb_regulator_disable(struct qpnp_labibb *labibb)
	}

	if (!disabled) {
		pr_err("%s:  failed for IBB %x\n", __func__, val);
		pr_err("failed for IBB %x\n", val);
		return -EINVAL;
	}

@@ -1447,13 +1449,7 @@ int qpnp_ibb_set_pwrup_dly(struct regulator *regulator, u32 val)
		goto _exit;
	}

	rc = qpnp_ibb_unlock_sec_access(labibb);
	if (rc) {
		pr_err("unlock ibb secure register failed rc = %d\n", rc);
		goto _exit;
	}

	rc = qpnp_labibb_masked_write(labibb, labibb->ibb_base +
	rc = qpnp_labibb_sec_masked_write(labibb, labibb->ibb_base,
				REG_IBB_PWRUP_PWRDN_CTL_1,
				IBB_PWRUP_PWRDN_CTL_1_DLY1_MASK <<
				IBB_PWRUP_PWRDN_CTL_1_DLY1_SHIFT,
@@ -1461,7 +1457,7 @@ int qpnp_ibb_set_pwrup_dly(struct regulator *regulator, u32 val)
				1);

	if (rc) {
		pr_err("qpnp_ibb_set_pwrup write register %x failed rc = %d\n",
		pr_err("qpnp_ibb_sec_masked_write register %x failed rc = %d\n",
			REG_IBB_PWRUP_PWRDN_CTL_1, rc);
		goto _exit;
	}
@@ -1499,20 +1495,14 @@ int qpnp_ibb_set_pwrdn_dly(struct regulator *regulator, u32 val)
		goto _exit;
	}

	rc = qpnp_ibb_unlock_sec_access(labibb);
	if (rc) {
		pr_err("unlock ibb secure register failed rc = %d\n", rc);
		goto _exit;
	}

	rc = qpnp_labibb_masked_write(labibb, labibb->ibb_base +
	rc = qpnp_labibb_sec_masked_write(labibb, labibb->ibb_base,
				REG_IBB_PWRUP_PWRDN_CTL_1,
				IBB_PWRUP_PWRDN_CTL_1_DLY2_MASK,
				reg,
				1);

	if (rc) {
		pr_err("qpnp_ibb_set_pwrdn write register %x failed rc = %d\n",
		pr_err("qpnp_labibb_sec_masked_write register %x failed rc = %d\n",
			REG_IBB_PWRUP_PWRDN_CTL_1, rc);
		goto _exit;
	}
@@ -1533,24 +1523,16 @@ static int qpnp_ibb_dt_init(struct qpnp_labibb *labibb,
	u8 val;

	if (labibb->mode != QPNP_LABIBB_STANDALONE_MODE) {
		rc = qpnp_ibb_unlock_sec_access(labibb);

		if (rc) {
			pr_err("unlock ibb secure register failed rc = %d\n",
				rc);
			return rc;
		}

		if (labibb->mode == QPNP_LABIBB_LCD_MODE)
			val = REG_LAB_IBB_LCD_MODE;
		else
			val = REG_LAB_IBB_AMOLED_MODE;

		rc = qpnp_labibb_write(labibb, labibb->ibb_base +
		rc = qpnp_labibb_sec_write(labibb, labibb->ibb_base,
				REG_LAB_LCD_AMOLED_SEL, &val, 1);

		if (rc) {
			pr_err("qpnp_ibb_dt_init write register %x failed rc = %d\n",
			pr_err("qpnp_labibb_sec_write register %x failed rc = %d\n",
				REG_IBB_LCD_AMOLED_SEL, rc);
			return rc;
		}
@@ -1605,19 +1587,12 @@ static int qpnp_ibb_dt_init(struct qpnp_labibb *labibb,
		val |= (IBB_PWRUP_PWRDN_CTL_1_EN_DLY1 |
				IBB_PWRUP_PWRDN_CTL_1_LAB_VREG_OK);

	rc = qpnp_ibb_unlock_sec_access(labibb);

	if (rc) {
		pr_err("unlock ibb secure register failed rc = %d\n", rc);
		return rc;
	}

	rc = qpnp_labibb_write(labibb, labibb->ibb_base +
	rc = qpnp_labibb_sec_write(labibb, labibb->ibb_base,
				REG_IBB_PWRUP_PWRDN_CTL_1,
				&val,
				1);
	if (rc) {
		pr_err("qpnp_ibb_set_pwrdn write register %x failed rc = %d\n",
		pr_err("qpnp_labibb_sec_write register %x failed rc = %d\n",
			REG_IBB_PWRUP_PWRDN_CTL_1, rc);
		return rc;
	}
@@ -1706,18 +1681,12 @@ static int qpnp_ibb_dt_init(struct qpnp_labibb *labibb,
		"qcom,qpnp-ibb-limit-max-current-enable"))
		val |= IBB_CURRENT_LIMIT_EN;

	rc = qpnp_ibb_unlock_sec_access(labibb);
	if (rc) {
		pr_err("unlock ibb secure register failed rc = %d\n", rc);
		return rc;
	}

	rc = qpnp_labibb_write(labibb, labibb->ibb_base +
	rc = qpnp_labibb_sec_write(labibb, labibb->ibb_base,
					REG_IBB_CURRENT_LIMIT,
					&val,
					1);
	if (rc) {
		pr_err("qpnp_ibb_dt_init write register %x failed rc = %d\n",
		pr_err("qpnp_labibb_sec_write register %x failed rc = %d\n",
				REG_IBB_CURRENT_LIMIT, rc);
		return rc;
	}