Commit graph

31 commits

Author SHA1 Message Date
Bartosz Bilas 2c08e9698d drivers: spi: remove deprecated functions
`spi_transceive_async`, `spi_read_async` and `spi_write_async`
are deprecated since v3.2.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2024-06-06 15:19:29 -05:00
Yong Cong Sin bbe5e1e6eb build: namespace the generated headers with zephyr/
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.

Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.

Updated the includes path of in-tree sources accordingly.

Most of the changes here are scripted, check the PR for more
info.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 22:03:55 +02:00
Bartosz Bilas 7046c9030e drivers: spi: remove deprecated spi_is_ready function
`spi_is_ready` is depreceted since v3.3 so let's remove it.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2024-05-18 12:20:05 -04:00
Ederson de Souza 28d08ada28 include/zephyr: Add 'version' and 'since' tag to groups
Based on information from doc/develop/api/overview.rst, add current
version for some groups representing APIs, following the following
table:

  - Experimental:   0.1.0
  - Unstable:       0.8.0
  - Stable:         1.0.0

Also based on doc/develop/api/overview.rst, add 'since' tag to the
groups.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-03-19 13:13:45 +01:00
Krzysztof Chruściński 8bc61e2b51 drivers: spi: Add missing retval to spi_read calls
spi_transceive returns number of received frames for slave mode.
This information was missing for spi_read type of functions.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-02-01 10:23:44 -06:00
Benjamin Cabé e4993fcc5b drivers: spi: doc: Doxygen cleanup
- Fixed a few improperly formatted struct
- Marked some mask definitions as internal when macros abstracting them
 out already exist
- Fixed a few code blocks to add proper syntax highlightingy

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-11-27 12:17:26 +00:00
Ali Hozhabri e2c0cb979f include: zephyr: drivers: modify SPI_CONFIG_DT to add CPOL, CPHA, HOLD_CS
Modify SPI_CONFIG_DT macro to config SPI clock polarity (CPOL),
clock phase (CPHA), and hold-cs.

Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
2023-10-25 18:30:28 -07:00
Tom Burdick cbc6af0d09 spi: Cleanup and fix SPI docs build
Use the defined(__DOXYGEN__) more specifically in the header to better
match i2c.h and make things more explicit. Removes the define being
setup in zephyr.doxyfile.in.

Fixes some of the deprecation notes and what to look for instead. Fixes
some typos.

The async, signal, and rtio APIs for SPI are now shown in the built docs
as would be expected.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-09-19 08:46:16 -05:00
Nick Ward 2d65acca3a drivers: gpio: use gpio_is_ready_dt helper function
Update `struct gpio_dt_spec` use with gpio_is_ready_dt()

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-08-28 08:48:35 -05:00
Gerard Marull-Paretas 4c4e2c5213 drivers: spi: fix spi_config structure documentation
`@param` can't be used to document struct fields. Inline each field
documentation and improve it.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-07-13 09:21:45 +02:00
Gerard Marull-Paretas 2c3165d187 drivers: spi: add opaque type to encode SPI operation flags
Since flags can use either 16/32-bit depending on
CONFIG_SPI_EXTENDED_MODES, add a new opaque type that uses the correct
bit-width depending on that option. This allows us to simplify the
structure layout.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-07-13 09:21:45 +02:00
Gerard Marull-Paretas 8ce048b8e1 drivers: spi: fix CS documentation
`spi_cs_control` `cs` field is no longer a pointer, but a struct member.
Clarify it must be zero-initialized if not used. Remove confusing
comment about the need to use `device_is_ready()` on `cs` field,
`spi_is_ready_dt()` is the only thing users need to do.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-07-13 09:21:45 +02:00
Benjamin Cabé e82e5a6513 doc: spi: fix doxygen comment for MISO Lines doc
Update SPI MISO Lines documentation to remove incorrect use of @kconfig.
Fixes #58912.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-06-07 04:41:04 -04:00
Qipeng Zha bc3ea1bb99 drivers: spi: add SPI device statistics
Enable below statistics for SPI by follow Zephyr STATS subsystem,
    rx_bytes, tx_bytes, transfer_error.

and add SPI_DEVICE_DT_DEFINE helper macro to define SPI device.

Signed-off-by: Xiaolu Sun <xiaolu.sun@intel.com>
Signed-off-by: Qipeng Zha <qipeng.zha@intel.com>
2023-05-23 22:15:25 -04:00
guotong ma 2539ac942a drivers: spi: Adapt to new SPI dt-spec macros
The SPI dt-spec macros has been modified to make it compatible with C++.
But there are still a macros that haven't been modified completely.
And the macros are not available.
So I modified them to Adapt the new SPI dt-spec macros.

Signed-off-by: guotong ma <maguotong66@gmail.com>
2023-05-19 09:39:48 +02:00
Tom Burdick e4b10328b4 rtio: Use mpsc for submission and completion queue
Rather than the rings, which weren't shared between userspace and kernel
space in Zephyr like they are in Linux with io_uring, use atomic mpsc
queues for submission and completion queues.

Most importantly this removes a potential head of line blocker in the
submission queue as the sqe would be held until a task is completed.

As additional bonuses this avoids some additional locks and restrictions
about what can be submitted and where. It also removes the need for
two executors as all chains/transactions are done concurrently.

Lastly this opens up the possibility for a common pool of sqe's to
allocate from potentially saving lots of memory.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-05-10 00:39:43 +09:00
Gerard Marull-Paretas 1e0028ae3d drivers: spi: add spi_cs_is_gpio(_dt) helpers
Add spi_cs_is_gpio(_dt) helpers to check whether SPI CS is controlled by
GPIO or not. This both improves code readability and isolates SPI
internals.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-24 21:29:55 +02:00
Gerard Marull-Paretas 3f2c2d4130 drivers: spi: make SPI dt-spec macros compatible with C++
As of today it is not possible to use SPI dt-spec macros in C++,
something known and documented. The main reason is because `cs` property
is initialized using a compound literal, something not supported in C++.
This PR takes another approach, that is to not make `cs` a pointer but a
struct member. This way, we can perform a regular initialization, at the
cost of using extra memory for unused delay/pin/flags if `cs` is not
used.

Fixes #56572

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-24 21:29:55 +02:00
Tom Burdick d9d24b4d65 spi: Add RTIO support to SPI
Provides a macro and submit API for SPI drivers to support RTIO.

A copy function enables compatibility with the existing blocking API
and very easily the existing async API as well.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-04-03 09:51:02 +02:00
Bartosz Bilas acbe0d3264 drivers: spi: deprecate spi_is_ready function
Make `spi_is_ready` function deprecated in favor of `spi_is_ready_dt`.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-12-07 09:40:23 -06:00
Bartosz Bilas 5170c16e5c spi: add spi_is_ready_dt function
Add `spi_is_ready_dt` function that validates SPI DT spec
is ready and it allows the user to pass `spi_dt_spec` directly.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-12-07 09:40:23 -06:00
Gerard Marull-Paretas 6a0f554ffa include: add missing kernel.h include
Some files make use of Kernel APIs without including kernel.h, fix this
problem.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Tom Burdick 4c20403629 spi: callback API for asynchronous transcieve
Adds a new spi_transcieve_cb API which enables asynchronous
SPI transactions with callback notification.

The exist spi_transcieve_async API remains and uses the new
spi_transcieve_cb API to provide a k_poll_signal notifier.

The driver API changes to provide a callback and userdata
parameter to async transcieve. All drivers in the tree
have been updated to the change.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-08-26 09:29:48 -04:00
Gerard Marull-Paretas be21b45522 drivers: spi: fix sample syntax
Upcoming versions of breathe highlight code embedded in Doxygen blocks.
In this case, the Devicetree fragment contained invalid syntax leading
to Sphinx warnings.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-12 11:04:26 +02:00
Kumar Gala f2d4e23d7e spi: Remove anonymous struct from struct spi_cs_control
Simplify spi_cs_control by removing anonymous struct around the
"gpio" field.  Update SPI_CS_CONTROL_PTR_DT to match this change.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-13 09:03:02 -05:00
Kumar Gala 7b6c1b158b spi: Remove deprecated fields from struct spi_cs_control
All in tree users are using the gpio_dt_spec so we can remove the
older gpio struct elements that have been deprecated for some
time.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-13 09:03:02 -05:00
Kumar Gala 29c993fc0f spi: Add SPI_CS_GPIOS_DT_SPEC_INST_GET macro
We didn't have an "INST" verion of SPI_CS_GPIOS_DT_SPEC_GET.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-06-30 19:42:14 +00:00
Gerard Marull-Paretas fb9b3bcd93 include: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all includes within
include directory to the new prefix <zephyr/...>. Note that the
conversion has been scripted, refer to zephyrproject-rtos#45388 for more
details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 20:03:00 +02:00
Bartosz Bilas 536fe6a948 drivers: spi: mark old spi_cs_control fields deprecated
Since gpio_dt_spec is finally available within spi_cs_control
struct, mark the old fields deprecated in order to use
gpio_dt_spec struct.

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>
2022-04-22 09:45:53 +02:00
Yuval Peress 9d58ea8470 include: update references to <device.h>
Use prefix zephyr/ for device.h includes

Issue #41543

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-21 07:40:54 -05:00
Yuval Peress 53ef68d459 include: Prefix includes to use a scope
Move include paths and add new target_include_directories to support
backwards compatibility:
* /include -> /include/zephyr
  example: <irq.h> -> <zephyr/irq.h>

Issue #41543

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-08 19:03:32 +02:00
Renamed from include/drivers/spi.h (Browse further)