iPXE
|
SPI bit-bashing interface. More...
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <byteswap.h>
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <ipxe/bitbash.h>
#include <ipxe/spi_bit.h>
Go to the source code of this file.
Macros | |
#define | SELECT_SLAVE 0 |
Chip select line will be asserted. More... | |
#define | DESELECT_SLAVE SPI_MODE_SSPOL |
Chip select line will be deasserted. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static void | spi_bit_delay (void) |
Delay between SCLK changes and around SS changes. More... | |
static void | spi_bit_set_slave_select (struct spi_bit_basher *spibit, unsigned int slave, unsigned int state) |
Select/deselect slave. More... | |
static void | spi_bit_transfer (struct spi_bit_basher *spibit, const void *data_out, void *data_in, unsigned int len, int endianness) |
Transfer bits over SPI bit-bashing bus. More... | |
static int | spi_bit_rw (struct spi_bus *bus, struct spi_device *device, unsigned int command, int address, const void *data_out, void *data_in, size_t len) |
Read/write data via SPI bit-bashing bus. More... | |
void | init_spi_bit_basher (struct spi_bit_basher *spibit) |
Initialise SPI bit-bashing interface. More... | |
SPI bit-bashing interface.
Definition in file spi_bit.c.
#define DESELECT_SLAVE SPI_MODE_SSPOL |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Delay between SCLK changes and around SS changes.
Definition at line 43 of file spi_bit.c.
References SPI_BIT_UDELAY, and udelay().
Referenced by spi_bit_set_slave_select(), and spi_bit_transfer().
|
static |
Select/deselect slave.
spibit | SPI bit-bashing interface |
slave | Slave number |
state | Slave select state |
state
must be SELECT_SLAVE
or DESELECT_SLAVE
.
Definition at line 62 of file spi_bit.c.
References spi_bit_basher::basher, spi_bit_basher::bus, DBGC2, spi_bus::mode, slave, spi_bit_delay(), SPI_BIT_SS, SPI_MODE_SSPOL, state, and write_bit().
Referenced by spi_bit_rw().
|
static |
Transfer bits over SPI bit-bashing bus.
bus | SPI bus |
data_out | TX data buffer (or NULL) |
data_in | RX data buffer (or NULL) |
len | Length of transfer (in bits) |
endianness | Endianness of this data transfer |
This issues len
clock cycles on the SPI bus, shifting out data from the data_out
buffer to the MOSI line and shifting in data from the MISO line to the data_in
buffer. If data_out
is NULL, then the data sent will be all zeroes. If data_in
is NULL, then the incoming data will be discarded.
Definition at line 91 of file spi_bit.c.
References spi_bit_basher::basher, bit, bus, spi_bit_basher::bus, DBGC2, DBGCP, len, read_bit(), SPI_BIT_BIG_ENDIAN, spi_bit_delay(), SPI_BIT_MISO, SPI_BIT_MOSI, SPI_BIT_SCLK, SPI_MODE_CPHA, SPI_MODE_CPOL, step(), and write_bit().
Referenced by spi_bit_rw().
|
static |
Read/write data via SPI bit-bashing bus.
bus | SPI bus |
device | SPI device |
command | Command |
address | Address to read/write (<0 for no address) |
data_out | TX data buffer (or NULL) |
data_in | RX data buffer (or NULL) |
len | Length of transfer |
rc | Return status code |
Definition at line 161 of file spi_bit.c.
References address, assert(), spi_bit_basher::basher, bus, close_bit(), container_of, cpu_to_le32, DBGC, DESELECT_SLAVE, spi_bit_basher::endianness, le32_to_cpu, len, NULL, open_bit(), SELECT_SLAVE, SPI_AUTODETECT_ADDRESS_LEN, SPI_BIT_BIG_ENDIAN, SPI_BIT_SCLK, spi_bit_set_slave_select(), spi_bit_transfer(), SPI_MODE_CPOL, and write_bit().
Referenced by init_spi_bit_basher().
void init_spi_bit_basher | ( | struct spi_bit_basher * | spibit | ) |
Initialise SPI bit-bashing interface.
spibit | SPI bit-bashing interface |
Definition at line 235 of file spi_bit.c.
References assert(), spi_bit_basher::basher, spi_bit_basher::bus, NULL, bit_basher::op, bit_basher_operations::read, spi_bus::rw, spi_bit_rw(), and bit_basher_operations::write.
Referenced by ifec_init_eeprom(), natsemi_init_eeprom(), realtek_init_eeprom(), and rtl818x_probe().