| // Copyright 2022 Google LLC. |
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| // SPDX-License-Identifier: Apache-2.0 |
| |
| #include "sw/device/lib/dif/dif_smc_ctrl.h" |
| |
| #include <stddef.h> |
| |
| #include "sw/device/lib/base/bitfield.h" |
| #include "sw/device/lib/base/macros.h" |
| #include "sw/device/lib/dif/dif_base.h" |
| |
| #include "smc_ctrl_regs.h" // Generated. |
| |
| |
| dif_result_t dif_smc_ctrl_set_regwen(const dif_smc_ctrl_t *smc_ctrl) { |
| |
| if (smc_ctrl == NULL) { |
| return kDifBadArg; |
| } |
| |
| mmio_region_write32(smc_ctrl->base_addr, SMC_CTRL_SMC_BOOT_EN_REGWEN_REG_OFFSET, 1); |
| return kDifOk; |
| } |
| |
| dif_result_t dif_smc_ctrl_clear_regwen(const dif_smc_ctrl_t *smc_ctrl) { |
| |
| if (smc_ctrl == NULL) { |
| return kDifBadArg; |
| } |
| |
| mmio_region_write32(smc_ctrl->base_addr, SMC_CTRL_SMC_BOOT_EN_REGWEN_REG_OFFSET, 0); |
| return kDifOk; |
| } |
| |
| dif_result_t dif_smc_ctrl_read_regwen(const dif_smc_ctrl_t *smc_ctrl, uint32_t *result) { |
| |
| if (smc_ctrl == NULL) { |
| return kDifBadArg; |
| } |
| |
| *result = mmio_region_read32(smc_ctrl->base_addr, SMC_CTRL_SMC_BOOT_EN_REGWEN_REG_OFFSET); |
| return kDifOk; |
| } |
| |
| dif_result_t dif_smc_ctrl_set_en(const dif_smc_ctrl_t *smc_ctrl) { |
| |
| if (smc_ctrl == NULL) { |
| return kDifBadArg; |
| } |
| |
| mmio_region_write32(smc_ctrl->base_addr, SMC_CTRL_SMC_BOOT_EN_CTRL_REG_OFFSET, 1); |
| return kDifOk; |
| } |
| |
| dif_result_t dif_smc_ctrl_clear_en(const dif_smc_ctrl_t *smc_ctrl) { |
| |
| if (smc_ctrl == NULL) { |
| return kDifBadArg; |
| } |
| |
| mmio_region_write32(smc_ctrl->base_addr, SMC_CTRL_SMC_BOOT_EN_CTRL_REG_OFFSET, 0); |
| return kDifOk; |
| } |
| |
| dif_result_t dif_smc_ctrl_read_en(const dif_smc_ctrl_t *smc_ctrl, uint32_t *result) { |
| |
| if (smc_ctrl == NULL) { |
| return kDifBadArg; |
| } |
| |
| *result = mmio_region_read32(smc_ctrl->base_addr, SMC_CTRL_SMC_BOOT_EN_CTRL_REG_OFFSET); |
| return kDifOk; |
| } |
| |