]> Git Repo - J-u-boot.git/blame - drivers/bootcount/bootcount_at91.c
Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"
[J-u-boot.git] / drivers / bootcount / bootcount_at91.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
0044c42e 2
0044c42e
SR
3#include <asm/io.h>
4#include <asm/arch/hardware.h>
5#include <asm/arch/at91_gpbr.h>
6
7/*
758694ff
MV
8 * We combine the CONFIG_SYS_BOOTCOUNT_MAGIC and bootcount in one 32-bit
9 * register. This is done so we need to use only one of the four GPBR
10 * registers.
0044c42e
SR
11 */
12void bootcount_store(ulong a)
13{
14 at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
15
758694ff
MV
16 writel((CONFIG_SYS_BOOTCOUNT_MAGIC & 0xffff0000) | (a & 0x0000ffff),
17 &gpbr->reg[AT91_GPBR_INDEX_BOOTCOUNT]);
0044c42e
SR
18}
19
20ulong bootcount_load(void)
21{
22 at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
23
24 ulong val = readl(&gpbr->reg[AT91_GPBR_INDEX_BOOTCOUNT]);
758694ff 25 if ((val & 0xffff0000) != (CONFIG_SYS_BOOTCOUNT_MAGIC & 0xffff0000))
0044c42e
SR
26 return 0;
27 else
28 return val & 0x0000ffff;
29}
This page took 0.41536 seconds and 4 git commands to generate.