Skip to content

Commit c08390d

Browse files
nordic-krchdkalowsk
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 <[email protected]> (cherry picked from commit e0f5241)
1 parent d4374ed commit c08390d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

drivers/serial/uart_nrfx_uarte.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2339,6 +2339,18 @@ static int uarte_instance_init(const struct device *dev,
23392339
: UART_CFG_FLOW_CTRL_NONE, \
23402340
}
23412341

2342+
/* Macro determines if PM actions are interrupt safe. They are in case of
2343+
* asynchronous API (except for instance in fast power domain) and non-asynchronous
2344+
* API if RX is disabled. Macro must resolve to a literal 1 or 0.
2345+
*/
2346+
#define UARTE_PM_ISR_SAFE(idx) \
2347+
COND_CODE_1(INSTANCE_IS_FAST_PD(_, /*empty*/, idx, _), \
2348+
(0), \
2349+
(COND_CODE_1(CONFIG_UART_##idx##_ASYNC, \
2350+
(PM_DEVICE_ISR_SAFE), \
2351+
(COND_CODE_1(UARTE_PROP(idx, disable_rx), \
2352+
(PM_DEVICE_ISR_SAFE), (0)))))) \
2353+
23422354
#define UART_NRF_UARTE_DEVICE(idx) \
23432355
NRF_DT_CHECK_NODE_HAS_PINCTRL_SLEEP(UARTE(idx)); \
23442356
UARTE_INT_DRIVEN(idx); \
@@ -2405,7 +2417,7 @@ static int uarte_instance_init(const struct device *dev,
24052417
} \
24062418
\
24072419
PM_DEVICE_DT_DEFINE(UARTE(idx), uarte_nrfx_pm_action, \
2408-
PM_DEVICE_ISR_SAFE); \
2420+
UARTE_PM_ISR_SAFE(idx)); \
24092421
\
24102422
DEVICE_DT_DEFINE(UARTE(idx), \
24112423
uarte_##idx##_init, \

0 commit comments

Comments
 (0)