Linux Audio

Check our new training course

Loading...
v6.8
 1/* SPDX-License-Identifier: GPL-2.0+ */
 2/*
 3 * Copyright (C) 2018 Exceet Electronics GmbH
 4 * Copyright (C) 2018 Bootlin
 5 *
 6 * Author: Boris Brezillon <boris.brezillon@bootlin.com>
 7 *
 8 * Helpers needed by the spi or spi-mem logic. Should not be used outside of
 9 * spi-mem.c and spi.c.
10 */
11
12#ifndef __LINUX_SPI_INTERNALS_H
13#define __LINUX_SPI_INTERNALS_H
14
15#include <linux/device.h>
16#include <linux/dma-direction.h>
17#include <linux/scatterlist.h>
18#include <linux/spi/spi.h>
19
20void spi_flush_queue(struct spi_controller *ctrl);
21
22#ifdef CONFIG_HAS_DMA
23int spi_map_buf(struct spi_controller *ctlr, struct device *dev,
24		struct sg_table *sgt, void *buf, size_t len,
25		enum dma_data_direction dir);
26void spi_unmap_buf(struct spi_controller *ctlr, struct device *dev,
27		   struct sg_table *sgt, enum dma_data_direction dir);
28#else /* !CONFIG_HAS_DMA */
29static inline int spi_map_buf(struct spi_controller *ctlr, struct device *dev,
30			      struct sg_table *sgt, void *buf, size_t len,
31			      enum dma_data_direction dir)
32{
33	return -EINVAL;
34}
35
36static inline void spi_unmap_buf(struct spi_controller *ctlr,
37				 struct device *dev, struct sg_table *sgt,
38				 enum dma_data_direction dir)
39{
40}
41#endif /* CONFIG_HAS_DMA */
42
 
 
 
 
 
 
 
 
43#endif /* __LINUX_SPI_INTERNALS_H */
v6.13.7
 1/* SPDX-License-Identifier: GPL-2.0+ */
 2/*
 3 * Copyright (C) 2018 Exceet Electronics GmbH
 4 * Copyright (C) 2018 Bootlin
 5 *
 6 * Author: Boris Brezillon <boris.brezillon@bootlin.com>
 7 *
 8 * Helpers needed by the spi or spi-mem logic. Should not be used outside of
 9 * spi-mem.c and spi.c.
10 */
11
12#ifndef __LINUX_SPI_INTERNALS_H
13#define __LINUX_SPI_INTERNALS_H
14
15#include <linux/device.h>
16#include <linux/dma-direction.h>
17#include <linux/scatterlist.h>
18#include <linux/spi/spi.h>
19
20void spi_flush_queue(struct spi_controller *ctrl);
21
22#ifdef CONFIG_HAS_DMA
23int spi_map_buf(struct spi_controller *ctlr, struct device *dev,
24		struct sg_table *sgt, void *buf, size_t len,
25		enum dma_data_direction dir);
26void spi_unmap_buf(struct spi_controller *ctlr, struct device *dev,
27		   struct sg_table *sgt, enum dma_data_direction dir);
28#else /* !CONFIG_HAS_DMA */
29static inline int spi_map_buf(struct spi_controller *ctlr, struct device *dev,
30			      struct sg_table *sgt, void *buf, size_t len,
31			      enum dma_data_direction dir)
32{
33	return -EINVAL;
34}
35
36static inline void spi_unmap_buf(struct spi_controller *ctlr,
37				 struct device *dev, struct sg_table *sgt,
38				 enum dma_data_direction dir)
39{
40}
41#endif /* CONFIG_HAS_DMA */
42
43static inline bool spi_xfer_is_dma_mapped(struct spi_controller *ctlr,
44					  struct spi_device *spi,
45					  struct spi_transfer *xfer)
46{
47	return ctlr->can_dma && ctlr->can_dma(ctlr, spi, xfer) &&
48	       (xfer->tx_sg_mapped || xfer->rx_sg_mapped);
49}
50
51#endif /* __LINUX_SPI_INTERNALS_H */