Skip to content

Commit e0f5241

Browse files
nordic-krchkartben
authored andcommitted
drivers: serial: nrfx_uarte: Fix use of PM_DEVICE_ISR_SAFE
PM_DEVICE_ISR_SAFE shall not be used when non-asynchronous API is used because RX is disabled in suspend action and that takes relatively long time. In case of PM_DEVICE_ISR_SAFE it is done with interrupts disabled. RX is not used at all if disable-rx property is set and in that case PM_DEVICE_ISR_SAFE can be used. Added macro which determines if ISR safe mode can be used. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
1 parent 66daaf6 commit e0f5241

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

drivers/serial/uart_nrfx_uarte.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,6 +2512,18 @@ static int uarte_instance_init(const struct device *dev,
25122512
: UART_CFG_FLOW_CTRL_NONE, \
25132513
}
25142514

2515+
/* Macro determines if PM actions are interrupt safe. They are in case of
2516+
* asynchronous API (except for instance in fast power domain) and non-asynchronous
2517+
* API if RX is disabled. Macro must resolve to a literal 1 or 0.
2518+
*/
2519+
#define UARTE_PM_ISR_SAFE(idx) \
2520+
COND_CODE_1(INSTANCE_IS_FAST_PD(_, /*empty*/, idx, _), \
2521+
(0), \
2522+
(COND_CODE_1(CONFIG_UART_##idx##_ASYNC, \
2523+
(PM_DEVICE_ISR_SAFE), \
2524+
(COND_CODE_1(UARTE_PROP(idx, disable_rx), \
2525+
(PM_DEVICE_ISR_SAFE), (0)))))) \
2526+
25152527
#define UART_NRF_UARTE_DEVICE(idx) \
25162528
NRF_DT_CHECK_NODE_HAS_PINCTRL_SLEEP(UARTE(idx)); \
25172529
UARTE_INT_DRIVEN(idx); \
@@ -2584,8 +2596,7 @@ static int uarte_instance_init(const struct device *dev,
25842596
} \
25852597
\
25862598
PM_DEVICE_DT_DEFINE(UARTE(idx), uarte_nrfx_pm_action, \
2587-
COND_CODE_1(INSTANCE_IS_FAST_PD(_, /*empty*/, idx, _),\
2588-
(0), (PM_DEVICE_ISR_SAFE))); \
2599+
UARTE_PM_ISR_SAFE(idx)); \
25892600
\
25902601
DEVICE_DT_DEFINE(UARTE(idx), \
25912602
uarte_##idx##_init, \

0 commit comments

Comments
 (0)