1 /*
2 * Copyright (c) 2024 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 /**
8 * @brief File containing HPQM interface specific definitions for the
9 * HAL Layer of the Wi-Fi driver.
10 */
11
12 #include "common/hal_reg.h"
13 #include "common/hal_mem.h"
14 #include "common/hal_common.h"
15
hal_rpu_hpq_enqueue(struct nrf_wifi_hal_dev_ctx * hal_ctx,struct host_rpu_hpq * hpq,unsigned int val)16 enum nrf_wifi_status hal_rpu_hpq_enqueue(struct nrf_wifi_hal_dev_ctx *hal_ctx,
17 struct host_rpu_hpq *hpq,
18 unsigned int val)
19 {
20 enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
21
22 status = hal_rpu_reg_write(hal_ctx,
23 hpq->enqueue_addr,
24 val);
25
26 if (status != NRF_WIFI_STATUS_SUCCESS) {
27 nrf_wifi_osal_log_err("%s: Writing to enqueue address failed",
28 __func__);
29 goto out;
30 }
31
32 out:
33 return status;
34 }
35
36
hal_rpu_hpq_dequeue(struct nrf_wifi_hal_dev_ctx * hal_ctx,struct host_rpu_hpq * hpq,unsigned int * val)37 enum nrf_wifi_status hal_rpu_hpq_dequeue(struct nrf_wifi_hal_dev_ctx *hal_ctx,
38 struct host_rpu_hpq *hpq,
39 unsigned int *val)
40 {
41 enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
42
43 status = hal_rpu_reg_read(hal_ctx,
44 val,
45 hpq->dequeue_addr);
46
47 if (status != NRF_WIFI_STATUS_SUCCESS) {
48 nrf_wifi_osal_log_err("%s: Dequeue failed, val (0x%X)",
49 __func__,
50 *val);
51 goto out;
52 }
53
54 /* Pop the element only if it is valid */
55 if (*val) {
56 status = hal_rpu_reg_write(hal_ctx,
57 hpq->dequeue_addr,
58 *val);
59
60 if (status != NRF_WIFI_STATUS_SUCCESS) {
61 nrf_wifi_osal_log_err("%s: Writing to dequeue address failed, val (0x%X)",
62 __func__,
63 *val);
64 goto out;
65 }
66 }
67 out:
68 return status;
69 }
70