summaryrefslogtreecommitdiff
path: root/chip/npcx/gpio_chip.h
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2017-09-05 10:10:29 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-10-25 03:58:50 -0700
commitab9084fd2a70a505e0e43b39e0ad40876e4853fc (patch)
treebf29e85cfbb3203dbf148dc2aecb82d7e0f793c6 /chip/npcx/gpio_chip.h
parent28a5ad1646b2994853e310354b604547950a55c0 (diff)
downloadchrome-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 'chip/npcx/gpio_chip.h')
-rw-r--r--chip/npcx/gpio_chip.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/chip/npcx/gpio_chip.h b/chip/npcx/gpio_chip.h
index 1595f6b20d..b5fcec20c8 100644
--- a/chip/npcx/gpio_chip.h
+++ b/chip/npcx/gpio_chip.h
@@ -32,6 +32,17 @@
NPCX_LVOL_CTRL_##ctrl##_6, \
NPCX_LVOL_CTRL_##ctrl##_7, }
+/**
+ * Switch NPCX UART pins back to normal GPIOs.
+ */
+void npcx_uart2gpio(void);
+
+/**
+ * Switch NPCX UART pins to UART mode (depending on the currently selected
+ * pad, see uart.c).
+ */
+void npcx_gpio2uart(void);
+
/*
* Include the MIWU, alternative and low-Voltage macro functions for GPIOs
* depends on Nuvoton chip series.