iPXE
spi_bit.h
Go to the documentation of this file.
1#ifndef _IPXE_SPI_BIT_H
2#define _IPXE_SPI_BIT_H
3
4/** @file
5 *
6 * SPI bit-bashing interface
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <ipxe/spi.h>
14#include <ipxe/bitbash.h>
15
16/** A bit-bashing SPI bus */
18 /** SPI bus */
19 struct spi_bus bus;
20 /** Bit-bashing interface */
22 /** Endianness of data
23 *
24 * SPI commands and addresses are always big-endian (i.e. MSB
25 * transmitted first on the wire), but some cards
26 * (e.g. natsemi) choose to regard the data stored in the
27 * EEPROM as little-endian (i.e. LSB transmitted first on the
28 * wire).
29 */
31};
32
33/** Bit indices used for SPI bit-bashing interface */
34enum {
35 /** Serial clock */
37 /** Master Out Slave In */
39 /** Master In Slave Out */
41 /** Slave 0 select */
43};
44
45/**
46 * Determine bit index for a particular slave
47 *
48 * @v slave Slave number
49 * @ret index Bit index (i.e. SPI_BIT_SSN, where N=slave)
50 */
51#define SPI_BIT_SS( slave ) ( SPI_BIT_SS0 + (slave) )
52
53/** Delay between SCLK transitions */
54#define SPI_BIT_UDELAY 1
55
56/** SPI bit basher treats data as big-endian */
57#define SPI_BIT_BIG_ENDIAN 0
58
59/** SPI bit basher treats data as little-endian */
60#define SPI_BIT_LITTLE_ENDIAN 1
61
62extern void init_spi_bit_basher ( struct spi_bit_basher *spibit );
63
64#endif /* _IPXE_SPI_BIT_H */
Bit-bashing interfaces.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
SPI interface.
void init_spi_bit_basher(struct spi_bit_basher *spibit)
Initialise SPI bit-bashing interface.
Definition spi_bit.c:236
@ 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
@ SPI_BIT_SS0
Slave 0 select.
Definition spi_bit.h:42
A bit-bashing interface.
Definition bitbash.h:56
A bit-bashing SPI bus.
Definition spi_bit.h:17
struct spi_bus bus
SPI bus.
Definition spi_bit.h:19
int endianness
Endianness of data.
Definition spi_bit.h:30
struct bit_basher basher
Bit-bashing interface.
Definition spi_bit.h:21
An SPI bus.
Definition spi.h:127