@@ -11,6 +11,9 @@ LOG_MODULE_REGISTER(idle_with_pwm, LOG_LEVEL_INF);
1111#include <zephyr/drivers/pwm.h>
1212#include <zephyr/pm/device_runtime.h>
1313
14+ #include <nrfs_backend_ipc_service.h>
15+ #include <nrfs_gdpwr.h>
16+
1417#if IS_ENABLED (CONFIG_SOC_NRF54H20_CPUAPP_COMMON )
1518/* Alias pwm-led0 = &pwm_led2 */
1619static const struct pwm_dt_spec pwm_led = PWM_DT_SPEC_GET (DT_ALIAS (pwm_led0 ));
@@ -23,6 +26,53 @@ static const struct pwm_dt_spec pwm_led = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led0));
2326
2427#define PWM_STEPS_PER_SEC (50)
2528
29+ /* Required to power off the GD2 and GD3 domains
30+ * Will be removed when GD handling
31+ * is implemented in sdk-zephyr
32+ */
33+ static void gdpwr_handler (nrfs_gdpwr_evt_t const * p_evt , void * context )
34+ {
35+ switch (p_evt -> type ) {
36+ case NRFS_GDPWR_REQ_APPLIED :
37+ printk ("GDPWR handler - response received: 0x%x, CTX=%d\n" , p_evt -> type ,
38+ (uint32_t )context );
39+ break ;
40+ case NRFS_GDPWR_REQ_REJECTED :
41+ printk ("GDPWR handler - request rejected: 0x%x, CTX=%d\n" , p_evt -> type ,
42+ (uint32_t )context );
43+ break ;
44+ default :
45+ printk ("GDPWR handler - unexpected event: 0x%x, CTX=%d\n" , p_evt -> type ,
46+ (uint32_t )context );
47+ break ;
48+ }
49+ }
50+
51+ /* Required to power off the GD2 and GD3 domains
52+ * Will be removed when GD handling
53+ * is implemented in sdk-zephyr
54+ */
55+ static void clear_global_power_domains_requests (void )
56+ {
57+ int service_status ;
58+ int tst_ctx = 1 ;
59+
60+ service_status = nrfs_gdpwr_init (gdpwr_handler );
61+ printk ("Response: %d\n" , service_status );
62+ printk ("Sending GDPWR DISABLE request for: GDPWR_POWER_DOMAIN_ACTIVE_SLOW\n" );
63+ service_status = nrfs_gdpwr_power_request (GDPWR_POWER_DOMAIN_ACTIVE_SLOW ,
64+ GDPWR_POWER_REQUEST_CLEAR , (void * )tst_ctx ++ );
65+ printk ("Response: %d\n" , service_status );
66+ printk ("Sending GDPWR DISABLE request for: GDPWR_POWER_DOMAIN_ACTIVE_FAST\n" );
67+ service_status = nrfs_gdpwr_power_request (GDPWR_POWER_DOMAIN_ACTIVE_FAST ,
68+ GDPWR_POWER_REQUEST_CLEAR , (void * )tst_ctx ++ );
69+ printk ("Response: %d\n" , service_status );
70+ printk ("Sending GDPWR DISABLE request for: GDPWR_POWER_DOMAIN_MAIN_SLOW\n" );
71+ service_status = nrfs_gdpwr_power_request (GDPWR_POWER_DOMAIN_MAIN_SLOW ,
72+ GDPWR_POWER_REQUEST_CLEAR , (void * )tst_ctx );
73+ printk ("Response: %d\n" , service_status );
74+ }
75+
2676int main (void )
2777{
2878 int ret ;
@@ -33,6 +83,9 @@ int main(void)
3383 int32_t pulse_step ;
3484 uint32_t current_pulse_width ;
3585
86+ nrfs_backend_wait_for_connection (K_FOREVER );
87+ clear_global_power_domains_requests ();
88+
3689 if (!pwm_is_ready_dt (& pwm_led )) {
3790 LOG_ERR ("Device %s is not ready." , pwm_led .dev -> name );
3891 return - ENODEV ;
0 commit comments