9
9
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
10
10
#include <zephyr/kernel.h>
11
11
#include <zephyr/ztest.h>
12
+ #include <zephyr/dt-bindings/clock/nrf-auxpll.h>
12
13
13
14
struct test_clk_context {
14
15
const struct device * clk_dev ;
15
16
const struct nrf_clock_spec * clk_specs ;
16
17
size_t clk_specs_size ;
17
18
};
18
19
20
+ #if defined(CONFIG_CLOCK_CONTROL_NRF_HSFLL_LOCAL )
19
21
const struct nrf_clock_spec test_clk_specs_hsfll [] = {
20
22
{
21
23
.frequency = MHZ (128 ),
@@ -33,6 +35,7 @@ const struct nrf_clock_spec test_clk_specs_hsfll[] = {
33
35
.precision = NRF_CLOCK_CONTROL_PRECISION_DEFAULT ,
34
36
},
35
37
};
38
+ #endif
36
39
37
40
#if CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUAPP
38
41
const struct nrf_clock_spec test_clk_specs_fll16m [] = {
@@ -99,6 +102,7 @@ static const struct test_clk_context cpurad_hsfll_test_clk_contexts[] = {
99
102
};
100
103
#endif
101
104
105
+ #if defined(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL )
102
106
const struct nrf_clock_spec test_clk_specs_global_hsfll [] = {
103
107
{
104
108
.frequency = MHZ (320 ),
@@ -121,7 +125,9 @@ static const struct test_clk_context global_hsfll_test_clk_contexts[] = {
121
125
.clk_specs_size = ARRAY_SIZE (test_clk_specs_global_hsfll ),
122
126
},
123
127
};
128
+ #endif
124
129
130
+ #if defined(CONFIG_CLOCK_CONTROL_NRF_LFCLK )
125
131
const struct nrf_clock_spec test_clk_specs_lfclk [] = {
126
132
{
127
133
.frequency = 32768 ,
@@ -147,6 +153,44 @@ static const struct test_clk_context lfclk_test_clk_contexts[] = {
147
153
.clk_specs_size = ARRAY_SIZE (test_clk_specs_lfclk ),
148
154
},
149
155
};
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
150
194
151
195
static void test_request_release_clock_spec (const struct device * clk_dev ,
152
196
const struct nrf_clock_spec * clk_spec )
@@ -266,18 +310,23 @@ ZTEST(nrf2_clock_control, test_cpurad_hsfll_control)
266
310
}
267
311
#endif
268
312
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
- }
274
313
314
+
315
+ #if defined(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL )
275
316
ZTEST (nrf2_clock_control , test_global_hsfll_control )
276
317
{
277
318
TC_PRINT ("Global HSFLL test\n" );
278
319
test_clock_control_request (global_hsfll_test_clk_contexts ,
279
320
ARRAY_SIZE (global_hsfll_test_clk_contexts ));
280
321
}
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
+ }
281
330
282
331
ZTEST (nrf2_clock_control , test_safe_request_cancellation )
283
332
{
@@ -303,6 +352,16 @@ ZTEST(nrf2_clock_control, test_safe_request_cancellation)
303
352
TC_PRINT ("Clock control safe cancellation return value: %d\n" , ret );
304
353
zassert_between_inclusive (ret , ONOFF_STATE_ON , ONOFF_STATE_TO_ON );
305
354
}
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
306
365
307
366
static void * setup (void )
308
367
{
0 commit comments