Commit Graph

819 Commits

Author SHA1 Message Date
Maureen Helm 53b08ecbfd drivers: serial: Don't condition uart_irq_rx_ready on irq enabled
The function uart_irq_rx_ready() should return true if there is data in
the receive buffer, regardless of whether the irq is enabled. Fix the
mcux and rv32m1 shim drivers to implement this behavior correctly.

Prior to this change:
- irq_rx_full() checks if RX data is available
- irq_rx_ready() checks if RX data is available and interrupts are
  enabled

After this change:
- irq_rx_full() checks if RX data is available
- irq_rx_ready() renamed to irq_rx_pending() to avoid confusion with the
  API ready() function
- API ready() implementation switched to use irq_rx_full()

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2021-02-03 08:36:23 -05:00
Volodymyr Babchuk 4fb1ee771a drivers: pl011: add SBSA mode
ARM Server Base System Architecture defines Generic UART interface,
which is subset of PL011 UART.

Minimal SBSA UART implementation does not define UART hardware
configuration registers. Basically, only FIFOs and interrupt management
operation are defined.

Add SBSA mode to PL011 UART driver, so it can be used at SBSA-compatible
platforms, like Xen guest.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
2021-01-24 13:59:55 -05:00
Shubham Kulkarni d621dad21b soc/esp32: Move logging library to IRAM with CONFIG_LOG_MINIMAL
This commit updates linker script to move minimal log module to internal
RAM

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-01-23 08:43:10 -05:00
Flavio Ceolin d21cfd5f36 power: Remove power management conditionals from code
Remove conditionals (PM_DEEP_SLEEP_STATES and PM_SLEEP_STATES) from
power management code. Now these features are always available when
power management is enabled.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-01-22 09:31:20 -05:00
Flavio Ceolin 579f7049c7 power: Move pm subsystem to new power states
Migrate the whole pm subsystem to use new power states information
from power_state.h and get states and residency properties from
device tree.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-01-22 09:31:20 -05:00
Martin Åberg 40ab00ac3d drivers/apbuart: add TX FIFO interrupt support
Use TX FIFO level interrupt if available in hardware. It matches the
Zephyr UART API and avoids "bootstrapping" which is needed when using
the TX edge interrupt ("TI"). TX FIFO has room for up to 32 characters
and will typically reduce the number of interrupts.

Details:
APBUART can be synthesized with or without support for TX/RX FIFO.
Edge interrupts which fire when TX holding register changes and RX data
available are always available, independent of the FIFO configuration.
If FIFO is made available at synthesis time, two additional interrupts
become available: TX FIFO half-empty and RX FIFO half-full. These
are level interrupts.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2021-01-21 15:53:03 -05:00
Martin Åberg ec138d6256 drivers/apbuart: Fix interrupt-driven operation
This commit aligns the GRLIB APBUART driver with the Zephyr UART API
and fixes an issue where TX interrupt could previously be lost. It
was typically seen during interactive operation in the Zephyr shell.

There is an expectation in the Zephyr UART API that TX ready (i.e. TX
buffer space available) interrupt is a level interrupt, i.e. always
active while there's TX buffer space available. In particular, there's
an expectation that after uart_irq_tx_enable(), the TX interrupt will
immediately fire (assuming free TX buffer space is available).

The APBUART "Transmitter interrupt (CTRL_TI)" does not directly fulfill
this expectation because it is edge triggered and fires when the TX
holding register moves from being non-empty to empty. The solution
is to "bootstrap" interrupt processing by calling user-defined ISR
in irq_tx_enable().

This fix is similar to commit 49bb163756 ("drivers: serial:
uart_cmsdk_apb: Fix interrupt-driven operation").

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2021-01-21 15:53:03 -05:00
Johan Hedberg 4fa0a9b4b2 drivers: serial: ns16550: Remove hard-coded max instance count
Instead of having a hard-coded maximum instance count, introduce a
Kconfig variable for it. The inclusion of the per-instance header
files is solved by having them chain-include each other with a
pre-processor condition that checks if the current header file is the
last one or not.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2021-01-18 15:45:58 -05:00
Johan Hedberg 048dcea54b drivers: serial: ns16550: Remove reg-shift instance count assumption
The reg-shift support was quite broken in that the code only looked
for this property on instance 0. Now we support the property on any
node which might declare it.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2021-01-18 15:45:58 -05:00
Johan Hedberg 0cb118968d drivers: serial: ns16550: Remove DLF & PCP instance count assumptions
Take advantage of DT_INST_FOREACH_STATUS_OKAY() to look for DLF and
PCP properties on any matching nodes with "okay" status.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2021-01-18 15:45:58 -05:00
Johan Hedberg 4cc0391a1f drivers: uart: ns16550: Clean up Kconfig dependency usage
Use a dependency block instead of specifying a UART_NS16550 dependency
for each individual opton. This doesn't save many lines right now, but
may do so once more options are added.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2021-01-18 15:45:58 -05:00
Johan Hedberg 1d5d5fcf49 drivers: uart: ns16550: Move all PCIe-using nodes to a PCIe bus in DTS
The existing method of testing for any of the first four DT instances
having the pcie property feels a bit clumsy and will get more so when
support for more than four UARTs is added. A much more cleaner way to
do this (and more correct probably as well) is to list any PCIe-based
UART nodes under a pcie bus in the Device Tree hierarchy.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2021-01-18 15:45:58 -05:00
Shlomi Vaknin b4afd1aecf drivers: serial: implement stm32 uart async api
Add initial implementation of the uart async api
for stm32 mcus. This uses the dma controller
in normal mode for reception. In addition, to detect
reception of bytes we enable the idle line detection
interrupt.

Signed-off-by: Shlomi Vaknin <shlomi.39sd@gmail.com>
Signed-off-by: Jun Li <jun.r.li@intel.com>
Signed-off-by: Giancarlo Stasi <giancarlo.stasi.co@gmail.com>
2021-01-18 19:07:29 +01:00
Katsuhiro Suzuki eb86d1eec1 drivers: serial: sifive: use interrupt-cell to set IRQ priority
This patch replace CONFIG_UART_SIFIVE_PORT_0_IRQ_PRIORITY into
interrupt-cell of device-tree to set IRQ priority.

Signed-off-by: Katsuhiro Suzuki <katsuhiro@katsuster.net>
2021-01-16 17:22:08 -05:00
Erwan Gouriou 2b0311d903 drivers/serial: stm32: Revert change in uart_irq_rx_ready
In #31192 stm32 uart driver uart_irq_rx/tx_ready functions were
modified to take into account status of irq.
While it seems wlecome for TX (based on uart client's implementation),
this is not correct for RX.
Revert change in uart_stm32_irq_rx_ready function.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-01-15 13:19:39 -05:00
Kumar Gala 02703e60d9 device: Remove DEVICE_DT_DECLARE / DEVICE_DT_INST_DECLARE
Now that we generate a header that extern's all possible devicetree
based device struct we can remove DEVICE_DT_DECLARE and
DEVICE_DT_INST_DECLARE as they aren't needed anymore.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-01-15 07:16:21 -06:00
Mahavir Jain 29f87c3a0f boards: esp32: add XIP support and enable bootloader build
Disable RTC WDT enabled (by default) by 2nd stage bootloader in ESP-IDF.
This WDT timer ensures correct hand-over and startup sequence from
bootloader to application.

Enabling bootloader caused system clock initialization to fail
when clock rate is greater then 80MHz. This also fixes
esp32 clock source code.

Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2021-01-13 09:10:46 -05:00
Erwan Gouriou 37c7b89e43 drivers/serial: stm32: Force oversampling value
When setting baudrate register, baudrate value is computed according
to the oversampling given value, which is default boot time
value (16).
In case oversampling value has been changed by bootloader (as in case
of TFM bootloader), a desynchronsation happens between OVR and BRR
values and the ouptut baudarate is incorrect.
For oversampling register before setting the baudrate to avoid this
situation.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-01-12 06:48:16 -05:00
Nicolas VINCENT eb534d39d2 driver: uart stm32: Check irq enabled in API calls
When calling irq_rx_ready or irq_tx_ready API, return the logical AND
between the irq status and the enable of that irq.

Signed-off-by: Nicolas VINCENT <nicolas.vincent@vossloh.com>
2021-01-11 16:55:29 -05:00
Jordan Yates 8e2b2fe595 serial: `CONFIG_USB_CDC_ACM` adds file to library
It is possible to use the UART abstraction for USB communications
without any of the dedicated UART drivers being enabled. This currently
causes a compilation error because CMake throws an error if a library
has no sources. The empty file forces there to be at least one file in
the library when `CONFIG_USB_CDC_ACM` is enabled.

Removing `select CONFIG_SERIAL_HAS_DRIVER` from `CONFIG_USB_CDC_ACM` is
not a valid solution as this symbol is required by `CONFIG_UART_CONSOLE`
and therefore `USB_UART_CONSOLE`.

Fixes #31067.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-01-04 16:20:43 +01:00
Kumar Gala 14d5c2fa8f drivers: serial: Convert DEVICE_AND_API_INIT to DEVICE_DEFINE
Convert driver(s) to DEVICE_DEFINE instead of DEVICE_AND_API_INIT
so we can deprecate DEVICE_AND_API_INIT in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-19 19:59:21 -05:00
Kumar Gala f062fbe856 drivers: serial: uart_lpc11u6x: Convert drivers to new DT device macros
Convert uart_lpc11u6x drivers from:

    DEVICE_AND_API_INIT -> DEVICE_DT_DEFINE
    DEVICE_GET -> DEVICE_DT_GET

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-19 19:58:33 -05:00
Kumar Gala c49b162214 drivers: uart: Convert drivers to new DT device macros
Convert uart drivers from:

	DEVICE_AND_API_INIT -> DEVICE_DT_INST_DEFINE
	DEVICE_GET -> DEVICE_DT_INST_GET
	DEVICE_DECLARE -> DEVICE_DT_INST_DECLARE

etc..

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-15 15:28:49 -06:00
Anas Nashif e0f3833bf7 power: remove SYS_ and sys_ prefixes
Remove SYS_ and sys_ from all PM related functions and defines.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-09 15:18:29 -05:00
Anas Nashif dd931f93a2 power: standarize PM Kconfigs and cleanup
- Remove SYS_ prefix
- shorten POWER_MANAGEMENT to just PM
- DEVICE_POWER_MANAGEMENT -> PM_DEVICE

and use PM_ as the prefix for all PM related Kconfigs

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-09 15:18:29 -05:00
Kumar Gala 06a5946266 drivers: Convert to use new DEVICE_DT_INST_* macros
Move users that are DEVICE_DT_DECLARE(DT_DRV_INST(n, ...)) to
DEVICE_DT_INST_DECLARE(n, ...) and similar for DEVICE_DT_DEFINE.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-09 14:06:48 -06:00
Mulin Chao daa48daf52 soc: replace DT_ with NPCX_DT_ prefix for all macros in soc_dt.h
This CL replaces all DT_ prefix with NPCX_DT_ for all macros used
for providing npcx device information in soc_dt.h It avoided the
ambiguity with the DT_ prefix for system DT macros/defines.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2020-12-09 00:46:57 -05:00
Mulin Chao 507f31472c driver: clock_controller: return values of clock_control apis directly.
return values of clock_control_on()/clock_control_get_rate() directly in
case overwriting error codes.

Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-12-07 12:11:17 -05:00
Mulin Chao 14b98135fd driver: npcx7: fixed typo in Kconfig.npcx files.
Fixed typo in Kconfig.npcx files.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2020-12-07 12:11:17 -05:00
Krzysztof Chruscinski 2db49c4b99 drivers: serial: nrfx_uarte: Fix race condition in TX path
If interrupt handler contains while loop which depends on
uart_irq_tx_ready() and uart_fifo_fill is called inside this
loop then if TXSTOPPED event occurs while code executes the
loop then uart_irq_tx_ready() will return true but uart_fifo_fill
will fail to write any bytes. That is because fifo_fill_lock is
cleared in handling of TXSTOPPED. To solve that added clearing
the lock inside uart_irq_tx_ready() if STOPPED event is detected
there.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-12-07 12:56:22 +01:00
Peter Bigot cf33927933 drivers: serial: convert nrf drivers to dt device defines
Use the devicetree node as the source of object name and other
information used when defining the device structure.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Krzysztof Chruscinski 751bdf483b drivers: serial: nrfx: Skip poll out when device is not active
Added early return from uart_poll_out when uart device is not in
active state. Poll_out is used from many contexts by multiple users
and currently here is no mechanism in power management to disable
them (console, logger when going to inactive power state.

Additionally, moved setting new state when disactivating the device to
ensure that no poll_out will happen after disabling the UARTE.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-11-26 19:08:01 +02:00
Gerard Marull-Paretas e83fab32d7 drivers: serial: stm32: use generic LL headers
Use generic LL headers instead of depending on soc.h.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-11-24 17:22:27 +01:00
Maximilian Bachmann 3c8e98cb39 drivers/pcie: Change pcie_get_mbar() to return size and flags
currently pcie_get_mbar only returns the physical address.
This changes the function to return the size of the mbar and
the flags (IO Bar vs MEM BAR).

Signed-off-by: Maximilian Bachmann <m.bachmann@acontis.com>
2020-11-20 09:36:22 +02:00
Jukka Rissanen 84e74b6a88 drivers: uart: Remove extra warn print from native_posix
Sometimes native_posix UART driver starts to flood the output
by printing hundreds of lines like this

    np_uart_poll_out: a character could not be output

Remove the warning as it makes the output very hard to read
without giving much useful information.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-11-19 08:46:51 +01:00
Johan Hedberg 3203fd3200 drivers: serial: ns16550: Update to use new pcie_alloc_irq API
Use the new pcie_alloc_irq() API so that we get a valid IRQ on
platforms where the IRQ registers do not contain valid values up
front.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2020-11-14 11:13:00 +02:00
Martin Åberg ae309f8597 serial: apbuart interrupt support
Adds driver support for APBUART transmitter and receiver
interrupts. Compatible with APBUART implementations without HW FIFO
interrupt, for example QEMU.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-11-13 14:53:55 -08:00
Martin Åberg 4888afd793 serial: Add support for GRLIB APBUART
This adds support for the GRLIB APBUART UART peripheral commonly used in
LEON3/4/5 systems.

Driver features:
- Auto-detecting debug FIFO, if configured by GRMON
- Setting and getting UART transfer attributes
- Hardware FIFO if available
- Any number of APBUART devices based on devicetree
- Error status indication
- Polled operation

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-11-13 14:53:55 -08:00
Fabio Utzig 0f1517a490 doc: fix broken rST syntax in Kconfig help
Update usage of literal syntax in Kconfig file from markdown to
proper rST.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-11-07 08:29:57 -06:00
Kumar Gala b4a3880a75 drivers: remove unnecessary use of DEVICE_AND_API_INIT
For drivers that support CONFIG_DEVICE_POWER_MANAGEMENT there are some
cases that look like:

  #ifdef CONFIG_DEVICE_POWER_MANAGEMENT
    DEVICE_DEFINE()
  #else
    DEVICE_AND_API_INIT()
  #endif

There is no need to special case this as the pm_control_fn argument to
DEVICE_DEFINE will just be ignored in the
!CONFIG_DEVICE_POWER_MANAGEMENT case.  So we can cleanup the code a
little and remove the #else cases for the drivers that do this.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-11-06 09:42:47 -06:00
Pavel Král 97696f3ed0 uart: native_posix: Add support for pts readiness
Option to pause writing to the pseudo terminal until it is ready to
receive data. Useful for pseudo terminal synchronization with other
host processes.

Signed-off-by: Pavel Král <pavel.kral@omsquare.com>
2020-11-06 12:29:57 +01:00
Mulin Chao d55aa5a71b driver: npcx7: replace platform specific functions with 'npcx_' prefix.
Replace all platform specific functions with 'npcx_' prefix.

Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-10-21 12:49:02 -05:00
Andrzej Głąbek a36c66dd40 drivers: uart_nrfx_uart: Replace k_delayed_work with k_timer
There is no need to involve a work queue to control timeouts in
the uart_nrfx_uart driver. Kernel timers are sufficient for those
tasks, and the uart_nrfx_uarte driver may serve as a proof of this.
Replace then those uses of work queue with timers, for consistency
and simplicity, also to avoid potential issues with cancellation of
the delayed work queue items.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-10-21 17:55:18 +02:00
Erwan Gouriou 0b9c584ec1 drivers/pinmux: stm32: Provide unique API to stm32_dt_pinctrl
Set stm32_dt_pinctrl_configure function as the unique entry point
to STM32 DT pinctrl management.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-20 09:09:29 -05:00
Erwan Gouriou f44e931b0c drivers/pinmux: stm32: Get remap functions visible across family
Move pinctrl remap functions out of stm32f1 definition in order
to get it available to all series.
Allows use of more IS_ENABLED macros in calling drivers and make
code more readable.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-20 09:09:29 -05:00
Erwan Gouriou 0143b5e3de drivers/pinctrl: stm32f1: Provide a function which centralize remap
Centralize AFIO remapping into one single function.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-20 09:09:29 -05:00
Mahesh Mahadevan 3eb3b58bb4 drivers: Update Flexcomm Serial driver for clock control
Use the clock API to get the serial clock frequency

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2020-10-15 11:17:24 -05:00
Kumar Gala c22e34397e drivers: serial: stm32: set default parity in driver
Have the driver default to UART_CFG_PARITY_NONE if no parity property
exists rather than using default in binding.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-10-15 04:01:22 -05:00
Erwan Gouriou 91e9fde778 drivers/serial: stm32f1: REMAP_FULL is not a possible remap value
'remap' value can never be REMAP_FULL for usart.
Fix this value depending on the usart instance.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-14 07:11:46 -05:00
Krzysztof Chruscinski db6bfde8b3 drivers: serial: nrfx_uarte: Refactoring poll_out
Refactoring poll_out to be ready for handling preemption. uart_tx and
uart_fifo_fill modified so they are resilient to being preempted by
uart_poll_out.

Refactored uart_poll_out implementation to be common for interrupt
driven API and asynchronous API. In both APIs active state is detected
by evaluating state of ENDTX and TXSTOPPED events. If anyone is set it
means that new transfer can be started.

Patch is fixing existing issues:
- potential bytes dropping with flow control enabled
- busywaiting for ENDTX (asynchronous API) - poor performance
- potential bytes dropping during preemption
- potential uart_tx returning -EBUSY when interrupted poll_out

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-10-14 14:06:25 +02:00