diff options
author | Aseda Aboagye <aaboagye@google.com> | 2016-09-23 10:48:35 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-09-23 21:08:54 -0700 |
commit | 0567596eb109ee95ac6564e73c79b4761219785d (patch) | |
tree | edc744ae5163f57abae2632df60d27341e5e4f70 | |
parent | f9272713da615e51ea14f70872fec46fbd88e938 (diff) | |
download | chrome-ec-0567596eb109ee95ac6564e73c79b4761219785d.tar.gz |
system: Add print_system_rtc().
This commit adds a function that allows the real-time clock to be
printed on the EC console. This could be helpful in trying to correlate
events between the EC's log and the kernel's.
BUG=chrome-os-partner:57731
BRANCH=gru
TEST=make -j buildall
Change-Id: I5e20692a173bddea3dc5c20cc0f2061cc170ce7d
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/388856
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r-- | chip/lm4/system.c | 14 | ||||
-rw-r--r-- | chip/npcx/system.c | 11 | ||||
-rw-r--r-- | include/system.h | 13 |
3 files changed, 30 insertions, 8 deletions
diff --git a/chip/lm4/system.c b/chip/lm4/system.c index 26cd0f2967..3f39da0a32 100644 --- a/chip/lm4/system.c +++ b/chip/lm4/system.c @@ -624,13 +624,19 @@ const char *system_get_chip_revision(void) /*****************************************************************************/ /* Console commands */ - #ifdef CONFIG_CMD_RTC -static int command_system_rtc(int argc, char **argv) +void print_system_rtc(enum console_channel ch) { uint32_t rtc; uint32_t rtcss; + rtc = system_get_rtc_sec_subsec(&rtcss); + cprintf(ch, "RTC: 0x%08x.%04x (%d.%06d s)\n", + rtc, rtcss, rtc, HIB_RTC_SUBSEC_TO_USEC(rtcss)); +} + +static int command_system_rtc(int argc, char **argv) +{ if (argc == 3 && !strcasecmp(argv[1], "set")) { char *e; uint32_t t = strtoi(argv[2], &e, 0); @@ -642,9 +648,7 @@ static int command_system_rtc(int argc, char **argv) return EC_ERROR_INVAL; } - rtc = system_get_rtc_sec_subsec(&rtcss); - ccprintf("RTC: 0x%08x.%04x (%d.%06d s)\n", - rtc, rtcss, rtc, HIB_RTC_SUBSEC_TO_USEC(rtcss)); + print_system_rtc(CC_COMMAND); return EC_SUCCESS; } diff --git a/chip/npcx/system.c b/chip/npcx/system.c index d8ff38f0f4..9123d52896 100644 --- a/chip/npcx/system.c +++ b/chip/npcx/system.c @@ -742,9 +742,15 @@ int system_is_reboot_warm(void) /*****************************************************************************/ /* Console commands */ #ifdef CONFIG_CMD_RTC +void print_system_rtc(enum console_channel ch) +{ + uint32_t sec = system_get_rtc_sec(); + + cprintf(ch, "RTC: 0x%08x (%d.00 s)\n", sec, sec); +} + static int command_system_rtc(int argc, char **argv) { - uint32_t sec; if (argc == 3 && !strcasecmp(argv[1], "set")) { char *e; uint32_t t = strtoi(argv[2], &e, 0); @@ -756,8 +762,7 @@ static int command_system_rtc(int argc, char **argv) return EC_ERROR_INVAL; } - sec = system_get_rtc_sec(); - ccprintf("RTC: 0x%08x (%d.00 s)\n", sec, sec); + print_system_rtc(CC_COMMAND); return EC_SUCCESS; } diff --git a/include/system.h b/include/system.h index b8895c02e2..4e0b002387 100644 --- a/include/system.h +++ b/include/system.h @@ -10,6 +10,7 @@ #include "atomic.h" #include "common.h" +#include "console.h" #include "timer.h" /* Reset causes */ @@ -309,6 +310,18 @@ void board_hibernate_late(void) __attribute__((weak)); timestamp_t system_get_rtc(void); /** + * Print out the current real-time clock value to the console. + * + * @param channel Console channel to print on. + */ +/* TODO(aaboagye): Replace this with CONFIG_RTC eventually. */ +#ifdef CONFIG_CMD_RTC +void print_system_rtc(enum console_channel channel); +#else +static inline void print_system_rtc(enum console_channel channel) { } +#endif /* !defined(CONFIG_CMD_RTC) */ + +/** * Enable hibernate interrupt */ void system_enable_hib_interrupt(void); |