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

Commit f6ed50fb authored by Jigarkumar Kishorkumar Zala's avatar Jigarkumar Kishorkumar Zala
Browse files

leds: leds-qpnp-wled: remove IBB/LAB initialization and operations



Remove IBB/LAB initialization and operations, as IBB/LAB for display
panel is set by PMIC

CRs Fixed: 857820
Change-Id: I3b345275fbe6e8d185d4d24ea8a30cccd36bf68b
Signed-off-by: default avatarJigarkumar Kishorkumar Zala <j_zala@codeaurora.org>
parent a5eb2c93
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -41,10 +41,6 @@ Optional properties for WLED:
- qcom,en-9b-dim-res	: boolean, specify if 9-bit dim resultion is needed. otherwise 12-bit is used.
- qcom,en-phase-stag	: boolean, specify if phase staggering is needed.
- qcom,en-cabc		: boolean, specify if cabc (content adaptive backlight control) is needed.
- qcom,ibb-bias-active	: boolean, specify to activate the bias
- qcom,ibb-pwrup-dly	: ibb power up delay in milli seconds. The supported values are 1 to 8.
			  default is 1.
- qcom,lab-fast-precharge: boolean, specify to activate the fast precharge
- qcom,disp-type-amoled	: specify if the display is amoled
- qcom,led-strings-list	: Wled module has four strings of leds numbered from 0 to 3. each string of leds
			  are operated individually. specify the list of strings used by the device.
@@ -80,7 +76,6 @@ Example:
		qcom,sync-dly-us = <800>;
		qcom,fs-curr-ua = <16000>;
		qcom,en-phase-stag;
		qcom,ibb-pwrup-dly = <8>;
		qcom,led-strings-list = [00 01 02 03];
		qcom,en-ext-pfet-sc-pro;
	};
+0 −201
Original line number Diff line number Diff line
@@ -30,8 +30,6 @@
/* base addresses */
#define QPNP_WLED_CTRL_BASE		"qpnp-wled-ctrl-base"
#define QPNP_WLED_SINK_BASE		"qpnp-wled-sink-base"
#define QPNP_WLED_IBB_BASE		"qpnp-wled-ibb-base"
#define QPNP_WLED_LAB_BASE		"qpnp-wled-lab-base"

/* ctrl registers */
#define QPNP_WLED_EN_REG(b)		(b + 0x46)
@@ -144,20 +142,6 @@
#define QPNP_WLED_EN_SC_SHIFT		7
#define QPNP_WLED_EXT_FET_DTEST2	0x09

#define QPNP_WLED_IBB_BIAS_REG(b)	(b + 0x58)
#define QPNP_WLED_IBB_BIAS_MASK		0x7F
#define QPNP_WLED_IBB_BIAS_SHIFT	7
#define QPNP_WLED_IBB_PWRUP_DLY_MASK	0xCF
#define QPNP_WLED_IBB_PWRUP_DLY_SHIFT	4
#define QPNP_WLED_IBB_PWRUP_DLY_MIN_MS	1
#define QPNP_WLED_IBB_PWRUP_DLY_MAX_MS	8

#define QPNP_WLED_LAB_IBB_RDY_REG(b)	(b + 0x49)
#define QPNP_WLED_LAB_FAST_PC_REG(b)	(b + 0x5E)
#define QPNP_WLED_LAB_FAST_PC_MASK	0xFB
#define QPNP_WLED_LAB_START_DLY_US	8
#define QPNP_WLED_LAB_FAST_PC_SHIFT	2

#define QPNP_WLED_SEC_ACCESS_REG(b)    (b + 0xD0)
#define QPNP_WLED_SEC_UNLOCK           0xA5

@@ -201,16 +185,6 @@ static u8 qpnp_wled_sink_dbg_regs[] = {
	0xe6,
};

/* wled ibb debug registers */
static u8 qpnp_wled_ibb_dbg_regs[] = {
	0x08, 0x09, 0x0A, 0x44, 0x45, 0x46, 0x50, 0x53, 0x56, 0x57, 0x58, 0x61
};

/* wled lab debug registers */
static u8 qpnp_wled_lab_dbg_regs[] = {
	0x08, 0x44, 0x45, 0x46, 0x49, 0x5e
};

/**
 *  qpnp_wled - wed data structure
 *  @ cdev - led class device
@@ -259,8 +233,6 @@ struct qpnp_wled {
	u32 sc_cnt;
	u16 ctrl_base;
	u16 sink_base;
	u16 ibb_base;
	u16 lab_base;
	u16 mod_freq_khz;
	u16 hyb_thres;
	u16 sync_dly_us;
@@ -270,7 +242,6 @@ struct qpnp_wled {
	u16 ilim_ma;
	u16 boost_duty_ns;
	u16 fs_curr_ua;
	u16 ibb_pwrup_dly_ms;
	u16 ramp_ms;
	u16 ramp_step;
	u8 strings[QPNP_WLED_MAX_STRINGS];
@@ -279,13 +250,9 @@ struct qpnp_wled {
	bool en_phase_stag;
	bool en_cabc;
	bool disp_type_amoled;
	bool ibb_bias_active;
	bool lab_fast_precharge;
	bool en_ext_pfet_sc_pro;
};

static struct qpnp_wled *gwled;

/* helper to read a pmic register */
static int qpnp_wled_read_reg(struct qpnp_wled *wled, u8 *data, u16 addr)
{
@@ -513,18 +480,6 @@ static ssize_t qpnp_wled_dump_regs_show(struct device *dev,
	if (count < 0 || count == PAGE_SIZE - 1)
		return count;

	count = qpnp_wled_dump_regs(wled, wled->ibb_base,
			qpnp_wled_ibb_dbg_regs,
			ARRAY_SIZE(qpnp_wled_ibb_dbg_regs),
			"wled_ibb", count, buf);

	if (count < 0 || count == PAGE_SIZE - 1)
		return count;

	count = qpnp_wled_dump_regs(wled, wled->lab_base,
			qpnp_wled_lab_dbg_regs,
			ARRAY_SIZE(qpnp_wled_lab_dbg_regs),
			"wled_lab", count, buf);
	return count;
}

@@ -647,44 +602,6 @@ static ssize_t qpnp_wled_fs_curr_ua_show(struct device *dev,
	return snprintf(buf, PAGE_SIZE, "%d\n", wled->fs_curr_ua);
}

int qpnp_ibb_enable(bool state)
{
	int rc;
	u8 reg;

	if (!gwled) {
		pr_err("%s: wled is not initialized yet\n", __func__);
		return -EAGAIN;
	}

	/* enable lab */
	if (gwled->ibb_bias_active) {
		rc = qpnp_wled_module_en(gwled, gwled->lab_base, state);
		if (rc < 0)
			return rc;
		usleep_range(QPNP_WLED_LAB_START_DLY_US,
				QPNP_WLED_LAB_START_DLY_US + 1);
	} else {
		rc = qpnp_wled_read_reg(gwled, &reg,
				QPNP_WLED_LAB_IBB_RDY_REG(gwled->lab_base));
		if (rc < 0)
			return rc;
		reg &= QPNP_WLED_MODULE_EN_MASK;
		reg |= (state << QPNP_WLED_MODULE_EN_SHIFT);
		rc = qpnp_wled_write_reg(gwled, &reg,
				QPNP_WLED_LAB_IBB_RDY_REG(gwled->lab_base));
		if (rc)
			return rc;
	}

	rc = qpnp_wled_module_en(gwled, gwled->ibb_base, state);
	if (rc < 0)
		return rc;

	return 0;
}
EXPORT_SYMBOL(qpnp_ibb_enable);

/* sysfs store function for full scale current in ua*/
static ssize_t qpnp_wled_fs_curr_ua_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t count)
@@ -815,11 +732,6 @@ static int qpnp_wled_set_disp(struct qpnp_wled *wled, u16 base_addr)

	reg &= QPNP_WLED_DISP_SEL_MASK;
	reg |= (wled->disp_type_amoled << QPNP_WLED_DISP_SEL_SHIFT);

	rc = qpnp_wled_sec_access(wled, base_addr);
	if (rc)
		return rc;

	rc = qpnp_wled_write_reg(wled, &reg,
			QPNP_WLED_DISP_SEL_REG(base_addr));
	if (rc)
@@ -828,25 +740,6 @@ static int qpnp_wled_set_disp(struct qpnp_wled *wled, u16 base_addr)
	return 0;
}

static int qpnp_wled_mod_rdy(struct qpnp_wled *wled, u16 base_addr, bool state)
{
	int rc;
	u8 reg;

	rc = qpnp_wled_read_reg(wled, &reg,
			QPNP_WLED_MODULE_RDY_REG(base_addr));
	if (rc < 0)
		return rc;
	reg &= QPNP_WLED_MODULE_RDY_MASK;
	reg |= (state << QPNP_WLED_MODULE_RDY_SHIFT);
	rc = qpnp_wled_write_reg(wled, &reg,
			QPNP_WLED_MODULE_RDY_REG(base_addr));
	if (rc)
		return rc;

	return 0;
}

/* ovp irq handler */
static irqreturn_t qpnp_wled_ovp_irq(int irq, void *_wled)
{
@@ -1170,64 +1063,6 @@ static int qpnp_wled_config(struct qpnp_wled *wled)
			return rc;
	}

	/* LAB fast precharge */
	rc = qpnp_wled_read_reg(wled, &reg,
			QPNP_WLED_LAB_FAST_PC_REG(wled->lab_base));
	if (rc < 0)
		return rc;
	reg &= QPNP_WLED_LAB_FAST_PC_MASK;
	reg |= (wled->lab_fast_precharge << QPNP_WLED_LAB_FAST_PC_SHIFT);
	rc = qpnp_wled_write_reg(wled, &reg,
			QPNP_WLED_LAB_FAST_PC_REG(wled->lab_base));
	if (rc)
		return rc;

	/* Configure lab display type */
	rc = qpnp_wled_set_disp(wled, wled->lab_base);
	if (rc < 0)
		return rc;

	/* make LAB module ready */
	rc = qpnp_wled_mod_rdy(wled, wled->lab_base, true);
	if (rc < 0)
		return rc;

	/* IBB active bias */
	if (wled->ibb_pwrup_dly_ms < QPNP_WLED_IBB_PWRUP_DLY_MIN_MS)
		wled->ibb_pwrup_dly_ms = QPNP_WLED_IBB_PWRUP_DLY_MIN_MS;
	else if (wled->ibb_pwrup_dly_ms > QPNP_WLED_IBB_PWRUP_DLY_MAX_MS)
		wled->ibb_pwrup_dly_ms = QPNP_WLED_IBB_PWRUP_DLY_MAX_MS;

	rc = qpnp_wled_read_reg(wled, &reg,
			QPNP_WLED_IBB_BIAS_REG(wled->ibb_base));
	if (rc < 0)
		return rc;
	reg &= QPNP_WLED_IBB_BIAS_MASK;
	reg |= (!wled->ibb_bias_active << QPNP_WLED_IBB_BIAS_SHIFT);

	temp = fls(wled->ibb_pwrup_dly_ms) - 1;
	reg &= QPNP_WLED_IBB_PWRUP_DLY_MASK;
	reg |= (temp << QPNP_WLED_IBB_PWRUP_DLY_SHIFT);

	rc = qpnp_wled_sec_access(wled, wled->ibb_base);
	if (rc)
		return rc;

	rc = qpnp_wled_write_reg(wled, &reg,
			QPNP_WLED_IBB_BIAS_REG(wled->ibb_base));
	if (rc)
		return rc;

	/* Configure ibb display type */
	rc = qpnp_wled_set_disp(wled, wled->ibb_base);
	if (rc < 0)
		return rc;

	/* make IBB module ready */
	rc = qpnp_wled_mod_rdy(wled, wled->ibb_base, true);
	if (rc < 0)
		return rc;

	/* setup ovp and sc irqs */
	if (wled->ovp_irq >= 0) {
		rc = devm_request_threaded_irq(&wled->spmi->dev, wled->ovp_irq,
@@ -1455,22 +1290,6 @@ static int qpnp_wled_parse_dt(struct qpnp_wled *wled)
		memcpy(wled->strings, prop->value, temp_val);
	}

	wled->ibb_bias_active = of_property_read_bool(spmi->dev.of_node,
				"qcom,ibb-bias-active");

	wled->ibb_pwrup_dly_ms = QPNP_WLED_IBB_PWRUP_DLY_MIN_MS;
	rc = of_property_read_u32(spmi->dev.of_node,
				"qcom,ibb-pwrup-dly", &temp_val);
	if (!rc) {
		wled->ibb_pwrup_dly_ms = temp_val;
	} else if (rc != -EINVAL) {
		dev_err(&spmi->dev, "Unable to read ibb pwrup delay\n");
		return rc;
	}

	wled->lab_fast_precharge = of_property_read_bool(spmi->dev.of_node,
				"qcom,lab-fast-precharge");

	wled->ovp_irq = spmi_get_irq_byname(spmi, NULL, "ovp-irq");
	if (wled->ovp_irq < 0)
		dev_dbg(&spmi->dev, "ovp irq is not used\n");
@@ -1515,24 +1334,6 @@ static int qpnp_wled_probe(struct spmi_device *spmi)

	wled->ctrl_base = wled_resource->start;

	wled_resource = spmi_get_resource_byname(spmi, NULL, IORESOURCE_MEM,
					QPNP_WLED_IBB_BASE);
	if (!wled_resource) {
		dev_err(&spmi->dev, "Unable to get IBB base address\n");
		return -EINVAL;
	}

	wled->ibb_base = wled_resource->start;

	wled_resource = spmi_get_resource_byname(spmi, NULL, IORESOURCE_MEM,
					QPNP_WLED_LAB_BASE);
	if (!wled_resource) {
		dev_err(&spmi->dev, "Unable to get LAB base address\n");
		return -EINVAL;
	}

	wled->lab_base = wled_resource->start;

	dev_set_drvdata(&spmi->dev, wled);

	rc = qpnp_wled_parse_dt(wled);
@@ -1572,8 +1373,6 @@ static int qpnp_wled_probe(struct spmi_device *spmi)
		}
	}

	gwled = wled;

	return 0;

sysfs_fail: