summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNamyoon Woo <namyoon@chromium.org>2020-01-21 14:59:09 -0800
committerCommit Bot <commit-bot@chromium.org>2020-01-22 20:55:27 +0000
commit88549e6d2bf0f951d58b9a714033a08a72372df3 (patch)
tree624f52fce332b944ad963f316cd3766d8724c433
parent29dcf53164fa4b003414ab666b81286f4fbdf058 (diff)
downloadchrome-ec-stabilize-quickfix-12871.27.B-cr50_stab.tar.gz
This patch reduces redundant condition checking in connecting or disconnecting UART TX. BUG=none BRANCH=cr50 TEST=manually checked ccd state with/without servo connection and/or ccd connection. [AFTER] > ccdstate AP: on AP UART: on EC: on Rdd: connected Servo: connected CCD EXT: enabled State flags: UARTAP UARTEC CCD ports blocked: (none) > ccdstate AP: on AP UART: on EC: on Rdd: disconnected Servo: connected CCD EXT: disabled State flags: CCD ports blocked: (none) > ccdstate AP: on AP UART: on EC: on Rdd: connected Servo: undetectable CCD EXT: enabled State flags: UARTAP+TX UARTEC+TX I2C SPI CCD ports blocked: (none) > ccdstate AP: off AP UART: off EC: on Rdd: connected Servo: undetectable CCD EXT: enabled State flags: UARTEC+TX I2C SPI CCD ports blocked: (none) > ccdstate AP: on AP UART: on EC: on Rdd: connected Servo: disconnected CCD EXT: enabled State flags: UARTAP+TX I2C SPI CCD ports blocked: EC > ccdstate AP: on AP UART: on EC: on Rdd: connected Servo: disconnected CCD EXT: enabled State flags: I2C SPI CCD ports blocked: AP EC > ccdstate AP: on AP UART: on EC: on Rdd: connected Servo: ignored CCD EXT: enabled State flags: UARTAP+TX UARTEC+TX I2C SPI CCD ports blocked: IGNORE_SERVO WARNING: enabling UART while servo is connected may damage hardware Change-Id: Icea2978b15e15bbf7cea8e48fd2bf4fdecc78f46 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2013823 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
-rw-r--r--board/cr50/rdd.c50
-rw-r--r--chip/g/uartn.h6
2 files changed, 11 insertions, 45 deletions
diff --git a/board/cr50/rdd.c b/board/cr50/rdd.c
index 2d1403ec02..21d1357df8 100644
--- a/board/cr50/rdd.c
+++ b/board/cr50/rdd.c
@@ -78,60 +78,32 @@ int uart_tx_is_connected(int uart)
return !uart_bitbang_is_enabled() && GREAD(PINMUX, DIOB5_SEL);
}
-/**
- * Connect the UART pin to the given signal
- *
- * @param uart the uart peripheral number
- * @param signal the pinmux selector value for the gpio or peripheral
- * function. 0 to disable the output.
- */
-static void uart_select_tx(int uart, int signal)
+static void uartn_tx_connect(int uart)
{
+ /* Connect the TX pin to UART peripheral */
if (uart == UART_AP) {
- GWRITE(PINMUX, DIOA7_SEL, signal);
+ GWRITE(PINMUX, DIOA7_SEL, GC_PINMUX_UART1_TX_SEL);
} else {
- GWRITE(PINMUX, DIOB5_SEL, signal);
+ GWRITE(PINMUX, DIOB5_SEL, GC_PINMUX_UART2_TX_SEL);
/* Remove the pulldown when we are driving the signal */
- GWRITE_FIELD(PINMUX, DIOB5_CTL, PD, signal ? 0 : 1);
+ GWRITE_FIELD(PINMUX, DIOB5_CTL, PD, 0);
}
}
-void uartn_tx_connect(int uart)
+static void uartn_tx_disconnect(int uart)
{
- /*
- * Don't drive TX unless the debug cable is connected (we have
- * something to transmit) and servo is disconnected (we won't be
- * drive-fighting with servo).
- */
- if (servo_is_connected() || !ccd_ext_is_enabled())
- return;
-
+ /* Disconnect the TX pin from UART peripheral */
if (uart == UART_AP) {
- if (!ccd_is_cap_enabled(CCD_CAP_GSC_TX_AP_RX))
- return;
-
- if (!ap_uart_is_on())
- return;
-
- uart_select_tx(UART_AP, GC_PINMUX_UART1_TX_SEL);
+ GWRITE(PINMUX, DIOA7_SEL, 0);
} else {
- if (!ccd_is_cap_enabled(CCD_CAP_GSC_TX_EC_RX))
- return;
+ GWRITE(PINMUX, DIOB5_SEL, 0);
- if (!ec_is_on())
- return;
-
- uart_select_tx(UART_EC, GC_PINMUX_UART2_TX_SEL);
+ /* Set up the pulldown */
+ GWRITE_FIELD(PINMUX, DIOB5_CTL, PD, 1);
}
}
-void uartn_tx_disconnect(int uart)
-{
- /* Disconnect the TX pin from UART peripheral */
- uart_select_tx(uart, 0);
-}
-
/*
* Flags for the current CCD device state. This is used for determining what
* hardware devices we've enabled now, and which we want enabled.
diff --git a/chip/g/uartn.h b/chip/g/uartn.h
index bfb7772518..e0d0c140b3 100644
--- a/chip/g/uartn.h
+++ b/chip/g/uartn.h
@@ -82,12 +82,6 @@ void uartn_tx_stop(int uart);
*/
int uart_tx_is_connected(int uart);
-/* Connect TX pin for the UART */
-void uartn_tx_connect(int uart);
-
-/* Disconnect TX pin for the UART */
-void uartn_tx_disconnect(int uart);
-
/**
* Return non-zero if TX and RX are enabled for the UART.
*