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

Commit 59b7a87c authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "leds: qpnp-flash-v2: Fix low current configuration for PM8150L"

parents dd2c1602 18183be5
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
 */

#define pr_fmt(fmt)	"flashv2: %s: " fmt, __func__
@@ -181,6 +181,10 @@ enum strobe_type {
	LPG_STROBE,
};

enum wa_flags {
	PM8150L_IRES_WA = BIT(0),
};

/*
 * Configurations for each individual LED
 */
@@ -279,6 +283,7 @@ struct qpnp_flash_led {
	int				num_snodes;
	int				enable;
	int				total_current_ma;
	u32				wa_flags;
	u16				base;
	bool				trigger_lmh;
	bool				trigger_chgr;
@@ -1058,7 +1063,12 @@ static void qpnp_flash_led_node_set(struct flash_node_data *fnode, int value)
				break;
			}
		}
	} else if (prgm_current_ma <= 20 &&
			(led->wa_flags & PM8150L_IRES_WA)) {
		fnode->ires_idx = FLASH_LED_IRES_BASE;
		fnode->ires_ua = FLASH_LED_IRES_MIN_UA;
	}

	fnode->current_ma = prgm_current_ma;
	fnode->cdev.brightness = prgm_current_ma;
	fnode->current_reg_val = get_current_reg_code(prgm_current_ma,
@@ -2273,6 +2283,9 @@ static int qpnp_flash_led_parse_common_dt(struct qpnp_flash_led *led,
		led->pdata->pmic_rev_id->pmic_subtype,
		led->pdata->pmic_rev_id->rev4);

	if (led->pdata->pmic_rev_id->pmic_subtype == PM8150L_SUBTYPE)
		led->wa_flags |= PM8150L_IRES_WA;

	led->pdata->hdrm_auto_mode_en = of_property_read_bool(node,
							"qcom,hdrm-auto-mode");

+16 −9
Original line number Diff line number Diff line
@@ -272,6 +272,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)
@@ -827,6 +829,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++) {
@@ -1059,6 +1070,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);
@@ -1993,10 +2009,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);
@@ -2353,11 +2365,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;
}