| /* |
| * Copyright (c) 2020 The Fuchsia Authors |
| * |
| * SPDX-License-Identifier: BSD-3-Clause |
| */ |
| |
| #include <zircon/zircon_abr_reg_util.h> |
| |
| abr_sticky_reg1_t read_sticky_reg1() |
| { |
| abr_sticky_reg1_t sticky_reg1; |
| sticky_reg1.value = readl(P_AO_RTI_STICKY_REG1); |
| return sticky_reg1; |
| } |
| |
| abr_sticky_reg0_t read_sticky_reg0() |
| { |
| abr_sticky_reg0_t sticky_reg0; |
| sticky_reg0.value = readl(P_AO_RTI_STICKY_REG0); |
| return sticky_reg0; |
| } |
| |
| void write_sticky_reg1(abr_sticky_reg1_t reg1) |
| { |
| writel(reg1.value, P_AO_RTI_STICKY_REG1); |
| } |
| |
| void write_sticky_reg0(abr_sticky_reg0_t reg0) |
| { |
| writel(reg0.value, P_AO_RTI_STICKY_REG0); |
| } |
| |
| void set_force_recovery_bit(bool val) |
| { |
| abr_sticky_reg0_t reg0 = read_sticky_reg0(); |
| reg0.fields.force_recovery = val; |
| write_sticky_reg0(reg0); |
| } |
| |
| // The flag indicates whether this boot is due to force recovery. |
| bool force_recovery_mode_flag = false; |
| |
| void set_force_recovery_mode(bool val) |
| { |
| force_recovery_mode_flag = val; |
| } |
| |
| bool force_recovery_mode(void) |
| { |
| return force_recovery_mode_flag; |
| } |
| |
| void set_abr_sticky_reg_rebootmode(uint8_t value) |
| { |
| abr_sticky_reg0_t reg0 = read_sticky_reg0(); |
| reg0.fields.rebootmode = value; |
| write_sticky_reg0(reg0); |
| } |
| |
| bool force_recovery_bit_set(void) |
| { |
| return read_sticky_reg0().fields.force_recovery; |
| } |