summaryrefslogtreecommitdiff
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
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
-rw-r--r--chip/lm4/keyboard_scan.c4
-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
-rw-r--r--include/chipset.h52
-rw-r--r--include/x86_power.h17
8 files changed, 76 insertions, 90 deletions
diff --git a/chip/lm4/keyboard_scan.c b/chip/lm4/keyboard_scan.c
index 03534260fc..fd2f6486b9 100644
--- a/chip/lm4/keyboard_scan.c
+++ b/chip/lm4/keyboard_scan.c
@@ -5,6 +5,7 @@
/* Keyboard scanner module for Chrome EC */
+#include "chipset.h"
#include "common.h"
#include "console.h"
#include "host_command.h"
@@ -17,7 +18,6 @@
#include "task.h"
#include "timer.h"
#include "util.h"
-#include "x86_power.h"
/* Console output macros */
#define CPUTS(outstr) cputs(CC_KEYSCAN, outstr)
@@ -202,7 +202,7 @@ static void check_runtime_keys(const uint8_t *state)
if (state[MASK_INDEX_KEY_R] == MASK_VALUE_KEY_R) {
/* R = reboot */
CPRINTF("[%T KB warm reboot]\n");
- x86_power_reset(0);
+ chipset_reset(0);
} else if (state[MASK_INDEX_KEY_H] == MASK_VALUE_KEY_H) {
/* H = hibernate */
CPRINTF("[%T KB hibernate]\n");
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,
diff --git a/include/chipset.h b/include/chipset.h
index b2f8897ea9..e652ec23d8 100644
--- a/include/chipset.h
+++ b/include/chipset.h
@@ -3,23 +3,27 @@
* found in the LICENSE file.
*/
-/* Chipset module for Chrome EC.
+/*
+ * Chipset module for Chrome EC.
*
* This is intended to be a platform/chipset-neutral interface, implemented by
- * all main chipsets (x86, gaia, etc.). */
+ * all main chipsets (x86, gaia, etc.).
+ */
#ifndef __CROS_EC_CHIPSET_H
#define __CROS_EC_CHIPSET_H
#include "common.h"
-/* Chipset state mask
+/*
+ * Chipset state mask
*
* Note that this is a non-exhaustive list of states which the main chipset can
* be in, and is potentially one-to-many for real, underlying chipset states.
* That's why chipset_in_state() asks "Is the chipset in something
* approximating this state?" and not "Tell me what state the chipset is in and
- * I'll compare it myself with the state(s) I want." */
+ * I'll compare it myself with the state(s) I want."
+ */
enum chipset_state_mask {
CHIPSET_STATE_HARD_OFF = 0x01, /* Hard off (G3) */
CHIPSET_STATE_SOFT_OFF = 0x02, /* Soft off (S5) */
@@ -30,15 +34,45 @@ enum chipset_state_mask {
CHIPSET_STATE_SOFT_OFF), /* Any off state */
};
-/* Return non-zero if the chipset is in one of the states specified in the
- * mask. */
+/**
+ * Check if chipset is in a given state.
+ *
+ * @param state_mask Combination of one or more CHIPSET_STATE_* flags.
+ *
+ * @return non-zero if the chipset is in one of the states specified in the
+ * mask.
+ */
int chipset_in_state(int state_mask);
-/* Ask the chipset to exit the hard off state. Does nothing if the chipset has
- * already left the state, or was not in the state to begin with. */
+/**
+ * Ask the chipset to exit the hard off state.
+ *
+ * Does nothing if the chipset has already left the state, or was not in the
+ * state to begin with.
+ */
void chipset_exit_hard_off(void);
-/* Enable/disable CPU throttling. */
+/**
+ * Enable/disable CPU throttling.
+ *
+ * @param throttle Enable (!=0) or disable(0) throttling
+ */
void chipset_throttle_cpu(int throttle);
+/**
+ * Immedaitely shut off power to main processor and chipset.
+ *
+ * This is intended for use when the system is too hot or battery power is
+ * critical.
+ */
+void chipset_force_shutdown(void);
+
+/**
+ * Reset the CPU and/or chipset.
+ *
+ * @param cold_reset If !=0, force a cold reset of the CPU and chipset;
+ * if 0, just pulse the reset line to the CPU.
+ */
+void chipset_reset(int cold_reset);
+
#endif /* __CROS_EC_CHIPSET_H */
diff --git a/include/x86_power.h b/include/x86_power.h
index ec0adeb34e..48744b0786 100644
--- a/include/x86_power.h
+++ b/include/x86_power.h
@@ -8,22 +8,11 @@
#ifndef __CROS_EC_X86_POWER_H
#define __CROS_EC_X86_POWER_H
-#include "common.h"
#include "gpio.h"
-/* Interrupt handler for input GPIOs */
+/**
+ * Interrupt handler for x86 chipset GPIOs.
+ */
void x86_power_interrupt(enum gpio_signal signal);
-/* Informs the power module that the CPU has overheated (too_hot=1) or is
- * no longer too hot (too_hot=0). */
-void x86_power_cpu_overheated(int too_hot);
-
-/* Immediately shuts down power to the main processor and chipset. This is
- * intended for use when the system is too hot or battery power is critical. */
-void x86_power_force_shutdown(void);
-
-/* Reset the x86. If cold_reset!=0, forces a cold reset by sending
- * power-not-ok; otherwise, just pulses the reset line to the x86. */
-void x86_power_reset(int cold_reset);
-
#endif /* __CROS_EC_X86_POWER_H */