mrccache.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2014 Google, Inc
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef _ASM_ARCH_MRCCACHE_H
  7. #define _ASM_ARCH_MRCCACHE_H
  8. #define MRC_DATA_ALIGN 0x1000
  9. #define MRC_DATA_SIGNATURE (('M' << 0) | ('R' << 8) | ('C' << 16) | \
  10. ('D'<<24))
  11. __packed struct mrc_data_container {
  12. u32 signature; /* "MRCD" */
  13. u32 data_size; /* Size of the 'data' field */
  14. u32 checksum; /* IP style checksum */
  15. u32 reserved; /* For header alignment */
  16. u8 data[0]; /* Variable size, platform/run time dependent */
  17. };
  18. struct fmap_entry;
  19. struct udevice;
  20. /**
  21. * mrccache_find_current() - find the latest MRC cache record
  22. *
  23. * This searches the MRC cache region looking for the latest record to use
  24. * for setting up SDRAM
  25. *
  26. * @entry: Information about the position and size of the MRC cache
  27. * @return pointer to latest record, or NULL if none
  28. */
  29. struct mrc_data_container *mrccache_find_current(struct fmap_entry *entry);
  30. /**
  31. * mrccache_update() - update the MRC cache with a new record
  32. *
  33. * This writes a new record to the end of the MRC cache. If the new record is
  34. * the same as the latest record then the write is skipped
  35. *
  36. * @sf: SPI flash to write to
  37. * @entry: Position and size of MRC cache in SPI flash
  38. * @cur: Record to write
  39. * @return 0 if updated, -EEXIST if the record is the same as the latest
  40. * record, -EINVAL if the record is not valid, other error if SPI write failed
  41. */
  42. int mrccache_update(struct udevice *sf, struct fmap_entry *entry,
  43. struct mrc_data_container *cur);
  44. #endif