1 #ifndef _IPXE_SPI_BIT_H
2 #define _IPXE_SPI_BIT_H
6 * SPI bit-bashing interface
10 FILE_LICENCE ( GPL2_OR_LATER );
13 #include <ipxe/bitbash.h>
15 /** A bit-bashing SPI bus */
16 struct spi_bit_basher {
19 /** Bit-bashing interface */
20 struct bit_basher basher;
21 /** Endianness of data
23 * SPI commands and addresses are always big-endian (i.e. MSB
24 * transmitted first on the wire), but some cards
25 * (e.g. natsemi) choose to regard the data stored in the
26 * EEPROM as little-endian (i.e. LSB transmitted first on the
32 /** Bit indices used for SPI bit-bashing interface */
36 /** Master Out Slave In */
38 /** Master In Slave Out */
45 * Determine bit index for a particular slave
47 * @v slave Slave number
48 * @ret index Bit index (i.e. SPI_BIT_SSN, where N=slave)
50 #define SPI_BIT_SS( slave ) ( SPI_BIT_SS0 + (slave) )
52 /** Delay between SCLK transitions */
53 #define SPI_BIT_UDELAY 1
55 /** SPI bit basher treats data as big-endian */
56 #define SPI_BIT_BIG_ENDIAN 0
58 /** SPI bit basher treats data as little-endian */
59 #define SPI_BIT_LITTLE_ENDIAN 1
61 extern void init_spi_bit_basher ( struct spi_bit_basher *spibit );
63 #endif /* _IPXE_SPI_BIT_H */