Commit 2313be11 authored by Krzysztof Chruściński's avatar Krzysztof Chruściński Committed by github-actions[bot]
Browse files

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: default avatarKrzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
(cherry picked from commit 13ed9e42)
parent 2f0e67fe
Loading
Loading
Loading
Loading
+18 −9
Changes for drivers/serial/uart_nrfx_uarte.c: 18 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -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)) {
		if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
			if (data->flags & UARTE_FLAG_POLL_OUT) {
				data->flags &= ~UARTE_FLAG_POLL_OUT;
			pm_device_runtime_put(dev);
				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)

	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)
{
	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;