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;
29 static const dt_pwrmgr_t kPwrmgrDt = 0;
30 static_assert(kDtPwrmgrCount == 1,
"this test expects a pwrmgr");
31 static const dt_pinmux_t kPinmuxDt = 0;
32 static_assert(kDtPinmuxCount == 1,
"this test expects a pinmux");
33 static const dt_rstmgr_t kRstmgrDt = 0;
34 static_assert(kDtRstmgrCount == 1,
"this test expects a rstmgr");
35 static const dt_sysrst_ctrl_t kSysrstCtrlDt = 0;
36 static_assert(kDtSysrstCtrlCount == 1,
"this test expects a sysrst_ctrl");
58 kDetectionTimeThreshold = 1024,
59 kEcResetStretchDurationMicros = 200 * 1000,
60 kDebounceTimeThreshold = 128,
65 static void pinmux_setup(
void) {
66 for (
int i = 0; i < kNumMioInputs; ++i) {
72 static void configure_combo_reset(
void) {
77 .detection_time_threshold = kDetectionTimeThreshold,
78 .embedded_controller_reset_duration = 0,
83 .debounce_time_threshold = kDebounceTimeThreshold,
90 dt_sysrst_ctrl_instance_id(kSysrstCtrlDt), kDtSysrstCtrlResetReqRstReq,
92 CHECK_STATUS_OK(rstmgr_testutils_pre_reset(&rstmgr));
96 LOG_INFO(
"wait for combo (key0&1 low)");
97 test_status_set(kTestStatusInWfi);
102 CHECK_DIF_OK(dif_pinmux_init_from_dt(kPinmuxDt, &pinmux));
103 CHECK_DIF_OK(dif_sysrst_ctrl_init_from_dt(kSysrstCtrlDt, &sysrst_ctrl));
104 CHECK_DIF_OK(dif_pwrmgr_init_from_dt(kPwrmgrDt, &pwrmgr));
105 CHECK_DIF_OK(dif_rstmgr_init_from_dt(kRstmgrDt, &rstmgr));
108 sysrst_ctrl_testutils_setup_dio(&pinmux);
109 rstmgr_reset_info = rstmgr_testutils_reason_get();
114 sysrst_ctrl_testutils_release_dio(&sysrst_ctrl,
true,
true);
115 configure_combo_reset();
116 LOG_ERROR(
"We should have reset before this line.");
119 CHECK(rstmgr_reset_info == kDifRstmgrResetInfoSysRstCtrl);
122 LOG_INFO(
"wait for key0 to go high");
123 test_status_set(kTestStatusInWfi);
124 bool key0_up =
false;
130 LOG_INFO(
"releasing ec_rst and flash_wp");
132 sysrst_ctrl_testutils_set_ec_rst_pulse_width(&sysrst_ctrl, 0);
133 sysrst_ctrl_testutils_release_dio(&sysrst_ctrl,
true,
true);
136 sysrst_ctrl_testutils_set_ec_rst_pulse_width(&sysrst_ctrl,
137 kEcResetStretchDurationMicros);
138 test_status_set(kTestStatusInWfi);