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

threewire.h 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef _GPXE_THREEWIRE_H
  2. #define _GPXE_THREEWIRE_H
  3. /** @file
  4. *
  5. * Three-wire serial interface
  6. *
  7. * The Atmel three-wire interface is a subset of the (newer) SPI
  8. * interface, and is implemented here as a layer on top of the SPI
  9. * support.
  10. */
  11. #include <gpxe/spi.h>
  12. /**
  13. * @defgroup tcmds Three-wire commands
  14. * @{
  15. */
  16. /** Read data from memory array */
  17. #define THREEWIRE_READ 0x6
  18. /** @} */
  19. extern int threewire_read ( struct nvs_device *nvs, unsigned int address,
  20. void *data, size_t len );
  21. /**
  22. * @defgroup tdevs Three-wire device types
  23. * @{
  24. */
  25. static inline __attribute__ (( always_inline )) void
  26. init_at93cx6 ( struct spi_device *device, unsigned int organisation ) {
  27. device->nvs.word_len = organisation;
  28. device->nvs.block_size = 1;
  29. device->command_len = 3,
  30. device->nvs.read = threewire_read;
  31. }
  32. /**
  33. * Initialise Atmel AT93C46 serial EEPROM
  34. *
  35. * @v device SPI device
  36. * @v organisation Word organisation (8 or 16)
  37. */
  38. static inline __attribute__ (( always_inline )) void
  39. init_at93c46 ( struct spi_device *device, unsigned int organisation ) {
  40. device->nvs.size = ( 1024 / organisation );
  41. device->address_len = ( ( organisation == 8 ) ? 7 : 6 );
  42. init_at93cx6 ( device, organisation );
  43. }
  44. /**
  45. * Initialise Atmel AT93C56 serial EEPROM
  46. *
  47. * @v device SPI device
  48. * @v organisation Word organisation (8 or 16)
  49. */
  50. static inline __attribute__ (( always_inline )) void
  51. init_at93c56 ( struct spi_device *device, unsigned int organisation ) {
  52. device->nvs.size = ( 2048 / organisation );
  53. device->address_len = ( ( organisation == 8 ) ? 9 : 8 );
  54. init_at93cx6 ( device, organisation );
  55. }
  56. /** @} */
  57. #endif /* _GPXE_THREEWIRE_H */