Skip to content

Commit b67efcc

Browse files
committed
[nrf fromtree] drivers: serial: nrfx_uarte: Fix runtime PM for interrupt driven API
TX part of interrupt driven API was not calling PM device runtime API. Additionally, when txstopped occurred after poll out it was not handled correctly. Signed-off-by: Krzysztof Chruściński <[email protected]> (cherry picked from commit 13ed9e4)
1 parent e756c63 commit b67efcc

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

drivers/serial/uart_nrfx_uarte.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,16 @@ static void uarte_nrfx_isr_int(const void *arg)
353353
if (txstopped && (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME) || LOW_POWER_ENABLED(config))) {
354354
unsigned int key = irq_lock();
355355

356-
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME) &&
357-
(data->flags & UARTE_FLAG_POLL_OUT)) {
358-
data->flags &= ~UARTE_FLAG_POLL_OUT;
359-
pm_device_runtime_put(dev);
356+
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
357+
if (data->flags & UARTE_FLAG_POLL_OUT) {
358+
data->flags &= ~UARTE_FLAG_POLL_OUT;
359+
pm_device_runtime_put_async(dev, K_NO_WAIT);
360+
}
360361
} else {
361362
nrf_uarte_disable(uarte);
362363
}
363-
364364
#ifdef UARTE_INTERRUPT_DRIVEN
365-
if (!data->int_driven || data->int_driven->fifo_fill_lock == 0)
365+
if (!data->int_driven)
366366
#endif
367367
{
368368
nrf_uarte_int_disable(uarte, NRF_UARTE_INT_TXSTOPPED_MASK);
@@ -378,16 +378,20 @@ static void uarte_nrfx_isr_int(const void *arg)
378378

379379
if (txstopped) {
380380
data->int_driven->fifo_fill_lock = 0;
381+
if (!data->int_driven->tx_irq_enabled) {
382+
383+
nrf_uarte_int_disable(uarte, NRF_UARTE_INT_TXSTOPPED_MASK);
384+
}
385+
381386
if (data->int_driven->disable_tx_irq) {
382-
nrf_uarte_int_disable(uarte,
383-
NRF_UARTE_INT_TXSTOPPED_MASK);
384387
data->int_driven->disable_tx_irq = false;
388+
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
389+
pm_device_runtime_put_async(dev, K_NO_WAIT);
390+
}
385391
return;
386392
}
387-
388393
}
389394

390-
391395
if (nrf_uarte_event_check(uarte, NRF_UARTE_EVENT_ERROR)) {
392396
nrf_uarte_event_clear(uarte, NRF_UARTE_EVENT_ERROR);
393397
}
@@ -1900,6 +1904,11 @@ static void uarte_nrfx_irq_tx_enable(const struct device *dev)
19001904
{
19011905
NRF_UARTE_Type *uarte = get_uarte_instance(dev);
19021906
struct uarte_nrfx_data *data = dev->data;
1907+
1908+
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
1909+
pm_device_runtime_get(dev);
1910+
}
1911+
19031912
unsigned int key = irq_lock();
19041913

19051914
data->int_driven->disable_tx_irq = false;

0 commit comments

Comments
 (0)