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

Commit a79db933 authored by Ram Chandrasekar's avatar Ram Chandrasekar
Browse files

power: battery_current_limit: Support to get the minimum frequency limit



BCL driver supports a phandle reference to the msm_thermal's
vdd restriction node. BCL uses the phandle to get the minimum
frequency limit that the thermal driver places during vdd
restriction. This frequency limit is the minimum value that
the BCL driver can limit the CPU max frequency to.

CRs-Fixed: 629894
Change-Id: I0a4ff50b1759e2abe97d732da8a3de71f58bc538
Signed-off-by: default avatarRam Chandrasekar <rkumbako@codeaurora.org>
parent f2b2e8d4
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -70,6 +70,12 @@ Optional nodes:
	* vph-low-threshold-uv: The battery voltage threshold below which the
		BCL driver starts monitoring the battery current thresholds and
		mitigates the CPU on the event of high load.
	* thermal-handle = <&phandle_to_vdd_apps>: phandle to the "qcom,msm_thermal"
		vdd restriction property, "qcom,vdd-apps-rstr". This phandle is
		used by BCL driver to get the minimum frequency request that the
		thermal driver places during vdd restriction. This frequency
		value will be the lowest max frequency value the BCL driver can
		request.

Example:
	qcom,bcl {
@@ -87,5 +93,6 @@ Example:
			vph-channel = <0x07>;
			vph-high-threshold-uv = <3700000>;
			vph-low-threshold-uv = <3500000>;
			thermal-handle = <&msm_thermal_freq>;
		};
	};
+31 −4
Original line number Diff line number Diff line
@@ -888,8 +888,7 @@ static ssize_t freq_max_store(struct device *dev,
	ret = convert_to_int(buf, &val);
	if (ret)
		return ret;
	gbcl->btm_freq_max = (val >= BTM_8084_FREQ_MITIG_LIMIT) ?
				val : BTM_8084_FREQ_MITIG_LIMIT;
	gbcl->btm_freq_max = max_t(uint32_t, val, gbcl->btm_freq_limit);

	return count;
}
@@ -1139,6 +1138,34 @@ static int bcl_resume(struct device *dev)
	return 0;
}

static void get_vdd_rstr_freq(struct bcl_context *bcl,
				struct device_node *ibat_node)
{
	int ret = 0;
	struct device_node *phandle = NULL;
	char *key = NULL;

	key = "thermal-handle";
	phandle = of_parse_phandle(ibat_node, key, 0);
	if (!phandle) {
		pr_err("Thermal handle not present\n");
		ret = -ENODEV;
		goto vdd_rstr_exit;
	}
	key = "qcom,levels";
	ret = of_property_read_u32_index(phandle, key, 0,
					&bcl->btm_freq_limit);
	if (ret) {
		pr_err("Error reading property %s. ret:%d\n", key, ret);
		goto vdd_rstr_exit;
	}

vdd_rstr_exit:
	if (ret)
		bcl->btm_freq_limit = BTM_8084_FREQ_MITIG_LIMIT;
	return;
}

static int probe_btm_properties(struct bcl_context *bcl)
{
	int ret = 0, curr_ua = 0;
@@ -1181,8 +1208,6 @@ static int probe_btm_properties(struct bcl_context *bcl)
	ret = of_property_read_u32(ibat_node, key, &bcl->btm_freq_max);
	if (ret < 0)
		goto btm_probe_exit;
	bcl->btm_freq_max = (bcl->btm_freq_max >= BTM_8084_FREQ_MITIG_LIMIT) ?
				bcl->btm_freq_max : BTM_8084_FREQ_MITIG_LIMIT;

	key = "ibat-channel";
	ret = of_property_read_u32(ibat_node, key, &bcl->btm_ibat_chan);
@@ -1223,6 +1248,8 @@ static int probe_btm_properties(struct bcl_context *bcl)
		ret = PTR_ERR(bcl->btm_vadc_dev);
		goto btm_probe_exit;
	}
	get_vdd_rstr_freq(bcl, ibat_node);
	bcl->btm_freq_max = max(bcl->btm_freq_max, bcl->btm_freq_limit);

	bcl->btm_mode = BCL_MONITOR_DISABLED;
	bcl->bcl_monitor_type = BCL_IBAT_MONITOR_TYPE;