5#include "sw/device/silicon_creator/lib/drivers/retention_sram.h"
9#include "hw/top/dt/sram_ctrl.h"
13#include "hw/top/sram_ctrl_regs.h"
17retention_sram_t *retention_sram_get(
void) {
19 kDtSramCtrlMemoryRam);
22void retention_sram_clear(
void) {
23 memset(retention_sram_get(), 0,
sizeof(retention_sram_t));
26void retention_sram_init(
void) {
27 uint32_t reg = bitfield_bit32_write(0, SRAM_CTRL_CTRL_INIT_BIT,
true);
28 uint32_t base = dt_sram_ctrl_primary_reg_block(kSramCtrlDt);
29 abs_mmio_write32(base + SRAM_CTRL_CTRL_REG_OFFSET, reg);
32void retention_sram_readback_enable(uint32_t en) {
33 uint32_t base = dt_sram_ctrl_primary_reg_block(kSramCtrlDt);
34 abs_mmio_write32(base + SRAM_CTRL_READBACK_REG_OFFSET, en);
37void retention_sram_scramble(
void) {
41 ctrl = bitfield_bit32_write(ctrl, SRAM_CTRL_CTRL_RENEW_SCR_KEY_BIT,
true);
42 ctrl = bitfield_bit32_write(ctrl, SRAM_CTRL_CTRL_INIT_BIT,
true);
43 uint32_t base = dt_sram_ctrl_primary_reg_block(kSramCtrlDt);
44 abs_mmio_write32(base + SRAM_CTRL_CTRL_REG_OFFSET, ctrl);
47rom_error_t retention_sram_check_version(
void) {
48 retention_sram_t *rr = retention_sram_get();
50 case kRetentionSramVersion1:
52 rr->
version = kRetentionSramVersion4;
54 case kRetentionSramVersion4:
57 case kRetentionSramVersion3:
58 case kRetentionSramVersion2:
62 return kErrorRetRamBadVersion;
68extern retention_sram_t *retention_sram_get(
void);