2c1ee809da3689092e5d654bc99b0919cfa23371
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723bs / hal / rtl8723b / rtl8723b_sreset.c
1 /******************************************************************************\r
2  *\r
3  * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.\r
4  *\r
5  * This program is free software; you can redistribute it and/or modify it\r
6  * under the terms of version 2 of the GNU General Public License as\r
7  * published by the Free Software Foundation.\r
8  *\r
9  * This program is distributed in the hope that it will be useful, but WITHOUT\r
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
12  * more details.\r
13  *\r
14  * You should have received a copy of the GNU General Public License along with\r
15  * this program; if not, write to the Free Software Foundation, Inc.,\r
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA\r
17  *\r
18  *\r
19  ******************************************************************************/\r
20 #define _RTL8723B_SRESET_C_\r
21 \r
22 #include <rtl8723b_hal.h>\r
23 \r
24 \r
25 #ifdef DBG_CONFIG_ERROR_DETECT\r
26 void rtl8723b_sreset_xmit_status_check(_adapter *padapter)\r
27 {\r
28         HAL_DATA_TYPE   *pHalData = GET_HAL_DATA(padapter);\r
29         struct sreset_priv *psrtpriv = &pHalData->srestpriv;\r
30 \r
31         unsigned long current_time;\r
32         struct xmit_priv        *pxmitpriv = &padapter->xmitpriv;\r
33         unsigned int diff_time;\r
34         u32 txdma_status;\r
35 \r
36         txdma_status=rtw_read32(padapter, REG_TXDMA_STATUS);\r
37         if( txdma_status !=0x00 && txdma_status !=0xeaeaeaea){\r
38                 DBG_871X("%s REG_TXDMA_STATUS:0x%08x\n", __FUNCTION__, txdma_status);\r
39                 rtw_hal_sreset_reset(padapter);\r
40         }\r
41 \r
42 #ifdef CONFIG_USB_HCI\r
43         //total xmit irp = 4\r
44         //DBG_8192C("==>%s free_xmitbuf_cnt(%d),txirp_cnt(%d)\n",__FUNCTION__,pxmitpriv->free_xmitbuf_cnt,pxmitpriv->txirp_cnt);\r
45         //if(pxmitpriv->txirp_cnt == NR_XMITBUFF+1)\r
46         current_time = rtw_get_current_time();\r
47 \r
48         if(0 == pxmitpriv->free_xmitbuf_cnt || 0 == pxmitpriv->free_xmit_extbuf_cnt) {\r
49 \r
50                 diff_time = rtw_get_passing_time_ms(psrtpriv->last_tx_time);\r
51 \r
52                 if (diff_time > 2000) {\r
53                         if (psrtpriv->last_tx_complete_time == 0) {\r
54                                 psrtpriv->last_tx_complete_time = current_time;\r
55                         }\r
56                         else{\r
57                                 diff_time = rtw_get_passing_time_ms(psrtpriv->last_tx_complete_time);\r
58                                 if (diff_time > 4000) {\r
59                                         u32 ability;\r
60 \r
61                                         //padapter->Wifi_Error_Status = WIFI_TX_HANG;\r
62                                         rtw_hal_get_hwreg(padapter, HW_VAR_DM_FLAG, (u8*)&ability);\r
63 \r
64                                         DBG_871X("%s tx hang %s\n", __FUNCTION__,\r
65                                                 (ability & ODM_BB_ADAPTIVITY)? "ODM_BB_ADAPTIVITY" : "");\r
66 \r
67                                         if (!(ability & ODM_BB_ADAPTIVITY))\r
68                                                 rtw_hal_sreset_reset(padapter);\r
69                                 }\r
70                         }\r
71                 }\r
72         }\r
73 #endif // #ifdef CONFIG_USB_HCI\r
74 \r
75         if (psrtpriv->dbg_trigger_point == SRESET_TGP_XMIT_STATUS) {\r
76                 psrtpriv->dbg_trigger_point = SRESET_TGP_NULL;\r
77                 rtw_hal_sreset_reset(padapter);\r
78                 return;\r
79         }\r
80 }\r
81 \r
82 void rtl8723b_sreset_linked_status_check(_adapter *padapter)\r
83 {\r
84         HAL_DATA_TYPE   *pHalData = GET_HAL_DATA(padapter);\r
85         struct sreset_priv *psrtpriv = &pHalData->srestpriv;\r
86 #if 0\r
87         u32 regc50,regc58,reg824,reg800;\r
88         regc50 = rtw_read32(padapter,0xc50);\r
89         regc58 = rtw_read32(padapter,0xc58);\r
90         reg824 = rtw_read32(padapter,0x824);\r
91         reg800 = rtw_read32(padapter,0x800);\r
92         if(     ((regc50&0xFFFFFF00)!= 0x69543400)||\r
93                 ((regc58&0xFFFFFF00)!= 0x69543400)||\r
94                 (((reg824&0xFFFFFF00)!= 0x00390000)&&(((reg824&0xFFFFFF00)!= 0x80390000)))||\r
95                 ( ((reg800&0xFFFFFF00)!= 0x03040000)&&((reg800&0xFFFFFF00)!= 0x83040000)))\r
96         {\r
97                 DBG_8192C("%s regc50:0x%08x, regc58:0x%08x, reg824:0x%08x, reg800:0x%08x,\n", __FUNCTION__,\r
98                         regc50, regc58, reg824, reg800);\r
99                 rtw_hal_sreset_reset(padapter);\r
100         }\r
101 #endif\r
102 \r
103         if (psrtpriv->dbg_trigger_point == SRESET_TGP_LINK_STATUS) {\r
104                 psrtpriv->dbg_trigger_point = SRESET_TGP_NULL;\r
105                 rtw_hal_sreset_reset(padapter);\r
106                 return;\r
107         }\r
108 }\r
109 \r
110 #endif\r
111 \r