Linux-libre 3.14.42-gnu
[librecmc/linux-libre.git] / drivers / staging / rtl8188eu / hal / rtl8188e_sreset.c
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 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 _RTL8188E_SRESET_C_
21
22 #include <rtl8188e_sreset.h>
23 #include <rtl8188e_hal.h>
24
25 void rtl8188e_silentreset_for_specific_platform(struct adapter *padapter)
26 {
27 }
28
29 void rtl8188e_sreset_xmit_status_check(struct adapter *padapter)
30 {
31         struct hal_data_8188e   *pHalData = GET_HAL_DATA(padapter);
32         struct sreset_priv *psrtpriv = &pHalData->srestpriv;
33
34         unsigned long current_time;
35         struct xmit_priv        *pxmitpriv = &padapter->xmitpriv;
36         unsigned int diff_time;
37         u32 txdma_status;
38
39         txdma_status = rtw_read32(padapter, REG_TXDMA_STATUS);
40         if (txdma_status != 0x00) {
41                 DBG_88E("%s REG_TXDMA_STATUS:0x%08x\n", __func__, txdma_status);
42                 rtw_write32(padapter, REG_TXDMA_STATUS, txdma_status);
43                 rtl8188e_silentreset_for_specific_platform(padapter);
44         }
45         /* total xmit irp = 4 */
46         current_time = jiffies;
47         if (0 == pxmitpriv->free_xmitbuf_cnt) {
48                 diff_time = jiffies_to_msecs(current_time - psrtpriv->last_tx_time);
49
50                 if (diff_time > 2000) {
51                         if (psrtpriv->last_tx_complete_time == 0) {
52                                 psrtpriv->last_tx_complete_time = current_time;
53                         } else {
54                                 diff_time = jiffies_to_msecs(current_time - psrtpriv->last_tx_complete_time);
55                                 if (diff_time > 4000) {
56                                         DBG_88E("%s tx hang\n", __func__);
57                                         rtl8188e_silentreset_for_specific_platform(padapter);
58                                 }
59                         }
60                 }
61         }
62 }
63
64 void rtl8188e_sreset_linked_status_check(struct adapter *padapter)
65 {
66         u32 rx_dma_status = 0;
67         u8 fw_status = 0;
68         rx_dma_status = rtw_read32(padapter, REG_RXDMA_STATUS);
69         if (rx_dma_status != 0x00) {
70                 DBG_88E("%s REG_RXDMA_STATUS:0x%08x\n", __func__, rx_dma_status);
71                 rtw_write32(padapter, REG_RXDMA_STATUS, rx_dma_status);
72         }
73         fw_status = rtw_read8(padapter, REG_FMETHR);
74         if (fw_status != 0x00) {
75                 if (fw_status == 1)
76                         DBG_88E("%s REG_FW_STATUS (0x%02x), Read_Efuse_Fail !!\n", __func__, fw_status);
77                 else if (fw_status == 2)
78                         DBG_88E("%s REG_FW_STATUS (0x%02x), Condition_No_Match !!\n", __func__, fw_status);
79         }
80 }