Commit graph

1532 commits

Author SHA1 Message Date
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
Hao Luo 3c1fd19d96 drivers: serial: pl011: Add support for Ambiq Apollo3 SoCs UART
Apollo3 SoCs have different UART register design compared with
that of Apollo4 SoCs, we need to change the offset and mask for
the power status check

Signed-off-by: Hao Luo <hluo@ambiq.com>
2024-05-07 18:57:19 +02:00
Hess Nathan 1486259139 coding guidelines: comply with MISRA Rule 20.9
- avoid to use undefined macros in #if expressions

Signed-off-by: Hess Nathan <nhess@baumer.com>
2024-05-06 17:30:26 +01:00
Declan Snyder 9320907fdf drivers: uart_mcux_lpuart: Fix APIs used together
Handle controller instances wanting to use different
API instances, need to change init flow so that they dont
interfere with each other, trick for now is returning
either the interrupt driven or async apis as not enabled
if the other has already been used on that controller.

Previously, there was an issue where enabling CONFIG_UART_ASYNC_API
would overwrite the init even if controller was meant to use
interrupt driven (as kconfig is global to affect all the controllers)

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-04-30 08:53:02 +02:00
Declan Snyder dfe4991a2c Revert "drivers: serial: uart_mcux_lpuart: fix IRQ-driven API with ASYNC_API"
This reverts commit a80fa5163b.

That commit broke the polling API when used with the interrupt driven,
it is completely wrong to disable the receiver from irq_rx_disable,
the uart_basic_api test has been broken on all lpuart platforms because
of this bug.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-04-30 08:53:02 +02:00
Yong Cong Sin 0291c551a2 drivers: use DT_INST_NODE_HAS_COMPAT
Replace occurances of:

  DT_NODE_HAS_COMPAT\(DT_DRV_INST\((.*)\), (.*)\)

With:

  DT_INST_NODE_HAS_COMPAT($1, $2)

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-04-26 20:04:38 +01:00
Jun Lin 458b219879 drivers: uart: npcx: extend the UART baudrate support
1. support the baudrate = 3MHz.
2. add baudrate = 115200 setting when UART source clock = 25/30/48/50 MHz.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2024-04-26 16:13:25 +02:00
Jun Lin 08fedb4a80 drivers: uart: npcx: add asychronous API support
This commit implement the UART asynchronous API mode support.
When the API is used, the UART hardware cooperates with the DMA (MDMA)
module to handle the the data transfer and receiving.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2024-04-26 16:13:25 +02:00
Jun Lin 3ba7874cd5 driver: uart: npcx: fix coding style
Fix the coding style by clang-format tool.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2024-04-26 16:13:25 +02:00
Krzysztof Chruściński 8b96dff2f6 drivers: serial: nrfx_uarte2: Fix error event not being sent
When RX length was 0 and error was reported then UART_RX_STOPPED event
was not sent. Fixing the condition check to ensure that UART_RX_STOPPED
is always generated.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-04-18 11:14:58 +02:00
Krzysztof Chruściński 5a41aa2614 drivers: serial: uart_nrfx_uarte2: Prevent TX in suspend mode
Do not transmit if the device is in suspend mode.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-04-18 11:14:58 +02:00
Krzysztof Chruściński d27842c953 drivers: serial: nrfx_uarte2: Clean error state on rx_enable
Clean error state on re-enabling RX. If previous transmission ended with
an error it should not impact next receiving session.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-04-18 11:14:58 +02:00
Krzysztof Chruściński e10ed057e8 drivers: serial: uart_async_to_irq: Move resetting to disabling function
Move resetting of the receiver state to disabling function so that once
uart is disabled there is no data pending in the module.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-04-16 09:07:55 +02:00
Krzysztof Chruściński 8f89013789 drivers: serial: uart_async_rx: Fix uart_async_rx_reset function
Add missing fields clearing to the resetting function.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-04-16 09:07:55 +02:00
Krzysztof Chruściński 685e6cec9b drivers: serial: nrf: Adapt config dependencies to nrf54h20
DT nodes and compatible had been renamed and Kconfig option was relying
on the names that do not exists.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-04-15 12:53:09 +02:00
Tom Burdick 4180d70439 dma: Fix error_callback enable/disable confusion
Previously the logic was inverted for error_callback_en where 0 was
enablement and 1 was disable. This was likely done so that the default,
sensibly so, was to enable the error callback if possible. A variety of
in tree users had confused the enable/disable value.

Change the name of the flag to error_callback_dis where the default
remains 0 (do not disable the callback!) and correct in tree uses of the
flag where it seemed incorrect.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-04-11 17:08:10 -04:00
TOKITA Hiroshi e678a6247d drivers: serial: rpi_pico: Migrate to pl011 driver
RaspberryPi Pico's UART can be operated with the pl011 driver.
Replace it with this.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-04-10 10:01:25 +02:00
TOKITA Hiroshi e93cf224b6 drivers: serial: pl011: Add err_check function
Implementing err_check function by porting from
rpi_pico implementation.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-04-10 10:01:25 +02:00
TOKITA Hiroshi dd84e8db26 drivers: serial: pl011: Use clock control to determine frequency
If a clock control device is set in the `clocks` property,
it is used to determine the frequency.
If `fixed-clock` is set for the clocks, we use that value as is.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-04-10 10:01:25 +02:00
TOKITA Hiroshi 80b8ef80b3 drivers: serial: pl011: Add capability for handling reset device
Reset the device on initializing if the node inherits
`reset-device.yaml`.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-04-10 10:01:25 +02:00
TOKITA Hiroshi 155fee5924 drivers: serial: pl011: Introduce macros to separate device-dependent code
Introduce the `COMPAT_SPECIFIC_...` macros to determine the function name
from the compatible name.
These macros allow the isolation of device-dependent code in a generic way.

For example, if the compatible name is `ambiq,uart`,
The `COMPAT_SPECIFIC_DEFINE` macro is replaced by `AMBIQ_UART_DEFINE`.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-04-10 10:01:25 +02:00
Lucas Tamborrino fe57a12cf2 drivers: esp32: update to hal_espressif v5.1
Modify necessary drivers to meet updated hal.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2024-04-05 13:39:53 +02:00
Krzysztof Chruściński 7bededbc29 drivers: serial: nrfx_uarte2: Fix re-enabling the receiver
Move providing of the first buffer in uart_rx_enable from that
function to the callback which is called from nrfx_uarte_rx_enable
context. By doing this nrfx_uarte_rx_buffer_set is called when
RX configuration flags are already known to the driver.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-04-05 12:21:58 +02:00
Luis Ubieda f643f3a6cf drivers: serial: bt: Make TX flush non-deferrable
To prevent postponing data flush until filling fifo. Now the flush will
occur at the scheduled time, regardless of subsequent poll_out reqs.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-04-03 20:42:01 -04:00
David Brown f7e64c8703 drivers: serial: rpi_pico: Enable uart FIFO
A few lines above this change explicitly enable the UART FIFO.  Then this
line, goes and disables it.  This seems to be from a workaround where the
parity and stop bits are not coming in correctly in the config.  Fixing
that will be another patch.  But, the FIFO should always be enabled.  This
is visible when trying to use bit rates that are reasonably fast.  Even in
IRQ mode, with a sufficient bit rate, bytes are readily dropped.

Tested on a Sparkfun Promicro rp2040 board.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-04-03 15:38:29 -05:00
Mahesh Mahadevan a9fea59281 soc: nxp: Select the MFD Kconfig when LPFlexcomm is enabled
LPFlexcomm is a MFD device hence select this Kconfig whenever
it is enabled.
Remove the selection from the individual driver Kconfig files.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2024-04-02 21:00:24 -04:00
Luis Ubieda 92e0d0bbfc bluetooth: nus: Change Kconfigs prefix to BT_ZEPHYR_NUS
To prevent future conflicts with NCS's NUS implementation, whose
Kconfig's are prefixed with BT_NUS.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-04-02 10:36:01 +03:00
Fabian Kainka 24c03bfacb serial: uart_native_tty: Polling thread fix
Addresses an issue where attempts to transmit data fail.
The identified cause of this failure is the handling of the
`rx_irq_enable` and `tx_irq_enable` flags. The `else if` handling the
`tx_irq_enable` was replaced by an `if` so both flags can be true,
and both functions can be called. This fix was tested with the
`cellular_modem` example successfully.

Signed-off-by: Fabian Kainka <kainka@cognid.de>
2024-03-27 15:18:11 +00:00
Lukas Gehreke 9e06a8a1e6 drivers: uart_pl011: Implemented runtime configure
Implemented runtime configure functions for the driver.

Signed-off-by: Lukas Gehreke <lk.gehreke@gmail.com>
2024-03-26 11:03:13 -04:00
Krzysztof Chruściński 8bc5111c27 drivers: serial: uart_async_rx: Optimize RAM usage
Since there is only one consumer of the data stored in the buffers,
it is enough to have one read index variable which can be stored in
the data associated with the module and not in the buffer space (where
there is a read index for each buffer).

Additionally, we can safely assume that module works with small buffers
so 127 byte limit is enough. Based on that assumption completed flag
can be stored on a single byte together with write index. After this
change, control data for each buffer takes 1 byte (3 bytes previously).

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-03-26 10:46:02 -04:00
Krzysztof Chruściński 17dc3da35d drivers: serial: uart_async_rx: Fix race condition
There was a wrong order of conditions checking. First indexes were
compared and then completed flag was checked. It was possible that
after checking first condition context is preempted and new data
is written to the buffer and completed flag is set. In that case
both conditions are met but data added in preemption is dropped.
In order to avoid that completed flag must be checked first.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-03-26 10:46:02 -04:00
Krzysztof Chruściński d2bd82eb5f drivers: serial: uart_async_rx: Add return value to consume function
Return availability of free buffers after data is consumed. This
information may be important for the module using uart_async_rx to
schedule next reception if there is a new buffer available.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-03-26 10:46:02 -04:00
Krzysztof Chruściński 65b42260f7 drivers: serial: uart_async_rx: Add buffer release to consuming function
Add buffer releasing to consuming function to allow better buffer
utilization since buffer is available earlier.

Note that releasing in claiming function is still needed as there
are cases when there are empty but completed buffers and those
need to be consumed in claiming phase.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-03-26 10:46:02 -04:00
Krzysztof Chruściński ce3d45375e drivers: serial: uart_async_rx: Remove unused field
Removing a field which was redundant. It was only incremented but
never read.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-03-26 10:46:02 -04:00
Luis Ubieda 3c56af6c87 drivers: serial: bt: Fix Max payload to be transmitted with minimum MTU
As correctly pointed during the initial PR Review, when the MTU-size is
23 the effective payload that can be transferred is MTU-3 = 20. Thus,
this change to be consistent.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-03-25 13:26:27 -05:00
Luis Ubieda 205994b87b drivers: serial: bt: Add UART over NUS Bluetooth driver
Enables usage Bluetooth LE GATT as a serial endpoint to exchange data
using UART APIs. This implementation is compatible with UART Interrupt
Driven APIs and uses the nus-uart device-tree node properties to
configure FIFO buffers for transmitting and receiving. Defining
multiple instances of the driver is possible and it allows implementing
multiple GATT NUS service instances to exchange data as separate serial
endpoints.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-03-22 10:25:37 +01:00
Johan Carlsson 94351ce2ad drivers: uart_mcux_flexcomm: fix invalid use of status bits.
uart flexcomm driver incorrectly used kStatus enum as mask when
checking for errors and enabling the error interrupts.

Signed-off-by: Johan Carlsson <johan.carlsson@teenage.engineering>
2024-03-20 17:18:48 -05:00
Steven Chang 9f22c8951b drivers: uart: initial device driver for ENE KB1200
Add uart driver for ENE KB1200

Signed-off-by: Steven Chang <steven@ene.com.tw>
2024-03-15 09:39:48 +00:00
Mahesh Mahadevan 61d1a711fc drivers: uart: Use the register define instead of enum define
The enum define is not implemented with the same name on all SoC's.
Use the register define instead.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2024-03-13 22:38:46 +00:00
Mahesh Mahadevan bb9386473b dts: nxp_lpuart: Interrupts is no longer a required property
Some NXP SoC's have a FlexComm interface which manages
interrupts.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2024-03-13 22:38:46 +00:00