Every read went to the start of the RX buffer, so data from an earlier
UART_RX_RDY could be overwritten before the user had read it. Advance
the offset through the buffer instead, wrapping once it is full.
Signed-off-by: Eden Frosst <eden.frosst@rbr-global.com>
The async RX thread sleeps 10 ms whenever the pty is empty, adding up
to 10 ms of latency to every received byte. Make the period
configurable, keeping 10 ms as the default.
Signed-off-by: Eden Frosst <eden.frosst@rbr-global.com>
Add a "snps,dw-apb-uart" binding that includes ns16550.yaml, and make
UART_NS16550_DW8250_DW_APB default to y whenever a node with that
compatible is enabled. This removes the need for each SoC to opt in
to the DesignWare 8250 quirks through a configdefault in its
Kconfig.defconfig.
Drop the now-redundant configdefault from the Allwinner H3/H618,
Rockchip RV1106 and Silabs SiWx91x SoCs, and add the
"snps,dw-apb-uart" compatible to the SiWG917 UART nodes so the
Kconfig default picks them up.
The UART nodes in dts/arm/intel_socfpga_std/socfpga.dtsi already list
"snps,dw-apb-uart", so the option is now also enabled on
cyclonev_socdk, where it was previously off. The Cyclone V HPS UARTs
are DesignWare APB UARTs.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
The async section includes rtl_gdma.h / rtl876x_gdma.h although the
driver uses no symbol from either; DMA goes through the generic API and
the helpers in dma_bee.h. Those headers only reach the include path
when the Bee DMA HAL is built, so enabling UART_ASYNC_API with no
realtek,bee-dma node breaks the build.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
This change marks each instance of the `uart_xxx_config` as `const`.
By using `const`, we ensure immutability, leading to usage of only
`.rodata` and a reduction in the `.data` area.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Remove address-of operator ('&') when assigning `init_fn`
function pointer in `DEVICE_DT_INST_DEFINE` and `DEVICE_DT_DEFINE`
macros.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Adding initial of baud_setting.clock_source variable.
Fixing p_reg in extended configuration to cover sci and sci_b
Signed-off-by: Duc Bui <duc.bui.vt@bp.renesas.com>
Signed-off-by: Tien Nguyen <tien.nguyen.zg@renesas.com>
The async RX helper returns immediately when no bytes are pending. This
leaves completed buffers with no received data outside the free pool. The
consumer cannot reclaim them by polling for data. If every buffer reaches
that state, the UART cannot obtain a buffer to restart reception.
Run the existing ordered reclaim loop before checking pending_bytes. This
keeps read-cursor updates in the consumer context. It adds no
interrupt-masked sections to producer callbacks. Preserve zero-length
claims as side-effect free.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
Let an LPUART instance describe its own clock source. When the node names
a "source" clocks entry, apply it with clock_control_configure() before
the peripheral clock is ungated, so the root's mux and dividers come from
devicetree rather than from a board C file. The cells are opaque here and
are interpreted by the clock controller.
Fetch that entry by name rather than by index. The families sharing this
driver spell their other clocks entries differently, and most of their
nodes carry no clock-names at all, so a node that already names its
entries can append "source" without disturbing them while the gate entry
stays at index 0 for every node that names nothing.
An instance that names no "source" entry behaves as before.
Signed-off-by: Lucien Zhao <lucien.zhao@nxp.com>
Add the UART driver for MediaTek MT8188, giving the Genio boards a
console. Register access is split into a shared core and a small
per-SoC instantiation layer, so other MediaTek SoCs can reuse the core.
The driver is instantiated for every enabled node rather than a fixed
instance, and takes its gate clock from the infra-ao controller.
Co-authored-by: Felix Freimann <felix.freimann@mediatek.com>
Signed-off-by: Aary Patil <aary.patil@mediatek.com>
Added a TX done interrupt check so that device SUSPEND has the
opportunity to run again once the UART has completed its
transmission. Otherwise the scheduler does not run pm_state_set
again, and the app would stay in runtime-idle mode.
Assisted-by: Claude:claude-opus-4.8
Signed-off-by: Richard Mc Sweeney <Richard.McSweeney@infineon.com>
Added pm_action suspend/resume/turn_on routine for UART
Assisted-by: Claude:claude-opus-4.8
Signed-off-by: Richard Mc Sweeney <Richard.McSweeney@infineon.com>
dma_tx.buf_len doubles as the transfer-in-progress flag that uart_tx()
tests to reject an overlapping transfer, but it was only cleared on the
successful DMA completion. An abort, a TX timeout or a DMA error left it
set, so every later uart_tx() returned -EBUSY for good. Clear it on each
path that ends a transfer.
dma_rx.buf_len has the same role and the same gap: rx_enable() left it
set when the DMA configuration failed, and the mid-stream rearm in the
RX callback discarded its return value, leaving RX dead with the runtime
PM reference still held and no event delivered to the application.
Release both buffers and end the session on those paths as well.
Assisted-by: Claude:claude-opus-4.8
Signed-off-by: Richard Mc Sweeney <Richard.McSweeney@infineon.com>
ifx_cat1_uart_async_tx() overwrote the transfer descriptor and
reconfigured the DMA channel even when a previous transfer was still
in flight, corrupting the running transfer. Return -EBUSY while
buf_len is non-zero so a second uart_tx() is rejected while a transfer
is ongoing, as the UART async API requires.
Assisted-by: Claude:claude-opus-4.8
Signed-off-by: Richard Mc Sweeney <Richard.McSweeney@infineon.com>
ifx_cat1_uart_set_baud() reprogrammed the peripheral clock divider
while it was still enabled, so a new baud rate could be applied to a
running divider. Disable the divider, set the new value, then
re-enable it; a failed set leaves the register unchanged, so the
re-enable restores the previous rate.
Assisted-by: Claude:claude-opus-4.8
Signed-off-by: Richard Mc Sweeney <Richard.McSweeney@infineon.com>
uart_mchp_init() assumes the SERCOM it is handed has never been used.
It issues no software reset and makes no check, and then writes the
character size, parity, stop bits, clock source and baud rate straight
into registers the SERCOM write-protects while CTRLA.ENABLE is set.
From a cold reset that assumption holds. Under a bootloader it does not:
MCUboot drives its own console out of this same SERCOM and hands it over
still enabled, so none of the configuration above takes effect and the
application's console never comes up. On a PIC32CM5112GC00100 the image
chainloaded by MCUboot faults during this device's init, which is
visible over SWD as the console device being the one entry in
device_states that never reaches initialized.
The fix is the sequence the datasheet prescribes: when the peripheral is
found enabled, clear ENABLE, wait for synchronization, assert
CTRLA.SWRST and wait again. On a cold boot the branch is not taken, so
nothing changes for the case that already worked.
This is the same defect as the DPLL patch beside it, in another driver -
init code that reads its own state rather than the hardware's and so
only works on the first boot after reset.
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
irq_rx_enable() took the lock for as long as the receiver was armed.
A shell enables RX once and never disables it, so light sleep never
runs.
Take the lock only for an async RX transfer. Bytes that arrive while
the SoC sleeps are dropped; the UART is not a wake source.
Assisted-by: Grok:4.6
Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
uart_irq_tx_disable() dropped the lock as soon as the driver stopped
asking for more data. Bytes can still be in the FIFO at that point,
so the SoC could enter light sleep mid-frame.
Wait for TX_DONE instead, which poll_out() already does. Rename
TX_POLL to TX_DRAIN and share it, as both paths wait for the same
event: the transmitter going empty. If TX is already idle, mask
TX_DONE and drop the lock now: the interrupt will not fire, and
leaving it enabled would keep a stale mask across the next transfer.
Assisted-by: Grok:4.6
Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
Commit ed7dd4f011 ("drivers: serial: stm32: split cyclic RX wrap into two
contiguous events") fixed some issues with cyclic wraparound,
but left a race condition where if the timeout arrives before COMPLETE,
data is emitted twice.
Simplify handling by ignoring the status and always using
`dma_get_status` to determine how much data to emit.
Return an error when trying to enable cyclic DMA with a 1-byte buffer.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Kamil Krzyżanowski <kamnxt@kamnxt.com>
The slot argument from macros STM32_DT_INST_DMA_SLOT* was useless.
With it the macro was basically a redefinition a the Zephyr macro.
It is now removed to be similar to other STM32 DMA macros that call
DT_INST_DMAS_CELL_BY_NAME.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Typically Zephyr device tree macros that take a inst as argument
start with DT_INST_.
For the STM32 DMA driver we currently have several macros taking an inst as
argument but missing this prefix.
For consistency, it is added to these macros. The goal is to also define
DT_ variants of these macros that take a node_id as argument.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Read the input clock rate from the clock controller. Allow to
also define the clock rate via the device-tree.
Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
Fixes various issues with Kconfigs, including:
- Using the wrong indentation
- Not having [EXPERIMENTAL] in the prompt, or not having it at
the end
- Wrongly stating the CONFIG_EXPERIMENTAL is needed to enable
an experimental Kconfig
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes various issues with Kconfigs, including:
- Redundent `default n` on bools
- Not select deprecated on supposed deprecated symbols
- Using the wrong indentation
- Not having [DEPRECATED] in the prompt, or not having it at the
end
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Protect the assignment of user_cb and user_data in
uart_stm32_irq_callback_set() using irq_lock() and irq_unlock() to
prevent a race condition where an incoming UART interrupt executes the
new callback with stale user_data.
Fixes#118457
Signed-off-by: Jay Roy <jayroy0304@gmail.com>
BIT() overflows for pins >= 32, so pio_sm_set_pins_with_mask() and
pio_sm_set_pindirs_with_mask() cannot express them. Use the 64-bit
variants, which are equivalent below GP32.
Assisted-by: Claude:claude-opus-5
Signed-off-by: John Goble <john.goble@nimbusdigital.com>
Add UART_NS16550_VARIANT_NS16450 to run the controller with FIFOs
disabled. This is for hardware whose FIFO-mode receive interrupts do
not work: on the C-DAC THEJAS32, neither the receive trigger level nor
the character timeout ever raises an interrupt, so received data sits
in the FIFO unnoticed. In 16450 mode the received data available
interrupt is raised for every character.
The FIFO detection already present in the driver handles the rest: with
FIFOs disabled the IIR FIFO-enabled bits read back zero and the FIFO
size is treated as one byte.
Signed-off-by: Anuj Deshpande <anuj@makerville.io>
Replaced SOC dependent kconfigs CONFIG_SOC_SERIES_NRF54H,
CONFIG_SOC_SERIES_NRF92 with feature oriented
CONFIG_HAS_MULTI_OPTION_CLOCKS, in clock related drivers.
Signed-off-by: Michal Frankiewicz <michal.frankiewicz@nordicsemi.no>
The driver rejects PM_DEVICE_ACTION_TURN_OFF with -ENOTSUP, so a power
domain cannot tell it that the supply is about to go away. Accept the
action instead. There is nothing to save: TURN_ON already rebuilds the
whole register bank from data->uart_config, and SUSPEND has stashed the
interrupt mask in data->pm_saved_int, so re-reading the mask here would
only record the zero SUSPEND left behind.
This matters on SoCs where a low-power state collapses the LPUART power
domain. Baud rate, format and enables are all lost, and without a TURN_OFF
the domain never gets to re-run TURN_ON: the first write after the window
stalls on a transmitter that is no longer clocked, or bus-faults on the
block.
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
Add UART driver for the ASCLIN module found on TC3x and TC4x.
Supports polling mode with configurable baudrate via the ASCLIN
fractional divider. Uses a private register header to handle
TXDATA/RXDATA layout differences between TC3x and TC4x.
Signed-off-by: Christoph Seitz <christoph.seitz@infineon.com>
Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
The ns16550 driver unconditionally references DT_INST_IRQ(n, priority)
when registering the interrupt handler. This fails to compile when the
DT Nodes interrupt controller uses a single-cell specifier with no
priority cell (e.g., riscv,cpu-intc with #interrupt-cells = <1>).
Add a UART_NS16550_IRQ_PRIORITY helper macro that checks for the
priority cell existence using DT_INST_IRQ_HAS_CELL and falls back to 0
when it is absent, matching the existing pattern used by
UART_NS16550_IRQ_FLAGS for the optional flags cell.
Signed-off-by: Conor Paxton <conor.paxton@microchip.com>
Commit a93e31f280 ("drivers: uart: stm32: don't read TC interrupt flag
multiple times") introduced a regression.
When building with both `PM` and `UART_ASYNC_API` enabled, using
`poll_out` on a UART causes the PM lock to be released twice after being
acquired a single time.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Kamil Krzyżanowski <kamnxt@kamnxt.com>
Add DMA Controller (DMAC) support for asynchronous UART TX/RX on
Renesas RA SCI-B.
Key changes:
- Add UART_RA8_SCI_B_UART_DMAC and UART_RA8_SCI_B_UART_DTC Kconfig
option to gate DTC/DMA support
- Add tx-dtc and rx-dtc DT binding properties for DTC transfer
- Support both DTC/DMAC transfer with shared transfer infrastructure
- Add DMAC transfer configuration, interrupt and callback declarations
Signed-off-by: Khai Cao <khai.cao.xk@renesas.com>
Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
Even if the driver does not support the frame timeout configuration,
if the HW peripheral does, we need to set it to disabled.
Otherwise the value is just random garbage which corrupts the
whole uart configuration as it will be OR'ed with the rest.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
The uart_driver_api irq_update member is void (*)(const struct device *),
but numicro_uart_irq_update() still returns int, so building the driver
fails with an incompatible pointer type error. Make it return void,
which changes no behavior: the body is a no-op and uart_irq_update()
discards the value.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
The slim ring buffer API is now header-only and always available and the
tree has already migrated from the _claim/_finish API, so the RING_BUFFER
symbol no longer gates any code.
Remove the now-redundant "select RING_BUFFER" and CONFIG_RING_BUFFER=y
entries across drivers, subsystems, samples and tests.
Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
The ring buffer API is now unconditionally available, so the mock serial
driver no longer needs to compile its written/read_queue buffers and the
poll/queue/peek helpers conditionally.
Remove the #ifdef CONFIG_RING_BUFFER blocks and the -ENOTSUP fallback in
serial_vnd_poll_in().
Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
Replace direct NVIC pending-state calls with k_irq_set_pending()/
k_irq_is_pending()/k_irq_clear_pending(), dropping the dependency on
cmsis_core.h where nothing else needed it.
The NVIC_EnableIRQ()/NVIC_DisableIRQ() pair on the error interrupt
becomes irq_enable()/irq_disable().
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC pending-state calls with k_irq_set_pending()/
k_irq_is_pending()/k_irq_clear_pending(), dropping the dependency on
cmsis_core.h where nothing else needed it.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Handle PSC3M6 SCB naming differences in the PDL. Select the
multi-processor-mode field for the UART under SOC_DIE_PSC3M6.
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Richard Mc Sweeney <Richard.McSweeney@infineon.com>
Signed-off-by: Niranjan M <niranjan@aerlync.com>
Update the existing UART PDL driver to work with the CYT4DN SoC in
the TRAVEO family. This adds CYT4DN-specific clock, interrupt, and
DMA handling using the INFINEON_TRAVEO_FAMILY Kconfig option.
Signed-off-by: Alexpandi Muniyandi <alexpandi@linumiz.com>
The verifiers for uart_poll_out_u16(), uart_tx_u16() and
uart_rx_enable_u16() checked for the 8-bit driver op rather than the
16-bit one the implementation calls, so the check passed for drivers
that provide only the 8-bit op.
Check the matching _u16 op instead. Those ops only exist under
CONFIG_UART_WIDE_DATA, so uart_poll_out_u16() falls back to a plain
object check when it is disabled. uart_poll_in_u16() uses the object
check unconditionally because its implementation already tests the op
for NULL.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
On the C6, UART_SCLK_DEFAULT is PLL_F80M, and programming the UART
clock mux/divider while the PLL is still settling after a cold boot
intermittently latches a wrong effective clock: the port then corrupts
essentially every frame (CRC failures at the frame rate, occasional
merged frames when a delimiter byte is hit) for the entire session.
Warm resets never reproduce it - the PLL is already settled - and
re-running uart_configure() with identical values once the clock tree
is stable heals the port instantly, which pins the fault to the latch,
not the programmed values. Observed on ~50% of cold boots on affected
hardware; bench-validated 2026-08-26.
Source the UART from the always-stable XTAL instead, following the
same reasoning as the existing P4 handling (keep a settle-independent
source) and IDF practice under DFS. The fractional divider keeps
standard rates within ~0.02% from the 40 MHz XTAL.
Signed-off-by: Linus Ruettimann <linus@noxblanc.com>
The ERI ISR only cleared the SCI error flags and the pending IELSR.IR
inside the user_cb!=NULL branch. When an RX error (overrun/framing/
parity) occurs while no interrupt callback is registered yet - e.g. the
window during uart_configure()/R_SCI_UART_Open() before the Zephyr
callback is set - nothing is acknowledged, so the error stays pending
and the ISR re-triggers forever, starving the CPU (uart_configure hangs,
USB never enumerates). Always run err_check() and clear IELSR.IR.
Signed-off-by: Mattia Pennasilico <m.pennasilico@arduino.cc>
Assisted-by: Claude:claude-opus-4.8
mcux_lpuart_configure() begins by spinning unbounded on the
Transmission Complete flag before reconfiguring the peripheral. TC
only sets when the transmitter is enabled and idle, so a
uart_configure() call issued while traffic is flowing parks the
calling thread for the full duration of that traffic. Observed on an
MCXA153 driving a USB CDC-ACM to UART bridge: the host's line-coding
change (9600 -> 115200 at port open) triggered uart_configure()
against a live transfer and the configuring thread spun for 15.36 s,
the time the entire transfer took to drain at the old baud rate
(BAUD register sampled over SWD while stalled). When the loop finally
exited, the driver disabled TE/RE and reinitialized mid-frame,
deterministically corrupting the byte being received.
Bound the wait with WAIT_FOR (300 ms total, 100 us poll). On timeout,
return -EBUSY and leave the peripheral untouched so the caller can
quiesce its traffic and retry; proceeding to tear down the
transmitter and receiver at that point can only destroy in-flight
data. 300 ms covers this driver's worst-case 12-bit frame (start +
8 data + parity + 2 stop, 240 ms) at 50 baud, the slowest standard
rate, so a transmitter finishing its last frame completes within the
window; for the arbitrarily slower rates the hardware can still be
configured to, the bound is an intentional policy limit and the
resulting -EBUSY is side-effect-free and retryable.
Callers that configure an idle UART see no change: TC is already set
and WAIT_FOR returns on its first evaluation.
Signed-off-by: João Felipe <joao@binho.io>
Signed-off-by: Leonardo José Consoni <leonardo@binho.io>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add support for software-managed RTS flow control to work around
hardware RTS silicon limitations on affected STM32 SoC revisions:
- Add st,sw-rts-gpios property to st,stm32-uart-base binding.
- Add UART_STM32_ABNORMAL_RTS_ERRATUM_WORKAROUND Kconfig option with
automatic GPIO selection.
- Configure USART hardware for CTS-only flow control.
- Assert RTS (active low) on rx_enable and deassert on rx_disable
or buffer exhaustion.
Fixes#36849
Signed-off-by: Priyanshu Singh <singhpriyanshu9838@gmail.com>
Add DEVICE_DT_INST_GET_COMMA helper macro to include/zephyr/device.h to
easily get a device pointer followed by a comma when expanding
devicetree foreach iterators like DT_INST_FOREACH_STATUS_OKAY.
Update drivers, soc, subsys, and tests to use the common definition.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Assisted-by: Antigravity:gemini-1.5-pro
All UART devices supports ISR_SAFE PM device when asynchronous
API is used so pm_device_runtime_put can be used from an interrupt
context. It allows to disable CONFIG_PM_DEVICE_RUNTIME_ASYNC if
needed to safe space.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>