Commit graph

1871 commits

Author SHA1 Message Date
Andriy Gelman
041f9821ca drivers: xmc4xxx_uart: Delay transmit interrupt until byte is sent out
Generate the Tx service request after the symbol is shifted out of the
UART. This is useful when the UART is connected to an RS485 transducer
which has a separate transmit enable gpio/line. Hence it's important
to know when the transmission actually finishes so that the drive
enable line can be disabled.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2024-11-16 14:02:43 -05:00
McAtee Maxwell
2fe4a37f38 Documentation: Update documenation for Infineon boards
-Update formatting and contents of index.rst for cy8ckit_062s4
	-Update formatting and contents of index.rst for cy8ckit_064s0s2_4343w
	-Update formatting and contents of index.rst for cy8cproto_062_4343w
	-Update formatting and contents of index.rst for cy8cproto_063_ble
	-Update formatting and contents of index.rst for xmc45_relax_kit
	-Update formatting and contents of index.rst for xmc47_relax_kit
	-Change all instances of "PSoC" to "PSOC" for infineon platforms

Signed-off-by: McAtee Maxwell <maxwell.mcatee@infineon.com>
2024-11-14 20:36:38 -06:00
Aksel Skauge Mellbye
7f8b531d4c drivers: serial: gecko: Fix build error on Series 0
Series 0 does not have the TXIDLE status flag. The closest equivalent is
TXC, but it isn't set until the first transmission completes, and is
therefore not safe to use in PM suspend without also separately keeping
track of whether the driver has ever initiated a transmission. For now,
disable the TXIDLE check on devices that don't support it as a minimal
fix for the observed build error. This is effectively equivalent to
reverting the addition of PM support for these devices only. Since these
devices don't have a low-power system timer implementation anyway, the
lack of PM handling does not hurt anything.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2024-11-14 11:01:17 -06:00
Bernardo Perez Priego
b6b8eeedf0 serial: mchp_xec: Fix uart_xec_irq_tx_complete function
This function is only checking for current byte being transmitted.
This patch ensures that function returns `1` until TX is disabled and
no byte is being transmitted.

Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com>
2024-11-08 15:55:52 -06:00
Raymond Lei
209cb8157a drivers: serial: lpuart: Enable SG mode of LPUART
New implemented eDMA loop SG mode can be used to lpuart driver to fix
the conflict of "Done" bit issue which cause uart_async_api test failed
when SG mode is enabled.

Also, this loop SG mode works well even with a high bandrate(test done
on 2000000bps).
Fixes: #78291

Signed-off-by: Raymond Lei <raymond.lei@nxp.com>
2024-11-08 13:57:29 -06:00
Jordan Yates
60442a221a modules: segger: remove mutex locking
Remove mutex locking in favour of the standard IRQ locking mechanism.
The primary problem with the mutex implementation is that mutex locking
is forbidden in ISR's. This means that any logging from an interrupt
context (e.g. LOG_PANIC in an exception handler), will itself trigger
another assertion due its attempt to use a mutex.

Furthermore, mutexes are a relatively heavyweight locking scheme, which
doesn't necessarily make sense in the context of extremely short locking
periods that would be expected from RTT.

This change aligns Zephyr with the default RTT locking scheme, which
uses interrupt masking to perform access control.

Resolves #79403.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-11-07 11:06:45 -08:00
Jun Lin
69e85b25fe board: npcx: remove CONFIG_PINCTRL from defconfig of npcx boards
The CONFIG_PINCTRL is removed from the board's defconfig files.
Drivers which use pin control function should add "select PINCTRL"
in their Kconfig files.

Fixes #78619

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2024-11-07 08:59:14 -08:00
Zheng Wu
f59e2477ba drivers: serial: fix potential overflow in fifo_fill and fifo_read
Change the type of num_tx/num_rx to avoid overflow.

Fixes #80599

Signed-off-by: Zheng Wu <ken4647@outlook.com>
2024-11-06 10:06:06 -08:00
Thao Luong
c66dcd52db drivers: Select PINCTRL for renesas RA drivers
Select PINCTRL for drivers: adc, i2c, pwm, serial and spi

Signed-off-by: Thao Luong <thao.luong.uw@renesas.com>
2024-11-06 09:59:32 -08:00
Gerson Fernando Budke
0cc8f93e8a soc: atmel: Drop PINCTRL from Kconfig.defconfig
This Kconfig has wrongly been added to defconfig files. It is not the
right place for it. It has never been the right place for it. Drivers
that need it should select the symbol in their Kconfig entries. Drop
PINCTL from Kconfig.defconfig and add proper select at Kconfig.sam*.

Fixes #78619

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2024-11-04 13:43:26 -06:00
Gerson Fernando Budke
52d21d7bf0 soc: gd32: Drop PINCTRL from Kconfig.defconfig
This Kconfig has wrongly been added to defconfig files. It is not the
right place for it. It has never been the right place for it. Drivers
that need it should select the symbol in their Kconfig entries. Drop
PINCTL from Kconfig.defconfig and add proper select at Kconfig.gd32.

Fixes #78619

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2024-11-04 13:40:42 -06:00
Gerard Marull-Paretas
b6d45423c6 drivers: serial: nrfx_uarte: set/clear pins retention
When GPD is managed by pinctrl, pins retention needs to be controlled by
the driver to avoid glitches.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-11-01 12:10:12 -05:00
Ian Morris
adced0c29b drivers: serial: fix renesas ra sci uart hardware flow control enable
Fixed typo in Renesas RA SCI UART configuration that was preventing
hardware flow control from being enabled.

Signed-off-by: Ian Morris <ian.d.morris@outlook.com>
2024-10-29 16:01:38 -07:00
Krzysztof Chruściński
da53adfc56 drivers: serial: uart_async_to_irq: Fix uart_irq_tx_complete
uart_irq_tx_complete is implemented by z_uart_async_to_irq_irq_tx_ready
which changed recently (5bd53b6e2) to return positive value that may be
bigger than 1. uart_irq_tx_complete shall not return value bigger
than 1.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-10-29 07:10:08 -05:00
Krzysztof Chruściński
ee1cbf063c drivers: serial: nrfx_uart: Fix poll_out for low baudrates
uart_poll_out had 1 ms timeout which is too short for lower baudrates.
Increase to 10 ms.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-10-29 07:07:27 -05:00
Krzysztof Chruściński
9ccaf9b5bd drivers: serial: nrfx_uarte: Minor code size optimization
Optimize function which enables UARTE peripheral. It is called
only when interrupts are locked so data->flags does not require
atomic operation. Use standard logical operations so save few
bytes.

Simplify uarte_disable_locked.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-10-26 03:54:11 +01:00
Krzysztof Chruściński
7e94fca0bd drivers: serial: nrfx_uarte: Use legacy shim by default
So far new platforms did not use legacy shim but it shall
be now a default uart shim for all platforms.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-10-26 03:54:11 +01:00
Krzysztof Chruściński
68903ca8dd drivers: serial: nrfx_uarte: Improve RX FIFO flushing workaround
Improved a workaround. When FIFO is not empty then FLUSHRX
task will generate RXSTARTED event to indicated that DMA transfer
was started. This property can be used to detect when FIFO was
not empty and workaroud a HW bug where RX.AMOUNT register is not
updated after flushing empty FIFO.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-10-26 03:54:11 +01:00
Krzysztof Chruściński
3ce19da43b drivers: serial: nrfx_uarte: Add runtime PM
Add runtime PM to the driver. When asynchronous or interrupt
driven API is used, there are 3 independent paths for enabling
the device: RX, TX and TX poll_out. TX poll_out requires special
handling because number of poll_out calls does not need to much
number of TXSTOPPED interrupts. To handle that special flag is
added. For standard RX and TX is simpler.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-10-26 03:54:11 +01:00
Krzysztof Chruściński
cfc87dab75 drivers: serial: nrfx_uarte: Remove unused element from a structure
Remove aborted flag from uarte_async_rx structure. Flag is not
used.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-10-26 03:54:11 +01:00
Krzysztof Chruściński
a98bde993e drivers: serial: nrfx_uarte: Add missing closing bracket
A code ifdefed by UARTE_BAUDRATE_RETENTION_WORKAROUND was missing a
closing bracket. It was missed because CI did not compile any target
that is applying this workaround and enables code compilation.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-10-26 03:54:11 +01:00
Aksel Skauge Mellbye
00378b56ec drivers: serial: gecko: Add device power management
Add basic device power management to USART driver. The initial
implementation only ensures that the TX FIFO is flushed before
allowing the system to go to sleep by polling the TXIDLE status
register.

This fixes an issue where the last 1-2 characters would be lost
if transmitted immediately before going to deep sleep.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2024-10-25 14:09:00 +02:00
Pisit Sawangvonganan
3ca71c94df drivers: serial: ra_sci: add missing break in callback_adapter
Added missing `break` statement in `uart_ra_sci_callback_adapter`
for the `UART_EVENT_RX_COMPLETE` case.
Without it, `async_evt_rx_err()` would be called, which is not
the desired operation.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-10-25 13:50:55 +02:00
Pisit Sawangvonganan
f44690795f drivers: serial: ra_sci: revise switch-case in callback_adapter
Unified switch-case usage in `uart_ra_sci_callback_adapter` to use
`break` instead of `return`.
Typically, a `break` is used in switch-case statements unless an early
return is necessary, in which case `return` is appropriate.

For this case, using a `break` statement is the more suitable choice.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-10-25 13:50:55 +02:00
Andrew Davis
9d0da02fbd soc: ti: k3: Select PINCTRL in UART driver not Kconfig.defconfig
The default configuration for PINCTRL should not be set with
the other default configurations in .defconfig, instead select
a default value as part of defining the UART driver.

Signed-off-by: Andrew Davis <afd@ti.com>
2024-10-23 11:23:18 +02:00
Reto Schneider
f81c1de130 drivers: serial: Sort CMake and Kconfig files alphabetically
By sorting the lines alphabetically, merge conflicts can be reduced.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2024-10-22 18:29:53 -04:00
Michal Simek
7c809b9945 serial: xilinx: uartlite: switch to DT_INST_IRQN_BY_IDX
Use DT_*IRQN helper to get the IRQ number on systems with multi-level
interrupt configuration instead of IRQ number on particular interrupt
controller.

Signed-off-by: Michal Simek <michal.simek@amd.com>
2024-10-22 20:39:12 +02:00
Krzysztof Chruściński
317de0c6de drivers: serial: nrfx_uarte: Add lock to uart_rx_disable
Add lock to fix race when uart_rx_disable is interrupted by RXTO
event which lead to driver state corruption.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-10-21 18:40:57 -05:00
Krzysztof Chruściński
5eaafbaf99 drivers: serial: nrfx_uarte: Add workaround for BAUDRATE register
On uart120 BAUDRATE register is not retained when ENABLE=0 and
because of that BAUDRATE must be set after enabling. Add workaround
to the driver.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-10-21 18:40:57 -05:00
Krzysztof Chruściński
7735302e06 drivers: serial: nrfx_uarte: Improve RX FIFO flush workaround
Add configurable magic byte instead of fixed 0xAA. In some cases, it
is known that certain bytes are less likely in the transmission and
picking specific magic byte may reduce probability of failure of
detection of the correct amount of flushed data.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-10-21 18:40:57 -05:00
Krzysztof Chruściński
9517106899 drivers: serial: nrfx_uarte: Add support for DMM and cache
Add support for DMM which manages cache and dedicated memory spaces.
Added support for data cache for buffers which are not DMM managed.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-10-21 18:40:57 -05:00
Yong Cong Sin
b9df2bed64 drivers: uart: ns16550: add support for Synopsys DesignWare 8250
Extended functionality of the current driver to support
Synopsys DesignWare 8250 UART.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-10-17 10:48:02 -04:00
Yong Cong Sin
b0a872c908 drivers: uart: ns16550: refactor read into a function
Refactor the char read into a function, check for availability
before reading.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-10-17 10:48:02 -04:00
Yong Cong Sin
1d571fff4c drivers: serial: ns16550: rename config to uart_ns16550_dev_config
Rename `uart_ns16550_device_config` to `uart_ns16550_dev_config` so
that it looks consistent with the device data structure.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-10-17 10:48:02 -04:00
Krzysztof Chruściński
1f96e62397 drivers: serial: nrfx_uarte: Add support for frame timeout
Frame timeout is a hardware feature present in newer versions
of UARTE (e.g. in NRF54X platforms) for detecting idle state
on RX line and ending RX after configurable timeout.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-10-17 10:47:32 -04:00
Krzysztof Chruściński
399a235653 drivers: serial: nrfx_uarte: Rework driver to support new features
Rework driver to support new way of asynchronous RX handling.
Previously RX was handled in two modes: using RXDRDY interrupt for byte
counting or TIMER + PPI. Both modes had flaws. RXDRDY interrupt mode
could miscalculated amount of received bytes when interrupt was not
handled on time. Data was not lost but was not reported on time that
could lead to issues. PPI+TIMER mode requires additional resources
thus it was not the default mode. Often user was not aware of that
option and was expiriencing driver RX faults.

New RX mode is switching buffers when there is new data (RXDRDY event
not set for given amount of time). It does not require additional
resources to get precise byte counting. Additionally, this is in line
with new UARTE feature (RX frame timeout) which is present in nRF54X
devices. The behavior of the driver is the same for legacy devices
and new one. For legacy devices k_timer periodic interrupts are used
to check if there are any new bytes and it is not needed when RX frame
timeout is present.

Improved RX mode is enabled by default
(CONFIG_UART_NRFX_UARTE_ENHANCED_RX=y) but legacy modes are still
available though not recommended to be used.

Note that new RX mode (CONFIG_UART_NRFX_UARTE_ENHANCED_RX=y) behaves
a bit different because timeout always triggers switch of buffers
which means that there will be no UART_RX_RDY events with non-zero
offset. It also means that every UART_RX_RDY will be followed by
UART_RX_BUF_RELEASED.

After rework, driver is recommended to be used for all platforms as it
performs much better and takes much less code than the second UART shim
available for Nordic devices.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-10-17 10:47:32 -04:00
Krzysztof Chruściński
d82808ea9b drivers: serial: nrfx_uarte: Refactor to use RX async struct pointer
Refactor RX asynchronous API function to use a pointer to the RX
async data structure instead of top level data structure pointer.
It improves readability with more concise code.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-10-17 10:47:32 -04:00
Chang Feng
2e93bcf2d7 driver: serial: gd32: add irq_update
Add missing api irq_update for gd32.

Signed-off-by: Chang Feng <chang_196700@hotmail.com>
2024-10-16 09:57:05 +02:00
Emilio Benavente
82a192c8a9 boards: nxp: Removing CONFIG_PINCTRL from the boards defconfig
The Drivers using Pinctrl should be turning Pinctrl on
this should not be the responsibility of the board. This
commit removes CONFIG_PINCTRL from the boards side for nxp boards.

Signed-off-by: Emilio Benavente <emilio.benavente@nxp.com>
2024-10-15 19:09:45 -04:00
Hake Huang
fb1ffff7d3 driver: uart: uart_mcux_lpuart fix issues in async api
1. optimized the logic for buffer usage in async api
2. skip timeout flush when the remaining counts is 0,
   as this will trigger dma_callback to process.
3. remove scatter mode, as we are not using this mode
4. trigger after dma_reload.

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2024-10-15 19:09:19 -04:00
Tim Lin
7fa962589f ITE: it8xxx2: Remove CONFIG_PINCTRL from soc defconfig file
The driver Kconfig determines whether pinctrl is enabled
instead of soc defconfig.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-10-15 13:52:55 +02:00
Ioannis Damigos
6c6a1e550c da1469x: Remove CONFIG_PINCTRL from all defconfig files
Remove CONFIG_PINCTRL from all defconfig files.

Fixes #78619

Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
2024-10-08 16:57:41 +02:00
Pisit Sawangvonganan
640a2ade8b drivers: serial: ra8_sci_b: adjust return usage in void functions
For code clarity, this commit adjusts the use of `return` statements
in functions with a void return type by:
- Remove unnecessary `return` statements when
  they don't affect control flow.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-10-07 18:42:58 +02:00
Pisit Sawangvonganan
626918588d drivers: serial: ra8_sci_b: revise switch-case in callback_adapter
Unified switch-case usage in `uart_ra_sci_b_callback_adapter` to use
`break` instead of `return`.
Typically, a `break` is used in switch-case statements unless an early
return is necessary, in which case `return` is appropriate.

For this case, using a `break` statement is the more suitable choice.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-10-07 18:42:58 +02:00
Ian Morris
627c33292a boards: mikroe: remove CONFIG_PINCTRL from defconfig of RA4M1 clicker
This PR fixes #78619 for the Mikroe RA4M1 Clicker board.

Signed-off-by: Ian Morris <ian.d.morris@outlook.com>
2024-10-05 14:05:48 -04:00
Yong Cong Sin
52a202309b zephyr: bulk update to DT_NODE_HAS_STATUS_OKAY
Change instances of:

DT_NODE_HAS_STATUS(<node_id>, okay)

to

DT_NODE_HAS_STATUS_OKAY(<node_id>)

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-10-03 17:06:52 +01:00
Jordan Yates
0425b04fc3 serial: uart_nrfx_*: update tx_ready return codes
Update nrfx drivers with the minimum number of bytes that can be sent
in a single call to `uart_fifo_fill`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-10-02 09:56:45 +02:00
Jordan Yates
3e5c72a0ee serial: async_to_irq: update tx_ready return
The async IRQ shim supports writes of any size up to the TX buffer size.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-10-02 09:56:45 +02:00
Jordan Yates
81352d011f serial/usb: update struct ring_buf users
Update the interrupt driver UART drivers that use `struct ring_buf`
internally to report the number of bytes that can be pushed in
`uart_fifo_fill` without fragmentation.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-10-02 09:56:45 +02:00
Aksel Skauge Mellbye
00270d0d12 drivers: serial: gecko: Use clock control on Series 2
Use clock control driver to configure peripheral clock on
Series 2 devices.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2024-09-30 17:12:01 +01:00