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