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: UART shim based on nrfx_uarte driver #65155

Merged
merged 8 commits into from
Jan 18, 2024
Merged
3 changes: 3 additions & 0 deletions boards/posix/nrf_bsim/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,7 @@ config POSIX_ARCH_CONSOLE

endif # CONSOLE

config UART_NRFX_UARTE_LEGACY_SHIM
default y

endif # SOC_SERIES_BSIM_NRFXX
4 changes: 4 additions & 0 deletions doc/releases/migration-guide-3.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ Device Drivers and Device Tree
<&rcc STM32_SRC_PLL1_Q FDCAN_SEL(1)>;
};

* Runtime configuration is now disabled by default for Nordic UART drivers. The motivation for the
change is that this feature is rarely used and disabling it significantly reduces the memory
footprint.

Power Management
================

Expand Down
9 changes: 8 additions & 1 deletion drivers/serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ zephyr_library_sources_ifdef(CONFIG_UART_MIV uart_miv.c)
zephyr_library_sources_ifdef(CONFIG_UART_MSP432P4XX uart_msp432p4xx.c)
zephyr_library_sources_ifdef(CONFIG_UART_NS16550 uart_ns16550.c)
zephyr_library_sources_ifdef(CONFIG_UART_NRFX_UART uart_nrfx_uart.c)
zephyr_library_sources_ifdef(CONFIG_UART_NRFX_UARTE uart_nrfx_uarte.c)
if (CONFIG_UART_NRFX_UARTE)
if (CONFIG_UART_NRFX_UARTE_LEGACY_SHIM)
zephyr_library_sources(uart_nrfx_uarte.c)
else()
zephyr_library_sources(uart_nrfx_uarte2.c)
endif()
endif()
zephyr_library_sources_ifdef(CONFIG_UART_NUMICRO uart_numicro.c)
zephyr_library_sources_ifdef(CONFIG_UART_SAM uart_sam.c)
zephyr_library_sources_ifdef(CONFIG_USART_SAM usart_sam.c)
Expand Down Expand Up @@ -93,3 +99,4 @@ endif()

zephyr_library_sources_ifdef(CONFIG_SERIAL_TEST serial_test.c)
zephyr_library_sources_ifdef(CONFIG_UART_ASYNC_RX_HELPER uart_async_rx.c)
zephyr_library_sources_ifdef(CONFIG_UART_ASYNC_TO_INT_DRIVEN_API uart_async_to_irq.c)
15 changes: 15 additions & 0 deletions drivers/serial/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ config UART_ASYNC_RX_HELPER
is delayed. Module implements zero-copy approach with multiple reception
buffers.

config UART_ASYNC_TO_INT_DRIVEN_API
bool
select UART_ASYNC_RX_HELPER
help
Asynchronous to Interrupt driven adaptation layer. When enabled device
which implements only asynchronous API can be used with interrupt driven
API implemented by the generic adaptation layer.

config UART_ASYNC_TO_INT_DRIVEN_RX_TIMEOUT
int "Receiver timeout (in bauds)"
depends on UART_ASYNC_TO_INT_DRIVEN_API
default 100
help
Receiver inactivity timeout. It is used to calculate timeout in microseconds.

comment "Serial Drivers"

source "drivers/serial/Kconfig.b91"
Expand Down
11 changes: 10 additions & 1 deletion drivers/serial/Kconfig.nrfx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,20 @@ config UART_NRFX_UART
config UART_NRFX_UARTE
def_bool y
depends on DT_HAS_NORDIC_NRF_UARTE_ENABLED
imply NRFX_UARTE_CONFIG_SKIP_PSEL_CONFIG if !UART_NRFX_UARTE_LEGACY_SHIM
imply NRFX_UARTE_CONFIG_SKIP_GPIO_CONFIG if !UART_NRFX_UARTE_LEGACY_SHIM

config UART_NRFX_UARTE_LEGACY_SHIM
bool "Legacy UARTE shim"
depends on UART_NRFX_UARTE
# New shim takes more ROM. Until it is fixed use legacy shim in memory
# constraint case.
Comment on lines +34 to +35
Copy link
Member

Choose a reason for hiding this comment

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

is this expected to improve/be fixed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, eventually we want to have one shim only. But harder to say exact when.

default y if MCUBOOT

config UART_ASYNC_TX_CACHE_SIZE
int "TX cache buffer size"
depends on UART_ASYNC_API
depends on UART_NRFX_UARTE
depends on UART_NRFX_UARTE_LEGACY_SHIM
default 8
help
For UARTE, TX cache buffer is used when provided TX buffer is not located
Expand Down
45 changes: 44 additions & 1 deletion drivers/serial/Kconfig.nrfx_uart_instance
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
config UART_$(nrfx_uart_num)_INTERRUPT_DRIVEN
bool "Interrupt support on port $(nrfx_uart_num)"
depends on UART_INTERRUPT_DRIVEN
select UART_ASYNC_TO_INT_DRIVEN_API if !UART_NRFX_UARTE_LEGACY_SHIM
default y
help
This option enables UART interrupt support on port $(nrfx_uart_num).
Expand All @@ -27,14 +28,18 @@ config UART_$(nrfx_uart_num)_ENHANCED_POLL_OUT
When enabled, polling out does not trigger interrupt which stops TX.
Feature uses a PPI channel.

config NRFX_UARTE$(nrfx_uart_num)
def_bool y if HAS_HW_NRF_UARTE$(nrfx_uart_num) && !UART_NRFX_UARTE_LEGACY_SHIM

config UART_$(nrfx_uart_num)_NRF_PARITY_BIT
bool "Parity bit"
help
Enable parity bit.

config UART_$(nrfx_uart_num)_NRF_TX_BUFFER_SIZE
int "Size of RAM buffer"
depends on UART_INTERRUPT_DRIVEN
depends on HAS_HW_NRF_UARTE$(nrfx_uart_num)
depends on UART_NRFX_UARTE_LEGACY_SHIM
range 1 65535
default 32
help
Expand All @@ -46,6 +51,7 @@ config UART_$(nrfx_uart_num)_NRF_HW_ASYNC
bool "Use hardware RX byte counting"
depends on HAS_HW_NRF_UARTE$(nrfx_uart_num)
depends on UART_ASYNC_API
depends on UART_NRFX_UARTE_LEGACY_SHIM
select NRFX_PPI if HAS_HW_NRF_PPI
select NRFX_DPPI if HAS_HW_NRF_DPPIC
help
Expand All @@ -58,6 +64,7 @@ config UART_$(nrfx_uart_num)_NRF_ASYNC_LOW_POWER
bool "Low power mode"
depends on HAS_HW_NRF_UARTE$(nrfx_uart_num)
depends on UART_ASYNC_API
depends on UART_NRFX_UARTE_LEGACY_SHIM
help
When enabled, UARTE is enabled before each TX or RX usage and disabled
when not used. Disabling UARTE while in idle allows to achieve lowest
Expand All @@ -67,6 +74,42 @@ config UART_$(nrfx_uart_num)_NRF_HW_ASYNC_TIMER
int "Timer instance"
depends on UART_$(nrfx_uart_num)_NRF_HW_ASYNC

config UART_$(nrfx_uart_num)_TX_CACHE_SIZE
int "TX cache buffer size"
depends on !UART_NRFX_UARTE_LEGACY_SHIM
default 8
help
For UARTE, TX cache buffer is used when provided TX buffer is not located
in memory which can be used by the EasyDMA.

config UART_$(nrfx_uart_num)_RX_CACHE_SIZE
int "RX cache buffer size"
depends on !UART_NRFX_UARTE_LEGACY_SHIM
default 32 if $(dt_nodelabel_has_compat,ram3x,$(DT_COMPAT_MMIO_SRAM))
default 5
range 5 255
help
For UARTE, RX cache buffer is used when provided RX buffer is not located
in memory which can be used by the EasyDMA. It is also used to store
flushed data.

config UART_$(nrfx_uart_num)_A2I_RX_SIZE
depends on !UART_NRFX_UARTE_LEGACY_SHIM
int "Asynchronous to interrupt driven adaptation layer RX buffer size"
default 64 if UART_$(nrfx_uart_num)_INTERRUPT_DRIVEN
default 0
help
Amount of space dedicated for RX. It is divided into chunks with some
amount of that space used for control data.

config UART_$(nrfx_uart_num)_A2I_RX_BUF_COUNT
Comment on lines +77 to +105
Copy link
Member

Choose a reason for hiding this comment

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

not a fan is instance-based options, these do not scale well and perpetuate the problem nrfx-based driver have: hardcoded relationship with hw instance numbers. Isn't there a better option?

Copy link
Member

Choose a reason for hiding this comment

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

ping

depends on !UART_NRFX_UARTE_LEGACY_SHIM
int "Asynchronous to interrupt driven adaptation layer RX buffer count"
default 8 if UART_$(nrfx_uart_num)_INTERRUPT_DRIVEN
default 0
help
Number of chunks into RX space is divided.

config UART_$(nrfx_uart_num)_GPIO_MANAGEMENT
bool "GPIO management on port $(nrfx_uart_num)"
depends on PM_DEVICE
Expand Down
Loading
Loading