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

Commit c5bc46fb authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

backlight: qcom-spmi-wled: Update flash sink config in auto calibration



Currently, when the sink configuration is incorrect, auto
calibration fixes the sink configuration dynamically. However,
WLED flash sink configuration is not updated accordingly. This
can cause OVP faults whenever the selfie flash is attempted. Fix
it by updating WLED flash sink configuration in auto calibration.

Since the auto calibration can be run during HW initialization
before flash configuration is made, move wled_flash_setup() to
wled5_setup().

Change-Id: I953a59fd4e053390c382ce9e27ba2fa76cc4f5c1
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 291d6946
Loading
Loading
Loading
Loading
+16 −9
Original line number Diff line number Diff line
@@ -278,6 +278,8 @@ static const u8 wled5_brt_wid_sel_reg[MOD_MAX] = {
	[MOD_B] = WLED5_SINK_MOD_B_BR_WID_SEL_REG,
};

static int wled_flash_setup(struct wled *wled);

static inline bool is_wled4(struct wled *wled)
{
	if (*wled->version == WLED_PMI8998 || *wled->version == WLED_PM660L)
@@ -833,6 +835,15 @@ static int wled_auto_calibrate(struct wled *wled)
		goto failed_calib;
	}

	if (is_wled5(wled)) {
		/* Update the flash sink configuration as well */
		rc = regmap_update_bits(wled->regmap,
				wled->sink_addr + WLED5_SINK_FLASH_SINK_EN_REG,
				WLED_SINK_CURR_SINK_MASK, sink_config);
		if (rc < 0)
			return rc;
	}

	/* MODULATOR_EN setting for valid sinks */
	if (is_wled4(wled)) {
		for (i = 0; (string_cfg >> i) != 0; i++) {
@@ -1065,6 +1076,11 @@ static int wled5_setup(struct wled *wled)
	u32 val;
	u8 string_cfg = wled->cfg.string_cfg;

	rc = wled_flash_setup(wled);
	if (rc < 0)
		dev_err(&wled->pdev->dev, "failed to setup WLED flash/torch rc:%d\n",
			rc);

	rc = regmap_update_bits(wled->regmap,
			wled->ctrl_addr + WLED_CTRL_OVP,
			WLED5_CTRL_OVP_MASK, wled->cfg.ovp);
@@ -1999,10 +2015,6 @@ static int wled_flash_setup(struct wled *wled)
	int rc, i;
	u8 val;

	/* Not supported */
	if (is_wled4(wled))
		return 0;

	/* Set FLASH_VREF_ADIM_HDIM to maximum */
	rc = regmap_write(wled->regmap,
			wled->ctrl_addr + WLED5_CTRL_FLASH_HDRM_REG, 0xF);
@@ -2359,11 +2371,6 @@ static int wled_probe(struct platform_device *pdev)
		return rc;
	}

	rc = wled_flash_setup(wled);
	if (rc < 0)
		dev_err(&pdev->dev, "failed to setup WLED flash/torch rc:%d\n",
			rc);

	return rc;
}