Browse Source

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 <krzysztof.chruscinski@nordicsemi.no>
(cherry picked from commit 13ed9e4210)
backport-81533-to-v4.0-branch
Krzysztof Chruściński 8 months ago committed by github-actions[bot]
parent
commit
2313be11a7
  1. 29
      drivers/serial/uart_nrfx_uarte.c

29
drivers/serial/uart_nrfx_uarte.c

@ -353,16 +353,16 @@ static void uarte_nrfx_isr_int(const void *arg) @@ -353,16 +353,16 @@ static void uarte_nrfx_isr_int(const void *arg)
if (txstopped && (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME) || LOW_POWER_ENABLED(config))) {
unsigned int key = irq_lock();
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME) &&
(data->flags & UARTE_FLAG_POLL_OUT)) {
data->flags &= ~UARTE_FLAG_POLL_OUT;
pm_device_runtime_put(dev);
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
if (data->flags & UARTE_FLAG_POLL_OUT) {
data->flags &= ~UARTE_FLAG_POLL_OUT;
pm_device_runtime_put_async(dev, K_NO_WAIT);
}
} else {
nrf_uarte_disable(uarte);
}
#ifdef UARTE_INTERRUPT_DRIVEN
if (!data->int_driven || data->int_driven->fifo_fill_lock == 0)
if (!data->int_driven)
#endif
{
nrf_uarte_int_disable(uarte, NRF_UARTE_INT_TXSTOPPED_MASK);
@ -378,16 +378,20 @@ static void uarte_nrfx_isr_int(const void *arg) @@ -378,16 +378,20 @@ static void uarte_nrfx_isr_int(const void *arg)
if (txstopped) {
data->int_driven->fifo_fill_lock = 0;
if (!data->int_driven->tx_irq_enabled) {
nrf_uarte_int_disable(uarte, NRF_UARTE_INT_TXSTOPPED_MASK);
}
if (data->int_driven->disable_tx_irq) {
nrf_uarte_int_disable(uarte,
NRF_UARTE_INT_TXSTOPPED_MASK);
data->int_driven->disable_tx_irq = false;
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
pm_device_runtime_put_async(dev, K_NO_WAIT);
}
return;
}
}
if (nrf_uarte_event_check(uarte, NRF_UARTE_EVENT_ERROR)) {
nrf_uarte_event_clear(uarte, NRF_UARTE_EVENT_ERROR);
}
@ -1892,6 +1896,11 @@ static void uarte_nrfx_irq_tx_enable(const struct device *dev) @@ -1892,6 +1896,11 @@ static void uarte_nrfx_irq_tx_enable(const struct device *dev)
{
NRF_UARTE_Type *uarte = get_uarte_instance(dev);
struct uarte_nrfx_data *data = dev->data;
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
pm_device_runtime_get(dev);
}
unsigned int key = irq_lock();
data->int_driven->disable_tx_irq = false;

Loading…
Cancel
Save