summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-10-29 10:48:13 -0700
committerGerrit <chrome-bot@google.com>2012-11-01 12:45:28 -0700
commite9e02762dd4b09060911bda9b160502a8f36d4fd (patch)
tree8847133693a1a089e918bbf58bac4d507ac07dbf /common
parentd83f42bdc8b61773efc17e0194e5abe26109128d (diff)
downloadchrome-ec-e9e02762dd4b09060911bda9b160502a8f36d4fd.tar.gz
Move reset/overheat/shutdown funcs to chipset interface
They're not x86-specific, so move to the chipset interface. BUG=chrome-os-partner:15579 BRANCH=none TEST=x86reset warm, then x86reset cold. Should reboot OS in each case. Change-Id: Ib571ab916bab16179198a0d054320e59afbae124 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36785
Diffstat (limited to 'common')
-rw-r--r--common/charge_state.c8
-rw-r--r--common/keyboard.c14
-rw-r--r--common/mock_x86_power.c18
-rw-r--r--common/thermal.c23
-rw-r--r--common/x86_power.c30
5 files changed, 28 insertions, 65 deletions
diff --git a/common/charge_state.c b/common/charge_state.c
index f658b3daea..7cf8fe9546 100644
--- a/common/charge_state.c
+++ b/common/charge_state.c
@@ -23,7 +23,6 @@
#include "task.h"
#include "timer.h"
#include "util.h"
-#include "x86_power.h"
/* Console output macros */
#define CPUTS(outstr) cputs(CC_CHARGER, outstr)
@@ -108,14 +107,9 @@ static void poweroff_wait_ac(int hibernate_ec)
{
/* Shutdown the main processor */
if (chipset_in_state(CHIPSET_STATE_ON)) {
- /* chipset_force_state(CHIPSET_STATE_SOFT_OFF);
- * TODO(rong): remove platform dependent code
- */
-#ifdef CONFIG_TASK_X86POWER
CPRINTF("[%T force shutdown to avoid damaging battery]\n");
- x86_power_force_shutdown();
+ chipset_force_shutdown();
host_set_single_event(EC_HOST_EVENT_BATTERY_SHUTDOWN);
-#endif /* CONFIG_TASK_X86POWER */
}
/* If battery level is critical, hibernate the EC too */
diff --git a/common/keyboard.c b/common/keyboard.c
index 93d4d96a13..f71842d7dd 100644
--- a/common/keyboard.c
+++ b/common/keyboard.c
@@ -21,7 +21,6 @@
#include "task.h"
#include "timer.h"
#include "util.h"
-#include "x86_power.h"
#define KEYBOARD_DEBUG 1
@@ -262,20 +261,11 @@ void keyboard_clear_underlying_buffer(void)
i8042_flush_buffer();
}
-
-/*
- * TODO: Move this implementation to platform-dependent files.
- * We don't do it now because not every board implement x86_power.c
- * bds: no CONFIG_LPC and no CONFIG_TASK_X86POWER
- * daisy(variants): no CONFIG_LPC and no CONFIG_TASK_X86POWER
- * crosbug.com/p/8523
- */
static void keyboard_wakeup(void)
{
host_set_single_event(EC_HOST_EVENT_KEY_PRESSED);
}
-
void keyboard_state_changed(int row, int col, int is_pressed)
{
uint8_t scan_code[MAX_SCAN_CODE_LEN];
@@ -597,11 +587,9 @@ int handle_keyboard_command(uint8_t command, uint8_t *output)
data_port_state = STATE_SEND_TO_MOUSE;
break;
-#ifdef CONFIG_TASK_X86POWER
case I8042_SYSTEM_RESET:
- x86_power_reset(0);
+ chipset_reset(0);
break;
-#endif
default:
if (command >= I8042_READ_CTL_RAM &&
diff --git a/common/mock_x86_power.c b/common/mock_x86_power.c
index ddf99127e3..e7c24bedd9 100644
--- a/common/mock_x86_power.c
+++ b/common/mock_x86_power.c
@@ -15,28 +15,14 @@
static int mock_power_on = 0;
-void x86_power_cpu_overheated(int too_hot)
-{
- /* Print transitions */
- static int last_val = 0;
- if (too_hot != last_val) {
- if (too_hot)
- uart_printf("CPU overheated.\n");
- else
- uart_printf("CPU no longer overheated.\n");
- last_val = too_hot;
- }
-}
-
-
-void x86_power_force_shutdown(void)
+void chipset_force_shutdown(void)
{
uart_puts("Force shutdown\n");
mock_power_on = 0;
}
-void x86_power_reset(int cold_reset)
+void chipset_reset(int cold_reset)
{
uart_printf("X86 Power %s reset\n", cold_reset ? "cold" : "warm");
}
diff --git a/common/thermal.c b/common/thermal.c
index 907743bcdd..69b24e6d9d 100644
--- a/common/thermal.c
+++ b/common/thermal.c
@@ -17,7 +17,10 @@
#include "thermal.h"
#include "timer.h"
#include "util.h"
-#include "x86_power.h"
+
+/* Console output macros */
+#define CPUTS(outstr) cputs(CC_THERMAL, outstr)
+#define CPRINTF(format, args...) cprintf(CC_THERMAL, format, ## args)
/*
* Temperature threshold configuration. Must be in the same order as in enum
@@ -103,18 +106,26 @@ static void smi_sensor_failure_warning(void)
*/
static void overheated_action(void)
{
+ static int cpu_down_count;
+
if (overheated[THRESHOLD_POWER_DOWN]) {
cprintf(CC_CHIPSET,
"[%T critical temperature; shutting down]\n");
- x86_power_force_shutdown();
+ chipset_force_shutdown();
host_set_single_event(EC_HOST_EVENT_THERMAL_SHUTDOWN);
return;
}
- if (overheated[THRESHOLD_CPU_DOWN])
- x86_power_cpu_overheated(1);
- else
- x86_power_cpu_overheated(0);
+ if (overheated[THRESHOLD_CPU_DOWN]) {
+ cpu_down_count++;
+ if (cpu_down_count > 3) {
+ CPRINTF("[%T overheated; shutting down]\n");
+ chipset_force_shutdown();
+ host_set_single_event(EC_HOST_EVENT_THERMAL_SHUTDOWN);
+ }
+ } else {
+ cpu_down_count = 0;
+ }
if (overheated[THRESHOLD_WARNING]) {
smi_overheated_warning();
diff --git a/common/x86_power.c b/common/x86_power.c
index 1a31749cd2..7165bff499 100644
--- a/common/x86_power.c
+++ b/common/x86_power.c
@@ -190,25 +190,12 @@ static int wait_in_signals(uint32_t want)
return EC_SUCCESS;
}
-void x86_power_cpu_overheated(int too_hot)
-{
- static int overheat_count;
-
- if (too_hot) {
- overheat_count++;
- if (overheat_count > 3) {
- CPRINTF("[%T overheated; shutting down]\n");
- x86_power_force_shutdown();
- host_set_single_event(EC_HOST_EVENT_THERMAL_SHUTDOWN);
- }
- } else {
- overheat_count = 0;
- }
-}
+/*****************************************************************************/
+/* Chipset interface */
-void x86_power_force_shutdown(void)
+void chipset_force_shutdown(void)
{
- CPRINTF("[%T x86 power force shutdown]\n");
+ CPRINTF("[%T chipset force shutdown]\n");
/*
* Force x86 off. This condition will reset once the state machine
@@ -218,7 +205,7 @@ void x86_power_force_shutdown(void)
gpio_set_level(GPIO_PCH_RSMRSTn, 0);
}
-void x86_power_reset(int cold_reset)
+void chipset_reset(int cold_reset)
{
if (cold_reset) {
/*
@@ -252,9 +239,6 @@ void x86_power_reset(int cold_reset)
}
}
-/*****************************************************************************/
-/* Chipset interface */
-
int chipset_in_state(int state_mask)
{
int need_mask = 0;
@@ -680,7 +664,7 @@ static int command_x86reset(int argc, char **argv)
/* Force the x86 to reset */
ccprintf("Issuing x86 %s reset...\n", is_cold ? "cold" : "warm");
- x86_power_reset(is_cold);
+ chipset_reset(is_cold);
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(x86reset, command_x86reset,
@@ -706,7 +690,7 @@ DECLARE_CONSOLE_COMMAND(powerinfo, command_powerinfo,
static int command_x86shutdown(int argc, char **argv)
{
- x86_power_force_shutdown();
+ chipset_force_shutdown();
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(x86shutdown, command_x86shutdown,