[WCNCR00158507] misc: refine MT7668 reset feature
[Description]
Refine CFG_CHIP_RESET_SUPPORT that used for all HIFs.
1. For USB, WiFi driver detect command/data timeout and trigger
POR(Power On Reset) flow.
- After 3 times timeout occurs, call reset API provided by BT driver
- Change "ChipResetRecover" in wifi.cfg from 0 to 1 to enable USB reset
2. Remove obsolete code used for wmt in gl_rst files.
3. Remove typedef "UINT32" defined in gl_rst.h and fix the callers.
CFG_CHIP_RESET_SUPPORT is default off, needs BT driver to toggle GPIO
based on a specific platform.
Test:
Sanity check: BT and WiFi scan/connection are OK
Succeed to recovery MT7668 by calling
"iwpriv wlan0 driver set_chip assert" 5 times.
Change-Id: I7577a4a1a72e5ec71a415b2eec5d01b05a1b48e3
CR-Id: WCNCR00158507
Feature: misc
Signed-off-by: ZD Hu <zd.hu@mediatek.com>
diff --git a/Makefile.ce b/Makefile.ce
index 51d018d..fa830eb 100644
--- a/Makefile.ce
+++ b/Makefile.ce
@@ -165,7 +165,7 @@
# eg. insmod wlan_mt7668_usb.ko sta=wlan p2p=p2p ap=ap
CFG_DRIVER_INF_NAME_CHANGE=n
-
+CFG_CHIP_RESET_SUPPORT=0
#/***** Platform dependent part ******/
ifeq ($(PLATFORM),MT53XX)
@@ -244,6 +244,10 @@
PLATFORM_FLAGS += -DCFG_SCAN_CHANNEL_SPECIFIED=$(CFG_SCAN_CHANNEL_SPECIFIED)
endif
+ifneq ($(CFG_CHIP_RESET_SUPPORT),)
+PLATFORM_FLAGS += -DCFG_CHIP_RESET_SUPPORT=$(CFG_CHIP_RESET_SUPPORT)
+endif
+
##############################################################
# Compile settings
##############################################################
diff --git a/Makefile.x86 b/Makefile.x86
index c48baf1..3a91303 100644
--- a/Makefile.x86
+++ b/Makefile.x86
@@ -81,6 +81,8 @@
# Support firmware auto roaming
#CFG_SUPPORT_ROAMING=0
+CFG_CHIP_RESET_SUPPORT=0
+
#/***** Manage configs into compile options ******/
ifneq ($(CFG_NUM_DIFFERENT_CHANNELS_STA),)
PLATFORM_FLAGS += -DCFG_NUM_DIFFERENT_CHANNELS_STA=$(CFG_NUM_DIFFERENT_CHANNELS_STA)
@@ -146,6 +148,10 @@
PLATFORM_FLAGS += -DCFG_SCAN_CHANNEL_SPECIFIED=$(CFG_SCAN_CHANNEL_SPECIFIED)
endif
+ifneq ($(CFG_CHIP_RESET_SUPPORT),)
+PLATFORM_FLAGS += -DCFG_CHIP_RESET_SUPPORT=$(CFG_CHIP_RESET_SUPPORT)
+endif
+
all: driver
driver:
diff --git a/common/wlan_lib.c b/common/wlan_lib.c
index 3501f33..840eeba 100644
--- a/common/wlan_lib.c
+++ b/common/wlan_lib.c
@@ -7263,7 +7263,7 @@
DBGLOG(INIT, LOUD, "parse aucValue error i4Ret=%d\n", i4Ret);
}
- wlanCfgRecordValue(prAdapter, pucKey, (UINT32)i4Value);
+ wlanCfgRecordValue(prAdapter, pucKey, (UINT_32)i4Value);
return i4Value;
}
diff --git a/common/wlan_oid.c b/common/wlan_oid.c
index 905aa08..a12eddd 100644
--- a/common/wlan_oid.c
+++ b/common/wlan_oid.c
@@ -11991,8 +11991,8 @@
}
prFwLog2HostCtrl = (P_CMD_FW_LOG_2_HOST_CTRL_T)pvSetBuffer;
- prFwLog2HostCtrl->u4HostTimeSec = (UINT32)ts;
- prFwLog2HostCtrl->u4HostTimeMSec = (UINT32)(do_div(ts, 1000000000) / 1000);
+ prFwLog2HostCtrl->u4HostTimeSec = (UINT_32)ts;
+ prFwLog2HostCtrl->u4HostTimeMSec = (UINT_32)(do_div(ts, 1000000000) / 1000);
DBGLOG(REQ, INFO, "McuDest %d, LogType %d\n", prFwLog2HostCtrl->ucMcuDest, prFwLog2HostCtrl->ucFwLog2HostCtrl);
diff --git a/include/config.h b/include/config.h
index 35e70a1..0695220 100644
--- a/include/config.h
+++ b/include/config.h
@@ -322,9 +322,7 @@
#define HW_BSSID_NUM 4 /* HW BSSID number by chip */
#define HW_WMM_NUM 4 /* HW WMM number by chip */
-#if (MTK_WCN_HIF_SDIO)
-#define CFG_CHIP_RESET_SUPPORT 1
-#else
+#ifndef CFG_CHIP_RESET_SUPPORT
#define CFG_CHIP_RESET_SUPPORT 0
#endif
diff --git a/mgmt/rlm_domain.c b/mgmt/rlm_domain.c
index 74c898d..0b6fea0 100644
--- a/mgmt/rlm_domain.c
+++ b/mgmt/rlm_domain.c
@@ -2404,7 +2404,7 @@
#if (CFG_SUPPORT_SINGLE_SKU == 1)
WLAN_STATUS rStatus;
UINT_32 u4SetQueryInfoLen;
- UINT32 ch_cnt;
+ UINT_32 ch_cnt;
struct wiphy *wiphy;
u8 band_idx, ch_idx;
P_CMD_SET_COUNTRY_CHANNEL_POWER_LIMIT_V2_T prCmd[KAL_NUM_BANDS] = {NULL};
diff --git a/os/linux/gl_init.c b/os/linux/gl_init.c
index 144c2b6..3ef9884 100644
--- a/os/linux/gl_init.c
+++ b/os/linux/gl_init.c
@@ -2804,9 +2804,6 @@
kalUninitIOBuffer();
return ret;
}
-#if (CFG_CHIP_RESET_SUPPORT)
- glResetInit();
-#endif
return ret;
} /* end of initWlan() */
@@ -2824,9 +2821,6 @@
static VOID exitWlan(void)
{
/* printk("remove %p\n", wlanRemove); */
-#if CFG_CHIP_RESET_SUPPORT
- glResetUninit();
-#endif
glUnregisterBus(wlanRemove);
diff --git a/os/linux/gl_rst.c b/os/linux/gl_rst.c
index 33ed1ae..22ed24d 100644
--- a/os/linux/gl_rst.c
+++ b/os/linux/gl_rst.c
@@ -70,11 +70,7 @@
* E X T E R N A L R E F E R E N C E S
********************************************************************************
*/
-#include <linux/kernel.h>
-#include <linux/workqueue.h>
-
#include "precomp.h"
-#include "gl_rst.h"
#if CFG_CHIP_RESET_SUPPORT
@@ -87,154 +83,38 @@
* P U B L I C D A T A
********************************************************************************
*/
-BOOLEAN fgIsResetting = FALSE;
-UINT_32 g_IsNeedDoChipReset;
/*******************************************************************************
* P R I V A T E D A T A
********************************************************************************
*/
-static RESET_STRUCT_T wifi_rst;
-
-static void mtk_wifi_reset(struct work_struct *work);
/*******************************************************************************
* F U N C T I O N D E C L A R A T I O N S
********************************************************************************
*/
-static void *glResetCallback(ENUM_WMTDRV_TYPE_T eSrcType,
- ENUM_WMTDRV_TYPE_T eDstType,
- ENUM_WMTMSG_TYPE_T eMsgType, void *prMsgBody, unsigned int u4MsgLength);
/*******************************************************************************
* F U N C T I O N S
********************************************************************************
*/
-/*----------------------------------------------------------------------------*/
-/*!
- * @brief This routine is responsible for
- * 1. register wifi reset callback
- * 2. initialize wifi reset work
- *
- * @param none
- *
- * @retval none
- */
-/*----------------------------------------------------------------------------*/
-VOID glResetInit(VOID)
+
+VOID glResetTrigger(P_ADAPTER_T prAdapter)
{
- /* 1. Register reset callback */
- mtk_wcn_wmt_msgcb_reg(WMTDRV_TYPE_WIFI, (PF_WMT_CB) glResetCallback);
+ void (*btmtk_usb_toggle_rst_pin)(void);
- /* 2. Initialize reset work */
- INIT_WORK(&(wifi_rst.rst_work), mtk_wifi_reset);
+ /* Call POR(Power On Reset) off->on API provided by BT driver */
+ btmtk_usb_toggle_rst_pin = (void *)kallsyms_lookup_name("btmtk_usb_toggle_rst_pin");
-}
-
-/*----------------------------------------------------------------------------*/
-/*!
- * @brief This routine is responsible for
- * 1. deregister wifi reset callback
- *
- * @param none
- *
- * @retval none
- */
-/*----------------------------------------------------------------------------*/
-VOID glResetUninit(VOID)
-{
- /* 1. Deregister reset callback */
- mtk_wcn_wmt_msgcb_unreg(WMTDRV_TYPE_WIFI);
-
-}
-
-/*----------------------------------------------------------------------------*/
-/*!
- * @brief This routine is invoked when there is reset messages indicated
- *
- * @param eSrcType
- * eDstType
- * eMsgType
- * prMsgBody
- * u4MsgLength
- *
- * @retval
- */
-/*----------------------------------------------------------------------------*/
-static void *glResetCallback(ENUM_WMTDRV_TYPE_T eSrcType,
- ENUM_WMTDRV_TYPE_T eDstType,
- ENUM_WMTMSG_TYPE_T eMsgType, void *prMsgBody, unsigned int u4MsgLength)
-{
- switch (eMsgType) {
- case WMTMSG_TYPE_RESET:
- if (u4MsgLength == sizeof(ENUM_WMTRSTMSG_TYPE_T)) {
- P_ENUM_WMTRSTMSG_TYPE_T prRstMsg = (P_ENUM_WMTRSTMSG_TYPE_T) prMsgBody;
-
- switch (*prRstMsg) {
- case WMTRSTMSG_RESET_START:
- DBGLOG(INIT, WARN, "Whole chip reset start!\n");
- fgIsResetting = TRUE;
- wifi_reset_start();
- break;
-
- case WMTRSTMSG_RESET_END:
- DBGLOG(INIT, WARN, "Whole chip reset end!\n");
- fgIsResetting = FALSE;
- wifi_rst.rst_data = RESET_SUCCESS;
- schedule_work(&(wifi_rst.rst_work));
- break;
-
- case WMTRSTMSG_RESET_END_FAIL:
- DBGLOG(INIT, WARN, "Whole chip reset fail!\n");
- fgIsResetting = FALSE;
- wifi_rst.rst_data = RESET_FAIL;
- schedule_work(&(wifi_rst.rst_work));
- break;
-
- default:
- break;
- }
- }
- break;
-
- default:
- break;
+ if (!btmtk_usb_toggle_rst_pin) {
+ DBGLOG(HAL, ERROR, "btmtk_usb_toggle_rst_pin() is not found\n");
+ } else {
+ DBGLOG(HAL, ERROR, "Trigger MT7668 POR(Power On Reset) off->on by BT driver\n");
+ btmtk_usb_toggle_rst_pin();
}
-
- return NULL;
}
-/*----------------------------------------------------------------------------*/
-/*!
- * @brief This routine is called for wifi reset
- *
- * @param skb
- * info
- *
- * @retval 0
- * nonzero
- */
-/*----------------------------------------------------------------------------*/
-static void mtk_wifi_reset(struct work_struct *work)
-{
- RESET_STRUCT_T *rst = container_of(work, RESET_STRUCT_T, rst_work);
-
- wifi_reset_end(rst->rst_data);
-}
-
-/*----------------------------------------------------------------------------*/
-/*!
- * @brief This routine is called for generating reset request to WMT
- *
- * @param None
- *
- * @retval None
- */
-/*----------------------------------------------------------------------------*/
-VOID glSendResetRequest(VOID)
-{
- /* WMT thread would trigger whole chip reset itself */
-}
+#endif /* CFG_CHIP_RESET_SUPPORT */
/*----------------------------------------------------------------------------*/
/*!
@@ -248,50 +128,5 @@
/*----------------------------------------------------------------------------*/
BOOLEAN kalIsResetting(VOID)
{
- return fgIsResetting;
-}
-
-BOOLEAN glResetTrigger(P_ADAPTER_T prAdapter)
-{
- BOOLEAN fgResult = TRUE;
-
-#if CFG_WMT_RESET_API_SUPPORT
- if (kalIsResetting()) {
- DBGLOG(INIT, ERROR,
- "Skip triggering whole-chip reset during resetting! Chip[%04X E%u]\n",
- MTK_CHIP_REV, wlanGetEcoVersion(prAdapter));
- DBGLOG(INIT, ERROR,
- "FW Ver DEC[%u.%u] HEX[%x.%x], Driver Ver[%u.%u]\n",
- (prAdapter->rVerInfo.u2FwOwnVersion >> 8),
- (prAdapter->rVerInfo.u2FwOwnVersion & BITS(0, 7)),
- (prAdapter->rVerInfo.u2FwOwnVersion >> 8),
- (prAdapter->rVerInfo.u2FwOwnVersion & BITS(0, 7)),
- (prAdapter->rVerInfo.u2FwPeerVersion >> 8), (prAdapter->rVerInfo.u2FwPeerVersion & BITS(0, 7)));
-
- fgResult = TRUE;
- } else {
- DBGLOG(INIT, ERROR,
- "Trigger whole-chip reset! Chip[%04X E%u] FW Ver DEC[%u.%u] HEX[%x.%x], Driver Ver[%u.%u]\n",
- MTK_CHIP_REV,
- wlanGetEcoVersion(prAdapter),
- (prAdapter->rVerInfo.u2FwOwnVersion >> 8),
- (prAdapter->rVerInfo.u2FwOwnVersion & BITS(0, 7)),
- (prAdapter->rVerInfo.u2FwOwnVersion >> 8),
- (prAdapter->rVerInfo.u2FwOwnVersion & BITS(0, 7)),
- (prAdapter->rVerInfo.u2FwPeerVersion >> 8), (prAdapter->rVerInfo.u2FwPeerVersion & BITS(0, 7)));
-
- fgResult = mtk_wcn_wmt_do_reset(WMTDRV_TYPE_WIFI);
- }
-#endif
-
- return fgResult;
-}
-
-#else
-
-BOOLEAN kalIsResetting(VOID)
-{
return FALSE;
}
-
-#endif
diff --git a/os/linux/hif/sdio/hal_api.c b/os/linux/hif/sdio/hal_api.c
index 67d386a..e648295 100644
--- a/os/linux/hif/sdio/hal_api.c
+++ b/os/linux/hif/sdio/hal_api.c
@@ -1880,7 +1880,7 @@
if ((u4IntrBits & WHISR_D2H_SW_ASSERT_INFO_INT) != 0) {
halPrintFirmwareAssertInfo(prAdapter);
#if CFG_CHIP_RESET_SUPPORT
- glSendResetRequest();
+ glResetTrigger();
#endif
}
diff --git a/os/linux/hif/usb/hal_api.c b/os/linux/hif/usb/hal_api.c
index ae8a51b..aaa6b8f 100644
--- a/os/linux/hif/usb/hal_api.c
+++ b/os/linux/hif/usb/hal_api.c
@@ -317,8 +317,12 @@
if (wlanIsChipRstRecEnabled(prGlueInfo->prAdapter)
&& wlanIsChipNoAck(prGlueInfo->prAdapter)) {
wlanChipRstPreAct(prGlueInfo->prAdapter);
+#if CFG_CHIP_RESET_SUPPORT
+ glResetTrigger(prGlueInfo->prAdapter);
+#else
DBGLOG(HAL, ERROR, "usb trigger whole reset\n");
HAL_WIFI_FUNC_CHIP_RESET(prGlueInfo->prAdapter);
+#endif
}
return u4Status;
}
@@ -582,8 +586,12 @@
if (wlanIsChipRstRecEnabled(prGlueInfo->prAdapter)
&& wlanIsChipNoAck(prGlueInfo->prAdapter)) {
wlanChipRstPreAct(prGlueInfo->prAdapter);
+#if CFG_CHIP_RESET_SUPPORT
+ glResetTrigger(prGlueInfo->prAdapter);
+#else
DBGLOG(HAL, ERROR, "usb trigger whole reset\n");
HAL_WIFI_FUNC_CHIP_RESET(prGlueInfo->prAdapter);
+#endif
}
return u4Status;
}
diff --git a/os/linux/include/gl_rst.h b/os/linux/include/gl_rst.h
index 4e7b484..0fa3960 100644
--- a/os/linux/include/gl_rst.h
+++ b/os/linux/include/gl_rst.h
@@ -72,91 +72,21 @@
*/
#include "gl_typedef.h"
-#if 0
-#include "mtk_porting.h"
-#endif
/*******************************************************************************
* C O N S T A N T S
********************************************************************************
*/
-#if (MTK_WCN_HIF_SDIO)
-#define CFG_WMT_RESET_API_SUPPORT 1
-#else
-#define CFG_WMT_RESET_API_SUPPORT 0
-#endif
/*******************************************************************************
* D A T A T Y P E S
********************************************************************************
*/
-typedef enum _ENUM_RESET_STATUS_T {
- RESET_FAIL,
- RESET_SUCCESS
-} ENUM_RESET_STATUS_T;
-
-typedef struct _RESET_STRUCT_T {
- ENUM_RESET_STATUS_T rst_data;
- struct work_struct rst_work;
-} RESET_STRUCT_T;
-
-/* duplicated from wmt_exp.h for better driver isolation */
-typedef enum _ENUM_WMTDRV_TYPE_T {
- WMTDRV_TYPE_BT = 0,
- WMTDRV_TYPE_FM = 1,
- WMTDRV_TYPE_GPS = 2,
- WMTDRV_TYPE_WIFI = 3,
- WMTDRV_TYPE_WMT = 4,
- WMTDRV_TYPE_STP = 5,
- WMTDRV_TYPE_SDIO1 = 6,
- WMTDRV_TYPE_SDIO2 = 7,
- WMTDRV_TYPE_LPBK = 8,
- WMTDRV_TYPE_MAX
-} ENUM_WMTDRV_TYPE_T, *P_ENUM_WMTDRV_TYPE_T;
-
-typedef enum _ENUM_WMTMSG_TYPE_T {
- WMTMSG_TYPE_POWER_ON = 0,
- WMTMSG_TYPE_POWER_OFF = 1,
- WMTMSG_TYPE_RESET = 2,
- WMTMSG_TYPE_STP_RDY = 3,
- WMTMSG_TYPE_HW_FUNC_ON = 4,
- WMTMSG_TYPE_MAX
-} ENUM_WMTMSG_TYPE_T, *P_ENUM_WMTMSG_TYPE_T;
-
-typedef enum _ENUM_WMTRSTMSG_TYPE_T {
- WMTRSTMSG_RESET_START = 0x0,
- WMTRSTMSG_RESET_END = 0x1,
- WMTRSTMSG_RESET_END_FAIL = 0x2,
- WMTRSTMSG_RESET_MAX,
- WMTRSTMSG_RESET_INVALID = 0xff
-} ENUM_WMTRSTMSG_TYPE_T, *P_ENUM_WMTRSTMSG_TYPE_T;
-
-typedef void (*PF_WMT_CB) (ENUM_WMTDRV_TYPE_T, /* Source driver type */
- ENUM_WMTDRV_TYPE_T, /* Destination driver type */
- ENUM_WMTMSG_TYPE_T, /* Message type */
- void *,
- /* READ-ONLY buffer. Buffer is allocated and freed by WMT_drv. Client
- * can't touch this buffer after this function return.
- */
- unsigned int); /* Buffer size in unit of byte */
-
-typedef int MTK_WCN_BOOL;
-typedef unsigned int UINT32, *PUINT32;
-
/*******************************************************************************
* E X T E R N A L F U N C T I O N S
********************************************************************************
*/
-#if CFG_CHIP_RESET_SUPPORT
-
-extern MTK_WCN_BOOL mtk_wcn_wmt_assert(ENUM_WMTDRV_TYPE_T type, UINT32 reason);
-extern int mtk_wcn_wmt_msgcb_reg(ENUM_WMTDRV_TYPE_T eType, PF_WMT_CB pCb);
-extern int mtk_wcn_wmt_msgcb_unreg(ENUM_WMTDRV_TYPE_T eType);
-extern int wifi_reset_start(void);
-extern int wifi_reset_end(ENUM_RESET_STATUS_T);
-#endif
-
/*******************************************************************************
* P U B L I C D A T A
********************************************************************************
@@ -171,34 +101,19 @@
* M A C R O S
********************************************************************************
*/
-#if CFG_CHIP_RESET_SUPPORT
-#define glDoCoreDump() \
- do { \
- DBGLOG(JOIN, INFO, "do core dump in %s\n", __func__); \
- mtk_wcn_wmt_assert(WMTDRV_TYPE_WIFI, 40); \
- } while (0)
-#endif
/*******************************************************************************
* F U N C T I O N D E C L A R A T I O N S
********************************************************************************
*/
-#if CFG_WMT_RESET_API_SUPPORT
-extern MTK_WCN_BOOL mtk_wcn_wmt_do_reset(ENUM_WMTDRV_TYPE_T type);
-#endif
+
/*******************************************************************************
* F U N C T I O N S
********************************************************************************
*/
-VOID glResetInit(VOID);
-
-VOID glResetUninit(VOID);
-
-VOID glSendResetRequest(VOID);
-
BOOLEAN kalIsResetting(VOID);
-BOOLEAN glResetTrigger(P_ADAPTER_T prAdapter);
+VOID glResetTrigger(P_ADAPTER_T prAdapter);
#endif /* _GL_RST_H */