@@ -12,6 +12,9 @@ LOG_MODULE_REGISTER(idle_spim_loopback, LOG_LEVEL_INF);
1212#include <zephyr/linker/devicetree_regions.h>
1313#include <zephyr/pm/device_runtime.h>
1414
15+ #include <nrfs_backend_ipc_service.h>
16+ #include <nrfs_gdpwr.h>
17+
1518#define DELTA (1)
1619
1720#define SPI_MODE (SPI_OP_MODE_MASTER | SPI_WORD_SET(8) | SPI_LINES_SINGLE | SPI_TRANSFER_MSB \
@@ -37,6 +40,53 @@ void my_timer_handler(struct k_timer *dummy)
3740 timer_expired = true;
3841}
3942
43+ /* Required to power off the GD2 and GD3 domains
44+ * Will be removed when GD handling
45+ * is implemented in sdk-zephyr
46+ */
47+ static void gdpwr_handler (nrfs_gdpwr_evt_t const * p_evt , void * context )
48+ {
49+ switch (p_evt -> type ) {
50+ case NRFS_GDPWR_REQ_APPLIED :
51+ printk ("GDPWR handler - response received: 0x%x, CTX=%d\n" , p_evt -> type ,
52+ (uint32_t )context );
53+ break ;
54+ case NRFS_GDPWR_REQ_REJECTED :
55+ printk ("GDPWR handler - request rejected: 0x%x, CTX=%d\n" , p_evt -> type ,
56+ (uint32_t )context );
57+ break ;
58+ default :
59+ printk ("GDPWR handler - unexpected event: 0x%x, CTX=%d\n" , p_evt -> type ,
60+ (uint32_t )context );
61+ break ;
62+ }
63+ }
64+
65+ /* Required to power off the GD2 and GD3 domains
66+ * Will be removed when GD handling
67+ * is implemented in sdk-zephyr
68+ */
69+ static void clear_global_power_domains_requests (void )
70+ {
71+ int service_status ;
72+ int tst_ctx = 1 ;
73+
74+ service_status = nrfs_gdpwr_init (gdpwr_handler );
75+ printk ("Response: %d\n" , service_status );
76+ printk ("Sending GDPWR DISABLE request for: GDPWR_POWER_DOMAIN_ACTIVE_SLOW\n" );
77+ service_status = nrfs_gdpwr_power_request (GDPWR_POWER_DOMAIN_ACTIVE_SLOW ,
78+ GDPWR_POWER_REQUEST_CLEAR , (void * )tst_ctx ++ );
79+ printk ("Response: %d\n" , service_status );
80+ printk ("Sending GDPWR DISABLE request for: GDPWR_POWER_DOMAIN_ACTIVE_FAST\n" );
81+ service_status = nrfs_gdpwr_power_request (GDPWR_POWER_DOMAIN_ACTIVE_FAST ,
82+ GDPWR_POWER_REQUEST_CLEAR , (void * )tst_ctx ++ );
83+ printk ("Response: %d\n" , service_status );
84+ printk ("Sending GDPWR DISABLE request for: GDPWR_POWER_DOMAIN_MAIN_SLOW\n" );
85+ service_status = nrfs_gdpwr_power_request (GDPWR_POWER_DOMAIN_MAIN_SLOW ,
86+ GDPWR_POWER_REQUEST_CLEAR , (void * )tst_ctx );
87+ printk ("Response: %d\n" , service_status );
88+ }
89+
4090int main (void )
4191{
4292 int ret ;
@@ -63,6 +113,9 @@ int main(void)
63113 .count = 1
64114 };
65115
116+ nrfs_backend_wait_for_connection (K_FOREVER );
117+ clear_global_power_domains_requests ();
118+
66119 LOG_INF ("%s runs as a SPI HOST" , CONFIG_BOARD_TARGET );
67120 LOG_INF ("%d bytes of data exchanged at once" , CONFIG_DATA_FIELD );
68121
0 commit comments