xref: /rk3399_rockchip-uboot/include/bootcount.h (revision 326ea986ac150acdc7656d57fca647db80b50158)
10044c42eSStefan Roese /*
20044c42eSStefan Roese  * (C) Copyright 2012
30044c42eSStefan Roese  * Stefan Roese, DENX Software Engineering, sr@denx.de.
40044c42eSStefan Roese  *
5*1a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
60044c42eSStefan Roese  */
70044c42eSStefan Roese 
80044c42eSStefan Roese #include <common.h>
90044c42eSStefan Roese #include <asm/io.h>
100044c42eSStefan Roese #include <asm/byteorder.h>
110044c42eSStefan Roese 
120044c42eSStefan Roese #if !defined(CONFIG_SYS_BOOTCOUNT_LE) && !defined(CONFIG_SYS_BOOTCOUNT_BE)
130044c42eSStefan Roese # if __BYTE_ORDER == __LITTLE_ENDIAN
140044c42eSStefan Roese #  define CONFIG_SYS_BOOTCOUNT_LE
150044c42eSStefan Roese # else
160044c42eSStefan Roese #  define CONFIG_SYS_BOOTCOUNT_BE
170044c42eSStefan Roese # endif
180044c42eSStefan Roese #endif
190044c42eSStefan Roese 
200044c42eSStefan Roese #ifdef CONFIG_SYS_BOOTCOUNT_LE
raw_bootcount_store(volatile u32 * addr,u32 data)210044c42eSStefan Roese static inline void raw_bootcount_store(volatile u32 *addr, u32 data)
220044c42eSStefan Roese {
230044c42eSStefan Roese 	out_le32(addr, data);
240044c42eSStefan Roese }
250044c42eSStefan Roese 
raw_bootcount_load(volatile u32 * addr)260044c42eSStefan Roese static inline u32 raw_bootcount_load(volatile u32 *addr)
270044c42eSStefan Roese {
280044c42eSStefan Roese 	return in_le32(addr);
290044c42eSStefan Roese }
300044c42eSStefan Roese #else
raw_bootcount_store(volatile u32 * addr,u32 data)310044c42eSStefan Roese static inline void raw_bootcount_store(volatile u32 *addr, u32 data)
320044c42eSStefan Roese {
330044c42eSStefan Roese 	out_be32(addr, data);
340044c42eSStefan Roese }
350044c42eSStefan Roese 
raw_bootcount_load(volatile u32 * addr)360044c42eSStefan Roese static inline u32 raw_bootcount_load(volatile u32 *addr)
370044c42eSStefan Roese {
380044c42eSStefan Roese 	return in_be32(addr);
390044c42eSStefan Roese }
400044c42eSStefan Roese #endif
41