summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2014-03-27 21:52:43 -0700
committerKyösti Mälkki <kyosti.malkki@gmail.com>2014-07-05 11:36:20 +0200
commit93d9f92cfbb214718e211aee71ac869c77f725ee (patch)
tree5ce61557bc84bd374744ba4ca07a8a48825ae58a /src/include
parent1e187356e831583830a22cf051c792470d0440f5 (diff)
spi: Change spi_xfer to work in units of bytes instead of bits.
Whenever spi_xfer is called and whenver it's implemented, the natural unit for the amount of data being transfered is bytes. The API expected things to be expressed in bits, however, which led to a lot of multiplying and dividing by eight, and checkes to make sure things were multiples of eight. All of that can now be removed. BUG=None TEST=Built and booted on link, falco, peach_pit and nyan and looked for SPI errors in the firmware log. Built for rambi. BRANCH=None Change-Id: I02365bdb6960a35def7be7a0cd1aa0a2cc09392f Signed-off-by: Gabe Black <gabeblack@google.com> Reviewed-on: https://chromium-review.googlesource.com/192049 Reviewed-by: Gabe Black <gabeblack@chromium.org> Tested-by: Gabe Black <gabeblack@chromium.org> Commit-Queue: Gabe Black <gabeblack@chromium.org> [km: cherry-pick from chromium] Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/6175 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com> Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/spi-generic.h24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/include/spi-generic.h b/src/include/spi-generic.h
index b7a14f9342..6c62de6d1d 100644
--- a/src/include/spi-generic.h
+++ b/src/include/spi-generic.h
@@ -120,27 +120,17 @@ void spi_release_bus(struct spi_slave *slave);
/*-----------------------------------------------------------------------
* SPI transfer
*
- * This writes "bitlen" bits out the SPI MOSI port and simultaneously clocks
- * "bitlen" bits in the SPI MISO port. That's just the way SPI works.
- *
- * The source of the outgoing bits is the "dout" parameter and the
- * destination of the input bits is the "din" parameter. Note that "dout"
- * and "din" can point to the same memory location, in which case the
- * input data overwrites the output data (since both are buffered by
- * temporary variables, this is OK).
- *
* spi_xfer() interface:
* slave: The SPI slave which will be sending/receiving the data.
- * dout: Pointer to a string of bits to send out. The bits are
- * held in a byte array and are sent MSB first.
- * bitsout: How many bits to write.
- * din: Pointer to a string of bits that will be filled in.
- * bitsin: How many bits to read.
+ * dout: Pointer to a string of bytes to send out.
+ * bytesout: How many bytes to write.
+ * din: Pointer to a string of bytes that will be filled in.
+ * bytesin: How many bytes to read.
*
* Returns: 0 on success, not 0 on failure
*/
-int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bitsout,
- void *din, unsigned int bitsin);
+int spi_xfer(struct spi_slave *slave, const void *dout, unsigned int bytesout,
+ void *din, unsigned int bytesin);
/*-----------------------------------------------------------------------
* Determine if a SPI chipselect is valid.
@@ -196,7 +186,7 @@ static inline int spi_w8r8(struct spi_slave *slave, unsigned char byte)
dout[0] = byte;
dout[1] = 0;
- ret = spi_xfer(slave, dout, 16, din, 16);
+ ret = spi_xfer(slave, dout, 2, din, 2);
return ret < 0 ? ret : din[1];
}