您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

spi_bit.h 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef _IPXE_SPI_BIT_H
  2. #define _IPXE_SPI_BIT_H
  3. /** @file
  4. *
  5. * SPI bit-bashing interface
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <ipxe/spi.h>
  10. #include <ipxe/bitbash.h>
  11. /** A bit-bashing SPI bus */
  12. struct spi_bit_basher {
  13. /** SPI bus */
  14. struct spi_bus bus;
  15. /** Bit-bashing interface */
  16. struct bit_basher basher;
  17. /** Endianness of data
  18. *
  19. * SPI commands and addresses are always big-endian (i.e. MSB
  20. * transmitted first on the wire), but some cards
  21. * (e.g. natsemi) choose to regard the data stored in the
  22. * EEPROM as little-endian (i.e. LSB transmitted first on the
  23. * wire).
  24. */
  25. int endianness;
  26. };
  27. /** Bit indices used for SPI bit-bashing interface */
  28. enum {
  29. /** Serial clock */
  30. SPI_BIT_SCLK = 0,
  31. /** Master Out Slave In */
  32. SPI_BIT_MOSI,
  33. /** Master In Slave Out */
  34. SPI_BIT_MISO,
  35. /** Slave 0 select */
  36. SPI_BIT_SS0,
  37. };
  38. /**
  39. * Determine bit index for a particular slave
  40. *
  41. * @v slave Slave number
  42. * @ret index Bit index (i.e. SPI_BIT_SSN, where N=slave)
  43. */
  44. #define SPI_BIT_SS( slave ) ( SPI_BIT_SS0 + (slave) )
  45. /** Delay between SCLK transitions */
  46. #define SPI_BIT_UDELAY 1
  47. /** SPI bit basher treats data as big-endian */
  48. #define SPI_BIT_BIG_ENDIAN 0
  49. /** SPI bit basher treats data as little-endian */
  50. #define SPI_BIT_LITTLE_ENDIAN 1
  51. extern void init_spi_bit_basher ( struct spi_bit_basher *spibit );
  52. #endif /* _IPXE_SPI_BIT_H */