summaryrefslogtreecommitdiffstats
path: root/src/drivers/nvs
diff options
context:
space:
mode:
authorMichael Brown2006-12-04 16:36:51 +0100
committerMichael Brown2006-12-04 16:36:51 +0100
commit931f94dca30b04f8303acdcfd08436e61a491a92 (patch)
treeb478b672436d696ce8d0a4d91c804d29a65db6a9 /src/drivers/nvs
parentForce syntax-checking on assertions even in non-asserting builds. (diff)
downloadipxe-931f94dca30b04f8303acdcfd08436e61a491a92.tar.gz
ipxe-931f94dca30b04f8303acdcfd08436e61a491a92.tar.xz
ipxe-931f94dca30b04f8303acdcfd08436e61a491a92.zip
Generalised the SPI abstraction layer to also be able to handle interfaces
that don't provide the full flexibility of a bit-bashing interface. Temporarily hacked rtl8139.c to use the new interface.
Diffstat (limited to 'src/drivers/nvs')
-rw-r--r--src/drivers/nvs/threewire.c39
1 files changed, 15 insertions, 24 deletions
diff --git a/src/drivers/nvs/threewire.c b/src/drivers/nvs/threewire.c
index 92f9a24b..fd360037 100644
--- a/src/drivers/nvs/threewire.c
+++ b/src/drivers/nvs/threewire.c
@@ -17,8 +17,7 @@
*/
#include <stddef.h>
-#include <byteswap.h>
-#include <gpxe/spi.h>
+#include <assert.h>
#include <gpxe/threewire.h>
/** @file
@@ -27,31 +26,23 @@
*
*/
-/**
- * Read from a three-wire device
+/** Read data from three-wire device
*
- * @v three Three-wire device
- * @v address Address
- * @ret data Data
+ * @v device SPI device
+ * @v address Address from which to read
+ * @v data Data buffer
+ * @v len Length of data to read, in @b words
+ * @ret rc Return status code
*/
-unsigned long threewire_read ( struct threewire_device *three,
- unsigned long address ) {
- struct spi_interface *spi = three->spi;
- uint32_t data;
+int threewire_read ( struct spi_device *device, unsigned int address,
+ void *data, unsigned int len ) {
+ struct spi_bus *bus = device->bus;
- /* Activate chip select line */
- spi->select_slave ( spi, three->slave );
+ assert ( bus->mode == SPI_MODE_THREEWIRE );
- /* Send command and address */
- data = cpu_to_le32 ( threewire_cmd_read ( three, address ) );
- spi->transfer ( spi, &data, NULL, threewire_cmd_len ( three ) );
-
- /* Read back data */
- data = 0;
- spi->transfer ( spi, NULL, &data, three->datasize );
+ DBG ( "3wire %p reading words [%04x,%04x)\n", device,
+ address, ( address + len ) );
- /* Deactivate chip select line */
- spi->deselect_slave ( spi );
-
- return le32_to_cpu ( data );;
+ return bus->rw ( bus, device, THREEWIRE_READ, address,
+ NULL, data, len );
}