Commit graph

1871 commits

Author SHA1 Message Date
Pieter De Gendt
92019b1dac emul: Support UART device emulation
Add support to the existing UART emulated bus, to have a client device
emulator.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-07-30 18:28:17 +01:00
Pieter De Gendt
ad63ca284e kconfig: replace known integer constants with variables
Make the intent of the value clear and avoid invalid ranges with typos.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-07-27 20:49:15 +03:00
Pisit Sawangvonganan
a2e0b1d366 drivers: serial: remove '&' when assigning init_fn
Remove address-of operator ('&') when assigning `init_fn`
function pointer in `DEVICE_DT_INST_DEFINE` macro.

This change aims to maintain consistency among the drivers in
`drivers/serial`, ensuring that all function pointer assignments
follow the same pattern.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-07-27 20:48:34 +03:00
Flavio Ceolin
5822267c23 serial: uart_async_rx: Avoid possible division by zero
Ensures that config->but_cnt is not zero.

Fixes #66800
CID #338107

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-07-27 15:14:26 +03:00
Fabio Baltieri
ef14c9b867 lib: os: add a header for printk hook functions
Add a zephyr/printk.h header for the __printk_hook functions, these are
currently manually declared by all console drivers for no good reason.

Move the documentation into the header and also unify the way that
console drivers call the function.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-07-27 10:41:01 +03:00
Simon Guinot
740d7f735e drivers: serial: lpc11u6x: allow to configure data polarity
This patch adds support for the rx-invert and tx-invert device-tree
properties to the uart_lpc11u6x driver for USARTs 1, 2, 3 and 4.

Note that this feature is not supported by USART 0.

Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
2024-07-12 06:29:56 -04:00
Frank Lin
6fc525cc20 drivers: serial: uart_cdns: fix interrupt driven
Fix interrupt driven for shell

Signed-off-by: Frank Lin <linfrank@meta.com>
2024-07-09 19:45:18 -04:00
Omer Gozderesi
1fc97561ed config: esp32: configurable UART FIFO thresholds
The existing configuration of the ESP32 UART FIFO thresholds
was fixed, leading to inefficiencies in handling
Modbus RTU packages exceeding this size.
This commit introduces two new Kconfig options,
allowing users to adjust the esp32 fifo thresholds as needed.
fixes #74311

Signed-off-by: Omer Gozderesi <omer.gozderesi@enda.com>

config: esp32:  configurable UART FIFO thresholds

The existing configuration of the ESP32 UART FIFO thresholds
was fixed, leading to inefficiencies in handling
Modbus RTU packages exceeding this size.
This commit introduces two new Kconfig options,
allowing users to adjust the esp32 fifo thresholds as needed.
fixes #74311
Signed-off-by: Omer Gozderesi <omer.gozderesi@enda.com>
2024-07-09 15:24:02 -04:00
Furkan Akkiz
abef5a3c86 drivers: serial: uart_max32: Fixing bugs and code optimizations
- Defined 'api_configure' function outside of
'CONFIG_UART_USE_RUNTIME_CONFIGURE' macro because it is the only
configuration function and used in device initialization function.
- Removed unnecessary 'IF_ENABLED' part.

Signed-off-by: Furkan Akkiz <hasanfurkan.akkiz@analog.com>
2024-07-04 08:17:27 +02:00
Xudong Zheng
19c1f9f6c5 drivers: serial: pl011: add support for hardware flow control
Flow control will be enabled for UART if hw-flow-control is set.

Signed-off-by: Xudong Zheng <7pkvm5aw@slicealias.com>
2024-07-01 16:08:23 -04:00
Jordan Yates
91f8c1aea9 everywhere: replace #if IS_ENABLED() as per docs
Replace `#if IS_ENABLED()` with `#if defined()` as recommended by the
documentation of `IS_ENABLED`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-28 07:20:32 -04:00
The Thanh. Nguyen
f93f801c65 driver: serial: Add serial driver support for Renesas RA8 devices
Add implementation of sci_b_uart for Renesas RA device

Signed-off-by: The Thanh. Nguyen <the.nguyen.yf@renesas.com>
2024-06-26 13:36:14 -04:00
Duy Nguyen
ee4613a3a6 boards: arm: Add initial support for EKRA8M1
Add support for the EK RA8M1 board
This board is using Renesas RA8M1 MCU.

Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
2024-06-26 13:36:14 -04:00
Sadik Ozer
ada6ab25ee drivers: serial: Update MAX32xxx tx and rx ready functions
Update rx and tx ready function as per of its description.
For tx_ready if tx interrupt enabled AND tx fifo is not full
For rx_ready if rx interrupt enalbed AND rx fifo not empty

Signed-off-by: Sadik Ozer <sadik.ozer@analog.com>
2024-06-26 09:00:26 -04:00
Lingao Meng
302422ad9d everywhere: replace double words
import os
import re

common_words = set([
    'about', 'after', 'all', 'also', 'an', 'and',
     'any', 'are', 'as', 'at',
    'be', 'because', 'but', 'by', 'can', 'come',
    'could', 'day', 'do', 'even',
    'first', 'for', 'get', 'give', 'go', 'has',
    'have', 'he', 'her',
    'him', 'his', 'how', 'I', 'in', 'into', 'it',
    'its', 'just',
    'know', 'like', 'look', 'make', 'man', 'many',
    'me', 'more', 'my', 'new',
    'no', 'not', 'now', 'of', 'one', 'only', 'or',
    'other', 'our', 'out',
    'over', 'people', 'say', 'see', 'she', 'so',
    'some', 'take', 'tell', 'than',
    'their', 'them', 'then', 'there', 'these',
    'they', 'think',
    'this', 'time', 'two', 'up', 'use', 'very',
    'want', 'was', 'way',
    'we', 'well', 'what', 'when', 'which', 'who',
    'will', 'with', 'would',
    'year', 'you', 'your'
])

valid_extensions = set([
    'c', 'h', 'yaml', 'cmake', 'conf', 'txt', 'overlay',
    'rst', 'dtsi',
    'Kconfig', 'dts', 'defconfig', 'yml', 'ld', 'sh', 'py',
    'soc', 'cfg'
])

def filter_repeated_words(text):
    # Split the text into lines
    lines = text.split('\n')

    # Combine lines into a single string with unique separator
    combined_text = '/*sep*/'.join(lines)

    # Replace repeated words within a line
    def replace_within_line(match):
        return match.group(1)

    # Regex for matching repeated words within a line
    within_line_pattern =
	re.compile(r'\b(' +
		'|'.join(map(re.escape, common_words)) +
		r')\b\s+\b\1\b')
    combined_text = within_line_pattern.
		sub(replace_within_line, combined_text)

    # Replace repeated words across line boundaries
    def replace_across_lines(match):
        return match.group(1) + match.group(2)

    # Regex for matching repeated words across line boundaries
    across_lines_pattern = re.
		compile(r'\b(' + '|'.join(
			map(re.escape, common_words)) +
			r')\b(\s*[*\/\n\s]*)\b\1\b')
    combined_text = across_lines_pattern.
		sub(replace_across_lines, combined_text)

    # Split the text back into lines
    filtered_text = combined_text.split('/*sep*/')

    return '\n'.join(filtered_text)

def process_file(file_path):
    with open(file_path, 'r', encoding='utf-8') as file:
        text = file.read()

    new_text = filter_repeated_words(text)

    with open(file_path, 'w', encoding='utf-8') as file:
        file.write(new_text)

def process_directory(directory_path):
    for root, dirs, files in os.walk(directory_path):
        dirs[:] = [d for d in dirs if not d.startswith('.')]
        for file in files:
            # Filter out hidden files
            if file.startswith('.'):
                continue
            file_extension = file.split('.')[-1]
            if
	file_extension in valid_extensions:  # 只处理指定后缀的文件
                file_path = os.path.join(root, file)
                print(f"Processed file: {file_path}")
                process_file(file_path)

directory_to_process = "/home/mi/works/github/zephyrproject/zephyr"
process_directory(directory_to_process)

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2024-06-25 06:05:35 -04:00
Eric Holmberg
18ebfe59d0 drivers: serial: esp32_usb: fix interrupt-enable race condition
After enabling interrupts, serial_esp32_usb_irq_tx_enable() calls the
interrupt handler to handle any old events that occurred while interrupts
were disabled.  However, this happens in the callers context, so if an
interrupt arrives during the call, it will call the interrupt handler again
resulting in corruption if the interrupt handler is not reentrant.

Fixes #74569

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2024-06-24 09:47:05 +02:00
Nazar Palamar
b6d0958ab7 drivers: serial: CAT1 UART driver: fix HW flow control
fix HW flow control:
- remove cyhal_uart_enable_flow_control
- added Cy_SCB_UART_EnableCts if cfg->flow_ctrl = true
  (required to enable hw flow control)
- configuration of CTS/RTS done by pincntr driver

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
2024-06-24 09:46:01 +02:00
Jordan Yates
07870934e3 everywhere: replace double words
Treewide search and replace on a range of double word combinations:
    * `the the`
    * `to to`
    * `if if`
    * `that that`
    * `on on`
    * `is is`
    * `from from`

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-22 05:40:22 -04:00
Ioannis Damigos
b9dab49b13 drivers/smartbond: Remove atomic flags from drivers
Remove atomic flags from drivers that use balanced calls
for PM locking.

Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
2024-06-21 08:45:10 -04:00
Piotr Kosycarz
4d01353640 drivers: serial: fix cfg.baudrate may be used uninitialized
drivers/serial/uart_async_to_irq.c: In function 'get_rx_timeout':
drivers/serial/uart_async_to_irq.c:51:26:
warning: 'cfg.baudrate' may be used uninitialized
   51 |                 baudrate = cfg.baudrate;
      |                 ~~~~~~~~~^~~~~~~~~~~~~~
drivers/serial/uart_async_to_irq.c:45:28: note: 'cfg' declared here
   45 |         struct uart_config cfg;

Signed-off-by: Piotr Kosycarz <piotr.kosycarz@nordicsemi.no>
2024-06-20 12:04:02 -04:00
Ioannis Damigos
0a0bccabd8 drivers/smartbond: Fix PM device runtime support
Removed PM device runtime support from drivers in PD_SYS domain.

Update the rest device drivers to call pm_device_runtime_get/put()
functions when CONFIG_PM_DEVICE_RUNTIME is enabled.

Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
2024-06-18 14:36:38 -04:00
Lucas Tamborrino
a62423f391 drivers: Update to add support for esp32c6
Changes to bring support for esp32c6 SoC.
- clock control
- gpio
- pinctrl
- serial
- timer

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2024-06-14 18:51:46 -04:00
Yong Cong Sin
0103c56dd6 zephyr: remove deprecated headers
These headers have been deprecated for > 2 full releases,
let's remove them to keep them out of v3.7.0 LTS.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-14 19:12:00 +02:00
Thibo Verheyde
ddef306394 drivers: serial: esp32: Fix next buffer release on rx disable
Set event data rx buffer as next buffer instead of current buffer.

Signed-off-by: Thibo Verheyde <thibo@dptechnics.com>
2024-06-14 15:38:02 +02:00
Daniel Leung
e98e4ed067 serial: convert kconfig source to rsource
Simple cosmetic change to convert all the source commands
to rsource so that includes are relative to driver/serial.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-14 15:37:31 +02:00
Maureen Helm
595fdb6089 drivers: serial: Set default baud rate and data bits in max32 driver
The uart-controller devicetree binding declares current-speed and
data-bits properties as optional, but the max32 uart driver failed to
build if they weren't defined. Fix the driver by falling back to
commonly used values for these properties.

Signed-off-by: Maureen Helm <maureen.helm@analog.com>
2024-06-13 17:52:37 +02:00
Nazar Palamar
c0be06be02 soc: psoc6: fix build error when CONFIG_UART_INTERRUPT_DRIVEN
Fix build error when CONFIG_UART_INTERRUPT_DRIVEN is enabled
see details: issues/74004

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
2024-06-12 12:50:28 -04:00
Nazar Palamar
cc4e12e09b drivers: serial: Update Infineon CAT1 UART driver
Set RTS/CTS flow control pins as NC in cyhal
UART object so cyhal will skip to try initialize
those pins.

Initialization of RTS/CTS is done via
PINCNTRL driver.

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
2024-06-12 14:21:01 +03:00
Ruben Völl
2c82681bec driver: uart: emul: Add support for async UART API
As it is up to a driver implementation if a partial filled buffer is
released, this behavior can be configured during runtime to allow testing
for this edge case.

Signed-off-by: Ruben Völl <ruben.voell@grandcentrix.net>
2024-06-11 20:05:24 +03:00
Ruben Völl
e5dd2376b3 drivers: uart: emul: Remove uart_emul_work struct
This structure is bad style and not needed. Instead get the surrounding
`struct uart_emul_data` with `CONTAINER_OF()` directly.

Signed-off-by: Ruben Völl <ruben.voell@grandcentrix.net>
2024-06-11 20:05:24 +03:00
Krzysztof Chruściński
79c93dd5ec drivers: serial: Add gpio management to low power mode
When low power mode is enabled then whenever UARTE is not active,
driver attempts to put the peripheral into the lowest power state
by stopping and disabling UARTE. However, it did not put pins into
sleep state which could lead to increased current consumption.
Adding pins state handling to the low power mode.

Pins are put into sleep state only if CONFIG_PM_DEVICE=y.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-06-07 19:07:56 -04:00
Krzysztof Chruściński
d07b13dbc2 drivers: serial: nrfx_uarte: Allow use of legacy shim on RISCV cores
Legacy shim takes less flash so it should be a first choice on cores
with less code memory (like RISCV cores on nrf54h20). Adding new
instances support to the legacy shim.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-06-05 01:37:57 -07:00
Nazar Palamar
7c3b66eac8 soc: psoc6: update pinctrl for PSoC6 MCU (legacy)
update pinctrl for PSoC6 MCU (legacy)

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
2024-06-04 16:35:39 +02:00
Johan Carlsson
bc2aba157b drivers: uart_mcux_flexcomm: remove incorrect dma_slot.
a change in the dma driver exposed that the dma_slot was incorrectly
set in the uart driver. this change is needed for async uart on lpc55
to work.

Signed-off-by: Johan Carlsson <johan.carlsson@teenage.engineering>
2024-05-29 10:48:44 -07:00
Sadik Ozer
0480b2625b drivers: Add MAX32690 uart driver
UART driver for MAX32690

Co-authored-by: Okan Sahin <okan.sahin@analog.com>
Co-authored-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
Signed-off-by: Sadik Ozer <sadik.ozer@analog.com>
2024-05-29 07:30:12 +02:00
Yong Cong Sin
bbe5e1e6eb build: namespace the generated headers with zephyr/
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.

Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.

Updated the includes path of in-tree sources accordingly.

Most of the changes here are scripted, check the PR for more
info.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 22:03:55 +02:00
Pisit Sawangvonganan
f503b7a26d drivers: serial: stm32: replace config parameter with usart
Updated function parameters from `const struct uart_stm32_config *config`
to `USART_TypeDef *usart`. This change reduces the level of pointer
indirection, which minimizes repeated dereferencing and helps reduce
the overall code size.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-05-28 09:49:09 +02:00
Pisit Sawangvonganan
86e0fe13e1 drivers: serial: stm32: reduce pointer level from config->usart to usart
This change reduces the level of pointer indirection, which minimizes
repeated dereferencing and helps reduce the overall code size.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-05-28 09:49:09 +02:00
Declan Snyder
938050c7ce drivers: lpuart: Fix async configure
Fix async configure function not being called
when the irq driven api is not used, which
both causes a build warning and would not
work at runtime.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-05-18 15:50:11 +03:00
Ayush Kothari
13dfd86616 Driver: Add pin inversion to Esp32 Uart
Additional properties are added to esp32 uart to allow
for signal inversion.

Signed-off-by: Ayush Kothari <ayush@croxel.com>
2024-05-14 18:21:27 -04:00
Alberto Escolar Piedras
c1a39f31b2 driver: uart: native: fix stop_bits/databits mix
Correct a trivial bug and doxygen documentation error
in which data_bits was missused instead of stop_bits.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Signed-off-by: Mateusz Grzywacz <amateusz.grzywacz@gmail.com>
2024-05-14 18:19:11 -04:00
Luis Ubieda
413518e0c8 serial: bt: Set configurable options for the NUS Work-queue
Default priority set to Main Thread's and Stack-size set to 1KiB. This
should still allow for the System work-queue, considering this
Work-queue could be temporarily blocked on BT TX commands.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-05-13 16:17:58 -04:00
Luis Ubieda
b1913fb47e drivers: serial: bt: Use dedicated Workqueue
Stop relying on the system workqueue, as the BT TX APIs should
potentially block and now by design this will not work with the
Bluetooth Stack (for good reasons). Now the UART NUS driver has a
dedicated workqueue, which all NUS instances share.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-05-13 16:17:58 -04:00
Abderrahmane Jarmouni
e783aafdd0 drivers: uart_stm32: add DCache support in async DMA mode
Adapt the driver to verify if DMA buffers are located in noncacheable
memory when DCache is activated, in order to avoid cache coherency issues.
This is required until manual cache coherency management is implemented.

Signed-off-by: Abderrahmane Jarmouni <abderrahmane.jarmouni-ext@st.com>
2024-05-13 16:09:20 -04:00
Hess Nathan
958a4505bd coding guidelines: comply with MISRA Rule 12.1.
-added parentheses verifying lack of ambiguities

Signed-off-by: Hess Nathan <nhess@baumer.com>
2024-05-13 16:05:53 -04:00
Grzegorz Swiderski
24ce3f4182 drivers: serial: nrfx: Update Kconfig dependencies for RX cache
Two Kconfig symbols were tied to a board-specific DT nodelabel - namely
the `NRFX_UARTE_CONFIG_RX_CACHE_ENABLED` and `UART_<n>_RX_CACHE_SIZE`
were tied to `shared_ram3x_region` - but this is not necessary.

That DT node is where the UARTE driver RX/TX cache buffers are placed
in the default nRF54H20 DK memory map, but on another board, they could
be located somewhere else.

The exact memory sub-regions used for this purpose are indicated using
the `memory-regions` property on each UARTE instance, which should be
generic enough already, so let's use that instead.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2024-05-13 16:05:39 -04:00
Jerzy Kasenberg
961959fc5f drivers: serial: Smartbond: add support DTR line wakeup
This change allows to use DTR line driven from external serial port
that when active (low) will prevent UART device from going to sleep.
It will also wake up platform when DTR line becomes active.

DTR line is often activated in serial port connected to host computer
when operating system opens serial device like COMx for Windows
or /dev/ttyACMx /dev/ttyUSBx for Linux based systems.

DTR line (specified in device tree) will be used by WAKEUP and PDC
controllers (via GPIO driver) to handle DTR line changes.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
2024-05-12 17:03:17 -04:00
Jerzy Kasenberg
f10b77364a drivers: serial: Smartbond: add support RX line wakeup
This change allows to wake up UART from sleep mode when
low level on inactive UART is detected during platform sleep.

Timeout can be specified for each UART separately in device tree.
If one of the UARTs is selected as console sleep timeout is taken
from Kconfig same way other platform configure same functionality
using CONFIG_UART_CONSOLE_INPUT_EXPIRED_TIMEOUT

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
2024-05-12 17:03:17 -04:00
Andrzej Kaczmarek
e24c6ce721 drivers: serial: smartbond: Add PM for UART
This is initial version that implements device power
management support when configured in Kconfig files.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2024-05-12 17:03:17 -04:00
Peter van der Perk
7adc4b689b drivers: serial: mcux lpuart add (tx/rx)invert and single wire
Adds device tree definitions to enable tx/rx invert and singlewire modes

Signed-off-by: Peter van der Perk <peter.vanderperk@nxp.com>
2024-05-10 18:25:03 -04:00