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>
diff --git a/src/include/spi-generic.h b/src/include/spi-generic.h
index b7a14f9..6c62de6 100644
--- a/src/include/spi-generic.h
+++ b/src/include/spi-generic.h
@@ -120,27 +120,17 @@
 /*-----------------------------------------------------------------------
  * 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 @@
 	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];
 }