chromeec: allow transport implementation to provide buffers for proto v3
Depending on the transport mechanism for proto v3 different bytes need to be send and/or read before the request and response. Depending on the software and/or controller interface that requirement leads to needing to copy data into temporary buffers. Avoid this by allowing the transport mechanism to provide the request and response buffers. BUG=chrome-os-partner:31148 BRANCH=None TEST=Built for rush and ryu. Ran on ryu with i2c implementation. Also built for rambi to check x86 systems. Change-Id: I35d4d69bd1fa900fc0cfe3822496f381405bdcb1 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: c7224426e1d0bcf06ed010131a2462a6ca201d8b Original-Change-Id: Iad6cce566a253ca72e6f5009a97235ece0a6c1b5 Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/211138 Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: http://review.coreboot.org/8827 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
committed by
Patrick Georgi
parent
3e49738baa
commit
828272767d
@@ -25,15 +25,32 @@
|
||||
|
||||
static const uint8_t EcFramingByte = 0xec;
|
||||
|
||||
static int crosec_spi_io(uint8_t *write_bytes, size_t write_size,
|
||||
uint8_t *read_bytes, size_t read_size,
|
||||
void *context)
|
||||
#define PROTO3_MAX_PACKET_SIZE 268
|
||||
|
||||
static uint8_t req_buf[PROTO3_MAX_PACKET_SIZE];
|
||||
static uint8_t resp_buf[PROTO3_MAX_PACKET_SIZE];
|
||||
|
||||
void *crosec_get_buffer(size_t size, int req)
|
||||
{
|
||||
if (size > PROTO3_MAX_PACKET_SIZE) {
|
||||
printk(BIOS_DEBUG, "Proto v3 buffer request too large: %zu!\n",
|
||||
size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (req)
|
||||
return req_buf;
|
||||
else
|
||||
return resp_buf;
|
||||
}
|
||||
|
||||
static int crosec_spi_io(size_t req_size, size_t resp_size, void *context)
|
||||
{
|
||||
struct spi_slave *slave = (struct spi_slave *)context;
|
||||
|
||||
spi_claim_bus(slave);
|
||||
|
||||
if (spi_xfer(slave, write_bytes, write_size, NULL, 0)) {
|
||||
if (spi_xfer(slave, req_buf, req_size, NULL, 0)) {
|
||||
printk(BIOS_ERR, "%s: Failed to send request.\n", __func__);
|
||||
spi_release_bus(slave);
|
||||
return -1;
|
||||
@@ -64,7 +81,7 @@ static int crosec_spi_io(uint8_t *write_bytes, size_t write_size,
|
||||
}
|
||||
}
|
||||
|
||||
if (spi_xfer(slave, NULL, 0, read_bytes, read_size)) {
|
||||
if (spi_xfer(slave, NULL, 0, resp_buf, resp_size)) {
|
||||
printk(BIOS_ERR, "%s: Failed to receive response.\n", __func__);
|
||||
spi_release_bus(slave);
|
||||
return -1;
|
||||
|
Reference in New Issue
Block a user