File Index
Files and directories
Sign in
FILE

types.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/spi/offload/types.h C
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * Copyright (C) 2024 Analog Devices Inc.
  4 * Copyright (C) 2024 BayLibre, SAS
  5 */
  6
  7#ifndef __LINUX_SPI_OFFLOAD_TYPES_H
  8#define __LINUX_SPI_OFFLOAD_TYPES_H
  9
 10#include <linux/bits.h>
 11#include <linux/types.h>
 12
 13struct device;
 14
 15/* This is write xfer but TX uses external data stream rather than tx_buf. */
 16#define SPI_OFFLOAD_XFER_TX_STREAM	BIT(0)
 17/* This is read xfer but RX uses external data stream rather than rx_buf. */
 18#define SPI_OFFLOAD_XFER_RX_STREAM	BIT(1)
 19
 20/* Offload can be triggered by external hardware event. */
 21#define SPI_OFFLOAD_CAP_TRIGGER			BIT(0)
 22/* Offload can record and then play back TX data when triggered. */
 23#define SPI_OFFLOAD_CAP_TX_STATIC_DATA		BIT(1)
 24/* Offload can get TX data from an external stream source. */
 25#define SPI_OFFLOAD_CAP_TX_STREAM_DMA		BIT(2)
 26/* Offload can send RX data to an external stream sink. */
 27#define SPI_OFFLOAD_CAP_RX_STREAM_DMA		BIT(3)
 28
 29/**
 30 * struct spi_offload_config - offload configuration
 31 *
 32 * This is used to request an offload with specific configuration.
 33 */
 34struct spi_offload_config {
 35	/** @capability_flags: required capabilities. See %SPI_OFFLOAD_CAP_* */
 36	u32 capability_flags;
 37};
 38
 39/**
 40 * struct spi_offload - offload instance
 41 */
 42struct spi_offload {
 43	/** @provider_dev: for get/put reference counting */
 44	struct device *provider_dev;
 45	/** @priv: provider driver private data */
 46	void *priv;
 47	/** @ops: callbacks for offload support */
 48	const struct spi_offload_ops *ops;
 49	/** @xfer_flags: %SPI_OFFLOAD_XFER_* flags supported by provider */
 50	u32 xfer_flags;
 51};
 52
 53enum spi_offload_trigger_type {
 54	/* Indication from SPI peripheral that data is read to read. */
 55	SPI_OFFLOAD_TRIGGER_DATA_READY,
 56	/* Trigger comes from a periodic source such as a clock. */
 57	SPI_OFFLOAD_TRIGGER_PERIODIC,
 58};
 59
 60/**
 61 * spi_offload_trigger_periodic - configuration parameters for periodic triggers
 62 * @frequency_hz: The rate that the trigger should fire in Hz.
 63 * @offset_ns: A delay in nanoseconds between when this trigger fires
 64 *	       compared to another trigger. This requires specialized hardware
 65 *	       that supports such synchronization with a delay between two or
 66 *	       more triggers. Set to 0 when not needed.
 67 */
 68struct spi_offload_trigger_periodic {
 69	u64 frequency_hz;
 70	u64 offset_ns;
 71};
 72
 73struct spi_offload_trigger_config {
 74	/** @type: type discriminator for union */
 75	enum spi_offload_trigger_type type;
 76	union {
 77		struct spi_offload_trigger_periodic periodic;
 78	};
 79};
 80
 81/**
 82 * struct spi_offload_ops - callbacks implemented by offload providers
 83 */
 84struct spi_offload_ops {
 85	/**
 86	 * @trigger_enable: Optional callback to enable the trigger for the
 87	 * given offload instance.
 88	 */
 89	int (*trigger_enable)(struct spi_offload *offload);
 90	/**
 91	 * @trigger_disable: Optional callback to disable the trigger for the
 92	 * given offload instance.
 93	 */
 94	void (*trigger_disable)(struct spi_offload *offload);
 95	/**
 96	 * @tx_stream_request_dma_chan: Optional callback for controllers that
 97	 * have an offload where the TX data stream is connected directly to a
 98	 * DMA channel.
 99	 */
100	struct dma_chan *(*tx_stream_request_dma_chan)(struct spi_offload *offload);
101	/**
102	 * @rx_stream_request_dma_chan: Optional callback for controllers that
103	 * have an offload where the RX data stream is connected directly to a
104	 * DMA channel.
105	 */
106	struct dma_chan *(*rx_stream_request_dma_chan)(struct spi_offload *offload);
107};
108
109#endif /* __LINUX_SPI_OFFLOAD_TYPES_H */
~/ Read-only file preview.