Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: serial: nrfx_uarte: Add support for higher baudrates #84485

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

nordic-krch
Copy link
Contributor

Fast instances (uart00 in nRF54Lx and uart120 in nRF54H20) support >1M baudates. Extend driver to support that.

Updated overlay for nrf54h20dk in uart_async_api test to use 4Mbaud for uart120 instance. This shown an issue in the test which was not ready for higher baudrates. Test was tweaked to adjust its timings based on used baudrate.

Add faster baudrates (2M, 4M and 8M).

Signed-off-by: Krzysztof Chruściński <[email protected]>
@zephyrbot zephyrbot added the area: UART Universal Asynchronous Receiver-Transmitter label Jan 24, 2025
@zephyrbot zephyrbot added the platform: nRF Nordic nRFx label Jan 24, 2025
nika-nordic
nika-nordic previously approved these changes Jan 24, 2025
@@ -43,3 +43,6 @@ properties:
- 460800
- 921600
- 1000000
- 2000000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we introduce nordic,nrf-uart-fast.yaml or similar to differentiate between devices that have >1Mbaud capabilities? Take a look at this PR for reference: #79330

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Driver compilation will fail if not supported current-speed is set for an instance. Alternative approach would be to use separate compatible but this will trigger more work as currently current-speed is an enum in nordic,nrf-uart-common.yaml and that would need to be extracted because enums in bindings cannot be overwritten. Additionally, support for two compatibles would need be added in places like:

#elif DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_uarte) || defined(CONFIG_NRFX_UARTE)
. I'm not sure what we gain apart from error detected in DT vs error detected during compilation.

Copy link
Collaborator

@bjarki-andreasen bjarki-andreasen Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we where completely true to the devicetree, if its the "same" underlying hardware block, and "fast" just means, "supports higher bitrate", we would add a flag/boolean to the common binding like:

uart@xxx {
        compatible = "nordic,nrf-uarte"; /* same hardware, targets same driver */
        fast; /* <this instance is fast */
};

the current-speed enum should contain a superset of all supported speeds, for all variations, including fast, the driver then validates current-speed based on if the fast; flag exists. DT really is not there to validate stuff like current-speed, current-speed is a zephyr-ism we use to set initial configs, DT enums are just a "base filter"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider how many nordic,nrf-comp variations there would be if we had one compat if it supported low power mode, one if it supported some specific subset of voltage references etc. pure chaos :)

kl-cruz
kl-cruz previously approved these changes Jan 24, 2025
Rename UARTE_ANY_FAST to UARTE_ANY_FAST_PD. There are 2 types of
'fast' UARTE instances. In nrf54h20 instance uart120 is in fast
power domain that requires additional power and clock management
of that domain. In nrf54lx fast uart00 instance does not require
that. Add _PD to indicate fast power domain.

Signed-off-by: Krzysztof Chruściński <[email protected]>
nrf54x devices have UARTE instance capable of using baudrate higher
than 1M. Higher baudrates does not have predefined values for
BAUDRATE register. A formula can be used to calculate BAUDRATE
value that shall be used for desired baudrate. Add UARTE_ANY_HIGH_SPEED
macro which is set when high speed is enabled (uart00 in nrf54lx or
uart120 in nrf54h20). For high speed instance use formula for getting
value that shall be written to BAUDRATE register.

When runtime configuration is not used then same formula is used to
calculate fixed BAUDRATE value.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Fast instance in nrf54h (uart120) can generate a spurious RXTO event
some time after RXTO event that indicates that RX path is disabled.
The time when event is generated depends on baudrate and when slower
baudrates are used peripheral is disabled on time to not notice it
in the test but with higher baudates issue become visible. In order
to avoid spurious interrupt, RXTO interrupt is disabled during RXTO
event handling and enabled when RX is enabled. This workaround is
applied only for fast instance to avoid unnecessary register
accesses for slower instances.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Test was staring a TX transfer and aborting it after 300 us from
the timer handler. Test was assuming that ongoing transfer will
not finish in those 300 us. This might not be true for higher
baudrates. Instead of using fixed timeout, a value is calculated
from the baudrate and targets to abort the transfer after approx.
20 bytes of 95 byte long transfer.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Use high baudrate when testing uart120 on nrf54h20dk/nrf54h20/cpuapp.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: UART Universal Asynchronous Receiver-Transmitter platform: nRF Nordic nRFx
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants