linux-loongson/include/linux/spi/offload/consumer.h
David Lechner 700a281905
spi: add offload TX/RX streaming APIs
Most configuration of SPI offloads is handled opaquely using the offload
pointer that is passed to the various offload functions. However, there
are some offload features that need to be controlled on a per transfer
basis.

This patch adds a flag field to struct spi_transfer to allow specifying
such features. The first feature to be added is the ability to stream
data to/from a hardware sink/source rather than using a tx or rx buffer.
Additional flags can be added in the future as needed.

A flags field is also added to the offload struct for providers to
indicate which flags are supported. This allows for generic checking of
offload capabilities during __spi_validate() so that each offload
provider doesn't have to implement their own validation.

As a first users of this streaming capability, getter functions are
added to get a DMA channel that is directly connected to the offload.
Peripheral drivers will use this to get a DMA channel and configure it
to suit their needs.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250207-dlech-mainline-spi-engine-offload-2-v8-5-e48a489be48c@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2025-02-07 20:17:11 +00:00

40 lines
1.3 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2024 Analog Devices Inc.
* Copyright (C) 2024 BayLibre, SAS
*/
#ifndef __LINUX_SPI_OFFLOAD_CONSUMER_H
#define __LINUX_SPI_OFFLOAD_CONSUMER_H
#include <linux/module.h>
#include <linux/spi/offload/types.h>
#include <linux/types.h>
MODULE_IMPORT_NS("SPI_OFFLOAD");
struct device;
struct spi_device;
struct spi_offload *devm_spi_offload_get(struct device *dev, struct spi_device *spi,
const struct spi_offload_config *config);
struct spi_offload_trigger
*devm_spi_offload_trigger_get(struct device *dev,
struct spi_offload *offload,
enum spi_offload_trigger_type type);
int spi_offload_trigger_validate(struct spi_offload_trigger *trigger,
struct spi_offload_trigger_config *config);
int spi_offload_trigger_enable(struct spi_offload *offload,
struct spi_offload_trigger *trigger,
struct spi_offload_trigger_config *config);
void spi_offload_trigger_disable(struct spi_offload *offload,
struct spi_offload_trigger *trigger);
struct dma_chan *devm_spi_offload_tx_stream_request_dma_chan(struct device *dev,
struct spi_offload *offload);
struct dma_chan *devm_spi_offload_rx_stream_request_dma_chan(struct device *dev,
struct spi_offload *offload);
#endif /* __LINUX_SPI_OFFLOAD_CONSUMER_H */