xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8822cs/hal/phydm/rtl8822c/phydm_rtl8822c.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2017  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  * The full GNU General Public License is included in this distribution in the
15  * file called LICENSE.
16  *
17  * Contact Information:
18  * wlanfae <wlanfae@realtek.com>
19  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20  * Hsinchu 300, Taiwan.
21  *
22  * Larry Finger <Larry.Finger@lwfinger.net>
23  *
24  *****************************************************************************/
25 #include "mp_precomp.h"
26 #include "../phydm_precomp.h"
27 
28 #if (RTL8822C_SUPPORT)
phydm_dynamic_switch_htstf_agc_8822c(struct dm_struct * dm)29 void phydm_dynamic_switch_htstf_agc_8822c(struct dm_struct *dm)
30 {
31 	u16 ndp_valid_cnt = 0;
32 	u16 ndp_valid_cnt_diff = 0;
33 
34 	if (dm->bhtstfdisabled)
35 		return;
36 
37 	/*set debug port to 0x51f*/
38 	if (phydm_set_bb_dbg_port(dm, DBGPORT_PRI_1, 0x51f)) {
39 		ndp_valid_cnt = (u16)(phydm_get_bb_dbg_port_val(dm) & 0xff);
40 		phydm_release_bb_dbg_port(dm);
41 
42 		ndp_valid_cnt_diff = DIFF_2(dm->ndp_cnt_pre, ndp_valid_cnt);
43 		dm->ndp_cnt_pre = ndp_valid_cnt;
44 
45 		if (ndp_valid_cnt_diff)
46 			dm->is_beamformed = true;
47 		else
48 			dm->is_beamformed = false;
49 
50 		if (dm->total_tp == 0 || dm->is_beamformed) {
51 			odm_set_bb_reg(dm, R_0x8a0, BIT(2), 0x1);
52 			dm->no_ndp_cnts = 0;
53 		} else {
54 			if (dm->no_ndp_cnts == 3)
55 				odm_set_bb_reg(dm, R_0x8a0, BIT(2), 0x0);
56 			else if (dm->no_ndp_cnts < 3)
57 				dm->no_ndp_cnts++;
58 		}
59 	}
60 }
61 
phydm_hwsetting_8822c(struct dm_struct * dm)62 void phydm_hwsetting_8822c(struct dm_struct *dm)
63 {
64 	phydm_dynamic_switch_htstf_agc_8822c(dm);
65 }
66 #endif
67