iPXE
spi_bit.h
Go to the documentation of this file.
00001 #ifndef _IPXE_SPI_BIT_H
00002 #define _IPXE_SPI_BIT_H
00003 
00004 /** @file
00005  *
00006  * SPI bit-bashing interface
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <ipxe/spi.h>
00013 #include <ipxe/bitbash.h>
00014 
00015 /** A bit-bashing SPI bus */
00016 struct spi_bit_basher {
00017         /** SPI bus */
00018         struct spi_bus bus;
00019         /** Bit-bashing interface */
00020         struct bit_basher basher;
00021         /** Endianness of data
00022          *
00023          * SPI commands and addresses are always big-endian (i.e. MSB
00024          * transmitted first on the wire), but some cards
00025          * (e.g. natsemi) choose to regard the data stored in the
00026          * EEPROM as little-endian (i.e. LSB transmitted first on the
00027          * wire).
00028          */
00029         int endianness;
00030 };
00031 
00032 /** Bit indices used for SPI bit-bashing interface */
00033 enum {
00034         /** Serial clock */
00035         SPI_BIT_SCLK = 0,
00036         /** Master Out Slave In */
00037         SPI_BIT_MOSI,
00038         /** Master In Slave Out */
00039         SPI_BIT_MISO,
00040         /** Slave 0 select */
00041         SPI_BIT_SS0,
00042 };
00043 
00044 /**
00045  * Determine bit index for a particular slave
00046  *
00047  * @v slave             Slave number
00048  * @ret index           Bit index (i.e. SPI_BIT_SSN, where N=slave) 
00049  */
00050 #define SPI_BIT_SS( slave ) ( SPI_BIT_SS0 + (slave) )
00051 
00052 /** Delay between SCLK transitions */
00053 #define SPI_BIT_UDELAY 1
00054 
00055 /** SPI bit basher treats data as big-endian */
00056 #define SPI_BIT_BIG_ENDIAN 0
00057 
00058 /** SPI bit basher treats data as little-endian */
00059 #define SPI_BIT_LITTLE_ENDIAN 1
00060 
00061 extern void init_spi_bit_basher ( struct spi_bit_basher *spibit );
00062 
00063 #endif /* _IPXE_SPI_BIT_H */