Commit graph

486 commits

Author SHA1 Message Date
Flavio Ceolin ad8ae7f735 dma: intel: Merge cavs and ace gpdma
cAVS and ACE gpdma driver have several similarities. This commit merge
this two drivers into a single one for Intel ADSP devices.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-07-11 10:21:17 +02:00
Flavio Ceolin d8c7aed261 dma: ace: Add ace gpdma driver
Add ace gpdma driver.

Co-authored-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-07-11 10:21:17 +02:00
Tom Burdick 572ccd531d intel_adsp: Use device tree to enable/disable each HDA driver
Uses the dt_compat_enabled Kconfig preprocessor to set defaults
for each HDA driver.

Each direction is uniquely selectable which can be useful when building
with SOF where only some directions may wish to be enabled at any given
time.

By default, given the device tree (intel_cavs.dtsi) only the host
directions are enabled but an overlay may adjust that as needed.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-07-08 14:33:06 -04:00
Adrian Bonislawski ef2644d40d dma/cavs_hda: add missing hda link files to CMakeLists
This patch will allow to build hda link in&out files

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2022-07-07 15:04:31 -04:00
Anas Nashif b330a05539 intel_adsp: add a new series to support Meteorlake
Meteorlake support as part of the Intel ADSP family.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Co-authored-by: Michal Wasko <michal.wasko@intel.com>
Co-authored-by: Konrad Leszczynski <konrad.leszczynski@intel.com>
Co-authored-by: Rafal Redzimski <rafal.f.redzimski@intel.com>
Co-authored-by: Enjia Mai <enjia.mai@intel.com>
Co-authored-by: Flavio Ceolin <flavio.ceolin@intel.com>
Co-authored-by: Tomasz Leman <tomasz.m.leman@intel.com>
Co-authored-by: Bonislawski Adrian <adrian.bonislawski@intel.com>
Co-authored-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
Co-authored-by: Andrey Borisovich <andrey.borisovich@intel.com>
2022-07-06 15:11:07 -04:00
Anas Nashif 49b36ead95 drivers: add mising braces to single line if statements
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-06 11:00:45 -04:00
Francois Ramu a20aa34301 drivers: dma: no irq when stopping dma channel
when the dma channel is stopped, the irq is no more
relevant ; clear any irq but do not process it.
Fix Typo on comments and add LOG_DBG on channel increment.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-07-06 11:19:47 +00:00
Fabio Baltieri e24314f10f include: add more missing zephyr/ prefixes
Adds few missing zephyr/ prefixes to leftover #include statements that
either got added recently or were using double quote format.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-05-27 15:20:27 -07:00
Gerard Marull-Paretas fb60aab245 drivers: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all drivers to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 19:58:21 +02:00
Tom Burdick 6913da9ddd logging: cAVS HDA based logger
Adds a log backend that maintains a ringbuffer in coordination
with cAVS HDA.

The DMA channel is expected to be given some time after the logger
starts so a seperate step to initialize the dma channel is required.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-05-04 18:56:13 -04:00
Francois Ramu 005968a81f drivers: dma: stm32 driver is using the STM32_DMA_STREAM_OFFSET
Includes the definition of the STM32_DMA_STREAM_OFFSET
depending on the peripheral to adjust the first DMA channel
in the list of streams.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-05-02 10:57:15 +02:00
Francois Ramu 41efe865ed drivers: dma: stm32 dma driver valid override control
This change is controlling of function parameters before
configuring the STM32_DMA_HAL_OVERRIDE mode.
Then, in case the DMA channel is not valid (wrong ID) or busy,
an error occurs before overriding the DMA channel.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-04-29 08:56:55 +02:00
Daniel DeGrasse 17d9bea474 drivers: edma: allow transfer descriptors to be placed in SRAM
SOCs using the EDMA IP that supported caching must locate EDMA transfer
control descriptors (TCDs) in non cacheable memory. For M7 cores, this
can simply use the "nocache" section. For M4 cores, where the nocache
section does not exist, the chosen SRAM section must be a tightly
coupled memory block which cannot be cached. Add a note to all boards
with M4 SOCs that support caching explaining this issue, and enable EDMA
driver to locate TCDs in SRAM.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-04-22 09:44:19 +02:00
Tom Burdick 2f320730a1 dma/cavs_hda: Adds link in/link out compatibles
Adds hda link in and out drivers. The link in and link
out channels of HDA have small differences
with the host channels. Updates the existing
cavs_hda drivers and code to account for these
differences.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-04-18 19:19:40 -04:00
Bartosz Bilas c51210beb0 drivers: dma: mcxuc_edma: remove superfluous default n for boolean
bool symbols implicitly default to n so
there is no need to redundant those values.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-04-15 10:32:24 -07:00
Nickolas Lapp c959ae81d6 dma_mcux_edma: Fixup Scatter-Gather EDMA Mode
This PR fixes up the Scatter-Gather EDMA mode for the MCUX EDMA Driver,
as well as enabling the dma reload feature for the same EDMA Driver.

Signed-off-by: Nickolas Lapp <nickolaslapp@gmail.com>
2022-04-14 15:21:58 -05:00
Tom Burdick 06cc6fe7a0 dma: dw: Use a LLI pool per device
Multiple instances of the device would have inadvertently shared the
LLI pool potentially causing nasty bugs.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-04-14 15:06:02 -04:00
Adrian Bonislawski cd11910201 dma/cavs_hda: Support channel filtering
Support channel filtering to find the requested channel
if filter_param provided

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2022-04-06 14:08:01 -04:00
Tom Burdick 9933f18ad3 dma/cavs_hda: Provide pending/free byte lengths
In status the pending/free byte lengths are now provided

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-04-01 09:12:20 -04:00
Tom Burdick c0b63d6afb dma/cavs_hda: Support source/dest width setting
Support adjusting the sample size to 16bits if the source
or destination width is set 3 or less.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-04-01 09:12:20 -04:00
Tom Burdick 602ef3fb0e soc/intel_adsp: Require definitions for cavs_hda.h
Rather than defining them in the header, require a set of defines
be provided to cavs_hda.h as part of the expected input to the API.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-04-01 09:12:20 -04:00
Tom Burdick e018a3dff7 dma/cavs_hda: DMA driver for HDA on cAVS
Adds an initial driver for HDA streams on cAVS. A common code base is
provided for all HDA streams while the drivers are identified
differently as they have small behavior differences.

Uses dma_status to describe the positions for read/write. Uses dma_reload
to inform when to move the read/write positions. This closely follows
how HDA is being used in SoF

Simple test case is provided for both drivers.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-04-01 09:12:20 -04:00
Tom Burdick 2f792c2de5 dma/dw_common: Update dma_dw_common from sof
Ports the SOF DesignWare DMA code to Zephyr.

Effectively replaces much of what was the designware driver as this
driver enables scatter gather which the older driver did not.

* Enables cyclic transfer description lists when the cyclic config
  param is given.
* Enables linear link position usage with cAVS GPDMA.
* Passes suspend/resume, scatter/gather tests.
* Provides status updates of the transfer through dma_get_status()
* Enables reloading a cyclic transfer with dma_reload()
* Enables dma handshakes using the dma_slot config param.
* cAVS specifics remain in the dma_cavs_gpdma driver.

Co-authored-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
Co-authored-by: Tom Burdick <thomas.burdick@intel.com>
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-03-29 14:33:48 -04:00
Nazar Kazakov f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Tomasz Bursztyka 9a18fdea3f drivers: Check and fix device const qualifier on ISR
Re-running the script that checks for the const qualifier missing on
struct device ISR's parameter.

The script also changes the parameter 'arg' to 'dev' when relevant.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2022-03-16 12:33:12 +01:00
Gerard Marull-Paretas 9953c194b9 drivers: remove redundant DEV_NAME helpers
Just use dev->name. This change follow same principles applied when
DEV_CFG and DEV_DATA macros were removed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-15 17:31:51 -04:00
Nazar Kazakov 9713f0d47c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-14 20:22:24 -04:00
Tom Burdick ad2799ed15 drivers: dma: nios2: const device driver config
Moves the nios2 msgdma driver device config struct to the device data
struct for mutable data. The config struct is expected to be const.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-03-09 14:13:02 -05:00
Gerard Marull-Paretas 95fb0ded6b kconfig: remove Enable from boolean prompts
According to Kconfig guidelines, boolean prompts must not start with
"Enable...". The following command has been used to automate the changes
in this patch:

sed -i "s/bool \"[Ee]nables\? \(\w\)/bool \"\U\1/g" **/Kconfig*

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-09 15:35:54 +01:00
Krzysztof Chruscinski 47ae656cc1 all: Deprecate UTIL_LISTIFY and replace with LISTIFY
UTIL_LISTIFY is deprecated. Replacing it with LISTIFY.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-08 11:03:30 +01:00
Gerard Marull-Paretas cb9a279050 drivers: dma: dw_common: fix style issue
Fix a couple of issues reported by checkpatch:

ERROR:POINTER_LOCATION: "(foo*)" should be "(foo *)"

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-04 08:55:45 -06:00
Tom Burdick d5e6027131 dma/cavs_gpdma: Revert IRQ_CONNECT changes
It turns out XCC didn't like this change as it doesn't have a
__COUNTER__ builtin. Bummer.

This reverts commit e8389f2f53.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-02-25 22:20:31 -05:00
Gerard Marull-Paretas cc3952e266 drivers: dma: iproc_pax: use DEVICE_DT_GET
The PCIe device can be obtained at compile time, so make code more
efficient thanks to that.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-02-21 22:16:10 -05:00
Tom Burdick e8389f2f53 dma: intel_adsp: Reduce irq setup code
Makes the IRQ_CONNECT macro statically declarable for Xtensa (nothing
prevented it except its structuring). Allows for IRQ_CONNECT usage
on a xtensa only platform to be declared statically avoiding the
fluff of setting up and enabling irqs for cavs gpdma.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-02-21 20:59:08 -05:00
Tom Burdick 1e9ada4eb9 dma: cavs: Add gpdma derivative of dw dma for cavs
Intel's adsp needs to set, at a minimum, a clocking bit before the driver
can initialize the designware dma controller. In many ways it is the
designware dmac IP but with additional registers and functionality added
on top of it. So the code structure here follows how the hardware
appears to be designed, layered on top of the designware driver.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-02-21 20:59:08 -05:00
Tom Burdick f9acacfd11 dma: dw: Common dw dma driver functionality
Move most of the designware driver into a common compile unit with a
a header that exposes the common functionality.

This allows for derivative hardware, such as that in intel's adsp (cavs)
to use the common functionality while extending.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-02-21 20:59:08 -05:00
Daniel DeGrasse 3603b6d501 drivers: dma: mcux_lpc_dma: Fix data variable name
Device 'data' variable name was incorrect due to recent treewide naming
cleanups. Fix variable name to fix build error.

Fixes #42118

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-01-25 14:09:30 -06:00
Tomasz Bursztyka 7bbf818cc5 drivers/dma: Fix conficting types for a variable name
Let's have dev_data for dev->data so it will not conflict with struct
call_back data variable.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2022-01-24 10:23:05 -05:00
David Leach eb9a97299d driver: edma: Fix MCUX NULL parameter check before dereference
Coverity identified valid error where the routine does a NULL
check for two different pointers after they have been dereferenced.

fixes #39868
fixes #39874

Signed-off-by: David Leach <david.leach@nxp.com>
2022-01-22 16:56:21 -05:00
Gerard Marull-Paretas 20d0260753 drivers: dma: mcux_lpc: fix variable name clash
data was already used by the struct call_back, rename device data to
`dev_data`.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-20 07:41:26 -06:00
Gerard Marull-Paretas 63d696e3b8 drivers: dma: iprox_pax_v1/2: constify device config access
`const` was missing from one device config access.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-19 18:16:02 +01:00
Gerard Marull-Paretas 8398105d82 drivers: fix style issues
Fix issues reported by checkpatch.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-19 18:16:02 +01:00
Gerard Marull-Paretas d2118eb1bc drivers: dma: drop DEV_DATA/DEV_CFG usage
Stop using redundant DEV_DATA/DEV_CFG macros and use dev->data and
dev->config instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-19 18:16:02 +01:00
Tom Burdick 0e96f59e83 dma: Add suspend resume implementation for edma
Implement the suspend and resume transfer api calls for NXP's eDMA.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-01-12 17:33:48 -05:00
Abel Radenac e8fa6b3f08 drivers: dma_stm32: init DMA struct in dma_stm32_configure
The init struct for DMA peripheral is allocated in stack
and must be initialized (e.g. with LL_DMA_StructInit here)
to avoid loading undefined values in the DMA peripheral
registers.

Signed-off-by: Abel Radenac <a.radenac@lacroix-sofrel.com>
2021-12-17 11:52:22 -06:00
Gerard Marull-Paretas d4a5a633a6 drivers: dma: mcux_edma: use instance based macros
Replace usage of DT_DRV_INST with instance based macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-17 17:30:06 +01:00
Daniel DeGrasse 20eed64030 drivers: edma: update MCUX dma driver for multi-instance
Updates mcux edma driver to handle multiple DMA instances correctly.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2021-12-08 08:40:06 -05:00
Maureen Helm b539699a98 drivers: dma: Refactor drivers to use shared init priority
Refactors all of the DMA drivers to use a shared driver class
initialization priority configuration, CONFIG_DMA_INIT_PRIORITY, to
allow configuring DMA drivers separately from other devices. This is
similar to other driver classes like I2C and SPI.

Most drivers previously used CONFIG_KERNEL_INIT_PRIORITY_DEFAULT or
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, therefore the default for this new
option is the lower of the two, which means earlier initialization.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2021-10-29 22:55:03 -04:00
Josh Hansen ae4f68c16d drivers: dma: stm32 Fix for STM32F1 SoCs
Not all STM32 parts have at least 5 DMA interrupt vectors for DMA2. In
particular, some STM32F1 XL-density devices only have 4 DMA2 interrupt
vectors, with Channels 4 and 5 sharing the same vector. Added
#if DT_INST_IRQ_HAS_IDX(1, 4) to prevent compiler errors on these SoCs.

Signed-off-by: Josh Hansen <jhansen3141@gmail.com>
2021-10-17 10:58:39 -04:00
Ron Smith 4f9ac180b4 drivers: dma: dma_sam0: change sam0 DMA to higher priority init.
fixes peripheral drivers such as async uart that rely on dma being
ready failing because dma is not initialized yet.

Signed-off-by: Ron Smith <rockyowl171@gmail.com>
2021-09-19 19:31:25 -04:00
Mahesh Mahadevan 91f172e4ad drivers: dma: Zero-initialize memory allocated using kmalloc
The code was wrongly calling DMA_Abort on a channel
that not initialized. This fixes Issue#38078

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2021-09-01 12:34:50 -04:00
Francois Ramu e90c47fbc4 drivers: dma: stm32 initialize a dma_stm32_data structure
In the dma.h there is a dma_ctx structure using a magic code
to be identify. This structure must be prepared as a new
element of the dma_stm32_data.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-08-27 13:08:33 -04:00
Francois Ramu c4161024c4 drivers: dma: stm32 dma of type V1 with mux
This is the configuration of the stm32h723 where the
dma1 & dma2 of type V1 with a MUX. Even if DMA is of type V1,
the 'feature' does not exist with DMAMUX

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-08-20 06:28:32 -04:00
Piotr Mienkowski 4b36416720 drivers: dma_sam_xdmac: add dma_reload function
Add implementation of `dma_reload()` function.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2021-07-27 09:52:07 -04:00
Francois Ramu 325edf23d7 drivers: dma: stm32 source_periph incorrectly set in dma_stm32
The flag source_periph seems to be incorrectly set in dma_stm32.
In case the transfer direction is from periph to mem, then the
stream->source_periph is 1 (true) else it is false.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-07-22 06:06:11 -04:00
Francois Ramu dcefbd67ed drivers: dma: stm32 dma driver for a new dma version
This is the dma V2bis which is particular DMA V2 instance for
stm32F1 and STM32L1 soc series. This DMA does not use the dma slot
Otherwise it is similar to version V2.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-07-22 04:52:53 -04:00
Francois Ramu 6312b7383d drivers: dma: stm32 dma driver using DT compat macro
Controlling the DMA offset  for the request, relies on the
dma version different from V1

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-07-22 04:52:53 -04:00
Krishna Mohan Dani ca0b261b7f drivers/dma: STM32: Initialising DMA_InitStruct with 0 for stm32l5xx
In stm32l5xx soc, the LL_DMA_InitTypeDef has 2 more fields
(DoubleBufferMode and TargetMemInDoubleBufferMode) that must be
initialised with 0 else the configuration is wrong and gives
wrong values to the LL_DMA_Init function. Due to this the test
tests/drivers/dma/loop_transfer too would fail.

Signed-off-by: Krishna Mohan Dani <krishnamohan.d@hcl.com>
2021-07-10 12:43:19 -04:00
Francois Ramu aa2e915fbf drivers: dma: stm32 dmamux has request 0 for mem-to-mem
The request ID = 0 is allowed for mem-to-mem data
transfer through the DMAMUX.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-05-21 04:55:02 -05:00
Simon Guinot 1945f70eee drivers: dma: stm32: fix build for STM32F0 MCUs
The STM32F0 MCUs (except STM32F030XC) don't have a DMA channel selection
register (DMA_CSELR). This patch fixes the build of the dma_stm32 driver
for them.

Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
2021-05-20 13:24:18 -05:00
Thomas Stranger 04ee034f4b drivers/dma: stm32 fix dmamux request id valid check
The request id is given by the DMA request MUX id which start at offset
1 and are vaid until req_nb + gen_nb.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2021-05-06 09:28:33 -05:00
Thomas Stranger 0014193193 drivers/dma: stm32 dmamux: use util_listify to gen. func/dma_chan arrays
This commit continues simplifying the generation of
isActiveFlag/clearFlag funtion pointer array for the request generators
and does the same for the table_ll_channel.
Additionally move struct dmamux_stm32_channel to c file.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2021-05-06 07:10:02 -05:00
Thomas Stranger d7fb6fa9f1 drivers/dma: stm32 dmamux: fix isActiveFlag/clearFlag function array len
This commit uses dt property dma-channels instead of ll defines to
make sure every soc has correct number of function pointers defined.

While commit 5f6218a tried to fix this for g0 series, this caused
regression for other series(e.g. stm32g431). Using UTIL_LISTIFY and
dt properties this should finally be fixed and reduce boilerplate code.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2021-05-06 07:10:02 -05:00
Mahesh Mahadevan b88d8070d7 drivers: dma: Update the LPC DMA driver
1. Update the SDK API's called in the configure implementation.
The DMA_PrepareTransfer and DMA_SubmitTransfer SDK functions
are not recommneded for use. Replaced the call to these SDK
functions with other SDK API's.
2. Fix the implementation the configure function when multiple
blocks are used.
3. Update the dma_reload implementation. The old reload function
would simply abort the transfer. The new implementation reloads
the DMA buffers for transfer.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2021-04-30 12:02:55 -05:00
Gerard Marull-Paretas 861eac31b8 drivers: dma: remove usage of device_pm_control_nop
device_pm_control_nop is now deprecated in favour of NULL.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 16:41:29 -04:00
Thomas Stranger 1e3512c94e drivers/dma: stm32: don't omit IRQ status check in dma_is_irq_active
Fix stm32_dma_is_irq_active not checking the IRQ status(IsEnabled) for
active interrupts.
While the transfer-complete, half-transfer comp.  and transfer-error
is_XX_irq_active() functions check for IRQ status (IsEnabled),
ORing the result with dma_stm32_is_gi_active() overrides the
status check as gi is always 1 in case any of these flags is active.
Related to commit 96c92ed93f.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2021-04-26 14:16:03 -04:00
Thomas Stranger e53ee41338 driver: dmamux: use LL_DMAMUX_CHANNEL_X flag to check if channels exists
Use LL_DMAMUX_CHANNEL_x defines instead of DMAMUX_CSR_SOF7x to check
if corresponding LL_DMAMUX_IsActiveFlag_SOx and LL_DMAMUX_ClearFlag_SOx
inline functions exist and should be added to func_ll_is_active_so[]
and func_ll_clear_so[].
The HAL of some socs uses the same flag to decide which registers exist
on a specific soc. And the same defines are used for table_ll_channel[]
initializations.

This is necessary because DMAMUX_CSR_SOF5 and DMAMUX_CSR_SOF6 were
wrongly added in the HALs soc header file for some stm32g0 socs,
therefore without this change some stm32g0 socs couldn't compile.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2021-04-26 14:16:03 -04:00
Thomas Stranger 5a475d7cc2 drivers/dma: stm32: add support for stm32g0 series
Update the existing driver to support STM32G0 series.
It enables the DMA_STM32_SHARED_IRQS flag for g0 series, such that
all interrupts are handled in a shared isr to avoid irq conflicts.
The shared isr is extended to be able to handle irqs from more than one
dma instance.

Furthermore the config_irq function of instance 1, which connects to the
irqs, was reworked to avoid irq conflicts when 2 dma instances on
stm32f0, or stm32g0 are enabled:
While dma1 has one exclusive irq for channel 1, and one irq for dma1
channels 2 and 3, all other channels share the same irq.
Therefore it is currently not possible to enable dma2 without enabling
dma1 at the same time, without getting an build errror due to an irq
conflict.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2021-04-26 14:16:03 -04:00
Thomas Stranger 73374fbfa9 driver: dmamux: enable clocks only if node has clocks property defined
Not all STM32 Series can enable a dedicated clock for dmamux.
In stm32g0 series for example the clock is enabled automatically
as long as either DMA1 or DMA2 is enabled.
This commit changes dmamux driver to cope with socs that don't have
defined a clocks property. Therefore it moves the config(and data)
struct into the c file to be able to use DT_INST_NODE_HAS_PROP macro.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2021-04-26 14:16:03 -04:00
Hake Huang b609242903 dma: add request channel and release channel helper
add two dma api for dynamic channel reqest and release

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2021-04-23 14:58:40 +02:00
Shlomi Vaknin 95143fc98e drivers: dma: stm32: add support for stm32h7
Add the missing parts for adding support
to stm32h7 dma driver.
The fix is to make dmamux driver work with
dma v1 driver.

Signed-off-by: Shlomi Vaknin <shlomi.39sd@gmail.com>
2021-04-14 18:18:12 +02:00
Hake Huang 81ed02d341 dma: mcux edma driver support multi-channel
1. remove redundant protection on channel status
2. update link interface to support major and minor link

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2021-04-08 16:38:49 +02:00
Shlomi Vaknin e9efa8a77c dma: stm32: enable half transfer interrupt
Enable half transfer interrupt of the dma controller
in case the channel was enabled in circular mode.

Signed-off-by: Shlomi Vaknin <shlomi.39sd@gmail.com>
2021-04-01 07:32:22 -05:00
Raveendra Padasalagi e2b51da6f5 drivers: dma: paxdma: increase bd buffers.
Increase BD buffers from 7 to 9 to handle 1024 block
counts having mega/normal src,dst bd combinations in one request.

Signed-off-by: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
2021-03-19 09:32:08 -04:00
Raveendra Padasalagi 9adbc5a616 drivers: dma: paxdma: Sync payload as separate packet
Sync packet is always CARD to HOST and if it's combined with HOST
to CARD transfers in one single RM header packet, it's not allowed
due to RM implementation constraints. RM implementation allows same
type of data transfer direction in all the BD's populated under one
header BD.

Signed-off-by: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
2021-03-19 09:32:08 -04:00
Raveendra Padasalagi 32d62972ce drivers: dma: paxdma: Use uncached sync bufer
Use uncached memory for sync payload buffer.

Signed-off-by: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
2021-03-19 09:32:08 -04:00
Arjun Jyothi 4fe04c84d4 drivers: dma: pl330: Zero initialize the ch_handle
Zero initialize the ch_handle in dma_pl330_configure().
The memset in dma_pl330_config_channel()is incorrect,
as the ch_handle is already populated with valid values and
the dma_pl330_config_channel() is overwriting with zeros.

Signed-off-by: Arjun Jyothi <arjun.jyothi@broadcom.com>
2021-03-04 12:59:46 +01:00
Raveendra Padasalagi 3c420566bd drivers: dma: pl330: remove callback
Removed dma callback in start() API, since dma
completion happens synchronously.

Signed-off-by: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
2021-03-04 12:59:46 +01:00
Raveendra Padasalagi 3bb095e710 drivers: dma: pl330: increase timeout
Increase timeout value related to dma completion status.

Signed-off-by: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
2021-03-04 12:59:46 +01:00
Raveendra Padasalagi f86889e7ec drivers: dma: pl330: fix warnings
Fix compile warnings in PL330 DMA driver.

Signed-off-by: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
2021-03-04 12:59:46 +01:00
Kumar Gala c308c4b1f6 drivers: dma: nios2_msgdma: Fix typo in irq priority
Extracting priority from the devicetree should specify instance 0, not
'inst'.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-03 06:28:34 -05:00
Kumar Gala d521129c4f dma: Kconfig remove unused kconfig symbols
All dma drivers are devicetree based now so we can remove the last
bits of Kconfig associated with the old driver style.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 20:28:35 -06:00
Kumar Gala b60b4be4e3 drivers: dma: nios2_msgdma: Conver to devicetree
Conver the NIOS-II mSGDMA driver to be devicetree based.  Add node for
dma controller into nios2f.dtsi.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 08:36:58 -06:00
Shlomi Vaknin 23bb30a73a stm32: dmamux: change initialization order to PRE_KERNEL_1
When running the tests of the async api of uart
on nucleo-l4r5zi we get MPU fault.
The reason is ordering initialization. The uart and dma
drivers are initialized PRE_KERNEL_1 while dmamux is
initialized POST_KERNEL.
Thus, the function device_get_binding fails since the
dmamux device is not ready to be used.

Fixes: #32715.

Signed-off-by: Shlomi Vaknin <shlomi.39sd@gmail.com>
2021-03-01 15:41:11 -06:00
Thomas Stranger 49b490161d drivers: dmamux_stm32: compile time dmamux channels initialization
Move dmamux_stm32_channels struct from device data to device
configuration and initialize the dmamux channel - dma channel
assignment during build time,
as this association is hardwired in all known series.
The information is taken from dma_offset and dma_requests device tree
properties. The current implementation is valid for series with either
a single or two dma peripherals and a single dmamux peripheral.
Both dmas can independently enabled.
As the driver uses multi-instance DT_INST_DEFINE, also macros for a
second dmamux are are added that should allow easier extension to a
second dmamux instance.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2021-02-25 21:57:59 +03:00
Kumar Gala b275fec8c4 soc: stm32: convert to use DEVICE_DT_GET for clocks
Convert from device_get_binding to DEVICE_DT_GET.  In doing this we
no longer need the label in the devicetree node so we remove that.

Removed all __ASSERT_NO_MSG(clk) since we'll get a build error if
DEVICE_DT_GET cant be satisfied, and the clock control api's will
handle reporting if the device_is_ready.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-16 17:01:37 -06:00
Kumar Gala 937dad2cb7 drivers: dma: iProc PAX: Fix use of deprecated APIs
Drivers are using DEVICE_AND_API_INIT which is deprecated so convert
the iproc_pax dma drivers over to using DEVICE_DT_INST_DEFINE and
DEVICE_DT_INST_GET.

Fixes #32153

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-10 07:16:11 -05:00
Shlomi Vaknin 5ccb89c3bc dma: stm32: remove dump stream info in irq
Remove printing dma stream info in irq context.
This is printed in case of error.

Signed-off-by: Shlomi Vaknin <shlomi.39sd@gmail.com>
2021-02-05 12:24:20 -05:00
Erwan Gouriou 96c92ed93f drivers/dma: stm32: Don't omit IRQ status check
When checking for IRQ flags, we should also check
for IRQ status (IsEnabled ?).
If this is not done we can end up in Half Transfer
interrupt processing while it is not enabled.

Additionaly always use the id translation function
in LL API calls.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-02-04 12:35:04 -05:00
Raveendra Padasalagi 228a3cffd6 drivers: dma: Add iProc PAXDMA driver
Add PAX[PCIE<->AXI] DMA driver which supports DMA
transfers between host and target memory over PCIe link.

Signed-off-by: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
2021-01-18 16:58:55 -05:00
Erwan Gouriou d43200e9c4 drivers/dma: stm32: Preparation for QSPI DMA mode support
In preparation for QSPI DMA mode:
-Add a possibility to override driver by the HAL DMA. In that case
stream is set as busy and no configuration nor treatment is done.
In case of interrupt, flags clearing is let to HAL.
-Treat Half Transfer interrupt prior to Transfer Complete for the
cases were both IRQ are both raised at the time IRQ handler is called

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-01-15 10:29:30 -05:00
Erwin Rol 4cc15d73dd drivers: dmamux: Remove need for kmalloc
Use file static variable for the channel config data, instead
of a dynamic array allocated with kmalloc.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2021-01-15 10:27:43 -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
Erwan Gouriou b226f1d446 drivers/dma: stm32: Base Konfig symbols on dts compatible status
In order to simplify the handling of DMA_STM32_V1/V2 and DMAMUX_STM32
symbols, set them directly based on related compatible status.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-01-11 16:49:39 -05:00
Erwan Gouriou a214f41992 dts/arm/st: Split "st,stm32-dma" compatible into -v1 and -v2
2 versions of DMA hardware blocks could be found across stm32 series.
In order to simplify the handling of matching Kconfig symbols,
make this visible in dts files by creating "st,stm32-dma-v1" and
"st,stm32-dma-v2" and set them accordingly in dtsi files.

Duplicate and update related bindings to reflect that new state.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-01-11 16:49:39 -05:00
Shlomi Vaknin cad96852a2 drivers: dma: stm32: add get_status to dmamux driver
Add `get_status` function to dmamux driver api.
This uses the regular dma driver `get_status` function.

Signed-off-by: Shlomi Vaknin <shlomi.39sd@gmail.com>
2020-12-20 13:00:46 -05:00
Kumar Gala 078368efcf drivers: dma: pl330: Convert drivers to new DT device macros
Convert dma pl330 driver from:

    DEVICE_AND_API_INIT -> DEVICE_DT_INST_DEFINE
    DEVICE_NAME_GET -> DEVICE_DT_INST_DECLARE

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-19 20:05:14 -05:00
Kumar Gala c5582358f6 drivers: dma: Convert drivers to new DT device macros
Convert dma drivers from:

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

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-19 20:03:23 -05:00
Kumar Gala 37e30726c8 drivers: dma: nios2_msgdma: 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 12:19:35 -05:00
Kumar Gala 7c699348a8 drivers: dma: mcux_edma: Convert drivers to new DT device macros
Convert dma mcux_edma driver from:

    DEVICE_AND_API_INIT -> DEVICE_DT_DEFINE
    DEVICE_GET -> DEVICE_DT_INST_GET

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-18 07:54:48 -06:00
Martin Jäger 00ac525603 drivers: dma: stm32: use generic LL headers
Use generic LL headers instead of depending on soc.h.

Signed-off-by: Martin Jäger <martin@libre.solar>
2020-11-30 15:50:03 +01:00
Francois Ramu e7f222a3b6 drivers: dma: stm32 dma source and dest data size must be equal
It raises an error in case the source data width differs
from the dest data width.
The dma_stm32_width_config function is no more useful: removed.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-11-26 14:18:28 +01:00
Francois Ramu 720863217d drivers: dma : stm32 with dmamux has a special offset
This new offset value in the dma config is made to
build the table of dma mux_channels with a dmamux.
Range depends on the nb of channels for selected dma instance

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-11-19 17:04:25 -05:00
Mahesh Mahadevan cb715fc813 drivers: dma: Update NXP LPC driver for SPI peripheral
1, Change the allocation of DMA descriptors for the case
when multiple buffers are used for DMA transfer. This was
tested during SPI DMA transfers
2. Add support for the case when source and destination
addresses should not be incremented.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2020-10-21 06:26:40 -05:00
Raveendra Padasalagi ea2107c429 drivers: dma: pl330: const-ify device instance
Fix compilation issue associated with const-ifying
pl330 device instance.

Signed-off-by: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
2020-10-16 06:50:49 -05:00
Alexandre Bourdiol 41621ba0bf drivers: dma: dma_stm32_v2: typo in compilation switch
For example, LL_DMA_IFCR_CTEF6 doesn't exist,
it must be replaced by LL_DMA_IFCR_CTEIF6.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-09-11 09:31:27 -05:00
Alexandre Bourdiol 4dbd96900d drivers: dma: dma_stm32: can't use device_get_binding() during init
Not possible to use device_get_binding() because we are
currently initializing DMA_1 device, so it is not ready and
device_get_binding() will fail.
Directly use string compare is more efficient.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-09-11 09:31:27 -05:00
Francois Ramu fafb72f8ed drivers: dma: dmamux init needs k_malloc
The dmamux requires HEAP size definition, so that k_malloc
is valid. The HEAP size config is defined in the common for
any stm32 soc instead of specific to dma Kconfig

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-09-04 10:42:18 -05:00
Erwin Rol 113b016b51 drivers: dma: stm32: change order of disabling and checking result
The stm32_dma_disable_stream first checked if the stream was
disabled and if so returned OK. If it wasn't disabled it
tried to disable it and returned -EAGAIN.

The function is used in loops that try to disable the stream
by calling this function and if it fails wait for 1ms and
retry.

Becuase this function the first time (if the stream wasn't
disabled already) fails there is always a 1 ms delay. For
the SPI driver, that has a RX and TX stream, this means
a 2ms delay between the last data and CS going high.

By first trying to disable the stream and than checking
if it succeded most of the time the first call disables
the stream and the 1ms delay isn't needed.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2020-09-04 12:00:37 +02:00
Erwin Rol 742256f8ed drivers: dma: stm32: only set mem pool size when using DMAMUX
The general DMA driver doesn't use kmalloc anymore so it doesn't
need a memory pool. The DMAMUX_SMT32 driver still uses kmalloc,
so move the HEAP_MEM_POOL_SIZE config under DMAMUX_STM32.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2020-09-03 21:50:58 +02:00
Erwin Rol 7b8b219d63 drivers: dma: stm32: check result of stream disabling
Use dma_stm32_disable_stream instead of stm32_dma_disable_stream
to check if the disabling of the stream really worked and if
not return an error.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2020-09-03 21:50:58 +02:00
Erwin Rol 2da881a0ed drivers: dma: stm32: prevent posible out of bound access
Set pointer to an array element only after checking the bounds
of the index.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2020-09-03 21:50:58 +02:00
Erwin Rol 3866b39bb2 drivers: dma: stm32: remove global function tables
Convert the driver from global function tables to functions
that use static const function tables.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2020-09-03 21:50:58 +02:00
Erwin Rol b05dc440e0 drivers: dma: stm32: convert global conversion tables to functions
Convert global conversion tables for id-to-stream and slot-to-channel
to functions that use local const static conversion tables.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2020-09-03 21:50:58 +02:00
Erwin Rol 67f68e68f1 drivers: dma: stm32: refactor irq handling
- Remove the need for kmalloc
- On hardware that supports it use 1 IRQ handler per stream to
  determine the stream ID, so the ISR does not have to loop
  over all ID's to see which one is active. On hardware (like
  STM32L0 and STM32F0) where up to 7 streams share 3 IRQ's use
  the loop to check which stream is active.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2020-09-03 21:50:58 +02:00
Erwin Rol c8ae070de7 drivers: dma: stm32: Improve code readability
Some small code readability changes.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2020-09-03 21:50:58 +02:00
Erwin Rol 1c6a405ccb drivers: dma: stm32: Use volatile for flag used in ISR
Use volatile for flag shared between normal code and ISR to
prevent the compiler from possibly optimizing it away.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2020-09-03 21:50:58 +02:00
Tomasz Bursztyka ef560e0a53 drivers: Manual const-ification of device driver instance
These are all the case that coccinelle cannot find as they are inside
macro declarations.

Fixed via:

git grep -rlz -E "\(struct device \*" |
	xargs -0 sed -i 's/(struct device/(const struct device/g'

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka 4dcfb5531c isr: Normalize usage of device instance through ISR
The goal of this patch is to replace the 'void *' parameter by 'struct
device *' if they use such variable or just 'const void *' on all
relevant ISRs

This will avoid not-so-nice const qualifier tweaks when device instances
will be constant.

Note that only the ISR passed to IRQ_CONNECT are of interest here.

In order to do so, the script fix_isr.py below is necessary:

from pathlib import Path
import subprocess
import pickle
import mmap
import sys
import re
import os

cocci_template = """
@r_fix_isr_0
@
type ret_type;
identifier P;
identifier D;
@@
-ret_type <!fn!>(void *P)
+ret_type <!fn!>(const struct device *P)
{
 ...
(
 const struct device *D = (const struct device *)P;
|
 const struct device *D = P;
)
 ...
}

@r_fix_isr_1
@
type ret_type;
identifier P;
identifier D;
@@
-ret_type <!fn!>(void *P)
+ret_type <!fn!>(const struct device *P)
{
 ...
 const struct device *D;
 ...
(
 D = (const struct device *)P;
|
 D = P;
)
 ...
}

@r_fix_isr_2
@
type ret_type;
identifier A;
@@
-ret_type <!fn!>(void *A)
+ret_type <!fn!>(const void *A)
{
 ...
}

@r_fix_isr_3
@
const struct device *D;
@@
-<!fn!>((void *)D);
+<!fn!>(D);

@r_fix_isr_4
@
type ret_type;
identifier D;
identifier P;
@@
-ret_type <!fn!>(const struct device *P)
+ret_type <!fn!>(const struct device *D)
{
 ...
(
-const struct device *D = (const struct device *)P;
|
-const struct device *D = P;
)
 ...
}

@r_fix_isr_5
@
type ret_type;
identifier D;
identifier P;
@@
-ret_type <!fn!>(const struct device *P)
+ret_type <!fn!>(const struct device *D)
{
 ...
-const struct device *D;
...
(
-D = (const struct device *)P;
|
-D = P;
)
 ...
}
"""

def find_isr(fn):
    db = []
    data = None
    start = 0

    try:
        with open(fn, 'r+') as f:
            data = str(mmap.mmap(f.fileno(), 0).read())
    except Exception as e:
        return db

    while True:
        isr = ""
        irq = data.find('IRQ_CONNECT', start)
        while irq > -1:
            p = 1
            arg = 1
            p_o = data.find('(', irq)
            if p_o < 0:
                irq = -1
                break;

            pos = p_o + 1

            while p > 0:
                if data[pos] == ')':
                    p -= 1
                elif data[pos] == '(':
                    p += 1
                elif data[pos] == ',' and p == 1:
                    arg += 1

                if arg == 3:
                    isr += data[pos]

                pos += 1

            isr = isr.strip(',\\n\\t ')
            if isr not in db and len(isr) > 0:
                db.append(isr)

            start = pos
            break

        if irq < 0:
            break

    return db

def patch_isr(fn, isr_list):
    if len(isr_list) <= 0:
        return

    for isr in isr_list:
        tmplt = cocci_template.replace('<!fn!>', isr)
        with open('/tmp/isr_fix.cocci', 'w') as f:
            f.write(tmplt)

        cmd = ['spatch', '--sp-file', '/tmp/isr_fix.cocci', '--in-place', fn]

        subprocess.run(cmd)

def process_files(path):
    if path.is_file() and path.suffix in ['.h', '.c']:
        p = str(path.parent) + '/' + path.name
        isr_list = find_isr(p)
        patch_isr(p, isr_list)
    elif path.is_dir():
        for p in path.iterdir():
            process_files(p)

if len(sys.argv) < 2:
    print("You need to provide a dir/file path")
    sys.exit(1)

process_files(Path(sys.argv[1]))

And is run: ./fix_isr.py <zephyr root directory>

Finally, some files needed manual fixes such.

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka 5c9dd0de78 drivers: Apply dynamic IRQ API change
Switching to constant parameter.

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka d1aee6b87f drivers: dma: Fix device instance const qualifier loss in NIOS2 driver
Passing the device's config was necessary, and wrapping device inside
it.

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Mahesh Mahadevan f75f8bec20 MXRT600: Add DMA support
Add DMA support for MCUX LPC SoC's

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2020-08-28 14:24:21 -05:00
Tomasz Bursztyka 98d9b01322 device: Apply driver_api/data attributes rename everywhere
Via coccinelle:

@r_device_driver_api_and_data_1@
struct device *D;
@@
(
D->
-	driver_api
+	api
|
D->
-	driver_data
+	data
)

@r_device_driver_api_and_data_2@
expression E;
@@
(
net_if_get_device(E)->
-	driver_api
+	api
|
net_if_get_device(E)->
-	driver_data
+	data
)

And grep/sed rules for macros:

git grep -rlz 'dev)->driver_data' |
	xargs -0 sed -i 's/dev)->driver_data/dev)->data/g'

git grep -rlz 'dev->driver_data' |
	xargs -0 sed -i 's/dev->driver_data/dev->data/g'

git grep -rlz 'device->driver_data' |
	xargs -0 sed -i 's/device->driver_data/device->data/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Tomasz Bursztyka af6140cc0d device: Apply config_info rename everywhere
Via coccinelle:

@r_device_config@
struct device *D;
@@

D->
-	config_info
+	config

And 2 grep/sed rules for macros:

git grep -rlz 'dev)->config_info' |
	xargs -0 sed -i 's/dev)->config_info/dev)->config/g'

git grep -rlz 'dev->config_info' |
	xargs -0 sed -i 's/dev->config_info/dev->config/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Tomasz Bursztyka 1580768fd3 drivers: dma: Align all drivers using user_data for callback
s/callback_arg/user_data

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:48:00 +02:00
Tomasz Bursztyka 3a3f10c06e drivers: dma: Align all drivers using dma_callback_t type
No need to re-declare such signature anymore.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:48:00 +02:00
Tomasz Bursztyka 6acee3dcba drivers: dma: Apply DMA callback change to relevant drivers
Now the dma device instance is passed as parameter to the callback.

Fixes #26923

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:48:00 +02:00
Raveendra Padasalagi f4a141639d drivers: dma: Add pl330 dma driver
Add PL330 dma driver support, this driver
- supports 32 bit memory to memory operation
- supports 36 bit memory to memory operation
  under a config flag DMA_64BIT
- supports secure channel

Signed-off-by: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
2020-07-24 11:54:31 +02:00
Raveendra Padasalagi 306980816a dma: Support 64bit source/dest address
Add 64bit source_address/dest_address fields support.
This is needed in situation where DMA controller is capable
of handling more than 32bit source and destination addresses.

Signed-off-by: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
2020-07-24 11:54:31 +02:00
Henrik Brix Andersen 381a1cfcd2 drivers: dma: mcux_dma: add support for the NXP KE1xF
Add support for the NXP KE1xF SoC to the eDMA driver. The KE1xF supports
m2m DMA transfers from sources 60 to 63.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-07-21 08:56:51 -05:00
Henrik Brix Andersen c89ef2f393 drivers: dma: mcux_emda: only enable nocache memory if supported
Only enable CONFIG_NOCACHE_MEMORY if supported by the SoC.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-07-21 08:56:51 -05:00
Jun Li 486dab02ec dma: stm32: implement get_status api
get_status api is not implemented in stm32 dma driver
but it will be used by others like async uart driver.

Signed-off-by: Jun Li <jun.r.li@intel.com>
2020-06-16 10:55:19 -05:00
Jun Li 8f7832cfb2 dma: stm32: increase driver init priority
DMA driver shall be initialized before any of its
clients. Right now, its initialization priority is
lower than that of UARTs. So, increase its init
priority to support future async uart drivers.

Signed-off-by: Jun Li <jun.r.li@intel.com>
2020-06-16 16:37:24 +02:00
Hake Huang 999c59c1ec dma: add error check on peripheral to peripheral
add dma direction check for dma_sam0

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2020-06-12 13:03:28 -05:00
Hake Huang 10fc7a38cc dma: add EDMA MCUX support for RT and k6s
tested on mimxrt1060_evt
  MEMORY_NOCACHE is needed
test on frdmk64f
  special test slot need configure with
  CONFIG_DMA_TEST_SLOT_START

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2020-06-12 13:03:28 -05:00
Peter Bigot bc34501892 drivers: use macro to define device structures
Replace individual device instance definitions with the macro that
expands to the equivalent change.

    F='struct device DEVICE_NAME_GET'
    git grep -l "$F" \
     | xargs sed -i -r \
       -e "s@$F"'\(([^)]*)\);@DEVICE_DECLARE(\1);@'

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-06-08 15:01:52 -04: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 6e8775ff84 devicetree: remove DT_HAS_NODE_STATUS_OKAY
Several reviewers agreed that DT_HAS_NODE_STATUS_OKAY(...) was an
undesirable API for the following reasons:

- it's inconsistent with the rest of the DT_NODE_HAS_FOO names
- DT_NODE_HAS_FOO_BAR_BAZ(node) was agreed upon as a shorthand
  for macros which are equivalent to
  DT_NODE_HAS_FOO(node) && DT_NODE_HAS_BAR(node) &&
- DT_NODE_HAS_BAZ(node), and DT_HAS_NODE_STATUS_OKAY is an odd duck
- DT_NODE_HAS_STATUS(..., okay) was viewed as more readable anyway
- it is seen as a somewhat aesthetically challenged name

Replace all users with DT_NODE_HAS_STATUS(..., okay), which is
semantically equivalent.

This is mostly done with sed, but a few remaining cases were done by
hand, along with whitespace, docs, and comment changes. These special
cases include the Nordic SOC static assert files.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 18:24:42 +02: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
Kumar Gala 49bab484df drivers: dma: sam_xdmac: Convert to devicetree
Convert sam_xdmac driver to utilize devicetree.  As part of the
controller binding we specify that dmas should contain a channel and the
perid for the DMA transaction.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-07 22:24:58 -05: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
Martí Bolívar 87e1743ae0 devicetree: replace DT_HAS_DRV_INST with DT_INST_FOREACH
Make drivers multi-instance wherever possible using DT_INST_FOREACH.
This allows removing DT_HAS_DRV_INST in favor of making drivers just
do the right thing regardless of how many instances there are.

There are a few exceptions:

- SoC drivers which use CMake input files (like i2c_dw.c) or otherwise
  would require more time to convert than I have at the moment. For the
  sake of expediency, just inline the DT_HAS_DRV_INST expansion for
  now in these cases.

- SoC drivers which are explicitly single-instance (like the nRF SAADC
  driver). Again for the sake of expediency, drop a BUILD_ASSERT in
  those cases to make sure the assumption that all supported SoCs have
  at most one available instance is valid, failing fast otherwise.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-06 17:35:08 -05:00
Stephanos Ioannidis 2a710b1372 Revert "drivers: dma: sam0: fix DMA to peripheral transfer on SAMD5x"
This reverts commit 90cc723e65.

Using `DMAC_CHCTRLA_TRIGACT_BLOCK` breaks SERCOM UART peripheral DMA
operations (DMA-based asynchronous UART transmit operation only sends
the first byte and does not proceed any further).

The `DMAC_CHCTRLA_TRIGACT_BURST` with `DMAC_CHCTRLA_BURSTLEN(0)` is a
special case utilising the "internal FIFO", according to the datasheet
(see DS60001507E; 22.6.2.8), and should always be specified for
peripheral data transfer operations.

Also it is worth noting that Atmel and other third-party drivers use
the aforementioned "internal FIFO" configuration for peripheral data
transfers as well.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-05-05 13:53:49 -05:00
Abe Kohandel 8c7f63cf8d drivers: dma: stm32: DMA V1 channel direction
The channel direction for a V1 DMA is not allowed to be memory to memory
and there is a check in place for this. However, the check is being
performed on the stream prior to actually configuring the stream. This
results in the check always failing regardless of the channel direction.

The check has been modified to be performed on the incoming
configuration.

Signed-off-by: Abe Kohandel <abe@electronshepherds.com>
2020-05-05 13:48:09 -05:00
Francois Ramu 41df1c9380 drivers: dma: Enable dma and dmamux on stm32
This patch prepares the dma and introduces the dmamux on soc series
which supports this feature for memory/periph transfers.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-05-05 11:51:25 -05:00
Francois Ramu bea0a95578 drivers: dma: stm32 dma_reload function must re-enable
This patch is disabling the dma channel before reloading
source and dest for memory and peripheral addresses
Then the channel is enabled to re-launch the transfer.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-05-04 09:46:07 -05:00
Francois Ramu 7ed83ded6d drivers: dma: initialize peripheral request dma on stm32
Set the peripheral ID for the Channel Selection register

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-04-17 03:13:02 -05:00
Francois Ramu a9f277a61b drivers: dma: control of null buffer address for stm32 dma transfers
Raise warning if the buffer address of the source or the dest is NULL

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-04-17 03:13:02 -05:00
Francois Ramu 60644a3e2c drivers: dma: irq handler of the dma_stm32
define the irq handler in case of DMA V1 or V2,
for the stm32x soc series
with DMA V1 raise Fifo Error if enabled
with V2, handle the Global Interrupt

Signed-off-by: Francois Ramu <francois.ramu@st.com>
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-04-17 03:13:02 -05:00
Francois Ramu e135bba72e drivers: dma: channel direction of the dma_stm32
Return an error if the direction of the channel is wrong

Signed-off-by: Francois Ramu <francois.ramu@st.com>
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-04-17 03:13:02 -05:00
Francois Ramu 1b0503d2cd drivers: dma: clean up header
Move tables declaration as they are only used locally for now

Signed-off-by: Francois Ramu <francois.ramu@st.com>
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-04-17 03:13:02 -05:00
Erwan Gouriou de4ba27539 drivers: dma: channel configuration for dma_stm32
Control values when configuring the dma channel
According to the soc specification,
the dma V2 channel counts from 1.
the dma V1 stream counts from 0.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-04-17 03:13:02 -05:00
Francois Ramu c4bf6ac1f9 drivers: dma: include duplicated
remove duplicates line

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-04-17 03:13:02 -05:00
Abe Kohandel d35567b375 drivers: dma: stm32: Stream disable success
When a DMA stream is successfully disabled, the function should
immediately return with a success status.

Signed-off-by: Abe Kohandel <abe@electronshepherds.com>
2020-04-08 12:21:05 -05:00
Ioannis Glaropoulos ba6dc5bc25 drivers: dma: sam0: fix macro definition
Fix the definition of DMA_SAM0_IRQ_CONNECT
pre-processor directive, so that it calls
DT_INST_IRQ_BY_IDX macro instead of
DT_INST_IRQ_HAS_IDX macro.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-03-30 08:32:17 -05:00
Kumar Gala 1aa5b5a414 drivers: dma: dma_dw: 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 08:29:30 -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 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 f91b4dbe94 drivers: dma: dma_dw: convert to DT_INST defines
Convert driver to use DT_INST_ defines.  The preferred defines for
drivers are DT_INST_.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-11 07:59:38 -06:00
Kumar Gala 6d1a32a60d drivers: dma: stm32: Fix compiler warning
When building the i2s tests on 96b_argonkey we get the following
warnings:

drivers/dma/dma_stm32.c: In function 'dma_stm32_configure':
drivers/dma/dma_stm32.c:181:2: error: 'periph_addr_adj' may be used
  uninitialized in this function [-Werror=maybe-uninitialized]
  181 |  switch (increment) {
      |  ^~~~~~
drivers/dma/dma_stm32.c:161:2: error: 'memory_addr_adj' may be used
   uninitialized in this function [-Werror=maybe-uninitialized]
  161 |  switch (increment) {
      |  ^~~~~~

Fix by initialzing periph_addr_adj and memory_addr_adj to 0.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-04 15:49:48 -06:00
Tomasz Bursztyka ab72e3478f drivers/dma: Add support for 3 instances instead of only one.
If more is needed, it will be added.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-01-28 18:18:18 -05:00
Tomasz Bursztyka dff4857349 drivers/dma: Make initialization function generic in DW driver
There will be more instance of that driver, and the initialization
function will the same all the time. That was done wrong as it was not
following the device driver rules.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-01-28 18:18:18 -05:00
Tomasz Bursztyka defa1bce5f drivers/dma: Use DTS generated option when configuring DW driver
This driver is going to be used by other SoCs and as such should be
easily configurable through DTS.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-01-28 18:18:18 -05:00
Tomasz Bursztyka 414f8b037d driver/dma: No need to store IRQ number in DW driver
irq_enable() can be directly called from relevant irq config function
and thus voids the necessity to store the IRQ number, saving some
memory.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-01-28 18:18:18 -05:00
Tomasz Bursztyka e33432fd44 drivers/dma: Rename CAVS driver to DesignWare
There is no such thing as CAVS DMA IP block, the DMA IP block found on
CAVS based chips is made with DesignWare one.

This will help to centralize DW based DMA device into one driver.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-01-28 18:18:18 -05:00
Francois Ramu 25700ace0a soc: arm: stm32: define the heap size when enabling dma feature
when DMA IP is enabled on stm32 series,
the heap size must be configured to large value
because of dma channels configuration.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-01-28 12:58:44 -06:00
Francois Ramu 3553d4fa69 driver: dma: split header file differently
This patches just changes the header file organisation

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-01-28 12:58:44 -06:00
Francois Ramu 53dec09037 driver: dma: update for different dma channels
This patches defines constants from dma registers
depending on the dma configuration of the stm32 soc
Some devices have 6 or 7 or 8 dma channels per dma instance

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-01-28 12:58:44 -06:00
Francois Ramu a569303f70 drivers: dma: wrong return type of dma_stm32_width_config function
The dma_stm32_width_config must return a int type
as -EINVAL is a possible return value

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-01-28 12:58:44 -06:00
Francois Ramu 82799d2ae4 dts: bindings: dma controller supports mem2mem transfer
This checks if the DMA controller supports or not
the memory-to-memory transfers. For DMA Version1,
in the stm32f2xx, stm32f4xx, stm32f7xx series,
only DMA instance 2 is able to transfer mem-to-mem.
For other series, with DMA Version2, there is no such a limitation.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-01-28 12:58:44 -06: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
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
Song Qiang 65c1d764bb drivers: dma: stm32: add missing assignment for fifo threshold
Fixes #20490.

Signed-off-by: Song Qiang <songqiang1304521@gmail.com>
2019-12-09 09:42:24 -06:00
Song Qiang 40962a81e7 drivers: dma: stm32: add missing fifo operation
The DMA driver of stm32 used to use `stm32_dma_enable_fifo()`,
which is located in dma_stm32_v1.c to set DMDIS bit, enable
interrupt generation and set FIFO threshold. Now since FIFO
threshold is initialized with `stm32_dma_get_fifo_threshold()`
and interrupt generation is also configured in dma_stm32.c, this
function will only have one job, to configure FIFO mode.
We can add FIFO mode operation in dma_stm32.c directly and
remove it from dma_stm32_v1.c.

Signed-off-by: Song Qiang <songqiang1304521@gmail.com>
2019-12-09 09:42:02 -06:00
Ulf Magnusson d0a6f682d1 kconfig: Fix up newly-introduced copy-pasted headers
Same deal as in https://github.com/zephyrproject-rtos/zephyr/pull/20280,
for newly-introduced stuff.

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

Also fix some un-indented properties on choices. Choice properties work
the same as symbol properties syntactically.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-19 15:25:08 -05:00
Song Qiang 749d2d21bf drivers: dma: add generic driver support for some series of stm32
This commit adds driver support for DMA on f0/f1/f2/f3/f4/l0/l4
series stm32.

Notice due to some bugs, this is currently not working with f7.

There are two kinds of IP blocks are used across these stm32, one is the
one that has been used on F2/F4/F7 series, and the other one is the one
that has been used on F0/F1/F3/L0/L4 series.

Memory to memory transfer is only supported on the second DMA on
F2/F4 with 'st,mem2mem' to be declared in dts.

This driver depends on k_malloc to allocate memory for stream instances,
so CONFIG_HEAP_MEM_POOL_SIZE must be big enough to hold them.

Common parts of the driver are in dma_stm32.c and SoC related parts are
implemented in dma_stm32_v*.c.

This driver has been tested on multiple nucleo boards, including
NUCLEO_F091RC/F103RB/F207ZG/F302R8/F401RE/L073RZ/L476RG with the
loop_transfer and chan_blen_transfer test cases.

Signed-off-by: Song Qiang <songqiang1304521@gmail.com>
2019-11-06 14:14:39 +01:00
Benjamin Valentin 90cc723e65 drivers: dma: sam0: fix DMA to peripheral transfer on SAMD5x
We need to select TRIGACT_BLOCK for DMA to peripheral to work.

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2019-11-05 23:29:50 +01: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 975de21858 kconfig: Global whitespace/consistency cleanup
Clean up space errors and use a consistent style throughout the Kconfig
files. This makes reading the Kconfig files more distraction-free, helps
with grepping, and encourages the same style getting copied around
everywhere (meaning another pass hopefully won't be needed).

Go for the most common style:

 - Indent properties with a single tab, including for choices.

   Properties on choices work exactly the same syntactically as
   properties on symbols, so not sure how the no-indentation thing
   happened.

 - Indent help texts with a tab followed by two spaces

 - Put a space between 'config' and the symbol name, not a tab. This
   also helps when grepping for definitions.

 - Do '# A comment' instead of '#A comment'

I tweaked Kconfiglib a bit to find most of the stuff.

Some help texts were reflowed to 79 columns with 'gq' in Vim as well,
though not all, because I was afraid I'd accidentally mess up
formatting.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-01 15:53:23 +01:00
Ulf Magnusson 66682a2ee9 drivers: dma: kconfig: Remove unused DMA_1/2_IRQ_PRI symbols
Added in commit bb36c0af86 ("dma: Add possibility for up to 3 DMA
Controllers") in February 2017, then never used.

Found with a script.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-10-22 23:41:01 +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
Anas Nashif 5cde4ea245 drivers: dma: remove qmsi DMA driver
No users of this driver after dropping quark platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-18 11:06:18 -05:00
Andy Ross 075c94f6e2 kernel: Port remaining syscalls to new API
These calls are not accessible in CI test, nor do they get built on
common platforms (in at least one case I found a typo which proved the
code was truly unused).  These changes are blind, so live in a
separate commit.  But the nature of the port is mechanical, all other
syscalls in the system work fine, and any errors should be easily
corrected.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-09-12 11:31:50 +08:00
Anas Nashif 578ae40761 boards: remove quarl_se_c1000
This board and SoC was discontinued some time ago and is currently not
maintained in the zephyr tree.
Remove all associated configurations and variants from the tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-07-29 21:30:25 -07:00
Anas Nashif a2fd7d70ec cleanup: include/: move misc/util.h to sys/util.h
move misc/util.h to sys/util.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 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 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
Derek Hageman 59786b43b3 drivers: sam0: Fix deprecated instance macro usage
During conversion in #16815 a few device tree instance macro aliases
where missed (probably due to them existing to support future SoCs
and so not currently compiled), this fixes their usage.

Signed-off-by: Derek Hageman <hageman@inthat.cloud>
2019-06-24 07:21:26 -04:00
Kumar Gala a2693975d7 dts: Convert from DT_<COMPAT>_<INSTANCE>_<PROP> to DT_INST...
Change code from using now deprecated DT_<COMPAT>_<INSTANCE>_<PROP>
defines to using DT_INST_<INSTANCE>_<COMPAT>_<PROP>.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-14 08:02:15 -05:00
Anas Nashif 4c32258606 style: add braces around if/while statements
Per guidelines, all statements should have braces around them. We do not
have a CI check for this, so a few went in unnoticed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-06 15:20:21 +02:00
Derek Hageman 64e02021ee drivers: dma: sam0: Implement get_status API
Implement the get_status DMA API for the SAM0 DMA controller.
The busy field is set only when the selected channel is
actively transferring data (i.e. both enabled and selected by the
arbiter).  The direction field is left unset, since that
information is not normally retained by the DMA controller.

Signed-off-by: Derek Hageman <hageman@inthat.cloud>
2019-05-30 17:18:44 -04:00
Jun Li 74e320d859 api: dma: add api to retrieve runtime status
Some applications using DMA, such as UART RX, could
need to complete the current DMA transaction earlier than
predefined, based on other termination conditions,
like UART's IDLE interrupts.

In that case, the client needs to know how many data are
still left in DMA transfer buffer so that it can figure
out how many data has been transfered. However, the current
DMA API doesn't provide any information for the client
to learn the transfer buffer information.

And some other information, like whether DMA transfer is busy
or not, transfer direction, etc, could interest a client.

So, added a dma API function to retrieve the current DMA
runtime status.

And implemented the API for STM32F4's DMA while keeping
others unimplemented.

Signed-off-by: Jun Li <jun.r.li@intel.com>
2019-05-07 22:14:36 -04:00
Michael Hope ba21de582b drivers: dma: Add SAM0 DMAC driver
This adds support for the SAM0 DMA Controller (DMAC).  Chained
transfer are not currently implemented.

Tested with tests/drivers/dma/loop_transfer and custom modifications
to that test using three parallel reloading channels.  Also tested
with a trivial program that did memory->serial.

Signed-off-by: Michael Hope <mlhx@google.com>

[hageman@inthat.cloud: Rebased and updated commit message]
Signed-off-by: Derek Hageman <hageman@inthat.cloud>
2019-05-02 19:20:12 -05:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Armando Visconti c0ffa6f2b7 dma: stm32f4: Add support for dma_reload API specific implementation
The dma_reload() is useful when there's the need to immediately
and quickly restart the DMA for a new transfer when the current
one is completed. If the operation is not done quickly there
might be underrun or overrun errors and the data flow is broken.

The dma_reload() just does the minimum operations required, i.e.
programming the new src/dst addresses and transfer size.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2019-03-18 11:22:19 -05:00
Ramakrishna Pallala e1639b5345 device: Extend device_set_power_state API to support async requests
The existing device_set_power_state() API works only in synchronous
mode and this is not desirable for devices(ex: Gyro) which take
longer time (few 100 mSec) to suspend/resume.

To support async mode, a new callback argument is added to the API.
The device drivers can asynchronously suspend/resume and call the
callback function upon completion of the async request.

This commit adds the missing callback parameter to all the drivers
to make it compliant with the new API.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2019-03-14 14:26:15 +01:00
Patrik Flykt 4344e27c26 all: Update reserved function names
Update reserved function names starting with one underscore, replacing
them as follows:
   '_k_' with 'z_'
   '_K_' with 'Z_'
   '_handler_' with 'z_handl_'
   '_Cstart' with 'z_cstart'
   '_Swap' with 'z_swap'

This renaming is done on both global and those static function names
in kernel/include and include/. Other static function names in kernel/
are renamed by removing the leading underscore. Other function names
not starting with any prefix listed above are renamed starting with
a 'z_' or 'Z_' prefix.

Function names starting with two or three leading underscores are not
automatcally renamed since these names will collide with the variants
with two or three leading underscores.

Various generator scripts have also been updated as well as perf,
linker and usb files. These are
   drivers/serial/uart_handlers.c
   include/linker/kobject-text.ld
   kernel/include/syscall_handler.h
   scripts/gen_kobject_list.py
   scripts/gen_syscall_header.py

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-11 13:48:42 -04:00
Manivannan Sadhasivam c58b637f26 dma: stm32f4: Use dma_config for checking memcopy support
Checking for the memcopy support using dma_stm32_stream will give wrong
result as it won't get initialised at that point of time. Hence, use
the dma_config member directly for checking the memcopy support.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2019-03-08 07:24:33 -05:00
Sathish Kuttan 3061fb7db2 Kconfig: intel_s1000: Remove DCACHE_WRITEBACK
Remove DCACHE_WRITEBACK Kconfig variable definition in Intel S1000
DMA driver. Remove the variable from default configuration as well.

Cache configuration is fixed and the cache operation routines
internally take appropriate action based on the cache configuration.

Signed-off-by: Sathish Kuttan <sathish.k.kuttan@intel.com>
2019-02-20 07:33:11 -05:00
Manivannan Sadhasivam b8c83338ec dma: stm32: Configure bus width and burst size for memcpy mode
In order to make use of the configurable bus width and burst size
options in memcpy mode, lets add configurations bits for the same.

This configuration is derived from the TRM of STM32F446xx Page No. 210
"Memory-to-memory mode" section and verified on 96Boards STM32 Sensor
Mezzanine board.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2018-12-13 07:33:30 -06:00
Erwan Gouriou 9062e97a45 drivers: stm32: check clock_control_on return value
Check clock_control_on return value now that it is checking appropriate
bus is used in the request.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-12-07 11:31:48 -05:00
Patrik Flykt 8ff96b5a57 drivers: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Krzysztof Chruscinski 97345dbb1b logging: Fix errors in log usage
Couple of findings which were revealed after changing
LOG_MODULE_REGISTER macro:
- missing semicolons after LOG_MODULE_REGISTER()
- missing LOG_LEVEL defines
- other

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-11-10 12:38:29 -05:00
Sathish Kuttan 9c52171750 drivers: dma_cavs: add buffer refresh/reload
Added a mechanism to refresh DMA buffers without the
need to call the "configure" API every time.
The reload is done after every DMA completion.

Signed-off-by: Sathish Kuttan <sathish.k.kuttan@intel.com>
2018-11-05 08:48:36 -05:00
Armando Visconti 7a18efefbc drivers: dma: stm32f4: Fix typo introduced when removing board.h
Following commit removed board.h but forgot to add soc.h:

  "drivers: Remove board.h include"

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2018-11-05 07:49:19 -05:00
Anas Nashif 238b664a89 intel_s1000: include soc.h where needed
We still need defines from soc.h for some of the drivers.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-11-02 08:37:27 -04:00
Kumar Gala aa2bdbe322 drivers: Remove board.h include
We either don't need board.h in the driver or we should be include soc.h
instead.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-01 13:21:11 -04:00
Himanshu Jha b8c19d8c75 util: Add GENMASK helper macro definition
Macro is used to create contiguous bitmask between the
arguments passed to the macro.

BITS_PER_LONG is computed as the multiplication of predefined
macros `__CHAR_BIT__` and `__SIZEOF_LONG__`.

Both gcc and clang support these predefined macros.

With this change, replace the redundant defintions of
GENMASK with the new generic macro available.

Fixes #10843

Suggested-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
2018-11-01 13:40:01 +01:00
Jun Li 4982fa9858 dma: use user data in callback
Use user data to replace DMA's device pointer in
the callback function so that the user can retrieve
its context by that private data.

Signed-off-by: Jun Li <jun.r.li@intel.com>
2018-10-16 16:58:19 -04:00
Rajavardhan Gundi b5eb656142 drivers: dma_cavs: Correct typo for logger
LOG_MODULE_REGISTEr corrected to LOG_MODULE_REGISTER.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2018-10-12 07:52:17 -04:00
Anas Nashif 49838296f8 drivers: dma: fix logger call
We had one stray SYS_LOG.. in the file that was added after initial move
was done.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-10 10:22:01 -04:00
Armando Visconti 92ed716169 drivers: dma: stm32f4: Fix typo introduced with new logger
Compilation of this driver was broken by commit 07ff2d5
as reported in issue #10453. This commit is fixing it.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2018-10-09 13:29:08 +02:00
Anas Nashif 07ff2d580b drivers: dma: move to new logger
Move to new logger and adapt samples.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-08 17:49:12 -04:00
Alexander Polleti c8153c35fe dma: check whether memory to memory is allowed
This patch checks whether memory to memory is allowed for the device.
Tested it with tests/drivers/dma with one of the 2 settings:
CONFIG_DMA1_NAME=DMA_0 -> test fails with error message on console
	and an error at configuration.
CONFIG_DMA2_NAME=DMA_0 -> test succeeds
Fixes: #7547

Signed-off-by: Alexander Polleti <metapsycholo@gmail.com>
2018-10-08 12:47:49 -04:00
Flavio Ceolin 67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Flavio Ceolin da49f2e440 coccicnelle: Ignore return of memset
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.

The only directory excluded directory was ext/* since it contains
only imported code.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-14 16:55:37 -04:00
Sathish Kuttan e9c0f7e4e3 drivers: dma_cavs: Remove resource owner config
Remove DMA resource ownership configuration.
Such configuration will be done in an SoC level
initialization routine

Signed-off-by: Sathish Kuttan <sathish.k.kuttan@intel.com>
2018-08-19 11:06:09 -07:00
Ulf Magnusson 8cf8db3a73 Kconfig: Use a short, consistent style for prompts
Consistently use

    config FOO
            bool/int/hex/string "Prompt text"

instead of

    config FOO
            bool/int/hex/string
            prompt "Prompt text"

(...and a bunch of other variations that e.g. swapped the order of the
type and the 'prompt', or put other properties between them).

The shorthand is fully equivalent to using 'prompt'. It saves lines and
avoids tricking people into thinking there is some semantic difference.

Most of the grunt work was done by a modified version of
https://unix.stackexchange.com/questions/26284/
how-can-i-use-sed-to-replace-a-multi-line-string/26290#26290, but some
of the rarer variations had to be converted manually.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-15 04:10:10 -07:00
Armando Visconti b29dabaf57 drivers/dma: dma_stm32f4x: use dma_slot to select peripheral
The DMA API provides dma_slot field as a method to configure at
runtime which peripheral DMA_request the DMA controller should
select.

This method allows to specify different selections for different stm32
DMA streams. So, all the Kconfig definitions, which by the way where
fixing the same selection for all DMA streams, have been deleted.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2018-07-05 11:24:59 -05:00
Armando Visconti 86de204852 drivers/dma: dma_stm32f4x: Fix Peripheral To Memory case
The Transfer Complete (TC) interrupt as well as the Memory
Increment (MINC) bits were not enabled for Periperal To
Memory (and Memory to Peripheral) case.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2018-07-05 11:24:59 -05:00
Sathish Kuttan 8a75e43bad drivers: dma_cavs: preserve DMA LLIs on stop
DMA channel linked list items (LLIs) are allocated when the channel is
configured.
The LLIs should not be freed until the channel is de-configured
Hence, k_free of LLI memory is removed from stop handler.
Also, added code to disable the channel in stop handler.

Signed-off-by: Sathish Kuttan <sathish.k.kuttan@intel.com>
2018-07-05 11:05:16 -04:00
Ulf Magnusson cc74397a17 drivers: dma: Kconfig: Remove redundant 'default n' 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, and is
inconsistent.

This will make the auto-generated Kconfig documentation have "No
defaults. Implicitly defaults to n." as well, which is clearer than
'default n if ...'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-07-03 17:11:31 -04:00
Erwan Gouriou d84795b0c1 drivers/dma: stm32: Use CMSIS IRQ defines instead of zephyr
stm32cube SDK provides defines for IRQ line numbers.
It was not possible to use them, since enum where not supported
by IRQ_CONNECT macro.
Use them in order to get rid of zephyr manually coded IRQ lines.
They will later be replaced by device tree definitions when
made available

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-06-13 11:43:56 +02:00
Sathish Kuttan 7b7784e149 drivers: dma_cavs: Add support for circular list
Added support for circular linked list of DMA buffers
This patch checks the last block supplied by the application
and if the next pointer in the last block is valid, the tail
linked list item is linked to the head linked list item
to form a circular linked list

Signed-off-by: Sathish Kuttan <sathish.k.kuttan@intel.com>
2018-06-11 17:34:04 -04:00
Sathish Kuttan 9a7538b95d drivers: dma_cavs: separate callbacks per channel
Allow the application using DMA driver to register a callback for
a specific channel within the DMA device instead of one callback
per device.

Signed-off-by: Sathish Kuttan <sathish.k.kuttan@intel.com>
2018-05-30 20:33:06 -04:00
Andrew Boie 8345e5ebf0 syscalls: remove policy from handler checks
The various macros to do checks in system call handlers all
implictly would generate a kernel oops if a check failed.
This is undesirable for a few reasons:

* System call handlers that acquire resources in the handler
  have no good recourse for cleanup if a check fails.
* In some cases we may want to propagate a return value back
  to the caller instead of just killing the calling thread,
  even though the base API doesn't do these checks.

These macros now all return a value, if nonzero is returned
the check failed. K_OOPS() now wraps these calls to generate
a kernel oops.

At the moment, the policy for all APIs has not changed. They
still all oops upon a failed check/

The macros now use the Z_ notation for private APIs.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-05-17 23:34:03 +03:00
Erwan Gouriou 49d820866c drivers/dma: dma_stm32f4x: check stream id boundaries
Check that stream Id passed to stm32 DMA API is within
possible stream values and return -EINVAL is invalid stream
id is passed.

fixes: #7380


Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-05-15 15:48:55 -05:00
Adithya Baglody b0db28b512 drivers: Cmake: Add __ZEPHYR_SUPERVISOR__ macro for driver files.
Normally a syscall would check the current privilege level and then
decide to go to _impl_<syscall> directly or go through a
_handler_<syscall>.
__ZEPHYR_SUPERVISOR__ is a compiler optimization flag which will
make all the system calls from the driver files directly link
to the _impl_<syscall>. Thereby reducing the overhead of checking the
privileges.

In the previous implementation all the source files would be compiled
by zephyr_source() rule. This means that zephyr_* is a catchall CMake
library for source files that can be built purely with the include
paths, defines, and other compiler flags that all zephyr source
files uses. This states that adding one extra compiler flag for only
one complete directory would fail.
This limitation can be overcome by using zephyr_libray* APIs. This
creates a library for the required directories and it also supports
directory level properties.
Hence we use zephyr_library* to create a new library with
macro _ZEPHYR_SUPERVISOR_ for the optimization.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-05-15 17:48:18 +03:00
Ramakrishna Pallala 15447fa1d8 drivers: dma: Add dma driver for Nios-II MSGDMA core
Add dma driver for Nios-II Modular Scatter-Gather DMA soft IP.

This driver relies upon the Altera HAL msgdma driver for all
the dma core register programming and interrupt handling.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-05-03 10:38:09 -04:00
Rajavardhan Gundi bd0d5133e4 drivers: dma: introduce Intel CAVS DMA
Introduce the Intel CAVS DMA. This is based out of the DesignWare
DMA IP but the register offset and bits have been changed in some
cases. However, the fundamental definition for the register field
has not been changed. Hence the registers begin with "DW_" to
indicate the Designware origin.

This driver currently supports the single block mode and linked list
multi-block mode. Scatter-Gather is not supported.

Change-Id: I33a8ed5141d9236167de50e14d3d407e95d6f553
Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-01 16:46:41 -04:00
Leandro Pereira c200367b68 drivers: Perform a runtime check if a driver is capable of an operation
Driver APIs might not implement all operations, making it possible for
a user thread to get the kernel to execute a function at 0x00000000.

Perform runtime checks in all the driver handlers, checking if they're
capable of performing the requested operation.

Fixes #6907.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-26 02:57:12 +05:30
Anas Nashif 8949233390 kconfig: fix more help spacing issues
Fix Kconfig help sections and add spacing to be consistent across all
Kconfig file. In a previous run we missed a few.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-15 23:20:55 -05:00
Andrew Boie ce6c8f347b dma: add system calls for dma_start/dma_stop
As per current policy of requiring supervisor mode to register
callbacks, dma_config() is omitted.

A note added about checking the channel ID for start/stop, current
implementations already do this but best make it explicitly
documented.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-02-12 19:24:25 -05:00
Anas Nashif 429c2a4d9d kconfig: fix help syntax and add spaces
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-13 17:43:28 -06:00
Piotr Mienkowski dbcc7429e6 drivers: Add Atmel SAM DMA (XDMAC) driver
Added DMA (XDMAC) driver for Atmel SAM MCU family. The driver provides
private DMA API to be used by the SAM family device drivers. Public
DMA API to be used by user space programs is currently missing.

Tested on Atmel SMART SAM E70 Xplained board

Origin: Original

Jira: ZEP-1609
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-11-30 10:30:33 -05:00
Sebastian Bøe 0829ddfe9a kbuild: Removed KBuild
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Piotr Mienkowski d760dc2616 drivers: dma: remove deprecated API functions
This patch removes deprecated API functions and data types from
dma.h file as well as device drivers.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-09-22 07:50:20 -04:00
David B. Kinder a3e38685a7 doc: fix misspellings in Kconfig files
Also fixed missing newline at end of file

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-08-16 15:47:42 -04:00
Johann Fischer 868c3eadce drivers: dma: add Log level option to Kconfig
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2017-08-09 16:04:46 -05:00
Johann Fischer 92e24de7cd drivers: dma: restructure dma drivers Kconfig
Moves Kconfig options for each dma controllers into own Kconfig files.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2017-08-09 16:04:46 -05:00
Erwan Gouriou 242ed389a3 stm32f4: Clean references to stm32f4 specific clock control
Following activation of stm32 common clock driver for stm32f4 series
remove references to stm32f4 specific driver.

Change-Id: I372a0ea046007bcb34944d6b2b8880077583b1d3
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-04-28 15:26:11 -05:00
Erwan Gouriou 9e558fc05a drivers: dma_stm32f4x: make driver compatible with LL Clock Driver
Following update of LL clock driver to suport F4 series,
update dma driver to support LL clock driver API.

Change-Id: Ic8ecfe4f33109204f3b5f8c22bcb9c41de81531d
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-04-28 15:06:41 -05:00
David B. Kinder 3561c73ece spell: Kconfig help typos: /arch
Fix misspellings in Kconfig help text and made spelling of
RX and TX consistent (from reviewer comments)

Change-Id: Ie9d4c3863cd210e7a17b50a85a7e64156b6bf3d7
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-04-24 20:14:53 +00:00
David B. Kinder 93e4d7258d spell: fix Kconfig help typos: /boards /drivers
Fix misspellings in Kconfig help text

Change-Id: I3ae28a5d23d8e266612114bc0eb8a6e158129dc7
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-04-21 21:31:30 +00:00
Kumar Gala ccad5bf3e3 drivers: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I08f51e2bfd475f6245771c1bd2df7ffc744c48c4
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 10:06:48 -05:00
Lee Jones 66ded99622 dma: stm32f4x: Fix warning when !SYS_LOG_INF
The following warning occurs when !SYS_LOG_INF due to the fact
that these variables are only used for information purposes.
When logging is <INFO then the variables aren't utilised at all.
To fix this we're removing the variables completely and using
the direct calls from within the information prints instead.

drivers/dma/dma_stm32f4x.c: In function 'dma_stm32_dump_reg':
drivers/dma/dma_stm32f4x.c:196:11: warning: unused variable 'sfcr' [-Wunused-variable]
  uint32_t sfcr  = dma_stm32_read(ddata, DMA_STM32_SFCR(id));
           ^
drivers/dma/dma_stm32f4x.c:195:11: warning: unused variable 'sm1ar' [-Wunused-variable]
  uint32_t sm1ar = dma_stm32_read(ddata, DMA_STM32_SM1AR(id));
           ^
drivers/dma/dma_stm32f4x.c:194:11: warning: unused variable 'sm0ar' [-Wunused-variable]
  uint32_t sm0ar = dma_stm32_read(ddata, DMA_STM32_SM0AR(id));
           ^
drivers/dma/dma_stm32f4x.c:193:11: warning: unused variable 'spar' [-Wunused-variable]
  uint32_t spar  = dma_stm32_read(ddata, DMA_STM32_SPAR(id));
           ^
drivers/dma/dma_stm32f4x.c:192:11: warning: unused variable 'ndtr' [-Wunused-variable]
  uint32_t ndtr  = dma_stm32_read(ddata, DMA_STM32_SNDTR(id));
           ^
drivers/dma/dma_stm32f4x.c:191:11: warning: unused variable 'scr' [-Wunused-variable]
  uint32_t scr   = dma_stm32_read(ddata, DMA_STM32_SCR(id));

Change-Id: I91a0373ef6c9afa8a342181c0ab24bd58743300d
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-04-09 15:44:48 +00:00