Commit graph

29 commits

Author SHA1 Message Date
Krzysztof Chruscinski 8592d43191 drivers: uart: sam0: Reorder events on rx_disable
Modified order of reported events on rx disable to match API
description: first RX_RDY and then RX_BUF_RELEASED.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-06-16 19:11:57 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Martí Bolívar 7e0eed9235 devicetree: allow access to all nodes
Usually, we want to operate only on "available" device
nodes ("available" means "status is okay and a matching binding is
found"), but that's not true in all cases.

Sometimes we want to operate on special nodes without matching
bindings, such as those describing memory.

To handle the distinction, change various additional devicetree APIs
making it clear that they operate only on available device nodes,
adjusting gen_defines and devicetree.h implementation details
accordingly:

- emit macros for all existing nodes in gen_defines.py, regardless
  of status or matching binding
- rename DT_NUM_INST to DT_NUM_INST_STATUS_OKAY
- rename DT_NODE_HAS_COMPAT to DT_NODE_HAS_COMPAT_STATUS_OKAY
- rename DT_INST_FOREACH to DT_INST_FOREACH_STATUS_OKAY
- rename DT_ANY_INST_ON_BUS to DT_ANY_INST_ON_BUS_STATUS_OKAY
- rewrite DT_HAS_NODE_STATUS_OKAY in terms of a new DT_NODE_HAS_STATUS
- resurrect DT_HAS_NODE in the form of DT_NODE_EXISTS
- remove DT_COMPAT_ON_BUS as a public API
- use the new default_prop_types edtlib parameter

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-08 19:37:18 -05:00
Tomasz Bursztyka 97326c0445 device: Fix structure attributes access
Since struct devconfig was merged earlier into struct device, let's fix
accessing config_info, name, ... attributes everywhere via:

grep -rlZ 'dev->config->' | xargs -0 sed -i 's/dev->config->/dev->/g'

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-08 23:07:44 +02:00
Carles Cufi 3954aa5a5a serial: sam0: Complete port to the new timeout API
The conversion in 9b096f40b6 left out a
few tidbits that were not converted properly. Complete the conversion
properly.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-05-07 22:00:39 -05:00
Carles Cufi 9b096f40b6 timeouts: Port UART async API to the new timeout API
Port the API to the new paradigm as to avoid having to select
LEGACY_TIMEOUT_API.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-05-07 11:01:55 +02:00
Kumar Gala a58777e251 drivers: dma: atmel_sam0: Convert to use devicetree macros for dma dev
Convert to using DT_INST_LABEL() in the dma driver and convert dma users
to use the DMA property macros to get the dma controller name.  We make
the assumption in the drivers that there is a single DMA controller
instance.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-07 00:49:32 -05:00
Kumar Gala bd639fc332 drivers: serial: uart_sam0: rework devicetree support
Rework the devicetree to utilize new DT_INST macros and extract per
instance data for clocks and dma from devicetree.  We update the
atmel,sam0-uart binding for dma to replace the rxdma and txdma
properties with proper 'dmas' property.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-22 21:34:21 -05:00
Kumar Gala bf0add1a34 drivers: serial: uart_sam0: Fix build error with CONFIG_UART_ASYNC_API
When we build this driver with CONFIG_UART_ASYNC_API enabled we get the
following build error:

uart_sam0.c: In function 'uart_sam0_init':
uart_sam0.c:558:35: error: redefinition of 'dev_data'
  558 |  struct uart_sam0_dev_data *const dev_data = DEV_DATA(dev);
uart_sam0.c:498:35: note: previous definition of 'dev_data' was here
  498 |  struct uart_sam0_dev_data *const dev_data = DEV_DATA(dev);

Fix this be removnig the duplicate at line 558.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-21 08:00:49 -05:00
Kuba Sanak bf2dccb0eb drivers: uart: samd0: add missing .configure API functionality
The UART driver for samd0 was is missing the .configure and
.config_get functionality expected from api for serial driver.
This commit fixes this by providing basic configuration

Signed-off-by: Kuba Sanak <contact@kuba.fyi>
2020-04-17 08:07:28 -04: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
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
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
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
Anas Nashif 5eb90ec169 cleanup: include/: move misc/__assert.h to sys/__assert.h
move misc/__assert.h to sys/__assert.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif d1b2718687 cleanup: include/: move uart.h to drivers/uart.h
move uart.h to drivers/uart.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 46a5d1e5cb cleanup: include/: move dma.h to drivers/dma.h
move dma.h to drivers/dma.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Kumar Gala dba65ce47c drivers: Update DT IRQ alias defines
The defines should have had a _0 on them, now that we generate the
proper defines, fixup the cases that used that old scheme.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-21 07:53:05 -05:00
Derek Hageman 55bb37e35c drivers: serial: sam0: Implement DMA async API
This adds support for the async API for SAM0 SERCOM USARTs using
DMA to drive the device.

Tested on SAMD21 with a few trivial programs and with
tests/drivers/uart/uart_async_api.

Signed-off-by: Derek Hageman <hageman@inthat.cloud>
2019-05-30 17:18:44 -04:00
Derek Hageman 4709816a69 soc: sam0: Remove SERCOM defines from dts_fixup.h
Move SERCOM peripherals to use the raw defines generated from DTS
parsing.  This adds aliases to the DTS so that the SERCOM number
can still be used for clocking and pinmux.

Signed-off-by: Derek Hageman <hageman@inthat.cloud>
2019-05-03 08:46:57 -05:00
Kumar Gala e6e580305b serial: uart_sam0: Don't use CONFIG_ namespace for non Kconfig
The driver was defining a macro with a CONFIG_ prefix but this wasn't
coming from Kconfig.  Change the macro name not to conflict with the
Kconfig CONFIG_ namespace.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-01 19:01:16 -05:00
Flavio Ceolin 98d03266f1 serial: Change poll_out signature
poll_out function was returning the character that was sent. It
happens that it is always constant and the return of this functions is
never tested. Changing it to be a void function.

MISRA-C rule 17.7

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-11-29 10:18:59 -08:00
Andrzej Głąbek 20202902f2 dts_fixups: Use DT_ prefix in all defined labels not related to Kconfig
These changes were obtained by running a script  created by
Ulf Magnusson <Ulf.Magnusson@nordicsemi.no> for the following
specification:

1. Read the contents of all dts_fixup.h files in Zephyr
2. Check the left-hand side of the #define macros (i.e. the X in
   #define X Y)
3. Check if that name is also the name of a Kconfig option
   3.a If it is, then do nothing
   3.b If it is not, then replace CONFIG_ with DT_ or add DT_ if it
       has neither of these two prefixes
4. Replace the use of the changed #define in the code itself
   (.c, .h, .ld)

Additionally, some tweaks had to be added to this script to catch some
of the macros used in the code in a parameterized form, e.g.:
- CONFIG_GPIO_STM32_GPIO##__SUFFIX##_BASE_ADDRESS
- CONFIG_UART_##idx##_TX_PIN
- I2C_SBCON_##_num##_BASE_ADDR
and to prevent adding DT_ prefix to the following symbols:
- FLASH_START
- FLASH_SIZE
- SRAM_START
- SRAM_SIZE
- _ROM_ADDR
- _ROM_SIZE
- _RAM_ADDR
- _RAM_SIZE
which are surprisingly also defined in some dts_fixup.h files.

Finally, some manual corrections had to be done as well:
- name##_IRQ -> DT_##name##_IRQ in uart_stm32.c

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-11-13 10:44:42 -06:00
Kumar Gala 6d08958ad5 drivers: uart_sam0: move sercom pad info to dts
Move the setting of the SERCOM PAD for rxpo/txpo for the uart driver
into device tree out of board.h

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-05 10:05:47 -05:00
Paul Sokolovsky 57286afdd6 drivers: uart: Allow to pass arbitrary user data to irq callback
Zephyr UART drivers offer very low-level functionality. Oftentimes,
it would be useful to provide higher-level wrappers around UART
device which would offer additional functionality. However, UART
driver irq callback routine receives just a pointer to (low-level)
UART device, and it's not possible to get to a wrapper structure
(without introducing expensive external mapping structures). This
is an indirect reason why the current UARt wrappers - uart_pipe,
console - are instantiated statically just for one underlying UART
device and cannot be reused for multiple devices.

Solve this by allowing to pass an arbitrary user data to irq
callback, set by new uart_irq_callback_user_data_set() function.
Existing uart_irq_callback_set() keeps setting a callback which
will receive pointer to the device.

While public API maintains compatibility, drivers themselves need
to be updated to support arbitrary user data storage/passing (as
legacy uart_irq_callback_set() functionality is now implemented in
terms of it).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-08-02 19:20:12 +02:00
Sean Nyekjaer d9b105fff5 serial: sam0: add samd20 support
There are some minor differences between the UART om SAMD20 and SAMD21
that we need to take into account:

SYNCBUSY bit for the samd20 is located in the STATUS reg.

The samd20 does not have a SAMPR bit like the samd21.

Signed-off-by: Sean Nyekjaer <sean@nyekjaer.dk>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-02-21 08:07:09 -06:00
Michael Hope 247782a7b3 sam0: move the UART and SPI configuration into pinmux.
Also pull out the SERCOM pads configuration to defines.  Note that the
SAM0 has a two level configuration - a signal (like TX) is mapped to a
pad, and then a pad is mapped to a function on a pin.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-02-08 12:09:46 -06:00
Michael Hope 17fcbc3f9b serial: sam0: add support for interrupt based transmit.
Signed-off-by: Michael Hope <mlhx@google.com>
2018-01-10 21:49:18 -05:00
Michael Hope b85b676ba9 serial: add a serial driver for the SAM0 family.
Signed-off-by: Michael Hope <mlhx@google.com>
2018-01-04 13:18:25 -05:00