From 931f94dca30b04f8303acdcfd08436e61a491a92 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 4 Dec 2006 15:36:51 +0000 Subject: 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. --- src/drivers/nvs/threewire.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) (limited to 'src/drivers/nvs') diff --git a/src/drivers/nvs/threewire.c b/src/drivers/nvs/threewire.c index 92f9a24b7..fd360037a 100644 --- a/src/drivers/nvs/threewire.c +++ b/src/drivers/nvs/threewire.c @@ -17,8 +17,7 @@ */ #include -#include -#include +#include #include /** @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 ); } -- cgit v1.2.3-55-g7522