Commit graph

1005 commits

Author SHA1 Message Date
Daniel DeGrasse 6545a3d0fa drivers: spi: enable pinctrl for spi_mcux_lpspi
Enable pinctrl for lpspi driver

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-03-22 12:36:04 +01:00
Daniel DeGrasse f400aa41cd boards: remove spi pinmux setting for kinetis boards
Remove spi pinmux setting for kinetis boards with dspi, as dspi driver
supports pinctrl

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-03-22 12:36:04 +01:00
Daniel DeGrasse f90c356025 drivers: spi: enable pinctrl for kinetis dspi driver
Enable pinctrl unconditionally for kinetis dspi driver

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-03-22 12:36:04 +01:00
Andrzej Głąbek a5234f3647 soc_nrf_common: Extend and rename the NRF_DT_ENSURE_PINS_ASSIGNED macro
Extend the macro with checks for DT properties related to pin
assignments that are defined but would be ignored, depending on
whether PINCTRL is enabled or not, what presumably indicates
a resulting configuration different from what the user expects.

Add also a possibility to indicate that the pinctrl-1 property
should not be checked because the caller does not support the
sleep state.

Rename the macro so that its name better reflects its function.
Update accordingly all drivers that use it.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-03-18 16:26:21 +01:00
Gerard Marull-Paretas b618bdbaad drivers: spi: cc13xx_cc26xx: remove CONFIG_PM guards
API provides no-op fallback when CONFIG_PM=n

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-16 15:26:47 +01:00
Gerard Marull-Paretas 5a71eeb35c pm: policy: move constraints to policy API
The pm_constraint_* APIs were effectively used by the policy manager
only. This patch renames the API to the policy namespace and makes its
naming more explicit:

- pm_constraint_set -> pm_policy_state_lock_get()
- pm_constraint_release -> pm_policy_state_lock_put()
- pm_constraint_get -> pm_policy_state_lock_is_active()

The reason for these changes is that constraints can be of many types:
allow/disallow states, impose latency requirements, etc. The new naming
also makes explicit that the API calls will influence the PM policy
behavior.

All drivers and documentation have been updated accordingly.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-16 15:26:47 +01:00
Tomasz Bursztyka 16062c2e5a drivers: constify all device instances
Run cocci script to constify device instances.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2022-03-16 12:33:12 +01: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
Francois Ramu 61bef2087f drivers: spi: stm32 spi with dma must enable cs after periph
When using DMA to transfer over the spi, the spi_stm32_cs_control
is done after enabling the SPI. The same sequence applies
in the transceive_dma function as in transceive function

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-03-11 10:59:05 +01: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
Andrzej Głąbek 32b9e65e4b drivers: spi: nrfx: Add support for pinctrl
Add support for the new pinctrl API to the SPI drivers that handle
the nRF SPI, SPIM, and SPIS peripherals. Update code of the drivers
and related devicetree bindings.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-03-09 12:05:22 +01:00
Andrzej Głąbek 2a87e04ce6 drivers: spi: nrfx: Clean up code
- clean up registration of the drivers with the logging subsystem
- use consistent naming of local variables accessing configuration
  and runtime data of driver instances, for easier code maintenance

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-03-09 12:05:22 +01:00
Jay Vasanth 535c20e490 qmspi: MEC172x: fix unused variable warning
Fix unused variable warning when CONFIG_SPI_ASYNC
is not defined

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
2022-03-07 11:03:06 +01:00
Jay Vasanth 99c89ebb78 qmspi: update MEC172x qmspi module for pinctrl
Changes to qmspi module to support pinctrl

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
2022-03-07 11:03:06 +01:00
Yuriy Vynnychek f47d8568f2 drivers: spi: telink_b91: replace Pinmux by Pinctrl
Updated driver to use new Pinctrl driver.

Signed-off-by: Yuriy Vynnychek <yura.vynnychek@telink-semi.com>
2022-02-21 19:41:44 -05:00
Andrzej Głąbek 9b9de62046 drivers: spi_nrfx_spi: Fix compilation error
Fix a copy/paste mistake introduced by commit
fdc25cd44c.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-02-08 07:29:33 -05:00
Jordan Yates fdc25cd44c spi: nrfx_spi*: only run uninit if configured
Only run the `uninit` function if the SPI instance has previously been
configured. This stops an assertion in the HAL drivers from triggering
due to running `uninit` without a previous `init`.

Fixes #42299.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-01-31 12:14:05 +01:00
Wealian Liao 6d6c5e1155 drivers: npcx: Drop DRV_CONFIG/DRV_DATA usage
Stop using DRV_CONFIG/DRV_DATA macros and use dev->data and dev->config
instead.

Signed-off-by: Wealian Liao <WHLIAO@nuvoton.com>
2022-01-28 10:06:05 +01:00
Wealian Liao 3565f71a72 drivers: npcx: Correct the macro parentheses
This corrects the following:
1. The priority of type cast is lower than member access. So don't need
the redundant parentheses.
2. The macro should be added to the parentheses.

Signed-off-by: Wealian Liao <WHLIAO@nuvoton.com>
2022-01-28 10:06:05 +01:00
Christian Taedcke 3b271006cb drivers: spi_gecko: fix duplicated variable declaration
The commit 44679c7bd8 introduced this
duplicated declaration of the local variable data.

This commit fixes this issue.

Fixes #42117

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2022-01-27 05:23:18 -05:00
Gerard Marull-Paretas 435213a753 drivers: remove redundant data/config casts
Some drivers explicitely casted data/config from void * to the
corresponding type. However, this is unnecessary and, in many drivers it
has been misused to drop const qualifier (refer to previous commits).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-19 18:16:02 +01:00
Gerard Marull-Paretas 468de7eb29 drivers: spi: drop get_dev_data/get_dev_config usage
Replace all get_dev_data()/get_dev_config() accessor utilities with
dev->data and dev->config.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-19 18:16:02 +01:00
Gerard Marull-Paretas 44679c7bd8 drivers: spi: 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
Gerard Marull-Paretas ddc168fa78 pm: s/PM_DEVICE_(DT_(INST))_REF/PM_DEVICE_(DT_(INST))_GET
In order to align with macros used to obtain a device reference (e.g.
DEVICE_DT_GET), align the PM macros to use "GET" instead of "REF". This
change should have low impact since no official release has gone out yet
with the "REF" macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-18 12:14:06 -05:00
Gerson Fernando Budke 58936e7639 soc: arm: atmel_sam: samv71: Fix SPI build dependency
The SAM spi driver depends on GPIO driver to work. It seems that this
dependency chain it is not handled. This select GPIO driver when SPI
driver is enabled. It rework GPIO and SPI Kconfig to select driver by
devicetree and drop entries at Kconfig.defconfig.series file.

Fixes #41525

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2022-01-18 12:12:52 -05:00
Francois Ramu d65a74e2dd drivers: spi: stm32 spi drivers supports the frame format
the stm32 spi drivers now takes the DTS frame_format property
from the include/ drivers/spi.h
It will be possible to select the Motorola (default)
or TI from the DTS entry of the device,
when soc supports it, else a run time error is raised.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-01-17 11:46:14 -05:00
Alexander Mihajlovic 673806aef1 drivers: spi: stm32: Skip pinctrl setup for subghzspi
Subghzspi instances cannot have any pinctrl configs,
they are blacklisted by the dts binding. This caused an
initialization failure of the spi_ll_stm32 driver for
subghzspi instance because no "default" pinctrl was found.

This commit solves the problem by skipping the pinctrl setup
for subghzpi devices. The use_subghzpi_nss property is used
to identify a subghzspi device, as this is a required boolean
property only available in the subghzspi binding this is a
perfect indicator for such instances.

Signed-off-by: Alexander Mihajlovic <a@abxy.se>
2022-01-11 11:52:59 +01:00
Francois Ramu 1da200bf16 drivers: spi: stm32h7 spi drivers with DMA transfer
This patch controls the SPI of the stm32H7 mcu when using
the DMA transfer. Starting and ending the transfer
are specific according to the RefMan.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-01-07 15:06:28 -06:00
Francois Ramu ca3c2cf1f9 drivers: spi: stm32 spi instance of stm32H7 mcu
A generic function is used to give the register address to the DMA.
The SPI of the stm32H7 serie has two data registers for Tx and Rx
When the DMA is getting the address it differs between Rx and Tx.
As the stm32cube/stm32h7xx/drivers/include/stm32h7xx_ll_spi.h
has no such LL functions, the register address is get direclty.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-01-07 15:06:28 -06:00
Francois Ramu 0ce796398a drivers: spi: stm32 ll driver disable the instance after completion
The spi_stm32_complete() is checking spi flags which are valid when the
intance is still enable: disable afterwards. No more need to disable
the DMA transfer then

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-01-07 15:06:28 -06:00
Francois Ramu 081e2d5a54 drivers: spi: stm32 driver with dma checking spi busy status flag
Defines a function to control the spi busy state during DMA transfer.
After the DMA Tx, the spi might still have some data to Transmit.
The driver must wait for the SPI Tx before sending the next packet.
This is not required for the Rx part as the DMA Rx is already done.
Some mcus like stm32H7 have a TX complete bit, other must wait for the
TXE and BSY line.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-01-07 15:06:28 -06:00
Gerard Marull-Paretas 5dc6ed3ce3 pinctrl: require ; after PINCTRL_DT_(INST_)DEFINE macros
The PINCTRL_DT_(INST_)DEFINE macros already defined the trailing ;,
making its usage inconsistent with other macros such as
DEVICE_DT_DEFINE.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-01 07:39:08 -05:00
Francois Ramu 188c8c47a8 drivers: spi: stm32 spi driver using ll_func as defined in the header
Instead of checking the SPI register flags, the spi_ll_stm32.h
has dedicated functions for that purpose.
They are abstracting the STM32 registers of SPI instance.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-12-20 17:42:17 +01:00
Jay Vasanth fd43c725d2 drivers: spi: Add MEC172x QMSPI-LDMA driver
Add driver for MEC172x QMSPI with local DMA(LDMA). The driver
support SPI asynchronous operation.

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
2021-12-08 08:43:05 -05:00
Keith Short f7005599ff spi: npcx_fiu: Update the SPI context
Update the SPI context during all transceive functions. This fixes a
deadlock where SPI transactions failed to give back the semaphore.

Verified on NPCX9 based Chromebook.

Signed-off-by: Keith Short <keithshort@google.com>
2021-12-07 09:44:34 -06:00
Marc Reilly 54b6d26242 drivers: spi: add spi-bitbang driver
This adds an spi master mode driver via bitbanged gpio. Only syncronous
transfers are implemented. Clock signal timing is accomplished via busy
waits, the gpios are manipulated via the standard gpio interface; these
two factors limit the frequency at which it can operate - but here
a simple and generic implementation was chosen over performance.

The driver supports the various clock polarity and phase
configurations, and can also work with word sizes which are non
multiples of 8bits, currently up to 16 bits.

A sample program is also added demonstrating basic use of the driver
with 9bit data words.

Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
2021-12-06 07:29:45 -05:00
Bryce Wilkins 219bf88fe8 drivers: spi: Add optional delays to mcux flexcomm spi driver
Adds optional device tree properties to insert delays between spi chip
select assert/deassert and the clock edges, and also between spi
frames and transfers to the mcux flexcomm spi driver. If the properties
are not set, no additional delay is inserted.

Verified expected behavior on mimxrt685_evk and check with a scope
that the pre- and post-delay could be changed from the device tree
properties.

Signed-off-by: Bryce Wilkins <bryce.wilkins@gmail.com>
2021-12-03 16:42:10 -06:00
Daniel DeGrasse 7b74dbb405 drivers: spi_mcux_lpspi: Added DMA support to NXP LPSPI driver
Adds DMA support to NXP's LPSPI driver. This can be enabled by selecting
the KConfig symbol CONFIG_SPI_MCUX_LPSPI_DMA, and requires the LPSPI
instances enabled in the devicetree to have valid DMA instances
assigned.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2021-11-30 10:57:17 -06:00
Lukasz Majewski aa464a9d67 spi: Fix the Pcs setup for NXP's K6xF processors
Without this change, when DTS SPI device node has node ID = <0>, the
value of 0 is assigned during SPI configuration and written to
whichPcs member in master_config structure.
This value wrongly overrides the default value read from NXP's DSPI
HAL (kDSPI_Pcs0 = 1U << 0).

Such situation occurs on ip_k66f board, where the DSA device -
controlled via SPI has the node ID equal to 0 (i.e. reg = <0>).

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2021-11-30 09:55:46 -06:00
Gerard Marull-Paretas 89a4f36fc8 device: remove inclusion of pm/device.h
The device PM subsystem _depends_ on device, not vice-versa. Devices
only hold a reference to struct pm_device now, and initialize this
reference with the value provided in Z_DEVICE_DEFINE. This requirement
can be solved with a forward struct declaration, meaning there is no
need to include device PM headers.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-29 11:08:38 +01:00
Johann Fischer 5aedcabf51 drivers: spi_context: fix null pointer dereferencing
commit 54907c7014
("drivers: spi: spi_context: improve support of multiple cs gpios")
added function to initialize all CS GPIOs defined in devicetree.
This function, spi_context_cs_configure_all, is intended to be
called during SPI driver initialization (POST_KERNEL init level).
It is also obvious that a SPI driver was not used at that time,
and no bus configuration (struct spi_config) is assigned to
SPI bus (spi_context.config).

The spi_context_cs_configure_all function has a homeopathic
ASSERT to validate CS levels, which causes a null pointer
dereferencing by ctx->config->operation if asserts are
enabled.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-11-26 11:47:27 +01:00
Erwan Gouriou 8bd410a589 drivers/spi: stm32: use new pinctrl API
Use the new pinctrl API to configure pins.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-11-26 11:36:42 +01:00
Sylvio Alves 779ef06a5b drivers: spi: esp32: fix CS gpio initialization
SPI_CONTEXT_CS_GPIOS_INITIALIZE call was not considering
proper SPI driver instance ID.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-11-20 11:56:55 -05:00
Sylvio Alves 71d3609e16 drivers: spi: esp32: fix frequency config
Current implementation is using hardcoded frequency
and not the one provided by the spi api.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-11-20 11:56:55 -05:00
Tomasz Bursztyka 01b9813d73 drivers/spi: Return an error on SPI_HALF_DUPLEX for relevant drivers
This feature will need to be, however, implemented driver by driver
afterwards.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-11-19 11:50:38 +01:00
Tomasz Bursztyka f6be2835bd drivers: Apply SPI API change to relevant places
Mostly drivers, but also one sample and one test.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-11-19 11:50:38 +01:00
Tomasz Bursztyka f8cc93de8c spi: Add a configuration option for half/full duplex mode
This is meant to expose half/full duplex configuration option on regular
configuration. So far, dual/quad/octal are not exactly supported, as it
would require extensions to the SPI buffer for a full support.

So moving these modes to an extended operation attribute
(32 vs 16 bits), disabled by default.

And exposing half/full duplex configuration bit. Full duplex being the
default option.

Fixes #19134

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-11-19 11:50:38 +01:00
Gerard Marull-Paretas 88a69674c0 drivers: use new PM macros
Port some drivers to the recently introduced macros to showcase its
usage and be able to do some initial testing (nRF52840).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-19 10:11:32 +01:00
Gerard Marull-Paretas c759a35d08 drivers: use DT_INST_ENUM_IDX(_OR) macros
Replace `DT_ENUM_IDX(_OR)(DT_DRV_INST(...),` pattern with
`DT_INST_ENUM_IDX(_OR)(...,`.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-18 19:12:07 -05:00
Nick Ward fa94be591d drivers: spi_nrfx_spim: workaround for nRF52832 errata anomaly 58
See:
https://infocenter.nordicsemi.com/index.jsp?topic=%2Fstruct_nrf52%2Fstruct%2Fnrf52832_errata.html
https://infocenter.nordicsemi.com/pdf/nRF52832_Rev_3_Errata_v1.0.pdf

Code derived from the example PAN 58 workaround code.

Adds a new nRF SPIM Devicetree binding property called
anomaly-58-workaround that allows the workaround to be enabled
if required per SPIM instance.

Signed-off-by: Nick Ward <nick.ward@setec.com.au>
2021-11-09 20:04:45 -05:00
Andrzej Głąbek 760adff120 drivers: spi_context: Correct alignment of LOG_DBG() parameters
so that the call looks nicer.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-11-09 12:46:08 +01:00
Andrzej Głąbek 688d81813e drivers: spi_context: Fix handling of zero-length buffers
In some cases, it is quite useful to have the possibility to also
include zero-length buffers in a buffer set used in transfers
(for example, when frames in a protocol consist of several parts,
of which some are optional). So far, the behavior of spi_context
update functions was that the transfer in a given direction was
finished when a zero-length buffer was encountered in the buffer
set. Change those functions to simply skip such buffers. Correct
in the same way also the spi_context_buffers_setup() function.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-11-09 12:46:08 +01:00
Andrzej Głąbek 3489ca9da2 drivers: spi_context: Do not use transfer timeout in slave mode
Do not use any timeout in the slave mode, as in this case it is not
known when the transfer will actually start and what the frequency
will be.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-11-09 12:46:08 +01:00
Andrzej Głąbek f7466d28fd drivers: spi_nrfx_spim/spi: Fix initialization of CS GPIOs
This is a follow-up to commits 99daca9bba
and ae03c0a6bf.

nRF SPI driver shims cannot use devicetree instance indexes, they need
to use the DT_NODELABEL macro and SoC peripheral instance indexes.
Correct the macros used in initialization of CS GPIOs in those shims.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-11-09 11:11:19 +01:00
Bartosz Bilas 41325bd1fb drivers: spi: remove spi_context_cs_configure function
Since cs gpios are initialized during driver initialization
remove spi_context_cs_configure that is not longer need.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas 7ba48aa7a9 drivers: spi_xlnx_axi_quadspi: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas 258f2d85f7 drivers: spi_xec_qmspi: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas 997723b760 drivers: spi_sifive: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas 81a3900b35 drivers: spi_sam0: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas 61646649a1 drivers: spi_sam: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas 05f326c96e drivers: spi_rv32m1_lpspi: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas 97d3de2349 drivers: spi_psoc6: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas 225f0b3825 drivers: spi_oc_simple: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas 99daca9bba drivers: spi_nrfx_spim: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas ae03c0a6bf drivers: spi_nrfx_spi: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas 054fb71bf0 drivers: spi_mcux_lpspi: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas ab2d23c5f4 drivers: spi_mcux_flexcomm: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas 0ccdd5f263 drivers: spi_mcux_dspi: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas bcd0364ab8 drivers: spi_gecko: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas f40be1f17f drivers: spi_esp32_spim: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas 70a65b229b drivers: spi_dw: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas 37925430b1 drivers: spi_cc13xx_cc26xx: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas b370fb8fad drivers: spi_b91: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas 388a33c188 drivers: spi_ll_stm32: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas 54907c7014 drivers: spi: spi_context: improve support of multiple cs gpios
Add extra cs_gpios and num_cs_gpios members into
spi_context structure that will be used to
initialize all defined cs gpios during the driver
initialization using SPI_CONTEXT_CS_GPIOS_INITIALIZE macro.
While at it add a new spi_context_cs_configure_all
function that allows the user to configure
all available cs gpios in inactive mode.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Bartosz Bilas ea25b92cd9 drivers: spi: use dedicated init priority
A couple of SPI drivers use CONFIG_KERNEL_INIT_PRIORITY_DEVICE
as init priority for driver initialization. Let's change
it to the dedicated CONFIG_SPI_INIT_PRIORITY to make it
compatible with other ones.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-11-04 16:23:05 +01:00
Gerard Marull-Paretas 4baf1e01ff drivers: use common PM action callback naming
The PM callback is no longer referenced as "pm_control" but
"pm_action_cb", so reflect this new naming on the callbacks.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-03 20:27:18 -04:00
Gerard Marull-Paretas dd9d0560d1 drivers: spi: esp32_spim: use NULL for PM callback
A non-existing definition was being used (probably a misspelled
deprecated macro).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-03 20:27:18 -04:00
Andrzej Głąbek eafafa2816 drivers: spi_nrfx_spis: Fix handling of buffer lengths
Do not limit the length of the prepared transfer to the shorter of
provided TX and RX buffers if both are used. The SPIS peripheral
cannot handle scattered buffers anyway, so there is no point in
getting the common part of TX and RX buffers for a partial transfer,
like it is done for SPI and SPIM peripherals; everything what is
possible needs to be transferred in one shot. For the same reason,
there is no point in calling spi_context_buffers_setup() and using
the related part of the spi_context structure, hence the call is
removed and buffer pointers are used directly.
Also return an error if a requested transfer length exceeds the SPIS
peripheral hardware limit, instead of silently limiting the transfer
like it was done so far.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-11-03 17:34:35 +01:00
Jun Lin 5d72417df4 drivers: spi: npcx: add SPI support to access the SPI flash
The FIU/UMA module in the NPCX chip provides an dedicated SPI interface
to access the SPI flash. This commit adds the driver support for it.
With this commit, the application can call the flash APIs
(via spi_nor.c) to access the internal flash of NPCX EC chips.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
Change-Id: I32bbf09f6e014b728ff8e4692e48151ae759e188
2021-11-01 21:48:20 -04:00
Felipe Neves 0a0fed7879 drivers: spi: esp32: add esp32c3 support
to the esp32 spi unified driver

Signed-off-by: Felipe Neves <felipe.neves@espressif.com>
2021-11-01 21:47:26 -04:00
Torsten Rasmussen bd61122aa2 kconfig: drivers: experimental settings now uses select EXPERIMENTAL
With the introduction of `EXPERIMENTAL` and `WARN_EXPERIMENTAL` in
Zephyr all drivers settings having `[EXPERIMENTAL]` in their
prompt has has been updated to include `select EXPERIMENTAL` so that
developers can enable warnings when experimental features are enabled.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-10-25 10:46:48 +02:00
Glauber Maroto Ferreira 7468121f19 esp32s2: drivers: spi: add driver support
and hooks to spi_loopback test.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2021-10-10 14:52:41 -04:00
Glauber Maroto Ferreira 26131ba5d4 esp32: drivers: spi: driver refactoring
in preparation to support other esp32-family socs

on top of existing driver.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2021-10-10 14:52:41 -04:00
Glauber Maroto Ferreira fb1632925e soc: esp32: partial code standardization
Replaces the prefixes of gpio_matrix_in and gpio_matrix_out
to unify those function calls on all supported socs.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2021-10-10 14:52:41 -04:00
Jordan Yates 29773391c7 spi: convert CS usage to gpio_dt_spec
Convert all CS control logic to be based on the `gpio_dt_spec` member
instead of the standalone `port`, `pin` and `flags` members.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Co-authored-by: Jordan Yates <jordan.yates@data61.csiro.au>
Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
Co-authored-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-10-05 19:24:18 -04:00
Francois Ramu 33e0f1a87a drivers/spi: stm32u5 spi support
Add the specific driver functions for the SPI
of the stm32u5 device.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-10-05 19:23:37 -04:00
Christopher Friedt c4ecd78ce1 Revert "drivers: spi: stm32 can support TI mode for the SPI frame format"
This reverts commit d563313ab1.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-09-30 16:04:37 -04:00
Francois Ramu d563313ab1 drivers: spi: stm32 can support TI mode for the SPI frame format
Depending of the soc and SPI peripheral, the Frame-Format of the
SPI can be configured to support TI or Motorola protocol.
This is configured through a new DTS property.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-09-29 14:47:31 -04:00
Andrzej Głąbek 36451e6b54 drivers: spi_nrfx_spi: Change the way the nrfx driver is configured
Apply the same changes as the previous commit made in the spi_nrfx_spim
shim, to keep these two shims aligned.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-09-23 08:39:37 -04:00
Andrzej Głąbek 2a199afac3 drivers: spi_nrfx_spim: Change the way the nrfx driver is configured
According to the nRF5340 PS, for 32 Mbps high-speed SPI using SPIM4,
drive configuration H0H1 must be used. The underlying nrfx_spim driver
does it properly in its initialization function, so change the shim to
(re)initialize the driver when the SPI configuration is to be changed
(only then the speed to use is known), to avoid the need of duplicating
the corresponding code in the shim itself.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-09-23 08:39:37 -04:00
Andrzej Głąbek 5f1581bb05 drivers: spi_nrfx_spim: Fix limiting of SPIM frequency on nRF5340
According to the nRF5340 PS, SPIM4 only supports 32 Mbps when
the application core is running at 128 MHz. This patch adds
the corresponding check.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-09-23 08:39:37 -04:00
Julien D'ascenzio ca7899afa9 drivers: spi: stm32: Fix forever lock when configure failed
On transceive, if the SPI configure failed, the SPI wasn't release.

Signed-off-by: Julien D'ascenzio <julien.dascenzio@paratronic.fr>
2021-09-20 10:17:56 -04:00
Hake Huang ef410ee732 drivers: spi: Update mcux driver to support edma
enable spi driver to support dspi edma

add support for shared dma mux spi port

for shared spi port we need judge the irq source

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2021-09-02 15:50:52 -05:00
Hake Huang cc1801440f spi: mcux: update driver init priority
use the CONFIG_SPI_INIT_PRIORITY to init device driver

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2021-09-02 15:50:52 -05:00
Alexandre Bourdiol 4b7e9368bc drivers: spi: spi_ll_stm32: not all stm32l1 MCU have SPI_CR2_FRF
After update of stm32 cube l1 V1.10.3,
SPI_CR2_FRF doesn't exist for all stm32L1 MCU,
thus LL_SPI_SetStandard() is also not defined for all stm32l1 MCU.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2021-08-24 22:14:20 -04:00
Yuriy Vynnychek 87018c50cc drivers: spi: introduce new Telink B91 SPI driver
SPI driver basic support for Telink B91 SoC.

Signed-off-by: Yuriy Vynnychek <yura.vynnychek@telink-semi.com>
2021-08-19 17:18:23 -04:00
Sylvio Alves 907b5d9e7f drivers: spi: set max chunk len for esp32
Max SPI chunk len was missing from the
implementation, causing SPI to hang up in some
conditions.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-08-12 16:22:34 -05:00
Gerard Marull-Paretas 7ccc1a41bc pm: use actions for device PM control
Instead of passing target states, use actions for device PM control.
Actions represent better the meaning of the callback argument.
Furthermore, they are more future proof as they can be suitable for
other PM actions that have no direct mapping to a state. If we compare
with Linux, we could have a multi-stage suspend/resume. Such scenario
would not have a good mapping when using target states.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 6d273f49bd pm: fix incorrect usages of PM_DEVICE_STATE_OFF
According to the documentation the OFF state has to be used when the
devices is fully turned off, ie, power removed. Most drivers were using
a sort of fall-through for all non-active states, leading to behaviors
not following the specifications.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 495672ab62 pm: cleanup pm control callback implementations
- Return -ENOTSUP if the requested state is not supported
- Remove redundant "noop style" functions.
- Use switch everywhere to handle requested state (not necessary in all
  drivers, but better take off with consistency in place after current
  changes).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas d41dadc569 pm: rename PM_DEVICE_STATE_SUSPEND to PM_DEVICE_STATE_SUSPENDED
The verb tense for the suspended state was not consistent with other
states. The likely reason: state was being used as a command/action.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 56a35e5682 pm: converge to suspend state for low power modes
The difference between low power and suspend states is a thin blur line
that is is not clear and most drivers have used indistinctly. This patch
converges to the usage of the suspend state for low power, since
contrary to the low power state, it is used by both system and runtime
device PM. The low power state is still kept, but its future is unclear
and needs some discussion.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 920f30cc0e pm: simplify state change check logic
The device PM control function will only be called if the requested
state is different from the current one. A significant amount of drivers
were checking for state changes, now unnecessary. This patch removes all
this redundant logic.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 11eef4d8c8 pm: device: remove pointer usage for state
Since the state is no longer modified by the device PM callback, just
use the state value.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 9e7d545bb4 pm: device: remove ctrl_command callback argument
The ctrl_command is not used anymore, so remove it from the callback
signature.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas da0ff4ae46 pm: device: remove usage of ctrl_command
The callback is now invoked to set the device PM state in all cases, so
the usage of ctrl_command is redundant.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas c2cf1ad203 pm: device: remove usage of local states
The device PM subsystem already holds the device state, so there is no
need to keep duplicates inside the device. The pm_device_state_get has
been refactored to just return the device state. Note that this is still
not safe, but the same applied to the previous implementation. This
problem will be addressed later.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 6c3beb928e pm: adjust busy check API call return types and naming
Busy check APIs now return boolean type. Due to that change, the
function names have also been adjusted. The common name pattern for
boolean check type APIs is "PREFIX_is_CONDITION". For example,
"pm_device_is_busy".  pm_device_busy_check has been renamed to
pm_device_is_busy and pm_device_any_busy_check to pm_device_is_any_busy.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-30 09:28:42 -04:00
Gerard Marull-Paretas 70322853a8 pm: device: move device busy APIs to pm subsystem
The following device busy APIs:

- device_busy_set()
- device_busy_clear()
- device_busy_check()
- device_any_busy_check()

were used for device PM, so they have been moved to the pm subsystem.
This means they are now prefixed with `pm_` and are defined in
`pm/device.h`.

If device PM is not enabled dummy functions are now provided that do
nothing or return `-ENOSYS`, meaning that the functionality is not
available.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-30 09:28:42 -04:00
Francois Ramu 8fe0831c6b include: dt-bindings: remove dma header for stm32 soc
All the macro for dma-cells are now in the
include/drivers/dma/dma_stm32.h header file.
So the include/dt-bindings/dma/stm32_dma.h is no more
useful and removed from #include.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-07-22 04:52:53 -04:00
Francois Ramu 30fd0228ae drivers: dma of the stm32 refactored macro for the dma-cells
The macro to set the element of the dma-cells for each peripheral
are defined in the dma_stm32 header file
and used in the periph driver (as dma client)

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-07-22 04:52:53 -04:00
Glauber Maroto Ferreira 35c8cb7b37 esp32: drivers: interrupt_controller: review SPI interrupt usage
Review SPI interrupt allocation usage.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2021-07-16 07:19:28 -04:00
Fabio Baltieri 624886156a drivers: spi_ll_stm32: add SUBGHZSPI support
This adds support for controlling the SUBGHZSPI NSS line in STM32WL
devices. This is a special dedicated SPI port only connected to the
radio device internally, chip select happens through a bit in the PWR
module. Adding a special dt-property to identify the port, it all gets
built out on non-WL devices.

Deduplicate the existing dts bindings in the process, and add the new
one for the special spi with the new property.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
2021-07-15 21:30:28 -04:00
Manivannan Sadhasivam fa2d1ea422 drivers: spi: Use timeout for transfer completion
Instead of waiting forever for the SPI transfer to complete, let's use
a timeout value and bail out if elapsed. The timeout value logic is,

xfer_len/frequency + tolerance

Tolerance value can be modified using a Kconfig symbol,
CONFIG_SPI_COMPLETION_TIMEOUT_TOLERANCE. It defaults to 200ms.

Fixes: #33192

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2021-07-15 06:43:23 -04:00
Gerard Marull-Paretas 26ad8376bd pm: remove callback from control function
The callback is not used anymore, so just delete it from the pm_control
callback signature.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-13 09:36:45 -04:00
Gerard Marull-Paretas 217e610d8f pm: remove redundant callback usage
the device PM callback is not used anymore by the device PM subsystem,
so remove it from all drivers/tests using it.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-13 09:36:45 -04:00
Sylvio Alves 4303cfdb3c hal: esp32: driver changes to allow HAL update
hal_espressif repository was updated from esp-idf v4.2
to esp-idf v4.3 to allow latest Espressif chips integration.
As a consequence, it added a few changes in drivers
and peripherals. To maintain bisectability, changes in this
PR cannot be split. Here are some details:

wifi: update linker script by adding libphy and new attributes.

spi: update some APIs and fixed missing wait_idle check

west.yml: esp32: update hal to new version

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-07-07 15:01:16 -04:00
Gerard Marull-Paretas cc2f0e9c08 pm: use enum for device PM states
Move all PM_DEVICE_STATE_* definitions to an enum. The
PM_DEVICE_STATE_SET and PM_DEVICE_STATE_GET definitions have been kept
out of the enum since they do not represent any state. However, their
name has not been changed since they will be removed soon.

All drivers and tests have been adjusted accordingly.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-07 14:13:12 -04:00
Piotr Mienkowski aaf64e0bdf soc: atmel_sam: Add _INST to ATMEL_SAM_DT_PIN* macros
The macros are used to get the pin(s) of a given driver instance. Add
_INST prefix to match convention used by the devicetree.h. The original
macros can now be used to obtain pin(s) of an arbitrary device instance
identified by the nodelabel.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2021-06-14 09:50:41 -05:00
Erwan Gouriou fcc3177509 drivers/pinmux: stm32: Move stm32 driver from stm32/
Since we removed various series headers, move stm32 driver
under main driver/pinmux folder.
Take this change into account into various drivers.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-06-11 08:04:39 -05:00
Stancu Florin 8ebb641ef7 drivers: cc13xx_cc26xx: fix pm.h not included
Fixes #35916.

Signed-off-by: Stancu Florin <niflostancu@gmail.com>
2021-06-04 10:24:10 -05:00
Affrin Pinhero c1daae647e driver/spi: STM32 Revert while loop on tx only
This commit reverted while loop on tx only.
This commit solves SPI loopback failure and SPI wrong behaviour on RX.
fix:
* zephyrproject-rtos/zephyr#35297
* zephyrproject-rtos/zephyr#35539

Revert "drivers/spi: STM32: This solves SPI infinite loop on Tranceive"

This reverts commit 50c2acbc03e7a48a09880b6fcb8c22256bffa70c.

Signed-off-by: Affrin Pinhero <affrin.pinhero@hcl.com>
2021-05-26 10:38:21 -05:00
Affrin Pinhero 0129884062 drivers/spi: STM32: This solves SPI infinite loop on Tranceive
This commit loops on rx not empty only if rx_buf is enabled.
And if rx_buf is not enabled, it loops on tx empty status.

Signed-off-by: Affrin Pinhero <affrin.pinhero@hcl.com>
2021-05-11 13:01:57 -05:00
Flavio Ceolin 0c607adb63 pm: device: Align state names with system states
Change device pm states to the same pattern used by system power
management.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 18:35:12 -04:00
Flavio Ceolin 7eba310220 power: device: void *context -> uint32_t *state
The context parameter used across device power management is
actually the power state. Just use it and avoid a lot of
unnecessary casts.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
Katsuhiro Suzuki f8e9b505c9 drivers: spi: sifive: fix bug of transferring multiple bufs
This patch fixes a bug of SPI driver for SiFive FE310.
Current implementation sends/receives only first buffer even if
an user passed two or more struct spi_buf to driver.

Signed-off-by: Katsuhiro Suzuki <katsuhiro@katsuster.net>
2021-05-06 07:41:16 -05:00
Gerard Marull-Paretas 56f1a8ce98 pm: rename PM_DEVICE_GET/SET_POWER_STATE to PM_DEVICE_STATE_GET/SET
Adjust name to be consistent with device PM naming conventions.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas dbf46b3815 pm: rename device_pm_cb to pm_device_cb
Prefix all device PM functions/data structures with pm.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas 2c7b763e47 pm: replace DEVICE_PM_* states with PM_DEVICE_*
Prefix device PM states with PM.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas 3863be02a5 drivers: replace power/power.h with pm/device.h
Drivers need access to the device PM API, so just include pm/device.h.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerson Fernando Budke d999531f7f drivers: spi: Add cypress PSoC-6 scb spi driver
Add Cypress PSoC-6 SCB[spi] driver.

Signed-off-by: Gerson Fernando Budke <gerson.budke@atl-electronics.com>
2021-05-05 16:01:28 +02:00
Jordan Yates ed20c06908 spi: spi_nrfx_spim: limit clock frequency by inst
Limit the maximum SPI frequency to that supported by the instance
hardware. This stops peripherals supporting >8MHz on slow instances
from wrapping around on the clock frequency for undefined behaviour.

Fixes #34402

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-04-28 19:49:57 +02:00
Gerard Marull-Paretas 90118b265f drivers: spi: 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 12:25:39 -04:00
Kumar Gala e1032ad2c3 include: Move emul.h to drivers/emul.h
Move emul.h out of the top level include/ dir into
include/drivers/emul.h and deprecated the old location.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-04-22 12:51:01 -04:00
Flavio Ceolin 9fd4ea91b7 coccinelle: Remove extra semicolon
coccicheck --mode=patch --cocci=semicolon.cocci

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-03-25 11:35:30 -05:00
Kumar Gala b9ed2d33fd drivers: spi: Remove unused Kconfig symbols
Remove SPI_[0-8] and SPI_[0-8]_OP_MODES Kconfig symbols as no driver
uses them anymore.  We also cleanup board and sample code to remove
use of these symbols.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-09 04:53:46 -05:00
Kumar Gala 0f0308c197 drivers: spi: sam0: Convert dma to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access
to the dma controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-08 18:22:27 -06:00
Erwan Gouriou d8348b0e5e drivers/spi: stm32: Minor init code refactoring
Minor changes to init code indentation.


Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-03-03 07:24:56 -05:00
Erwan Gouriou 375db6e080 drivers/spi: stm32 convert dma to new DT_DMA helper macros
New DT_DMA helper macors are available to access DMA node
identifier. Use them

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-03-03 07:24:56 -05:00
Kumar Gala 767ba47423 drivers: spi: spi_dw: Move to devicetree detection
We can utilize the devicetree macros to determine which instances to
enable.  This will allow us to phase out the per instance Kconfig
symbols.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 20:06:38 -06:00
Kumar Gala c0d82cf434 drivers: spi: spi_dw: set op-mode to master-only always
Nothing sets the op mode to anything but master.  For now default the
mode to master-only and we can determine a devicetree property in the
future if we need to support other configurations.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 20:06:38 -06:00
Kumar Gala 1957fe2417 drivers: spi: spi_dw: determine num IRQs from devicetree
Replace Kconfig symbols SPI_DW_PORT_n_INTERRUPT_SINGLE_LINE with just
seeing how many IRQs are defined in the devicetree to determine single
or multiline interrupt support.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 20:06:38 -06:00
Kumar Gala b08c5d2bb8 drivers: spi: spi_dw: Remove clock gate support
The SoC that utilized the clock support isn't supported in Zephyr
anymore and there are no users of this code.  Remove it for now as it
should get converted to utilize devicetree if needed in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 20:06:38 -06:00
Kumar Gala 3b8ea186fd spi: mcux flexcomm: Convert dma to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access
to the dma controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-28 18:19:18 -06:00
Martí Bolívar 63471ba93b drivers: spi: add dummy driver for vnd,spi
We will need this to be able to DEVICE_DT_GET() bus devices from
tests/drivers/build_all in an upcoming commit.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-02-23 10:34:19 -05:00
Glauber Maroto Ferreira 74922049ba drivers: spi: esp32: add basic SPI master support
Include SPI master support for blocking and asynchronous calls.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2021-02-22 08:17:04 -05:00
Kumar Gala 7ee312ec57 drivers: spi: NXP: Convert clock control to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access
to the clock controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-18 10:53:27 -06:00
Kumar Gala 3a8fffb9c3 device: rv32m1: Convert clock control to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access
to the clock controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-18 09:26:39 -06: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
Flavio Ceolin 3f87c5a0f4 power: Rename constraint API
Replace pm_ctrl_* with pm_constraint.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-02-15 08:08:36 -05:00
Flavio Ceolin d21cfd5f36 power: Remove power management conditionals from code
Remove conditionals (PM_DEEP_SLEEP_STATES and PM_SLEEP_STATES) from
power management code. Now these features are always available when
power management is enabled.

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

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-01-22 09:31:20 -05:00
Kumar Gala 3216856ea1 drivers: spi: cc13xx_cc26xx: Fix compile error
The cc13xx_cc26xx driver uses "inst" so we need to use
DEVICE_DT_INST_DEFINE instead of DEVICE_DT_DEFINE.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-11 03:34:50 -06:00
Kumar Gala 5a70f54f62 drivers: spi: spi_nrfx_spis: Fix compile error
The spi_nrfx_spis driver uses nodelabel so we need to use
DEVICE_DT_DEFINE instead of DEVICE_DT_INST_DEFINE.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-10 11:34:56 -06:00
Kumar Gala 03ad31b0e4 drivers: spi: Convert drivers to new DT device macros
Convert spi drivers from:

DEVICE_AND_API_INIT -> DEVICE_DT_INST_DEFINE
DEVICE_GET -> DEVICE_DT_INST_GET

etc..

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

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

and use PM_ as the prefix for all PM related Kconfigs

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-09 15:18:29 -05:00
Peter Bigot d721b7a6ab drivers: spi: convert nrf drivers to dt device defines
Use the devicetree node as the source of object name and other
information used when defining the device structure.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Martin Jäger c512a908c8 drivers: spi: 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
Kumar Gala 1e674ad815 drivers: spi: mcux_flexcomm: Fix build failure
Change to spi_context_lock missed one spot in the flexcomm driver and
this causes a build issue.  Pass spi_cfg to spi_context_lock to fix
the issue.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-11-20 13:59:24 -05:00
Harry Jiang de729882a0 drivers: spi: spi_ll_stm32: Fix the master mode not work.
On the STM32MP1 and STM32H7 Series SoC, if slave select pin control by
software on master mode operation, the SS input/output polarity (SSIOP)
should be set to high level avoid the mode fault (MODF) error.

Signed-off-by: Harry Jiang <explora26@gmail.com>
2020-11-19 12:35:12 +01:00
Harry Jiang 85e0e21390 drivers: spi: spi_ll_stm32: Add support for STM32H7xx SoC
Add SPI driver support for STM32H7xx SoC.

Signed-off-by: Harry Jiang <explora26@gmail.com>
2020-11-19 12:35:12 +01:00
Stefan Bigler 596cad8231 spi: fix locking for SPI_LOCK_ON using synchronous API
Keep locking for SPI_LOCK_ON from the first call of transceive until
spi_release release the lock. Use owner parameter to in the spi_context
to store the owner of the lock.
The locking is in line with the SPI_HOLD_ON_CS

Signed-off-by: Stefan Bigler <stefan@bigler.io>
2020-11-19 12:34:44 +01:00
Kumar Gala b4a3880a75 drivers: remove unnecessary use of DEVICE_AND_API_INIT
For drivers that support CONFIG_DEVICE_POWER_MANAGEMENT there are some
cases that look like:

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

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

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-11-06 09:42:47 -06:00
Trond Einar Snekvik 86c793af3f sys: util: Replace MIN(MAX(a, b), c) with CLAMP
Replaces all existing variants of value clamping with the MIN and MAX
macros with the CLAMP macro.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-11-05 12:12:17 +01:00
Clotilde Sattler 168f8bec6d nrfx_spi and nrfx_spim: Fix SPI assert and busy error
This removes a semaphore unlock in init_spi function
which causes risks of competitive access

Signed-off-by: Clotilde Sattler <clotilde.sattler@stimio.fr>
2020-10-23 12:53:19 +02:00
Mahesh Mahadevan 10809b5402 drivers: spi: Update MCUX Flexcomm driver to add DMA support
Add DMA support to the MCUX Flexcomm SPI driver

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2020-10-21 06:26:40 -05:00
Erwan Gouriou 0b9c584ec1 drivers/pinmux: stm32: Provide unique API to stm32_dt_pinctrl
Set stm32_dt_pinctrl_configure function as the unique entry point
to STM32 DT pinctrl management.

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

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

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-20 09:09:29 -05:00
Erwan Gouriou d4e390ce63 drivers/spi: stm32: Convert to devicetree pinctrl generation
Convert STM32 SPI driver to device pinctrl configuration.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-19 10:24:01 -05:00
Mahesh Mahadevan c6b3316947 drivers: Update Flexcomm SPI driver for clock control
Use the clock API to get the spi clock frequency

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2020-10-15 11:17:24 -05:00
Łukasz Mazur 705e1a4610 SPI: Refactoring in SPI with DMA (peripheral switching on/off)
Moved enabling SPI peripheral in front of the buffers loop.
Removed SPI DMA switching on in front of the buffers loop.

Signed-off-by: Łukasz Mazur <lukasz.mazur@hidglobal.com>
2020-10-15 14:11:46 +02:00
Łukasz Mazur f091aab0d7 SPI: Do not disable SPI peripheral while switching DMA buffers
Removed SPI peripheral disabling when switching DMA to another buffer.
When using hardware chip select this would cause to stop driving
CS pin when swhitching buffers. This is different (and wrong) than
when used software CS.

Fixes #28833

Signed-off-by: Łukasz Mazur <lukasz.mazur@hidglobal.com>
2020-10-15 14:11:46 +02:00
Simon Glass a1d8e55cad emul: spi: Add support for SPI emulators
Add an emulation controller which routes SPI traffic to an attached
emulator. Only one emulator is supported per bus at present, since
chip-selction functionality is not present.

This allows drivers for SPI peripherals to be tested on systems that
don't have that peripheral attached, with the emulator handling the SPI
traffic.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-05 15:33:00 -04:00
Mahesh Mahadevan 133705f497 drivers: spi: Set the spi_config before calling Chip select configure
This was accidentally moved to after calling chip select configure

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2020-10-02 11:47:23 +02:00
Andrzej Głąbek a3430c2caf drivers: spi: nrfx: Restore recently changed spi_context function
Function spi_context_longest_current_buf() has been introduced in
commit ddef35c1da for the purpose of
getting the longest possible (potentially partial) SPI transfer
for which all currently active directions have a continuous buffer.
Such transfer can be done with taking advantage of a DMA that cannot
use scattered buffers (and this is the case for nRF SPI drivers with
which this function has been introduced).
Unfortunately, because of its inadequate name, later on this function
has been incorrectly used in other SPI drivers for getting the longer
of TX/RX buffers. And commit afc480f12b
recently "fixed" the implementation of this function, assumably to
adjust it to those incorrect uses, but this way it has also broken
the nRF SPI drivers.
Instead of restoring the original implementation of the function in
question, this commit adds a new one with functionality equivalent
to that original but with a hopefully less misleading name, and this
function is used in the nRF SPI drivers.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-09-15 15:59:18 +02:00
Andrzej Głąbek b197fb0bbe drivers: spi: Kconfig.nrfx: Use RAM buffers for SPIMs by default
Enable by default the use of RAM buffers in the spi_nrfx_spim.c
driver for copying TX data located in flash (as SPIM peripherals
cannot transfer directly form flash). Without this patch, users can
get confused, especially when SPI transaction is used by an upper
level driver which does not check all error codes.
For size of the buffer, use the value used so far in the reel_board
default configuration and in the SPI loopback test, i.e. 8 bytes.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-09-14 16:02:59 -05:00
Erwin Rol 65434f58dd drivers: spi_ll_stm32: refactor DMA support
- Fix GPIO CS timing when using DMA. When using GPIO CS the
  CS select was enabled after the DMA started the transfer,
  resulting in the first few bits being transfered while
  CS was still disabled.

- Fix TX or RX only DMA transfers. When only a RX or only
  a TX transfer was requested the DMA never finished.

  For the RX only cause the size on the transfer was
  calculated by taking the TX buffer length (0), this
  caused problems.

  For the TX only transfer the RX buffer was set to NULL,
  this caused the DMA to acctually writing data to the
  adress 0x00000000. By using the dummy destination buffer
  it now only writes to valid memory.

- Add semaphore to signal that DMA is ready, instead of
  just busy waiting.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2020-09-04 12:00:37 +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 898f914df5 drivers: spi: Fix device instance const qualifier loss
Some needed to wrap the device pointer into device's data, where others
needed only device's data to be passed to HAL callback function.

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
Ilya Averyanov afc480f12b drivers/spi: spi_context_longest_current_buf fix
spi_context_longest_current_buf must return max buffer len.
Also remove redundant check

Signed-off-by: Ilya Averyanov <a1ien.n3t@gmail.com>
2020-08-31 13:05:50 +02:00
Mahesh Mahadevan 99f24aeac6 MCUX Flexcomm SPI: Add Slave support
Add support for Slave mode in the mcux flexcomm spi driver

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2020-08-26 16:32:50 -05:00
Henrik Brix Andersen d5514752d0 drivers: spi: add driver for the Xilinx AXI Quad SPI IP
Add SPI driver for the Xilinx AXI Quad SPI IP. Despite the name, this IP
block supports both single, dual, and quad line widths.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2020-08-26 12:32:27 +02: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
Jui-Chou Chung ed642dcd24 drivers: spi: nrfx: Update get_nrf_spim_frequency for nRF5340 HS-SPI
Using SPIM_FREQUENCY_FREQUENCY_M32 to check if the device has HS-SPI and
able to use higher SPI clock than 8MHz.

Signed-off-by: Jui-Chou Chung <jui-chou.chung@nordicsemi.no>
2020-08-04 17:24:41 +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 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
Andrei Gansari dc2efff38d drivers: spi_mcux_flexcomm: CS remains low until frame ends
Flexcomm's SPI SSEL (or CS) will be held until frame end.
FIFOWR[EOT] (kSPI_FrameAssert enum) is the register not set.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2020-07-29 08:00:23 -05:00
Michael Hope e68287dd90 drivers: spi: fix the fast path on the SAM0 driver
To keep the bus fully loaded, the SAM0 has a fast path that recognises
special cases like TX only, RX only, or TX/RX of the same size.
Commit #ea2431f32f7 accidentally disabled this.

This increases the utilisation from around 30 % to around 90 % at 48
MHz.

Signed-off-by: Michael Hope <mlhx@google.com>
2020-07-06 10:02:14 -04:00
Michael Hope 8181eede5d drivers: spi: ensure the first byte has been loaded in the TX fast path
The SAM0 has a data register and a shift register.  Data that is
written to the data register is transferred to the shift register by
the peripheral.

On the SAMD51, the CPU is fast enough that the first data write hasn't
been transferred to the shift register by the time the next data write
occurs, causing the second write to be dropped, causing the receiver
to wait forever.

Fix by spinning until the data register is empty.

Signed-off-by: Michael Hope <mlhx@google.com>
2020-07-06 10:01:35 -04:00
Maureen Helm 10c1ded452 drivers: spi: Add optional delays to mcux dspi and lpspi drivers
Adds optional device tree properties to set delays between spi chip
select assert/deassert and clock edges in the mcux dspi and lpspi
drivers. If these properties are not set, then the minimum supported
delays are used.

Verified that tests/drivers/spi/spi_loopback/ still passes on
mimxrt1050_evk (lpspi driver) and frdm_k64f (dspi driver).

Measured with a scope that the pcs-sck-delay and sck-pcs-delay times on
the first spi transaction in the test are reduced from 7.82 us to 20 ns
on mimxrt1050_evk.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-07-02 07:57:36 -04:00
Jordan Yates 5963ebaf33 drivers: spi: CS configuration through devicetree
Add an additional option to the spi_cs_control struct that records how
the pin has been configured in devicetree. For drivers that are not
updated, the CS behaviour is the same as before (Push-Pull).

Use the devicetree knowledge with the GPIO subsystem so that the correct
physical pin levels for the CS pin are automatically selected.

Fixes #26267

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Karsten Koenig 189ae8c890 drivers: spi: rv32m1_lpspi: Fix null tx
Initialize the dummy data transfer so spi transfer is defined even for
an undefined tx data buffer. This aligns the rv32m1 spi driver with the
mcux spi driver.

Signed-off-by: Karsten Koenig <karsten.koenig.030@gmail.com>
2020-06-17 09:30:12 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Martí Bolívar 3852e08126 drivers: spi_ll_stm32: fix COND_CODE_1 usage
The consequent and alternate expressions for COND_CODE_1 must be
enclosed in parentheses, like this:

COND_CODE_1(PREDICATE, (consequent), (alternate))

The parens are missing in exactly one place in the tree. Fix it.

Reported-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-29 23:07:19 +02:00
Vincent Wan 002de4decf drivers: spi: cc13xx_cc26xx: set power config based on SPI base addr
The power configuration is dependent on which SPI is physically used.
In order to allow DT_INST_FOREACH_STATUS_OKAY() to iterate through
instances without the assumption that index 0 corresponds to SPI0
(which would be incorrect in the case when only SPI1 is enabled),
we need to check the base address to identify which SPI is being dealt
with.

Fixes #25673

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2020-05-28 10:30:14 +02:00
Erwan Gouriou ac98a786d4 drivers/spi: stm32: Fix use of single dma channel
Current dma struture code didn't allowed only rx channel removal,
disabling tx channel (in spi client node) was leading compilation
issue.
Fix this by moving conditional code inside SPI_DMA_CHANNEL macro and
get the part of code which is present or removed (SPI_DMA_CHANNEL_INIT)
outside of {}.
Additionally, fix indentation on '\' in whole instance init macros

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-05-18 19:14:37 +02: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
Francois Ramu 1a163673c7 drivers: spi: driver reloading dma buffers in the main transceive loop
With this change, the spi transceive with dma function
waits for the spi busy flag reset and for the dma transfer end.
Then it reloads the channels until all buffers are consumed.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-05-13 16:22:10 +02:00
Francois Ramu c83e2a41ae drivers: spi: driver dma callback function to set transfer flag
This change avoids the reload of the dma channel
in the callback function, just sets the corresponding Tx, Rx flag.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-05-13 16:22:10 +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 0a7d4e2135 devicetree: Change DT_FOREACH_IMPL_ to not insert semicolon
Remove semicolon between instance invocations of DT_FOREACH_IMPL_ and
thus DT_INST_FOREACH.  This provides more flexibility to the user.  This
requires we fixup in tree users to add semicolon where needed.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-07 20:03:56 -05:00
Andrei Gansari ec7fad0853 drivers: spi_mcux_flexcomm clock increase
Attached Flexcomm SPI driver to the main clock used by the core.
This means setting the SPI clock the same value as the core clock.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2020-05-07 12:47:34 -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
Vincent Wan da60111949 drivers: spi: cc13xx_cc26xx: remove usage of CONFIG_SPI_0/1
Clean up as we wish to move away from using these Kconfig settings.
Also removing them from the boards' default config.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2020-05-06 17:48:13 -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
Kumar Gala fdd85d5ad7 dts: Rename DT_HAS_NODE macro to DT_HAS_NODE_STATUS_OKAY
Rename DT_HAS_NODE to DT_HAS_NODE_STATUS_OKAY so the semantics are
clear.  As going forward DT_HAS_NODE will report if a NODE exists
regardless of its status.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-06 05:25:41 -05:00
Benjamin Valentin 8a99bd0da8 drivers: spi: spi_sam0: fix spi_sam0_fast_txrx()
The optimisation in `spi_sam0_fast_txrx()` is broken, loading
two bytes into the `DATA` register in rapid succession will lose
one byte.

This can be observed by running `tests/drivers/spi/spi_loopback`.
The test will get stuck in `spi_sam0_fast_txrx()` forever waiting
for the final byte.

Undo this small optimisation and only load the next byte into the
`DATA` register after the response has been received.

This fixes `tests/drivers/spi/spi_loopback`.

Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
2020-05-05 09:58:29 -05:00
Francois Ramu 469e505278 drivers: spi: control of the dma callback on spi client for stm32
The DMA callback function now controls the tx or rx buffers
and reload dma in case of multiple trnasfer before the transfer ends

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-05-04 09:46:07 -05:00
Francois Ramu ce093dc35e drivers: spi: Enable dma transfer for SPI on stm32
Enable dma operations with or w/o a dmamux on STM32
for SPI periph/memory operations.
Use the pi dma client with dma macros

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-05-04 09:46:07 -05:00
Daniel Leung f59d56b534 drivers: spi: xec_qmspi: Convert to using DT_INST macros
Convert driver to use instance macro's instead of dts_fixup.h based
macros.  This moves us closer to removing both dts_fixup.h and per
instance Kconfig symbols.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-04-28 07:43:31 -05:00
Kumar Gala aa63b07019 drivers: spi: spi_sam0: rework devicetree support
Rework the devicetree to utilize new DT_INST macros and extract per
instance data for clocks and dma from devicetree.  We update the
atmel,sam0-spi binding for dma to replace the rxdma and txdma
properties with proper 'dmas' property.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-25 09:30:16 -05:00
Kumar Gala dbeb3ba32e drivers: spi: spi_sam: rework device tree support
Reworked spi_sam driver to utilize new DT_INST macros as part of
this rework we also now get pin ctrl/mux configuration information
from the device tree instead of via Kconfig and defines in soc_pinmap.h

We remove defines from dts_fixup.h and soc_pinmap.h and associated
Kconfig symbols that are no longer needed due to getting all that
information from devicetree.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-25 09:29:54 -05:00
Kumar Gala 8b6acb5e91 soc: arm: replace DT_CPU_CLOCK_FREQUENCY with new dt macros
Replace DT_CPU_CLOCK_FREQUENCY with a PATH based reference to cpu@0
(DT_PATH(cpus, cpu_0)) and than getting the clock_frequency property:

DT_CPU_CLOCK_FREQUENCY -> DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency)

This lets us remove DT_CPU_CLOCK_FREQUENCY from dts_fixup.h.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-23 23:55:37 -05:00
Vincent Wan 0915ccca46 drivers: cc13xx_cc26xx: use DT_INST_FOREACH to reduce code duplication
Use DT_INST_FOREACH macro to combine code used for multiple instances.
Remove unnecessary Kconfig options for UART instances.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2020-04-23 17:29:53 -05:00
Vincent Wan 9d89ce1d6d drivers: cc13xx_cc26xx: Convert drivers to use more new DT_INST macros
Changing more of DT_* prefixed macros that refer to instances to use
DT_INST macros.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2020-04-23 17:29:53 -05:00
Tobias Svehagen 688f506d4b drivers: spi: sifive: Fix bug with checking if tx fifo is full
The check of the SF_TXDATA_FULL flag is only done on the register
address and not on the actual register content.

Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
2020-04-23 17:28:48 +02:00
Kumar Gala 5999787e6e drivers: spi: spi_stm32: Convert DT_COMPAT_ define usage to new macros
Convert driver from using DT_COMPAT_ST_STM32_SPI_FIFO to new macro
DT_HAS_COMPAT(st_stm32_spi_fifo).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-23 05:58:17 -05:00
Kumar Gala fac0d7d90e drivers: spi: mcux_lpspi: Convert to DT_INST
Convert driver to use new DT_INST macros throughout.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-20 15:23:47 -05:00
Kumar Gala df302727dc drivers: spi: mcux_flexcomm: Convert to DT_INST
Convert driver to use new DT_INST macros throughout.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-20 15:23:47 -05:00
Kumar Gala 1d33ed3dfc drivers: spi: mcux_dspi: Convert to DT_INST
Convert driver to use new DT_INST macros throughout.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-20 15:23:47 -05:00
Martí Bolívar 44cf00d6e1 drivers: spi: nordic: finish conversion to new DT API
The SPIM driver has been converted already. Convert the SPI and SPIS
drivers too. Leave existing Kconfigs in place.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-04-20 15:43:39 +02:00
Maureen Helm 1b6d4dd223 drivers: spi: Set dummy data in mcux drivers
Sets the "dummy data" value to send when the transmit buffer is null.
Fixes the spi_null_tx_buf test in tests/drivers/spi/spi_loopback on the
lpcxpresso54114 board.

Tested on frdm_k64f, mimxrt1050_evk, and lpcxpresso54114_m4 boards.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-04-16 06:01:43 -05:00
Kumar Gala 8c60bc0b07 drivers: spi: rv32m1_spi: Convert driver to new DT_INST macros
Convert driver to use DT_INST macros and remove related board per
instance Kconfig symbol usage.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-10 14:38:04 -05:00
Andrzej Głąbek 011e9bac0b drivers: nrf: Remove no longer suitable dependencies on Kconfig options
Make I2C and SPI drivers for nRF SoCs no longer dependent on Kconfig
options that enable instances (i.e. I2C_x and SPI_x). Now these drivers
enable hardware instances when corresponding nodes in devicetree are
enabled (have status "okay").
For I2C, SPI, and UART drivers, instead of using Kconfig dependencies
to prevent enabling of hardware instances that cannot be used together
(e.g. SPIM1 and TWIM1), a file that signals invalid configurations with
build assertions is added to compilation.
Also dependencies on HAS_HW_NRF_* options are removed from Kconfigs
of I2C, SPI, and UART drivers, as for hidden options that activate
proper type of driver such dependencies are not actually helpful.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-04-03 14:47:32 +02:00
Andrzej Głąbek cb0cb3f2e8 drivers/spi/Kconfig.nrfx: Choose driver type basing on DT compatible
Remove prompts from Kconfig options `SPI_x_NRF_SPI*` that select the
type of nrfx driver (for SPI, SPIM, or SPIS peripheral) to be used
for a given instance. This prevents the options from being modified
in configuration files.
Instead, make one of these options selected by default according to the
"compatible" property set for the corresponding SPI node in devicetree.

This eliminates the need of changing both the "compatible" property in
devicetree and the Kconfig option selecting the driver type when a user
wants to switch between SPI, SPIM, and SPIS for a given instance.

Since all `SPI_x_NRF_SPI*` options are made "hidden" by this commit,
all their occurrences in configuration files are removed.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-04-03 14:47:32 +02:00
Kumar Gala 36049b1657 drivers: Convert to use DT_INST_FOREACH
Convert drivers that have the following pattern:

   #if DT_INST_NODE_HAS_PROP(0, label)
   INIT_MACRO(0)
   #endif

   ...

   #if DT_INST_NODE_HAS_PROP(n, label)
   INIT_MACRO(n)
   #endif

to use DT_INST_FOREACH(INIT_MACRO) instead.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-31 19:29:22 -05:00
Vincent Wan 16fab6c4f8 drivers: cc13xx_cc26xx: guard references to sleep states
Use of macros such as SYS_POWER_STATE_SLEEP_2 needs to be guarded by
making sure CONFIG_SYS_POWER_SLEEP_STATES is defined.

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

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

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

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-30 12:49:43 -05:00
Kumar Gala 0c4779d413 drivers: spi: spi_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 020a899ec3 drivers: sifive: Convert sifive drivers to new DT_INST macros
Convert older DT_INST_ macro use in sifive drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 16:06:09 -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 4cb0a5d992 drivers: silabs: Convert silabs drivers to new DT_INST macros
Convert older DT_INST_ macro use in silab drivers to the new
include/devicetree.h DT_INST macro APIs.

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

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 05:20:19 -05:00
Vincent Wan ddfb1b5ec7 drivers: spi: cc13xx_cc26xx: add power management support
Add a dependency on the SSI resource in the TI Power module, and add
support for device PM.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2020-03-25 16:21:33 -04:00
Martí Bolívar ffcf7cad6a drivers: spi: convert spi_nrfx_spim.c to new DT API
This allows us to start using DT_NODELABEL() to access SPIMs that way,
instead of via an alias.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-24 10:11:20 -05:00
Carles Cufi 4b37a8f3a4 Revert "global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT()"
This reverts commit 8739517107.

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

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

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-19 15:47:53 +01:00
Kumar Gala 47968e30cf drivers: spi: dw: handle flags differences in driver
Towards cleaning up (and hopefully removing dts_fixup.h in the near
future).  We need to move the handling of different names for the irq
flag propety into the driver and out of dts_fixup.h.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-17 19:37:59 -04:00
Erwan Gouriou c2f19dc52e drivers: spi: spi_stm32: convert to DT_INST defines
Convert driver to use DT_INST_ defines.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-03-17 11:03:10 -06:00
Erwan Gouriou d3664b063e drivers/spi: stm32: Modify use of "st,stm32-spi-fifo" compatible
On stm32 spi devices, there are 2 main IP variants, with and w/o
fifo. Fifo is not really used today, but still there is some
additional code handling fifo. Today this code is protected under
Kconfig symbol SPI_STM32_HAS_FIFO.
This code carries redundant information vs dedicated compatible
"st,stm32-spi-fifo", which is provided as unique driver compatible
for devices supporting this IP as opposed to use of "st,stm32-spi"
when fifo is not supported.

Having these 2 compatibles defined exclusively is not convenient for
migration to DT_INST as DT_INST macros contain compatible string and
hence it cannot be used to provide common compatible code for devices
defining different compatibles.

Based on these observations, review stm32 spi devices compatible
declarations. Devices supporting fifo will now declare both
compatibles, as proposed by dt spec: "[compatible] property value
consists of a concatenated list of null terminated strings,
from most specific to most general". Hence field will now be:
"st,stm32-spi-fifo", "st,stm32-spi"

This way, fifo enabled stm32 spi devices will generate both:
DT_INST_STM32_SPI_FOO and DT_INST_STM32_SPI_FIFO_FOO
As well as:
DT_COMPAT_ST_STM32_SPI and DT_COMPAT_ST_STM32_SPI_FIFO
So, DT_INST_STM32_SPI_FOO could be used for device initialization.
Also DT_COMPAT_ST_STM32_SPI_FIFO could be used for FIFO handling
code inside driver. Hence use it to replace Kconfig symbol
SPI_STM32_HAS_FIFO.


Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-03-17 11:03:10 -06:00
Andrzej Głąbek 2b2a3b030f drivers: spi: nrfx: Prevent double nrfx_spi[m]_uninit calls
Attempt to deinitialize an nrfx driver that is not initialized results
in an assertion failure reported by the driver. And such attempt could
happen in SPI shims when the power state was switched between states
other than ACTIVE.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-03-12 08:57:14 -05:00
Kumar Gala 69c5aa0b32 driver: spi: 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
Andrzej Głąbek 668d401293 modules: hal: nordic: Define NRFX_ASSERT as __ASSERT_NO_MSG
Update hal_nordic's revision, so that NRFX_ASSERT uses __ASSERT_NO_MSG
directly, not through the assert macro that comes from from libc,
as the definition of the latter might be different when some specific
libc version is used, and this could generate troubles.

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

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-03-10 17:21:27 +01:00
Kumar Gala 93b78b7bf8 drivers: spi: sifive: Fix comment to match ifdef
The endif comment didn't match the actual ifdef define.  Fix the comment
to match.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-17 09:05:32 +01:00
Ulf Magnusson 378d6b137a kconfig: Replace non-defconfig single-symbol 'if's with 'depends on'
Same deal as in commit eddd98f811 ("kconfig: Replace some single-symbol
'if's with 'depends on'"), for the remaining cases outside defconfig
files. See that commit for an explanation.

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

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-02-12 10:32:34 -06:00
Mikkel Jakobsen 4adc40889d drivers: spi: spi_mcux_dspi: fix missing context unlock on busy bus
Error codes from DSPI_MasterTransferNonBlocking are now handled in
tranceive to ensure that the context is unlocked when an busy bus
is detected.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@prevas.dk>
2020-02-08 11:41:21 +02:00
Ulf Magnusson b9270c388d kconfig: Remove redundant SPI_DW dep on SPI_DW_ACCESS_WORD_ONLY
This symbol is already defined within an 'if SPI_DW'.

Flagged by https://github.com/zephyrproject-rtos/ci-tools/pull/128.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-02-08 09:58:33 +02:00
Gerson Fernando Budke 738f76736e drivers: spi: sam: Add sam4e chip select config
Add depends on SOC_SERIES_SAM4E to enable spi driver for sam4e soc.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-02-05 10:14:51 -05:00
Erwan Gouriou 361b55d4cb drivers/spi: spi_context.h: Update to new GPIO API
Update to new GPIO API.


Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-02-05 12:00:36 +01:00
Gerson Fernando Budke b1b60ac1d8 drivers: spi: sam: Add support to samv71 soc
Add depends on SOC_SERIES_SAMV71 to enable spi driver for samv71 soc.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-02-04 14:55:45 -05:00
Gerson Fernando Budke 7422cff736 drivers: spi: sam: Enable generic config
The current sam spi driver uses soc dependent name which duplicate
configuration to enable other platforms. This refactor current
definitions to a generic way to reuse symbols by multi soc definitions.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2020-02-04 14:55:45 -05:00
Ismael Fillonneau 84a0b32210 drivers: spi: nrfx: factorise spi_context_lock()
spi_context_lock() & spi_context_release() are called in transceive()
function for a better readability.

Signed-off-by: Ismael Fillonneau <ismael.fillonneau@stimio.fr>
2020-02-04 20:58:05 +02:00
Andrzej Głąbek 7899b1f5b6 modules: hal_nordic: Update nrfx to version 2.1.0
Update the hal_nordic module revision, to switch to nrfx 2.1.0.

Because the list of peripherals for nRF5340 has changed as follows:
- SPIM2 has been renamed to SPIM4
- SPIM2-3, SPIS2-3, TWIM2-3, TWIS2-3, and UARTE2-3 have been added
a couple of related corrections needed to be applied in dts and Kconfig
files, plus the spi_nrfx_spim driver has been extended with the support
for SPIM4.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-01-29 15:00:45 +01:00
Tomasz Bursztyka f5a9d5d1a5 driver/spi: Make DT aliases consistent for the DW drivers
And apply it on all existing fixups.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-01-28 18:18:18 -05:00
Peter Bigot 5ceb612738 treewide: use full path to spi.h header
The build infrastructure should not be adding the drivers subdirectory
to the include path.  Fix the legacy uses that depended on that
addition.

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

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:52:12 +01:00
Ulf Magnusson d28e1f6bcb kconfig: Turn pointless 'menuconfig's into 'config's
Same deal as in commit 677f1e6 ("config: Turn pointless/confusing
'menuconfig's into 'config's"), for a newly-introduced stuff.

Also clean up headers to be consistent with recent cleanups.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-24 21:30:17 -05:00
David D b96525c82c drivers: spi: Fixing null-pointer dereference in stm32
Fixes #21935

Signed-off-by: David D <a8961713@gmail.com>
2020-01-20 18:38:39 -05:00
Marcin Niestroj bbe8e63c46 spi: stm32: deduplicate code creating SPI instances
Create new instances of SPI using single STM32_SPI_INIT() macro
invocation, similar as it is done for STM32 UART driver. Add also
implicit '#ifdef CONFIG_SPI_id' check, so it further reduces required
lines of code for each SPI instance definition.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-01-20 18:36:24 -05:00
Maureen Helm 94c5a75998 drivers: spi: Refactor mcux dspi driver to use generated dts macros
Refactors the mcux dspi driver to use generated device tree macros
directly. Removes now unused dts fixup macros from kinetis socs.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-01-15 18:02:19 -05:00
Maksim Masalski 33336e78f6 drivers: spi: Support PM busy state where relevant in DW
Need to set device busy when enter into transceive function
in SPI DW driver.
In current SPI DW driver the transceive function don't set busy state,
but that is important for PM busy state.
This will lead to unexpected behaviors when system calls this
function and enter into idle state.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-01-13 11:33:12 -05:00
Christian Taedcke 6da94af847 drivers: spi: Add Gecko SPI driver
This commit adds SPI driver and its bindings using the USART peripheral
for Silicon Labs EFM32 and EFR32 MCUs.

Signed-off-by: Christian Taedcke <hacking@taedcke.com>
2020-01-10 07:14:35 -06:00
Erwan Gouriou ca61847af2 Revert "spi: stm32: Enable sending 16bits at a time in 8bit mode if possible"
This reverts commit 2ce8fa1e42.

Fixes #21546
Fixes #21679

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-01-07 19:08:36 +01:00
Marciano C. Preciado d3abb0b9ca drivers: nrf: Catch for nRF53 serial interference
UARTE, SPI, & TWI with the same ID# share resources on nRF53

Signed-off-by: Marciano C. Preciado <marciano@passive-logic.com>
2020-01-07 17:14:25 +01:00
Ulf Magnusson 0fb370b257 drivers: spi: kconfig: Turn pointless 'menuconfig' into 'config'
Same deal as in commit 677f1e6 ("config: Turn pointless/confusing
'menuconfig's into 'config's"), for a newly-introduced SPI_MCUX_FLEXCOMM
symbol.

Also clean up the header to be consistent with recent cleanups.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-03 07:32:32 -06:00
Benjamin Valentin 74f95c499e spi: sam0: Add support for SAME54
The SPI SERCOM peripheral found on the SAMD5x/SAME5x is very much alike
the one found in previous SAM0 MCUs.

Only the clock setup is different.

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2019-12-18 22:12:15 +01:00
Pushpal Sidhu 2ce8fa1e42 spi: stm32: Enable sending 16bits at a time in 8bit mode if possible
If possible, allow sending 16bits at once instead of 8bits. I found
large delays (up to 3us) between sending bytes due to Zephyr SPI
overhead, so allowing 16bits at a time if possible helps save that
time.

Signed-off-by: Pushpal Sidhu <psidhu.devel@gmail.com>
2019-12-18 22:01:20 +01:00
Pushpal Sidhu 8f0788ee69 spi: stm32: remove spi_stm32_next_tx helper
Remove usage of this helper to stage for 16bit frame transfers in 8bit
mode.

Signed-off-by: Pushpal Sidhu <psidhu.devel@gmail.com>
2019-12-18 22:01:20 +01:00
Pushpal Sidhu cf228ec2f8 spi: stm32: Add ll_func_set_fifo_threshold_16bit helper
Add this function to allow the fifo to be set for 16bits.

Signed-off-by: Pushpal Sidhu <psidhu.devel@gmail.com>
2019-12-18 22:01:20 +01:00
Krzysztof Chruscinski d716e3a66c various: Cleanup COND_CODE_1 usage or replace with IF_ENABLED()
Cleanup around COND_CODE_1 usage and replacing with
IF_ENABLED if applicable.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-12-18 08:14:52 -05:00
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
Maureen Helm a63676761b drivers: spi: Add mcux flexcomm driver
Adds a shim layer around the mcux lpc flexcomm driver to adapt it to the
zephyr spi interface. It leverages heavily from the existing mcux dspi
shim driver.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-12-10 08:48:56 -06:00
Maureen Helm d55d532ebd drivers: spi: Add configs for instances 7 and 8
Adds configs for spi instances 7 and 8.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-12-10 08:48:56 -06:00
Kumar Gala cd0f8d5c4f include: Fix use of <sys_io.h> -> <sys/sys_io.h>
Fix #include <sys_io.h> as it has been deprecated and
should be #include <sys/sys_io.h>.

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

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

Also replace some

    config
    	prompt "foo"
    	bool/int

with the more common shorthand

    config
    	bool/int "foo"

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

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-09 16:14:50 +01:00
Andrzej Głąbek 69c75c7267 drivers: spi: nrfx: Move MISO lines pull configuration to DT
After switching to nrfx 2.0.0, the Kconfig choice options that allowed
enabling of pull-up or pull-down for MISO lines in SPIs and SPIMs are
not properly supported, they are simply ignored. This commit restores
the possibility of applying pull configuration for MISO lines.

In earlier nrfx versions, the MISO pull configuration could be only
set globally, in nrfx_config files, for all SPI and SPIM instances
together. Since nrfx 2.0.0, this configuration can be applied per
instance. This commit takes advantage of this possibility and instead
of using a common Kconfig option as a global setting for all instances,
allows applying individual instance settings via devicetree.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-12-09 16:08:39 +01:00
Andrzej Głąbek 377002d4b5 drivers: spi_nrfx_spim: Fix handling of extended SPIM configuration (2)
This is a follow-up to commit 84f8235005.

Default initialization to 0 of the .dcx_pin field in the extended part
of the SPIM configuration is incorrect, because this means that pin 0
should be used as the D/CX line. For the SPIM instance that provides
the extended functionality, this results in undesired assignment of
the pin 0, and for the other SPIM instances, this causes that their
initialization fails with the NRFX_ERROR_NOT_SUPPORTED code.

This commit sets this field to NRFX_SPIM_PIN_NOT_USED, to indicate that
the D/CX line is not supposed to be used.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-12-09 16:07:55 +01:00
Andrzej Głąbek 84f8235005 drivers: spi_nrfx_spim: Fix handling of extended SPIM configuration
Fill the `rx_delay` field in the SPIM configuration structure only when
the RXDELAY feature is present in a given SPIM instance, to prevent
compilation errors when some other SPIM instance is enabled together
with SPIM3.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-12-03 12:26:12 -06:00
Wentong Wu aa37522fe3 spi: fix spell typo in spi handler
fix spell typo in spi handler.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-11-20 09:56:53 -08:00
Wentong Wu b82e202988 spi: pass correct buffer to spi driver given NULL to spi_transceive
When pass NULL to spi_transceive with user space enabled, stack buffer
is still passed to spi driver and it will cause kinds of problems like
MPU fault, so change it to pass relevant NULL pointers in the actual
transceive call.

Fixes: #20811.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
2019-11-20 09:56:53 -08: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
Francois Ramu a0bd434fa5 driver: spi: Error handling issues in spi_stm32_configure
This patch tests the return code when calling clock_control_get_rate
and completes the issue  #20503 seen on watchdog
[Coverity CID :205655]

Fixes #20503

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2019-11-18 09:18:13 -06:00
Emil Obalski 6c82c80a3c drivers: Add support for nRF52833 in several drivers
By adding new SoC to Zephyr drivers has to be updated.
Commit affects:
 - USB driver
	- support for nRF52833 added.
	- support for USB_DEVICE_REMOTE_WAKEUP in hid-mouse added.
 - SPI
 - IEEE 802.15.4
 - CLOCK CONTROL

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

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

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

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

Signed-off-by: Karol Lasończyk <karol.lasonczyk@nordicsemi.no>
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-11-08 14:54:12 +01:00
Vincent Wan 27c035fff4 drivers: spi: use CPU clock frequency in configuration on CC13XX/CC26XX
The SPI peripheral should be configured using the CPU clock speed and
not the system clock speed. This used to be fine because they were the
same before #19232, but now that the system clock is RTC-based (which
has a different frequency), we can no longer make that assumption.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-11-07 15:55:21 -06: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
Karsten Koenig ee2dd7322f drivers: spi: rv32m1: Add driver for RV32M1 LPSPI
Add SPI driver and bindings for LPSPI peripheral for the RV32M1 SOC.
Based heavily on the existing mcux LPSPI driver.

Signed-off-by: Karsten Koenig <karsten.koenig.030@gmail.com>
2019-11-04 14:11:18 -06:00
Ulf Magnusson c8e5ca3852 kconfig: Turn pointless/confusing 'menuconfig's into 'config's
Same deal as in commit 677f1e6db9 ("config: Turn pointless/confusing
'menuconfig's into 'config's"), for some newly introduced (or maybe
overlooked) stuff.

Also clean up formatting a bit, replacing spaces with tabs and
shortening the header.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-03 12:47:30 +01: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
Scott Worley c8b1eb79a1 drivers : spi : mec1501 : XEC SPI driver
SPI driver for MEC1501 QMSPI supporting synchronous only.

Signed-off-by: Scott Worley <scott.worley@microchip.com>
2019-10-23 19:18:32 -07:00
Olof Kindgren d09614ab59 drivers: spi: Add simple_spi driver
Add support for the OpenCores simple_spi controller

Signed-off-by: Olof Kindgren <olof.kindgren@gmail.com>
2019-10-22 15:54:03 -05: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
Daniel Craviee 256c5c4e17 drivers: spi: Add LiteX SPI driver
This commit adds LiteX SPI drivers and its bindings.

Signed-off-by: Daniel Craviee <dcraviee@internships.antmicro.com>
Signed-off-by: Mateusz Holenko <mholenko@antmicro.com>
2019-10-21 08:40:09 -05:00
Richard Osterloh 794606f866 drivers: spi: Add STM32G4X SPI support
Add SPI driver support for STM32G4X SoC series.

Signed-off-by: Richard Osterloh <richard.osterloh@gmail.com>
2019-10-04 18:44:24 -07:00
Andrzej Głąbek f43bae38e8 dts: Use separate compatibles for Nordic SPI/SPIM/SPIS peripherals
This commit introduces separate "compatible" strings for DTS nodes
representing different types of Nordic SPI peripherals. Previously
"nordic,nrf-spi" was used for both SPI and SPIM. SPIS was already
handled separately.

Quite a few files need to be touched by this commit but the changes can
be divided into groups of related or very similar ones, distinguishable
by the initial part of the path to the modified file:

* dts/bindings/spi/
  new binding for "nordic,nrf-spim" is added and common fields for all
  3 types of Nordic SPI peripherals are extracted to a shared file

* dts/arm/nordic/
  "compatible" properties in spiX nodes are updated (when there is no
  choice as only one type of SPI peripheral is available) or replaced
  with a comment pointing out that the proper type of peripheral needs
  to be picked at some upper layer

* drivers/spi/
  spi_nrfx_spim driver is updated with the new form of macros generated
  from dts

* boards/
  all spiX nodes in dts files for boards equipped with an nRF chip are
  updated with the proper "compatible" property, according to the type
  of SPI peripheral that is currently selected for the board by the
  corresponding Kconfig choice option (SPI_x_NRF_SPI*)

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-09-26 19:13:17 +02:00
Watson Zeng 75a65a0ad1 drivers: spi_dw: add WORD only access support
In some hardware, e.g. ARC HS Development kit,the peripheral
space of DesignWare SPI only allowes WORD access,
byte acess will raise bus error.

This commit adds support for this case

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2019-09-17 20:40:38 +08:00
Erwan Gouriou 555936f771 dts/Kconfig: Remove unused HAS_DTS_SPI
Symbol is always "and'ed" with the symbol that
selects it, so no effect. Clean it up.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-09-12 08:16:42 -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
Andrzej Głąbek 70d426bd33 modules: Kconfig: Unify the way of enabling instances in nrfx drivers
Use a consistent way of enabling particular instances of peripherals
in nrfx drivers through options defined in modules/Kconfig.nordic,
to make the usage of nrfx drivers in Zephyr, especially the ones for
which there are no Zephyr driver shims (yet), easier.

Jira: NCSDK-2744

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-09-10 13:23:44 +02:00
Charles E. Youse 34ffdd0aab drivers/spi/spi_intel.c: remove Quark SPI support
This was only used on Quark SoCs. It is no longer used, can no
longer be tested, and it's reliant upon the deprecated legacy PCI
subsystem. Remove it to prevent bitrot.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-09-08 22:09:10 -04:00
Peter Bigot 5f481bb042 drivers: rearrange for standard use of extern "C" in private headers
Consistently place C++ use of extern "C" after all include directives,
within the negative branch of _ASMLANGUAGE if used.

Only updated in headers that already had support for drivers built with
a C++ compiler.

The spi_dw.h file defines macros to declare functions, then uses them
within a file that may have out-of-tree overrides.  In this case we
leave the including file extern "C" active for backward compatibility.

Background from issue #17997:

Declarations that use C linkage should be placed within extern "C"
so the language linkage is correct when the header is included by
a C++ compiler.

Similarly #include directives should be outside the extern "C" to
ensure the language-specific default linkage is applied to any
declarations provided by the included header.

See: https://en.cppreference.com/w/cpp/language/language_linkage
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-08-13 18:00:31 +02:00
Nicolas Pitre 75bf3c5368 riscv: freedom: rename RISCV32 to RISCV
This code is common to 32- and 64-bit builds.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-08-08 00:29:24 -04:00
Yaël Boutreux e0d6534f09 drivers: spi: spi_ll_stm32: Add support for STM32MP1x SoC
Add SPI driver support for STM32MP1x SoC.

Signed-off-by: Yaël Boutreux <yael.boutreux@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
2019-08-05 13:52:34 -05:00
Yaël Boutreux 876eb63ac3 drivers: spi: st_stm32: Abstract LL function for spi ver. compatibility
Abstract some SPI LL function call for future driver compatibility with
a new SPI peripheral version (introduced with STM32MP1x and STM32H7x
SoC)

Signed-off-by: Yaël Boutreux <yael.boutreux@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
2019-08-05 13:52:34 -05:00
Yaël Boutreux c935508c05 drivers: spi: spi_ll_stm32: set NSS before mode
This commit solves an issue where the NSS must be set before the
mode on the stm32mp157c_dk2, else LL_SPI_SetMode won't affect the
mode registry.
stm32mp1x (and stm32h7) LL function SPI_Init seems to also define
first the NSS then the mode, unlike other STM32 boards where this
is not specified.
Changing the order shouldn't have bad repercussions on other boards,
ZephyrnSPI driver test has been passed successfully on disco_l475_iot1
board.

Signed-off-by: Yaël Boutreux <yael.boutreux@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
2019-08-05 13:52:34 -05:00
Yaël Boutreux ebcd6506fa drivers: spi: spi_ll_stm32: Long line cleanup
Split a long line remaining in the driver.

Signed-off-by: Yaël Boutreux <yael.boutreux@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
2019-08-01 11:58:02 -04:00
Yaël Boutreux 13ceab4c3b drivers: spi: spi_ll_stm32: Add config to manage slave select
Allow the user to use software slave select instead of the
hardware pin, in order to free the related GPIO and avoid
unwanted SS triggering on the hardware pin. The default SS
is still the hardware pin.

Signed-off-by: Yaël Boutreux <yael.boutreux@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
2019-08-01 11:58:02 -04:00
Yaël Boutreux 3a6b46e263 drivers: spi: spi_ll_stm32: Fix uncleared MODF flag
Clear raised MODF flag, if not done the flag stay set forever.

Fixes https://github.com/zephyrproject-rtos/zephyr/issues/17363

Signed-off-by: Yaël Boutreux <yael.boutreux@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
2019-07-31 10:30:44 -04: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
Rick Conrey 32a3ae8ab9 drivers: spi: Enable SPI on stm32wb
Enable FIFO for stm32wb

Signed-off-by: Rick Conrey <rick.conrey@witiproducts.com>
2019-07-25 10:49:58 -04:00
Piotr Zięcik 4a543e138d drivers: spi_dw: Get clock frequency from DTS
The spi_dw driver used system clock frequency
as a base for SPI bus frequency calculation.
This commit corrects that by obtaining the needed value from DTS.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2019-07-24 15:10:02 +02:00
Mieszko Mierunski f4b999a389 drivers: nrf: Add power management to nrf SPI driver.
Add power management to nrf SPI driver.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2019-07-15 12:05:19 +02:00
Mieszko Mierunski 23992a0614 drivers: nrf: Add power management to nrf SPIM driver.
Add power management functions to nrf SPIM driver.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2019-07-15 12:05:19 +02: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 bd70f6f1ed cleanup: include/: move spi.h to drivers/spi.h
move spi.h to drivers/spi.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 6aa9c3a68f cleanup: include/: move gpio.h to drivers/gpio.h
move gpio.h to drivers/gpio.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
Anas Nashif 17ddd1714c cleanup: include/: move clock_control.h to drivers/clock_control.h
move clock_control.h to drivers/clock_control.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 ef281c4237 cleanup: include/: move sys_io.h to sys/sys_io.h
move sys_io.h to sys/sys_io.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 190e368275 cleanup: include/: move power.h to power/power.h
move power.h to power/power.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 43a49335f4 include: move interrupt controller headers to interrupt_controller/
Move internal and architecture specific headers from include/drivers to
subfolder for interrupt_controller:

include/drivers/interrupt_controller/

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

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-21 07:53:05 -05:00
Anas Nashif f2cb20c772 docs: fix misspelling across the tree
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-19 15:34:13 -05: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
Brett Witherspoon f2eea2ef85 drivers: add CC13xx / CC26xx SPI driver
Add driver for the SPI peripheral on the TI CC13xx / CC26xx series SoCs.

Signed-off-by: Brett Witherspoon <spoonb@cdspooner.com>
2019-05-27 09:21:19 -04:00
Benoit Leforestier 9915b4ec4e C++: Fix compilation error "invalid conversion"
When some header are included into C++ source file, this kind of
compilations errors are generated:
error: invalid conversion from 'void*'
	to 'u32_t*' {aka 'unsigned int*'} [-fpermissive]

Signed-off-by: Benoit Leforestier <benoit.leforestier@gmail.com>
2019-05-03 14:27:07 -04:00
Derek Hageman 4709816a69 soc: sam0: Remove SERCOM defines from dts_fixup.h
Move SERCOM peripherals to use the raw defines generated from DTS
parsing.  This adds aliases to the DTS so that the SERCOM number
can still be used for clocking and pinmux.

Signed-off-by: Derek Hageman <hageman@inthat.cloud>
2019-05-03 08:46:57 -05:00
Derek Hageman d68666fc08 drivers: spi: sam0: Implement DMA async API
This adds support for the async API for SAM0 SERCOM SPI using
DMA to drive the device.  This implementation does the reload
for both transmit and receive in the receive DMA handler.
Doing this simplifies the implementation but means that the
transmit drains completely, resulting in the SPI clock pausing
between buffers while both are reloaded in the receive handler.

Tested with tests/drivers/spi/spi_loopback and several simple
programs monitored with a logic analyzer.

Signed-off-by: Derek Hageman <hageman@inthat.cloud>
2019-05-01 10:27:42 -04:00
Andrew Fernandes e96673dca7 drivers: spi: nrfx: allow enabling DMA with the nRF52832 despite PAN 58
Add a Kconfig option to enable DMA for SPI with SOC_NRF52832 as long as
it being disabled due to Product Anomaly Notice (PAN) 58 is explicitly
overridden. This allows the SPIM driver to be enabled for the nRF52832
SoC for situations where PAN 58 is not a problem.

Signed-off-by: Andrew Fernandes <andrew@fernandes.org>
2019-04-28 13:29:46 -04:00
Benjamin Valentin 4d9486fc22 soc: sam0: Enable generic peripheral selection
Make sure that when e.g. CONFIG_SERIAL is set, CONFIG_UART_SAM0 is
selected automatically when the sam0 SoC family is used.

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2019-04-19 14:37:17 -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 97b3bd11a7 drivers: Rename reserved function names
Rename reserved function names in drivers/ subdirectory. Update
function macros concatenatenating function names with '##'. As
there is a conflict between the existing gpio_sch_manage_callback()
and _gpio_sch_manage_callback() names, leave the latter unmodified.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-04-03 17:31:00 -04:00
Patrik Flykt 21358baa72 all: Update unsigend 'U' suffix due to multiplication
As the multiplication rule is updated, new unsigned suffixes
are added in the code.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05: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
Benjamin Valentin c9907b438a drivers: spi: sam/sam0: Don't access uninitialized data
Set data->ctx.config before calling a function that operates on it.

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2019-03-26 07:28:52 -05:00
Benjamin Valentin 388e9a6223 drivers: spi: sam/sam0: Don't claim support for async transfers
Asyc transceive is currently not implemented for this driver,
so don't claim support.

spi_context_lock() is already being called in spi_sam_transceive()
so calling it in the wrapper function will cause a deadlock.

This reverts eae05d928e

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2019-03-26 07:28:52 -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
Ulf Magnusson 53376394b7 kconfig: Remove blank lines at the beginning/end of files
Maybe this is some "just in case" thing that got copied around. There's
no need to have a blank line at the beginning or end of Kconfig files.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-13 07:29:42 -05: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