Skip to content

Commit 2742e46

Browse files
nordic-krchrlubos
authored andcommitted
[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 893c333 commit 2742e46

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
@@ -57,6 +57,11 @@ config UART_ASYNC_TX_CACHE_SIZE
5757
in RAM, because EasyDMA in UARTE peripherals can only transfer data
5858
from RAM.
5959

60+
config UART_NRFX_UARTE_SPURIOUS_RXTO_WORKAROUND
61+
bool
62+
help
63+
Apply workaround for spurious RXTO during restart.
64+
6065
if HAS_HW_NRF_UART0 || HAS_HW_NRF_UARTE0
6166
nrfx_uart_num = 0
6267
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.
@@ -2555,6 +2569,9 @@ static int uarte_instance_init(const struct device *dev,
25552569
(!IS_ENABLED(CONFIG_HAS_NORDIC_DMM) ? 0 : \
25562570
(UARTE_IS_CACHEABLE(idx) ? \
25572571
UARTE_CFG_FLAG_CACHEABLE : 0)) | \
2572+
(IS_ENABLED(CONFIG_UART_NRFX_UARTE_SPURIOUS_RXTO_WORKAROUND) && \
2573+
INSTANCE_IS_HIGH_SPEED(_, /*empty*/, idx, _) ? \
2574+
UARTE_CFG_FLAG_SPURIOUS_RXTO : 0) | \
25582575
USE_LOW_POWER(idx), \
25592576
UARTE_DISABLE_RX_INIT(UARTE(idx)), \
25602577
.poll_out_byte = &uarte##idx##_poll_out_byte, \

0 commit comments

Comments
 (0)