summaryrefslogtreecommitdiff
path: root/common/chipset.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/chipset.c')
-rw-r--r--common/chipset.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/common/chipset.c b/common/chipset.c
index 61478f184a..55964e4ba9 100644
--- a/common/chipset.c
+++ b/common/chipset.c
@@ -1,4 +1,4 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -18,30 +18,27 @@
/* Console output macros */
#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
-#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ##args)
/*****************************************************************************/
/* Console commands */
#ifdef CONFIG_CMD_POWER_AP
-static int command_apreset(int argc, char **argv)
+static int command_apreset(int argc, const char **argv)
{
/* Force the chipset to reset */
ccprintf("Issuing AP reset...\n");
chipset_reset(CHIPSET_RESET_CONSOLE_CMD);
return EC_SUCCESS;
}
-DECLARE_CONSOLE_COMMAND(apreset, command_apreset,
- NULL,
- "Issue AP reset");
+DECLARE_CONSOLE_COMMAND(apreset, command_apreset, NULL, "Issue AP reset");
-static int command_apshutdown(int argc, char **argv)
+static int command_apshutdown(int argc, const char **argv)
{
chipset_force_shutdown(CHIPSET_SHUTDOWN_CONSOLE_CMD);
return EC_SUCCESS;
}
-DECLARE_CONSOLE_COMMAND(apshutdown, command_apshutdown,
- NULL,
+DECLARE_CONSOLE_COMMAND(apshutdown, command_apshutdown, NULL,
"Force AP shutdown");
#endif
@@ -53,9 +50,7 @@ static enum ec_status host_command_apreset(struct host_cmd_handler_args *args)
chipset_reset(CHIPSET_RESET_HOST_CMD);
return EC_RES_SUCCESS;
}
-DECLARE_HOST_COMMAND(EC_CMD_AP_RESET,
- host_command_apreset,
- EC_VER_MASK(0));
+DECLARE_HOST_COMMAND(EC_CMD_AP_RESET, host_command_apreset, EC_VER_MASK(0));
#endif
@@ -64,8 +59,7 @@ K_MUTEX_DEFINE(reset_log_mutex);
static int next_reset_log __preserved_logs(next_reset_log);
static uint32_t ap_resets_since_ec_boot;
/* keep reset_logs size a power of 2 */
-static struct ap_reset_log_entry
- reset_logs[4] __preserved_logs(reset_logs);
+static struct ap_reset_log_entry reset_logs[4] __preserved_logs(reset_logs);
static int reset_log_checksum __preserved_logs(reset_log_checksum);
/* Calculate reset log checksum */
@@ -113,11 +107,10 @@ get_ap_reset_stats(struct ap_reset_log_entry *reset_log_entries,
mutex_lock(&reset_log_mutex);
*resets_since_ec_boot = ap_resets_since_ec_boot;
- for (i = 0;
- i != ARRAY_SIZE(reset_logs) && i != num_reset_log_entries;
+ for (i = 0; i != ARRAY_SIZE(reset_logs) && i != num_reset_log_entries;
++i) {
log_address = (next_reset_log + i) &
- (ARRAY_SIZE(reset_logs) - 1);
+ (ARRAY_SIZE(reset_logs) - 1);
reset_log_entries[i] = reset_logs[log_address];
}
mutex_unlock(&reset_log_mutex);
@@ -125,4 +118,19 @@ get_ap_reset_stats(struct ap_reset_log_entry *reset_log_entries,
return EC_SUCCESS;
}
-#endif /* !CONFIG_AP_RESET_LOG */
+enum chipset_shutdown_reason chipset_get_shutdown_reason(void)
+{
+ enum chipset_shutdown_reason reason = CHIPSET_RESET_UNKNOWN;
+
+ mutex_lock(&reset_log_mutex);
+ if (ap_resets_since_ec_boot != 0) {
+ int i = (next_reset_log == 0) ? ARRAY_SIZE(reset_logs) - 1 :
+ next_reset_log - 1;
+ reason = reset_logs[i].reset_cause;
+ }
+ mutex_unlock(&reset_log_mutex);
+
+ return reason;
+}
+
+#endif /* !CONFIG_AP_RESET_LOG */