Skip to content

Commit b783bc8

Browse files
xudongzhengkartben
authored andcommitted
drivers: serial: pl011: fix missing TX callback with FIFO enabled
When using the interrupt UART API, it is expected that the driver will call the callback function repeatedly while TX interrupt is enabled. However that is not necessarily the case with the FIFO is enabled. If the application calls uart_fifo_fill() each time with only one byte of data, the TX interrupt will never trigger. This is because the 1/8 TX interrupt trigger threshold is never reached. For this reason, the callback function should be called multiple times from software as needed. Fixes #85479 Signed-off-by: Xudong Zheng <7pkvm5aw@slicealias.com>
1 parent bddaff1 commit b783bc8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/serial/uart_pl011.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ static void pl011_irq_tx_enable(const struct device *dev)
343343

344344
get_uart(dev)->imsc |= PL011_IMSC_TXIM;
345345
if (data->sw_call_txdrdy) {
346+
data->sw_call_txdrdy = false;
347+
346348
/* Verify if the callback has been registered */
347349
if (data->irq_cb) {
348350
/*
@@ -357,14 +359,18 @@ static void pl011_irq_tx_enable(const struct device *dev)
357359
* [1]: PrimeCell UART (PL011) Technical Reference Manual
358360
* functional-overview/interrupts
359361
*/
360-
data->irq_cb(dev, data->irq_cb_data);
362+
while (get_uart(dev)->imsc & PL011_IMSC_TXIM) {
363+
data->irq_cb(dev, data->irq_cb_data);
364+
}
361365
}
362-
data->sw_call_txdrdy = false;
363366
}
364367
}
365368

366369
static void pl011_irq_tx_disable(const struct device *dev)
367370
{
371+
struct pl011_data *data = dev->data;
372+
373+
data->sw_call_txdrdy = true;
368374
get_uart(dev)->imsc &= ~PL011_IMSC_TXIM;
369375
}
370376

0 commit comments

Comments
 (0)