Skip to content

Commit f75980c

Browse files
committed
nrf_wifi: Add support to get current temperature
Add command/event to retrieve current temperature. Signed-off-by: Ajay Parida <[email protected]>
1 parent 4309051 commit f75980c

File tree

7 files changed

+144
-0
lines changed

7 files changed

+144
-0
lines changed

nrf_wifi/fw_if/umac_if/inc/fmac_api_common.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,19 @@ enum nrf_wifi_status nrf_wifi_fmac_set_packet_filter(void *dev_ctx, unsigned cha
362362
unsigned short buffer_size);
363363
#endif /* CONFIG_NRF700X_RAW_DATA_RX || CONFIG_NRF700X_PROMISC_DATA_RX */
364364

365+
/**
366+
* @brief Issue a request to get current temperature from the RPU.
367+
* @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device.
368+
* @param current_temp Pointer to memory where the current temp is to be copied.
369+
*
370+
* This function is used to send a command to
371+
* instruct the firmware to return the current temperature. The RPU will
372+
* send the event with the current temperature.
373+
*
374+
* @return Command execution status
375+
*/
376+
enum nrf_wifi_status nrf_wifi_fmac_temp_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
377+
int *current_temp);
365378
/**
366379
* @}
367380
*/

nrf_wifi/fw_if/umac_if/inc/fmac_cmd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,6 @@ enum nrf_wifi_status umac_cmd_prog_stats_get(struct nrf_wifi_fmac_dev_ctx *fmac_
7373
#endif /* CONFIG_NRF700X_RADIO_TEST */
7474
int stat_type);
7575

76+
enum nrf_wifi_status umac_cmd_prog_temp_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx);
77+
7678
#endif /* __FMAC_CMD_H__ */

nrf_wifi/fw_if/umac_if/inc/fmac_structs_common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ struct nrf_wifi_fmac_dev_ctx {
176176
struct nrf_wifi_event_regulatory_change *reg_change;
177177
/** TX power ceiling parameters */
178178
struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params;
179+
/** current temp request status */
180+
int temp_get_status;
181+
/** current temperature */
182+
int current_temp;
179183
/** Data pointer to mode specific parameters */
180184
char priv[];
181185
};

nrf_wifi/fw_if/umac_if/inc/fw/host_rpu_sys_if.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ enum nrf_wifi_sys_commands {
161161
NRF_WIFI_CMD_RAW_CONFIG_FILTER,
162162
/** Command to configure packet injector mode or Raw Tx mode */
163163
NRF_WIFI_CMD_RAW_TX_PKT,
164+
/** Command to get RPU temperature */
165+
NRF_WIFI_CMD_GET_TEMP,
164166
};
165167

166168
/**
@@ -192,6 +194,8 @@ enum nrf_wifi_sys_events {
192194
NRF_WIFI_EVENT_FILTER_SET_DONE,
193195
/** Tx done event for the Raw Tx */
194196
NRF_WIFI_EVENT_RAW_TX_DONE,
197+
/** Response to NRF_WIFI_CMD_GET_TEMP */
198+
NRF_WIFI_EVENT_CURRENT_TEMP,
195199
};
196200

197201
/**
@@ -1597,4 +1601,24 @@ struct nrf_wifi_event_deinit_done {
15971601
struct nrf_wifi_sys_head sys_head;
15981602
} __NRF_WIFI_PKD;
15991603

1604+
/**
1605+
* @brief This structure represents the command used to get the RPU temperature.
1606+
*/
1607+
struct nrf_wifi_cmd_get_temperature {
1608+
/** UMAC header, @ref nrf_wifi_sys_head */
1609+
struct nrf_wifi_sys_head sys_head;
1610+
} __NRF_WIFI_PKD;
1611+
1612+
/**
1613+
* @brief This structure represents an event that provides the current RPU temperature
1614+
* in degree celsius.
1615+
*
1616+
*/
1617+
struct nrf_wifi_event_current_temperature {
1618+
/** UMAC header, @ref nrf_wifi_sys_head */
1619+
struct nrf_wifi_sys_head sys_head;
1620+
/** Current temperature value in degree celsius */
1621+
int current_temperature;
1622+
} __NRF_WIFI_PKD;
1623+
16001624
#endif /* __HOST_RPU_SYS_IF_H__ */

nrf_wifi/fw_if/umac_if/src/cmd.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,3 +541,35 @@ enum nrf_wifi_status umac_cmd_prog_stats_get(struct nrf_wifi_fmac_dev_ctx *fmac_
541541
out:
542542
return status;
543543
}
544+
545+
enum nrf_wifi_status umac_cmd_prog_temp_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx)
546+
{
547+
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
548+
struct host_rpu_msg *umac_cmd = NULL;
549+
struct nrf_wifi_cmd_get_temperature *umac_cmd_data = NULL;
550+
int len = 0;
551+
552+
len = sizeof(*umac_cmd_data);
553+
554+
umac_cmd = umac_cmd_alloc(fmac_dev_ctx,
555+
NRF_WIFI_HOST_RPU_MSG_TYPE_SYSTEM,
556+
len);
557+
558+
if (!umac_cmd) {
559+
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
560+
"%s: umac_cmd_alloc failed",
561+
__func__);
562+
goto out;
563+
}
564+
565+
umac_cmd_data = (struct nrf_wifi_cmd_get_temperature *)(umac_cmd->msg);
566+
567+
umac_cmd_data->sys_head.cmd_event = NRF_WIFI_CMD_GET_TEMP;
568+
umac_cmd_data->sys_head.len = len;
569+
570+
status = nrf_wifi_hal_ctrl_cmd_send(fmac_dev_ctx->hal_dev_ctx,
571+
umac_cmd,
572+
(sizeof(*umac_cmd) + len));
573+
out:
574+
return status;
575+
}

nrf_wifi/fw_if/umac_if/src/event.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,38 @@ nrf_wifi_fmac_if_mode_set_event_proc(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
10081008
}
10091009
#endif /* CONFIG_NRF700X_SYSTEM_WITH_RAW_MODES */
10101010

1011+
static enum nrf_wifi_status umac_event_current_temp_proc(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
1012+
void *event)
1013+
{
1014+
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
1015+
struct nrf_wifi_event_current_temperature *event_current_temp = NULL;
1016+
1017+
if (!event) {
1018+
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
1019+
"%s: Invalid parameters",
1020+
__func__);
1021+
goto out;
1022+
}
1023+
1024+
if (!fmac_dev_ctx->temp_get_status) {
1025+
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
1026+
"%s: Temperature recevied when req was not sent!",
1027+
__func__);
1028+
goto out;
1029+
}
1030+
1031+
event_current_temp = ((struct nrf_wifi_event_current_temperature *)event);
1032+
1033+
fmac_dev_ctx->current_temp = event_current_temp->current_temperature;
1034+
1035+
fmac_dev_ctx->temp_get_status = false;
1036+
1037+
status = NRF_WIFI_STATUS_SUCCESS;
1038+
1039+
out:
1040+
return status;
1041+
}
1042+
10111043
static enum nrf_wifi_status umac_process_sys_events(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
10121044
struct host_rpu_msg *rpu_msg)
10131045
{
@@ -1092,6 +1124,10 @@ static enum nrf_wifi_status umac_process_sys_events(struct nrf_wifi_fmac_dev_ctx
10921124
status = NRF_WIFI_STATUS_SUCCESS;
10931125
break;
10941126
#endif /* CONFIG_NRF700X_RAW_DATA_RX || CONFIG_NRF700X_PROMISC_DATA_RX */
1127+
case NRF_WIFI_EVENT_CURRENT_TEMP:
1128+
status = umac_event_current_temp_proc(fmac_dev_ctx,
1129+
sys_head);
1130+
break;
10951131
default:
10961132
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
10971133
"%s: Unknown event recd: %d",

nrf_wifi/fw_if/umac_if/src/fmac_api_common.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,3 +1301,36 @@ enum nrf_wifi_status nrf_wifi_fmac_set_packet_filter(void *dev_ctx, unsigned cha
13011301
return status;
13021302
}
13031303
#endif /* CONFIG_NRF700X_RAW_DATA_RX || CONFIG_NRF700X_PROMISC_DATA_RX */
1304+
1305+
enum nrf_wifi_status nrf_wifi_fmac_temp_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx,
1306+
int *current_temp)
1307+
{
1308+
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
1309+
unsigned char count = 0;
1310+
1311+
fmac_dev_ctx->temp_get_status = true;
1312+
1313+
status = umac_cmd_prog_temp_get(fmac_dev_ctx);
1314+
1315+
if (status != NRF_WIFI_STATUS_SUCCESS) {
1316+
goto out;
1317+
}
1318+
1319+
do {
1320+
nrf_wifi_osal_sleep_ms(fmac_dev_ctx->fpriv->opriv,
1321+
1);
1322+
count++;
1323+
} while ((fmac_dev_ctx->temp_get_status == true) &&
1324+
(count < NRF_WIFI_FMAC_STATS_RECV_TIMEOUT));
1325+
1326+
if (count == NRF_WIFI_FMAC_STATS_RECV_TIMEOUT) {
1327+
nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv,
1328+
"%s: Timed out",
1329+
__func__);
1330+
goto out;
1331+
}
1332+
1333+
*current_temp = fmac_dev_ctx->current_temp;
1334+
out:
1335+
return status;
1336+
}

0 commit comments

Comments
 (0)