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

Commit c283f211 authored by Alex Sarraf's avatar Alex Sarraf
Browse files

leds: qpnp-wled: disable OVP fault interrupt before module enable



Disable OVP fault interrupt before module enable then reenable
no later than 10us.

Change-Id: I4fedc457f1653185f6815d6b84d4b9cc0879f2ca
Signed-off-by: default avatarAlex Sarraf <asarraf@codeaurora.org>
parent 73670fdd
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#define QPNP_WLED_SINK_BASE		"qpnp-wled-sink-base"

/* ctrl registers */
#define QPNP_WLED_INT_EN_SET(b)		(b + 0x15)
#define QPNP_WLED_EN_REG(b)		(b + 0x46)
#define QPNP_WLED_FDBK_OP_REG(b)	(b + 0x48)
#define QPNP_WLED_VREF_REG(b)		(b + 0x49)
@@ -71,6 +72,9 @@
#define QPNP_WLED_OVP_29500_MV		29500
#define QPNP_WLED_OVP_31000_MV		31000
#define QPNP_WLED_TEST4_EN_VREF_UP	0x32
#define QPNP_WLED_INT_EN_SET_OVP_DIS	0x00
#define QPNP_WLED_INT_EN_SET_OVP_EN	0x02
#define QPNP_WLED_OVP_FLT_SLEEP_US	10

/* sink registers */
#define QPNP_WLED_CURR_SINK_REG(b)	(b + 0x46)
@@ -352,6 +356,15 @@ static int qpnp_wled_module_en(struct qpnp_wled *wled,
	int rc;
	u8 reg;

	/* disable OVP fault interrupt */
	if (state) {
		reg = QPNP_WLED_INT_EN_SET_OVP_DIS;
		rc = qpnp_wled_write_reg(wled, &reg,
				QPNP_WLED_INT_EN_SET(base_addr));
		if (rc)
			return rc;
	}

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

	/* enable OVP fault interrupt */
	if (state) {
		udelay(QPNP_WLED_OVP_FLT_SLEEP_US);
		reg = QPNP_WLED_INT_EN_SET_OVP_EN;
		rc = qpnp_wled_write_reg(wled, &reg,
				QPNP_WLED_INT_EN_SET(base_addr));
		if (rc)
			return rc;
	}

	return 0;
}