I'm interested in porting the bootcount feature in u-boot to the TI AM62x SoC. The AM62x appears to take inspiration from its predecessor, the popular AM33x. Both SoCs have an RTC register block with a few "SCRATCH" registers that survive chip reset.
U-boot has explicit support for the AM33 RTC (bootcount_davinci.c).
Also, I've confirmed that on an AM625 I can indeed unlock the RTCSS block then write to SCRATCH2
from Linux userspace, and confirmed the value survives chip reset:
Options:
Certainly I could transliterate the bootcount_davinci.c implementation and change the register addresses and KICK magic numbers. However u-boot supports several more generic bootcount models including "MEM", and "RTC." I don't yet understand these well enough to know if either of those drivers can support the AM62x scratch register, and I haven't yet found any examples of their use in mainline .dts files. So I'm hoping someone with familiarity with modern u-boot development could point me in the right direction.
The TI E2E forums have little discussion on the topic.
I think the davinci driver may be considered legacy at this point, and I imagine using the RTC driver - assuming it can support the AM62x - would be preferable vs adding a new SoC-specific driver. So my question may just be "how would one configure the bootcount-rtc driver for AM62x?"