summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2021-06-18 11:27:23 -0700
committerCommit Bot <commit-bot@chromium.org>2021-06-29 18:58:37 +0000
commite2655cb43fdc938d467018ccd5c3df9fb907c400 (patch)
tree51d4f02fa4d520e35c040136b3f49fc93cc67a36 /include
parentc6b0971daa407213edc1f8ccc48a49994036c4d5 (diff)
downloadchrome-ec-e2655cb43fdc938d467018ccd5c3df9fb907c400.tar.gz
g: spi_controller: add the subtransaction capability
It is necessary to be able to send SPI transactions with sizes exceeding the SPI controller buffer size. This can be achieved by asserting CS before sending the first batch (data block) in a transaction and deasserting CS after the last batch. Let's add a SPI controller spi_sub_transaction() API, with an additional parameter indicating when the last batch is submitted for processing. The existing spi_transaction() API becomes a wrapper which always calls spi_sub_transaction() to send a full single batch transaction. BUG=b:79492818 TEST='flashrom --flash-name' still succeeds. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: Ia0c5114edd5caf6c6d0e22cab3bfa3c4d86ac79a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2977964 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/spi.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/spi.h b/include/spi.h
index 10286accab..b06f266d0c 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -85,6 +85,29 @@ int spi_transaction(const struct spi_device_t *spi_device,
const uint8_t *txdata, int txlen,
uint8_t *rxdata, int rxlen);
+/* Issue a part of SPI transaction. Assumes SPI port has already been enabled.
+ *
+ * If CS is not asserted, asserts it first.
+ * Transmits <txlen> bytes from <txdata>, throwing away the corresponding
+ * received data, then transmits <rxlen> unused bytes, saving the received data
+ * in <rxdata>.
+ * If SPI_READBACK_ALL is set in <rxlen>, the received data during transmission
+ * is recorded in rxdata buffer and it assumes that the real <rxlen> is equal
+ * to <txlen>.
+ * If 'final' is true, deasserts CS once transfer is completed.
+ *
+ * @param spi_device the SPI device to use
+ * @param txdata buffer to transmit
+ * @param txlen number of bytes in txdata.
+ * @param rxdata receive buffer.
+ * @param rxlen number of bytes in rxdata or SPI_READBACK_ALL.
+ * @param deassert_cs flag indicating that CS needs to be deasserted in the
+ * end of this sub transaction.
+ */
+int spi_sub_transaction(const struct spi_device_t *spi_device,
+ const uint8_t *txdata, int txlen, uint8_t *rxdata,
+ int rxlen, bool deassert_cs);
+
/* Similar to spi_transaction(), but hands over to DMA for reading response.
* Must call spi_transaction_flush() after this to make sure the response is
* received.