bootcount.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * (C) Copyright 2012
  3. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #include <common.h>
  19. #include <asm/io.h>
  20. #include <asm/byteorder.h>
  21. #if !defined(CONFIG_SYS_BOOTCOUNT_LE) && !defined(CONFIG_SYS_BOOTCOUNT_BE)
  22. # if __BYTE_ORDER == __LITTLE_ENDIAN
  23. # define CONFIG_SYS_BOOTCOUNT_LE
  24. # else
  25. # define CONFIG_SYS_BOOTCOUNT_BE
  26. # endif
  27. #endif
  28. #ifdef CONFIG_SYS_BOOTCOUNT_LE
  29. static inline void raw_bootcount_store(volatile u32 *addr, u32 data)
  30. {
  31. out_le32(addr, data);
  32. }
  33. static inline u32 raw_bootcount_load(volatile u32 *addr)
  34. {
  35. return in_le32(addr);
  36. }
  37. #else
  38. static inline void raw_bootcount_store(volatile u32 *addr, u32 data)
  39. {
  40. out_be32(addr, data);
  41. }
  42. static inline u32 raw_bootcount_load(volatile u32 *addr)
  43. {
  44. return in_be32(addr);
  45. }
  46. #endif