diff options
author | Gabe Black <gabeblack@google.com> | 2014-03-21 21:32:12 -0700 |
---|---|---|
committer | Marc Jones <marc.jones@se-eng.com> | 2014-12-09 20:32:06 +0100 |
commit | 967058f807418dc964ca04849b59c3b2a03dbee5 (patch) | |
tree | db501e751f3d6d75e17f796c07ec39ba9d094995 /src/soc/nvidia | |
parent | 30974bc2f5f4764425e69256782cca03b290c4f4 (diff) | |
download | coreboot-967058f807418dc964ca04849b59c3b2a03dbee5.tar.xz |
spi: Factor EC protocol details out of the SPI drivers.
The SPI drivers for tegra and exynos5420 have code in them which waits for a
frame header and leaves filler data out. The SPI driver shouldn't have support
for frame headers directly. If a device uses them, it should support them
itself. That makes the SPI drivers simpler and easier to write.
When moving the frame handling logic into the EC support code, EC communication
continued to work on tegra but no longer worked on exynos5420. That suggested
the SPI driver on the 5420 wasn't working correctly, so I replaced that with
the implementation in depthcharge. Unfortunately that implementation doesn't
support waiting for a frame header for the EC, so these changes are combined
into one.
BUG=None
TEST=Built and booted on pit. Built and booted on nyan. In both cases,
verified that there were no error messages from the SPI drivers or the EC
code.
BRANCH=None
Original-Change-Id: I62a68820c632f154acece94f54276ddcd1442c09
Original-Signed-off-by: Gabe Black <gabeblack@google.com>
Original-Reviewed-on: https://chromium-review.googlesource.com/191192
Original-Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Original-Commit-Queue: Gabe Black <gabeblack@chromium.org>
Original-Tested-by: Gabe Black <gabeblack@chromium.org>
(cherry picked from commit 4fcfed280ad70f14a013d5353aa0bee0af540630)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Change-Id: Id8824523abc7afcbc214845901628833e135d142
Reviewed-on: http://review.coreboot.org/7706
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <gaumless@gmail.com>
Diffstat (limited to 'src/soc/nvidia')
-rw-r--r-- | src/soc/nvidia/tegra124/spi.c | 41 | ||||
-rw-r--r-- | src/soc/nvidia/tegra124/spi.h | 3 |
2 files changed, 5 insertions, 39 deletions
diff --git a/src/soc/nvidia/tegra124/spi.c b/src/soc/nvidia/tegra124/spi.c index ae8a9a7626..7ad771633c 100644 --- a/src/soc/nvidia/tegra124/spi.c +++ b/src/soc/nvidia/tegra124/spi.c @@ -23,6 +23,7 @@ #include <cbfs_core.h> #include <inttypes.h> #include <spi-generic.h> +#include <spi_flash.h> #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -722,16 +723,11 @@ int spi_xfer(struct spi_slave *slave, const void *dout, u8 *out_buf = (u8 *)dout; u8 *in_buf = (u8 *)din; unsigned int todo; - int ret = 0, frame_started = 1; + int ret = 0; /* tegra bus numbers start at 1 */ ASSERT(slave->bus >= 1 && slave->bus <= ARRAY_SIZE(tegra_spi_channels)); - if (spi->rx_frame_header_enable) { - memset(in_buf, ~spi->frame_header, in_bytes); - frame_started = 0; - } - while (out_bytes || in_bytes) { int x = 0; @@ -779,41 +775,14 @@ int spi_xfer(struct spi_slave *slave, const void *dout, break; } - /* - * Post-processing. For output, we only need to increment - * the buffer and decrement the counter. Same for input if - * there is no frame header to be concerned with. - * - * If a frame header is used and is found, the input buffer - * is shifted so that the header starts at offset 0, and - * in_bytes and in_buf are incremented/decremented according - * to the offset where the header was originally found. - */ + /* Post-processing. */ if (out_bytes) { out_bytes -= x; out_buf += x; } if (in_bytes) { - if (spi->rx_frame_header_enable && !frame_started) { - int i; - - for (i = 0; i < x; i++) { - if (in_buf[i] == spi->frame_header) { - frame_started = 1; - i++; /* discard frame header */ - break; - } - } - - if (frame_started) { - memmove(&in_buf[0], &in_buf[i], x - i); - in_bytes -= x - i; - in_buf += x - i; - } - } else { - in_bytes -= x; - in_buf += x; - } + in_bytes -= x; + in_buf += x; } } diff --git a/src/soc/nvidia/tegra124/spi.h b/src/soc/nvidia/tegra124/spi.h index 857c35f1b9..11e88feec5 100644 --- a/src/soc/nvidia/tegra124/spi.h +++ b/src/soc/nvidia/tegra124/spi.h @@ -54,9 +54,6 @@ struct tegra_spi_channel { struct spi_slave slave; unsigned int req_sel; - /* stuff that is specific to the attached device */ - int rx_frame_header_enable; - u8 frame_header; int dual_mode; /* for x2 transfers with bit interleaving */ /* context (used internally) */ |