summaryrefslogtreecommitdiff
path: root/util/temp_metrics.conf
diff options
context:
space:
mode:
Diffstat (limited to 'util/temp_metrics.conf')
-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