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