Skip to contentSkip to conversation

bootcounter: add DM support for memory based bootcounter

PATCH New Heiko Schocher 2 participants 2 messages Mar 2, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bootcounter: add DM support for memory based bootcounter

add DM/DTS support for the memory based bootcounter in drivers/bootcount/bootcount.c.

Let the old implementation in, so boards which have not yet convert to DM/DTS do not break.

---
Travis build:
https://travis-ci.org/hsdenx/u-boot-test/builds/657150708

Changes in v2:
- add changes requested from Simon Glass
- add comment to struct bootcount_mem_priv
- change type of singleword from u8 to bool
- use dev_read_addr() and dev_read_bool()
- use "u-boot,bootcount" for compatible
string instead "uboot,bootcount"

 doc/device-tree-bindings/misc/bootcounter.txt | 21 +++++
 drivers/bootcount/Kconfig                     |  7 ++
 drivers/bootcount/Makefile                    |  1 +
 drivers/bootcount/bootcount.c                 | 92 +++++++++++++++++++
 4 files changed, 121 insertions(+)
 create mode 100644 doc/device-tree-bindings/misc/bootcounter.txt
doc/device-tree-bindings/misc/bootcounter.txt new file +21 -0
new file mode 100644
index 0000000000..d32fbc37b2
@@ -0,0 +1,21 @@
+U-Boot bootcounter Devicetree Binding
+=====================================
+
+The device tree node describes the U-Boot bootcounter
+memory based device binding.
+
+Required properties :
+
+- compatible : "u-boot,bootcount";
+- single-word : set this, if you have only one word space
+    for storing the bootcounter.
+
+Example
+-------
+
+MPC83xx based board:
+
+bootcount at 0x13ff8 {
+	compatible = "u-boot,bootcount";
+	reg = <0x13ff8 0x08>;
+};
drivers/bootcount/Kconfig +7 -0
index 0e506c9ea2..0356f8ba18 100644
@@ -106,6 +106,13 @@ config DM_BOOTCOUNT_I2C_EEPROM
 	  pointing to the underlying i2c eeprom device) and an optional 'offset'
 	  property are supported.
 
+config BOOTCOUNT_MEM
+	bool "Support memory based bootcounter"
+	help
+	  Enabling Memory based bootcount, typically in a SoC register which
+	  is not cleared on softreset.
+	  compatible = "u-boot,bootcount";
+
 endmenu
 
 endif
drivers/bootcount/Makefile +1 -0
index 73ccfb5a08..059d40d16b 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 obj-$(CONFIG_BOOTCOUNT_GENERIC)	+= bootcount.o
+obj-$(CONFIG_BOOTCOUNT_MEM)	+= bootcount.o
 obj-$(CONFIG_BOOTCOUNT_AT91)	+= bootcount_at91.o
 obj-$(CONFIG_BOOTCOUNT_AM33XX)	+= bootcount_davinci.o
 obj-$(CONFIG_BOOTCOUNT_RAM)	+= bootcount_ram.o
drivers/bootcount/bootcount.c +92 -0

101 lines not on this page · raw message

Signature · 1 line
2.24.1
#1 lore raw

PATCH v2 1/1 bootcounter: add DM support for memory based bootcounter

Quoted 20 lines · Heiko Schocher

add DM/DTS support for the memory based bootcounter in drivers/bootcount/bootcount.c.

Let the old implementation in, so boards which have not yet convert to DM/DTS do not break.

---
Travis build:
https://travis-ci.org/hsdenx/u-boot-test/builds/657150708

Changes in v2:
- add changes requested from Simon Glass
- add comment to struct bootcount_mem_priv
- change type of singleword from u8 to bool
- use dev_read_addr() and dev_read_bool()
- use "u-boot,bootcount" for compatible
string instead "uboot,bootcount"

Quoted 6 lines
 doc/device-tree-bindings/misc/bootcounter.txt | 21 +++++
 drivers/bootcount/Kconfig                     |  7 ++
 drivers/bootcount/Makefile                    |  1 +
 drivers/bootcount/bootcount.c                 | 92 +++++++++++++++++++
 4 files changed, 121 insertions(+)
 create mode 100644 doc/device-tree-bindings/misc/bootcounter.txt

Possible nit: dm.h could be included unconditionally