power: battery_current_limit: Support btm based current measurement
On some hardware configurations battery current can be
read from adc. Update the code to configure the adc to
periodically read the battery current and setup
notifications when the thresholds are crossed. Reduce max
frequency for all cpus when in high current mode.
Configuring battery current monitoring:
=> The bcl "type" sysfs node should read out "btm" and NOT
"bcl" for battery current monitor mode operation.
cat /sys/devices/qcom,bcl.29/type
=> Use the "mode" sysfs node to determine whether the
BCL driver is enabled or disabled. Configuring the BCL
operational parameters require the users to,
* disable the BCL driver.
* configure one or more BCL operational parameters.
* re-enable the BCL driver.
cat /sys/devices/qcom,bcl.29/mode
=> The sysfs node "high_threshold_ua" can be used to
configure the current threshold, ABOVE which the max
cpu frequency is restricted.
echo "disable" > /sys/devices/qcom,bcl.29/mode
echo 2000000 > /sys/devices/qcom,bcl.29/high_threshold_ua
echo "enable" > /sys/devices/qcom,bcl.29/mode
cat /sys/devices/qcom,bcl.29/high_threshold_ua
In the above commands, the BCL driver is disabled before
configuring the high threshold. The high threshold is
configured to 2A and then the driver is re-enabled.
=> The sysfs node "low_threshold_ua" can be used to
configure the current threshold, BELOW which the max
cpu frequency restriction is removed.
echo "disable" > /sys/devices/qcom,bcl.29/mode
echo 1000000 > /sys/devices/qcom,bcl.29/low_threshold_ua
echo "enable" > /sys/devices/qcom,bcl.29/mode
cat /sys/devices/qcom,bcl.29/low_threshold_ua
In the above commands, the BCL driver is disabled before
configuring the low threshold. The low threshold is
configured to 1A and then the driver is re-enabled.
=> The sysfs node "freq_max", can be used to configure
the BCL max frequency mitigation value. The BCL s/w by
default is configured to restrict the cpu max frequency
to 1.9Ghz. BCL driver doesn't mitigate the max cpu
frequency below 1.9GHz. Any request to the max frequency
value below 1.9Ghz, will be considered as a request for
1.9Ghz by BCL driver.
echo "disable" > /sys/devices/qcom,bcl.29/mode
echo 2265600 > /sys/devices/qcom,bcl.29/freq_max
echo "enable" > /sys/devices/qcom,bcl.29/mode
cat /sys/devices/qcom,bcl.29/freq_max
This command echo 2265600 > /sys/devices/qcom,bcl.29/freq_max,
will set the max cpu frequency restriction to 2.2Ghz. But
the command echo 300000 > /sys/devices/qcom,bcl.29/freq_max,
will restrict the max frequency restriction to 1.9Ghz.
=> The "adc_interval_us" sysfs node can be queried for
the ADC polling timer interval.
cat /sys/devices/qcom,bcl.29/adc_interval_us
=> The "high_load_state" sysfs nodes can be queried to see
whether the BCL driver has sensed a high load state or not.
cat /sys/devices/qcom,bcl.29/high_load_state
For the above command if a value 1 is returned, then it
implies that BCL has sensed a high load state and has
restricted the CPU max frequencies.
Change-Id: Ib3981c46f4fd44d90806a84276c98b8608ee8957
Signed-off-by:
Ram Chandrasekar <rkumbako@codeaurora.org>
Loading
Please register or sign in to comment