summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2020-01-14 07:42:15 -0700
committerCommit Bot <commit-bot@chromium.org>2020-01-15 18:02:02 +0000
commitb45b6ff946269c25b555fe3bc508d7c4c0b8b8fe (patch)
treeb66d845ad23c4d262abe3788c303e483a6554152
parent0ecc66ea725372db174fb5ac125b4f856f76cfce (diff)
downloadchrome-ec-b45b6ff946269c25b555fe3bc508d7c4c0b8b8fe.tar.gz
servo_micro: update UART holding logic
We do not need to shutdown the UART to take control of the RX pin, we can simply de-mux the pin from UART and make it a GPIO temporarily. BRANCH=none BUG=none TEST=builds and tested same code on c2d2 implementation. My reworked servo micro is no longer working for the EC console (without this change) Change-Id: Ie0aeb73e58aea08d42a32d47431ac36cd977b8ba Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2001124 Reviewed-by: Keith Short <keithshort@chromium.org> (cherry picked from commit 53818877a2b7d01089364fadc5de590e1b656bf2) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2002957
-rw-r--r--board/servo_micro/board.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/board/servo_micro/board.c b/board/servo_micro/board.c
index 70fdb7f55e..7d9bd0bac5 100644
--- a/board/servo_micro/board.c
+++ b/board/servo_micro/board.c
@@ -240,30 +240,23 @@ DECLARE_CONSOLE_COMMAND(baud, command_uart_baud,
*/
static int command_hold_usart_low(int argc, char **argv)
{
- /* Each bit represents if that port is being held low */
+ /* Each bit represents if that port rx is being held low */
static int usart_status;
- const struct usart_config *usart;
int usart_mask;
- enum gpio_signal tx, rx;
+ enum gpio_signal rx;
if (argc > 3 || argc < 2)
return EC_ERROR_PARAM_COUNT;
if (!strcasecmp(argv[1], "usart2")) {
- usart = &usart2;
usart_mask = 1 << 2;
- tx = GPIO_USART2_SERVO_TX_DUT_RX;
rx = GPIO_USART2_SERVO_RX_DUT_TX;
} else if (!strcasecmp(argv[1], "usart3")) {
- usart = &usart3;
usart_mask = 1 << 3;
- tx = GPIO_USART3_SERVO_TX_DUT_RX;
rx = GPIO_USART3_SERVO_RX_DUT_TX;
} else if (!strcasecmp(argv[1], "usart4")) {
- usart = &usart4;
usart_mask = 1 << 4;
- tx = GPIO_USART4_SERVO_TX_DUT_RX;
rx = GPIO_USART4_SERVO_RX_DUT_TX;
} else {
return EC_ERROR_PARAM1;
@@ -281,36 +274,22 @@ static int command_hold_usart_low(int argc, char **argv)
/* Do nothing since there is no change */
} else if (hold_low) {
/*
- * Only one USART can be held low at a time, because
- * re-initializing one USART will pull all of the USART
- * GPIO pins back into alternate mode.
- */
- if (usart_status)
- return EC_ERROR_BUSY;
-
- /*
- * Shutdown the USB uart,
- * turn off alternate mode, then set the RX line
- * pin to output low to enter UART programming mode.
+ * No need to shutdown UART, just de-mux the RX pin from
+ * UART and change it to a GPIO temporarily.
*/
- usart_shutdown(usart);
gpio_config_pin(MODULE_USART, rx, 0);
- gpio_config_pin(MODULE_USART, tx, 0);
gpio_set_flags(rx, GPIO_OUT_LOW);
+ /* Update global uart state */
usart_status |= usart_mask;
} else {
/*
- * This will reset the alternate mode of the
- * GPIO pins appropriately and restart USB UART
+ * Mux the RX pin back to GPIO mode
*/
- usart_init(usart);
+ gpio_config_pin(MODULE_USART, rx, 1);
- /*
- * Since only one USART can be held low at a time, the
- * uart_status will always be 0 after this call.
- */
- usart_status = 0;
+ /* Update global uart state */
+ usart_status &= ~usart_mask;
}
}