diff options
author | Bill Richardson <wfrichar@chromium.org> | 2013-08-07 15:34:04 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-08-23 10:38:36 -0700 |
commit | fcce7223a5493e512e77d9f7b758d874ac502df5 (patch) | |
tree | 3cfc90b9f4d16b1937f9927b48a80abc2035c48c /include/thermal.h | |
parent | 0e024b2bae085f12ec4df33000799339aef38809 (diff) | |
download | chrome-ec-fcce7223a5493e512e77d9f7b758d874ac502df5.tar.gz |
Completely new thermal/fan implementation
Problems with existing thermal control loop:
* Not multi-board friendly. thermal.c only supports Link and needs
refactoring. Temp thresholds and fan speeds are hard-coded.
* Only the PECI temp is used to determine the fan speed. Other temp sensors
are ignored.
* Has confusing data structures. Values in the CPU temp thresholds array mix
ACPI thresholds with fan step values.
With this change, the thermal task monitors all temp sensors in order to
perform two completely independent functions:
Function one: Determine if the host needs to be throttled by or informed of
any thermal events.
For thermal events, each temp sensor will have three threshold levels.
TEMP_HOST_WARN
* When any sensor goes above this level, host_throttle_cpu(1) will be called
to ask the CPU to slow itself down.
* When all sensors drop below this level, host_throttle_cpu(0) will be called.
* Exactly AT this level, nothing happens (this provides hysteresis).
TEMP_HOST_HIGH
* When any sensor goes above this level, chipset_throttle_cpu(1) will be
called to slow the CPU down whether it wants to or not.
* When all sensors drop below this level, chipset_throttle_cpu(0) will be
called.
* Exactly AT this level, nothing happens (this provides hysteresis).
TEMP_HOST_SHUTDOWN
* When any sensor is above this level, chipset_force_shutdown() will be
called to halt the CPU.
* Nothing turns the CPU back on again - the user just has to wait for things
to cool off. Pressing the power button too soon will just trigger shutdown
again as soon as the EC can read the host temp.
Function two: Determine the amount of fan cooling needed
For fan cooling, each temp sensor will have two levels.
TEMP_FAN_OFF
* At or below this temperature, no active cooling is needed.
TEMP_FAN_MAX
* At or above this temperature, active cooling should be running at maximum.
The highest level of all temp sensors will be used to request the amount of
active cooling needed. The function pwm_fan_percent_to_rpm() is invoked to
convert the amount of cooling to the target fan RPM.
The default pwm_fan_percent_to_rpm() function converts smoothly between the
configured CONFIG_PWM_FAN_RPM_MIN and CONFIG_PWM_FAN_RPM_MAX for percentages
between 1 and 100. 0% means "off".
The default function probably provide the smoothest and quietest behavior,
but individual boards can provide their own pwm_fan_percent_to_rpm() to
implement whatever curves, hysteresis, feedback, or other hackery they wish.
BUG=chrome-os-partner:20805
BRANCH=none
TEST=manual
Compile-time test with
make BOARD=falco runtests
On the EC console, the existing fan commands should work correctly:
faninfo - display the fan state
fanduty NUM - force the fan PWM to the specified percentage (0-100)
fanset RPM - force the fan to the specified RPM
fanset NUM% - force the fan to the specified percentage (0-100) between
its configured minimum and maximum speeds from board.h
(CONFIG_PWM_FAN_RPM_MIN and CONFIG_PWM_FAN_RPM_MAX)
fanauto - let the EC control the fan automatically
You can test the default pwm_fan_percent_to_rpm() with
fanset 1%
faninfo
The fan should be turning at CONFIG_PWM_FAN_RPM_MIN. Let the EC control it
automatically again with
fanauto
Also on the EC console, the thermal settings can be examined or changed:
> temps
PECI : 327 K = 54 C
ECInternal : 320 K = 47 C
G781Internal : 319 K = 46 C
G781External : 318 K = 45 C
>
> thermalget
sensor warn high shutdown fan_off fan_max name
0 373 387 383 333 363 PECI
1 0 0 0 0 0 ECInternal
2 0 0 0 0 0 G781Internal
3 0 0 0 0 0 G781External
>
> help thermalset
Usage: thermalset sensor warn [high [shutdown [fan_off [fan_max]]]]
set thermal parameters (-1 to skip)
>
> thermalset 2 -1 -1 999
sensor warn high shutdown fan_off fan_max name
0 373 387 383 333 363 PECI
1 0 0 0 0 0 ECInternal
2 0 0 999 0 0 G781Internal
3 0 0 0 0 0 G781External
>
From the host, ectool can be used to get and set these parameters with
nearly identical commands:
ectool thermalget
ectool thermalset 2 -1 -1 999
Change-Id: Idb27977278f766826045fb7d41929953ec6b1cca
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/66688
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include/thermal.h')
-rw-r--r-- | include/thermal.h | 68 |
1 files changed, 5 insertions, 63 deletions
diff --git a/include/thermal.h b/include/thermal.h index 3e43dfcd1a..d3729591a0 100644 --- a/include/thermal.h +++ b/include/thermal.h @@ -8,70 +8,12 @@ #ifndef __CROS_EC_THERMAL_H #define __CROS_EC_THERMAL_H -#include "temp_sensor.h" +/* The thermal configuration for a single temp sensor is defined here. */ +#include "ec_commands.h" -#define THERMAL_CONFIG_NO_FLAG 0x0 -#define THERMAL_CONFIG_WARNING_ON_FAIL 0x1 - -/* - * Number of steps for fan speed control. Speed of each step is defined - * in thermal.c. - */ -#define THERMAL_FAN_STEPS 5 - -/* Set a threshold temperature to this value to disable the threshold limit. */ -#define THERMAL_THRESHOLD_DISABLE 0 - -/* This macro is used to disable all threshold for a sensor. The value 0 - * expands to all field in the array 'thresholds'. Change this if - * THERMAL_THRESHOLD_DISABLE is no longer 0. - */ -#define THERMAL_THRESHOLD_DISABLE_ALL 0 - -enum thermal_threshold { - THRESHOLD_WARNING = 0, /* Issue overheating warning */ - THRESHOLD_CPU_DOWN, /* Shut down CPU */ - THRESHOLD_POWER_DOWN, /* Shut down everything we can */ - THRESHOLD_COUNT -}; - -/* Configuration for temperature sensor */ -struct thermal_config_t { - /* Configuration flags */ - int8_t config_flags; - /* Threshold temperatures in K */ - int16_t thresholds[THRESHOLD_COUNT + THERMAL_FAN_STEPS]; -}; - -/** - * Set a threshold temperature. - * - * @param type Sensor type to set threshold for - * @param threshold_id Threshold ID to set - * @param value New threshold temperature in K, or - * THERMAL_THRESHOLD_DISABLE to disable this threshold. - * - * @return EC_SUCCESS if success, non-zero if error. - */ -int thermal_set_threshold(enum temp_sensor_type type, int threshold_id, - int value); - -/** - * Read a threshold temperature. - * - * @param type Sensor type to get threshold for - * @param threshold_id Threshold ID - * - * @return The threshold temperature in K, THERMAL_THRESHOLD_DISABLE if - * disabled, -1 if error. - */ -int thermal_get_threshold(enum temp_sensor_type type, int threshold_id); - -/** - * Enable/disable automatic fan speed control - * - * @param enable Enable (!=0) or disable (0) auto fan control +/* We need to to hold a config for each board's sensors. Not const, so we can + * tweak it at run-time if we have to. */ -void thermal_control_fan(int enable); +extern struct ec_thermal_config thermal_params[]; #endif /* __CROS_EC_THERMAL_H */ |