1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2016, Linaro Limited
4  */
5 
6 #ifndef __SPI_H__
7 #define __SPI_H__
8 
9 #include <types_ext.h>
10 
11 enum spi_mode {
12 	SPI_MODE0,
13 	SPI_MODE1,
14 	SPI_MODE2,
15 	SPI_MODE3
16 };
17 
18 enum spi_result {
19 	SPI_OK,
20 	SPI_ERR_CFG,
21 	SPI_ERR_PKTCNT,
22 	SPI_ERR_GENERIC
23 };
24 
25 struct spi_chip {
26 	const struct spi_ops *ops;
27 };
28 
29 struct spi_ops {
30 	void (*configure)(struct spi_chip *chip);
31 	void (*start)(struct spi_chip *chip);
32 	enum spi_result (*txrx8)(struct spi_chip *chip, uint8_t *wdat,
33 		uint8_t *rdat, size_t num_pkts);
34 	enum spi_result (*txrx16)(struct spi_chip *chip, uint16_t *wdat,
35 		uint16_t *rdat, size_t num_pkts);
36 	void (*end)(struct spi_chip *chip);
37 	void (*flushfifo)(struct spi_chip *chip);
38 };
39 
40 #endif	/* __SPI_H__ */
41 
42