1*0044c42eSStefan Roese /* 2*0044c42eSStefan Roese * (C) Copyright 2012 3*0044c42eSStefan Roese * Stefan Roese, DENX Software Engineering, sr@denx.de. 4*0044c42eSStefan Roese * 5*0044c42eSStefan Roese * See file CREDITS for list of people who contributed to this 6*0044c42eSStefan Roese * project. 7*0044c42eSStefan Roese * 8*0044c42eSStefan Roese * This program is free software; you can redistribute it and/or 9*0044c42eSStefan Roese * modify it under the terms of the GNU General Public License as 10*0044c42eSStefan Roese * published by the Free Software Foundation; either version 2 of 11*0044c42eSStefan Roese * the License, or (at your option) any later version. 12*0044c42eSStefan Roese * 13*0044c42eSStefan Roese * This program is distributed in the hope that it will be useful, 14*0044c42eSStefan Roese * but WITHOUT ANY WARRANTY; without even the implied warranty of 15*0044c42eSStefan Roese * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16*0044c42eSStefan Roese * GNU General Public License for more details. 17*0044c42eSStefan Roese */ 18*0044c42eSStefan Roese 19*0044c42eSStefan Roese #include <common.h> 20*0044c42eSStefan Roese #include <asm/io.h> 21*0044c42eSStefan Roese #include <asm/byteorder.h> 22*0044c42eSStefan Roese 23*0044c42eSStefan Roese #if !defined(CONFIG_SYS_BOOTCOUNT_LE) && !defined(CONFIG_SYS_BOOTCOUNT_BE) 24*0044c42eSStefan Roese # if __BYTE_ORDER == __LITTLE_ENDIAN 25*0044c42eSStefan Roese # define CONFIG_SYS_BOOTCOUNT_LE 26*0044c42eSStefan Roese # else 27*0044c42eSStefan Roese # define CONFIG_SYS_BOOTCOUNT_BE 28*0044c42eSStefan Roese # endif 29*0044c42eSStefan Roese #endif 30*0044c42eSStefan Roese 31*0044c42eSStefan Roese #ifdef CONFIG_SYS_BOOTCOUNT_LE 32*0044c42eSStefan Roese static inline void raw_bootcount_store(volatile u32 *addr, u32 data) 33*0044c42eSStefan Roese { 34*0044c42eSStefan Roese out_le32(addr, data); 35*0044c42eSStefan Roese } 36*0044c42eSStefan Roese 37*0044c42eSStefan Roese static inline u32 raw_bootcount_load(volatile u32 *addr) 38*0044c42eSStefan Roese { 39*0044c42eSStefan Roese return in_le32(addr); 40*0044c42eSStefan Roese } 41*0044c42eSStefan Roese #else 42*0044c42eSStefan Roese static inline void raw_bootcount_store(volatile u32 *addr, u32 data) 43*0044c42eSStefan Roese { 44*0044c42eSStefan Roese out_be32(addr, data); 45*0044c42eSStefan Roese } 46*0044c42eSStefan Roese 47*0044c42eSStefan Roese static inline u32 raw_bootcount_load(volatile u32 *addr) 48*0044c42eSStefan Roese { 49*0044c42eSStefan Roese return in_be32(addr); 50*0044c42eSStefan Roese } 51*0044c42eSStefan Roese #endif 52