Skip to content

Bootcount driver using NVMEM cell as backend.

Nandor Han linux-devicetree lkml 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest4 patches 5 repliesIn review
  2. v34 patches 0 repliesSuperseded
  3. v24 patches 3 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v14 patches2 repliesSuperseded

Changes in v4 from the cover letter

----------------
- Remove the dependencies from the bindings documentation
- Fix the bootcount-magic description from bindings documentation

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4dt-bindings: nvmem: Add bootcount-nvmemDocumentation/devicetree/bindings/nvmem/bootcount-nvmem.yaml+71 -00 replies
2/4nvmem: bootcount: add bootcount driverdrivers/nvmem/Kconfig drivers/nvmem/Makefile drivers/nvmem/bootcount-nvmem.c+206 -04 replies
3/4nvmem: snvs_lpgpr: use cell stride for regmap size calculationdrivers/nvmem/snvs_lpgpr.c+3 -30 replies
4/4nvmem: snvs_lpgpr: support two bytes NVMEM cell sizedrivers/nvmem/snvs_lpgpr.c+61 -60 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH v4 0/4] Bootcount driver using NVMEM cell as backend.

Description
-----------
Implement a bootcount (1) related driver that uses NVMEM as a backend. The patchset will also update the snvs_lpgpr driver to support 2 bytes NVMEM cells.

1. https://www.denx.de/wiki/view/DULG/UBootBootCountLimit

Testing
-------
Hardware: i.MX6sx evaluation board
Kernel: linux-imx-5.4.24

1. Configure the bootcount hardware in DT to use a NVMEM cell provided by snvs_lpgpr driver as backend.
e.g. This will configure a 4 bytes long NVMEM cell

```
  bootcount_regs: bootcount-snvs-regs@0 {
      reg = <0x0 0x04>;
  };
```

2. Record the current NVMEM cell content:

```
~ # hexdump -C
/sys/devices/soc0/soc/2000000.aips-bus/20cc000.snvs/20cc000.snvs:snvs-lpgpr/20cc000.snvs:snvs-lpgpr0/nvmem
00000000  00 00 01 b0                                       |....|
00000004
```

3. Write the bootcount and check that is successful: PASS

```
~ # echo 1 > /sys/bus/platform/drivers/bootcount-nvmem/bootcount/value
bootcount: Write regval: 0xb0010001
~ # hexdump -C
/sys/devices/soc0/soc/2000000.aips-bus/20cc000.snvs/20cc000.snvs:snvs-lpgpr/20cc000.snvs:snvs-lpgpr0/nvmem
00000000  01 00 01 b0                                       |....|
00000004
``` 

Note: similar tests were done also for 2 bytes NVMEM cell size.

Kernel: linux-next, tag: next-20210322
1. Enable bootcount and snvs_lpgpr drivers
2. Verify that they compile succesfully: PASS

```
kernel-master> make -j2 drivers/nvmem/
  DESCEND  objtool
  CALL    scripts/atomic/check-atomics.sh
  CC      arch/x86/kernel/asm-offsets.s
  CALL    scripts/checksyscalls.sh
  CC      drivers/nvmem/core.o
  CC      drivers/nvmem/bootcount-nvmem.o
  CC      drivers/nvmem/snvs_lpgpr.o
  AR      drivers/nvmem/built-in.
```

Testing the bootcount YAML document:
1. Check the document by running the command:
make DT_CHECKER_FLAGS=-m dt_binding_check
2. Verify that is successful: PASS
3. Verify that no warnings are generated by bootcount related yaml file: PASS

```
...
CHECK Documentation/devicetree/bindings/nvmem/brcm,nvram.example.dt.yaml                                                                      DTC Documentation/devicetree/bindings/nvmem/bootcount-nvmem.example.dt.yaml
CHECK Documentation/devicetree/bindings/nvmem/bootcount-nvmem.example.dt.yaml
DTC Documentation/devicetree/bindings/opp/allwinner,sun50i-h6-operating-points.example.dt.yaml
...
```

Changes since v1
----------------
- Fix the dt-bindings YAML document.

Changes since v2
----------------
- Fix the dt-bindings YAML document warnings.

Changes since v3
----------------
- Remove the dependencies from the bindings documentation
- Fix the bootcount-magic description from bindings documentation

Nandor Han (4):
dt-bindings: nvmem: Add bootcount-nvmem
nvmem: bootcount: add bootcount driver
nvmem: snvs_lpgpr: use cell stride for regmap size calculation
nvmem: snvs_lpgpr: support two bytes NVMEM cell size

 .../bindings/nvmem/bootcount-nvmem.yaml       |  71 +++++++
 drivers/nvmem/Kconfig                         |  10 +
 drivers/nvmem/Makefile                        |   1 +
 drivers/nvmem/bootcount-nvmem.c               | 195 ++++++++++++++++++
 drivers/nvmem/snvs_lpgpr.c                    |  67 +++++-
 5 files changed, 338 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/nvmem/bootcount-nvmem.yaml
 create mode 100644 drivers/nvmem/bootcount-nvmem.c
Signature · 1 line
2.26.3