summaryrefslogtreecommitdiff
path: root/drivers/misc/cros_ec_spi.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2014-02-27 20:26:10 (GMT)
committerSimon Glass <sjg@chromium.org>2014-03-18 02:05:47 (GMT)
commita60702833150b8f9263a5f1fb9a6b64774cd44f3 (patch)
tree32581d04ab69321f2044c3cefc0f7560b384a65e /drivers/misc/cros_ec_spi.c
parent2d8ede58ca5873f485c7691b1ca1c1bc6aae7212 (diff)
downloadu-boot-a60702833150b8f9263a5f1fb9a6b64774cd44f3.tar.xz
cros_ec: spi: Add support for EC protocol version 3
Protocol version 3 will be attempted first; if the EC doesn't support it, u-boot will fall back to the old protocol version (2). Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Randall Spangler <rspangler@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/misc/cros_ec_spi.c')
-rw-r--r--drivers/misc/cros_ec_spi.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/misc/cros_ec_spi.c b/drivers/misc/cros_ec_spi.c
index ef73782..7df709c 100644
--- a/drivers/misc/cros_ec_spi.c
+++ b/drivers/misc/cros_ec_spi.c
@@ -17,6 +17,30 @@
#include <cros_ec.h>
#include <spi.h>
+int cros_ec_spi_packet(struct cros_ec_dev *dev, int out_bytes, int in_bytes)
+{
+ int rv;
+
+ /* Do the transfer */
+ if (spi_claim_bus(dev->spi)) {
+ debug("%s: Cannot claim SPI bus\n", __func__);
+ return -1;
+ }
+
+ rv = spi_xfer(dev->spi, max(out_bytes, in_bytes) * 8,
+ dev->dout, dev->din,
+ SPI_XFER_BEGIN | SPI_XFER_END);
+
+ spi_release_bus(dev->spi);
+
+ if (rv) {
+ debug("%s: Cannot complete SPI transfer\n", __func__);
+ return -1;
+ }
+
+ return in_bytes;
+}
+
/**
* Send a command to a LPC CROS_EC device and return the reply.
*