Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / include / ipxe / spi_bit.h
1 #ifndef _IPXE_SPI_BIT_H
2 #define _IPXE_SPI_BIT_H
3
4 /** @file
5  *
6  * SPI bit-bashing interface
7  *
8  */
9
10 FILE_LICENCE ( GPL2_OR_LATER );
11
12 #include <ipxe/spi.h>
13 #include <ipxe/bitbash.h>
14
15 /** A bit-bashing SPI bus */
16 struct spi_bit_basher {
17         /** SPI bus */
18         struct spi_bus bus;
19         /** Bit-bashing interface */
20         struct bit_basher basher;
21         /** Endianness of data
22          *
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
27          * wire).
28          */
29         int endianness;
30 };
31
32 /** Bit indices used for SPI bit-bashing interface */
33 enum {
34         /** Serial clock */
35         SPI_BIT_SCLK = 0,
36         /** Master Out Slave In */
37         SPI_BIT_MOSI,
38         /** Master In Slave Out */
39         SPI_BIT_MISO,
40         /** Slave 0 select */
41         SPI_BIT_SS0,
42 };
43
44 /**
45  * Determine bit index for a particular slave
46  *
47  * @v slave             Slave number
48  * @ret index           Bit index (i.e. SPI_BIT_SSN, where N=slave) 
49  */
50 #define SPI_BIT_SS( slave ) ( SPI_BIT_SS0 + (slave) )
51
52 /** Delay between SCLK transitions */
53 #define SPI_BIT_UDELAY 1
54
55 /** SPI bit basher treats data as big-endian */
56 #define SPI_BIT_BIG_ENDIAN 0
57
58 /** SPI bit basher treats data as little-endian */
59 #define SPI_BIT_LITTLE_ENDIAN 1
60
61 extern void init_spi_bit_basher ( struct spi_bit_basher *spibit );
62
63 #endif /* _IPXE_SPI_BIT_H */