1 /*
2  * Copyright (c) 2024 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef NRFS_GDFS_H
8 #define NRFS_GDFS_H
9 
10 #include <internal/services/nrfs_gdfs.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 /** @brief Global Domain Frequency Scaling service event types. */
17 typedef enum __NRFS_PACKED {
18 	NRFS_GDFS_EVT_REJECT, /** General purpose event for rejected requests. */
19 	NRFS_GDFS_EVT_FREQ_CONFIRMED, /** Frequency has been achieved. */
20 } nrfs_gdfs_evt_type_t;
21 
22 /** @brief Global Domain Frequency Scaling service event. */
23 typedef struct {
24 	nrfs_gdfs_evt_type_t type;			/** Event type. */
25 } nrfs_gdfs_evt_t;
26 
27 /** @brief Global Domain Frequency Scaling service event handler type. */
28 typedef void (*nrfs_gdfs_evt_handler_t)(nrfs_gdfs_evt_t const * p_evt, void * context);
29 
30 /**
31  * @brief Function for initializing the Global Domain Frequency Scaling service.
32  *
33  * @param[in] handler Function called as a response to the request.
34  *
35  * @retval NRFS_SUCCESS           Service initialized successfully.
36  * @retval NRFS_ERR_INVALID_STATE Service was already initialized.
37  */
38 nrfs_err_t nrfs_gdfs_init(nrfs_gdfs_evt_handler_t handler);
39 
40 /**
41  * @brief Function for uninitializing the Global Domain Frequency Scaling service.
42  *
43  * @warning Notifications from previous requests are dropped after service uninitialization.
44  */
45 void nrfs_gdfs_uninit(void);
46 
47 /**
48  * @brief Function for requesting a frequency change.
49  * @note The @p target_freq requirement might not be met by the system
50  * until the NRFS_GDFS_EVT_FREQ_CONFIRMED response is triggered.
51  *
52  * @param[in] target_freq  Minimal required frequency
53  * @param[in] p_context    Opaque user data that will be passed to registered callback.
54  *
55  * @retval NRFS_SUCCESS           Request sent successfully.
56  * @retval NRFS_ERR_INVALID_STATE Service is uninitialized.
57  * @retval NRFS_ERR_IPC           Backend returned error during request sending.
58  */
59 nrfs_err_t nrfs_gdfs_request_freq(enum gdfs_frequency_setting target_freq, void * p_context);
60 
61 /**
62  * @brief Function for requesting a frequency change.
63  * @note The response @p NRFS_GDFS_EVT_FREQ_CONFIRMED will not be triggered.
64  *
65  * @param[in] target_freq  Minimal required frequency
66  * @param[in] p_context    Opaque user data that will be passed to registered callback.
67  *
68  * @retval NRFS_SUCCESS           Request sent successfully.
69  * @retval NRFS_ERR_INVALID_STATE Service is uninitialized.
70  * @retval NRFS_ERR_IPC           Backend returned error during request sending.
71  */
72 nrfs_err_t nrfs_gdfs_request_freq_no_rsp(enum gdfs_frequency_setting target_freq, void * p_context);
73 
74 #ifdef __cplusplus
75 }
76 #endif
77 
78 #endif /* NRFS_GDFS_H */
79