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

For targets with LMH DCVSh hardware and OSM, BCL software frequency
mitigation is not required. Since hardware is doing the frequency
mitigation, there is no need for the HLOS BCL frequency mitigation.
So make the properties "qcom,mitigation-freq-khz" and
"qcom,thermal-handle" as optional properties.

Change-Id: I0062f3b39f00ff2f0e74affcffbcf1afd89d3b2f
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
This commit is contained in:
Manaf Meethalavalappu Pallikunhi 2016-11-18 15:33:31 +05:30
parent 54fb4f8396
commit c2ec16b9e1
2 changed files with 42 additions and 22 deletions

View file

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

View file

@ -1495,10 +1495,7 @@ static int probe_bcl_periph_prop(struct bcl_context *bcl)
bcl->ibat_high_thresh.trip_value); bcl->ibat_high_thresh.trip_value);
if (ret) if (ret)
goto ibat_probe_exit; 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_FETCH_DT_U32(ibat_node, key, "qcom,vph-high-threshold-uv", ret,
bcl->vbat_high_thresh.trip_value); bcl->vbat_high_thresh.trip_value);
if (ret) 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_low_thresh.trip_notify = bcl_periph_ibat_notify;
bcl->ibat_high_thresh.trip_data bcl->ibat_high_thresh.trip_data
= bcl->ibat_low_thresh.trip_data = (void *) bcl; = bcl->ibat_low_thresh.trip_data = (void *) bcl;
get_vdd_rstr_freq(bcl, ibat_node);
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->bcl_p_freq_max = max(bcl->bcl_p_freq_max, bcl->thermal_freq_limit);
bcl->btm_mode = BCL_MONITOR_DISABLED; bcl->btm_mode = BCL_MONITOR_DISABLED;
@ -1574,11 +1582,6 @@ static int probe_btm_properties(struct bcl_context *bcl)
goto btm_probe_exit; goto btm_probe_exit;
bcl->btm_high_threshold_uv = current_to_voltage(bcl, curr_ua); 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"; key = "qcom,ibat-channel";
ret = of_property_read_u32(ibat_node, key, &bcl->btm_ibat_chan); ret = of_property_read_u32(ibat_node, key, &bcl->btm_ibat_chan);
if (ret < 0) if (ret < 0)
@ -1618,7 +1621,17 @@ static int probe_btm_properties(struct bcl_context *bcl)
ret = PTR_ERR(bcl->btm_vadc_dev); ret = PTR_ERR(bcl->btm_vadc_dev);
goto btm_probe_exit; goto btm_probe_exit;
} }
get_vdd_rstr_freq(bcl, ibat_node);
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_freq_max = max(bcl->btm_freq_max, bcl->thermal_freq_limit);
bcl->btm_mode = BCL_MONITOR_DISABLED; bcl->btm_mode = BCL_MONITOR_DISABLED;
@ -1738,6 +1751,8 @@ static int bcl_probe(struct platform_device *pdev)
} }
} }
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
if (!(bcl_frequency_mask & BIT(cpu)))
continue;
snprintf(cpu_str, MAX_CPU_NAME, "cpu%d", cpu); snprintf(cpu_str, MAX_CPU_NAME, "cpu%d", cpu);
bcl->cpufreq_handle[cpu] = devmgr_register_mitigation_client( bcl->cpufreq_handle[cpu] = devmgr_register_mitigation_client(
&pdev->dev, cpu_str, NULL); &pdev->dev, cpu_str, NULL);