blob: 0c16c855322713228f721fe37a6e0f733cf0e6f5 [file] [log] [blame]
Silvestrs Timofejevs590e2972020-11-02 10:44:04 +00001// Copyright lowRISC contributors.
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5#include "sw/device/lib/base/mmio.h"
6#include "sw/device/lib/dif/dif_rstmgr.h"
7#include "sw/device/lib/testing/check.h"
Guillermo Maturana736a94d2021-11-01 17:13:51 -07008#include "sw/device/lib/testing/rstmgr_testutils.h"
Timothy Trippela6412d22021-11-23 20:13:04 +00009#include "sw/device/lib/testing/test_framework/ottf.h"
Silvestrs Timofejevs590e2972020-11-02 10:44:04 +000010
Timothy Trippelc3e76d02021-08-28 05:35:26 +000011#include "hw/top_earlgrey/sw/autogen/top_earlgrey.h"
Silvestrs Timofejevs590e2972020-11-02 10:44:04 +000012
Silvestrs Timofejevs590e2972020-11-02 10:44:04 +000013const test_config_t kTestConfig;
14
Guillermo Maturana736a94d2021-11-01 17:13:51 -070015// The SV side will flip POR_N and cause some AON power glitches prior to the
16// start of test_main. Both of these cause a new POR, so all this has to do is
17// check that the `reset_info` CSR is POR.
Silvestrs Timofejevs590e2972020-11-02 10:44:04 +000018bool test_main(void) {
Guillermo Maturana736a94d2021-11-01 17:13:51 -070019 dif_rstmgr_t rstmgr;
Timothy Trippelb654aa82021-10-01 23:56:10 +000020 CHECK_DIF_OK(dif_rstmgr_init(
21 mmio_region_from_addr(TOP_EARLGREY_RSTMGR_AON_BASE_ADDR), &rstmgr));
Silvestrs Timofejevs590e2972020-11-02 10:44:04 +000022
Guillermo Maturana736a94d2021-11-01 17:13:51 -070023 LOG_INFO("Checking reset status.");
24 rstmgr_testutils_post_reset(&rstmgr, kDifRstmgrResetInfoPor, 0, 0, 0, 0);
25 LOG_INFO("Reset status indicates a POR");
Silvestrs Timofejevs590e2972020-11-02 10:44:04 +000026
27 return true;
28}