summaryrefslogtreecommitdiff
path: root/common/thermal.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-10-11 13:16:43 -0700
committerGerrit <chrome-bot@google.com>2012-10-11 14:24:43 -0700
commitb00a446ec57323f84002722523783351f19e41b1 (patch)
tree03dce4a51f0ed47655cb147f5a02907c5c127a4b /common/thermal.c
parentceb696a20896511aa233b1f59227a6edaeda3157 (diff)
downloadchrome-ec-b00a446ec57323f84002722523783351f19e41b1.tar.gz
link: EC reclaims fan control on AP shutdown
Previously, if the AP took fan control, the EC would never take it back. This meant the EC would leave the fan off even if the system was sitting at the INSERT screen or booted an alternate OS. BUG=chrome-os-partner:15189 BRANCH=link TEST=manual - boot system - from EC console, fanset 0 - faninfo shows fan at 0rpm - from root shell, crossystem recovery_request=123 && reboot - wait a few mins - faninfo should show fan spinning again Change-Id: I534c9978194085467f1df6eae971c55d4e8083be Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35309
Diffstat (limited to 'common/thermal.c')
-rw-r--r--common/thermal.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/common/thermal.c b/common/thermal.c
index a300497bde..b189075af1 100644
--- a/common/thermal.c
+++ b/common/thermal.c
@@ -9,6 +9,7 @@
#include "common.h"
#include "console.h"
#include "gpio.h"
+#include "hooks.h"
#include "host_command.h"
#include "pwm.h"
#include "task.h"
@@ -55,23 +56,22 @@ static int8_t *fan_threshold_reached = overheated + THRESHOLD_COUNT;
static int fan_ctrl_on = 1;
-
-int thermal_set_threshold(enum temp_sensor_type type, int threshold_id, int value)
+int thermal_set_threshold(enum temp_sensor_type type, int threshold_id,
+ int value)
{
if (type < 0 || type >= TEMP_SENSOR_TYPE_COUNT)
- return -1;
+ return EC_ERROR_INVAL;
if (threshold_id < 0 ||
threshold_id >= THRESHOLD_COUNT + THERMAL_FAN_STEPS)
- return -1;
+ return EC_ERROR_INVAL;
if (value < 0)
- return -1;
+ return EC_ERROR_INVAL;
thermal_config[type].thresholds[threshold_id] = value;
return EC_SUCCESS;
}
-
int thermal_get_threshold(enum temp_sensor_type type, int threshold_id)
{
if (type < 0 || type >= TEMP_SENSOR_TYPE_COUNT)
@@ -83,10 +83,9 @@ int thermal_get_threshold(enum temp_sensor_type type, int threshold_id)
return thermal_config[type].thresholds[threshold_id];
}
-
-int thermal_toggle_auto_fan_ctrl(int auto_fan_on)
+int thermal_control_fan(int enable)
{
- fan_ctrl_on = auto_fan_on;
+ fan_ctrl_on = enable;
return EC_SUCCESS;
}
@@ -100,7 +99,6 @@ static void smi_sensor_failure_warning(void)
host_set_single_event(EC_HOST_EVENT_THERMAL);
}
-
/* TODO: When we need different overheated action for different boards,
* move these action to board-specific file. (e.g. board_thermal.c)
*/
@@ -135,7 +133,6 @@ static void overheated_action(void)
}
}
-
/* Update counter and check if the counter has reached delay limit.
* Note that we have various delay period to prevent one error value triggering
* overheated action. */
@@ -167,7 +164,6 @@ static inline void update_and_check_stat(int temp,
ot_count[sensor_id][threshold_id] = 0;
}
-
static void thermal_process(void)
{
int i, j;
@@ -204,7 +200,6 @@ static void thermal_process(void)
overheated_action();
}
-
void thermal_task(void)
{
while (1) {
@@ -213,6 +208,14 @@ void thermal_task(void)
}
}
+static int thermal_shutdown(void)
+{
+ /* Take back fan control when the processor shuts down */
+ thermal_control_fan(1);
+ return EC_SUCCESS;
+}
+DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, thermal_shutdown, HOOK_PRIO_DEFAULT);
+
/*****************************************************************************/
/* Console commands */
@@ -228,7 +231,6 @@ static void print_thermal_config(enum temp_sensor_type type)
config->thresholds[THRESHOLD_POWER_DOWN]);
}
-
static void print_fan_stepping(enum temp_sensor_type type)
{
const struct thermal_config_t *config = thermal_config + type;
@@ -242,7 +244,6 @@ static void print_fan_stepping(enum temp_sensor_type type)
fan_speed[i+1]);
}
-
static int command_thermal_config(int argc, char **argv)
{
char *e;
@@ -279,7 +280,6 @@ DECLARE_CONSOLE_COMMAND(thermalconf, command_thermal_config,
"Get/set thermal threshold temp",
NULL);
-
static int command_fan_config(int argc, char **argv)
{
char *e;
@@ -318,10 +318,9 @@ DECLARE_CONSOLE_COMMAND(thermalfan, command_fan_config,
"Get/set thermal threshold fan rpm",
NULL);
-
static int command_thermal_auto_fan_ctrl(int argc, char **argv)
{
- return thermal_toggle_auto_fan_ctrl(1);
+ return thermal_control_fan(1);
}
DECLARE_CONSOLE_COMMAND(autofan, command_thermal_auto_fan_ctrl,
NULL,