bootcount.h 803 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * (C) Copyright 2012
  3. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <asm/io.h>
  9. #include <asm/byteorder.h>
  10. #if !defined(CONFIG_SYS_BOOTCOUNT_LE) && !defined(CONFIG_SYS_BOOTCOUNT_BE)
  11. # if __BYTE_ORDER == __LITTLE_ENDIAN
  12. # define CONFIG_SYS_BOOTCOUNT_LE
  13. # else
  14. # define CONFIG_SYS_BOOTCOUNT_BE
  15. # endif
  16. #endif
  17. #ifdef CONFIG_SYS_BOOTCOUNT_LE
  18. static inline void raw_bootcount_store(volatile u32 *addr, u32 data)
  19. {
  20. out_le32(addr, data);
  21. }
  22. static inline u32 raw_bootcount_load(volatile u32 *addr)
  23. {
  24. return in_le32(addr);
  25. }
  26. #else
  27. static inline void raw_bootcount_store(volatile u32 *addr, u32 data)
  28. {
  29. out_be32(addr, data);
  30. }
  31. static inline u32 raw_bootcount_load(volatile u32 *addr)
  32. {
  33. return in_be32(addr);
  34. }
  35. #endif