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