Skip to content

Commit 0da6f1e

Browse files
committed
[nrf fromlist] drivers: serial: nrfx_uarte: Workaround for spurious RXTO during restart
Some SoCs generates unexpected RXTO event during restart. Restart happens when ENDRX_STARTRX short is enabled and STOPRX is triggered (via short or by CPU). STOPRX starts closing procedure and ENDRX event is generated at some point which triggers STARTRX and closing procedure is interrupted. RXTO should not be triggered in that case. Due to internal timings some SoC on fast UARTE instance will trigger RXTO followed by RXSTARTED. This RXTO event shall be cleared as receiver is actually restarted and not stopped. Affected SoC is not in tree so Kconfig is added which enables the workaround. Upstream PR #: 88935 Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 746a8ff commit 0da6f1e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

drivers/serial/Kconfig.nrfx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ config UART_ASYNC_TX_CACHE_SIZE
6666
config UART_NRFX_UARTE_DIRECT_ISR
6767
bool "Use direct ISR"
6868

69+
config UART_NRFX_UARTE_SPURIOUS_RXTO_WORKAROUND
70+
bool
71+
help
72+
Apply workaround for spurious RXTO during restart.
73+
6974
if HAS_HW_NRF_UART0 || HAS_HW_NRF_UARTE0
7075
nrfx_uart_num = 0
7176
rsource "Kconfig.nrfx_uart_instance"

drivers/serial/uart_nrfx_uarte.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ struct uarte_nrfx_data {
266266
/* If enabled then UARTE peripheral is using memory which is cacheable. */
267267
#define UARTE_CFG_FLAG_CACHEABLE BIT(3)
268268

269+
/* Indicates that workaround for spurious RXTO during restart shall be applied. */
270+
#define UARTE_CFG_FLAG_SPURIOUS_RXTO BIT(3)
271+
269272
/* Formula for getting the baudrate settings is following:
270273
* 2^12 * (2^20 / (f_PCLK / desired_baudrate)) where f_PCLK is a frequency that
271274
* drives the UARTE.
@@ -1546,6 +1549,17 @@ static void endrx_isr(const struct device *dev)
15461549
unsigned int key = irq_lock();
15471550

15481551
if (async_rx->buf) {
1552+
1553+
#if CONFIG_UART_NRFX_UARTE_SPURIOUS_RXTO_WORKAROUND
1554+
/* Check for spurious RXTO event. */
1555+
const struct uarte_nrfx_config *config = dev->config;
1556+
1557+
if ((config->flags & UARTE_CFG_FLAG_SPURIOUS_RXTO) &&
1558+
nrf_uarte_event_check(uarte, NRF_UARTE_EVENT_RXTO)) {
1559+
nrf_uarte_event_clear(uarte, NRF_UARTE_EVENT_RXTO);
1560+
}
1561+
#endif
1562+
15491563
/* Check is based on assumption that ISR handler handles
15501564
* ENDRX before RXSTARTED so if short was set on time, RXSTARTED
15511565
* event will be set.
@@ -2586,6 +2600,9 @@ static int uarte_instance_init(const struct device *dev,
25862600
(!IS_ENABLED(CONFIG_HAS_NORDIC_DMM) ? 0 : \
25872601
(UARTE_IS_CACHEABLE(idx) ? \
25882602
UARTE_CFG_FLAG_CACHEABLE : 0)) | \
2603+
(IS_ENABLED(CONFIG_UART_NRFX_UARTE_SPURIOUS_RXTO_WORKAROUND) && \
2604+
INSTANCE_IS_HIGH_SPEED(_, /*empty*/, idx, _) ? \
2605+
UARTE_CFG_FLAG_SPURIOUS_RXTO : 0) | \
25892606
USE_LOW_POWER(idx), \
25902607
UARTE_DISABLE_RX_INIT(UARTE(idx)), \
25912608
.poll_out_byte = &uarte##idx##_poll_out_byte, \

0 commit comments

Comments
 (0)