To fix the native hardware chip select, we need to rewrite this driver
to not use the MCUX SDK handle abstraction, which does not fit the
zephyr use case.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add functions to get remaining length in the transfer. Refactor a bit to
avoid duplicate code for the for loop that is the same as in the total
length function.
The difference between the total length and left length function is that
the current buffer total length is counted in the former and the current
buffer remaining length is counted in the latter.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add properties for describing RX and TX fifo sizes.
Also reformat some descriptions and fix the description of the
transfer-delay property which was incorrect. Since zephyr spi bufs are
not continuous, every possible Zephyr LPSPI driver must use
continuous transfer mode, for which the meaning of this delay has
nothing to do with the chip select.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
This allows to configure a GPIO pin as a CS line, in order to perform
spi transfers to a particular device in the bus.
Example usage for using GPIO1.12 with GPIO_ACTIVE_LOW:
`spi cs gpio1 12 0x01`
Signed-off-by: Luis Ubieda <luisf@croxel.com>
Make a pointer to data that is specific to a certain type of LPSPI
driver, instead of having all of it in the struct whether it is used
or not.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add DT property to configure the LPSPI instance to use tristated output
instead of retained output when PCS is negated.
Turn on the config on a couple boards for test coverage.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
If DMA-based transaction fails, usually due to a timeout, DMA channels
may need to be explicitly stopped otherwise further calls to transceive
function will immediately return due to DMA constantly being busy.
Signed-off-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
Hardware chip select is originally handled by the HAL driver. However, a
finer grained control is needed to keep CS asserted between requests and
deassert it after last request is completed. Workaround this problem by
handling hardware chip select in Zephyr driver.
Signed-off-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
The EUSART peripheral must always be enabled in configure(), as
its enable state gets cleared when the state machine is unretained
in deep sleep. The rest of the config registers are retained,
so they can continue to not be repainted on every configure() if
the context is the same as last time.
Remove unnecessary duplicated enable at the end of configure(),
the SPIInit HAL function already performs enable.
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Determine proper irq setup depending whether the spi is wrapped in an
lpflexcomm or not on an instance basis since some platforms have some
wrapped and some not.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
The data size is set using a burst length, the data size for 8/16/32 is
always 1 in those cases.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
The internal chip selects are limited to 4, however when using GPIOS
does not pose this limitation.
Also set internal channel to 0 if GPIOS are used.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
The commit 2c3165d187 ("drivers: spi: add opaque type to encode SPI
operation flags") introduces new type for operation flag, since it is
16/32-bit depending on CONFIG_SPI_EXTENDED_MODES.
Use the new type for safe, if the function 'spi_stm32_shift_frames' may
use extended operation flag later.
Signed-off-by: Haiyue Wang <haiyuewa@163.com>
The Atmel SAM0 SoC enable peripherals clocks in distinct places: PM and
MCLK. The old devices had defined the peripheral clock enable bit at PM.
On the newer devices this was extracted on a dedicated memory section
called Master Clock (MCLK). This change excludes the dedicated bindings
in favor of a generic approach that cover all cases.
Now the clocks properties is complemented by the atmel,assigned-clocks
property. It gives the liberty to user to customize the clock source
from a generic clock or configure the direct connections.
All peripherals drivers were reworked with the newer solution.
Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
The DMA-based path of the lpspi driver is basically
almost a driver of it's own, move it to it's own file.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
There is (almost) a whole separate driver for RTIO,
move this code to its own file and move shared code
and definitions to a common file.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Move this driver to its own subfolder to organize it
since there will be new files added for this hardware.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Updated various device definition macros to use the DT_INST variants for
consistency and improved readability.
Signed-off-by: Dong Wang <dong.d.wang@intel.com>
Update the context state parameters when the context is already locked.
This allows changing the callback information for asynchronous
operations while the context is locked.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Fast SPIM instances (SPIM120 and SPIM121) for correct operation require
the highest frequency from the global HSFLL. This commit adds needed
clock controller requests to the driver. When the runtime device power
management is enabled, the frequency is requested as long as the SPIM
is resumed, otherwise it is requested for the duration of transfers.
This commit also adds a missing call to `pm_device_runtime_put()` when
SPIM reconfiguration fails.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Propagate bit ordering and type of CS pin to HAL layer. Previously,
the driver assumed MSB first and EUSART hardware CS control.
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Implement the SPI context lock in the USART SPI driver for
EFM32/EFR32.
Remove incorrect -EBUSY error when spi_release() is called while
there are still bytes in the TX FIFO. This condition does not
cause the act of releasing the lock to fail.
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Use shell_device_get_binding() instead of device_get_binding() so that
we get the device based on its name and in addition by its label.
Signed-off-by: Yishai Jaffe <yishai1999@gmail.com>
Prevent the driver from perfroming transfer when SPI_LINES_OCTAL flag
is specified, as this driver supports only SPI_LINES_DUAL for now.
Signed-off-by: Michal Morsisko <morsisko@gmail.com>
Add support for sending and receiving the least significant bit first
for the spi_bitbang driver. This driver can now be used with
SPI_TRANFER_LSB flag.
Signed-off-by: Michal Morsisko <morsisko@gmail.com>
Enable the device runtime power management on the SPIM shim.
Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
To facilitate changing this driver, decouple rtio from functions not
specific to RTIO. This also requires moving the sdk driver handle
creation outside of the configure call. An effect of this is we can
stop initializing an unused sdk driver handle for the dma path.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
These changes:
* Fix the check of the word size to be more useful
- check min frame size instead of max
- check for min word size requirement
- add a clarifying comment about what the word size represents in
hardware since the nomenclature from zephyr does not match the nxp
references
* Add a clarifying comment about half duplex being supported by hardware
* Add LPSPI_ namespace to defines
* Change chip select error message to be more clear about the problem
* Move the check of the clock device being ready to the lpspi init,
instead of checking it every time on configure. It probably also makes
more sense to not ready the lpspi device if the clock is not ready.
* Move the bare-metal configuration of bit fields AFTER the SDK Init
call.
* Return the proper error code if clock control call errors.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
If CONFIG_SPI_STATS is enabled, the device state for all SPI controller
drivers must contain the SPI stats. This space is allocated by calling
Z_SPI_INIT_FN as part of the device definition; this is done automatically
when using SPI_DEVICE_DT_DEFINE instead of DEVICE_DT_DEFINE. If space for
statistics is not properly allocated but CONFIG_SPI_STATS is enabled, an
unexpected write to memory outside of the stats region may occur on a SPI
transfer. This commit uses SPI_DEVICE_DT_DEFINE or
SPI_DEVICE_DT_INST_DEFINE for all in-tree SPI controller drivers.
Signed-off-by: Dane Wagner <dane.wagner@gmail.com>
Rename "nxp,kinetis-dspi" compatible to "nxp,dspi" to remove the
device family from its name.
Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
The Smartbond SPI driver enables DMA acceleration by default. However
no DMA configuration is provided in the SPI node, resulting in run
time errors when the SPI interface is used. Instead, the application
should explicitly enable DMA acceleration and select the DMA channels
and priorities.
Signed-off-by: Ian Morris <ian.d.morris@outlook.com>
- Move selection of CONFIG_PINCTRL from soc to individual
drivers
- in accordance with issue #78619
Signed-off-by: McAtee Maxwell <maxwell.mcatee@infineon.com>
Do all input validation etc BEFORE setting up configuration,
instead of mixing these things everywhere. Also condense the formatting
of the code.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>