Skip to content

Commit

Permalink
nrf_wifi: Add support to get current temperature
Browse files Browse the repository at this point in the history
Add command/event to retrieve current temperature.

Signed-off-by: Ajay Parida <[email protected]>
  • Loading branch information
ajayparida committed Oct 24, 2024
1 parent 4309051 commit f75980c
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 0 deletions.
13 changes: 13 additions & 0 deletions nrf_wifi/fw_if/umac_if/inc/fmac_api_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,19 @@ enum nrf_wifi_status nrf_wifi_fmac_set_packet_filter(void *dev_ctx, unsigned cha
unsigned short buffer_size);
#endif /* CONFIG_NRF700X_RAW_DATA_RX || CONFIG_NRF700X_PROMISC_DATA_RX */

/**
* @brief Issue a request to get current temperature from the RPU.
* @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device.
* @param current_temp Pointer to memory where the current temp is to be copied.
*
* This function is used to send a command to
* instruct the firmware to return the current temperature. The RPU will
* send the event with the current temperature.
*
* @return Command execution status
*/
enum nrf_wifi_status nrf_wifi_fmac_temp_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
int *current_temp);
/**
* @}
*/
Expand Down
2 changes: 2 additions & 0 deletions nrf_wifi/fw_if/umac_if/inc/fmac_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,6 @@ enum nrf_wifi_status umac_cmd_prog_stats_get(struct nrf_wifi_fmac_dev_ctx *fmac_
#endif /* CONFIG_NRF700X_RADIO_TEST */
int stat_type);

enum nrf_wifi_status umac_cmd_prog_temp_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx);

#endif /* __FMAC_CMD_H__ */
4 changes: 4 additions & 0 deletions nrf_wifi/fw_if/umac_if/inc/fmac_structs_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ struct nrf_wifi_fmac_dev_ctx {
struct nrf_wifi_event_regulatory_change *reg_change;
/** TX power ceiling parameters */
struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params;
/** current temp request status */
int temp_get_status;
/** current temperature */
int current_temp;
/** Data pointer to mode specific parameters */
char priv[];
};
Expand Down
24 changes: 24 additions & 0 deletions nrf_wifi/fw_if/umac_if/inc/fw/host_rpu_sys_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ enum nrf_wifi_sys_commands {
NRF_WIFI_CMD_RAW_CONFIG_FILTER,
/** Command to configure packet injector mode or Raw Tx mode */
NRF_WIFI_CMD_RAW_TX_PKT,
/** Command to get RPU temperature */
NRF_WIFI_CMD_GET_TEMP,
};

/**
Expand Down Expand Up @@ -192,6 +194,8 @@ enum nrf_wifi_sys_events {
NRF_WIFI_EVENT_FILTER_SET_DONE,
/** Tx done event for the Raw Tx */
NRF_WIFI_EVENT_RAW_TX_DONE,
/** Response to NRF_WIFI_CMD_GET_TEMP */
NRF_WIFI_EVENT_CURRENT_TEMP,
};

/**
Expand Down Expand Up @@ -1597,4 +1601,24 @@ struct nrf_wifi_event_deinit_done {
struct nrf_wifi_sys_head sys_head;
} __NRF_WIFI_PKD;

/**
* @brief This structure represents the command used to get the RPU temperature.
*/
struct nrf_wifi_cmd_get_temperature {
/** UMAC header, @ref nrf_wifi_sys_head */
struct nrf_wifi_sys_head sys_head;
} __NRF_WIFI_PKD;

/**
* @brief This structure represents an event that provides the current RPU temperature
* in degree celsius.
*
*/
struct nrf_wifi_event_current_temperature {
/** UMAC header, @ref nrf_wifi_sys_head */
struct nrf_wifi_sys_head sys_head;
/** Current temperature value in degree celsius */
int current_temperature;
} __NRF_WIFI_PKD;

#endif /* __HOST_RPU_SYS_IF_H__ */
32 changes: 32 additions & 0 deletions nrf_wifi/fw_if/umac_if/src/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,3 +541,35 @@ enum nrf_wifi_status umac_cmd_prog_stats_get(struct nrf_wifi_fmac_dev_ctx *fmac_
out:
return status;
}

enum nrf_wifi_status umac_cmd_prog_temp_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx)
{
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
struct host_rpu_msg *umac_cmd = NULL;
struct nrf_wifi_cmd_get_temperature *umac_cmd_data = NULL;
int len = 0;

len = sizeof(*umac_cmd_data);

umac_cmd = umac_cmd_alloc(fmac_dev_ctx,
NRF_WIFI_HOST_RPU_MSG_TYPE_SYSTEM,
len);

if (!umac_cmd) {
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
"%s: umac_cmd_alloc failed",
__func__);
goto out;
}

umac_cmd_data = (struct nrf_wifi_cmd_get_temperature *)(umac_cmd->msg);

umac_cmd_data->sys_head.cmd_event = NRF_WIFI_CMD_GET_TEMP;
umac_cmd_data->sys_head.len = len;

status = nrf_wifi_hal_ctrl_cmd_send(fmac_dev_ctx->hal_dev_ctx,
umac_cmd,
(sizeof(*umac_cmd) + len));
out:
return status;
}
36 changes: 36 additions & 0 deletions nrf_wifi/fw_if/umac_if/src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,38 @@ nrf_wifi_fmac_if_mode_set_event_proc(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
}
#endif /* CONFIG_NRF700X_SYSTEM_WITH_RAW_MODES */

static enum nrf_wifi_status umac_event_current_temp_proc(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
void *event)
{
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
struct nrf_wifi_event_current_temperature *event_current_temp = NULL;

if (!event) {
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
"%s: Invalid parameters",
__func__);
goto out;
}

if (!fmac_dev_ctx->temp_get_status) {
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
"%s: Temperature recevied when req was not sent!",
__func__);
goto out;
}

event_current_temp = ((struct nrf_wifi_event_current_temperature *)event);

fmac_dev_ctx->current_temp = event_current_temp->current_temperature;

fmac_dev_ctx->temp_get_status = false;

status = NRF_WIFI_STATUS_SUCCESS;

out:
return status;
}

static enum nrf_wifi_status umac_process_sys_events(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
struct host_rpu_msg *rpu_msg)
{
Expand Down Expand Up @@ -1092,6 +1124,10 @@ static enum nrf_wifi_status umac_process_sys_events(struct nrf_wifi_fmac_dev_ctx
status = NRF_WIFI_STATUS_SUCCESS;
break;
#endif /* CONFIG_NRF700X_RAW_DATA_RX || CONFIG_NRF700X_PROMISC_DATA_RX */
case NRF_WIFI_EVENT_CURRENT_TEMP:
status = umac_event_current_temp_proc(fmac_dev_ctx,
sys_head);
break;
default:
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
"%s: Unknown event recd: %d",
Expand Down
33 changes: 33 additions & 0 deletions nrf_wifi/fw_if/umac_if/src/fmac_api_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,3 +1301,36 @@ enum nrf_wifi_status nrf_wifi_fmac_set_packet_filter(void *dev_ctx, unsigned cha
return status;
}
#endif /* CONFIG_NRF700X_RAW_DATA_RX || CONFIG_NRF700X_PROMISC_DATA_RX */

enum nrf_wifi_status nrf_wifi_fmac_temp_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
int *current_temp)
{
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
unsigned char count = 0;

fmac_dev_ctx->temp_get_status = true;

status = umac_cmd_prog_temp_get(fmac_dev_ctx);

if (status != NRF_WIFI_STATUS_SUCCESS) {
goto out;
}

do {
nrf_wifi_osal_sleep_ms(fmac_dev_ctx->fpriv->opriv,
1);
count++;
} while ((fmac_dev_ctx->temp_get_status == true) &&
(count < NRF_WIFI_FMAC_STATS_RECV_TIMEOUT));

if (count == NRF_WIFI_FMAC_STATS_RECV_TIMEOUT) {
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
"%s: Timed out",
__func__);
goto out;
}

*current_temp = fmac_dev_ctx->current_temp;
out:
return status;
}

0 comments on commit f75980c

Please sign in to comment.