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>
It will unlock and unhold the CS line. Note that the lock and the CS
being hold on are 2 separate config bits, so if only one is selected
spi_release() will only apply on this configuration.
Note: this has been already the case in the controller drivers, where
there implementation of spi_release() calls
spi_context_unlock_unconditionally(). And that function always forces
the CS line to an inactive state.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
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>
Use the standard `struct gpio_dt_spec` type in the chip select control.
The anonymous struct and union allows previous instantiations to
continue working while letting functions operate on the new type.
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>
Update doxygen usage of `@retval` to specify the value for each case,
instead of a chain of logic from the one `@retval`.
https://www.doxygen.nl/manual/commands.html#cmdretval
Convert `@retval`'s that simply reference another function to `@return`.
Convert some custom notes to `@note`.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Add helper functions to simplify the usage of `struct spi_dt_spec`.
Implements helpers for the standard synchronous calls (transceive, read,
write).
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Introduces the `struct spi_dt_spec` type, which contains the complete
SPI bus information derived from devicetree. It serves the same purpose
as `struct gpio_dt_spec` in that it can be constructed automatically in
`DEVICE_DT_INST_DEFINE` macros and provided as a single handle to SPI
API calls. Includes a single function, `spi_is_ready` that validates all
SPI bus dependencies are ready.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Similar to Sphinx, @kconfig{} alias should be used in Doxygen docstring
in order to reference a Kconfig option. @option{} is still kept for
compatibility reasons.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Add helper macros for initializing a struct spi_sconfig for a SPI
device which is defined in the devicetree. They are available from C
only due to C++ compatibility issues.
For some fields, like 'frequency', we just get the value from the
standard devicetree property. For others, like the spi_cs_control
structure's 'gpio_dev', we rely on the new DEVICE_DT_GET() macro.
This patch does not change anything for controlling SPI devices that
aren't set up in devicetree. It is entirely a convenience for driver
and application code that relies on DT.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
When the async API is not enabled produce a build-time error rather
than a runtime error. Also document the dependence on the option.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
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>
Most if not all drivers use an internal function
spi_context_configured() to bypass reconfiguring the SPI peripheral
when nothing has changed. That function determines change based on
comparing the struct spi_config pointer that was last used. This does
not work if a user changes fields within the pointed-to structure.
Document that pointer comparison may be used to detect changes.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
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>
This change removes the hardcoded subsystem list in gen_kobject_list.py
favor of marking the relevant driver API structs with the _subsystem
sentinel.
Signed-off-by: Corey Wharton <coreyw7@fb.com>
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>