@@ -215,8 +215,6 @@ static void test_clock_control_request(const struct test_clk_context *clk_contex
215
215
ZTEST (nrf2_clock_control , test_cpuapp_hsfll_control )
216
216
{
217
217
TC_PRINT ("APPLICATION DOMAIN HSFLL test\n" );
218
- /* Wait for the DVFS init to complete */
219
- k_msleep (3000 );
220
218
test_clock_control_request (cpuapp_hsfll_test_clk_contexts ,
221
219
ARRAY_SIZE (cpuapp_hsfll_test_clk_contexts ));
222
220
}
@@ -311,4 +309,56 @@ ZTEST(nrf2_clock_control, test_safe_request_cancellation)
311
309
zassert_between_inclusive (ret , ONOFF_STATE_ON , ONOFF_STATE_TO_ON );
312
310
}
313
311
314
- ZTEST_SUITE (nrf2_clock_control , NULL , NULL , NULL , NULL , NULL );
312
+ static void * setup (void )
313
+ {
314
+ #if defined(CONFIG_BOARD_NRF54H20DK_NRF54H20_CPUAPP )
315
+ const struct device * clk_dev = DEVICE_DT_GET (DT_NODELABEL (cpuapp_hsfll ));
316
+ const struct nrf_clock_spec clk_spec = {
317
+ .frequency = MHZ (64 ),
318
+ };
319
+ struct onoff_client cli ;
320
+ uint32_t start_uptime ;
321
+ const uint32_t timeout_ms = 3000 ;
322
+
323
+ zassert_true (device_is_ready (clk_dev ),
324
+ "%s is not ready" , clk_dev -> name );
325
+
326
+ /* Constantly make requests to DVFS until one is successful (what also
327
+ * means that the service has finished its initialization). This loop
328
+ * also verifies that the clock control driver is able to recover after
329
+ * an unsuccesful attempt to start a clock (at least one initial request
330
+ * is expected to fail here due to DFVS not being initialized yet).
331
+ */
332
+ TC_PRINT ("Polling DVFS until it is ready\n" );
333
+ start_uptime = k_uptime_get_32 ();
334
+ while (1 ) {
335
+ int status ;
336
+ int ret ;
337
+
338
+ sys_notify_init_spinwait (& cli .notify );
339
+ ret = nrf_clock_control_request (clk_dev , & clk_spec , & cli );
340
+ /* The on-off manager for this clock controller is expected to
341
+ * always be in the off state when a request is done (its error
342
+ * state is expected to be cleared by the clock control driver).
343
+ */
344
+ zassert_equal (ret , ONOFF_STATE_OFF , "request result: %d" , ret );
345
+ do {
346
+ ret = sys_notify_fetch_result (& cli .notify , & status );
347
+ k_yield ();
348
+ } while (ret == - EAGAIN );
349
+
350
+ if (status == 0 ) {
351
+ TC_PRINT ("DVFS is ready\n" );
352
+ break ;
353
+ } else if ((k_uptime_get_32 () - start_uptime ) >= timeout_ms ) {
354
+ TC_PRINT ("DVFS is not ready after %u ms\n" , timeout_ms );
355
+ ztest_test_fail ();
356
+ break ;
357
+ }
358
+ }
359
+ #endif
360
+
361
+ return NULL ;
362
+ }
363
+
364
+ ZTEST_SUITE (nrf2_clock_control , NULL , setup , NULL , NULL , NULL );
0 commit comments