12 #include "sw/device/lib/testing/rstmgr_testutils.h"
13 #include "sw/device/lib/testing/sysrst_ctrl_testutils.h"
14 #include "sw/device/lib/testing/test_framework/check.h"
21 OTTF_DEFINE_TEST_CONFIG(.enable_uart_flow_control =
true);
23 static dif_pinmux_t pinmux;
24 static dif_sysrst_ctrl_t sysrst_ctrl;
25 static dif_pwrmgr_t pwrmgr;
26 static dif_rstmgr_t rstmgr;
49 kDetectionTimeThreshold = 1024,
50 kEcResetStretchDurationMicros = 200 * 1000,
51 kDebounceTimeThreshold = 128,
56 static void pinmux_setup(
void) {
57 for (
int i = 0; i < kNumMioInputs; ++i) {
63 static void configure_combo_reset(
void) {
68 .detection_time_threshold = kDetectionTimeThreshold,
69 .embedded_controller_reset_duration = 0,
74 .debounce_time_threshold = kDebounceTimeThreshold,
78 CHECK_STATUS_OK(rstmgr_testutils_pre_reset(&rstmgr));
80 kDifPwrmgrResetRequestSourceOne,
83 LOG_INFO(
"wait for combo (key0&1 low)");
84 test_status_set(kTestStatusInWfi);
89 CHECK_DIF_OK(dif_pinmux_init(
91 CHECK_DIF_OK(dif_sysrst_ctrl_init(
94 CHECK_DIF_OK(dif_pwrmgr_init(
96 CHECK_DIF_OK(dif_rstmgr_init(
100 sysrst_ctrl_testutils_setup_dio(&pinmux);
101 rstmgr_reset_info = rstmgr_testutils_reason_get();
106 sysrst_ctrl_testutils_release_dio(&sysrst_ctrl,
true,
true);
107 configure_combo_reset();
108 LOG_ERROR(
"We should have reset before this line.");
111 CHECK(rstmgr_reset_info == kDifRstmgrResetInfoSysRstCtrl);
114 LOG_INFO(
"wait for key0 to go high");
115 test_status_set(kTestStatusInWfi);
116 bool key0_up =
false;
122 LOG_INFO(
"releasing ec_rst and flash_wp");
124 sysrst_ctrl_testutils_set_ec_rst_pulse_width(&sysrst_ctrl, 0);
125 sysrst_ctrl_testutils_release_dio(&sysrst_ctrl,
true,
true);
128 sysrst_ctrl_testutils_set_ec_rst_pulse_width(&sysrst_ctrl,
129 kEcResetStretchDurationMicros);
130 test_status_set(kTestStatusInWfi);