5 #ifndef OPENTITAN_SW_DEVICE_LIB_TESTING_CLKMGR_TESTUTILS_H_
6 #define OPENTITAN_SW_DEVICE_LIB_TESTING_CLKMGR_TESTUTILS_H_
8 #include "sw/device/lib/base/status.h"
11 #include "sw/device/lib/testing/test_framework/check.h"
13 #define MODULE_ID MAKE_MODULE_ID('c', 'm', 'h')
23 static inline bool clkmgr_testutils_get_trans_clock_status(
46 inline status_t clkmgr_testutils_check_trans_clock_gating(
48 bool exp_clock_enabled, uint32_t timeout_usec) {
62 const char *clkmgr_testutils_measurement_name(dif_clkmgr_measure_clock_t clock);
76 status_t clkmgr_testutils_enable_clock_count(
const dif_clkmgr_t *clkmgr,
77 dif_clkmgr_measure_clock_t clock,
78 uint32_t lo_threshold,
79 uint32_t hi_threshold);
95 status_t clkmgr_testutils_enable_clock_counts_with_expected_thresholds(
96 const dif_clkmgr_t *clkmgr,
bool jitter_enabled,
bool external_clk,
106 status_t clkmgr_testutils_check_measurement_counts(
const dif_clkmgr_t *clkmgr);
118 status_t clkmgr_testutils_check_measurement_enables(
119 const dif_clkmgr_t *clkmgr,
dif_toggle_t expected_status);
128 status_t clkmgr_testutils_disable_clock_counts(
const dif_clkmgr_t *clkmgr);
138 status_t clkmgr_testutils_enable_external_clock_blocking(
139 const dif_clkmgr_t *clkmgr,
bool is_low_speed);
149 #define CLKMGR_TESTUTILS_CHECK_CLOCK_HINT(clkmgr, clock_id, expected_state) \
151 dif_toggle_t clock_state; \
152 TRY(dif_clkmgr_hintable_clock_get_enabled(&clkmgr, clock_id, \
154 TRY_CHECK(clock_state == expected_state, \
155 "Clock enabled state is (%d) and not as expected (%d).", \
156 clock_state, expected_state); \
176 #define CLKMGR_TESTUTILS_SET_AND_CHECK_CLOCK_HINT(clkmgr, clock_id, new_state, \
181 dif_result_t set_res = \
182 dif_clkmgr_hintable_clock_set_hint(&clkmgr, clock_id, new_state); \
183 dif_toggle_t hint_state; \
187 dif_result_t hint_get_res = \
188 dif_clkmgr_hintable_clock_get_hint(&clkmgr, clock_id, &hint_state); \
190 dif_toggle_t clock_state; \
191 dif_result_t get_res = dif_clkmgr_hintable_clock_get_enabled( \
192 &clkmgr, clock_id, &clock_state); \
196 TRY_CHECK(hint_state == new_state, \
197 "Clock hint state is (%d) and not as requested (%d).", \
198 hint_state, new_state); \
199 TRY_CHECK(clock_state == expected_state, \
200 "Clock enabled state is (%d) and not as expected (%d).", \
201 clock_state, expected_state); \