summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bernacki <bernacki@google.com>2023-02-02 11:32:17 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-14 10:16:36 +0000
commit4232722401d59e8fcf0a8bd7902506945f1df835 (patch)
tree0640cd7d4ef7e98b747254127421cae8cb027053
parent4ffe5a5da01205ede49e2f001d9c3e1412ea4d64 (diff)
downloadchrome-ec-4232722401d59e8fcf0a8bd7902506945f1df835.tar.gz
host_cmd: Add command to get/set s0ix counter
BUG=b:261869264 TEST=Tested on skyrim and nissa BRANCH=none Change-Id: I4f2cd0121b6eab445b9645037d607ae10daea835 Signed-off-by: Grzegorz Bernacki <bernacki@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4239443 Reviewed-by: Robert Zieba <robertzieba@google.com>
-rw-r--r--common/host_command.c22
-rw-r--r--include/ec_commands.h17
2 files changed, 39 insertions, 0 deletions
diff --git a/common/host_command.c b/common/host_command.c
index 3693941476..37715b793f 100644
--- a/common/host_command.c
+++ b/common/host_command.c
@@ -13,6 +13,7 @@
#include "host_command.h"
#include "link_defs.h"
#include "lpc.h"
+#include "power.h"
#include "printf.h"
#include "shared_mem.h"
#include "system.h"
@@ -916,3 +917,24 @@ DECLARE_CONSOLE_COMMAND(hcdebug, command_hcdebug,
"hcdebug [off | normal | every | params]",
"Set host command debug output mode");
#endif /* CONFIG_CMD_HCDEBUG */
+
+#if defined(CONFIG_AP_PWRSEQ_S0IX_COUNTER) || \
+ defined(CONFIG_POWERSEQ_S0IX_COUNTER)
+static enum ec_status
+host_command_get_s0ix_cnt(struct host_cmd_handler_args *args)
+{
+ const struct ec_params_s0ix_cnt *p = args->params;
+ struct ec_response_s0ix_cnt *r = args->response;
+
+ if (p->flags & EC_S0IX_COUNTER_RESET) {
+ atomic_clear(&s0ix_counter);
+ }
+
+ r->s0ix_counter = atomic_get(&s0ix_counter);
+
+ args->response_size = sizeof(*r);
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_GET_S0IX_COUNTER, host_command_get_s0ix_cnt,
+ EC_VER_MASK(0));
+#endif
diff --git a/include/ec_commands.h b/include/ec_commands.h
index ecf499eb84..552dd1ca79 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -4984,6 +4984,23 @@ struct ec_response_device_event {
} __ec_align4;
/*****************************************************************************/
+/* Get s0ix counter */
+#define EC_CMD_GET_S0IX_COUNTER 0x00AB
+
+/* Flag use to reset the counter */
+#define EC_S0IX_COUNTER_RESET 0x1
+
+struct ec_params_s0ix_cnt {
+ /* If EC_S0IX_COUNTER_RESET then reset otherwise get the counter */
+ uint32_t flags;
+} __ec_align4;
+
+struct ec_response_s0ix_cnt {
+ /* Value of the s0ix_counter */
+ uint32_t s0ix_counter;
+} __ec_align4;
+
+/*****************************************************************************/
/* Smart battery pass-through */
/* Get / Set 16-bit smart battery registers - OBSOLETE */