Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c3dc1f0

Browse files
committedFeb 17, 2025·
[nrf fromlist] drivers: serial: nrfx_uarte: Fix low power mode when RX is disabled
Macros for determining is low power mode shall be used where incorrect. UARTE_ANY_LOW_POWER was taking into account only instances which had CONFIG_UART_x_NRF_ASYNC_LOW_POWER enabled. There are also instances with property which also can use low power mode. Created IS_LOW_POWER_INST macro which correctly determines if instance is using low power mode. Upstream PR #: 85370 Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
1 parent bf64a31 commit c3dc1f0

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed
 

‎drivers/serial/uart_nrfx_uarte.c

+12-15
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,16 @@ LOG_MODULE_REGISTER(uart_nrfx_uarte, CONFIG_UART_LOG_LEVEL);
101101
#define UARTE_ANY_CACHE 1
102102
#endif
103103

104-
#define IS_LOW_POWER(unused, prefix, i, _) IS_ENABLED(CONFIG_UART_##prefix##i##_NRF_ASYNC_LOW_POWER)
104+
/* Determine if instance uses low power mode (alternative to PM). It can be used
105+
* if asynchronous API is used or when RX is not used in polling or interrupt driven mode.
106+
*/
107+
#define IS_LOW_POWER_INST(idx) \
108+
COND_CODE_1(CONFIG_PM_DEVICE, (0), \
109+
(COND_CODE_1(CONFIG_UART_##idx##_ASYNC, \
110+
(IS_ENABLED(CONFIG_UART_##idx##_NRF_ASYNC_LOW_POWER)), \
111+
(UARTE_PROP(idx, disable_rx)))))
112+
113+
#define IS_LOW_POWER(unused, prefix, i, _) IS_LOW_POWER_INST(prefix##i)
105114

106115
#if UARTE_FOR_EACH_INSTANCE(IS_LOW_POWER, (||), (0))
107116
#define UARTE_ANY_LOW_POWER 1
@@ -280,9 +289,7 @@ struct uarte_nrfx_data {
280289
(baudrate) == 1000000 ? NRF_UARTE_BAUDRATE_1000000 : 0)
281290

282291
#define LOW_POWER_ENABLED(_config) \
283-
(IS_ENABLED(UARTE_ANY_LOW_POWER) && \
284-
!IS_ENABLED(CONFIG_PM_DEVICE) && \
285-
(_config->flags & UARTE_CFG_FLAG_LOW_POWER))
292+
(IS_ENABLED(UARTE_ANY_LOW_POWER) && (_config->flags & UARTE_CFG_FLAG_LOW_POWER))
286293

287294
/** @brief Check if device has PM that works in ISR safe mode.
288295
*
@@ -2398,16 +2405,6 @@ static int uarte_instance_init(const struct device *dev,
23982405
irq_enable(DT_IRQN(UARTE(idx))); \
23992406
} while (false)
24002407

2401-
/* Low power mode is used when disable_rx is not defined or in async mode if
2402-
* kconfig option is enabled.
2403-
*/
2404-
#define USE_LOW_POWER(idx) \
2405-
COND_CODE_1(CONFIG_PM_DEVICE, (0), \
2406-
(((!UARTE_PROP(idx, disable_rx) && \
2407-
COND_CODE_1(CONFIG_UART_##idx##_ASYNC, \
2408-
(!IS_ENABLED(CONFIG_UART_##idx##_NRF_ASYNC_LOW_POWER)),\
2409-
(1))) ? 0 : UARTE_CFG_FLAG_LOW_POWER)))
2410-
24112408
#define UARTE_DISABLE_RX_INIT(node_id) \
24122409
.disable_rx = DT_PROP(node_id, disable_rx)
24132410

@@ -2508,7 +2505,7 @@ static int uarte_instance_init(const struct device *dev,
25082505
(!IS_ENABLED(CONFIG_HAS_NORDIC_DMM) ? 0 : \
25092506
(UARTE_IS_CACHEABLE(idx) ? \
25102507
UARTE_CFG_FLAG_CACHEABLE : 0)) | \
2511-
USE_LOW_POWER(idx), \
2508+
(IS_LOW_POWER_INST(idx) ? UARTE_CFG_FLAG_LOW_POWER : 0),\
25122509
UARTE_DISABLE_RX_INIT(UARTE(idx)), \
25132510
.poll_out_byte = &uarte##idx##_poll_out_byte, \
25142511
.poll_in_byte = &uarte##idx##_poll_in_byte, \

0 commit comments

Comments
 (0)
Please sign in to comment.