net: wireless: rockchip_wlan: add rtl8188eu support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8188eu / hal / rtl8188e / rtl8188e_sreset.c
old mode 100755 (executable)
new mode 100644 (file)
index a76668d..deaf755
-/******************************************************************************\r
- *\r
- * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.\r
- *\r
- * This program is free software; you can redistribute it and/or modify it\r
- * under the terms of version 2 of the GNU General Public License as\r
- * published by the Free Software Foundation.\r
- *\r
- * This program is distributed in the hope that it will be useful, but WITHOUT\r
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
- * more details.\r
- *\r
- * You should have received a copy of the GNU General Public License along with\r
- * this program; if not, write to the Free Software Foundation, Inc.,\r
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA\r
- *\r
- *\r
- ******************************************************************************/\r
-#define _RTL8188E_SRESET_C_\r
-\r
-//#include <rtl8188e_sreset.h>\r
-#include <rtl8188e_hal.h>\r
-\r
-#ifdef DBG_CONFIG_ERROR_DETECT\r
-\r
-void rtl8188e_sreset_xmit_status_check(_adapter *padapter)\r
-{\r
-       HAL_DATA_TYPE   *pHalData = GET_HAL_DATA(padapter);\r
-       struct sreset_priv *psrtpriv = &pHalData->srestpriv;\r
-\r
-       unsigned long current_time;\r
-       struct xmit_priv        *pxmitpriv = &padapter->xmitpriv;\r
-       unsigned int diff_time;\r
-       u32 txdma_status;\r
-       \r
-       if( (txdma_status=rtw_read32(padapter, REG_TXDMA_STATUS)) !=0x00){\r
-               DBG_871X("%s REG_TXDMA_STATUS:0x%08x\n", __FUNCTION__, txdma_status);   \r
-               rtw_hal_sreset_reset(padapter);\r
-       }\r
-#ifdef CONFIG_USB_HCI\r
-       //total xmit irp = 4\r
-       //DBG_8192C("==>%s free_xmitbuf_cnt(%d),txirp_cnt(%d)\n",__FUNCTION__,pxmitpriv->free_xmitbuf_cnt,pxmitpriv->txirp_cnt);\r
-       //if(pxmitpriv->txirp_cnt == NR_XMITBUFF+1)\r
-       current_time = rtw_get_current_time();\r
-\r
-       if(0 == pxmitpriv->free_xmitbuf_cnt || 0 == pxmitpriv->free_xmit_extbuf_cnt) {\r
-\r
-               diff_time = rtw_get_passing_time_ms(psrtpriv->last_tx_time);\r
-\r
-               if (diff_time > 2000) {\r
-                       if (psrtpriv->last_tx_complete_time == 0) {\r
-                               psrtpriv->last_tx_complete_time = current_time;\r
-                       }\r
-                       else{\r
-                               diff_time = rtw_get_passing_time_ms(psrtpriv->last_tx_complete_time);\r
-                               if (diff_time > 4000) {\r
-                                       u32 ability;\r
-\r
-                                       //padapter->Wifi_Error_Status = WIFI_TX_HANG;\r
-                                       rtw_hal_get_hwreg(padapter, HW_VAR_DM_FLAG, (u8*)&ability);\r
-\r
-                                       DBG_871X("%s tx hang %s\n", __FUNCTION__,\r
-                                               (ability & ODM_BB_ADAPTIVITY)? "ODM_BB_ADAPTIVITY" : "");\r
-\r
-                                       if (!(ability & ODM_BB_ADAPTIVITY))\r
-                                               rtw_hal_sreset_reset(padapter);\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-#endif //CONFIG_USB_HCI\r
-\r
-       if (psrtpriv->dbg_trigger_point == SRESET_TGP_XMIT_STATUS) {\r
-               psrtpriv->dbg_trigger_point = SRESET_TGP_NULL;\r
-               rtw_hal_sreset_reset(padapter);\r
-               return;\r
-       }\r
-}\r
-\r
-void rtl8188e_sreset_linked_status_check(_adapter *padapter)\r
-{\r
-       HAL_DATA_TYPE   *pHalData = GET_HAL_DATA(padapter);\r
-       struct sreset_priv *psrtpriv = &pHalData->srestpriv;\r
-\r
-       u32 rx_dma_status = 0;\r
-       u8 fw_status=0;\r
-       rx_dma_status = rtw_read32(padapter,REG_RXDMA_STATUS);\r
-       if(rx_dma_status!= 0x00){\r
-               DBG_8192C("%s REG_RXDMA_STATUS:0x%08x \n",__FUNCTION__,rx_dma_status);\r
-               rtw_write32(padapter,REG_RXDMA_STATUS,rx_dma_status);\r
-       }       \r
-       fw_status = rtw_read8(padapter,REG_FMETHR);\r
-       if(fw_status != 0x00)\r
-       {               \r
-               if(fw_status == 1)\r
-                       DBG_8192C("%s REG_FW_STATUS (0x%02x), Read_Efuse_Fail !!   \n",__FUNCTION__,fw_status);\r
-               else if(fw_status == 2)\r
-                       DBG_8192C("%s REG_FW_STATUS (0x%02x), Condition_No_Match !!   \n",__FUNCTION__,fw_status);\r
-       }\r
-#if 0\r
-       u32 regc50,regc58,reg824,reg800;\r
-       regc50 = rtw_read32(padapter,0xc50);\r
-       regc58 = rtw_read32(padapter,0xc58);\r
-       reg824 = rtw_read32(padapter,0x824);\r
-       reg800 = rtw_read32(padapter,0x800);\r
-       if(     ((regc50&0xFFFFFF00)!= 0x69543400)||\r
-               ((regc58&0xFFFFFF00)!= 0x69543400)||\r
-               (((reg824&0xFFFFFF00)!= 0x00390000)&&(((reg824&0xFFFFFF00)!= 0x80390000)))||\r
-               ( ((reg800&0xFFFFFF00)!= 0x03040000)&&((reg800&0xFFFFFF00)!= 0x83040000)))\r
-       {\r
-               DBG_8192C("%s regc50:0x%08x, regc58:0x%08x, reg824:0x%08x, reg800:0x%08x,\n", __FUNCTION__,\r
-                       regc50, regc58, reg824, reg800);\r
-               rtw_hal_sreset_reset(padapter);\r
-       }\r
-#endif\r
-\r
-       if (psrtpriv->dbg_trigger_point == SRESET_TGP_LINK_STATUS) {\r
-               psrtpriv->dbg_trigger_point = SRESET_TGP_NULL;\r
-               rtw_hal_sreset_reset(padapter);\r
-               return;\r
-       }\r
-}\r
-#endif\r
-\r
+/******************************************************************************
+ *
+ * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ *
+ ******************************************************************************/
+#define _RTL8188E_SRESET_C_
+
+//#include <rtl8188e_sreset.h>
+#include <rtl8188e_hal.h>
+
+#ifdef DBG_CONFIG_ERROR_DETECT
+
+void rtl8188e_sreset_xmit_status_check(_adapter *padapter)
+{
+       HAL_DATA_TYPE   *pHalData = GET_HAL_DATA(padapter);
+       struct sreset_priv *psrtpriv = &pHalData->srestpriv;
+
+       unsigned long current_time;
+       struct xmit_priv        *pxmitpriv = &padapter->xmitpriv;
+       unsigned int diff_time;
+       u32 txdma_status;
+       
+       if( (txdma_status=rtw_read32(padapter, REG_TXDMA_STATUS)) !=0x00){
+               DBG_871X("%s REG_TXDMA_STATUS:0x%08x\n", __FUNCTION__, txdma_status);   
+               rtw_hal_sreset_reset(padapter);
+       }
+#ifdef CONFIG_USB_HCI
+       //total xmit irp = 4
+       //DBG_8192C("==>%s free_xmitbuf_cnt(%d),txirp_cnt(%d)\n",__FUNCTION__,pxmitpriv->free_xmitbuf_cnt,pxmitpriv->txirp_cnt);
+       //if(pxmitpriv->txirp_cnt == NR_XMITBUFF+1)
+       current_time = rtw_get_current_time();
+
+       if(0 == pxmitpriv->free_xmitbuf_cnt || 0 == pxmitpriv->free_xmit_extbuf_cnt) {
+
+               diff_time = rtw_get_passing_time_ms(psrtpriv->last_tx_time);
+
+               if (diff_time > 2000) {
+                       if (psrtpriv->last_tx_complete_time == 0) {
+                               psrtpriv->last_tx_complete_time = current_time;
+                       }
+                       else{
+                               diff_time = rtw_get_passing_time_ms(psrtpriv->last_tx_complete_time);
+                               if (diff_time > 4000) {
+                                       u32 ability = 0;
+
+                                       //padapter->Wifi_Error_Status = WIFI_TX_HANG;
+                                       ability = rtw_phydm_ability_get(padapter);
+                                       DBG_871X("%s tx hang %s\n", __FUNCTION__,
+                                               (ability & ODM_BB_ADAPTIVITY)? "ODM_BB_ADAPTIVITY" : "");
+
+                                       if (!(ability & ODM_BB_ADAPTIVITY))
+                                               rtw_hal_sreset_reset(padapter);
+                               }
+                       }
+               }
+       }
+#endif //CONFIG_USB_HCI
+
+       if (psrtpriv->dbg_trigger_point == SRESET_TGP_XMIT_STATUS) {
+               psrtpriv->dbg_trigger_point = SRESET_TGP_NULL;
+               rtw_hal_sreset_reset(padapter);
+               return;
+       }
+}
+
+void rtl8188e_sreset_linked_status_check(_adapter *padapter)
+{
+       HAL_DATA_TYPE   *pHalData = GET_HAL_DATA(padapter);
+       struct sreset_priv *psrtpriv = &pHalData->srestpriv;
+
+       u32 rx_dma_status = 0;
+       u8 fw_status=0;
+       rx_dma_status = rtw_read32(padapter,REG_RXDMA_STATUS);
+       if(rx_dma_status!= 0x00){
+               DBG_8192C("%s REG_RXDMA_STATUS:0x%08x \n",__FUNCTION__,rx_dma_status);
+               rtw_write32(padapter,REG_RXDMA_STATUS,rx_dma_status);
+       }       
+       fw_status = rtw_read8(padapter,REG_FMETHR);
+       if(fw_status != 0x00)
+       {               
+               if(fw_status == 1)
+                       DBG_8192C("%s REG_FW_STATUS (0x%02x), Read_Efuse_Fail !!   \n",__FUNCTION__,fw_status);
+               else if(fw_status == 2)
+                       DBG_8192C("%s REG_FW_STATUS (0x%02x), Condition_No_Match !!   \n",__FUNCTION__,fw_status);
+       }
+#if 0
+       u32 regc50,regc58,reg824,reg800;
+       regc50 = rtw_read32(padapter,0xc50);
+       regc58 = rtw_read32(padapter,0xc58);
+       reg824 = rtw_read32(padapter,0x824);
+       reg800 = rtw_read32(padapter,0x800);
+       if(     ((regc50&0xFFFFFF00)!= 0x69543400)||
+               ((regc58&0xFFFFFF00)!= 0x69543400)||
+               (((reg824&0xFFFFFF00)!= 0x00390000)&&(((reg824&0xFFFFFF00)!= 0x80390000)))||
+               ( ((reg800&0xFFFFFF00)!= 0x03040000)&&((reg800&0xFFFFFF00)!= 0x83040000)))
+       {
+               DBG_8192C("%s regc50:0x%08x, regc58:0x%08x, reg824:0x%08x, reg800:0x%08x,\n", __FUNCTION__,
+                       regc50, regc58, reg824, reg800);
+               rtw_hal_sreset_reset(padapter);
+       }
+#endif
+
+       if (psrtpriv->dbg_trigger_point == SRESET_TGP_LINK_STATUS) {
+               psrtpriv->dbg_trigger_point = SRESET_TGP_NULL;
+               rtw_hal_sreset_reset(padapter);
+               return;
+       }
+}
+#endif
+