xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8852bs/phl/hal_g6/hal_custom.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2019 Realtek Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  *****************************************************************************/
15 #define _HAL_CUSTOM_C_
16 #include "hal_headers.h"
17 
18 #ifdef CONFIG_PHL_CUSTOM_FEATURE
19 enum rtw_hal_status
rtw_hal_custom_cfg_tx_ampdu(void * hal,struct rtw_wifi_role_t * wrole,struct rtw_phl_custom_ampdu_cfg * ampdu)20 rtw_hal_custom_cfg_tx_ampdu(void *hal,
21                             struct rtw_wifi_role_t *wrole,
22                             struct rtw_phl_custom_ampdu_cfg *ampdu)
23 {
24 	struct hal_info_t *hal_info = (struct hal_info_t *)hal;
25 	enum rtw_hal_status hsts = RTW_HAL_STATUS_FAILURE;
26 	if (wrole == NULL || ampdu == NULL)
27 		return hsts;
28 	hsts = rtw_hal_mac_set_hw_ampdu_cfg(hal_info,
29 	                                    wrole->hw_band,
30 	                                    (u16)ampdu->max_agg_num,
31 	                                    (u8)ampdu->max_agg_time_32us);
32 	return hsts;
33 }
34 
35 enum rtw_hal_status
rtw_hal_get_ampdu_cfg(void * hal,struct rtw_wifi_role_t * wrole,struct rtw_phl_custom_ampdu_cfg * cfg)36 rtw_hal_get_ampdu_cfg(void *hal,
37                       struct rtw_wifi_role_t *wrole,
38                       struct rtw_phl_custom_ampdu_cfg *cfg)
39 {
40 	struct hal_info_t *hal_info = (struct hal_info_t *)hal;
41 	enum rtw_hal_status hsts = RTW_HAL_STATUS_FAILURE;
42 	struct mac_ax_ampdu_cfg ampdu_cfg = {0};
43 
44 	if (wrole == NULL || cfg == NULL)
45 		return hsts;
46 	hsts = rtw_hal_mac_get_ampdu_cfg(hal_info->hal_com,
47 	                                 wrole->hw_band,
48 	                                 &ampdu_cfg);
49 	if (hsts == RTW_HAL_STATUS_SUCCESS) {
50 		cfg->max_agg_num = ampdu_cfg.max_agg_num;
51 		cfg->max_agg_time_32us = ampdu_cfg.max_agg_time_32us;
52 	}
53 	return hsts;
54 }
55 
56 enum rtw_hal_status
rtw_hal_set_pop_en(void * hal,bool en,enum phl_phy_idx phy_idx)57 rtw_hal_set_pop_en(void *hal, bool en, enum phl_phy_idx phy_idx)
58 {
59 	struct hal_info_t *hal_info = (struct hal_info_t *)hal;
60 	return rtw_hal_bb_set_pop_en(hal_info, en, phy_idx);
61 }
62 
63 bool
rtw_hal_query_pop_en(void * hal,enum phl_phy_idx phy_idx)64 rtw_hal_query_pop_en(void *hal, enum phl_phy_idx phy_idx)
65 {
66 	struct hal_info_t *hal_info = (struct hal_info_t *)hal;
67 	return rtw_hal_bb_query_pop_en(hal_info, phy_idx);
68 }
69 
70 enum rtw_hal_status
rtw_hal_set_pkt_detect_thold(void * hal,u32 bound)71 rtw_hal_set_pkt_detect_thold(void *hal, u32 bound)
72 {
73 	struct hal_info_t *hal_info = (struct hal_info_t *)hal;
74 	return rtw_hal_bb_set_pkt_detect_thold(hal_info, bound);
75 }
76 
77 u8
rtw_hal_query_pkt_detect_thold(void * hal,bool get_en_info,enum phl_phy_idx phy_idx)78 rtw_hal_query_pkt_detect_thold(void *hal,
79                                bool get_en_info,
80                                enum phl_phy_idx phy_idx)
81 {
82 	struct hal_info_t *hal_info = (struct hal_info_t *)hal;
83 	return rtw_hal_bb_query_pkt_detect_thold(hal_info, get_en_info, phy_idx);
84 }
85 #endif
86 
87