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

Commit 8b4c2654 authored by Mohan Pallaka's avatar Mohan Pallaka
Browse files

leds: qpnp-wled: avoid false ovp on module enable



False ovp (over voltage protection) can be triggered
when the module is enabled. Avoid this scenario by
disabling the ovp before enabling the module. Enable
ovp after the module is enabled.

Change-Id: Icaa390b61ae2b09e21b10b801b8e22b0e6da5c3d
Signed-off-by: default avatarMohan Pallaka <mpallaka@codeaurora.org>
parent d9642cc2
Loading
Loading
Loading
Loading
+34 −6
Original line number Diff line number Diff line
@@ -40,7 +40,8 @@
#define QPNP_WLED_OVP_REG(b)		(b + 0x4D)
#define QPNP_WLED_ILIM_REG(b)		(b + 0x4E)
#define QPNP_WLED_SC_PRO_REG(b)		(b + 0x5E)
#define QPNP_WLED_TEST_REG(b)		(b + 0xE2)
#define QPNP_WLED_TEST1_REG(b)		(b + 0xE2)
#define QPNP_WLED_TEST3_REG(b)		(b + 0xE4)

#define QPNP_WLED_EN_MASK		0x7F
#define QPNP_WLED_EN_SHIFT		7
@@ -69,6 +70,9 @@
#define QPNP_WLED_OVP_19400_MV		19400
#define QPNP_WLED_OVP_29500_MV		29500
#define QPNP_WLED_OVP_31000_MV		31000
#define QPNP_WLED_TEST3_OVP_DIS		0x1F
#define QPNP_WLED_TEST3_OVP_EN		0x3F
#define QPNP_WLED_TEST3_OVP_DLY_US	100

/* sink registers */
#define QPNP_WLED_CURR_SINK_REG(b)	(b + 0x46)
@@ -199,8 +203,6 @@ static u8 qpnp_wled_sink_dbg_regs[] = {
 *  @ sc_cnt - short circuit irq count
 *  @ ctrl_base - base address for wled ctrl
 *  @ sink_base - base address for wled sink
 *  @ ibb_base - base address for IBB(Inverting Buck Boost)
 *  @ lab_base - base address for LAB(LCD/AMOLED Boost)
 *  @ mod_freq_khz - modulator frequency in KHZ
 *  @ hyb_thres - threshold for hybrid dimming
 *  @ sync_dly_us - sync delay in us
@@ -219,8 +221,6 @@ static u8 qpnp_wled_sink_dbg_regs[] = {
 *  @ en_phase_stag - enable or disable phase staggering
 *  @ en_cabc - enable or disable cabc
 *  @ disp_type_amoled - type of display: LCD/AMOLED
 *  @ ibb_bias_active - activate display bias
 *  @ lab_fast_precharge - fast/slow precharge
 *  @ en_ext_pfet_sc_pro - enable sc protection on external pfet
 */
struct qpnp_wled {
@@ -349,6 +349,19 @@ static int qpnp_wled_module_en(struct qpnp_wled *wled,
	int rc;
	u8 reg;

	/* false OVP can be generated when module is enabled so disable it*/
	if (state) {
		rc = qpnp_wled_sec_access(wled, base_addr);
		if (rc)
			return rc;

		reg = QPNP_WLED_TEST3_OVP_DIS;
		rc = qpnp_wled_write_reg(wled, &reg,
				QPNP_WLED_TEST3_REG(base_addr));
		if (rc)
			return rc;
	}

	rc = qpnp_wled_read_reg(wled, &reg,
			QPNP_WLED_MODULE_EN_REG(base_addr));
	if (rc < 0)
@@ -360,6 +373,21 @@ static int qpnp_wled_module_en(struct qpnp_wled *wled,
	if (rc)
		return rc;

	/* enable OVP */
	if (state) {
		usleep_range(QPNP_WLED_TEST3_OVP_DLY_US,
				QPNP_WLED_TEST3_OVP_DLY_US + 1);
		rc = qpnp_wled_sec_access(wled, base_addr);
		if (rc)
			return rc;

		reg = QPNP_WLED_TEST3_OVP_EN;
		rc = qpnp_wled_write_reg(wled, &reg,
				QPNP_WLED_TEST3_REG(base_addr));
		if (rc)
			return rc;
	}

	return 0;
}

@@ -1119,7 +1147,7 @@ static int qpnp_wled_config(struct qpnp_wled *wled)

			reg = QPNP_WLED_EXT_FET_DTEST2;
			rc = qpnp_wled_write_reg(wled, &reg,
					QPNP_WLED_TEST_REG(wled->ctrl_base));
					QPNP_WLED_TEST1_REG(wled->ctrl_base));
			if (rc)
				return rc;
		}