Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Stefan Roese | 033848e | 2012-08-16 17:55:41 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2012 |
| 4 | * Stefan Roese, DENX Software Engineering, sr@denx.de. |
Stefan Roese | 033848e | 2012-08-16 17:55:41 +0000 | [diff] [blame] | 5 | */ |
| 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 |
| 20 | static inline void raw_bootcount_store(volatile u32 *addr, u32 data) |
| 21 | { |
| 22 | out_le32(addr, data); |
| 23 | } |
| 24 | |
| 25 | static inline u32 raw_bootcount_load(volatile u32 *addr) |
| 26 | { |
| 27 | return in_le32(addr); |
| 28 | } |
| 29 | #else |
| 30 | static inline void raw_bootcount_store(volatile u32 *addr, u32 data) |
| 31 | { |
| 32 | out_be32(addr, data); |
| 33 | } |
| 34 | |
| 35 | static inline u32 raw_bootcount_load(volatile u32 *addr) |
| 36 | { |
| 37 | return in_be32(addr); |
| 38 | } |
| 39 | #endif |