5#include "sw/device/silicon_creator/lib/drivers/retention_sram.h"
9#include "dt/dt_sram_ctrl.h"
13#include "sram_ctrl_regs.h"
17void retention_sram_clear(
void) {
18 memset(retention_sram_get(), 0,
sizeof(retention_sram_t));
21void retention_sram_init(
void) {
22 uint32_t reg = bitfield_bit32_write(0, SRAM_CTRL_CTRL_INIT_BIT,
true);
23 uint32_t base = dt_sram_ctrl_primary_reg_block(kSramCtrlDt);
24 abs_mmio_write32(base + SRAM_CTRL_CTRL_REG_OFFSET, reg);
27void retention_sram_readback_enable(uint32_t en) {
28 uint32_t base = dt_sram_ctrl_primary_reg_block(kSramCtrlDt);
29 abs_mmio_write32(base + SRAM_CTRL_READBACK_REG_OFFSET, en);
32void retention_sram_scramble(
void) {
36 ctrl = bitfield_bit32_write(ctrl, SRAM_CTRL_CTRL_RENEW_SCR_KEY_BIT,
true);
37 ctrl = bitfield_bit32_write(ctrl, SRAM_CTRL_CTRL_INIT_BIT,
true);
38 uint32_t base = dt_sram_ctrl_primary_reg_block(kSramCtrlDt);
39 abs_mmio_write32(base + SRAM_CTRL_CTRL_REG_OFFSET, ctrl);
42rom_error_t retention_sram_check_version(
void) {
43 retention_sram_t *rr = retention_sram_get();
45 case kRetentionSramVersion1:
47 rr->
version = kRetentionSramVersion4;
49 case kRetentionSramVersion4:
52 case kRetentionSramVersion3:
53 case kRetentionSramVersion2:
57 return kErrorRetRamBadVersion;
63extern retention_sram_t *retention_sram_get(
void);