tests: drivers: uart: uart_mix_fifo_poll: Enable device PM

uart120 requires device runtime to be enable. Enable it for nrf54h20dk.

When device runtime PM is used for interrupt driven and polling API
then UART device is initially suspended. It means that RX is disabled.
In order to enable RX device must be explicitly resumed using PM API.

Test is enabling UART RX (uart_rx_enable) from counter callback
(interrupt handler context). For fast instance on nrf54h20dk (uart120)
it is not allowed because PM resume can only be called from the thread
context. Because of that, test is skipped for uart120 and asynchronous
API.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruściński 2025-01-20 14:27:53 +01:00 committed by Benjamin Cabé
parent 1ee434a6c2
commit cc12f655c9
3 changed files with 25 additions and 0 deletions

View file

@ -49,6 +49,7 @@ dut: &uart137 {
pinctrl-names = "default", "sleep";
current-speed = <115200>;
hw-flow-control;
zephyr,pm-device-runtime-auto;
};
dut2: &uart120 {
@ -57,6 +58,7 @@ dut2: &uart120 {
pinctrl-names = "default", "sleep";
current-speed = <115200>;
hw-flow-control;
zephyr,pm-device-runtime-auto;
};
counter_dev: &timer137 {

View file

@ -0,0 +1,2 @@
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y

View file

@ -15,6 +15,7 @@
#include <zephyr/ztest.h>
#include <zephyr/drivers/counter.h>
#include <zephyr/random/random.h>
#include <zephyr/pm/device_runtime.h>
/* RX and TX pins have to be connected together*/
#if DT_NODE_EXISTS(DT_NODELABEL(dut))
@ -329,6 +330,22 @@ ZTEST(uart_mix_fifo_poll, test_mixed_uart_access)
.flags = 0
};
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
if (async) {
#if DT_NODE_EXISTS(DT_NODELABEL(uart120)) && DT_NODE_HAS_STATUS(DT_NODELABEL(uart120), okay)
if (uart_dev == DEVICE_DT_GET(DT_NODELABEL(uart120))) {
ztest_test_skip();
}
#endif
} else {
/* If only polling API is available then UART device is initially
* suspended which means that RX is disabled and poll_in won't work.
* Device must be explicitly enabled.
*/
pm_device_runtime_get(uart_dev);
}
}
/* Setup counter which will periodically enable/disable UART RX,
* Disabling RX should lead to flow control being activated.
*/
@ -388,6 +405,10 @@ ZTEST(uart_mix_fifo_poll, test_mixed_uart_access)
err = counter_stop(counter_dev);
zassert_true(err >= 0);
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME) && !async) {
pm_device_runtime_put(uart_dev);
}
}
void *uart_mix_setup(void)