Skip to content

Commit bfdb71e

Browse files
nordic-krchanangl
authored andcommitted
[nrf fromlist] 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. Upstream PR #: 84240 Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent f79188c commit bfdb71e

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

tests/drivers/uart/uart_mix_fifo_poll/boards/nrf54h20dk_nrf54h20_common.dtsi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ dut: &uart137 {
4949
pinctrl-names = "default", "sleep";
5050
current-speed = <115200>;
5151
hw-flow-control;
52+
zephyr,pm-device-runtime-auto;
5253
};
5354

5455
dut2: &uart120 {
@@ -57,6 +58,7 @@ dut2: &uart120 {
5758
pinctrl-names = "default", "sleep";
5859
current-speed = <115200>;
5960
hw-flow-control;
61+
zephyr,pm-device-runtime-auto;
6062
};
6163

6264
counter_dev: &timer137 {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_PM_DEVICE=y
2+
CONFIG_PM_DEVICE_RUNTIME=y

tests/drivers/uart/uart_mix_fifo_poll/src/main.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <zephyr/ztest.h>
1616
#include <zephyr/drivers/counter.h>
1717
#include <zephyr/random/random.h>
18+
#include <zephyr/pm/device_runtime.h>
1819
/* RX and TX pins have to be connected together*/
1920

2021
#if DT_NODE_EXISTS(DT_NODELABEL(dut))
@@ -329,6 +330,22 @@ ZTEST(uart_mix_fifo_poll, test_mixed_uart_access)
329330
.flags = 0
330331
};
331332

333+
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
334+
if (async) {
335+
#if DT_NODE_EXISTS(DT_NODELABEL(uart120)) && DT_NODE_HAS_STATUS(DT_NODELABEL(uart120), okay)
336+
if (uart_dev == DEVICE_DT_GET(DT_NODELABEL(uart120))) {
337+
ztest_test_skip();
338+
}
339+
#endif
340+
} else {
341+
/* If only polling API is available then UART device is initially
342+
* suspended which means that RX is disabled and poll_in won't work.
343+
* Device must be explicitly enabled.
344+
*/
345+
pm_device_runtime_get(uart_dev);
346+
}
347+
}
348+
332349
/* Setup counter which will periodically enable/disable UART RX,
333350
* Disabling RX should lead to flow control being activated.
334351
*/
@@ -388,6 +405,10 @@ ZTEST(uart_mix_fifo_poll, test_mixed_uart_access)
388405

389406
err = counter_stop(counter_dev);
390407
zassert_true(err >= 0);
408+
409+
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME) && !async) {
410+
pm_device_runtime_put(uart_dev);
411+
}
391412
}
392413

393414
void *uart_mix_setup(void)

0 commit comments

Comments
 (0)