Commit graph zephyr/drivers/serial
Author SHA1 Message Date
Vedant Malkar
63c8890b6b drivers: serial: add Shakti UART driver
Add a UART driver for SHAKTI Ganga SoC,
supports polling and interrupt driven
operations

Signed-off-by: Vedant Malkar <vedantitsme@gmail.com>
2026-07-15 10:44:27 +02:00
Fin Maaß
e51fb465b7 virtio: select VIRTIO
drivers should select VIRTIO if they need it.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-09 07:58:11 +02:00
Fin Maaß
8ae67397d7 serial: add SERIAL_HAS_POST_KERNEL_INIT
uart drivers, that init in POST_KERNEL and
not in PRE_KERNEL_1 can't support
CONFIG_EARLY_CONSOLE, add a Kconfig for it.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-09 07:58:11 +02:00
Camille BAUD
a0473c3a2f drivers: bflb: extend shared drivers with BL616CL support
Add support for BL616CL in shared drivers

Signed-off-by: Camille BAUD <mail@massdriver.space>
2026-07-08 10:01:48 +02:00
Perry Naseck
16a5593e10 serial: sam0: Fix UART error assignment flip (framing/parity)
This commit fixes a bug where framing and parity errors are swapped
and misreported.

Signed-off-by: Perry Naseck <pnaseck@media.mit.edu>
2026-07-08 09:58:06 +02:00
Daniel Schultz
2031f2d8a1 drivers: serial: uart_aesc: Convert to sys_{write,read}32
Register structs rely on the compiler emitting 32-bit volatile accesses
and on the struct layout staying in sync with the hardware. sys_read32
and sys_write32 make the access width explicit, work with DEVICE_MMIO
address mapping, and match the convention used by in-tree drivers.

Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
2026-07-02 12:58:32 -04:00
Daniel Schultz
5beb6f2975 drivers: serial: uart_aesc: Add const to config struct
Make uart_aesc_dev_cfg_##no "static const struct" instead of
"static struct" to move this struct into ROM. This reduces the
memory usage for this driver.

Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
2026-07-02 12:58:32 -04:00
Fabio Baltieri
a5191c40ef drivers,subsys: use min3/max3 instead of nested MIN/MAX
Replace nested MIN/MAX macro calls with the min3/max3 APIs which are
safer (evaluate arguments only once) and cleaner.

Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2026-07-01 23:44:58 -04:00
Sylvio Alves
e65faf5d6e drivers: serial: esp32 lp_uart irq and optional flow control
Add interrupt-driven API support to the esp32 lp_uart driver and make
RTS/CTS hardware flow control optional, enabled only when the device
tree sets hw-flow-control. Add a loopback property that ties TX to RX
inside the peripheral for self-test without external wiring.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-06-30 18:22:25 -04:00
Sylvio Alves
98518707fa drivers: serial: esp32 lp_uart support on esp32c5 and esp32p4
Extend the esp32 lp_uart driver to the esp32c5 and esp32p4. On the
esp32p4 the LP UART signals are routed through the LP GPIO matrix and
the controller is clocked from the precise XTAL_D2 source instead of
the uncalibrated RC_FAST, so the baud-rate framing is reliable.

Relax the fixed-pin bindings, describe the lp_uart node pins on the
c5/c6/p4 HP and LP cores, and extend the echo_ulp sample. Update
hal_espressif for the esp32p4 LP GPIO matrix and clock-tree helpers.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-06-30 18:22:25 -04:00
Etienne Carriere
b0b25c35c9 drivers: use <> to include Zephyr headers instead of ""
Use <> operator to include a Zephyr header file instead of "" that
is intended to local header files, not header files relative to
specifically defined search paths.

This change was made running the sed shell command below:
$ sed -i -E 's/#include "zephyr\/([^"]+)\.h"/#include <zephyr\/\1.h>/g' \
    `grep -rsl "#include \"zephyr/" drivers/`

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-06-30 06:49:18 -04:00
Michael Zimmermann
e10af22991 tree-wide: replace usages of k_work_q thread with thread_id
The `thread` field is not initialized, if it's being animated via
k_work_queue_run instead of k_work_queue_start.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-06-29 22:17:45 -04:00
Surya Prakash T
00787dc99e drivers: serial: add NXP LPC84x UART driver
Add UART driver support for NXP LPC84x series.

The driver supports polling and interrupt-driven modes with
runtime configuration. It integrates with Zephyr clock control
and pinctrl for device setup.

Signed-off-by: Surya Prakash T <suryat@aerlync.com>
Signed-off-by: Sayooj K Karun <sayooj@aerlync.com>
Co-authored-by: Dilip Raman <dilipr@aerlync.com>
2026-06-26 14:23:10 +01:00
Michael Zimmermann
6c92db1979 soc: silabs: define clocks for gecko_sdk based SoCs in device tree
The main goal of this change is being able to use counter_gecko_rtcc.c and
leuart_gecko.c on boards without an LFXO. This is the case for tyzs3.
The main changes are in soc/silabs/common, the rest is just to migrate all
of the boards.

This uses the device tree for clock-initialization only. I did not
implement a clock_control driver, because I don't see a need for that. The
drivers use CMU_ClockEnable, which abstracts away SoC differences already.

The config SOC_GECKO_HAS_HFRCO_FREQRANGE was removed, because:
- This can be detected via macros provided by gecko_sdk.
- There is an alternative to that API which wasn't implemented previously,
  but is now (cmuHFRCOBand_*).

I don't own any of the boards except for tuya tyzs3, but did my best to
avoid mistakes. That being said, I found several issues, which were present
in some of the boards already:

- sltb004a: This board has a 38.4MHz HFXO crystal, but it was configured to
  40MHz. I fixed that.
- tomu: This board uses HFRCO as it's HF clock, even though the SoC does
  not support SOC_GECKO_HAS_HFRCO_FREQRANGE. So it was probably running at
  the initial 14MHz instead.
- Many boards enabled leuart and rtcc (counter) peripherals, which need(ed)
  LFXO, without ever enabling LFXO. These peripherals were probably not
  working before this change.

Noteworthy finds:
- slwrb4321a: This board uses HFRCO as it's HF clock, but has a board.c
  where it enables HFXO to use it as the RMII reference clock. I'm not sure
  if it's okay to do that without calling CMU_HFXOInit first. I did not
  modify that code to not change behavior that I don't understand.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-06-25 22:18:27 +01:00
Perry Naseck
77c9209927 esp32: serial: Save UART framing errors before clearing, catch all errors
This commit fixes a bug where esp32 UART errors are cleared before they
can be read. Additionally, all line errors (such as break and FIFO
overflow) are now watched and reported.

Assisted-by: Claude:claude-opus-4.7

Signed-off-by: Perry Naseck <pnaseck@media.mit.edu>
2026-06-23 21:16:42 -04:00
Liu Changjie
f22a995c50 drivers: serial: wch: reorder USART init / apply pinctrl first
The USART init sequence configured BRR and CTLR1 (enabling the UART) and
only afterwards applied the pinctrl state. Reorder so that:

1. The clock is enabled.
2. The pinctrl state is applied before the peripheral is enabled.
3. CTLR1 is cleared first to ensure the UART is disabled while CTLR2/CTLR3
   and the baud-rate divisor (BRR) are programmed, then CTLR1 is written
   last to enable the UART with the final configuration.

Programming the control and baud-rate registers while the UART is disabled
and bringing up the pins before enabling avoids configuring the peripheral
in an undefined intermediate state. This is the ordering required by the
CH32H417 (QingKe V5F) and was regression-tested on a CH32V317 to confirm it
does not affect existing single-core parts.

Signed-off-by: Liu Changjie <liucj1228@outlook.com>
2026-06-23 21:16:34 -04:00
Sreeram Tatapudi
b756ee2abd drivers: serial: infineon: pick oversample by absolute baud error
The UART bit clock is peripheral_clock / (divider * oversample), so the
driver must choose an oversample factor for the requested baud.
ifx_cat1_uart_set_baud() ranked candidates with ifx_uart_baud_diff(),
which returns the error as an integer percentage. At 100 MHz / 115200
every oversample (8-16) is under 1% and rounds to 0, so the first
candidate (oversample 8, -0.45%) always won, the least accurate option
with the smallest sampling margin.

Compare the error in absolute Hz instead. This selects oversample 14
(divider 62, 115207 baud, -0.006%), improving both accuracy and margin.
A zero divider is skipped to avoid divide-by-zero and the percentage
tolerance is kept as the validity check.

Assisted-by: Copilot:claude-opus-4.8
Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
2026-06-22 18:05:12 -04:00
Fin Maaß
212b4c4544 drivers: serial: ns16550: select PCIE
select PCIE if the controller is
on a pcie bus.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-06-19 22:39:12 +02:00
Michal Chromec
1aac1518d1 drivers: serial: uart_mcux_lpuart: ensure TX completes before reconfig
Add a wait for the Transmission Complete (TC) flag at the start of
mcux_lpuart_configure(). This prevents reconfiguration while the
hardware is still shifting out the final byte on the TX line.

Without this wait, uart_configure() could interrupt an ongoing
transmission, causing the last byte to not be fully sent on the UART
bus. This behavior was observed on NXP LPUART and tracked in issue
#109807.

Fixes #109807

Signed-off-by: Michal Chromec <michal.chromec@nxp.com>
2026-06-19 13:18:23 +02:00
Aaron Brice
716a56a916 drivers: serial: ra_sci: Fix intermittent duplicate tx chars
Related to commit 01b611100c. When not using
the fifo, the renesas_ra_sci peripheral will resend the last transmitted
character if you manually clear the TDRE bit in the SSR status register.
This makes 'SSR &=' dangerous to use in the case where the TDRE bit is set
in between reading the register and updating it.  The hardware manual says
that writing a zero clears status bits and writing a one is ignored, so the
update isn't needed, only write 0 to the bits that need to be cleared. Only
the error status bits need to be manually cleared, the RDRF bit is cleared
automatically by hardware.

Signed-off-by: Aaron Brice <aaron@embeddedts.com>
2026-06-19 11:10:32 +02:00
Perry Naseck
1069b6822a serial: Fix PL011 error staying latched
This commit fixes an issue where a framing error is never cleared
on the PL011 serial peripheral.

Assisted-by: Claude:claude-opus-4.7

Signed-off-by: Perry Naseck <pnaseck@media.mit.edu>
2026-06-17 16:34:56 -04:00
Anas Nashif
ea1fbf3588 driver: fix various typos
Fixed various typos under drivers/

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-17 10:12:27 -04:00
Michael Zimmermann
8a7ae0bed1 modules: hal_silabs: rename gecko kconfigs
- Kconfigs in modules/ should not define configs with an SOC_ prefix.
  Furthermore, these options are SDK specific, not SoC specific.
- The simplicity_sdk configs do the same.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-06-17 08:05:45 +02:00
Sylvio Alves
59bf0091b5 drivers: serial: esp32: clear all uhci escape bits
The escape_conf bits reset to 1 and were left set, escaping 0xC0 and
0xDB on the async path even with SLIP off. Clear them, then enable.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-06-17 08:03:15 +02:00
a3e079872c drivers: serial: wch: only report TX ready if the interrupt is enabled
`uart_irq_tx_ready` should report true if transmit is empty
and the transmit interrupt is enabled. This isn't documented in
drivers/uart.h but is required by code such
`subsys/modules/modbus_serial.c` and implemented in drivers such as
`uart_sam.c` and `uart_stm32.c`.

Fix.

Signed-off-by: Michael Hope <michaelh@juju.nz>
2026-06-16 23:15:28 +02:00
Krzysztof Chruściński
92b25f7ea4 drivers: serial: nrfx_uarte: Fix instance initialization priority
If UARTE instance is using GPPI during the initialization and GPPI is
using Ironside then that instance need to be initialized once Ironside
and GPPI is initialized. Delay initialization to POST_KERNEL and
derive init priority from Ironside call init priority (+2 as +1 is
used by GPPI).

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-06-15 12:10:58 -04:00
Daniel Schultz
cc32b6aa15 drivers: serial: aesc: Properly relocate register base
Don't write to "DEVICE_MMIO_GET(dev)". Instead, store the register
base address in the data struct and use it for accessing the
registers later.

Also return a volatile pointer with DEV_UART and change
DEVICE_MMIO_NAMES_x to DEVICE_MMIO_x.

Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
2026-06-12 07:49:34 +02:00
Daniel Schultz
47ec2ef89b drivers: uart: aesc: Fix Copyright Text
Use "SPDX-FileCopyrightText" for the copyright holder.

Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
2026-06-12 07:49:34 +02:00
Manimaran A
0a0f59e576 drivers: serial: mchp_xec: drain TX before suspend
Spin on Transmitter Empty at the top of PM_DEVICE_ACTION_SUSPEND so an
in-flight byte finishes shifting before LD_ACTIVATE is cleared. Without
this, poll_out callers (printk, LOG_MODE_MINIMAL) get their last byte
cut off mid-shift on every suspend, producing garbled console output.
No-op when TX is already idle.

Signed-off-by: Manimaran A <manimaran.a@microchip.com>
2026-06-10 14:54:10 -04:00
Muhammad Waleed Badar
6cad4eec23 drivers: uart: bcm2711: switch to clocks phandle for platform clock
Use the `clocks` phandle to obtain the UART peripheral clock instead
of `clock-frequency` property. Update the binding and BCM2711 DTS
accordingly and rename the driver configuration field from
`clocks` to `pclk`.

Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
2026-06-09 19:58:10 +02:00
Brian Cain
8352b398bd drivers: serial: fix spinlock leak in uart_renesas_rza2m_scif
Add missing k_spin_unlock() on two error return paths in
uart_rza2m_scif_configure():

- Unsupported parity mode (default switch case)
- Baudrate configuration failure

Both paths returned without releasing the spinlock acquired earlier.

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-06-09 10:32:08 +02:00
Brian Cain
55bb93ae1b drivers: serial: fix spinlock and irq leak in uart_rzt2m
Add missing k_spin_unlock() and irq_unlock() in rzt2m_module_start()
error path. When interface_id >= 5 the function returned -ENOTSUP
without releasing either the spinlock or the IRQ lock.

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-06-09 07:14:12 +02:00
Brian Cain
3cb1fbbfdc drivers: serial: fix spinlock leak in uart_neorv32
neorv32_uart_pm_action() returned -ENOTSUP for unsupported PM actions
without releasing the spinlock acquired at function entry. Restructure
to use a single unlock/return path at function exit.

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-06-09 07:12:43 +02:00
Daniel Schultz
290d44743e drivers: serial: uart: Add Interrupt Support
Adds full interrupt-driven UART support behind
CONFIG_UART_INTERRUPT_DRIVEN. Implements the Zephyr UART interrupt
API (FIFO fill/read, TX/RX enable/disable, TX-complete detection,
pending check, callback set). Extends the register map with
tx_trigger, error_pending, and error_enable fields and adds RX FIFO
count and error bit masks. Adds SERIAL_SUPPORT_INTERRUPT to Kconfig.

Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
2026-06-08 21:29:17 -04:00
Etienne Carriere
c9e77a2d60 drivers: serial: stm32: DT_INST_PROP_OR() for optional wakeup_line value
Replace a COND_CODE_1() logic with use of DT_INST_PROP_OR() to get
the wakeup-line DT property for STM32 UART devices.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-06-08 13:55:00 +02:00
Surya Prakash T
05bab75fc0 drivers: serial: renesas_ra_sau: Remove redundant irq_update
Removes the redundant uart_renesas_ra_sau_irq_update function,
as it performs no operations.

Signed-off-by: Surya Prakash T <suryat@aerlync.com>
2026-06-07 19:20:06 +02:00
Fiona Behrens
7a08bc9cbb driver: serial: uart_numicro: Add interrupt driven support
Add support for interrup driven UART for the numicro uart driver
targeting the nuvoton m48x line.

This is mostly copied from the uart_numaker driver with some changes.

Signed-off-by: Fiona Behrens <me@kloenk.dev>
2026-06-05 22:35:10 +02:00
Fiona Behrens
416120f85c driver: serial: Use clock control driver in uart numicro
Use the new scc driver in the uart for the m48x numicro soc.
This removes quite a lot of calls into the nuvoton BSP and replaces
them with functions using the clock driver.

Signed-off-by: Fiona Behrens <me@kloenk.dev>
2026-06-05 22:35:10 +02:00
Fabio Baltieri
61fa460c51 uart_bridge: replace BUILD_ASSERT with min-len/max-len
Replace the BUILD_ASSERT for device count with min-len/max-len.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2026-06-04 23:50:48 +02:00
Sylvio Alves
4867488361 drivers: serial: esp32: flush dma buffers in async path
Flush tx and invalidate rx DMA buffers around UART async DMA
transfers so the CPU and DMA engine see coherent data on SoCs
with an L1 data cache.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-06-03 18:27:15 -04:00
Sylvio Alves
8317efa25c drivers: serial: esp32: add esp32p4 uart support
Add ESP32-P4 to the Espressif UART driver and the USB-serial-JTAG
backend, including the SoC-specific clock source selection
for the P4 UART HAL.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-06-03 18:27:15 -04:00
Guilherme Costa
88e82f4ac2 serial: uart_mcux_lpuart: Handle zero timeout
When enabling RX with a timeout of 0 in the mcux lpuart driver, the
driver silently skipped starting the async work timer, making partial
DMA transmissions fail. This commit handles the scenario by
immediatelly flushing the RX data, if any.

Make it so the async timer for TX is skipped if timeout is 0, disabling
TX timeout.

Signed-off-by: Guilherme Costa <guilhermecosta@stratioautomotive.com>
2026-06-01 12:39:48 -04:00
Guilherme Costa
e3278fc1eb drivers: serial: uart: Cast log parameter to void *
Compiling the mcux lpuart driver with format string validation led to a
runtime warning about pointer types. This commit fixes the issue by
casting the offending parameter to void * as recommended.

Signed-off-by: Guilherme Costa <guilhermecosta@stratioautomotive.com>
2026-06-01 12:39:48 -04:00
Amneesh Singh
9969745801 drivers: update interrupt handling to use "flags" instead of "sense"
Update all drivers to use "flags" instead of "sense" when accessing
interrupt properties from device tree. This aligns with the updated
interrupt controller bindings that now consistently use "flags" as
the cell name for the IRQ type field.

Signed-off-by: Amneesh Singh <amneesh@ti.com>
2026-06-01 12:38:26 -04:00
Steven Chang
09f163b29c drivers: uart: kb106x: TX empty IRQ triggering
- Manually trigger TX IRQ when the buffer is empty to work around the
  hardware limitation where the IRQ is not automatically generated.

Signed-off-by: Steven Chang <steven@ene.com.tw>
2026-06-01 12:37:35 -04:00
Raffael Rostagno
e57da3593d drivers: uart: esp32: Sleep retention
Add sleep retention support for UART driver. When peripheral
power down is enabled for light sleep, register data is lost,
so REGDMA backup is needed to mantein peripheral operational.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2026-05-29 22:05:37 +02:00
Jonathan Elliot Peace
3290b3cd29 drivers: serial: uart_bcm2711: read-modify-write IER bits
The four irq_{rx,tx}_{enable,disable} helpers each wrote a single
constant value to IER -- BIT(N) on enable, ~BIT(N) on disable. As
a result they did not toggle a single bit; they overwrote the
entire register. Two side effects:

* irq_tx_disable() set the RX-enable bit (because ~BIT(1) has bit 0
  set), and vice versa. The expected sequence
      irq_rx_disable(); irq_tx_disable();
  ends with the RX bit on, even though the caller asked for both
  channels to be quiesced.

* On the BCM283x mini-UART, the upper bits of IER carry FIFO-clear
  shortcuts (see BCM2837 ARM Peripherals manual, "AUX_MU_IER_REG").
  Writing 0xfffffffd or 0xfffffffe arbitrarily perturbs them.

Fix: each helper reads IER, sets or clears its own bit, writes
back. The TX/RX-enable side now also preserves the other channel's
state correctly.

Signed-off-by: Jonathan Elliot Peace <jep@alphabetiq.com>
2026-05-29 07:36:27 +02:00
Jonathan Elliot Peace
cbc8cb440f drivers: serial: uart_bcm2711: return -1 from poll_in when no char
The current implementation spins forever waiting for a character and
unconditionally returns 0. The uart_poll_in() API contract is that
the function returns -1 (or another negative value) immediately when
no character is currently available, and 0 only after writing a
received character to *c.

Without this, callers that use the canonical drain pattern --

    while (uart_poll_in(dev, &c) == 0) {
        ;
    }

-- hang. drivers/console/uart_console.c::console_input_init() does
exactly this when registering an input handler, so any application
that calls uart_register_input() (e.g. via Zephyr's console handler
subsystem) can deadlock at startup waiting on idle UART RX.

The fix is to test once and return -1 on the no-char path. The
"got a character" path is unchanged.

Signed-off-by: Jonathan Elliot Peace <jep@alphabetiq.com>
2026-05-29 07:36:17 +02:00
Jordan Yates
5e285c49c2 serial: uart_nrfx_uarte: option to request HFXO
Add the option to explicitly request the HFXO while the UARTE peripheral
is active for nRF54L series devices. While the UARTE peripheral requests
a high frequency clock from the clock controller, both the HFINT and
HFXO oscillators satisfy this request. The problem is that the HFXO
oscillator is required to reach the highest bitrate accuracies (and
mitigate errata 30).

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-05-29 07:31:31 +02:00
Davide Di Lello
0269e4cbaa drivers: uart: infineon: Add UART IRQ update
Re-added irq_update API for UART.
It is required to clean the FIFO status, which flushes
the content correctly.

Signed-off-by: Davide Di Lello <Davide.Dilello@Infineon.com>
2026-05-27 21:34:11 -04:00