summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSameer Nanda <snanda@chromium.org>2012-10-11 10:09:45 -0700
committerSameer Nanda <snanda@chromium.org>2012-10-16 10:07:34 -0700
commit6bafbf15a1a0f4b7d75b3889eb900f27592d2cd2 (patch)
treedd5035c0da36742fb3f64533167ff4ed7129ca91
parent14380985e1e6e892876fb3e45f089331dbc24ca0 (diff)
downloadchrome-ec-6bafbf15a1a0f4b7d75b3889eb900f27592d2cd2.tar.gz
temp_metrics: tmp006 calibration and fan loop updates
With the recent changes that have gone into the EC, the TMP006 calibration data is no longer present in the EC by default. Push it down to the EC via the newly added ectool tmp006cal command. Also added couple of changes to the fan loop: - hand back fan control loop to the EC if none of the TMP006 sensors report valid temperatures. - handle S0->S3->S0 transition where the EC sets the fan to 0 RPM. BUG=chrome-os-partner:9193 TEST=run "ectool tmp006cal" command for sensors 0, 1, 2 and 3 and ensure that they return non-zero calibration values. BRANCH=none Original-Change-Id: Iaf91216a4d3353f15489b39aba9acb34055551cf Signed-off-by: Sameer Nanda <snanda@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35469 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> (cherry picked from commit dd300b5baf1d6eff7f53b8a94c8574cfece52685) Change-Id: I69549b360fb92bce5cc3326e635dbafd80ee011d Reviewed-on: https://gerrit.chromium.org/gerrit/35694 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Tested-by: Sameer Nanda <snanda@chromium.org>
-rw-r--r--util/temp_metrics.conf96
1 files changed, 74 insertions, 22 deletions
diff --git a/util/temp_metrics.conf b/util/temp_metrics.conf
index 303716ee79..5dba2c04bc 100644
--- a/util/temp_metrics.conf
+++ b/util/temp_metrics.conf
@@ -67,8 +67,11 @@ script
get_sensor_temp() {
s=$1
- tempk=$(ectool temps $s | sed 's/[^0-9]//g')
- tempc=$((tempk - $TEMP_OFFSET))
+ tempc=0
+ if out=$(ectool temps $s); then
+ tempk=$(echo $out | sed 's/[^0-9]//g')
+ tempc=$((tempk - $TEMP_OFFSET))
+ fi
echo $tempc
}
@@ -87,10 +90,33 @@ script
echo $usb_c_object $pch_d_object $charger_d_object
}
+ set_calibration_data() {
+ B0='-2.94e-5'
+ B1='-5.7e-7'
+ B2='4.63e-9'
+
+ USB_C_S0='3.648e-14'
+ PCH_D_S0='9.301e-14'
+ HINGE_C_S0='-11.000e-14'
+ CHARGER_D_S0='10.426e-14'
+
+ # Note that the sensor numbering is different between the ectool tmp006
+ # and temps/tempsinfo commands.
+ USB_C="0 $USB_C_S0 $B0 $B1 $B2"
+ PCH_D="1 $PCH_D_S0 $B0 $B1 $B2"
+ HINGE_C="2 $HINGE_C_S0 $B0 $B1 $B2"
+ CHARGER_D="3 $CHARGER_D_S0 $B0 $B1 $B2"
+
+ for i in "$USB_C" "$PCH_D" "$HINGE_C" "$CHARGER_D"; do
+ ectool tmp006cal $i
+ done
+ }
+
max_skin_temp=0
- sensor_temperatures=""
+ sensor_temperatures=
+
get_max_skin_temp() {
- sensor_temperatures=""
+ sensor_temperatures=
max_skin_temp=0
for i in $*; do
t=$(get_sensor_temp $i)
@@ -220,7 +246,15 @@ script
set_pkg_power_limit $pkg_power_limit
}
- fan_reset_thresholds() {
+ get_fan_rpm() {
+ echo $(ectool pwmgetfanrpm | sed 's/[^0-9]//g')
+ }
+
+ set_fan_rpm() {
+ ectool pwmsetfanrpm $1
+ }
+
+ reset_fan_thresholds() {
temp_low1=105
temp_low2=105
temp_low3=105
@@ -242,47 +276,60 @@ script
if [ $skin_temp -gt 48 ] || [ $skin_temp -gt $temp_low1 ]; then
rpm=9300
- fan_reset_thresholds
+ reset_fan_thresholds
temp_low1=46
elif [ $skin_temp -gt 44 ] || [ $skin_temp -gt $temp_low2 ]; then
rpm=8000
- fan_reset_thresholds
+ reset_fan_thresholds
temp_low2=43
elif [ $skin_temp -gt 42 ] || [ $skin_temp -gt $temp_low3 ]; then
rpm=7000
- fan_reset_thresholds
+ reset_fan_thresholds
temp_low3=41
elif [ $skin_temp -gt 40 ] || [ $skin_temp -gt $temp_low4 ]; then
rpm=5500
- fan_reset_thresholds
+ reset_fan_thresholds
temp_low4=39
elif [ $skin_temp -gt 38 ] || [ $skin_temp -gt $temp_low5 ]; then
rpm=4000
- fan_reset_thresholds
+ reset_fan_thresholds
temp_low5=34
elif [ $skin_temp -gt 33 ] || [ $skin_temp -gt $temp_low6 ]; then
rpm=3000
- fan_reset_thresholds
+ reset_fan_thresholds
temp_low6=30
else
rpm=0
- fan_reset_thresholds
+ reset_fan_thresholds
fi
- if [ $last_rpm -eq $rpm ]; then
+ # During S0->S3->S0 transitions, the EC sets the fan RPM to 0. This script
+ # isn't aware of such transitions. Read the current fan RPM again to see
+ # if it got set to 0. Note that comparing the current fan RPM against last
+ # requested RPM won't suffice since the actual fan RPM may not be exactly
+ # what was requested.
+ cur_rpm=$(get_fan_rpm)
+ if ([ $cur_rpm -ne 0 ] && [ $last_rpm -eq $rpm ]) || \
+ ([ $cur_rpm -eq 0 ] && [ $rpm -eq 0 ]); then
+ last_rpm=$rpm
return
fi
log_message "Setting fan RPM (temps: $sensor_temperatures): $last_rpm -> $rpm"
last_rpm=$rpm
- ectool pwmsetfanrpm $rpm
+ set_fan_rpm $rpm
}
# Get list of sensors to monitor.
sensor_list=$(get_sensor_list)
+ # Set sensor calibration data.
+ set_calibration_data
+
loop_count=0
+ ec_fan_loop=0
+
while true; do
sleep 10
loop_count=$(($loop_count + 1))
@@ -291,15 +338,20 @@ script
get_max_skin_temp $sensor_list
if [ $max_skin_temp -eq 0 ]; then
- # TODO (snanda): use PECI temperature as a fallback.
- log_message "Invalid max skin temp"
- fi
-
- # Run the fan loop every 10 seconds.
- fan_loop $max_skin_temp
+ if [ $ec_fan_loop -eq 0 ]; then
+ log_message "Invalid max skin temp. Switching to EC fan loop."
+ ectool autofanctrl
+ ec_fan_loop=1
+ last_rpm=10
+ fi
+ else
+ # Run the fan loop.
+ fan_loop $max_skin_temp
+ ec_fan_loop=0
- # Run the thermal loop every 10 seconds.
- thermal_loop $max_skin_temp
+ # Run the thermal loop.
+ thermal_loop $max_skin_temp
+ fi
# Report the metrics once every 30 seconds.
if [ $loop_count -lt 3 ]; then