blob: 9084ca8a6e82665c1b944f95a19012a7aeeb0163 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Heiko Schochereda0ba32013-11-04 14:04:59 +01002/*
3 * (C) Copyright 2013
4 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
Heiko Schochereda0ba32013-11-04 14:04:59 +01005 */
6
7#include <common.h>
Simon Glass01510092017-08-03 12:22:08 -06008#include <environment.h>
Heiko Schochereda0ba32013-11-04 14:04:59 +01009
10void bootcount_store(ulong a)
11{
Simon Glassbfebc8c2017-08-03 12:22:13 -060012 int upgrade_available = env_get_ulong("upgrade_available", 10, 0);
Heiko Schochereda0ba32013-11-04 14:04:59 +010013
14 if (upgrade_available) {
Simon Glass018f5302017-08-03 12:22:10 -060015 env_set_ulong("bootcount", a);
Simon Glass01510092017-08-03 12:22:08 -060016 env_save();
Heiko Schochereda0ba32013-11-04 14:04:59 +010017 }
18}
19
20ulong bootcount_load(void)
21{
Simon Glassbfebc8c2017-08-03 12:22:13 -060022 int upgrade_available = env_get_ulong("upgrade_available", 10, 0);
Heiko Schochereda0ba32013-11-04 14:04:59 +010023 ulong val = 0;
24
25 if (upgrade_available)
Simon Glassbfebc8c2017-08-03 12:22:13 -060026 val = env_get_ulong("bootcount", 10, 0);
Heiko Schochereda0ba32013-11-04 14:04:59 +010027
28 return val;
29}