blob: 06fb4d3578b5079bd3f8bb4b41a23fa8af03c31d [file] [log] [blame]
Stefan Roese033848e2012-08-16 17:55:41 +00001/*
2 * (C) Copyright 2012
3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Stefan Roese033848e2012-08-16 17:55:41 +00006 */
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
21static inline void raw_bootcount_store(volatile u32 *addr, u32 data)
22{
23 out_le32(addr, data);
24}
25
26static inline u32 raw_bootcount_load(volatile u32 *addr)
27{
28 return in_le32(addr);
29}
30#else
31static inline void raw_bootcount_store(volatile u32 *addr, u32 data)
32{
33 out_be32(addr, data);
34}
35
36static inline u32 raw_bootcount_load(volatile u32 *addr)
37{
38 return in_be32(addr);
39}
40#endif