net: wireless: rockchip_wlan: add rtl8723cs support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723cs / hal / rtl8703b / rtl8703b_sreset.c
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
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  * 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
17  *
18  *
19  ******************************************************************************/
20 #define _RTL8703B_SRESET_C_
21
22 #include <rtl8703b_hal.h>
23
24
25 #ifdef DBG_CONFIG_ERROR_DETECT
26 void rtl8703b_sreset_xmit_status_check(_adapter *padapter)
27 {
28         HAL_DATA_TYPE   *pHalData = GET_HAL_DATA(padapter);
29         struct sreset_priv *psrtpriv = &pHalData->srestpriv;
30
31         unsigned long current_time;
32         struct xmit_priv        *pxmitpriv = &padapter->xmitpriv;
33         unsigned int diff_time;
34         u32 txdma_status;
35
36         txdma_status = rtw_read32(padapter, REG_TXDMA_STATUS);
37         if (txdma_status != 0x00 && txdma_status != 0xeaeaeaea) {
38                 RTW_INFO("%s REG_TXDMA_STATUS:0x%08x\n", __FUNCTION__, txdma_status);
39                 rtw_hal_sreset_reset(padapter);
40         }
41
42 #ifdef CONFIG_USB_HCI
43         /* total xmit irp = 4 */
44         /* RTW_INFO("==>%s free_xmitbuf_cnt(%d),txirp_cnt(%d)\n",__FUNCTION__,pxmitpriv->free_xmitbuf_cnt,pxmitpriv->txirp_cnt); */
45         /* if(pxmitpriv->txirp_cnt == NR_XMITBUFF+1) */
46         current_time = rtw_get_current_time();
47
48         if (0 == pxmitpriv->free_xmitbuf_cnt || 0 == pxmitpriv->free_xmit_extbuf_cnt) {
49
50                 diff_time = rtw_get_passing_time_ms(psrtpriv->last_tx_time);
51
52                 if (diff_time > 2000) {
53                         if (psrtpriv->last_tx_complete_time == 0)
54                                 psrtpriv->last_tx_complete_time = current_time;
55                         else {
56                                 diff_time = rtw_get_passing_time_ms(psrtpriv->last_tx_complete_time);
57                                 if (diff_time > 4000) {
58                                         u32 ability = 0;
59
60                                         /* padapter->Wifi_Error_Status = WIFI_TX_HANG; */
61                                         ability = rtw_phydm_ability_get(padapter);
62
63                                         RTW_INFO("%s tx hang %s\n", __FUNCTION__,
64                                                 (ability & ODM_BB_ADAPTIVITY) ? "ODM_BB_ADAPTIVITY" : "");
65
66                                         if (!(ability & ODM_BB_ADAPTIVITY))
67                                                 rtw_hal_sreset_reset(padapter);
68                                 }
69                         }
70                 }
71         }
72 #endif /*  #ifdef CONFIG_USB_HCI */
73
74         if (psrtpriv->dbg_trigger_point == SRESET_TGP_XMIT_STATUS) {
75                 psrtpriv->dbg_trigger_point = SRESET_TGP_NULL;
76                 rtw_hal_sreset_reset(padapter);
77                 return;
78         }
79 }
80
81 void rtl8703b_sreset_linked_status_check(_adapter *padapter)
82 {
83         HAL_DATA_TYPE   *pHalData = GET_HAL_DATA(padapter);
84         struct sreset_priv *psrtpriv = &pHalData->srestpriv;
85 #if 0
86         u32 regc50, regc58, reg824, reg800;
87         regc50 = rtw_read32(padapter, 0xc50);
88         regc58 = rtw_read32(padapter, 0xc58);
89         reg824 = rtw_read32(padapter, 0x824);
90         reg800 = rtw_read32(padapter, 0x800);
91         if (((regc50 & 0xFFFFFF00) != 0x69543400) ||
92             ((regc58 & 0xFFFFFF00) != 0x69543400) ||
93             (((reg824 & 0xFFFFFF00) != 0x00390000) && (((reg824 & 0xFFFFFF00) != 0x80390000))) ||
94             (((reg800 & 0xFFFFFF00) != 0x03040000) && ((reg800 & 0xFFFFFF00) != 0x83040000))) {
95                 RTW_INFO("%s regc50:0x%08x, regc58:0x%08x, reg824:0x%08x, reg800:0x%08x,\n", __FUNCTION__,
96                          regc50, regc58, reg824, reg800);
97                 rtw_hal_sreset_reset(padapter);
98         }
99 #endif
100
101         if (psrtpriv->dbg_trigger_point == SRESET_TGP_LINK_STATUS) {
102                 psrtpriv->dbg_trigger_point = SRESET_TGP_NULL;
103                 rtw_hal_sreset_reset(padapter);
104                 return;
105         }
106 }
107
108 #endif