1 /******************************************************************************
3 * Copyright(c) 2015 - 2016 Realtek Corporation. All rights reserved.
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.
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
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 ******************************************************************************/
20 #define _RTL8822B_MAC_C_
22 #include <drv_types.h> /* PADAPTER, basic_types.h and etc. */
23 #include <hal_data.h> /* HAL_DATA_TYPE */
24 #include "../hal_halmac.h" /* Register Definition and etc. */
27 inline u8 rtl8822b_rcr_config(PADAPTER p, u32 rcr)
33 v32 = GET_HAL_DATA(p)->ReceiveConfig;
35 v32 &= BIT_APP_PHYSTS_8822B;
37 v32 = rcr & BIT_APP_PHYSTS_8822B;
38 RTW_INFO("%s: runtime %s rx phy status!\n",
39 __FUNCTION__, v32 ? "ENABLE" : "DISABLE");
41 err = rtw_halmac_config_rx_info(adapter_to_dvobj(p), HALMAC_DRV_INFO_PHY_STATUS);
43 RTW_INFO("%s: Enable rx phy status FAIL!!", __FUNCTION__);
44 rcr &= ~BIT_APP_PHYSTS_8822B;
47 err = rtw_halmac_config_rx_info(adapter_to_dvobj(p), HALMAC_DRV_INFO_NONE);
49 RTW_INFO("%s: Disable rx phy status FAIL!!", __FUNCTION__);
50 rcr |= BIT_APP_PHYSTS_8822B;
55 err = rtw_write32(p, REG_RCR_8822B, rcr);
59 GET_HAL_DATA(p)->ReceiveConfig = rcr;
63 inline u8 rtl8822b_rcr_get(PADAPTER p, u32 *rcr)
67 v32 = rtw_read32(p, REG_RCR_8822B);
70 GET_HAL_DATA(p)->ReceiveConfig = v32;
74 inline u8 rtl8822b_rcr_check(PADAPTER p, u32 check_bit)
79 hal = GET_HAL_DATA(p);
80 rcr = hal->ReceiveConfig;
81 if ((rcr & check_bit) == check_bit)
87 inline u8 rtl8822b_rcr_add(PADAPTER p, u32 add)
93 hal = GET_HAL_DATA(p);
95 rcr = hal->ReceiveConfig;
97 if (rcr != hal->ReceiveConfig)
98 ret = rtl8822b_rcr_config(p, rcr);
103 inline u8 rtl8822b_rcr_clear(PADAPTER p, u32 clear)
109 hal = GET_HAL_DATA(p);
111 rcr = hal->ReceiveConfig;
113 if (rcr != hal->ReceiveConfig)
114 ret = rtl8822b_rcr_config(p, rcr);
119 inline u8 rtl8822b_rx_ba_ssn_appended(PADAPTER p)
121 return rtl8822b_rcr_check(p, BIT_APP_BASSN_8822B);
124 inline u8 rtl8822b_rx_fcs_append_switch(PADAPTER p, u8 enable)
129 rcr_bit = BIT_APP_FCS_8822B;
131 ret = rtl8822b_rcr_add(p, rcr_bit);
133 ret = rtl8822b_rcr_clear(p, rcr_bit);
138 inline u8 rtl8822b_rx_fcs_appended(PADAPTER p)
140 return rtl8822b_rcr_check(p, BIT_APP_FCS_8822B);
143 inline u8 rtl8822b_rx_tsf_addr_filter_config(PADAPTER p, u8 config)
148 v8 = GET_HAL_DATA(p)->rx_tsf_addr_filter_config;
152 err = rtw_write8(p, REG_NAN_RX_TSF_FILTER_8822B, config);
157 GET_HAL_DATA(p)->rx_tsf_addr_filter_config = config;
163 * _SUCCESS Download Firmware OK.
164 * _FAIL Download Firmware FAIL!
166 s32 rtl8822b_fw_dl(PADAPTER adapter, u8 wowlan)
168 struct dvobj_priv *d;
172 if (_TRUE == wowlan) {
173 RTW_INFO("%s: NOT support WOWLan firmware yet!\n", __FUNCTION__);
177 d = adapter_to_dvobj(adapter);
179 err = rtw_halmac_dlfw_from_file(d, REALTEK_CONFIG_PATH "RTL8822Bfw_NIC.bin");
181 RTW_INFO("%s: Download Firmware fail\n", __FUNCTION__);