diff options
author | Pai Peng <paipeng@google.com> | 2019-07-24 15:56:44 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-10-21 23:16:49 +0000 |
commit | 5e97ef02ffb701739d1bc525bb3fe999313a2ff5 (patch) | |
tree | f66afc58070f6bd852098c177b92b679c4fdc99d /chip/g/uart.c | |
parent | e36da133d89c675592c2ade4c0cbc80035db3fde (diff) | |
download | chrome-ec-5e97ef02ffb701739d1bc525bb3fe999313a2ff5.tar.gz |
Delay uart_init() done to after pinhold is disengaged.
Since pinhold will hold UART pin, UART won't work correctly. In this
case, we want to delay uart_init() done until pinhold is disengaged.
The messages to UART are still kept in the UART buffer and can be
correctly printed through UART after pinhold is released.
BUG=b:138327854
BRANCH=none
TEST=manual
Testing: verified that after cold or warm reset, messages from RW image
can be correctly printed to UART. Without this change, we might see
incomplete messages or garbage characters.
Change-Id: I00934aa16178b995d996f6ba773abab80f329124
Signed-off-by: Pai Peng <paipeng@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1717547
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'chip/g/uart.c')
-rw-r--r-- | chip/g/uart.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/chip/g/uart.c b/chip/g/uart.c index 0ae55c8eb0..2ce2c20ca3 100644 --- a/chip/g/uart.c +++ b/chip/g/uart.c @@ -13,7 +13,13 @@ #include "uartn.h" #include "util.h" -static uint8_t done_uart_init_yet; +enum init_values { + INIT_NOT_START, + INIT_IN_PROGRESS, + INIT_DONE +}; + +static enum init_values done_uart_init_yet; #define USE_UART_INTERRUPTS (!(defined(CONFIG_CUSTOMIZED_RO) && \ defined(SECTION_IS_RO))) @@ -21,9 +27,17 @@ static uint8_t done_uart_init_yet; #define UARTN 0 #endif +static int uart_init_check_pinhold(void) +{ + if (!GREAD(PINMUX, HOLD) && done_uart_init_yet == INIT_IN_PROGRESS) + done_uart_init_yet = INIT_DONE; + return done_uart_init_yet == INIT_DONE; +} + int uart_init_done(void) { - return done_uart_init_yet; + return (done_uart_init_yet == INIT_DONE) || + uart_init_check_pinhold(); } void uart_tx_start(void) @@ -108,6 +122,5 @@ void uart_init(void) #ifdef UART_EC uartn_init(UART_EC); #endif - - done_uart_init_yet = 1; + done_uart_init_yet = INIT_IN_PROGRESS; } |