iPXE
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)
 Determine bit index for a particular slave.
#define SPI_BIT_UDELAY   1
 Delay between SCLK transitions.
#define SPI_BIT_BIG_ENDIAN   0
 SPI bit basher treats data as big-endian.
#define SPI_BIT_LITTLE_ENDIAN   1
 SPI bit basher treats data as little-endian.

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)
 FILE_SECBOOT (PERMITTED)
void init_spi_bit_basher (struct spi_bit_basher *spibit)
 Initialise SPI bit-bashing interface.

Detailed Description

SPI bit-bashing interface.

Definition in file spi_bit.h.

Macro Definition Documentation

◆ SPI_BIT_SS

#define SPI_BIT_SS ( slave)
Value:
uint8_t slave
Slave.
Definition edd.h:1
@ SPI_BIT_SS0
Slave 0 select.
Definition spi_bit.h:42

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 51 of file spi_bit.h.

Referenced by spi_bit_set_slave_select().

◆ SPI_BIT_UDELAY

#define SPI_BIT_UDELAY   1

Delay between SCLK transitions.

Definition at line 54 of file spi_bit.h.

Referenced by spi_bit_delay().

◆ SPI_BIT_BIG_ENDIAN

#define SPI_BIT_BIG_ENDIAN   0

SPI bit basher treats data as big-endian.

Definition at line 57 of file spi_bit.h.

Referenced by natsemi_init_eeprom(), spi_bit_rw(), and spi_bit_transfer().

◆ SPI_BIT_LITTLE_ENDIAN

#define SPI_BIT_LITTLE_ENDIAN   1

SPI bit basher treats data as little-endian.

Definition at line 60 of file spi_bit.h.

Referenced by natsemi_init_eeprom().

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 34 of file spi_bit.h.

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

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ init_spi_bit_basher()

void init_spi_bit_basher ( struct spi_bit_basher * spibit)
extern

Initialise SPI bit-bashing interface.

Parameters
spibitSPI bit-bashing interface

Definition at line 236 of file spi_bit.c.

236 {
237 assert ( &spibit->basher.op->read != NULL );
238 assert ( &spibit->basher.op->write != NULL );
239 spibit->bus.rw = spi_bit_rw;
240}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
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:162
void(* write)(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
Set/clear output bit.
Definition bitbash.h:42
int(* read)(struct bit_basher *basher, unsigned int bit_id)
Read input bit.
Definition bitbash.h:52
struct bit_basher_operations * op
Bit-bashing operations.
Definition bitbash.h:58
struct spi_bus bus
SPI bus.
Definition spi_bit.h:19
struct bit_basher basher
Bit-bashing interface.
Definition spi_bit.h:21
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:153

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