Skip to content

Commit

Permalink
[nrf fromlist] tests: drivers: clock_control: nrf: add global hsfll c…
Browse files Browse the repository at this point in the history
…lock

Extend test suite to test global HSFLL clock.

Upstream PR #: 81735

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
  • Loading branch information
bjarki-andreasen committed Nov 27, 2024
1 parent 7ed03c0 commit ec280d5
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions tests/drivers/clock_control/nrf_clock_control/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,37 @@ static const struct test_clk_context cpurad_hsfll_test_clk_contexts[] = {
};
#endif

const struct nrf_clock_spec test_clk_specs_global_hsfll[] = {
{
.frequency = MHZ(320),
.accuracy = 0,
.precision = NRF_CLOCK_CONTROL_PRECISION_DEFAULT,
},
{
.frequency = MHZ(256),
.accuracy = 0,
.precision = NRF_CLOCK_CONTROL_PRECISION_DEFAULT,
},
{
.frequency = MHZ(128),
.accuracy = 0,
.precision = NRF_CLOCK_CONTROL_PRECISION_DEFAULT,
},
{
.frequency = MHZ(64),
.accuracy = 0,
.precision = NRF_CLOCK_CONTROL_PRECISION_DEFAULT,
},
};

static const struct test_clk_context global_hsfll_test_clk_contexts[] = {
{
.clk_dev = DEVICE_DT_GET(DT_NODELABEL(hsfll120)),
.clk_specs = test_clk_specs_global_hsfll,
.clk_specs_size = ARRAY_SIZE(test_clk_specs_global_hsfll),
},
};

const struct nrf_clock_spec test_clk_specs_lfclk[] = {
{
.frequency = 32768,
Expand Down Expand Up @@ -151,8 +182,10 @@ static void test_request_release_clock_spec(const struct device *clk_dev,
zassert_ok(ret);
zassert_ok(res);
ret = clock_control_get_rate(clk_dev, NULL, &rate);
zassert_ok(ret);
zassert_equal(rate, clk_spec->frequency);
if (ret != -ENOSYS) {
zassert_ok(ret);
zassert_equal(rate, clk_spec->frequency);
}
k_msleep(1000);
ret = nrf_clock_control_release(clk_dev, clk_spec);
zassert_equal(ret, ONOFF_STATE_ON);
Expand Down Expand Up @@ -249,6 +282,13 @@ ZTEST(nrf2_clock_control, test_lfclk_control)
test_clock_control_request(lfclk_test_clk_contexts, ARRAY_SIZE(lfclk_test_clk_contexts));
}

ZTEST(nrf2_clock_control, test_global_hsfll_control)
{
TC_PRINT("Global HSFLL test\n");
test_clock_control_request(global_hsfll_test_clk_contexts,
ARRAY_SIZE(global_hsfll_test_clk_contexts));
}

ZTEST(nrf2_clock_control, test_safe_request_cancellation)
{
int ret = 0;
Expand Down

0 comments on commit ec280d5

Please sign in to comment.