From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Roese Date: Tue, 14 Jan 2014 07:58:22 +0100 Subject: [U-Boot] [PATCH 1/9] kmp204x: support for QRIO1 bootcounter In-Reply-To: <1389630557-32312-2-git-send-email-valentin.longchamp@keymile.com> References: <1389630557-32312-1-git-send-email-valentin.longchamp@keymile.com> <1389630557-32312-2-git-send-email-valentin.longchamp@keymile.com> Message-ID: <52D4E00E.90503@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Valentin, On 13.01.2014 17:29, Valentin Longchamp wrote: > From: Rainer Boschung > > - make use of the QRIO1 32bit register at 0x20 as bootcounter register > - check for BOOTCOUNT_MAGIC pattern when before bootcounter value is read > > Signed-off-by: Rainer Boschung > Signed-off-by: Valentin Longchamp > Acked-by: Valentin Longchamp > --- > > board/keymile/kmp204x/kmp204x.c | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/board/keymile/kmp204x/kmp204x.c b/board/keymile/kmp204x/kmp204x.c > index f02642a..b41929a 100644 > --- a/board/keymile/kmp204x/kmp204x.c > +++ b/board/keymile/kmp204x/kmp204x.c > @@ -134,22 +134,25 @@ void qrio_prstcfg(u8 bit, u8 mode) > } > > > -#define BOOTCOUNT_OFF 0x12 > +#define BOOTCOUNT_OFF 0x20 > > void bootcount_store(ulong counter) > { > - u8 val; > void __iomem *qrio_base = (void *)CONFIG_SYS_QRIO_BASE; > > - val = (counter <= 255) ? (u8)counter : 255; > - out_8(qrio_base + BOOTCOUNT_OFF, val); > + out_be32(qrio_base + BOOTCOUNT_OFF, counter); > } > > ulong bootcount_load(void) > { > - u8 val; > + u32 val; > void __iomem *qrio_base = (void *)CONFIG_SYS_QRIO_BASE; > - val = in_8(qrio_base + BOOTCOUNT_OFF); > + val = in_be32(qrio_base + BOOTCOUNT_OFF + 4); > + > + if (val == BOOTCOUNT_MAGIC) > + val = in_be32(qrio_base + BOOTCOUNT_OFF); > + else > + val = 0; > return val; > } Can't you just use the common bootcount driver (drivers/bootcount/bootcount.c) instead? Should be easy. Just define this in your config header: #define CONFIG_BOOTCOUNT_LIMIT #define CONFIG_SYS_BOOTCOUNT_ADDR (CONFIG_SYS_QRIO_BASE + 0x20) Thanks, Stefan