-
Notifications
You must be signed in to change notification settings - Fork 605
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: Rework nrfx_uarte shim to support nrf54x platforms #2041
Open
nordic-krch
wants to merge
17
commits into
nrfconnect:main
Choose a base branch
from
nordic-krch:ncs/uart_legacy_rework
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,170
−698
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NordicBuilder
requested review from
jaz1-nordic,
kl-cruz,
magp-nordic,
masz-nordic and
nika-nordic
September 24, 2024 08:36
… peripheral clock Some UARTE instances may be clocked at higher speeds than 16MHz, so the baudrate setting needs to be scaled accordingly. This patch parses the `clocks` property and obtains the clock-frequency property of the associated clock, assuming it is a fixed-clock. We should ideally have a proper clock control subsystem where frequency can be queried using an API, but we're far from there. Signed-off-by: Gerard Marull-Paretas <[email protected]> (cherry picked from commit 65b45e5)
…l configuration When runtime configuration is not enable then we can determine at compile time what are the hardware settings. Function which translates zephyr values to nRF register values is not needed as macros can do that at compile time. This optimization saves almost 400 bytes of code. Signed-off-by: Krzysztof Chruściński <[email protected]> (cherry picked from commit 78ba608)
Code size can significantly reduced (220 bytes per instance) if data structure (stored in RAM) is not initilized (can be moved to .bss). Data for asynchronous API had two fields which can easily be moved to the configuration structure (which is in ROM) because they do not change duing runtime. Signed-off-by: Krzysztof Chruściński <[email protected]> (cherry picked from commit 04a930f)
The initialization of the UARTE is attempting to handle potential improper handover from the bootloader. This handling is additional complexity which should be fixed in the bootloader or whatever component is failing to deinit the UART properly. This commit removes the handling of improper handover from the bootloader, while additionally clearing the ERROR flag when suspending the UARTE component. Signed-off-by: Bjarki Arge Andreasen <[email protected]> (cherry picked from commit 28b9f55)
… TX only mode When interrupt driven instance is using only TX then low power mode is automatically enabled and then TXSTOPPED interrupt is disabled in idle so uarte_nrfx_irq_tx_ready_complete() was returning wrong value. Adding a dedicate flag which holds information is user enabled TX interrupt. Signed-off-by: Krzysztof Chruściński <[email protected]> (cherry picked from commit 282bc78)
… data When rx_flush() was called with NULL buffer it was an indication to drop data from the FIFO. However, it is still important to get the correct amount of dropped data because when PPI+TIMER are used to count bytes those flushed bytes are also counted (because each byte generates RXDRDY event). If those bytes are not counted then total amount of reported bytes is not correctly aligned with bytes counted by TIMER. Reworking rx_flush() to correctly count number of dropped bytes and then add this flushed bytes to the total amount of RX bytes reported to the user in RXTO event handler. Signed-off-by: Krzysztof Chruściński <[email protected]> (cherry picked from commit 345dd11)
… possible Use short which is available on some devices. Signed-off-by: Krzysztof Chruściński <[email protected]> (cherry picked from commit ffdf9a9)
… 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)
…perty Add information to the device tree if UARTE instance has a HW feature which is the ENDTX_STOPTX short. Add this property to all instances in nrf54hl15, nrf9280 and nrf54h20. Signed-off-by: Krzysztof Chruściński <[email protected]> (cherry picked from commit b7b25fe)
…operty Add property which indicates that UARTE support frame timeout feature. Property is added to nrf54h20, nrf9280, and nrf54l15. Signed-off-by: Krzysztof Chruściński <[email protected]> (cherry picked from commit ac1cc17)
…_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]>
…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 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. Upstream PR: zephyrproject-rtos/zephyr#75462 Signed-off-by: Krzysztof Chruściński <[email protected]>
…ache Add support for DMM which manages cache and dedicated memory spaces. Added support for data cache for buffers which are not DMM managed. Upstream PR: zephyrproject-rtos/zephyr#75462 Signed-off-by: Krzysztof Chruściński <[email protected]>
…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. Upstream PR: zephyrproject-rtos/zephyr#75462 Signed-off-by: Krzysztof Chruściński <[email protected]>
…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. Upstream PR: zephyrproject-rtos/zephyr#75462 Signed-off-by: Krzysztof Chruściński <[email protected]>
Add lock to fix race when uart_rx_disable is interrupted by RXTO event which lead to driver state corruption. Upstream PR: zephyrproject-rtos/zephyr#75462 Signed-off-by: Krzysztof Chruściński <[email protected]>
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. Upstream PR: zephyrproject-rtos/zephyr#75462 Signed-off-by: Krzysztof Chruściński <[email protected]>
nordic-krch
force-pushed
the
ncs/uart_legacy_rework
branch
from
October 2, 2024 13:03
e81d115
to
e786044
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Set of commits cherry-picked from upstream and from upstream PR (zephyrproject-rtos/zephyr#75462) which enable use of legacy shim on nrf54x.
PR introduces: