If the clock device (i.e., RCC) failed to initialize, we have bigger
problems than trying to call clock_control_{off,on,configure} on it.
Don't bother checking to save some footprint.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Clear the TX and RX FIFOs to ensure a clean state.
Without this reset, residual data or incomplete
characters from a previous session or the bootloader could remain
in the hardware buffers.
Signed-off-by: Elmo Lan <elmo_lan@realtek.com>
Preprocess endif should be before return so that uarte_periph_enable
returns always when asynchronous API is used. It leads to faulty
behavior in certain configurations.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Some of the peripherals might be used in the bootloader
and not cleaned up properly for the next image in the boot chain.
Ensure that affected registers are always cleaned up before use.
Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
Fix warnings reported by clang about the use of a C23 extension about
usage of a label at the end of a compound statement.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Moving the declaration of half_pos out of the switch case to avoid
C23 extensions that cause build failures in some environments.
BUG=None
TEST=None
Signed-off-by: Rob Barnes <robbarnes@google.com>
In some cases UARTE peripheral is generating RXTO events together with
ENDRX events. Those events are unexpected and should not be handled.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
It is possible that some uart devices ns16550 do not support interrupts.
As an example, using main domain uarts from mcu domain m4f core in AM62
processors does not support uarts.
Signed-off-by: Ayush Singh <ayush@beagleboard.org>
Add pinctrl support to the bcm2711 aux UART driver to allow
uart pin configuration via the pinctrl driver.
Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
Recent changes (6e65fbe585) deprecated Kconfig configuration for
TIMER that is used for bytes counting. In one place code was not
cleared correctly which results in compilation failure when
deprecated symbol is used.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
As per Zephyr coding guideline #59, "operands shall not be of an
inappropriate essential type". This makes sure boolean variables are
assigned true/false values, not 1/0.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This change makes the driver rely on DT_INST_FOREACH_STATUS_OKAY(...)
rather than copy-paste the same code several time.
This also has the advantage of allowing more that 5 instances of this
uart driver.
Signed-off-by: Wilfried Chauveau <wilfried.chauveau@arm.com>
Fix the logic in `uart_xec_irq_tx_complete` when evaluating the UART line
status register against the TX-empty mask. The previous condition could
report "TX complete" even when the TX path was not fully empty, which can
cause flush users to loop or make incorrect progress decisions.
This change corrects the comparison against the TX-empty mask so that the
function only reports completion when the hardware indicates the expected
empty state.
Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com>
This patch enhances the UART shell by:
- Adding a config command to display the UART configuration;
- Displaying the current configuration when the command misses the last
parameter (usefull for command line editing).
Signed-off-by: Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com>
Some time ago a receiver mode for newer SoCs was introduced. It is
using TIMER to count RX bytes via PPI. Due to changes in the system
behavior it is not the same implementation as the one used on
legacy targets (nRF52x, nRF53x and nRF91x). New implementation is
using the Device Tree to assign a TIMER instance and old feature was
using Kconfig which is now obsolete and error prone since it is
easy to get resource usage conflict is some instances are managed
in Device Tree and some in Kconfig.
As a result to reliably receive data without HWFC user had to use
different configuration depending on the target.
Legacy implementation was using nrfx_timer and new one used HAL.
Patch attempts to align better those two similar but different
implementations by:
- deprecating Kconfig symbols for selecting TIMER instance in favor
of the Device Tree
- extracting common part like PPI initialization and some control
block fields
- Using TIMER HAL in both implementations.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Interrupt handler was handling events in a following order:
ENDRX, RXSTARTED, RXTO. This could lead to error if RX buffer
is short then with high baudrate RXSTARTED for the current
buffer could be handled together with ENDRX and in that case
uart_rx_buf_rsp called from RXSTARTED would return error as
reception is already finished due to handled ENDRX.
Reworking the driver to change that order to RXSTARTED, ENDRX,
RXTO.
Additionally, driver is optimize to only check HW events for
enabled interrupts. To achieve that, RX path interrupts are
all disabled then RX is disabled.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Initialize p_reg with the register base address from devicetree.
Signed-off-by: Hoang Nguyen <hoang.nguyen.jx@bp.renesas.com>
Signed-off-by: Nhut Nguyen <nhut.nguyen.kc@renesas.com>
Make cc13xx_cc26xx_irq_tx_ready check that the TX Ready interrupt
occurred, instead of checking whether there is some free space in
the UART TX FIFO. This prevents a race condition from occurring in
OpenThread Spinel protocol implementation, when a UART RX interrupt
is received right after otPlatUartSend was called, between the
assignement of 1 to ot_uart.tx_busy and the initialization of
write_length.
Signed-off-by: Pascal Bodin <pbodin@baylibre.com>
Fix race condition between DMA ISR and work queue that caused RX
length underflow when calculating len = counter - offset.
Both mcux_lpuart_async_rx_timeout (work queue) and dma_callback
(ISR) modified rx_dma_params without locking, causing the ISR to
update counter/offset mid-calculation, resulting in integer
underflow and system crash.
Solution: Add irq_lock() protection around all rx_dma_params
accesses in async_evt_rx_rdy(), mcux_lpuart_async_rx_flush(),
and async_evt_rx_buf_release().
Signed-off-by: Holt Sun <holt.sun@nxp.com>
Split error handling in mcux_lpuart_rx_enable() to distinguish
between DMA status query failures (error) and busy status (debug).
- Use LOG_ERR for get_status failures with specific error code
- Use LOG_DBG for busy status (expected condition, valid -EBUSY)
- Improves debuggability by providing clearer diagnostic messages
Signed-off-by: Holt Sun <holt.sun@nxp.com>
The Xen events channel driver consume 72K of RAM, but may not be
required in all use cases.
Added a XEN_EVENTS Kconfig option so that Xen events can be gracefully
disabled if not required. Updated the relevant CMakeLists.txt and
Kconfig files to guard the inclusion of the Xen events driver and its
source files by this option.
Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
Signed-off-by: Svitlana Drozd <svitlana_drozd@epam.com>
When an async transfer finished quickly, the internal state of
the driver could come out of sync with the hardware. The tx/rx
enabled flag and PM lock was taken after starting the DMA
transaction, which caused issues if the DMA complete callback
was called before the flags were updated. Set the flag and take
the PM lock prior to starting the DMA transaction to avoid this.
Also release the PM rx lock upon successful completion of a
transfer. The lock was previously only released when the user
manually called `uart_rx_disable()`.
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Add a device tree property to request connecting an instance to stdin/out
(on top of the command line option, and the kconfig option).
And clarify that the kconfig option applies to whichever is the
first instance in whatever order the DT logic happens to order them.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
The UARTE instance must be disabled before the pinctrl state is
updated like it is done other places in this driver.
While the uarte is enabled, it controls the pins, keeping TX high
for example. Trying to apply pinctrl will have no effect other
than enabling pin retention, so the TX pin which should now be low
and configured as disconnected input, stays an output driven high.
Issue was discovered as the suspended UARTE was backpowering
devices connected to it because of the driven output pins.
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
This change updates uart_stm32_dma_rx_flush() to detect the wrap case
and emit two contiguous UART_RX_RDY events in order:
- tail: [offset .. buffer_length)
- head: [0 .. counter)
This guarantees that each RX_RDY event satisfies offset + len <=
buffer_length.
Non-cyclic behavior and cyclic non-wrapping cases remain
unchanged.
Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
Commit 45cde341dc ("drivers: serial: pl011: Allows mixed IRQ
settings.") introduced a bug where PL011_SBSA_CONFIG_PORT defines
the IRQ config function as pl011_irq_config_func_sbsa_##n but
IRQ_CONFIG_FUNC_INIT(n) references pl011_irq_config_func_##n,
causing a compilation error when building for boards with SBSA
UART and interrupt support enabled.
Fix by using the correct function name with the _sbsa_ suffix
in the SBSA config port macro.
Fixes: 45cde341dc ("drivers: serial: pl011: Allows mixed IRQ settings.")
Signed-off-by: Appana Durga Kedareswara rao <appana.durga.kedareswara.rao@amd.com>
Fixes the Kconfig name of this so that it matches the value from
soc.yml, and deprecates the old name - this is required to support
future build system features. Additionally, it fixes an issue in
Kconfigs of this SoC of duplicating existing symbols
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
In uart_stm32_async_rx_buf_rsp(), when the provided RX buffer is not
located in non-cacheable memory, the function would return -EFAULT
while still holding the IRQ lock acquired at the start of the critical
section. This causes a system deadlock as interrupts remain disabled
indefinitely.
The nocache validation check has been moved outside the critical
section to ensure proper error handling. The check is performed before
acquiring irq_lock(), maintaining the same validation behavior while
preventing the lock from being held during the early error return.
Fixes a bug where async UART RX operations with improperly
placed buffers would hang the system.
Signed-off-by: Miika Karanki <miika.karanki@vaisala.com>
Adds making a peripheral clock connection to the initialiazation for SCB
based drivers. These drivers are the UART/Serial driver, I2C driver, and
SPI driver.
Signed-off-by: John Batch <john.batch@infineon.com>
Add the `DEVICE_API` wrapper to the remaining `uart_driver_api` instances,
ensuring that each driver API is placed in its respective linker section.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
For the base ns16550 spec, supporting the UART interrupt API correctly
is not strictly possible- the IIR register will clear after one read and
not update, so multiple calls to uart_irq_[tx/rx]_ready after
uart_irq_update will return stale data.
The Synopsis DW variant of this IP includes a USR register, which can be
used to correctly identify when the TX FIFO has space for more data and
when the RX FIFO is empty. Use this register when
CONFIG_UART_NS16550_DW8250_DW_APB is set.
Signed-off-by: Daniel DeGrasse <ddegrasse@tenstorrent.com>
This patch just formats the uart_xmc4xxx.c file before the real
patch, otherwise the changes would be hard to read.
Signed-off-by: Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com>
Add clock control and UART support for PSOC 4 family:
- Clock control drivers with PSOC 4 compatibility
- PSOC4xx clock source bindings and definitions
- HF clock divider configuration support
- UART FIFO trigger level configuration for PSOC 4100S Max
series with 8-deep FIFO (RX trigger=7, TX trigger=0)
Signed-off-by: Braeden Lane <Braeden.Lane@infineon.com>
When uart_rx_disable is called, or rx gets otherwise disabled,
UART_RX_DISABLED event should be emitted.
Signed-off-by: Miika Karanki <miika.karanki@vaisala.com>
uart_bcm2711_poll_in() incorrectly returned the received byte
instead of writing it to the provided buffer.
Update the implementation to store the character in *c and
return 0 on success, matching the UART poll_in API.
Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
Add clock configuration step before UART initialization to ensure
proper clock setup. The clock is first disabled, then configured
if supported by the clock controller.
If clock configuration is not supported (ENOTSUP/ENOSYS), the driver
continues with default settings. Other errors are treated as failures
and propagated to the caller.
Signed-off-by: Albort Xue <yao.xue@nxp.com>
Allows a mixture of IRQ-enabled and IRQ-disabled nodes.
Enabled nodes are identified by the presence or absence of
the interrupt-names property.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Split DMA status error from busy state handling. Use LOG_DBG for
busy state and LOG_ERR for status query failures. Return -EBUSY
as required by async UART API when transfer is in progress.
Signed-off-by: Holt Sun <holt.sun@nxp.com>
We modified the Microchip MEC UART driver to be HAL
independent and be usuable on all MEC SoCs. The only
hardware difference is an extra register in the MEC174x/5x
family providing TX FIFO full and current byte count.
Signed-off-by: Scott Worley <scott.worley@microchip.com>
Add uart_configure()/uart_config_get() support to usart_gd32.
Store runtime config in driver data and init it from DT defaults.
Signed-off-by: Aleksandr Senin <al@meshium.net>