Silvestrs Timofejevs | 590e297 | 2020-11-02 10:44:04 +0000 | [diff] [blame] | 1 | // 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 Maturana | 736a94d | 2021-11-01 17:13:51 -0700 | [diff] [blame] | 8 | #include "sw/device/lib/testing/rstmgr_testutils.h" |
Timothy Trippel | a6412d2 | 2021-11-23 20:13:04 +0000 | [diff] [blame] | 9 | #include "sw/device/lib/testing/test_framework/ottf.h" |
Silvestrs Timofejevs | 590e297 | 2020-11-02 10:44:04 +0000 | [diff] [blame] | 10 | |
Timothy Trippel | c3e76d0 | 2021-08-28 05:35:26 +0000 | [diff] [blame] | 11 | #include "hw/top_earlgrey/sw/autogen/top_earlgrey.h" |
Silvestrs Timofejevs | 590e297 | 2020-11-02 10:44:04 +0000 | [diff] [blame] | 12 | |
Silvestrs Timofejevs | 590e297 | 2020-11-02 10:44:04 +0000 | [diff] [blame] | 13 | const test_config_t kTestConfig; |
| 14 | |
Guillermo Maturana | 736a94d | 2021-11-01 17:13:51 -0700 | [diff] [blame] | 15 | // 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 Timofejevs | 590e297 | 2020-11-02 10:44:04 +0000 | [diff] [blame] | 18 | bool test_main(void) { |
Guillermo Maturana | 736a94d | 2021-11-01 17:13:51 -0700 | [diff] [blame] | 19 | dif_rstmgr_t rstmgr; |
Timothy Trippel | b654aa8 | 2021-10-01 23:56:10 +0000 | [diff] [blame] | 20 | CHECK_DIF_OK(dif_rstmgr_init( |
| 21 | mmio_region_from_addr(TOP_EARLGREY_RSTMGR_AON_BASE_ADDR), &rstmgr)); |
Silvestrs Timofejevs | 590e297 | 2020-11-02 10:44:04 +0000 | [diff] [blame] | 22 | |
Guillermo Maturana | 736a94d | 2021-11-01 17:13:51 -0700 | [diff] [blame] | 23 | 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 Timofejevs | 590e297 | 2020-11-02 10:44:04 +0000 | [diff] [blame] | 26 | |
| 27 | return true; |
| 28 | } |