diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2017-09-05 10:10:29 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-10-25 03:58:50 -0700 |
commit | ab9084fd2a70a505e0e43b39e0ad40876e4853fc (patch) | |
tree | bf29e85cfbb3203dbf148dc2aecb82d7e0f793c6 /core | |
parent | 28a5ad1646b2994853e310354b604547950a55c0 (diff) | |
download | chrome-ec-ab9084fd2a70a505e0e43b39e0ad40876e4853fc.tar.gz |
chip/npcx: Add support for pad-switching UART
NPCX5* only has one UART controller, which can be switched
between 2 pads. We keep the default pad for EC console,
however, we allow switching to the alternate pad for short,
infrequent, transactions. Both pads are assumed to use the
same baudrate and other line settings.
When switching pad, we first configure the new pad, then switch
off the old one, to avoid having no pad selected at a given time,
see b/65526215#c26.
Because of the added complexity of npcx_gpio2uart (and the fact
that it uses the global variable "pad" define in uart.c), we
move the implementation to uart.c (npcx_uart2gpio is also moved
for consistency).
When the pad is switched to alternate pad, characters input
and output on the EC console (default pad) would be lost. To
compensate for this, we:
- Switch back to main pad in case of EC panic, so that output
is shown on EC console.
- Immediately abort current alternate pad transaction if a
character is received on the default pad. Note, however,
that the first character will be lost (this can be worked
around by telling user to press enter, and have servod/FAFT
always send 2 blank lines (instead of just one) before
sending a command).
- Inhibit pad switching for 500ms after receiving a character
on default pad. Assuming a reasonable typing speed, this
should allow developers to type console commands relatively
comfortably, while not starving the alternate pad communication
for too long.
The logic above could be simplified significantly by implementing
software flow control (XON/XOFF, see b/67026316).
BRANCH=none
BUG=b:65526215
TEST=While follow-up CL that writes long 1k buffers, the following
works fine:
- type 'uart' in EC console
- Read battery power consumption from servod, which "types" in
the EC console:
while true; do dut-control ppvar_vbat_mw; sleep 1; done
no failure is seen.
TEST=Add this test code in uart_alt_pad_read_write, after the pad
has been switched, and check that panic information is
consistently printed correctly:
{
static int t;
if (t++ > 20)
t = t / ret;
}
Change-Id: I18feed2f8ca4eb85f40389f77dac3a46315310e7
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/659458
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/cortex-m/panic.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/core/cortex-m/panic.c b/core/cortex-m/panic.c index 58887e5cb7..24174cfb2d 100644 --- a/core/cortex-m/panic.c +++ b/core/cortex-m/panic.c @@ -12,6 +12,7 @@ #include "system.h" #include "task.h" #include "timer.h" +#include "uart.h" #include "util.h" #include "watchdog.h" @@ -335,6 +336,9 @@ void __keep report_panic(void) pdata->cm.hfsr = CPU_NVIC_HFSR; pdata->cm.dfsr = CPU_NVIC_DFSR; +#ifdef CONFIG_UART_PAD_SWITCH + uart_reset_default_pad_panic(); +#endif panic_data_print(pdata); #ifdef CONFIG_DEBUG_EXCEPTIONS panic_show_process_stack(pdata); |