xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8723ds/hal/rtl8723d/rtl8723d_sreset.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  *****************************************************************************/
15 #define _RTL8723D_SRESET_C_
16 
17 #include <rtl8723d_hal.h>
18 
19 
20 #ifdef DBG_CONFIG_ERROR_DETECT
rtl8723d_sreset_xmit_status_check(_adapter * padapter)21 void rtl8723d_sreset_xmit_status_check(_adapter *padapter)
22 {
23 	HAL_DATA_TYPE	*pHalData = GET_HAL_DATA(padapter);
24 	struct sreset_priv *psrtpriv = &pHalData->srestpriv;
25 
26 	systime current_time;
27 	struct xmit_priv	*pxmitpriv = &padapter->xmitpriv;
28 	unsigned int diff_time;
29 	u32 txdma_status;
30 
31 	txdma_status = rtw_read32(padapter, REG_TXDMA_STATUS);
32 	if (txdma_status != 0x00 && txdma_status != 0xeaeaeaea) {
33 		RTW_INFO("%s REG_TXDMA_STATUS:0x%08x\n", __FUNCTION__, txdma_status);
34 		rtw_hal_sreset_reset(padapter);
35 	}
36 
37 #ifdef CONFIG_USB_HCI
38 	/* total xmit irp = 4 */
39 	/* DBG_8192C("==>%s free_xmitbuf_cnt(%d),txirp_cnt(%d)\n",__FUNCTION__,pxmitpriv->free_xmitbuf_cnt,pxmitpriv->txirp_cnt); */
40 	/* if(pxmitpriv->txirp_cnt == NR_XMITBUFF+1) */
41 	current_time = rtw_get_current_time();
42 
43 	if (0 == pxmitpriv->free_xmitbuf_cnt || 0 == pxmitpriv->free_xmit_extbuf_cnt) {
44 
45 		diff_time = rtw_get_passing_time_ms(psrtpriv->last_tx_time);
46 
47 		if (diff_time > 2000) {
48 			if (psrtpriv->last_tx_complete_time == 0)
49 				psrtpriv->last_tx_complete_time = current_time;
50 			else {
51 				diff_time = rtw_get_passing_time_ms(psrtpriv->last_tx_complete_time);
52 				if (diff_time > 4000) {
53 
54 					/* padapter->Wifi_Error_Status = WIFI_TX_HANG; */
55 					RTW_INFO("%s tx hang %s\n", __FUNCTION__,
56 						!adapter_to_rfctl(padapter)->adaptivity_en ? "" :
57 							rtw_edcca_mode_str(rtw_get_edcca_mode(adapter_to_dvobj(padapter), pHalData->current_band_type)));
58 
59 					if (!adapter_to_rfctl(padapter)->adaptivity_en)
60 						rtw_hal_sreset_reset(padapter);
61 				}
62 			}
63 		}
64 	}
65 #endif /*  #ifdef CONFIG_USB_HCI */
66 
67 	if (psrtpriv->dbg_trigger_point == SRESET_TGP_XMIT_STATUS) {
68 		psrtpriv->dbg_trigger_point = SRESET_TGP_NULL;
69 		rtw_hal_sreset_reset(padapter);
70 		return;
71 	}
72 }
73 
rtl8723d_sreset_linked_status_check(_adapter * padapter)74 void rtl8723d_sreset_linked_status_check(_adapter *padapter)
75 {
76 	HAL_DATA_TYPE	*pHalData = GET_HAL_DATA(padapter);
77 	struct sreset_priv *psrtpriv = &pHalData->srestpriv;
78 #if 0
79 	u32 regc50, regc58, reg824, reg800;
80 
81 	regc50 = rtw_read32(padapter, 0xc50);
82 	regc58 = rtw_read32(padapter, 0xc58);
83 	reg824 = rtw_read32(padapter, 0x824);
84 	reg800 = rtw_read32(padapter, 0x800);
85 	if (((regc50 & 0xFFFFFF00) != 0x69543400) ||
86 	    ((regc58 & 0xFFFFFF00) != 0x69543400) ||
87 	    (((reg824 & 0xFFFFFF00) != 0x00390000) && (((reg824 & 0xFFFFFF00) != 0x80390000))) ||
88 	    (((reg800 & 0xFFFFFF00) != 0x03040000) && ((reg800 & 0xFFFFFF00) != 0x83040000))) {
89 		DBG_8192C("%s regc50:0x%08x, regc58:0x%08x, reg824:0x%08x, reg800:0x%08x,\n", __FUNCTION__,
90 			  regc50, regc58, reg824, reg800);
91 		rtw_hal_sreset_reset(padapter);
92 	}
93 #endif
94 
95 	if (psrtpriv->dbg_trigger_point == SRESET_TGP_LINK_STATUS) {
96 		psrtpriv->dbg_trigger_point = SRESET_TGP_NULL;
97 		rtw_hal_sreset_reset(padapter);
98 		return;
99 	}
100 }
101 
102 #endif
103