summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJagan Teki <jagan@amarulasolutions.com>2019-07-22 17:22:56 +0530
committerJagan Teki <jagan@amarulasolutions.com>2019-09-16 08:09:22 +0530
commit8473b32127232d8b602d905a2ed26ed48d352f6e (patch)
tree82042e052a45f86951a769e161eb0eac6a6671fa /include
parent6bd6c21693547f1887b516bee11481e95e239ecb (diff)
spi: Add spi_write_then_read
Add support for SPI synchronous write followed by read, this is common interface call from spi-nor to spi drivers. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> Tested-by: Adam Ford <aford173@gmail.com> #da850-evm
Diffstat (limited to 'include')
-rw-r--r--include/spi.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/spi.h b/include/spi.h
index 378594163b..5eec0c4775 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -248,6 +248,26 @@ int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen);
int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
void *din, unsigned long flags);
+/**
+ * spi_write_then_read - SPI synchronous write followed by read
+ *
+ * This performs a half duplex transaction in which the first transaction
+ * is to send the opcode and if the length of buf is non-zero then it start
+ * the second transaction as tx or rx based on the need from respective slave.
+ *
+ * @slave: The SPI slave device with which opcode/data will be exchanged
+ * @opcode: opcode used for specific transfer
+ * @n_opcode: size of opcode, in bytes
+ * @txbuf: buffer into which data to be written
+ * @rxbuf: buffer into which data will be read
+ * @n_buf: size of buf (whether it's [tx|rx]buf), in bytes
+ *
+ * Returns: 0 on success, not 0 on failure
+ */
+int spi_write_then_read(struct spi_slave *slave, const u8 *opcode,
+ size_t n_opcode, const u8 *txbuf, u8 *rxbuf,
+ size_t n_buf);
+
/* Copy memory mapped data */
void spi_flash_copy_mmap(void *data, void *offset, size_t len);