xref: /openbmc/linux/drivers/spi/internals.h (revision 842ed298)
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 
20 void spi_flush_queue(struct spi_controller *ctrl);
21 
22 #ifdef CONFIG_HAS_DMA
23 int 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);
26 void 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 */
29 static 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 
36 static 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 */
44