Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Heiko Schocher | eda0ba3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2013 |
| 4 | * Heiko Schocher, DENX Software Engineering, hs@denx.de. |
Heiko Schocher | eda0ba3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 168068f | 2019-08-01 09:46:47 -0600 | [diff] [blame] | 8 | #include <env.h> |
Heiko Schocher | eda0ba3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 9 | |
| 10 | void bootcount_store(ulong a) |
| 11 | { |
Simon Glass | bfebc8c | 2017-08-03 12:22:13 -0600 | [diff] [blame] | 12 | int upgrade_available = env_get_ulong("upgrade_available", 10, 0); |
Heiko Schocher | eda0ba3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 13 | |
| 14 | if (upgrade_available) { |
Simon Glass | 018f530 | 2017-08-03 12:22:10 -0600 | [diff] [blame] | 15 | env_set_ulong("bootcount", a); |
Simon Glass | 0151009 | 2017-08-03 12:22:08 -0600 | [diff] [blame] | 16 | env_save(); |
Heiko Schocher | eda0ba3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 17 | } |
| 18 | } |
| 19 | |
| 20 | ulong bootcount_load(void) |
| 21 | { |
Simon Glass | bfebc8c | 2017-08-03 12:22:13 -0600 | [diff] [blame] | 22 | int upgrade_available = env_get_ulong("upgrade_available", 10, 0); |
Heiko Schocher | eda0ba3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 23 | ulong val = 0; |
| 24 | |
| 25 | if (upgrade_available) |
Simon Glass | bfebc8c | 2017-08-03 12:22:13 -0600 | [diff] [blame] | 26 | val = env_get_ulong("bootcount", 10, 0); |
Heiko Schocher | eda0ba3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 27 | |
| 28 | return val; |
| 29 | } |