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

Commit 6daf3a8c authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: bcl: Add frequency mitigation as an optional property for BCL"

parents 1bb4efc4 c2ec16b9
Loading
Loading
Loading
Loading
+16 −11
Original line number Diff line number Diff line
@@ -38,17 +38,19 @@ Optional parameters:
- qcom,bcl-framework-interface: If this property is defined, then the BCL uses
		the BCL framework for monitoring battery voltage and current.
		When this property is defined, the 'qcom,high-threshold-uamp',
		'qcom,low-threshold-uamp', 'qcom,mitigation-freq-khz',
		'qcom,vph-high-threshold-uv', 'qcom,vph-low-threshold-uv' and
		'qcom,thermal-handle' properties should be defined in the
		'qcom,ibat-monitor' node.
		'qcom,low-threshold-uamp', 'qcom,vph-high-threshold-uv',
		'qcom,vph-low-threshold-uv' and 'qcom,thermal-handle' properties
		should be defined in the 'qcom,ibat-monitor' node.
- qcom,bcl-hotplug-list = <hotplug-phandle-list>: List of phandles to the cores
		that are to be hotplugged, when battery current limit condition
		is reached.
- qcom,bcl-soc-hotplug-list: List of phandles to the cores that are to be hotplugged,
		when battery SOC limit condition is reached.
- qcom,bcl-freq-control-list: List of phandles to the cores that are to be frequency
                mitigated when BCL condition is reached.
- qcom,bcl-freq-control-list: This optional property takes list of phandles to the
		cores that are to be frequency mitigated when BCL condition is
		reached. When this property is defined, 'qcom,mitigation-freq-khz'
		and 'qcom,thermal-handle' should be defined in the
		'qcom,ibat-monitor' node.
- qcom,bcl-no-bms: This is an optional node for BCL IAVAIL monitor mode.
		If this property is defined, BCL IAVAIL monitor gets rbat value
		from power supply battery module instead of bms module.
@@ -65,10 +67,12 @@ Optional nodes:
		which the BCL driver should cap the maximum frequency.
	* qcom,low-threshold-uamp: The battery current, in microampere, below
		which the BCL driver should clear the CPU frequency mitigation.
	* qcom,mitigation-freq-khz: The maximum frequency value the BCL driver
		should mitigate the CPUS's with. This frequency shouldn't be
		less than the minimum frequency request that the kernel thermal
		monitor driver places during vdd restriction.
	* qcom,mitigation-freq-khz: This optional property defines the maximum
		frequency value the BCL driver should mitigate the CPUS's with.
		This property is valid only if 'qcom,bcl-freq-control-list' is
		defined in bcl parent node. This frequency shouldn't be less than
		the minimum frequency request that the kernel thermal monitor
		driver places during vdd restriction.
	* qcom,ibat-channel: The ADC hardware's Ibat channel number.
	* qcom,uv-to-ua-numerator: The conversion parameter required for converting
		the voltage measure from ADC hardware to current value.
@@ -92,7 +96,8 @@ Optional nodes:
		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.
		request. This property is valid only if 'qcom,bcl-freq-control-list'
		is defined in bcl parent node.
	* qcom,soc-low-threshold: The battery SOC percentage threshold below which
		mitigation needs to be applied.

+26 −11
Original line number Diff line number Diff line
@@ -1495,10 +1495,7 @@ static int probe_bcl_periph_prop(struct bcl_context *bcl)
		bcl->ibat_high_thresh.trip_value);
	if (ret)
		goto ibat_probe_exit;
	BCL_FETCH_DT_U32(ibat_node, key, "qcom,mitigation-freq-khz", ret,
		bcl->bcl_p_freq_max);
	if (ret)
		goto ibat_probe_exit;

	BCL_FETCH_DT_U32(ibat_node, key, "qcom,vph-high-threshold-uv", ret,
		bcl->vbat_high_thresh.trip_value);
	if (ret)
@@ -1520,7 +1517,18 @@ static int probe_bcl_periph_prop(struct bcl_context *bcl)
		= bcl->ibat_low_thresh.trip_notify = bcl_periph_ibat_notify;
	bcl->ibat_high_thresh.trip_data
		= bcl->ibat_low_thresh.trip_data = (void *) bcl;

	if (bcl_frequency_mask) {
		BCL_FETCH_DT_U32(ibat_node, key, "qcom,mitigation-freq-khz",
			ret, bcl->bcl_p_freq_max);
		if (ret)
			goto ibat_probe_exit;
		get_vdd_rstr_freq(bcl, ibat_node);
	} else {
		bcl->bcl_p_freq_max = UINT_MAX;
		bcl->thermal_freq_limit = 0;
	}

	bcl->bcl_p_freq_max = max(bcl->bcl_p_freq_max, bcl->thermal_freq_limit);

	bcl->btm_mode = BCL_MONITOR_DISABLED;
@@ -1574,11 +1582,6 @@ static int probe_btm_properties(struct bcl_context *bcl)
		goto btm_probe_exit;
	bcl->btm_high_threshold_uv = current_to_voltage(bcl, curr_ua);

	key = "qcom,mitigation-freq-khz";
	ret = of_property_read_u32(ibat_node, key, &bcl->btm_freq_max);
	if (ret < 0)
		goto btm_probe_exit;

	key = "qcom,ibat-channel";
	ret = of_property_read_u32(ibat_node, key, &bcl->btm_ibat_chan);
	if (ret < 0)
@@ -1618,7 +1621,17 @@ static int probe_btm_properties(struct bcl_context *bcl)
		ret = PTR_ERR(bcl->btm_vadc_dev);
		goto btm_probe_exit;
	}

	if (bcl_frequency_mask) {
		key = "qcom,mitigation-freq-khz";
		ret = of_property_read_u32(ibat_node, key, &bcl->btm_freq_max);
		if (ret < 0)
			goto btm_probe_exit;
		get_vdd_rstr_freq(bcl, ibat_node);
	} else {
		bcl->btm_freq_max = UINT_MAX;
		bcl->thermal_freq_limit = 0;
	}
	bcl->btm_freq_max = max(bcl->btm_freq_max, bcl->thermal_freq_limit);

	bcl->btm_mode = BCL_MONITOR_DISABLED;
@@ -1738,6 +1751,8 @@ static int bcl_probe(struct platform_device *pdev)
		}
	}
	for_each_possible_cpu(cpu) {
		if (!(bcl_frequency_mask & BIT(cpu)))
			continue;
		snprintf(cpu_str, MAX_CPU_NAME, "cpu%d", cpu);
		bcl->cpufreq_handle[cpu] = devmgr_register_mitigation_client(
					&pdev->dev, cpu_str, NULL);