1 /* 2 * Copyright (c) 2024 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 /** @file 8 * 9 * @addtogroup nrf_wifi_api_radio_test FMAC radio test API 10 * @{ 11 * 12 * @brief Header containing API declarations for the 13 * FMAC IF Layer of the Wi-Fi driver. 14 */ 15 16 #ifndef __FMAC_API_RT_H__ 17 #define __FMAC_API_RT_H__ 18 19 #include "osal_api.h" 20 #include "host_rpu_umac_if.h" 21 #include "host_rpu_data_if.h" 22 #include "host_rpu_sys_if.h" 23 24 #include "fmac_structs.h" 25 #include "fmac_cmd.h" 26 #include "fmac_event.h" 27 #include "common/fmac_api_common.h" 28 29 30 /** 31 * @brief Initialize the UMAC IF layer. 32 * 33 * This function initializes the UMAC IF layer of the RPU WLAN FullMAC driver. 34 * It does the following: 35 * 36 * - Creates and initializes the context for the UMAC IF layer. 37 * - Initialize the OS abstraction Layer 38 * - Initialize the HAL layer. 39 * - Registers the driver to the underlying Operating System. 40 * 41 * @return Pointer to the context of the UMAC IF layer. 42 */ 43 struct nrf_wifi_fmac_priv *nrf_wifi_rt_fmac_init(void); 44 45 46 /** 47 * @brief Initialize the RPU for radio tests. 48 * @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device. 49 * @param params Parameters necessary for the initialization. 50 * 51 * This function is used to send a command to: 52 * - The RPU firmware to initialize it for radio test mode. 53 * 54 * @retval NRF_WIFI_STATUS_SUCCESS On Success 55 * @retval NRF_WIFI_STATUS_FAIL On failure to execute command 56 */ 57 enum nrf_wifi_status nrf_wifi_rt_fmac_radio_test_init(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, 58 struct rpu_conf_params *params); 59 60 /** 61 * @brief Start TX tests in radio test mode. 62 * @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device. 63 * @param params Parameters necessary for the TX tests. 64 * 65 * This function is used to send a command to: 66 * - The RPU firmware to start the TX tests in radio test mode. 67 * 68 * @retval NRF_WIFI_STATUS_SUCCESS On Success 69 * @retval NRF_WIFI_STATUS_FAIL On failure to execute command 70 */ 71 enum nrf_wifi_status nrf_wifi_rt_fmac_prog_tx(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, 72 struct rpu_conf_params *params); 73 74 /** 75 * @brief Start RX tests in radio test mode. 76 * @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device. 77 * @param params Parameters necessary for the RX tests. 78 * 79 * This function is used to send a command to: 80 * - The RPU firmware to start the RX tests in radio test mode. 81 * 82 * @retval NRF_WIFI_STATUS_SUCCESS On Success 83 * @retval NRF_WIFI_STATUS_FAIL On failure to execute command 84 */ 85 enum nrf_wifi_status nrf_wifi_rt_fmac_prog_rx(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, 86 struct rpu_conf_params *params); 87 88 89 /** 90 * @brief Start RF test capture in radio test mode. 91 * @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device. 92 * @param rf_test_type Type of RF test to be performed. 93 * @param cap_data Pointer to the memory where the RF test capture is to be stored. 94 * @param num_samples Number of RF test samples to capture. 95 * @param capture_timeout Capture timeout. 96 * @param lna_gain LNA gain value. 97 * @param bb_gain Baseband gain value. 98 * @param timeout_status Timeout status. 99 * 100 * This function is used to send a command to: 101 * - The RPU firmware to start the RF test capture in radio test mode. 102 * 103 * @retval NRF_WIFI_STATUS_SUCCESS On Success 104 * @retval NRF_WIFI_STATUS_FAIL On failure to execute command 105 */ 106 enum nrf_wifi_status nrf_wifi_rt_fmac_rf_test_rx_cap(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, 107 enum nrf_wifi_rf_test rf_test_type, 108 void *cap_data, 109 unsigned short int num_samples, 110 unsigned short int capture_timeout, 111 unsigned char lna_gain, 112 unsigned char bb_gain, 113 unsigned char *timeout_status); 114 115 116 /** 117 * @brief Start/Stop RF TX tone test in radio test mode. 118 * @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device. 119 * @param enable Enable/Disable TX tone test. 120 * @param tone_freq Desired tone frequency in MHz in steps of 1 MHz from -10 MHz to +10 MHz. 121 * @param tx_power Desired TX power in the range -16dBm to +24dBm. 122 * 123 * This function is used to send a command to: 124 * - The RPU firmware to start the RF TX tone test in radio test mode. 125 * 126 * @retval NRF_WIFI_STATUS_SUCCESS On Success 127 * @retval NRF_WIFI_STATUS_FAIL On failure to execute command 128 */ 129 enum nrf_wifi_status nrf_wifi_rt_fmac_rf_test_tx_tone(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, 130 unsigned char enable, 131 signed char tone_freq, 132 signed char tx_power); 133 134 135 136 /** 137 * @brief Start/Stop RF DPD test in radio test mode. 138 * @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device. 139 * @param enable Enable/Disable DPD test. 140 * 141 * This function is used to send a command to: 142 * - The RPU firmware to start the RF DPD test in radio test mode. 143 * 144 * @retval NRF_WIFI_STATUS_SUCCESS On Success 145 * @retval NRF_WIFI_STATUS_FAIL On failure to execute command 146 */ 147 enum nrf_wifi_status nrf_wifi_rt_fmac_rf_test_dpd(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, 148 unsigned char enable); 149 150 151 152 /** 153 * @brief Get temperature in Fahrenheit using temperature sensor. 154 * @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device. 155 * 156 * This function is used to send a command to: 157 * - The RPU firmware to get the current temperature using the radio test mode. 158 * 159 * @retval NRF_WIFI_STATUS_SUCCESS On Success 160 * @retval NRF_WIFI_STATUS_FAIL On failure to execute command 161 */ 162 enum nrf_wifi_status nrf_wifi_rt_fmac_rf_get_temp(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx); 163 164 165 166 /** 167 * @brief Get RF RSSI status. 168 * @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device. 169 * 170 * This function is used to send a command to: 171 * - The RPU firmware to get RF RSSI status in radio test mode. 172 * 173 * @retval NRF_WIFI_STATUS_SUCCESS On Success 174 * @retval NRF_WIFI_STATUS_FAIL On failure to execute command 175 */ 176 enum nrf_wifi_status nrf_wifi_rt_fmac_rf_get_rf_rssi(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx); 177 178 179 /** 180 * @brief Set XO adjustment value. 181 * @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device. 182 * @param value XO adjustment value. 183 * 184 * This function is used to send a command to: 185 * - The RPU firmware to set XO adjustment value in radio test mode. 186 * 187 * @retval NRF_WIFI_STATUS_SUCCESS On Success 188 * @retval NRF_WIFI_STATUS_FAIL On failure to execute command 189 */ 190 enum nrf_wifi_status nrf_wifi_rt_fmac_set_xo_val(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, 191 unsigned char value); 192 193 /** 194 * @brief Get XO calibrated value. 195 * @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device. 196 * 197 * This function is used to send a command to: 198 * - The RPU firmware wherein the RPU firmware estimates and 199 * returns optimal XO value. 200 * 201 * @retval NRF_WIFI_STATUS_SUCCESS On Success 202 * @retval NRF_WIFI_STATUS_FAIL On failure to execute command 203 */ 204 enum nrf_wifi_status nrf_wifi_rt_fmac_rf_test_compute_xo(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx); 205 206 207 /** 208 * @brief Adds a RPU instance. 209 * @param fpriv Pointer to the context of the UMAC IF layer. 210 * @param os_dev_ctx Pointer to the OS specific context of the RPU instance. 211 * 212 * This function adds an RPU instance. This function will return the 213 * pointer to the context of the RPU instance. This pointer will need to be 214 * supplied while invoking further device specific APIs, 215 * for example, nrf_wifi_sys_fmac_scan() etc. 216 * 217 * @return Pointer to the context of the RPU instance. 218 */ 219 struct nrf_wifi_fmac_dev_ctx *nrf_wifi_rt_fmac_dev_add(struct nrf_wifi_fmac_priv *fpriv, 220 void *os_dev_ctx); 221 222 223 /** 224 * @brief Initialize a RPU instance. 225 * @param fmac_dev_ctx Pointer to the context of the RPU instance to be removed. 226 * @param sleep_type Type of RPU sleep. 227 * @param phy_calib PHY calibration flags to be passed to the RPU. 228 * @param op_band Operating band of the RPU. 229 * @param beamforming Enable/disable Wi-Fi beamforming. 230 * @param tx_pwr_ctrl TX power control parameters to be passed to the RPU. 231 * @param tx_pwr_ceil_params TX power ceiling parameters to be passed to the RPU. 232 * @param board_params Board parameters to be passed to the RPU. 233 * @param country_code Country code to be set for regularity domain. 234 * 235 * This function initializes the firmware of an RPU instance. 236 * 237 * @retval NRF_WIFI_STATUS_SUCCESS On Success 238 * @retval NRF_WIFI_STATUS_FAIL On failure to execute command 239 */ 240 enum nrf_wifi_status nrf_wifi_rt_fmac_dev_init(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, 241 #if defined(NRF_WIFI_LOW_POWER) || defined(__DOXYGEN__) 242 int sleep_type, 243 #endif /* NRF_WIFI_LOW_POWER */ 244 unsigned int phy_calib, 245 enum op_band op_band, 246 bool beamforming, 247 struct nrf_wifi_tx_pwr_ctrl_params *tx_pwr_ctrl, 248 struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params, 249 struct nrf_wifi_board_params *board_params, 250 unsigned char *country_code); 251 252 253 /** 254 * @brief De-initialize a RPU instance. 255 * @param fmac_dev_ctx Pointer to the context of the RPU instance to be removed. 256 * 257 * This function de-initializes the firmware of an RPU instance. 258 */ 259 void nrf_wifi_rt_fmac_dev_deinit(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx); 260 261 /** 262 * @brief Get the RF parameters to be programmed to the RPU. 263 * @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device. 264 * @param rf_params Pointer to the address where the RF params information needs to be copied. 265 * 266 * This function is used to fetch RF parameters information from the RPU and 267 * update the default RF parameter with the OTP values. The updated RF 268 * parameters are then returned in the \p f_params. 269 * 270 * @return Command execution status 271 */ 272 enum nrf_wifi_status nrf_wifi_rt_fmac_rf_params_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, 273 struct nrf_wifi_phy_rf_params *rf_params); 274 275 /** 276 * @brief Issue a request to get stats from the RPU. 277 * @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device. 278 * @param op_mode RPU operation mode. 279 * @param stats Pointer to memory where the stats are to be copied. 280 * 281 * This function is used to send a command to 282 * instruct the firmware to return the current RPU statistics. The RPU will 283 * send the event with the current statistics. 284 * 285 * @return Command execution status 286 */ 287 enum nrf_wifi_status nrf_wifi_rt_fmac_stats_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, 288 enum rpu_op_mode op_mode, 289 struct rpu_rt_op_stats *stats); 290 291 /** 292 * @} 293 */ 294 #endif /* __FMAC_API_RT_H__ */ 295