Skip to content

Commit

Permalink
drivers: wifi: Add support for TX power ceiling DTS configuration
Browse files Browse the repository at this point in the history
This adds support to take the TX power ceilings from the user using a
DTS file. This adds backward compatibility in case DTS file isn't
available to use defaults based on radio test or STA mode.
[SHEL-1993]:Modified RF parameters according to voltage and temperature
dependent backoffs specified.

Signed-off-by: Praveen Kankipati <[email protected]>
  • Loading branch information
kspraveeen authored and rlubos committed Sep 22, 2023
1 parent 662a9e2 commit 6a1a335
Show file tree
Hide file tree
Showing 8 changed files with 299 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,8 @@ enum wifi_nrf_status wifi_nrf_fmac_dev_init(struct wifi_nrf_fmac_dev_ctx *fmac_d
#endif /* CONFIG_NRF_WIFI_LOW_POWER */
unsigned int phy_calib,
enum op_band op_band,
struct nrf_wifi_tx_pwr_ctrl_params *tx_pwr_ctrl_params);
struct nrf_wifi_tx_pwr_ctrl_params *tx_pwr_ctrl_params,
struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params);


/**
Expand Down
6 changes: 4 additions & 2 deletions drivers/wifi/nrf700x/osal/fw_if/umac_if/inc/fmac_api_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,10 @@ enum wifi_nrf_status wifi_nrf_fmac_otp_mac_addr_get(struct wifi_nrf_fmac_dev_ctx
*
* @return Command execution status
*/
enum wifi_nrf_status wifi_nrf_fmac_rf_params_get(struct wifi_nrf_fmac_dev_ctx *fmac_dev_ctx,
unsigned char *rf_params);
enum wifi_nrf_status wifi_nrf_fmac_rf_params_get(
struct wifi_nrf_fmac_dev_ctx *fmac_dev_ctx,
unsigned char *rf_params,
struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params);

/**
* @brief Set regulatory domain in RPU.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ enum wifi_nrf_status wifi_nrf_fmac_dev_init(struct wifi_nrf_fmac_dev_ctx *fmac_d
#endif /* CONFIG_NRF_WIFI_LOW_POWER */
unsigned int phy_calib,
enum op_band op_band,
struct nrf_wifi_tx_pwr_ctrl_params *tx_pwr_ctrl_params)
struct nrf_wifi_tx_pwr_ctrl_params *tx_pwr_ctrl_params,
struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params)
{
enum wifi_nrf_status status = WIFI_NRF_STATUS_FAIL;
struct wifi_nrf_fmac_otp_info otp_info;
Expand Down Expand Up @@ -411,7 +412,8 @@ enum wifi_nrf_status wifi_nrf_fmac_dev_init(struct wifi_nrf_fmac_dev_ctx *fmac_d
}
} else {
status = wifi_nrf_fmac_rf_params_get(fmac_dev_ctx,
rf_params);
rf_params,
tx_pwr_ceil_params);

if (status != WIFI_NRF_STATUS_SUCCESS) {
wifi_nrf_osal_log_err(fmac_dev_ctx->fpriv->opriv,
Expand Down
58 changes: 55 additions & 3 deletions drivers/wifi/nrf700x/osal/fw_if/umac_if/src/fmac_api_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,21 @@ enum wifi_nrf_status wifi_nrf_fmac_otp_mac_addr_get(struct wifi_nrf_fmac_dev_ctx
}


enum wifi_nrf_status wifi_nrf_fmac_rf_params_get(struct wifi_nrf_fmac_dev_ctx *fmac_dev_ctx,
unsigned char *rf_params)
enum wifi_nrf_status wifi_nrf_fmac_rf_params_get(
struct wifi_nrf_fmac_dev_ctx *fmac_dev_ctx,
unsigned char *rf_params,
struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params)
{
enum wifi_nrf_status status = WIFI_NRF_STATUS_FAIL;
struct wifi_nrf_fmac_otp_info otp_info;
unsigned int ft_prog_ver;
int ret = -1;
#if defined(CONFIG_BOARD_NRF7002DK_NRF7001_NRF5340_CPUAPP) || \
defined(CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP) || \
defined(CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP)
unsigned char backoff_2g_dsss = 0, backoff_2g_ofdm = 0;
unsigned char backoff_5g_lowband = 0, backoff_5g_midband = 0, backoff_5g_highband = 0;
#endif

if (!fmac_dev_ctx || !rf_params) {
wifi_nrf_osal_log_err(fmac_dev_ctx->fpriv->opriv,
Expand All @@ -478,7 +486,6 @@ enum wifi_nrf_status wifi_nrf_fmac_rf_params_get(struct wifi_nrf_fmac_dev_ctx *f

status = wifi_nrf_hal_otp_ft_prog_ver_get(fmac_dev_ctx->hal_dev_ctx,
&ft_prog_ver);

if (status != WIFI_NRF_STATUS_SUCCESS) {
wifi_nrf_osal_log_err(fmac_dev_ctx->fpriv->opriv,
"%s: Fetching of FT program version failed\n",
Expand Down Expand Up @@ -514,6 +521,51 @@ enum wifi_nrf_status wifi_nrf_fmac_rf_params_get(struct wifi_nrf_fmac_dev_ctx *f

ft_prog_ver = (ft_prog_ver & FT_PROG_VER_MASK) >> 16;

#if defined(CONFIG_BOARD_NRF7002DK_NRF7001_NRF5340_CPUAPP) || \
defined(CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP) || \
defined(CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP)
if (tx_pwr_ceil_params->rf_tx_pwr_ceil_params_override) {
if (ft_prog_ver == FT_PROG_VER1) {
backoff_2g_dsss = FT_PROG_VER1_2G_DSSS_TXCEIL_BKOFF;
backoff_2g_ofdm = FT_PROG_VER1_2G_OFDM_TXCEIL_BKOFF;
backoff_5g_lowband = FT_PROG_VER1_5G_LOW_OFDM_TXCEIL_BKOFF;
backoff_5g_midband = FT_PROG_VER1_5G_MID_OFDM_TXCEIL_BKOFF;
backoff_5g_highband = FT_PROG_VER1_5G_HIGH_OFDM_TXCEIL_BKOFF;
} else if (ft_prog_ver == FT_PROG_VER2) {
backoff_2g_dsss = FT_PROG_VER2_2G_DSSS_TXCEIL_BKOFF;
backoff_2g_ofdm = FT_PROG_VER2_2G_OFDM_TXCEIL_BKOFF;
backoff_5g_lowband = FT_PROG_VER2_5G_LOW_OFDM_TXCEIL_BKOFF;
backoff_5g_midband = FT_PROG_VER2_5G_MID_OFDM_TXCEIL_BKOFF;
backoff_5g_highband = FT_PROG_VER2_5G_HIGH_OFDM_TXCEIL_BKOFF;
} else if (ft_prog_ver == FT_PROG_VER3) {
backoff_2g_dsss = FT_PROG_VER3_2G_DSSS_TXCEIL_BKOFF;
backoff_2g_ofdm = FT_PROG_VER3_2G_OFDM_TXCEIL_BKOFF;
backoff_5g_lowband = FT_PROG_VER3_5G_LOW_OFDM_TXCEIL_BKOFF;
backoff_5g_midband = FT_PROG_VER3_5G_MID_OFDM_TXCEIL_BKOFF;
backoff_5g_highband = FT_PROG_VER3_5G_HIGH_OFDM_TXCEIL_BKOFF;
}
rf_params[NRF_WIFI_RF_PARAMS_OFF_CALIB_PWR2G] =
tx_pwr_ceil_params->max_pwr_2g_dsss-backoff_2g_dsss;
rf_params[NRF_WIFI_RF_PARAMS_OFF_CALIB_PWR2GM0M7] =
tx_pwr_ceil_params->max_pwr_2g_mcs7-backoff_2g_ofdm;
rf_params[NRF_WIFI_RF_PARAMS_OFF_CALIB_PWR2GM0M7 + 1] =
tx_pwr_ceil_params->max_pwr_2g_mcs0-backoff_2g_ofdm;

rf_params[NRF_WIFI_RF_PARAMS_OFF_CALIB_PWR5GM7] =
tx_pwr_ceil_params->max_pwr_5g_low_mcs7-backoff_5g_lowband;
rf_params[NRF_WIFI_RF_PARAMS_OFF_CALIB_PWR5GM7 + 1] =
tx_pwr_ceil_params->max_pwr_5g_mid_mcs7-backoff_5g_midband;
rf_params[NRF_WIFI_RF_PARAMS_OFF_CALIB_PWR5GM7 + 2] =
tx_pwr_ceil_params->max_pwr_5g_high_mcs7-backoff_5g_highband;
rf_params[NRF_WIFI_RF_PARAMS_OFF_CALIB_PWR5GM0] =
tx_pwr_ceil_params->max_pwr_5g_low_mcs0-backoff_5g_lowband;
rf_params[NRF_WIFI_RF_PARAMS_OFF_CALIB_PWR5GM0 + 1] =
tx_pwr_ceil_params->max_pwr_5g_mid_mcs0-backoff_5g_midband;
rf_params[NRF_WIFI_RF_PARAMS_OFF_CALIB_PWR5GM0 + 2] =
tx_pwr_ceil_params->max_pwr_5g_high_mcs0-backoff_5g_highband;
}
#endif

status = WIFI_NRF_STATUS_SUCCESS;
out:
return status;
Expand Down
89 changes: 82 additions & 7 deletions drivers/wifi/nrf700x/osal/hw_if/hal/inc/fw/phy_rf_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
#define NRF_WIFI_RF_PARAMS_CONF_SIZE 42

#ifdef CONFIG_NRF700X_RADIO_TEST
#define NRF_WIFI_DEF_RF_PARAMS "0000000000002A00000000030303035440403838383838380000000050EC000000000000000000000000007077003F032424001000002800323500000C0008087D8105010071630300EED501001F6F00003B350100F52E0000E35E0000B7B6000066EFFEFFB5F60000896200007A840200E28FFCFF080808080408120100000000A1A10178000000080050003B020726181818181A120A140E0600"
#define NRF_WIFI_DEF_RF_PARAMS "0000000000002A0000000003030303544040383838383838000000003C00FC00F8FCFCFC00FC00000000007077003F032424001000002800323500000C0008087D8105010071630300EED501001F6F00003B350100F52E0000E35E0000B7B6000066EFFEFFB5F60000896200007A840200E28FFCFF080808080408120100000000A1A10178000000080050003B020726181818181A120A140E0600"
#define MAX_TX_PWR_SYS_TEST 30
#define MAX_TX_PWR_RADIO_TEST 24
#else
#define NRF_WIFI_DEF_RF_PARAMS "0000000000002A00000000030303035440403838383838380000000050EC000000FCFCF8FCF800000000007077003F032424001000002800323500000CF008087D8105010071630300EED501001F6F00003B350100F52E0000E35E0000B7B6000066EFFEFFB5F60000896200007A840200E28FFCFF080808080408120100000000A1A10178000000080050003B020726181818181A120A140E0600"
#define NRF_WIFI_DEF_RF_PARAMS "0000000000002A0000000003030303544040383838383838000000003C00FC00F8FCFCFC00FC00000000007077003F032424001000002800323500000CF008087D8105010071630300EED501001F6F00003B350100F52E0000E35E0000B7B6000066EFFEFFB5F60000896200007A840200E28FFCFF080808080408120100000000A1A10178000000080050003B020726181818181A120A140E0600"
#endif

#define NRF_WIFI_RF_PARAMS_OFF_RESV_1 0
Expand Down Expand Up @@ -84,9 +84,9 @@

/* Battery voltage changes base calibrations and voltage thresholds */
#define NRF_WIFI_DEF_PHY_VBAT_CALIB (NRF_WIFI_PHY_CALIB_FLAG_DPD)
#define NRF_WIFI_VBAT_VERYLOW (3) /* Corresponds to (2.5+3*0.07)=2.71V */
#define NRF_WIFI_VBAT_LOW (6) /* Correspond to (2.5+6*0.07)=2.92V */
#define NRF_WIFI_VBAT_HIGH (12) /* Correspond to (2.5+12*0.07)=3.34V */
#define NRF_WIFI_VBAT_VERYLOW (8) /* Corresponds to (2.5+8*0.07)=3.06V */
#define NRF_WIFI_VBAT_LOW (12) /* Correspond to (2.5+12*0.07)=3.34V */
#define NRF_WIFI_VBAT_HIGH (14) /* Correspond to (2.5+14*0.07)=3.48V */



Expand Down Expand Up @@ -186,10 +186,10 @@ struct nrf_wifi_rf_test_dpd_params {
struct nrf_wifi_temperature_params {
unsigned char test;

/*! current measured temperature */
/** current measured temperature */
signed int temperature;

/*! Temperature measurment status.
/** Temperature measurment status.
*0: Reading successful
*1: Reading failed
*/
Expand Down Expand Up @@ -223,4 +223,79 @@ struct nrf_wifi_rf_get_xo_value {

#endif /* CONFIG_NRF700X_RADIO_TEST */

/**
* @brief This structure defines the parameters used to control the max transmit (TX) power
* in both frequency bands for different data rates.
*
*/

struct nrf_wifi_tx_pwr_ceil_params {
/** Maximum power permitted while transmitting DSSS rates in 2.4G band.
* Resolution is 0.25dBm.
*/
unsigned char max_pwr_2g_dsss;
/** Maximum power permitted while transmitting MCS0 rate in 2.4G band.
* Resolution is 0.25dBm.
*/
unsigned char max_pwr_2g_mcs0;
/** Maximum power permitted while transmitting MCS7 rate in 2.4G band.
* Resolution is 0.25dBm.
*/
unsigned char max_pwr_2g_mcs7;
/** Maximum power permitted while transmitting MCS0 rate in 5G lowband.
* Low band corresponds to ch: 36 to 64 Resolution is 0.25dBm.
*/
unsigned char max_pwr_5g_low_mcs0;
/** Maximum power permitted while transmitting MCS7 rate in 5G lowband.
* Low band corresponds to ch: 36 to 64, resolution is 0.25dBm.
*/
unsigned char max_pwr_5g_low_mcs7;
/** Maximum power permitted while transmitting MCS0 rate in 5G midband.
* Mid band corresponds to ch: 96 to 132, resolution is 0.25dBm.
*/
unsigned char max_pwr_5g_mid_mcs0;
/** Maximum power permitted while transmitting MCS7 rate in 5G midband.
* Mid band corresponds to ch: 96 to 132, resolution is 0.25dBm.
*/
unsigned char max_pwr_5g_mid_mcs7;
/** Maximum power permitted while transmitting MCS0 rate in 5G highband.
* High band corresponds to ch: 136 to 177, resolution is 0.25dBm.
*/
unsigned char max_pwr_5g_high_mcs0;
/** Maximum power permitted while transmitting MCS7 rate in 5G highband.
* High band corresponds to ch: 136 to 177, resolution is 0.25dBm.
*/
unsigned char max_pwr_5g_high_mcs7;
/** Flag to determine presence of overriding, default parameters present
* in RF parameters string.
*/
unsigned char rf_tx_pwr_ceil_params_override;
} __NRF_WIFI_PKD;

/* FT Prog version info */
enum ft_prog_ver {
FT_PROG_VER1 = 1,
FT_PROG_VER2 = 2,
FT_PROG_VER3 = 3
};

/* FT Prog version dependent back off values
* from Max transmit power
*/
#define FT_PROG_VER1_2G_DSSS_TXCEIL_BKOFF 0
#define FT_PROG_VER1_2G_OFDM_TXCEIL_BKOFF 0
#define FT_PROG_VER1_5G_LOW_OFDM_TXCEIL_BKOFF 0
#define FT_PROG_VER1_5G_MID_OFDM_TXCEIL_BKOFF 0
#define FT_PROG_VER1_5G_HIGH_OFDM_TXCEIL_BKOFF 0
#define FT_PROG_VER2_2G_DSSS_TXCEIL_BKOFF 0
#define FT_PROG_VER2_2G_OFDM_TXCEIL_BKOFF 0
#define FT_PROG_VER2_5G_LOW_OFDM_TXCEIL_BKOFF 0
#define FT_PROG_VER2_5G_MID_OFDM_TXCEIL_BKOFF 0
#define FT_PROG_VER2_5G_HIGH_OFDM_TXCEIL_BKOFF 0
#define FT_PROG_VER3_2G_DSSS_TXCEIL_BKOFF 0
#define FT_PROG_VER3_2G_OFDM_TXCEIL_BKOFF 0
#define FT_PROG_VER3_5G_LOW_OFDM_TXCEIL_BKOFF 0
#define FT_PROG_VER3_5G_MID_OFDM_TXCEIL_BKOFF 0
#define FT_PROG_VER3_5G_HIGH_OFDM_TXCEIL_BKOFF 0

#endif
3 changes: 3 additions & 0 deletions drivers/wifi/nrf700x/zephyr/inc/zephyr_fmac_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ struct wifi_nrf_drv_priv_zep {
extern struct wifi_nrf_drv_priv_zep rpu_drv_priv_zep;

void wifi_nrf_scan_timeout_work(struct k_work *work);
void configure_tx_pwr_settings(struct nrf_wifi_tx_pwr_ctrl_params *tx_pwr_ctrl_params,
struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params);
void set_tx_pwr_ceil_default(struct nrf_wifi_tx_pwr_ceil_params *pwr_ceil_params);
const char *wifi_nrf_get_drv_version(void);
enum wifi_nrf_status wifi_nrf_fmac_dev_add_zep(struct wifi_nrf_drv_priv_zep *drv_priv_zep);
enum wifi_nrf_status wifi_nrf_fmac_dev_rem_zep(struct wifi_nrf_drv_priv_zep *drv_priv_zep);
Expand Down
Loading

0 comments on commit 6a1a335

Please sign in to comment.