iPXE
Data Structures | Macros | Enumerations | Functions
spi_bit.h File Reference

SPI bit-bashing interface. More...

#include <ipxe/spi.h>
#include <ipxe/bitbash.h>

Go to the source code of this file.

Data Structures

struct  spi_bit_basher
 A bit-bashing SPI bus. More...
 

Macros

#define SPI_BIT_SS(slave)   ( SPI_BIT_SS0 + (slave) )
 Determine bit index for a particular slave. More...
 
#define SPI_BIT_UDELAY   1
 Delay between SCLK transitions. More...
 
#define SPI_BIT_BIG_ENDIAN   0
 SPI bit basher treats data as big-endian. More...
 
#define SPI_BIT_LITTLE_ENDIAN   1
 SPI bit basher treats data as little-endian. More...
 

Enumerations

enum  { SPI_BIT_SCLK = 0, SPI_BIT_MOSI, SPI_BIT_MISO, SPI_BIT_SS0 }
 Bit indices used for SPI bit-bashing interface. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
void init_spi_bit_basher (struct spi_bit_basher *spibit)
 Initialise SPI bit-bashing interface. More...
 

Detailed Description

SPI bit-bashing interface.

Definition in file spi_bit.h.

Macro Definition Documentation

◆ SPI_BIT_SS

#define SPI_BIT_SS (   slave)    ( SPI_BIT_SS0 + (slave) )

Determine bit index for a particular slave.

Parameters
slaveSlave number
Return values
indexBit index (i.e. SPI_BIT_SSN, where N=slave)

Definition at line 50 of file spi_bit.h.

◆ SPI_BIT_UDELAY

#define SPI_BIT_UDELAY   1

Delay between SCLK transitions.

Definition at line 53 of file spi_bit.h.

◆ SPI_BIT_BIG_ENDIAN

#define SPI_BIT_BIG_ENDIAN   0

SPI bit basher treats data as big-endian.

Definition at line 56 of file spi_bit.h.

◆ SPI_BIT_LITTLE_ENDIAN

#define SPI_BIT_LITTLE_ENDIAN   1

SPI bit basher treats data as little-endian.

Definition at line 59 of file spi_bit.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Bit indices used for SPI bit-bashing interface.

Enumerator
SPI_BIT_SCLK 

Serial clock.

SPI_BIT_MOSI 

Master Out Slave In.

SPI_BIT_MISO 

Master In Slave Out.

SPI_BIT_SS0 

Slave 0 select.

Definition at line 33 of file spi_bit.h.

33  {
34  /** Serial clock */
35  SPI_BIT_SCLK = 0,
36  /** Master Out Slave In */
38  /** Master In Slave Out */
40  /** Slave 0 select */
42 };
Slave 0 select.
Definition: spi_bit.h:41
Master In Slave Out.
Definition: spi_bit.h:39
Master Out Slave In.
Definition: spi_bit.h:37
Serial clock.
Definition: spi_bit.h:35

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ init_spi_bit_basher()

void init_spi_bit_basher ( struct spi_bit_basher spibit)

Initialise SPI bit-bashing interface.

Parameters
spibitSPI bit-bashing interface

Definition at line 235 of file spi_bit.c.

235  {
236  assert ( &spibit->basher.op->read != NULL );
237  assert ( &spibit->basher.op->write != NULL );
238  spibit->bus.rw = spi_bit_rw;
239 }
struct bit_basher basher
Bit-bashing interface.
Definition: spi_bit.h:20
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.
Definition: spi_bit.c:161
int(* 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 bus.
Definition: spi.h:152
struct bit_basher_operations * op
Bit-bashing operations.
Definition: bitbash.h:57
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
int(* read)(struct bit_basher *basher, unsigned int bit_id)
Read input bit.
Definition: bitbash.h:51
struct spi_bus bus
SPI bus.
Definition: spi_bit.h:18
void(* write)(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
Set/clear output bit.
Definition: bitbash.h:41
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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().