mirror of
https://github.com/ipxe/ipxe
synced 2025-12-23 13:30:57 +03:00
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.
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user