15 #include "sw/device/lib/testing/aon_timer_testutils.h"
16 #include "sw/device/lib/testing/pwrmgr_testutils.h"
17 #include "sw/device/lib/testing/rstmgr_testutils.h"
18 #include "sw/device/lib/testing/test_framework/check.h"
23 OTTF_DEFINE_TEST_CONFIG();
28 static void config_wdog(
const dif_aon_timer_t *aon_timer,
29 const dif_pwrmgr_t *pwrmgr, uint64_t bark_time_us,
30 uint64_t bite_time_us) {
31 uint32_t bark_cycles = 0;
32 CHECK_STATUS_OK(aon_timer_testutils_get_aon_cycles_32_from_us(bark_time_us,
34 uint32_t bite_cycles = 0;
35 CHECK_STATUS_OK(aon_timer_testutils_get_aon_cycles_32_from_us(bite_time_us,
38 LOG_INFO(
"Wdog will bark after %u us and bite after %u us",
39 (uint32_t)bark_time_us, (uint32_t)bite_time_us);
43 kDifPwrmgrResetRequestSourceTwo,
47 CHECK_STATUS_OK(aon_timer_testutils_watchdog_config(aon_timer, bark_cycles,
54 static void wdog_bite_test(
const dif_aon_timer_t *aon_timer,
55 const dif_pwrmgr_t *pwrmgr, uint32_t bark_time_us) {
56 uint64_t bite_time_us = bark_time_us * 2;
57 config_wdog(aon_timer, pwrmgr, bark_time_us, bite_time_us);
67 bool is_pending =
false;
68 CHECK_DIF_OK(dif_aon_timer_irq_is_pending(
69 aon_timer, kDifAonTimerIrqWdogTimerBark, &is_pending));
70 CHECK(is_pending,
"Wdog bark irq did not rise after %u microseconds",
76 CHECK(
false,
"Timeout waiting for Wdog bite reset!");
82 CHECK_DIF_OK(dif_pwrmgr_init(
87 CHECK_DIF_OK(dif_rstmgr_init(
91 dif_aon_timer_t aon_timer;
92 CHECK_DIF_OK(dif_aon_timer_init(
97 rst_info = rstmgr_testutils_reason_get();
98 rstmgr_testutils_reason_clear();
101 rst_info == kDifRstmgrResetInfoWatchdog,
102 "Wrong reset reason %02X", rst_info);
105 LOG_INFO(
"Booting for the first time, setting wdog");
107 wdog_bite_test(&aon_timer, &pwrmgr, 200);
108 }
else if (rst_info == kDifRstmgrResetInfoWatchdog) {
109 LOG_INFO(
"Booting for the second time due to wdog bite reset");
113 LOG_ERROR(
"Got unexpected reset info 0x%x", rst_info);