Skip to content

Commit bd5aefb

Browse files
Hi-Im-Davidkartben
authored andcommitted
tests: drivers: Update nrf2 clock control tests for nrf2_auxpll driver
Test added for new nrf2_auxpll driver. Frequency checks are against known usecases of the auxpll (USB, CAN and AUDIO). Also update test to be more modular, only running certain tests if in the devicetree. Signed-off-by: David Jewsbury <david.jewsbury@nordicsemi.no>
1 parent 9087e82 commit bd5aefb

File tree

1 file changed

+64
-5
lines changed
  • tests/drivers/clock_control/nrf_clock_control/src

1 file changed

+64
-5
lines changed

tests/drivers/clock_control/nrf_clock_control/src/main.c

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
1010
#include <zephyr/kernel.h>
1111
#include <zephyr/ztest.h>
12+
#include <zephyr/dt-bindings/clock/nrf-auxpll.h>
1213

1314
struct test_clk_context {
1415
const struct device *clk_dev;
1516
const struct nrf_clock_spec *clk_specs;
1617
size_t clk_specs_size;
1718
};
1819

20+
#if defined(CONFIG_CLOCK_CONTROL_NRF_HSFLL_LOCAL)
1921
const struct nrf_clock_spec test_clk_specs_hsfll[] = {
2022
{
2123
.frequency = MHZ(128),
@@ -33,6 +35,7 @@ const struct nrf_clock_spec test_clk_specs_hsfll[] = {
3335
.precision = NRF_CLOCK_CONTROL_PRECISION_DEFAULT,
3436
},
3537
};
38+
#endif
3639

3740
#if CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUAPP
3841
const struct nrf_clock_spec test_clk_specs_fll16m[] = {
@@ -99,6 +102,7 @@ static const struct test_clk_context cpurad_hsfll_test_clk_contexts[] = {
99102
};
100103
#endif
101104

105+
#if defined(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL)
102106
const struct nrf_clock_spec test_clk_specs_global_hsfll[] = {
103107
{
104108
.frequency = MHZ(320),
@@ -121,7 +125,9 @@ static const struct test_clk_context global_hsfll_test_clk_contexts[] = {
121125
.clk_specs_size = ARRAY_SIZE(test_clk_specs_global_hsfll),
122126
},
123127
};
128+
#endif
124129

130+
#if defined(CONFIG_CLOCK_CONTROL_NRF_LFCLK)
125131
const struct nrf_clock_spec test_clk_specs_lfclk[] = {
126132
{
127133
.frequency = 32768,
@@ -147,6 +153,44 @@ static const struct test_clk_context lfclk_test_clk_contexts[] = {
147153
.clk_specs_size = ARRAY_SIZE(test_clk_specs_lfclk),
148154
},
149155
};
156+
#endif
157+
158+
#if defined(CONFIG_CLOCK_CONTROL_NRF_AUXPLL)
159+
160+
#define AUXPLL_COMPAT nordic_nrf_auxpll
161+
#define AUXPLL_NODE DT_INST(0, AUXPLL_COMPAT)
162+
#define AUXPLL_FREQ DT_PROP(AUXPLL_NODE, nordic_frequency)
163+
164+
/* Gets selected AUXPLL DIV and selects the expected frequency */
165+
#if AUXPLL_FREQ == NRF_AUXPLL_FREQUENCY_DIV_MIN
166+
#define AUXPLL_FREQ_OUT 80000000
167+
#elif AUXPLL_FREQ == NRF_AUXPLL_FREQ_DIV_AUDIO_44K1
168+
#define AUXPLL_FREQ_OUT 11289591
169+
#elif AUXPLL_FREQ == NRF_AUXPLL_FREQ_DIV_USB_24M
170+
#define AUXPLL_FREQ_OUT 24000000
171+
#elif AUXPLL_FREQ == NRF_AUXPLL_FREQ_DIV_AUDIO_48K
172+
#define AUXPLL_FREQ_OUT 12287963
173+
#else
174+
/*No use case for NRF_AUXPLL_FREQ_DIV_MAX or others yet*/
175+
#error "Unsupported AUXPLL frequency selection"
176+
#endif
177+
178+
const struct nrf_clock_spec test_clk_specs_auxpll[] = {
179+
{
180+
.frequency = AUXPLL_FREQ_OUT,
181+
.accuracy = 0,
182+
.precision = NRF_CLOCK_CONTROL_PRECISION_DEFAULT,
183+
},
184+
};
185+
186+
static const struct test_clk_context auxpll_test_clk_contexts[] = {
187+
{
188+
.clk_dev = DEVICE_DT_GET(AUXPLL_NODE),
189+
.clk_specs = test_clk_specs_auxpll,
190+
.clk_specs_size = ARRAY_SIZE(test_clk_specs_auxpll),
191+
},
192+
};
193+
#endif
150194

151195
static void test_request_release_clock_spec(const struct device *clk_dev,
152196
const struct nrf_clock_spec *clk_spec)
@@ -266,18 +310,23 @@ ZTEST(nrf2_clock_control, test_cpurad_hsfll_control)
266310
}
267311
#endif
268312

269-
ZTEST(nrf2_clock_control, test_lfclk_control)
270-
{
271-
TC_PRINT("LFCLK test\n");
272-
test_clock_control_request(lfclk_test_clk_contexts, ARRAY_SIZE(lfclk_test_clk_contexts));
273-
}
274313

314+
315+
#if defined(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL)
275316
ZTEST(nrf2_clock_control, test_global_hsfll_control)
276317
{
277318
TC_PRINT("Global HSFLL test\n");
278319
test_clock_control_request(global_hsfll_test_clk_contexts,
279320
ARRAY_SIZE(global_hsfll_test_clk_contexts));
280321
}
322+
#endif
323+
324+
#if defined(CONFIG_CLOCK_CONTROL_NRF_LFCLK)
325+
ZTEST(nrf2_clock_control, test_lfclk_control)
326+
{
327+
TC_PRINT("LFCLK test\n");
328+
test_clock_control_request(lfclk_test_clk_contexts, ARRAY_SIZE(lfclk_test_clk_contexts));
329+
}
281330

282331
ZTEST(nrf2_clock_control, test_safe_request_cancellation)
283332
{
@@ -303,6 +352,16 @@ ZTEST(nrf2_clock_control, test_safe_request_cancellation)
303352
TC_PRINT("Clock control safe cancellation return value: %d\n", ret);
304353
zassert_between_inclusive(ret, ONOFF_STATE_ON, ONOFF_STATE_TO_ON);
305354
}
355+
#endif
356+
357+
#if defined(CONFIG_CLOCK_CONTROL_NRF_AUXPLL)
358+
ZTEST(nrf2_clock_control, test_auxpll_control)
359+
{
360+
TC_PRINT("AUXPLL control test\n");
361+
test_clock_control_request(auxpll_test_clk_contexts,
362+
ARRAY_SIZE(auxpll_test_clk_contexts));
363+
}
364+
#endif
306365

307366
static void *setup(void)
308367
{

0 commit comments

Comments
 (0)