summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2015-05-05 17:35:46 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-05-07 17:25:40 +0000
commit3dd6e71828b12b786a7cf84fe1bf9b01a3856eee (patch)
tree74b8355f5a2aea7877721ffe5d393485ddd287e4
parentf8a8f0bbfdf06780759ecf1e315e9a81d41a6387 (diff)
downloadchrome-ec-3dd6e71828b12b786a7cf84fe1bf9b01a3856eee.tar.gz
power: Move EC_CMD_GSV_PAUSE_IN_S5 handler to common code
The same code exists in four (soon to be five!) different power sequencing drivers, so move it up to common. BUG=None TEST=Manual on Samus. Run "pause_in_s5 on" on EC console, verify that system stops in S5 on shutdown. Run "pause_in_s5 off" on EC console, verify that system again goes to G3 on shutdown. BRANCH=None Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: Iaf05ef7ce017be4f9d173e83e985a7a879ba278c Reviewed-on: https://chromium-review.googlesource.com/269566 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--board/auron/board.h1
-rw-r--r--board/cyan/board.h1
-rw-r--r--board/falco/board.h1
-rw-r--r--board/glower/board.h1
-rw-r--r--board/peppy/board.h1
-rw-r--r--board/rambi/board.h1
-rw-r--r--board/samus/board.h1
-rw-r--r--board/samus/power_sequence.c35
-rw-r--r--board/squawks/board.h1
-rw-r--r--board/strago/board.h1
-rw-r--r--include/config.h3
-rw-r--r--include/power.h14
-rw-r--r--power/baytrail.c38
-rw-r--r--power/braswell.c38
-rw-r--r--power/common.c52
-rw-r--r--power/haswell.c36
16 files changed, 87 insertions, 138 deletions
diff --git a/board/auron/board.h b/board/auron/board.h
index 7ae3f25836..af1837dac0 100644
--- a/board/auron/board.h
+++ b/board/auron/board.h
@@ -22,6 +22,7 @@
#define CONFIG_CHIPSET_CAN_THROTTLE
#define CONFIG_CHIPSET_HASWELL
#define CONFIG_POWER_COMMON
+#define CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5
#define CONFIG_CMD_GSV
#define CONFIG_EXTPOWER_GPIO
#define CONFIG_FANS 1
diff --git a/board/cyan/board.h b/board/cyan/board.h
index a866ec1f09..93b7d43537 100644
--- a/board/cyan/board.h
+++ b/board/cyan/board.h
@@ -24,6 +24,7 @@
#define CONFIG_LID_SWITCH
#define CONFIG_LED_COMMON
#define CONFIG_POWER_COMMON
+#define CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5
#define CONFIG_EXTPOWER_GPIO
#define CONFIG_I2C
diff --git a/board/falco/board.h b/board/falco/board.h
index 8b79534384..358f2a2235 100644
--- a/board/falco/board.h
+++ b/board/falco/board.h
@@ -19,6 +19,7 @@
#define CONFIG_CHIPSET_CAN_THROTTLE
#define CONFIG_CHIPSET_HASWELL
#define CONFIG_POWER_COMMON
+#define CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5
#define CONFIG_CMD_GSV
#define CONFIG_EXTPOWER_FALCO
#define CONFIG_EXTPOWER_GPIO
diff --git a/board/glower/board.h b/board/glower/board.h
index 387c582992..edd0c56ec9 100644
--- a/board/glower/board.h
+++ b/board/glower/board.h
@@ -27,6 +27,7 @@
#define CONFIG_CHIPSET_BAYTRAIL
#define CONFIG_CHIPSET_CAN_THROTTLE
#define CONFIG_POWER_COMMON
+#define CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5
/* #define CONFIG_CMD_GSV */
#define CONFIG_EXTPOWER_GPIO
#define CONFIG_I2C_PASSTHRU_RESTRICTED
diff --git a/board/peppy/board.h b/board/peppy/board.h
index ffc0c2e4fd..683aa82da1 100644
--- a/board/peppy/board.h
+++ b/board/peppy/board.h
@@ -22,6 +22,7 @@
#define CONFIG_CHIPSET_CAN_THROTTLE
#define CONFIG_CHIPSET_HASWELL
#define CONFIG_POWER_COMMON
+#define CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5
#define CONFIG_CMD_GSV
#define CONFIG_EXTPOWER_GPIO
#define CONFIG_FANS 1
diff --git a/board/rambi/board.h b/board/rambi/board.h
index f913792b32..40b6515fd9 100644
--- a/board/rambi/board.h
+++ b/board/rambi/board.h
@@ -23,6 +23,7 @@
#define CONFIG_CHIPSET_BAYTRAIL
#define CONFIG_CHIPSET_CAN_THROTTLE
#define CONFIG_POWER_COMMON
+#define CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5
#define CONFIG_CMD_GSV
#define CONFIG_EXTPOWER_GPIO
#define CONFIG_I2C_PASSTHRU_RESTRICTED
diff --git a/board/samus/board.h b/board/samus/board.h
index 8c168cffdc..30af544baf 100644
--- a/board/samus/board.h
+++ b/board/samus/board.h
@@ -26,6 +26,7 @@
#define CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT 60
#define CONFIG_BATTERY_CUT_OFF
#define CONFIG_POWER_COMMON
+#define CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5
#define CONFIG_CHIPSET_CAN_THROTTLE
#define CONFIG_KEYBOARD_BOARD_CONFIG
#define CONFIG_KEYBOARD_PROTOCOL_8042
diff --git a/board/samus/power_sequence.c b/board/samus/power_sequence.c
index daca4ae4ef..83bf1e91f9 100644
--- a/board/samus/power_sequence.c
+++ b/board/samus/power_sequence.c
@@ -13,7 +13,6 @@
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
-#include "host_command.h"
#include "lid_switch.h"
#include "power.h"
#include "registers.h"
@@ -62,7 +61,6 @@
IN_ALL_PM_SLP_DEASSERTED)
static int throttle_cpu; /* Throttle CPU? */
-static int pause_in_s5; /* Pause in S5 when shutting down? */
static uint32_t pp5000_in_g3; /* Turn PP5000 on in G3? */
void chipset_force_shutdown(void)
@@ -474,7 +472,7 @@ enum power_state power_handle_state(enum power_state state)
gpio_set_level(GPIO_TOUCHSCREEN_RESET_L, 0);
gpio_set_level(GPIO_LIGHTBAR_RESET_L, 0);
- return pause_in_s5 ? POWER_S5 : POWER_S5G3;
+ return power_get_pause_in_s5() ? POWER_S5 : POWER_S5G3;
case POWER_S5G3:
/* Deassert DPWROK */
@@ -559,34 +557,3 @@ int lb_power(int enabled)
return ret;
}
#endif
-
-static int host_command_gsv(struct host_cmd_handler_args *args)
-{
- const struct ec_params_get_set_value *p = args->params;
- struct ec_response_get_set_value *r = args->response;
-
- if (p->flags & EC_GSV_SET)
- pause_in_s5 = p->value;
-
- r->value = pause_in_s5;
-
- args->response_size = sizeof(*r);
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_GSV_PAUSE_IN_S5,
- host_command_gsv,
- EC_VER_MASK(0));
-
-static int console_command_gsv(int argc, char **argv)
-{
- if (argc > 1 && !parse_bool(argv[1], &pause_in_s5))
- return EC_ERROR_INVAL;
-
- ccprintf("pause_in_s5 = %s\n", pause_in_s5 ? "on" : "off");
-
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(pause_in_s5, console_command_gsv,
- "[on|off]",
- "Should the AP pause in S5 during shutdown?",
- NULL);
diff --git a/board/squawks/board.h b/board/squawks/board.h
index 935752fdf3..25c5a50d8a 100644
--- a/board/squawks/board.h
+++ b/board/squawks/board.h
@@ -23,6 +23,7 @@
#define CONFIG_CHIPSET_BAYTRAIL
#define CONFIG_CHIPSET_CAN_THROTTLE
#define CONFIG_POWER_COMMON
+#define CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5
#define CONFIG_CMD_GSV
#define CONFIG_EXTPOWER_GPIO
#define CONFIG_I2C_PASSTHRU_RESTRICTED
diff --git a/board/strago/board.h b/board/strago/board.h
index 3fec75e76b..9d1a18cf42 100644
--- a/board/strago/board.h
+++ b/board/strago/board.h
@@ -24,6 +24,7 @@
#define CONFIG_POWER_BUTTON_X86
#define CONFIG_LID_SWITCH
#define CONFIG_POWER_COMMON
+#define CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5
#define CONFIG_EXTPOWER_GPIO
#define CONFIG_PORT80_TASK_EN
diff --git a/include/config.h b/include/config.h
index ca6bcea988..307edb4722 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1026,6 +1026,9 @@
/* Compile common code for AP power state machine */
#undef CONFIG_POWER_COMMON
+/* Support stopping in S5 on shutdown */
+#undef CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5
+
/* Use part of the EC's data EEPROM to hold persistent storage for the AP. */
#undef CONFIG_PSTORE
diff --git a/include/power.h b/include/power.h
index 8f11c14868..9ba4213ad1 100644
--- a/include/power.h
+++ b/include/power.h
@@ -103,4 +103,18 @@ void power_signal_interrupt(enum gpio_signal signal);
static inline void power_signal_interrupt(enum gpio_signal signal) { }
#endif /* !HAS_TASK_CHIPSET */
+/**
+ * pause_in_s5 getter method.
+ *
+ * @return Whether we should pause in S5 when shutting down.
+ */
+inline int power_get_pause_in_s5(void);
+
+/**
+ * pause_in_s5 setter method.
+ *
+ * @param pause True if we should pause in S5 when shutting down.
+ */
+inline void power_set_pause_in_s5(int pause);
+
#endif /* __CROS_EC_POWER_H */
diff --git a/power/baytrail.c b/power/baytrail.c
index c84e74130a..3290378234 100644
--- a/power/baytrail.c
+++ b/power/baytrail.c
@@ -11,7 +11,6 @@
#include "ec_commands.h"
#include "gpio.h"
#include "hooks.h"
-#include "host_command.h"
#include "lid_switch.h"
#include "lpc.h"
#include "power.h"
@@ -52,7 +51,6 @@
IN_PGOOD_ALL_CORE | IN_ALL_PM_SLP_DEASSERTED)
static int throttle_cpu; /* Throttle CPU? */
-static int pause_in_s5 = 1; /* Pause in S5 when shutting down? */
static int restart_from_s5; /* Force system back on from S5 */
static int fake_pltrst_timeout; /* Fake PLTRST# timeout at next power-on */
@@ -110,6 +108,9 @@ void chipset_throttle_cpu(int throttle)
enum power_state power_chipset_init(void)
{
+ /* Pause in S5 when shutting down. */
+ power_set_pause_in_s5(1);
+
/*
* If we're switching between images without rebooting, see if the x86
* is already powered on; if so, leave it there instead of cycling
@@ -400,7 +401,7 @@ enum power_state power_handle_state(enum power_state state)
}
/* Start shutting down */
- return pause_in_s5 ? POWER_S5 : POWER_S5G3;
+ return power_get_pause_in_s5() ? POWER_S5 : POWER_S5G3;
case POWER_S5G3:
/* Assert RSMRST# */
@@ -413,37 +414,6 @@ enum power_state power_handle_state(enum power_state state)
return state;
}
-static int host_command_gsv(struct host_cmd_handler_args *args)
-{
- const struct ec_params_get_set_value *p = args->params;
- struct ec_response_get_set_value *r = args->response;
-
- if (p->flags & EC_GSV_SET)
- pause_in_s5 = p->value;
-
- r->value = pause_in_s5;
-
- args->response_size = sizeof(*r);
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_GSV_PAUSE_IN_S5,
- host_command_gsv,
- EC_VER_MASK(0));
-
-static int console_command_gsv(int argc, char **argv)
-{
- if (argc > 1 && !parse_bool(argv[1], &pause_in_s5))
- return EC_ERROR_INVAL;
-
- ccprintf("pause_in_s5 = %s\n", pause_in_s5 ? "on" : "off");
-
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(pause_in_s5, console_command_gsv,
- "[on|off]",
- "Should the AP pause in S5 during shutdown?",
- NULL);
-
static int console_command_powerfail(int argc, char **argv)
{
ccprintf("Faking a failure of next power-on event\n");
diff --git a/power/braswell.c b/power/braswell.c
index 0e2adb1034..aa9301f5d8 100644
--- a/power/braswell.c
+++ b/power/braswell.c
@@ -11,7 +11,6 @@
#include "ec_commands.h"
#include "gpio.h"
#include "hooks.h"
-#include "host_command.h"
#include "lid_switch.h"
#include "lpc.h"
#include "power.h"
@@ -52,7 +51,6 @@
#define IN_ALL_S0 (IN_PGOOD_S0 | IN_ALL_PM_SLP_DEASSERTED)
static int throttle_cpu; /* Throttle CPU? */
-static int pause_in_s5 = 1; /* Pause in S5 when shutting down? */
void chipset_force_shutdown(void)
{
@@ -108,6 +106,9 @@ void chipset_throttle_cpu(int throttle)
enum power_state power_chipset_init(void)
{
+ /* Pause in S5 when shutting down. */
+ power_set_pause_in_s5(1);
+
/*
* If we're switching between images without rebooting, see if the x86
* is already powered on; if so, leave it there instead of cycling
@@ -292,7 +293,7 @@ enum power_state power_handle_state(enum power_state state)
/*wireless_set_state(WIRELESS_OFF);*/
/* Start shutting down */
- return pause_in_s5 ? POWER_S5 : POWER_S5G3;
+ return power_get_pause_in_s5() ? POWER_S5 : POWER_S5G3;
case POWER_S5G3:
/* Assert RSMRST# */
@@ -302,34 +303,3 @@ enum power_state power_handle_state(enum power_state state)
return state;
}
-
-static int host_command_gsv(struct host_cmd_handler_args *args)
-{
- const struct ec_params_get_set_value *p = args->params;
- struct ec_response_get_set_value *r = args->response;
-
- if (p->flags & EC_GSV_SET)
- pause_in_s5 = p->value;
-
- r->value = pause_in_s5;
-
- args->response_size = sizeof(*r);
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_GSV_PAUSE_IN_S5,
- host_command_gsv,
- EC_VER_MASK(0));
-
-static int console_command_gsv(int argc, char **argv)
-{
- if (argc > 1 && !parse_bool(argv[1], &pause_in_s5))
- return EC_ERROR_INVAL;
-
- ccprintf("pause_in_s5 = %s\n", pause_in_s5 ? "on" : "off");
-
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(pause_in_s5, console_command_gsv,
- "[on|off]",
- "Should the AP pause in S5 during shutdown?",
- NULL);
diff --git a/power/common.c b/power/common.c
index b1bced365d..f59fe45273 100644
--- a/power/common.c
+++ b/power/common.c
@@ -12,6 +12,7 @@
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
+#include "host_command.h"
#include "power.h"
#include "system.h"
#include "task.h"
@@ -58,6 +59,11 @@ static uint64_t last_shutdown_time; /* When did we enter G3? */
static uint32_t hibernate_delay = CONFIG_HIBERNATE_DELAY_SEC;
#endif
+#ifdef CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5
+/* Pause in S5 on shutdown? */
+static int pause_in_s5;
+#endif
+
/**
* Update input signals mask
*/
@@ -410,7 +416,6 @@ static void siglog_add(enum gpio_signal signal)
#define SIGLOG(S)
#endif /* CONFIG_BRINGUP */
-
void power_signal_interrupt(enum gpio_signal signal)
{
SIGLOG(signal);
@@ -422,6 +427,18 @@ void power_signal_interrupt(enum gpio_signal signal)
task_wake(TASK_ID_CHIPSET);
}
+#ifdef CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5
+inline int power_get_pause_in_s5(void)
+{
+ return pause_in_s5;
+}
+
+inline void power_set_pause_in_s5(int pause)
+{
+ pause_in_s5 = pause;
+}
+#endif
+
/*****************************************************************************/
/* Console commands */
@@ -506,3 +523,36 @@ DECLARE_CONSOLE_COMMAND(hibdelay, command_hibernation_delay,
"Set the delay before going into hibernation",
NULL);
#endif /* CONFIG_HIBERNATE */
+
+#ifdef CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5
+static int host_command_pause_in_s5(struct host_cmd_handler_args *args)
+{
+ const struct ec_params_get_set_value *p = args->params;
+ struct ec_response_get_set_value *r = args->response;
+
+ if (p->flags & EC_GSV_SET)
+ pause_in_s5 = p->value;
+
+ r->value = pause_in_s5;
+
+ args->response_size = sizeof(*r);
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_GSV_PAUSE_IN_S5,
+ host_command_pause_in_s5,
+ EC_VER_MASK(0));
+
+static int command_pause_in_s5(int argc, char **argv)
+{
+ if (argc > 1 && !parse_bool(argv[1], &pause_in_s5))
+ return EC_ERROR_INVAL;
+
+ ccprintf("pause_in_s5 = %s\n", pause_in_s5 ? "on" : "off");
+
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(pause_in_s5, command_pause_in_s5,
+ "[on|off]",
+ "Should the AP pause in S5 during shutdown?",
+ NULL);
+#endif /* CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5 */
diff --git a/power/haswell.c b/power/haswell.c
index ae7cf7a14a..00a0926f6e 100644
--- a/power/haswell.c
+++ b/power/haswell.c
@@ -11,7 +11,6 @@
#include "ec_commands.h"
#include "gpio.h"
#include "hooks.h"
-#include "host_command.h"
#include "lid_switch.h"
#include "power.h"
#include "system.h"
@@ -52,7 +51,6 @@
IN_PGOOD_ALL_CORE | IN_ALL_PM_SLP_DEASSERTED)
static int throttle_cpu; /* Throttle CPU? */
-static int pause_in_s5; /* Pause in S5 when shutting down? */
void chipset_force_shutdown(void)
{
@@ -360,7 +358,7 @@ enum power_state power_handle_state(enum power_state state)
gpio_set_level(GPIO_PP5000_EN, 0);
/* Start shutting down */
- return pause_in_s5 ? POWER_S5 : POWER_S5G3;
+ return power_get_pause_in_s5() ? POWER_S5 : POWER_S5G3;
case POWER_S5G3:
/* Deassert DPWROK, assert RSMRST# */
@@ -378,35 +376,3 @@ void power_interrupt(enum gpio_signal signal)
/* Pass through eDP VDD enable from PCH */
gpio_set_level(GPIO_EC_EDP_VDD_EN, gpio_get_level(GPIO_PCH_EDP_VDD_EN));
}
-
-static int host_command_gsv(struct host_cmd_handler_args *args)
-{
- const struct ec_params_get_set_value *p = args->params;
- struct ec_response_get_set_value *r = args->response;
-
- if (p->flags & EC_GSV_SET)
- pause_in_s5 = p->value;
-
- r->value = pause_in_s5;
-
- args->response_size = sizeof(*r);
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_GSV_PAUSE_IN_S5,
- host_command_gsv,
- EC_VER_MASK(0));
-
-static int console_command_gsv(int argc, char **argv)
-{
- if (argc > 1 && !parse_bool(argv[1], &pause_in_s5))
- return EC_ERROR_INVAL;
-
- ccprintf("pause_in_s5 = %s\n", pause_in_s5 ? "on" : "off");
-
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(pause_in_s5, console_command_gsv,
- "[on|off]",
- "Should the AP pause in S5 during shutdown?",
- NULL);
-