1 /*
2  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #include "hal_api.h"
20 #include "hal_hw_headers.h"
21 #include "hal_reo.h"
22 #include "qdf_module.h"
23 
hal_reo_init_cmd_ring(hal_soc_handle_t hal_soc_hdl,hal_ring_handle_t hal_ring_hdl)24 void hal_reo_init_cmd_ring(hal_soc_handle_t hal_soc_hdl,
25 			   hal_ring_handle_t hal_ring_hdl)
26 {
27 	int cmd_num;
28 	uint32_t *desc_addr;
29 	struct hal_srng_params srng_params;
30 	uint32_t desc_size;
31 	uint32_t num_desc;
32 	struct hal_soc *soc = (struct hal_soc *)hal_soc_hdl;
33 	uint8_t tlv_hdr_size;
34 
35 	hal_get_srng_params(hal_soc_hdl, hal_ring_hdl, &srng_params);
36 
37 	desc_addr = (uint32_t *)(srng_params.ring_base_vaddr);
38 	tlv_hdr_size = hal_get_tlv_hdr_size(hal_soc_hdl);
39 	desc_addr += HAL_GET_NUM_DWORDS(tlv_hdr_size);
40 	desc_size = HAL_GET_NUM_DWORDS(hal_srng_get_entrysize(soc, REO_CMD));
41 	num_desc = srng_params.num_entries;
42 	cmd_num = 1;
43 	while (num_desc) {
44 		/* Offsets of descriptor fields defined in HW headers start
45 		 * from the field after TLV header */
46 		HAL_DESC_SET_FIELD(desc_addr, HAL_UNIFORM_REO_CMD_HEADER,
47 				   REO_CMD_NUMBER, cmd_num);
48 		desc_addr += desc_size;
49 		num_desc--; cmd_num++;
50 	}
51 
52 	soc->reo_res_bitmap = 0;
53 }
54 qdf_export_symbol(hal_reo_init_cmd_ring);
55