1aca1545dSVictor Chong /* 2aca1545dSVictor Chong * Copyright (c) 2016, Linaro Limited 3aca1545dSVictor Chong * All rights reserved. 4aca1545dSVictor Chong * 5aca1545dSVictor Chong * Redistribution and use in source and binary forms, with or without 6aca1545dSVictor Chong * modification, are permitted provided that the following conditions are met: 7aca1545dSVictor Chong * 8aca1545dSVictor Chong * 1. Redistributions of source code must retain the above copyright notice, 9aca1545dSVictor Chong * this list of conditions and the following disclaimer. 10aca1545dSVictor Chong * 11aca1545dSVictor Chong * 2. Redistributions in binary form must reproduce the above copyright notice, 12aca1545dSVictor Chong * this list of conditions and the following disclaimer in the documentation 13aca1545dSVictor Chong * and/or other materials provided with the distribution. 14aca1545dSVictor Chong * 15aca1545dSVictor Chong * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16aca1545dSVictor Chong * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17aca1545dSVictor Chong * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18aca1545dSVictor Chong * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19aca1545dSVictor Chong * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20aca1545dSVictor Chong * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21aca1545dSVictor Chong * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22aca1545dSVictor Chong * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23aca1545dSVictor Chong * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24aca1545dSVictor Chong * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25aca1545dSVictor Chong * POSSIBILITY OF SUCH DAMAGE. 26aca1545dSVictor Chong */ 27aca1545dSVictor Chong 28aca1545dSVictor Chong #ifndef __SPI_H__ 29aca1545dSVictor Chong #define __SPI_H__ 30aca1545dSVictor Chong 31aca1545dSVictor Chong #include <types_ext.h> 32aca1545dSVictor Chong 33aca1545dSVictor Chong enum spi_mode { 34aca1545dSVictor Chong SPI_MODE0, 35aca1545dSVictor Chong SPI_MODE1, 36aca1545dSVictor Chong SPI_MODE2, 37aca1545dSVictor Chong SPI_MODE3 38aca1545dSVictor Chong }; 39aca1545dSVictor Chong 40*9a2efe04SVictor Chong enum spi_result { 41*9a2efe04SVictor Chong SPI_OK, 42*9a2efe04SVictor Chong SPI_ERR_CFG, 43*9a2efe04SVictor Chong SPI_ERR_PKTCNT, 44*9a2efe04SVictor Chong SPI_ERR_GENERIC 45*9a2efe04SVictor Chong }; 46*9a2efe04SVictor Chong 47aca1545dSVictor Chong struct spi_chip { 48aca1545dSVictor Chong const struct spi_ops *ops; 49aca1545dSVictor Chong }; 50aca1545dSVictor Chong 51aca1545dSVictor Chong struct spi_ops { 52*9a2efe04SVictor Chong enum spi_result (*txrx8)(struct spi_chip *chip, uint8_t *wdat, 53*9a2efe04SVictor Chong uint8_t *rdat, size_t num_pkts); 54*9a2efe04SVictor Chong enum spi_result (*txrx16)(struct spi_chip *chip, uint16_t *wdat, 55*9a2efe04SVictor Chong uint16_t *rdat, size_t num_pkts); 56aca1545dSVictor Chong }; 57aca1545dSVictor Chong 58aca1545dSVictor Chong #endif /* __SPI_H__ */ 59aca1545dSVictor Chong 60