Commit graph

696 commits

Author SHA1 Message Date
Andy Ross 7832738ae9 kernel/timeout: Make timeout arguments an opaque type
Add a k_timeout_t type, and use it everywhere that kernel API
functions were accepting a millisecond timeout argument.  Instead of
forcing milliseconds everywhere (which are often not integrally
representable as system ticks), do the conversion to ticks at the
point where the timeout is created.  This avoids an extra unit
conversion in some application code, and allows us to express the
timeout in units other than milliseconds to achieve greater precision.

The existing K_MSEC() et. al. macros now return initializers for a
k_timeout_t.

The K_NO_WAIT and K_FOREVER constants have now become k_timeout_t
values, which means they cannot be operated on as integers.
Applications which have their own APIs that need to inspect these
vs. user-provided timeouts can now use a K_TIMEOUT_EQ() predicate to
test for equality.

Timer drivers, which receive an integer tick count in ther
z_clock_set_timeout() functions, now use the integer-valued
K_TICKS_FOREVER constant instead of K_FOREVER.

For the initial release, to preserve source compatibility, a
CONFIG_LEGACY_TIMEOUT_API kconfig is provided.  When true, the
k_timeout_t will remain a compatible 32 bit value that will work with
any legacy Zephyr application.

Some subsystems present timeout (or timeout-like) values to their own
users as APIs that would re-use the kernel's own constants and
conventions.  These will require some minor design work to adapt to
the new scheme (in most cases just using k_timeout_t directly in their
own API), and they have not been changed in this patch, instead
selecting CONFIG_LEGACY_TIMEOUT_API via kconfig.  These subsystems
include: CAN Bus, the Microbit display driver, I2S, LoRa modem
drivers, the UART Async API, Video hardware drivers, the console
subsystem, and the network buffer abstraction.

k_sleep() now takes a k_timeout_t argument, with a k_msleep() variant
provided that works identically to the original API.

Most of the changes here are just type/configuration management and
documentation, but there are logic changes in mempool, where a loop
that used a timeout numerically has been reworked using a new
z_timeout_end_calc() predicate.  Also in queue.c, a (when POLL was
enabled) a similar loop was needlessly used to try to retry the
k_poll() call after a spurious failure.  But k_poll() does not fail
spuriously, so the loop was removed.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-03-31 19:40:47 -04:00
Andy Ross 32bb2395c2 timeout: Fix up API usage
Kernel timeouts have always been a 32 bit integer despite the
existence of generation macros, and existing code has been
inconsistent about using them.  Upcoming commits are going to make the
timeout arguments opaque, so fix things up to be rigorously correct.
Changes include:

+ Adding a K_TIMEOUT_EQ() macro for code that needs to compare timeout
  values for equality (e.g. with K_FOREVER or K_NO_WAIT).

+ Adding a k_msleep() synonym for k_sleep() which can continue to take
  integral arguments as k_sleep() moves away to timeout arguments.

+ Pervasively using the K_MSEC(), K_SECONDS(), et. al. macros to
  generate timeout arguments.

+ Removing the usage of K_NO_WAIT as the final argument to
  K_THREAD_DEFINE().  This is just a count of milliseconds and we need
  to use a zero.

This patch include no logic changes and should not affect generated
code at all.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-03-31 19:40:47 -04:00
Vincent Wan 16fab6c4f8 drivers: cc13xx_cc26xx: guard references to sleep states
Use of macros such as SYS_POWER_STATE_SLEEP_2 needs to be guarded by
making sure CONFIG_SYS_POWER_SLEEP_STATES is defined.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2020-03-31 07:38:31 -05:00
Oleg Zhurakivskyy b1e1f64d14 global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT()
Replace all occurences of BUILD_ASSERT_MSG() with BUILD_ASSERT()
as a result of merging BUILD_ASSERT() and BUILD_ASSERT_MSG().

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-31 07:18:06 +02:00
Kumar Gala 80f0db4bd6 drivers: uart: uart_xlnx_ps: Convert to new DT_INST macros
Convert older DT_INST_ macro use the new include/devicetree.h
DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-30 14:48:09 -05:00
Kumar Gala 379aac5c97 drivers: uart: uart_nsim: Convert to new DT_INST macros
Convert older DT_INST_ macro use the new include/devicetree.h
DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-30 13:13:20 -05:00
Kumar Gala 7c6c0883e8 drivers: uart: uart_msp432p4xx: Convert to new DT_INST macros
Convert older DT_INST_ macro use the new include/devicetree.h
DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-30 13:11:55 -05:00
Kumar Gala 88469b7010 drivers: litex: Convert litex drivers to new DT_INST macros
Convert older DT_INST_ macro use in litex drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-30 12:49:43 -05:00
Kumar Gala decb7a3c6d drivers: uart: uart_miv: Convert to new DT_INST macros
Convert older DT_INST_ macro use the new include/devicetree.h
DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-28 10:18:02 -05:00
Kumar Gala 70a0063b69 drivers: serial: uart_ns16550: Convert to new DT_INST macros
Convert older DT_INST_ macro use the new include/devicetree.h
DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-27 16:54:50 -05:00
Kumar Gala 28870e7a32 drivers: atmel sam0: Convert atmel sam0 drivers to new DT_INST macros
Convert older DT_INST_ macro use in atmel sam0 drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-27 11:02:57 -05:00
Kumar Gala cdbc0f8c22 drivers: serial: uart_native_posix: Convert to new DT_INST macros
Convert older DT_INST_ macro use the new include/devicetree.h
DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-27 04:55:43 -05:00
Kieran Levin acac1584bc drivers: serial: add dts peripherals to stm32g0
Added device tree nodes and associated headers for
defined uarts on the stm32g0 and stm32g07x 8x parts.

Tested with uart on stm32g071rb disco board with usart3 going to stlink.
Using shell.

Signed-off-by: Kieran Levin <ktl@frame.work>
2020-03-26 22:45:01 +01:00
Kumar Gala 989484b4bf drivers: stm32: Convert STM32 drivers to new DT_INST macros
Convert older DT_INST_ macro use in STM32 drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 12:22:12 -05:00
Kumar Gala 8ea8925ebe drivers: esp32: Convert esp32 drivers to new DT_INST macros
Convert older DT_INST_ macro use in esp32 drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 08:49:11 -05:00
Kumar Gala b99ee328f8 drivers: serial: esp32: rename fake DT define
Rename DT_INST_{0,1,2}_ESPRESSIF_ESP32_UART_IRQ_0 defines to something
non-DT prefixed.  This way we know which defines are one's we generate
and which ones are driver created.  It should be easy enough to replace
these INST_{0,1,2}_ESPRESSIF_ESP32_UART_IRQ_0 define with DTS generated
one macros once esp32 has interrupt controller support in DTS.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 08:49:11 -05:00
Kumar Gala 4cb0a5d992 drivers: silabs: Convert silabs drivers to new DT_INST macros
Convert older DT_INST_ macro use in silab drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 05:26:23 -05:00
Kumar Gala aa5adf3c79 drivers: stellaris: Convert stellaris drivers to new DT_INST macros
Convert older DT_INST_ macro use in stellaris drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 03:39:11 -05:00
Vincent Wan e21bb3a812 drivers: serial: cc13xx_cc26xx: add power management support
Add a dependency on the UART resource in the TI Power module,
reconfigure the UART upon CPU exiting standby, and add support
for device PM.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2020-03-25 16:21:33 -04:00
Kumar Gala 9ede3c9a97 drivers: serial: uart_pl011: remove shared irq support
The shared irq support isn't needed in this driver.  We just need to
deal with the fact that some SoCs have only a single interrupt line and
some have three interrupts.  We can just ifdef that based on
DT_NUM_IRQS.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-25 08:34:40 -05:00
Peter A. Bigot 93309317d0 uart: sifive: fix interrupt-driven transmission
A txcnt of zero prevents transmission, as transmit requires the number
of entries in the transmit fifo to be strictly less than the txcnt
value.  Set the default to 1.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-03-24 13:28:58 -04:00
Kumar Gala 8f84520130 drivers: serial: uart_sifive: convert to new DT API
Use the new devicetree.h API instead of the legacy macros.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-24 10:11:20 -05:00
Martí Bolívar f50b0689b5 drivers: serial: convert uart_nrfx_uart to new DT API
Use the new devicetree.h API instead of the legacy macros.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-24 10:11:20 -05:00
Flavio Ceolin f0a4cb059d drivers: uart: Add uart_configure verification handler
uart_configure verification handler was missing what would cause a crash
if called from a user thread.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-03-23 15:23:50 -04:00
Flavio Ceolin 017c142fd2 drivers: uart: Add config_get verification handler
uart_config_get API was broken in USERSPACE because was lacking the
verification handler.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-03-23 15:23:50 -04:00
Krzysztof Chruscinski 729a9b0050 drivers: serial: nrfx_uarte: Improve TX only mode
Added return -ENOTSUP in uart_rx_enable() if RX pin is disabled.
Fixed power management call where TASKRX was started even though
RX pin was disabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-03-20 14:36:29 -05:00
Krzysztof Chruscinski 6a6063b57a drivers: serial: nrfx_uart: Allow TX only mode
Extended nrf_uart driver to support TX only.
When RX pin is not provided then RX is not started at all. This
allows to achieve low power with logging/console enabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-03-20 14:36:29 -05:00
Kumar Gala a288f07126 drivers: serial: uart_pl011: Unify uart clock from DT
Add a fixed clock to the qemu-virt-a53.dtsi to match how the musca dts
files work so we get the clock DT info in the same way in the driver.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-20 10:05:01 -05:00
Carles Cufi 4b37a8f3a4 Revert "global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT()"
This reverts commit 8739517107.

Pull Request #23437 was merged by mistake with an invalid manifest.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-19 18:45:13 +01:00
Oleg Zhurakivskyy 8739517107 global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT()
Replace all occurences of BUILD_ASSERT_MSG() with BUILD_ASSERT()
as a result of merging BUILD_ASSERT() and BUILD_ASSERT_MSG().

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-19 15:47:53 +01:00
Mieszko Mierunski 0278f9bc72 drivers: nrf: Flush RX fifo in UARTE Async API.
After RX is disabled during receiving, some bytes are received to
internal fifo. To not interfere with further transactions fifo has to be
flushed.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2020-03-18 13:21:04 +01:00
Erwan Gouriou 6275513051 drivers: serial: uart_stm32: convert to DT_INST defines
Convert driver to use DT_INST_ defines.
In the process, we've removed all UART/USART/LPUART code in
device instanciation code which had no impact.
Since all uart/usart/lpuart nodes declare compatibility with
st,stm32uart, DT_INST_X_ST_STM32_UART_FOO could be used.

Removed DT_UART fixup macros.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-03-17 11:03:10 -06:00
Kumar Gala 8bf05c7d61 drivers: serial: pl011: Fix typo bug in port1 support
In the DT_INST conversion we introduced a typo bug of accessing port0
instead of port1 in the IRQ config function.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-17 08:51:33 +01:00
Timo Teräs 1c3b46daff driver: uart: ns16550: store active configuration in dev data
Update device data with the activated configuration, so that it
will be remembered for follow up configuration get requests.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2020-03-14 02:22:05 +02:00
Timo Teräs 6fd168e9a1 driver: uart: ns16550: convert to DT_INST_*
Change to code to use the automatically generated DT_INST_*
defines and remove the now unneeded configs and fixups.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2020-03-14 02:22:05 +02:00
Timo Teräs e740818093 driver: uart: ns16550: convert custom init options to DTS flow control
The sole purpose of init options has been to enable hardware flow
control on NS16750 when asked. Use the proper DTS tags for this.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2020-03-14 02:22:05 +02:00
Mieszko Mierunski f818cdc33d drivers: nrf: Fix UARTE TX hangs when using both polling and async API.
Added locking for TX transfers between async and polling API.
Added safety counters for checking if transmission finished.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2020-03-13 11:13:43 +01:00
Mieszko Mierunski 0ca40205e5 drivers: nrf: Fix UART TX hanging when using both polling and async API.
Add locking between async and polling tx transfers.
Add safety counters while waiting for transmission to finish.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2020-03-13 11:13:43 +01:00
Kumar Gala 256c9acace drivers: serial: stellaris: convert to DT_INST defines
Convert driver to use DT_INST_ defines.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-12 04:54:04 -06:00
Kumar Gala aa98c7ba17 drivers: serial: pl011: convert to DT_INST defines
Convert driver to use DT_INST_ defines.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-12 04:53:30 -06:00
Kumar Gala 4372efe4ef drivers: uart: miv: convert to DT_INST defines
Convert driver to fully use DT_INST_ defines.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-11 16:37:22 -06:00
Francisco Igual 930c904c67 drivers: serial: esp32: Fix syntax error in file uart_esp32.c
Added missing comma. Made it impossible to compile a number of examples.

Signed-off-by: Francisco Igual <figual@ucm.es>
2020-03-11 13:42:50 -05:00
Kumar Gala 667f96389b drivers: uart: esp32: convert to DT_INST defines
Convert driver to fully use DT_INST_ defines.  Currently IRQs are not
generated from DTS on esp32 so we create #defines for what they should
look like.  Convert the IRQ defines to match DT_INST style so if/when
we have that info in DTS it will look the same.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-11 07:59:38 -06:00
Kumar Gala 3e6614a330 drivers: uart: msp432p4xx: convert to DT_INST defines
Convert driver to fully use DT_INST_ defines.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-11 07:59:38 -06:00
Kumar Gala afca340fc0 drivers: uart: native_posix: convert to DT_INST defines
Convert driver to fully use DT_INST_ defines.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-11 07:59:38 -06:00
Andrzej Głąbek 668d401293 modules: hal: nordic: Define NRFX_ASSERT as __ASSERT_NO_MSG
Update hal_nordic's revision, so that NRFX_ASSERT uses __ASSERT_NO_MSG
directly, not through the assert macro that comes from from libc,
as the definition of the latter might be different when some specific
libc version is used, and this could generate troubles.

Replace also uses of assert() with __ASSERT_NO_MSG() in nrfx driver
shims that use this macro without including the corresponding header
file (i.e. that implicitly rely on assert.h being included from
nrfx_glue.h, which is no longer the case).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-03-10 17:21:27 +01:00
Stephanos Ioannidis 95deb43e6f drivers: serial: uart_sam: Fix irq_update API function
The `irq_update` UART API function must always return 1 according to
the API documentations.

This commit fixes the `irq_update` API function to unconditionally
return `1`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-10 14:50:58 +02:00
Stephanos Ioannidis afb51d2750 drivers: serial: usart_sam: Fix irq_update API function
The `irq_update` UART API function must always return 1 according to
the API documentations.

This commit fixes the `irq_update` API function to unconditionally
return '1'.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-10 14:50:58 +02:00
Gerson Fernando Budke da72a3028e drivers: serial: Kconfig.usart_sam: Fix number of ports
Since driver is shared with other devices, it must be enabled
conditionally based on the number of instances. This avoid show
invalid options for devices with lower port count like SAM4S/SAM4E.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-10 14:43:36 +02:00
Gerson Fernando Budke 8480627d14 drivers: serial: Kconfig.uart_sam: Enable support to SAMV71
SAMV71 uses same driver of SAME70 and this enables the feature. Since
driver is shared with other devices, it must be enabled conditionally
based on the number of instances. This avoid show invalid options for
devices with lower port count like SAM4S/SAM4E.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-03-10 14:43:36 +02:00
Stephanos Ioannidis 9aed7fb040 drivers: serial: uart_sam0: Fix interrupt connection
This commit fixes the multiple SERCOM interrupt handling for the SAM
D5x and E5x devices by replacing the obsolete device tree symbol with
the new `DT_INST` symbol.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-06 18:34:12 +02:00
Ulf Magnusson 378d6b137a kconfig: Replace non-defconfig single-symbol 'if's with 'depends on'
Same deal as in commit eddd98f811 ("kconfig: Replace some single-symbol
'if's with 'depends on'"), for the remaining cases outside defconfig
files. See that commit for an explanation.

Will do the defconfigs separately in case there are any complaints
there.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-02-12 10:32:34 -06:00
Yannis Damigos a4b448ea59 uart_stm32: Fix flow misspelling
Fix flow misspelling.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2020-02-07 08:08:25 -06:00
Kumar Gala 6115346174 drivers: serial: stm32: Fix possible issue with mixed enum
When building with LLVM we get the following error:

uart_stm32.c:272:9: error: implicit conversion from enumeration type
'enum uart_config_parity' to different enumeration type
'enum uart_config_flow_control' [-Werror,-Wenum-conversion]
        return UART_CFG_PARITY_NONE;
        ~~~~~~ ^~~~~~~~~~~~~~~~~~~~

We shouldn't be mixing parity and flow control enum's.  Use
UART_CFG_FLOW_CTRL_NONE instead or UART_CFG_PARITY_NONE.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-07 11:50:38 +01:00
Mieszko Mierunski 971c27af0d drivers: sam: UART async API change timeout to signed value.
Change timeout to signed value.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2020-01-29 19:37:31 +01:00
Mieszko Mierunski 20444869e3 drivers: nrf: Fix forever timeout handling in UART async API.
Current implementation directly passes timeout value to workqueue/timer
which results in assertion or instant timeout in case when K_FOREVER is
passed. This fix ensures that no timer or workqueue is called with
K_FOREVER.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2020-01-29 19:37:31 +01:00
Mieszko Mierunski dc3c906d12 drivers: uart: Switch timeout values to s32_t in UART async API
Use signed values for timeout in UART asynchronous API, to be consistent
with timeout type in timer and workqueue values.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2020-01-29 19:37:31 +01:00
Krzysztof Chruscinski dcdc61cfdb drivers: serial: nrf_uarte: Allow TX only instance
Extended nrf_uarte driver to support TX only UARTE instances.
When RX pin is not provided then RX is not started at all. This
allows to achieve low power with logging/console enabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-01-29 12:03:05 -06:00
Peter Bigot 02ae343100 treewide: use full path to uart.h header
The build infrastructure should not be adding the drivers subdirectory
to the include path.  Fix the legacy uses that depended on that
addition.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:52:12 +01:00
Peter Bigot 0b0d2e640b treewide: use full path to clock_control/stm32_clock_control.h header
The build infrastructure should not be adding the drivers subdirectory
to the include path.  Fix the legacy uses that depended on that
addition.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:52:12 +01:00
Peter Bigot 4147188bbb treewide: use full path to clock_control/arm_clock_control.h header
The build infrastructure should not be adding the drivers subdirectory
to the include path.  Fix the legacy uses that depended on that
addition.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:52:12 +01:00
Oane Kingma ea9140e652 drivers/serial: Add more USART ports for Silabs EFM32GG11B
Silicon Labs EFM32GG11B SoCs have more USART ports than
currently supported by the driver. Driver expanded with
support for USART4 and USART5.

Signed-off-by: Oane Kingma <o.kingma@interay.com>
2020-01-24 10:28:33 -06:00
Carlo Caione b9fc192779 drivers: uart_pl011: Enable shared interrupts support
The PrimeCell UART (PL011) IP can use one single combined/shared
interrupt line instead than different IRQ lines for TX/RX/Err/... This
is the most common configuration supported in the Linux world but not
currently supported in Zephyr. QEMU emulates a PL011 UART with a single
interrupt line as well.

To support this configuration we have to hookup the PL011 driver with a
shared IRQ driver and add two new configuration options when the shared
IRQ line is used.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2020-01-23 02:04:52 -08:00
Flavio Ceolin 2abfccb352 driver: uart: ns16550: Simplify drv_cmd function
There is only one possible command, so just use if instead of switch
to avoid several MISRA-C violations and also avoid set dev_data wrongly
unused when UART_NS16550_DLF_ENABLED is defined.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-01-22 21:21:49 -05:00
Flavio Ceolin e1589c2278 driver: uart: ns16550: Setting default options
Commit 68a235932f changed this driver to
not use hard-coded options. The problem was that these options were
never being set. This commit just set an initial value that can be
changed later.

Fix 68a235932f

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-01-22 01:52:51 -05:00
Jennifer Williams 68a235932f drivers: uart: ns16550: move from hard-coded to configurable
The NS16550 UART driver is currently hard-coded as 8-n-1
with no flow control. The baud rate is set by what is in DTS.
This commit moves away from hard-coded and strictly DTS to
configurable using the UART configure API. Requires commit #bcb807.

Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
2020-01-21 18:50:27 -05:00
Jennifer Williams 3a34db8501 driver: uart: ns16550: implement configure API
The UART configure API was added to uart.h and this commit
implements the initial framework for the configure API for
the ns16550 uart. This includes the configure() and config_get()
functions and uart device configuration structures of the uart
configure API for the ns16550.

Note this commit does not resolve the pre-existing hard-coded
8-n-1 implementation.

Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
2020-01-21 18:50:27 -05:00
Kumar Gala b1602c8e39 arm: Removed support for CC2650
The SoC, driver, and board support for the CC2650 and CC2650 Sensortag
aren't currently supported and we are removing them as such.  If anyone
is interesting in supporting this platform we can easily recovery it
from git.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-01-18 09:27:55 -06:00
Andrew Boie a51b125aba drivers: serial: add async API system calls
These were unintentionally omitted. We don't expose callback
registration or callback response APIs for security reasons.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-17 16:15:02 -05:00
Audun Korneliussen a68ef65bc4 drivers: uart: Enable rx byte counting timer only in active power state
Nrfx_uarte uses a hardware timer/counter to count received bytes.
Keeping this timer enabled increases power consumption for some SoCs.

This change disables the timer when an inactive power state is set.

Signed-off-by: Audun Korneliussen <audun.korneliussen@nordicsemi.no>
2020-01-16 11:55:56 +01:00
Maureen Helm 93b457f4da drivers: serial: Refactor mcux lpsci driver to use generated dts macros
Refactors the mcux lpsci driver to use generated device tree macros
directly. Removes now unused dts fixup macros from i.mx rt and kinetis
socs.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-01-15 18:02:19 -05:00
Maureen Helm 5df8b5d63e drivers: serial: Refactor mcux uart driver to use generated dts macros
Refactors the mcux uart driver to use generated device tree macros
directly. Removes now unused dts fixup macros from kinetis socs.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-01-15 18:02:19 -05:00
Maureen Helm a2082303b8 drivers: serial: Refactor mcux lpuart driver to use generated dts macros
Refactors the mcux lpuart driver to use generated device tree macros
directly. Removes now unused dts fixup macros from i.mx rt and kinetis
socs.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-01-14 11:10:27 -05:00
Ismael Fillonneau 0c3fbaa882 drivers: nrf: avoid UARTE pm infinite loop
calling UARTE power management with DEVICE_PM_SUSPEND_STATE
then DEVICE_PM_OFF_STATE causes a deadlock in while loop.
It waits for an event witch never comes

Signed-off-by: Ismael Fillonneau <ismael.fillonneau@stimio.fr>
2020-01-10 10:42:23 +01:00
Marciano C. Preciado d3abb0b9ca drivers: nrf: Catch for nRF53 serial interference
UARTE, SPI, & TWI with the same ID# share resources on nRF53

Signed-off-by: Marciano C. Preciado <marciano@passive-logic.com>
2020-01-07 17:14:25 +01:00
Krzysztof Chruscinski d716e3a66c various: Cleanup COND_CODE_1 usage or replace with IF_ENABLED()
Cleanup around COND_CODE_1 usage and replacing with
IF_ENABLED if applicable.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-12-18 08:14:52 -05:00
Pawel Dunaj 6d911b8f2c drivers: uart_rtt: Handle PM callback properly
All drivers must have power management callbacks specified.

Signed-off-by: Pawel Dunaj <pawel.dunaj@nordicsemi.no>
2019-12-18 12:10:19 +01:00
Maureen Helm 95743561a6 drivers: serial: Use generated dts macros in mcux flexcomm driver
Uses the generated device tree macros, DT_NXP_LPC_USART_USART_*, in the
mcux flexcomm driver and removes the now unused dts fixups from the
lpc54xxx and lpc55xxx socs.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-12-13 18:45:54 +01:00
Maureen Helm 72e0080e56 drivers: serial: Rename lpc usart shim driver
Renames the lpc usart shim driver to more accurately reflect the
flexcomm hardware IP and to prepare for instantiating it on an SoC
outside the LPC family.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-12-13 18:45:54 +01:00
Ulf Magnusson 984bfae831 global: Remove leading/trailing blank lines in files
Remove leading/trailing blank lines in .c, .h, .py, .rst, .yml, and
.yaml files.

Will avoid failures with the new CI test in
https://github.com/zephyrproject-rtos/ci-tools/pull/112, though it only
checks changed files.

Move the 'target-notes' target in boards/xtensa/odroid_go/doc/index.rst
to get rid of the trailing blank line there. It was probably misplaced.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-11 19:17:27 +01:00
Kumar Gala cd0f8d5c4f include: Fix use of <sys_io.h> -> <sys/sys_io.h>
Fix #include <sys_io.h> as it has been deprecated and
should be #include <sys/sys_io.h>.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-12-10 08:39:37 -05:00
Ulf Magnusson 87e917a925 kconfig: Remove redundant 'default n' and 'prompt' properties
Bool symbols implicitly default to 'n'.

A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.

Also replace some

    config
    	prompt "foo"
    	bool/int

with the more common shorthand

    config
    	bool/int "foo"

See the 'Style recommendations and shorthands' section in
https://docs.zephyrproject.org/latest/guides/kconfig/index.html.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-09 16:14:50 +01:00
Mieszko Mierunski b7ae41779d drivers: nrf: Add CTS and RTS pins to UART and UARTE PM
Add gpio management for CTS and RTS pins in UART and UARTE drivers

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2019-11-29 09:04:55 +01:00
Mieszko Mierunski 21e0d48750 drivers: nrf: Fix UART and UARTE hanging on RX errors
Add clearing error event to UART and UARTE drivers.
Without it driver goes into infinite interrupt loop.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2019-11-26 09:01:22 +01:00
Francois Ramu d3ffa8d089 driver: serial: Error handling issues in uart_stm32_set_baudrate
This patch tests the return code when calling clock_control_get_rate
and completes the issue #20503 seen on watchdog
[Coverity CID :205655]

Fixes #20503

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2019-11-18 09:18:13 -06:00
Mieszko Mierunski 117bc6dfa4 drivers: nrf: Fix values in UARTE async API callback.
There is possibility that endrx interrupt will be triggered in the
middle of timer interrupt responsible for UARTE timeout, this
patch handles this case.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2019-11-13 15:09:12 -06:00
Andrzej Głąbek b1d5eed262 drivers: nrfx: Update implementations after switching to nrfx 2.0.0
Update calls to nrfx HAL functions to reflect API changes introduced in
nrfx 2.0.0. All these functions are now called with the first parameter
pointing to the structure of registers of the relevant peripheral.
Also a few functions got renamed:
- nrf_gpiote_int_is_enabled to nrf_gpiote_int_enable_check
- nrf_gpiote_event_is_set to nrf_gpiote_event_check
- nrf_rng_event_get to nrf_rng_event_check
- nrf_rng_int_get to nrf_rng_int_enable_check
- nrf_rtc_event_pending to nrf_rtc_event_check
- nrf_rtc_int_is_enabled to nrf_rtc_int_enable_check
- nrf_timer_cc_read to nrf_timer_cc_get
- nrf_timer_cc_write to nrf_timer_cc_set

Default configuration values were removed from nrfx_config files,
so the drivers pwm_nrfx and spi_nrfx_spis no longer can use those.

Function nrfx_pwm_init() now takes one more parameter - context pointer
that is passed to the event handler, not used in the pwm_nrfx driver.

HALs for UART and UARTE now allow configuration of the parity type
and the number of stop bits, for SoCs that provide the corresponding
registers.

Signed-off-by: Karol Lasończyk <karol.lasonczyk@nordicsemi.no>
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-11-08 14:54:12 +01:00
Peter A. Bigot a58d8ebaa6 driver: uart: make deprecation effective
Several macros were documented as deprecated but lacked the
infrastructure to produce deprecation warnings.  Add the deprecation
marker, and fix the in-tree references to the deprecated spellings.

Note that one non-deprecated macro should have been deprecated, and
is, referring to a newly added line control bit.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-11-07 12:44:15 -06:00
Benjamin Valentin ca9a64bd13 serial: sam0: Add support for SAME54
The SAME5x/SAMD5x MCUs share their SERCOM peripherals with the
samd2x and saml1x MCUs with only few registers changed.

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2019-11-06 17:36:23 -08:00
Ulf Magnusson bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Ulf Magnusson 3b98417ef2 drivers: serial: liteuart: Remove unused UART_LITEUART_PORT_0 symbol
Added in commit f9efca4b4f ("boards: riscv32: add LiteX VexRiscV
board"), then never used.

Found with a script.

Also change UART_LITEUART from a 'menuconfig' symbol to a 'config'
symbol, as it's no longer followed by symbols that depend on it
(UART_LITEUART_PORT_0 should have been a plain 'config' too).

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-29 06:16:27 +01:00
Dennis Wildmark 582e5e58c9 drivers: serial: Configurable GPIO management in NRFX UARTE
In some applications where power management is used, it is not expected
that the GPIO pins of the UARTE is reconfigured upon power state change.
Added a Kconfig option to disable the UARTE driver management of GPIOs.
It defaults to y in order to not affect current behavior unless the user
configures it specifically.

Signed-off-by: Dennis Wildmark <dennis.wildmark@assaabloy.com>
2019-10-25 08:50:25 +02:00
Ulf Magnusson 677f1e6db9 kconfig: Turn pointless/confusing 'menuconfig's into 'config's
Defining a symbol with 'menuconfig' just tells the menuconfig to display
any dependent symbols that immediately follow it in a separate menu.
'menuconfig' has no effect on symbol values.

Making a symbol that doesn't have any dependent symbols after it a
'menuconfig' should be avoided, because then you end up with an empty
menu, which is shown as e.g.

    [*] Enable foo ---

This is how it would be shown if there were children but they all
happened to be invisible as well.

With a regular 'config', it turns into

    [*] Enable foo

Change all pointless 'menuconfig's to 'config's.

See the section on 'menuconfig' on the Kconfig - Tips and Best Practices
page as well.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-22 13:53:06 -05:00
Henrik Brix Andersen 3d9eefc023 drivers: serial: mcux_lpuart: use base address from DTS for LPUART0
Use the base address from the device tree for instance 0 (LPUART0)
instead of hardcoding the address using the NXP MCUX HAL definition.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2019-10-21 12:25:26 -05:00
Carlo Caione 1c4626d324 kconfig: uart_pl011: Do not limit PL011 driver to ARM family
The driver is not specific to 32bit ARM family. For example it is
currently used by the QEMU ARM64 virt machine.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2019-10-18 08:11:48 -05:00
Carlo Caione 6148b5bd9e drivers: uart_pl011: Fix unused variable warning
Fix GCC complain when CONFIG_UART_INTERRUPT_DRIVEN=n

  warning: unused variable ‘config’ [-Wunused-variable]

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2019-10-18 08:11:48 -05:00
Mateusz Holenko ee36c2ce53 drivers: uart_liteuart: fix usage of DT_ defines
This commit switches from using device tree automatically
generated address-based defines to the instance id-based ones.

Without this change it is not be possible to re-use the driver
on boards where the device is located at different location
than 0xe0001800.

Signed-off-by: Mateusz Holenko <mholenko@antmicro.com>
2019-10-18 07:48:14 -05:00
Tommy Vestermark 22be864af3 stm32: Fix uart_irq_tx_complete() to output correct status
Currently both uart_stm32_irq_tx_complete() and
uart_stm32_irq_tx_ready() return the TXE flag. However
uart_irq_tx_complete() should really return the TC flag to output true
"Transmit Complete" status.

Signed-off-by: Tommy Vestermark <tovsurf@vestermark.dk>
2019-10-09 06:30:14 -05:00
Carlo Caione 26ff7603f1 drivers: uart_pl011: Fix compilation when CONFIG_UART_INTERRUPT_DRIVEN=n
The driver fails to compile when CONFIG_UART_INTERRUPT_DRIVEN=n. This is
due to a nested ifdef on CONFIG_UART_INTERRUPT_DRIVEN that is excluding
pieces of code unrelated to the uart interrupts management.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2019-10-08 10:22:46 -07:00
Carlo Caione a76a74c541 drivers: uart_pl011: Remove cortex_m header
The PL011 driver is not specific to the cortex_m arch and the driver
does not really use anything from the cmsis header file. Remove it.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2019-10-08 10:22:46 -07:00