blob: 3eb802470a2b8bae55802b319c684c387981756a [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Stefan Roese0044c422012-08-16 17:55:41 +00002/*
3 * (C) Copyright 2012
4 * Stefan Roese, DENX Software Engineering, sr@denx.de.
Stefan Roese0044c422012-08-16 17:55:41 +00005 */
6
7#include <common.h>
8#include <asm/io.h>
9#include <asm/byteorder.h>
10
11#if !defined(CONFIG_SYS_BOOTCOUNT_LE) && !defined(CONFIG_SYS_BOOTCOUNT_BE)
12# if __BYTE_ORDER == __LITTLE_ENDIAN
13# define CONFIG_SYS_BOOTCOUNT_LE
14# else
15# define CONFIG_SYS_BOOTCOUNT_BE
16# endif
17#endif
18
19#ifdef CONFIG_SYS_BOOTCOUNT_LE
20static inline void raw_bootcount_store(volatile u32 *addr, u32 data)
21{
22 out_le32(addr, data);
23}
24
25static inline u32 raw_bootcount_load(volatile u32 *addr)
26{
27 return in_le32(addr);
28}
29#else
30static inline void raw_bootcount_store(volatile u32 *addr, u32 data)
31{
32 out_be32(addr, data);
33}
34
35static inline u32 raw_bootcount_load(volatile u32 *addr)
36{
37 return in_be32(addr);
38}
39#endif