diff options
-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); |