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