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

[Backport v3.7.99-ncs1-branch] drivers: serial: nrfx_uarte: Legacy shim rework to support nrf54x and runtime device PM #2175

Merged
merged 23 commits into from
Oct 28, 2024

Conversation

NordicBuilder
Copy link
Contributor

Backport 055d020~23..055d020 from #2146.

… structure

Split async control block structure into tx and rx structures.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 701beec)
(cherry picked from commit a010c20)
…operty

Add property which indicates that UARTE support frame timeout
feature. Property is added to nrf54h20, nrf9280, nrf54l20 and
nrf54l15.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit ac1cc17)
(cherry picked from commit 8b426b8)
…_MANAGEMENT

This is a leftover from pre-pinctrl era and no longer makes sense.
Driver always manages gpio through pinctrl.

Support removed from uart and uarte shims.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 76db5b2)
(cherry picked from commit eb62dd5)
…O_MANAGEMENT

Remove Kconfig option that no longer has any use after pinctrl
driver is introduced.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit cae53af)
(cherry picked from commit 42fad2c)
…MENT removal

Add note that those Kconfig options were removed from Nordic UART driver
configuration.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 3a4c5a9)
(cherry picked from commit 49bbbea)
Use nrfx_gppi as abstraction over (D)PPI.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 2668476)
(cherry picked from commit 6bd3a7e)
…struct pointer

Refactor RX asynchronous API function to use a pointer to the RX
async data structure instead of top level data structure pointer.
It improves readability with more concise code.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit d82808e)
(cherry picked from commit d62a69c)
…new features

Rework driver to support new way of asynchronous RX handling.
Previously RX was handled in two modes: using RXDRDY interrupt for byte
counting or TIMER + PPI. Both modes had flaws. RXDRDY interrupt mode
could miscalculated amount of received bytes when interrupt was not
handled on time. Data was not lost but was not reported on time that
could lead to issues. PPI+TIMER mode requires additional resources
thus it was not the default mode. Often user was not aware of that
option and was expiriencing driver RX faults.

New RX mode is switching buffers when there is new data (RXDRDY event
not set for given amount of time). It does not require additional
resources to get precise byte counting. Additionally, this is in line
with new UARTE feature (RX frame timeout) which is present in nRF54X
devices. The behavior of the driver is the same for legacy devices
and new one. For legacy devices k_timer periodic interrupts are used
to check if there are any new bytes and it is not needed when RX frame
timeout is present.

Improved RX mode is enabled by default
(CONFIG_UART_NRFX_UARTE_ENHANCED_RX=y) but legacy modes are still
available though not recommended to be used.

Note that new RX mode (CONFIG_UART_NRFX_UARTE_ENHANCED_RX=y) behaves
a bit different because timeout always triggers switch of buffers
which means that there will be no UART_RX_RDY events with non-zero
offset. It also means that every UART_RX_RDY will be followed by
UART_RX_BUF_RELEASED.

After rework, driver is recommended to be used for all platforms as it
performs much better and takes much less code than the second UART shim
available for Nordic devices.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 399a235)
(cherry picked from commit 22c4f08)
…eout

Frame timeout is a hardware feature present in newer versions
of UARTE (e.g. in NRF54X platforms) for detecting idle state
on RX line and ending RX after configurable timeout.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 1f96e62)
(cherry picked from commit f80b608)
…ache

Add support for DMM which manages cache and dedicated memory spaces.
Added support for data cache for buffers which are not DMM managed.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 9517106)
(cherry picked from commit 76495df)
…karound

Add configurable magic byte instead of fixed 0xAA. In some cases, it
is known that certain bytes are less likely in the transmission and
picking specific magic byte may reduce probability of failure of
detection of the correct amount of flushed data.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 7735302)
(cherry picked from commit f6115ff)
…TE register

On uart120 BAUDRATE register is not retained when ENABLE=0 and
because of that BAUDRATE must be set after enabling. Add workaround
to the driver.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 5eaafba)
(cherry picked from commit c541fa9)
Add lock to fix race when uart_rx_disable is interrupted by RXTO
event which lead to driver state corruption.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 317de0c)
(cherry picked from commit 75263f7)
Add include path to nordic/soc/nordic/common where some internal
headers for nordic devices are kept (e.g. dmm.h).

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit ec224fd)
(cherry picked from commit 5d0ed65)
…igurable

One of the test case is performing long transfers using 1k buffers.
For some targets there may be not enough RAM to perform such
transfers. Make long buffer length configurable.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit d612982)
(cherry picked from commit 8f950bc)
…r for nrf54h20

nrf54h20dk_nrf54h20_cpurad by default has less RAM dedicated for
DMA transfers and default 1k buffer cannot be used for
uart_async_long_buf case. Use custom value.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit d480093)
(cherry picked from commit e6f1bb5)
…cpuapp overlay

Add overlay for nrf54l15dk/nrf54l15/cpuapp target.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit a04c1db)
(cherry picked from commit c7124d9)
A code ifdefed by UARTE_BAUDRATE_RETENTION_WORKAROUND was missing a
closing bracket. It was missed because CI did not compile any target
that is applying this workaround and enables code compilation.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit a98bde9)
(cherry picked from commit 9a0c387)
…m a structure

Remove aborted flag from uarte_async_rx structure. Flag is not
used.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit cfc87da)
(cherry picked from commit e209799)
Add runtime PM to the driver. When asynchronous or interrupt
driven API is used, there are 3 independent paths for enabling
the device: RX, TX and TX poll_out. TX poll_out requires special
handling because number of poll_out calls does not need to much
number of TXSTOPPED interrupts. To handle that special flag is
added. For standard RX and TX is simpler.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 3ce19da)
(cherry picked from commit 922989e)
…workaround

Improved a workaround. When FIFO is not empty then FLUSHRX
task will generate RXSTARTED event to indicated that DMA transfer
was started. This property can be used to detect when FIFO was
not empty and workaroud a HW bug where RX.AMOUNT register is not
updated after flushing empty FIFO.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 68903ca)
(cherry picked from commit 8171692)
So far new platforms did not use legacy shim but it shall
be now a default uart shim for all platforms.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 7e94fca)
(cherry picked from commit c3fd7fd)
Optimize function which enables UARTE peripheral. It is called
only when interrupts are locked so data->flags does not require
atomic operation. Use standard logical operations so save few
bytes.

Simplify uarte_disable_locked.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 9ccaf9b)
(cherry picked from commit 055d020)
@rlubos rlubos merged commit 7d77811 into v3.7.99-ncs1-branch Oct 28, 2024
21 checks passed
@rlubos rlubos deleted the backport-2146-to-v3.7.99-ncs1-branch branch October 30, 2024 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants