Commit 9e50c406c8eede1105bd8ad1c1b74e0ef64af233
1 parent
16c550274c
Exists in
master
and in
49 other branches
i2c, bootcount: add support for bootcounter on i2c devices
add support for bootcounter on an i2c device. And add a README for all bootcounter options. Signed-off-by: Heiko Schocher <hs@denx.de>
Showing 3 changed files with 65 additions and 0 deletions Side-by-side Diff
README
... | ... | @@ -2855,6 +2855,26 @@ |
2855 | 2855 | The signing part is build into mkimage regardless of this |
2856 | 2856 | option. |
2857 | 2857 | |
2858 | +- bootcount support: | |
2859 | + CONFIG_BOOTCOUNT_LIMIT | |
2860 | + | |
2861 | + This enables the bootcounter support, see: | |
2862 | + http://www.denx.de/wiki/DULG/UBootBootCountLimit | |
2863 | + | |
2864 | + CONFIG_AT91SAM9XE | |
2865 | + enable special bootcounter support on at91sam9xe based boards. | |
2866 | + CONFIG_BLACKFIN | |
2867 | + enable special bootcounter support on blackfin based boards. | |
2868 | + CONFIG_SOC_DA8XX | |
2869 | + enable special bootcounter support on da850 based boards. | |
2870 | + CONFIG_BOOTCOUNT_RAM | |
2871 | + enable support for the bootcounter in RAM | |
2872 | + CONFIG_BOOTCOUNT_I2C | |
2873 | + enable support for the bootcounter on an i2c (like RTC) device. | |
2874 | + CONFIG_SYS_I2C_RTC_ADDR = i2c chip address | |
2875 | + CONFIG_SYS_BOOTCOUNT_ADDR = i2c addr which is used for | |
2876 | + the bootcounter. | |
2877 | + CONFIG_BOOTCOUNT_ALEN = address len | |
2858 | 2878 | |
2859 | 2879 | - Show boot progress: |
2860 | 2880 | CONFIG_SHOW_BOOT_PROGRESS |
drivers/bootcount/Makefile
drivers/bootcount/bootcount_i2c.c
1 | +/* | |
2 | + * (C) Copyright 2013 | |
3 | + * Heiko Schocher, DENX Software Engineering, hs@denx.de. | |
4 | + * | |
5 | + * SPDX-License-Identifier: GPL-2.0+ | |
6 | + */ | |
7 | + | |
8 | +#include <bootcount.h> | |
9 | +#include <linux/compiler.h> | |
10 | +#include <i2c.h> | |
11 | + | |
12 | +#define BC_MAGIC 0xbc | |
13 | + | |
14 | +void bootcount_store(ulong a) | |
15 | +{ | |
16 | + unsigned char buf[3]; | |
17 | + int ret; | |
18 | + | |
19 | + buf[0] = BC_MAGIC; | |
20 | + buf[1] = (a & 0xff); | |
21 | + ret = i2c_write(CONFIG_SYS_I2C_RTC_ADDR, CONFIG_SYS_BOOTCOUNT_ADDR, | |
22 | + CONFIG_BOOTCOUNT_ALEN, buf, 2); | |
23 | + if (ret != 0) | |
24 | + puts("Error writing bootcount\n"); | |
25 | +} | |
26 | + | |
27 | +ulong bootcount_load(void) | |
28 | +{ | |
29 | + unsigned char buf[3]; | |
30 | + int ret; | |
31 | + | |
32 | + ret = i2c_read(CONFIG_SYS_I2C_RTC_ADDR, CONFIG_SYS_BOOTCOUNT_ADDR, | |
33 | + CONFIG_BOOTCOUNT_ALEN, buf, 2); | |
34 | + if (ret != 0) { | |
35 | + puts("Error loading bootcount\n"); | |
36 | + return 0; | |
37 | + } | |
38 | + if (buf[0] == BC_MAGIC) | |
39 | + return buf[1]; | |
40 | + | |
41 | + bootcount_store(0); | |
42 | + | |
43 | + return 0; | |
44 | +} |