mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
mkbp_event: Allow host to report sleep state for non-wake event skipping
Allow the host to self-report its sleep state through EC_CMD_HOST_SLEEP_EVENT, which will typically be sent with SUSPEND param when the host begins its sleep process. While the host has self-reported that it is in SUSPEND, don't assert the interrupt line, except for designated wake events. BUG=chrome-os-partner:56156 BRANCH=None TEST=On kevin, run 'ectool hostsleepstate suspend', verify that interrupt assertion is skipped for battery host event. Run 'ectool hostsleepstate resume' and verify interrupt is again asserted by the battery host event. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I74288465587ccf7185cec717f7c1810602361b8c Reviewed-on: https://chromium-review.googlesource.com/368391 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
88428882b8
commit
de4d25964d
@@ -51,6 +51,7 @@
|
||||
#define CONFIG_KEYBOARD_PWRBTN_ASSERTS_KSI2
|
||||
#define CONFIG_LTO
|
||||
#define CONFIG_POWER_BUTTON
|
||||
#define CONFIG_POWER_TRACK_HOST_SLEEP_STATE
|
||||
#define CONFIG_VBOOT_HASH
|
||||
|
||||
#define CONFIG_CHARGER
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "host_command.h"
|
||||
#include "link_defs.h"
|
||||
#include "mkbp_event.h"
|
||||
#include "power.h"
|
||||
#include "util.h"
|
||||
|
||||
static uint32_t events;
|
||||
@@ -44,13 +45,28 @@ static void set_host_interrupt(int active)
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the host is sleeping. Check our power state in addition to the
|
||||
* self-reported sleep state of host (CONFIG_POWER_TRACK_HOST_SLEEP_STATE).
|
||||
*/
|
||||
static inline int host_is_sleeping(void)
|
||||
{
|
||||
int is_sleeping = !chipset_in_state(CHIPSET_STATE_ON);
|
||||
|
||||
#ifdef CONFIG_POWER_TRACK_HOST_SLEEP_STATE
|
||||
is_sleeping |=
|
||||
(power_get_host_sleep_state() == HOST_SLEEP_EVENT_S3_SUSPEND);
|
||||
#endif
|
||||
return is_sleeping;
|
||||
}
|
||||
|
||||
void mkbp_send_event(uint8_t event_type)
|
||||
{
|
||||
set_event(event_type);
|
||||
|
||||
#ifdef CONFIG_MKBP_WAKEUP_MASK
|
||||
/* checking the event if AP is not in S0 */
|
||||
if (!chipset_in_state(CHIPSET_STATE_ON)) {
|
||||
/* Only assert interrupt for wake events if host is sleeping */
|
||||
if (host_is_sleeping()) {
|
||||
uint32_t events;
|
||||
events = *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS);
|
||||
/*
|
||||
|
||||
@@ -1527,6 +1527,13 @@
|
||||
|
||||
/* Support S0ix */
|
||||
#undef CONFIG_POWER_S0IX
|
||||
|
||||
/*
|
||||
* Allow the host to self-report its sleep state, in case there is some delay
|
||||
* between the host beginning to enter the sleep state and power signals
|
||||
* actually reflecting the new state.
|
||||
*/
|
||||
#undef CONFIG_POWER_TRACK_HOST_SLEEP_STATE
|
||||
/*****************************************************************************/
|
||||
/* Support PWM control */
|
||||
#undef CONFIG_PWM
|
||||
|
||||
@@ -3186,10 +3186,6 @@ struct ec_params_host_sleep_event {
|
||||
uint8_t sleep_event;
|
||||
} __packed;
|
||||
|
||||
struct ec_response_host_sleep_event {
|
||||
uint8_t sleep_event;
|
||||
} __packed;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Smart battery pass-through */
|
||||
|
||||
|
||||
@@ -133,4 +133,12 @@ int power_get_pause_in_s5(void);
|
||||
*/
|
||||
void power_set_pause_in_s5(int pause);
|
||||
|
||||
#ifdef CONFIG_POWER_TRACK_HOST_SLEEP_STATE
|
||||
/**
|
||||
* Get sleep state of host, as reported by the host.
|
||||
*
|
||||
* @return Believed sleep state of host.
|
||||
*/
|
||||
enum host_sleep_event power_get_host_sleep_state(void);
|
||||
#endif
|
||||
#endif /* __CROS_EC_POWER_H */
|
||||
|
||||
@@ -686,3 +686,24 @@ DECLARE_CONSOLE_COMMAND(pause_in_s5, command_pause_in_s5,
|
||||
"Should the AP pause in S5 during shutdown?",
|
||||
NULL);
|
||||
#endif /* CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5 */
|
||||
|
||||
#ifdef CONFIG_POWER_TRACK_HOST_SLEEP_STATE
|
||||
/* Track last reported sleep event */
|
||||
static enum host_sleep_event host_sleep_state;
|
||||
|
||||
static int host_command_host_sleep_event(struct host_cmd_handler_args *args)
|
||||
{
|
||||
const struct ec_params_host_sleep_event *p = args->params;
|
||||
|
||||
host_sleep_state = p->sleep_event;
|
||||
return EC_RES_SUCCESS;
|
||||
}
|
||||
DECLARE_HOST_COMMAND(EC_CMD_HOST_SLEEP_EVENT,
|
||||
host_command_host_sleep_event,
|
||||
EC_VER_MASK(0));
|
||||
|
||||
enum host_sleep_event power_get_host_sleep_state(void)
|
||||
{
|
||||
return host_sleep_state;
|
||||
}
|
||||
#endif /* CONFIG_POWER_TRACK_HOST_SLEEP_STATE */
|
||||
|
||||
@@ -119,6 +119,8 @@ const char help_str[] =
|
||||
" Checks for basic communication with EC\n"
|
||||
" hibdelay [sec]\n"
|
||||
" Set the delay before going into hibernation\n"
|
||||
" hostsleepstate\n"
|
||||
" Report host sleep state to the EC\n"
|
||||
" kbpress\n"
|
||||
" Simulate key press\n"
|
||||
" kbfactorytest\n"
|
||||
@@ -380,6 +382,32 @@ int cmd_hibdelay(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cmd_hostsleepstate(int argc, char *argv[])
|
||||
{
|
||||
struct ec_params_host_sleep_event p;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: %s [suspend|resume|freeze|thaw]\n",
|
||||
argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "suspend"))
|
||||
p.sleep_event = HOST_SLEEP_EVENT_S3_SUSPEND;
|
||||
else if (!strcmp(argv[1], "resume"))
|
||||
p.sleep_event = HOST_SLEEP_EVENT_S3_RESUME;
|
||||
else if (!strcmp(argv[1], "freeze"))
|
||||
p.sleep_event = HOST_SLEEP_EVENT_S0IX_SUSPEND;
|
||||
else if (!strcmp(argv[1], "thaw"))
|
||||
p.sleep_event = HOST_SLEEP_EVENT_S0IX_RESUME;
|
||||
else {
|
||||
fprintf(stderr, "Unknown command: %s\n", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ec_command(EC_CMD_HOST_SLEEP_EVENT, 0, &p, sizeof(p), NULL, 0);
|
||||
}
|
||||
|
||||
int cmd_test(int argc, char *argv[])
|
||||
{
|
||||
struct ec_params_test_protocol p = {
|
||||
@@ -6881,6 +6909,7 @@ const struct command commands[] = {
|
||||
{"hangdetect", cmd_hang_detect},
|
||||
{"hello", cmd_hello},
|
||||
{"hibdelay", cmd_hibdelay},
|
||||
{"hostsleepstate", cmd_hostsleepstate},
|
||||
{"kbpress", cmd_kbpress},
|
||||
{"i2cprotect", cmd_i2c_protect},
|
||||
{"i2cread", cmd_i2c_read},
|
||||
|
||||
Reference in New Issue
Block a user