1 /*
2  * Copyright (c) 2024 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @brief File containing FW load functions for Zephyr.
9  */
10 #include <stdlib.h>
11 #include <string.h>
12 
13 #include <zephyr/kernel.h>
14 #include <zephyr/device.h>
15 
16 #include <zephyr/logging/log.h>
17 LOG_MODULE_DECLARE(wifi_nrf, CONFIG_WIFI_NRF70_LOG_LEVEL);
18 
19 #include <fmac_main.h>
20 static const char fw_patch[] = {
21 	#include <nrf70_fw_patch/nrf70.bin.inc>
22 };
23 
nrf_wifi_fw_load(void * rpu_ctx)24 enum nrf_wifi_status nrf_wifi_fw_load(void *rpu_ctx)
25 {
26 	enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
27 	struct nrf_wifi_fmac_fw_info fw_info = { 0 };
28 
29 	status = nrf_wifi_fmac_fw_parse(rpu_ctx, fw_patch, sizeof(fw_patch), &fw_info);
30 	if (status != NRF_WIFI_STATUS_SUCCESS) {
31 		LOG_ERR("%s: nrf_wifi_fmac_fw_parse failed", __func__);
32 		return status;
33 	}
34 	/* Load the FW patches to the RPU */
35 	status = nrf_wifi_fmac_fw_load(rpu_ctx, &fw_info);
36 
37 	if (status != NRF_WIFI_STATUS_SUCCESS) {
38 		LOG_ERR("%s: nrf_wifi_fmac_fw_load failed", __func__);
39 	}
40 
41 	return status;
42 }
43