1 /* 2 * Copyright (c) 2024 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef NRFS_PMIC_H 8 #define NRFS_PMIC_H 9 10 #include <internal/services/nrfs_pmic.h> 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 /** @brief PMIC Service response notification types. */ 17 typedef enum __NRFS_PACKED { 18 NRFS_PMIC_EVT_APPLIED, /** Request applied succesfully */ 19 NRFS_PMIC_EVT_REJECT, /** Request rejected. */ 20 NRFS_PMIC_EVT_TEST_IF_RSP, /** Response for TEST_IF request */ 21 NRFS_PMIC_EVT_INFO_RSP, /** Response for INFO IF request */ 22 } nrfs_pmic_evt_type_t; 23 24 /** @brief PMIC Service response data structure. */ 25 typedef struct { 26 nrfs_pmic_evt_type_t type; /** Event type. */ 27 pmic_reg_access_type_t access_type; /** Register access type */ 28 uint8_t val; /** Register read value used by PMIC_TEST_IF request */ 29 } nrfs_pmic_evt_t; 30 31 /** @brief PMIC Service info response data structure. */ 32 typedef struct { 33 nrfs_pmic_evt_type_t type; /** Event type. */ 34 nrfs_pmic_info_rsp_data_t info; 35 } nrfs_pmic_info_evt_t; 36 37 /** @brief PMIC Service event handler type. */ 38 typedef void (*nrfs_pmic_evt_handler_t)(void const *p_evt, void * p_context); 39 40 /** 41 * @brief Function for initializing the PMIC service. 42 * 43 * @param[in] handler Function called as a response to the request 44 * 45 * @retval NRFS_SUCCESS Service initialized successfully. 46 * @retval NRFS_ERR_INVALID_STATE Service was already initialized. 47 */ 48 nrfs_err_t nrfs_pmic_init(nrfs_pmic_evt_handler_t handler); 49 50 /** 51 * @brief Function for uninitializing the PMIC service. 52 * 53 * @warning Notifications from previous requests are dropped after service uninitialization. 54 */ 55 void nrfs_pmic_uninit(void); 56 57 /** 58 * @brief Function for requesting power ON RFFE interface 59 * 60 * @param[in] p_context Opaque user data that will be passed to registered callback. 61 * 62 * @retval NRFS_SUCCESS Request sent successfully. 63 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 64 * @retval NRFS_ERR_IPC Backend returned error during request sending. 65 */ 66 nrfs_err_t nrfs_pmic_rffe_on(void * p_context); 67 68 /** 69 * @brief Function for requesting power ON RFFE interface with no response 70 * 71 * @retval NRFS_SUCCESS Request sent successfully. 72 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 73 * @retval NRFS_ERR_IPC Backend returned error during request sending. 74 */ 75 nrfs_err_t nrfs_pmic_rffe_on_no_rsp(void); 76 77 /** 78 * @brief Function for requesting power OFF RFFE interface 79 * 80 * @param[in] p_context Opaque user data that will be passed to registered callback. 81 * 82 * @retval NRFS_SUCCESS Request sent successfully. 83 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 84 * @retval NRFS_ERR_IPC Backend returned error during request sending. 85 */ 86 nrfs_err_t nrfs_pmic_rffe_off(void * p_context); 87 88 /** 89 * @brief Function for requesting power OFF RFFE interface with no response 90 * 91 * @retval NRFS_SUCCESS Request sent successfully. 92 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 93 * @retval NRFS_ERR_IPC Backend returned error during request sending. 94 */ 95 nrfs_err_t nrfs_pmic_rffe_off_no_rsp(void); 96 97 /** 98 * @brief Function for requesting power ON SIM interface 99 * 100 * @param[in] sim Requested SIM to power ON. 101 * @param[in] p_context Opaque user data that will be passed to registered callback. 102 * 103 * @retval NRFS_SUCCESS Request sent successfully. 104 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 105 * @retval NRFS_ERR_IPC Backend returned error during request sending. 106 */ 107 nrfs_err_t nrfs_pmic_sim_on(pmic_sim_t sim, void * p_context); 108 109 /** 110 * @brief Function for requesting power ON SIM interface with no response 111 * 112 * @param[in] sim Requested SIM to power ON. 113 * 114 * @retval NRFS_SUCCESS Request sent successfully. 115 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 116 * @retval NRFS_ERR_IPC Backend returned error during request sending. 117 */ 118 nrfs_err_t nrfs_pmic_sim_on_no_rsp(pmic_sim_t sim); 119 120 /** 121 * @brief Function for requesting power OFF SIM interface 122 * 123 * @param[in] sim Requested SIM to power OFF. 124 * @param[in] p_context Opaque user data that will be passed to registered callback. 125 * 126 * @retval NRFS_SUCCESS Request sent successfully. 127 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 128 * @retval NRFS_ERR_IPC Backend returned error during request sending. 129 */ 130 nrfs_err_t nrfs_pmic_sim_off(pmic_sim_t sim, void * p_context); 131 132 /** 133 * @brief Function for requesting power OFF SIM interface with no response 134 * 135 * @param[in] sim Requested SIM to power OFF. 136 * 137 * @retval NRFS_SUCCESS Request sent successfully. 138 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 139 * @retval NRFS_ERR_IPC Backend returned error during request sending. 140 */ 141 nrfs_err_t nrfs_pmic_sim_off_no_rsp(pmic_sim_t sim); 142 143 /** 144 * @brief Function for requesting power ON BLE radio 145 * 146 * @param[in] txpower Needed TX power 147 * @param[in] p_context Opaque user data that will be passed to registered callback. 148 * 149 * @retval NRFS_SUCCESS Request sent successfully. 150 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 151 * @retval NRFS_ERR_IPC Backend returned error during request sending. 152 */ 153 nrfs_err_t nrfs_pmic_ble_radio_on(pmic_ble_radio_txpower_t txpower, void * p_context); 154 155 /** 156 * @brief Function for requesting power ON BLE radio with no response 157 * 158 * @param[in] txpower Needed TX power 159 * 160 * @retval NRFS_SUCCESS Request sent successfully. 161 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 162 * @retval NRFS_ERR_IPC Backend returned error during request sending. 163 */ 164 nrfs_err_t nrfs_pmic_ble_radio_on_no_rsp(pmic_ble_radio_txpower_t txpower); 165 166 /** 167 * @brief Function for requesting power OFF BLE radio 168 * 169 * @param[in] p_context Opaque user data that will be passed to registered callback. 170 * 171 * @retval NRFS_SUCCESS Request sent successfully. 172 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 173 * @retval NRFS_ERR_IPC Backend returned error during request sending. 174 */ 175 nrfs_err_t nrfs_pmic_ble_radio_off(void * p_context); 176 177 /** 178 * @brief Function for requesting power OFF BLE radio with no response 179 * 180 * @retval NRFS_SUCCESS Request sent successfully. 181 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 182 * @retval NRFS_ERR_IPC Backend returned error during request sending. 183 */ 184 nrfs_err_t nrfs_pmic_ble_radio_off_no_rsp(void); 185 186 /** 187 * @brief Function for setting default PWM settings to DCDC converters 188 * 189 * @param[in] p_context Opaque user data that will be passed to registered callback. 190 * 191 * @retval NRFS_SUCCESS Request sent successfully. 192 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 193 * @retval NRFS_ERR_IPC Backend returned error during request sending. 194 */ 195 nrfs_err_t nrfs_pmic_pwm_default_set(void * p_context); 196 197 /** 198 * @brief Function for setting default PWM settings to DCDC converters with no response 199 * 200 * @retval NRFS_SUCCESS Request sent successfully. 201 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 202 * @retval NRFS_ERR_IPC Backend returned error during request sending. 203 */ 204 nrfs_err_t nrfs_pmic_pwm_default_set_no_rsp(void); 205 206 /** 207 * @brief Function for setting ghost avoidance PWM settings to DCDC converters 208 * 209 * @param[in] p_context Opaque user data that will be passed to registered callback. 210 * 211 * @retval NRFS_SUCCESS Request sent successfully. 212 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 213 * @retval NRFS_ERR_IPC Backend returned error during request sending. 214 */ 215 nrfs_err_t nrfs_pmic_pwm_ghost_avoid_set(void * p_context); 216 217 /** 218 * @brief Function for setting ghost avoidance PWM settings to DCDC converters with no response 219 * 220 * @retval NRFS_SUCCESS Request sent successfully. 221 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 222 * @retval NRFS_ERR_IPC Backend returned error during request sending. 223 */ 224 nrfs_err_t nrfs_pmic_pwm_ghost_avoid_set_no_rsp(void); 225 226 /** 227 * @brief Function for checking PMIC existence 228 * 229 * Value will be available for handler. 230 * 231 * @param[in] p_context Opaque user data that will be passed to registered callback. 232 * 233 * @retval NRFS_SUCCESS Request sent successfully. 234 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 235 * @retval NRFS_ERR_IPC Backend returned error during request sending. 236 */ 237 nrfs_err_t nrfs_pmic_info_read(void * p_context); 238 239 /** 240 * @brief Function for reading PMIC register 241 * 242 * Value of register read will be available for handler. 243 * 244 * @param[in] addr 16-bit register address 245 * @param[in] p_context Opaque user data that will be passed to registered callback. 246 * 247 * @retval NRFS_SUCCESS Request sent successfully. 248 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 249 * @retval NRFS_ERR_IPC Backend returned error during request sending. 250 */ 251 nrfs_err_t nrfs_pmic_test_if_read(uint16_t addr, void * p_context); 252 253 /** 254 * @brief Function for writing PMIC register 255 * 256 * @param[in] addr 16-bit register address 257 * @param[in] val 8-bit value to be written to PMIC register 258 * @param[in] p_context Opaque user data that will be passed to registered callback. 259 * 260 * @retval NRFS_SUCCESS Request sent successfully. 261 * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. 262 * @retval NRFS_ERR_IPC Backend returned error during request sending. 263 */ 264 nrfs_err_t nrfs_pmic_test_if_write(uint16_t addr, uint8_t val, void * p_context); 265 266 #ifdef __cplusplus 267 } 268 #endif 269 270 #endif /* NRFS_PMIC_H */ 271