serial/uart_16550: Wait before setting Line Control Register (Synopsys DesignWare 8250) #37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Some UART Controllers (Synopsys DesignWare 8250) will trigger spurious interrupts when the Line Control Register (LCR) is set while the UART is busy. This patch provides the option (16550_WAIT_LCR) to wait for UART until it's not busy, before setting the LCR. (16550_WAIT_LCR is disabled by default)
This patch fixes the spurious UART interrupts for the upcoming port of NuttX to StarFive JH7110 SoC (with Synopsys DesignWare 8250 UART). The patch is explained here
Modified Files
drivers/serial/uart_16550.c
: If 16550_WAIT_LCR is enabled, wait until UART is not busy before setting LCRinclude/nuttx/serial/uart_16550.h
: Define the UART Status Register (USR) for checking if UART is busydrivers/serial/Kconfig-16550
: Added option 16550_WAIT_LCR to 16550 UART Config, disabled by defaultImpact
After applying this patch and enabling 16550_WAIT_LCR, StarFive JH7110 will boot correctly to NSH. (Instead of getting stuck servicing too many spurious UART interrupts)
No impact on existing code, since 16550_WAIT_LCR is disabled by default.
Testing
We tested this patch with the upcoming port of NuttX for JH7110. For Regression Testing, we tested with QEMU RISC-V (rv-virt:knsh64).
JH7110 Test
When 16550_WAIT_LCR is Disabled (default), JH7110 will fire spurious UART interrupts and fail to start NSH Shell (because it's too busy servicing interrupts):
When 16550_WAIT_LCR is Enabled, JH7110 will start NSH Shell correctly:
Regression Test
We tested with QEMU RISC-V (rv-virt:knsh64):
NuttX boots correctly with the default setting of 16550_WAIT_LCR (disabled):