From d4a1bd480003f3e1a0590bc46fbcb24f05652ca7 Mon Sep 17 00:00:00 2001
From: tzh <tanzhtanzh@gmail.com>
Date: Thu, 15 Aug 2024 06:56:47 +0000
Subject: [PATCH] feat(wfit/bt): update aic8800 wifi/bt drive and hal

---
 longan/kernel/linux-4.9/drivers/net/wireless/aic8800/aic8800_fdrv/rwnx_main.c | 2996 ++++++++++++++++-------------------------------------------
 1 files changed, 816 insertions(+), 2,180 deletions(-)

diff --git a/longan/kernel/linux-4.9/drivers/net/wireless/aic8800/aic8800_fdrv/rwnx_main.c b/longan/kernel/linux-4.9/drivers/net/wireless/aic8800/aic8800_fdrv/rwnx_main.c
old mode 100644
new mode 100755
index 9a8066a..eb5046f
--- a/longan/kernel/linux-4.9/drivers/net/wireless/aic8800/aic8800_fdrv/rwnx_main.c
+++ b/longan/kernel/linux-4.9/drivers/net/wireless/aic8800/aic8800_fdrv/rwnx_main.c
@@ -48,6 +48,7 @@
 #include "aicwf_usb.h"
 #endif
 #include "aic_bsp_export.h"
+#include "rwnx_wakelock.h"
 
 #define RW_DRV_DESCRIPTION  "RivieraWaves 11nac driver for Linux cfg80211"
 #define RW_DRV_COPYRIGHT    "Copyright(c) 2015-2017 RivieraWaves"
@@ -313,7 +314,7 @@
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) || defined(CONFIG_HE_FOR_OLD_KERNEL)
 struct ieee80211_sband_iftype_data rwnx_he_capa = {
-	.types_mask = BIT(NL80211_IFTYPE_STATION),
+	.types_mask = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP),
 	.he_cap = RWNX_HE_CAPABILITIES,
 };
 #endif
@@ -678,29 +679,57 @@
 
 static void rwnx_del_csa(struct rwnx_vif *vif)
 {
-	struct rwnx_hw *rwnx_hw = vif->rwnx_hw;
 	struct rwnx_csa *csa = vif->ap.csa;
 
 	if (!csa)
 		return;
 
-	rwnx_ipc_elem_var_deallocs(rwnx_hw, &csa->elem);
 	rwnx_del_bcn(&csa->bcn);
 	kfree(csa);
 	vif->ap.csa = NULL;
 }
-
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
 static void rwnx_csa_finish(struct work_struct *ws)
 {
 	struct rwnx_csa *csa = container_of(ws, struct rwnx_csa, work);
 	struct rwnx_vif *vif = csa->vif;
 	struct rwnx_hw *rwnx_hw = vif->rwnx_hw;
 	int error = csa->status;
+	u8 *buf, *pos;
 
-	if (!error)
-		error = rwnx_send_bcn_change(rwnx_hw, vif->vif_index, csa->elem.dma_addr,
+	RWNX_DBG(RWNX_FN_ENTRY_STR);
+
+	buf = kmalloc(csa->bcn.len, GFP_KERNEL);
+	if (!buf) {
+		printk ("%s buf fail\n", __func__);
+		return;
+	}
+	pos = buf;
+
+	memcpy(pos, csa->bcn.head, csa->bcn.head_len);
+	pos += csa->bcn.head_len;
+	*pos++ = WLAN_EID_TIM;
+	*pos++ = 4;
+	*pos++ = 0;
+	*pos++ = csa->bcn.dtim;
+	*pos++ = 0;
+	*pos++ = 0;
+	if (csa->bcn.tail) {
+		memcpy(pos, csa->bcn.tail, csa->bcn.tail_len);
+		pos += csa->bcn.tail_len;
+	}
+	if (csa->bcn.ies) {
+		memcpy(pos, csa->bcn.ies, csa->bcn.ies_len);
+	}
+
+	if (!error) {
+		error = rwnx_send_bcn(rwnx_hw, buf, vif->vif_index, csa->bcn.len);
+		if (error)
+			return;
+		error = rwnx_send_bcn_change(rwnx_hw, vif->vif_index, 0,
 									 csa->bcn.len, csa->bcn.head_len,
 									 csa->bcn.tim_len, NULL);
+	}
 
 	if (error) {
 		#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
@@ -726,6 +755,7 @@
 	}
 	rwnx_del_csa(vif);
 }
+#endif
 
 /**
  * rwnx_external_auth_enable - Enable external authentication on a vif
@@ -949,9 +979,34 @@
 		rwnx_hw->scan_request = NULL;
 
 		ret = rwnx_send_scanu_cancel_req(rwnx_hw, NULL);
+		mdelay(35);//make sure firmware take affect
 		if (ret) {
 			printk("scanu_cancel fail\n");
 			return ret;
+		}
+	}
+
+	if (rwnx_hw->roc_elem && (rwnx_hw->roc_elem->wdev == &rwnx_vif->wdev)) {
+		printk(KERN_CRIT "%s clear roc\n", __func__);
+		/* Initialize RoC element pointer to NULL, indicate that RoC can be started */
+		kfree(rwnx_hw->roc_elem);
+		rwnx_hw->roc_elem = NULL;
+	}
+
+	rwnx_vif->up = false;
+
+	if (netif_carrier_ok(dev)) {
+		if (RWNX_VIF_TYPE(rwnx_vif) == NL80211_IFTYPE_STATION ||
+			RWNX_VIF_TYPE(rwnx_vif) == NL80211_IFTYPE_P2P_CLIENT) {
+			cfg80211_disconnected(dev, WLAN_REASON_DEAUTH_LEAVING,
+								  NULL, 0, true, GFP_ATOMIC);
+			netif_tx_stop_all_queues(dev);
+			netif_carrier_off(dev);
+			udelay(1000);
+		} else if (RWNX_VIF_TYPE(rwnx_vif) == NL80211_IFTYPE_AP_VLAN) {
+			netif_carrier_off(dev);
+		} else {
+			netdev_warn(dev, "AP not stopped when disabling interface");
 		}
 	}
 
@@ -960,7 +1015,8 @@
 		if (usbdev->state != USB_DOWN_ST)
 			rwnx_send_remove_if (rwnx_hw, rwnx_vif->vif_index, false);
 	}
-#elif defined(AICWF_SDIO_SUPPORT)
+#endif
+#if defined(AICWF_SDIO_SUPPORT)
 	bus_if = dev_get_drvdata(rwnx_hw->dev);
 	if (bus_if) {
 		sdiodev = bus_if->bus_priv.sdio;
@@ -969,35 +1025,11 @@
 		if (sdiodev->bus_if->state != BUS_DOWN_ST)
 			rwnx_send_remove_if (rwnx_hw, rwnx_vif->vif_index, false);
 	}
-#else
 #endif
-
-	if (rwnx_hw->roc_elem && (rwnx_hw->roc_elem->wdev == &rwnx_vif->wdev)) {
-		printk(KERN_CRIT "%s clear roc\n", __func__);
-		/* Initialize RoC element pointer to NULL, indicate that RoC can be started */
-		rwnx_hw->roc_elem = NULL;
-	}
-
 	/* Ensure that we won't process disconnect ind */
 	spin_lock_bh(&rwnx_hw->cb_lock);
 
-	rwnx_vif->up = false;
-	if (netif_carrier_ok(dev)) {
-		if (RWNX_VIF_TYPE(rwnx_vif) == NL80211_IFTYPE_STATION ||
-			RWNX_VIF_TYPE(rwnx_vif) == NL80211_IFTYPE_P2P_CLIENT) {
-			cfg80211_disconnected(dev, WLAN_REASON_DEAUTH_LEAVING,
-								  NULL, 0, true, GFP_ATOMIC);
-			netif_tx_stop_all_queues(dev);
-			netif_carrier_off(dev);
-		} else if (RWNX_VIF_TYPE(rwnx_vif) == NL80211_IFTYPE_AP_VLAN) {
-			netif_carrier_off(dev);
-		} else {
-			netdev_warn(dev, "AP not stopped when disabling interface");
-		}
-	}
-
 	rwnx_hw->vif_table[rwnx_vif->vif_index] = NULL;
-	spin_unlock_bh(&rwnx_hw->cb_lock);
 
 	rwnx_chanctx_unlink(rwnx_vif);
 
@@ -1005,6 +1037,8 @@
 		rwnx_hw->monitor_vif = RWNX_INVALID_VIF;
 
 	rwnx_hw->vif_started--;
+	spin_unlock_bh(&rwnx_hw->cb_lock);
+
 	if (rwnx_hw->vif_started == 0) {
 	/* This also lets both ipc sides remain in sync before resetting */
 #if 0
@@ -1041,17 +1075,31 @@
 enum {
 	SET_TX,
 	SET_TXSTOP,
+	SET_TXTONE,
 	SET_RX,
 	GET_RX_RESULT,
 	SET_RXSTOP,
 	SET_RXMETER,
-	SET_FREQ_CAL,
-	GET_EFUSE,
 	SET_POWER,
 	SET_XTAL_CAP,
 	SET_XTAL_CAP_FINE,
+	GET_EFUSE,
+	SET_FREQ_CAL,
+	SET_FREQ_CAL_FINE,
+	GET_FREQ_CAL,
 	SET_MAC_ADDR,
 	GET_MAC_ADDR,
+	SET_BT_MAC_ADDR,
+	GET_BT_MAC_ADDR,
+	SET_VENDOR_INFO,
+	GET_VENDOR_INFO,
+	RDWR_PWRMM,
+	RDWR_PWRIDX,
+	RDWR_PWROFST,
+	RDWR_DRVIBIT,
+	RDWR_EFUSE_PWROFST,
+	RDWR_EFUSE_DRVIBIT,
+	SET_PAPR,
 	SETSUSPENDMODE,
 };
 
@@ -1078,40 +1126,6 @@
 #endif
 
 #define CMD_MAXARGS 10
-
-#if 0
-#define isblank(c)      ((c) == ' ' || (c) == '\t')
-#define isascii(c)      (((unsigned char)(c)) <= 0x7F)
-
-static int isdigit(unsigned char c)
-{
-	return ((c >= '0') && (c <= '9'));
-}
-
-static int isxdigit(unsigned char c)
-{
-	if ((c >= '0') && (c <= '9'))
-		return 1;
-	if ((c >= 'a') && (c <= 'f'))
-		return 1;
-	if ((c >= 'A') && (c <= 'F'))
-		return 1;
-	return 0;
-}
-
-static int islower(unsigned char c)
-{
-	return ((c >= 'a') && (c <= 'z'));
-}
-
-static unsigned char toupper(unsigned char c)
-{
-	if (islower(c))
-		c -= 'a' - 'A';
-	return c;
-}
-#endif
-
 
 static int parse_line (char *line, char *argv[])
 {
@@ -1216,11 +1230,10 @@
 	u8_l pwr;
 	u8_l xtal_cap;
 	u8_l xtal_cap_fine;
+	u8_l vendor_info;
 	u8_l setsusp_mode;
 #endif
 	int ret = 0;
-
-	RWNX_DBG(RWNX_FN_ENTRY_STR);
 
 	argc = parse_line(command, argv);
 	if (argc == 0) {
@@ -1266,6 +1279,30 @@
 	#ifdef AICWF_USB_SUPPORT
 			rwnx_send_rftest_req(g_rwnx_plat->usbdev->rwnx_hw, SET_TXSTOP, 0, NULL, NULL);
 	#endif
+		} else if (strcasecmp(argv[0], "SET_TXTONE") == 0) {
+			printk("set_tx_tone,argc:%d\n", argc);
+			if ((argc == 2) || (argc == 3)) {
+				u8_l func, buf[2];
+				s8_l freq;
+				printk("argv 1:%s\n", argv[1]);
+				func = (u8_l)command_strtoul(argv[1], NULL, 16);
+				if (argc == 3) {
+					printk("argv 2:%s\n", argv[2]);
+					freq = (u8_l)command_strtoul(argv[2], NULL, 10);
+				} else {
+					freq = 0;
+				}
+				buf[0] = func;
+				buf[1] = (u8_l)freq;
+	#ifdef AICWF_SDIO_SUPPORT
+				rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, SET_TXTONE, argc - 1, buf, NULL);
+	#endif
+	#ifdef AICWF_USB_SUPPORT
+				rwnx_send_rftest_req(g_rwnx_plat->usbdev->rwnx_hw, SET_TXTONE, argc - 1, buf, NULL);
+	#endif
+			} else {
+				printk("wrong args\n");
+			}
 		} else if (strcasecmp(argv[0], "SET_RX") == 0) {
 			printk("set_rx\n");
 			if (argc < 3) {
@@ -1361,69 +1398,258 @@
 	#endif
 			memcpy(command, &cfm.rftest_result[0], 4);
 			bytes_written = 4;
-	} else if (strcasecmp(argv[0], "SET_XTAL_CAP_FINE") == 0) {
-		printk("set_xtal_cap_fine\n");
-		if (argc < 2) {
-			printk("wrong param\n");
-			break;
-		}
-		xtal_cap_fine = command_strtoul(argv[1], NULL, 10);
-		printk("xtal_cap_fine =%x\r\n", xtal_cap_fine);
-	#ifdef AICWF_SDIO_SUPPORT
-		rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, SET_XTAL_CAP_FINE, sizeof(xtal_cap_fine), (u8_l *)&xtal_cap_fine, &cfm);
-	#endif
-	#ifdef AICWF_USB_SUPPORT
-		rwnx_send_rftest_req(g_rwnx_plat->usbdev->rwnx_hw, SET_XTAL_CAP_FINE, sizeof(xtal_cap_fine), (u8_l *)&xtal_cap_fine, &cfm);
-	#endif
-		memcpy(command, &cfm.rftest_result[0], 4);
-		bytes_written = 4;
-	} else if (strcasecmp(argv[0], "SET_MAC_ADDR") == 0) {
-		printk("set_mac_addr\n");
-		if (argc < 7) {
-			printk("wrong param\n");
-			break;
-		}
-		mac_addr[5] = command_strtoul(argv[1], NULL, 16);
-		mac_addr[4] = command_strtoul(argv[2], NULL, 16);
-		mac_addr[3] = command_strtoul(argv[3], NULL, 16);
-		mac_addr[2] = command_strtoul(argv[4], NULL, 16);
-		mac_addr[1] = command_strtoul(argv[5], NULL, 16);
-		mac_addr[0] = command_strtoul(argv[6], NULL, 16);
-		printk("set macaddr:%x,%x,%x,%x,%x,%x\n", mac_addr[5], mac_addr[4], mac_addr[3], mac_addr[2], mac_addr[1], mac_addr[0]);
-	#ifdef AICWF_SDIO_SUPPORT
-		rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, SET_MAC_ADDR, sizeof(mac_addr), (u8_l *)&mac_addr, NULL);
-	#endif
-	#ifdef AICWF_USB_SUPPORT
-		rwnx_send_rftest_req(g_rwnx_plat->usbdev->rwnx_hw, SET_MAC_ADDR, sizeof(mac_addr), (u8_l *)&mac_addr, NULL);
-	#endif
-	} else if (strcasecmp(argv[0], "GET_MAC_ADDR") == 0) {
-		printk("get mac addr\n");
-	#ifdef AICWF_SDIO_SUPPORT
-		rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, GET_MAC_ADDR, 0, NULL, &cfm);
-	#endif
-	#ifdef AICWF_USB_SUPPORT
-		rwnx_send_rftest_req(g_rwnx_plat->usbdev->rwnx_hw, GET_MAC_ADDR, 0, NULL, &cfm);
-	#endif
-		memcpy(command, &cfm.rftest_result[0], 8);
-			bytes_written = 8;
-		printk("0x%x,0x%x\n", cfm.rftest_result[0], cfm.rftest_result[1]);
-	} else if (strcasecmp(argv[0], "SETSUSPENDMODE") == 0) {
-	#ifdef AICWF_SDIO_SUPPORT
-		setsusp_mode = command_strtoul(argv[1], NULL, 10);
-		rwnx_send_me_set_lp_level(g_rwnx_plat->sdiodev->rwnx_hw, setsusp_mode);
-		if (setsusp_mode == 1) {
-			aicwf_sdio_pwr_stctl(g_rwnx_plat->sdiodev, SDIO_SLEEP_ST);
-
-			ret = aicwf_sdio_writeb(g_rwnx_plat->sdiodev, SDIOWIFI_WAKEUP_REG, 2);
-			if (ret < 0) {
-				sdio_err("reg:%d write failed!\n", SDIOWIFI_WAKEUP_REG);
+		} else if (strcasecmp(argv[0], "SET_XTAL_CAP_FINE") == 0) {
+			printk("set_xtal_cap_fine\n");
+			if (argc < 2) {
+				printk("wrong param\n");
+				break;
 			}
-		}
-		printk("set suspend mode %d\n", setsusp_mode);
+			xtal_cap_fine = command_strtoul(argv[1], NULL, 10);
+			printk("xtal_cap_fine =%x\r\n", xtal_cap_fine);
+	#ifdef AICWF_SDIO_SUPPORT
+			rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, SET_XTAL_CAP_FINE, sizeof(xtal_cap_fine), (u8_l *)&xtal_cap_fine, &cfm);
 	#endif
-	} else {
-		printk("wrong cmd:%s in %s\n", cmd, __func__);
-	}
+	#ifdef AICWF_USB_SUPPORT
+			rwnx_send_rftest_req(g_rwnx_plat->usbdev->rwnx_hw, SET_XTAL_CAP_FINE, sizeof(xtal_cap_fine), (u8_l *)&xtal_cap_fine, &cfm);
+	#endif
+			memcpy(command, &cfm.rftest_result[0], 4);
+			bytes_written = 4;
+		} else if (strcasecmp(argv[0], "SET_MAC_ADDR") == 0) {
+			printk("set_mac_addr\n");
+			if (argc < 7) {
+				printk("wrong param\n");
+				break;
+			}
+			mac_addr[5] = command_strtoul(argv[1], NULL, 16);
+			mac_addr[4] = command_strtoul(argv[2], NULL, 16);
+			mac_addr[3] = command_strtoul(argv[3], NULL, 16);
+			mac_addr[2] = command_strtoul(argv[4], NULL, 16);
+			mac_addr[1] = command_strtoul(argv[5], NULL, 16);
+			mac_addr[0] = command_strtoul(argv[6], NULL, 16);
+			printk("set macaddr:%x,%x,%x,%x,%x,%x\n", mac_addr[5], mac_addr[4], mac_addr[3], mac_addr[2], mac_addr[1], mac_addr[0]);
+	#ifdef AICWF_SDIO_SUPPORT
+			rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, SET_MAC_ADDR, sizeof(mac_addr), (u8_l *)&mac_addr, NULL);
+	#endif
+	#ifdef AICWF_USB_SUPPORT
+			rwnx_send_rftest_req(g_rwnx_plat->usbdev->rwnx_hw, SET_MAC_ADDR, sizeof(mac_addr), (u8_l *)&mac_addr, NULL);
+	#endif
+		} else if (strcasecmp(argv[0], "GET_MAC_ADDR") == 0) {
+			printk("get mac addr\n");
+	#ifdef AICWF_SDIO_SUPPORT
+			rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, GET_MAC_ADDR, 0, NULL, &cfm);
+	#endif
+	#ifdef AICWF_USB_SUPPORT
+			rwnx_send_rftest_req(g_rwnx_plat->usbdev->rwnx_hw, GET_MAC_ADDR, 0, NULL, &cfm);
+	#endif
+			memcpy(command, &cfm.rftest_result[0], 8);
+			bytes_written = 8;
+			printk("0x%x,0x%x\n", cfm.rftest_result[0], cfm.rftest_result[1]);
+		} else if (strcasecmp(argv[0], "SET_VENDOR_INFO") == 0) {
+			vendor_info = command_strtoul(argv[1], NULL, 16);
+			printk("set vendor info:%x\n", vendor_info);
+	#ifdef AICWF_SDIO_SUPPORT
+			rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, SET_VENDOR_INFO, 1, &vendor_info, &cfm);
+	#endif
+	#ifdef AICWF_USB_SUPPORT
+			rwnx_send_rftest_req(g_rwnx_plat->usbdev->rwnx_hw, SET_VENDOR_INFO, 1, &vendor_info, &cfm);
+	#endif
+			memcpy(command, &cfm.rftest_result[0], 1);
+			bytes_written = 1;
+			printk("0x%x\n", cfm.rftest_result[0]);
+		} else if (strcasecmp(argv[0], "GET_VENDOR_INFO") == 0) {
+			printk("get vendor info\n");
+	#ifdef AICWF_SDIO_SUPPORT
+			rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, GET_VENDOR_INFO, 0, NULL, &cfm);
+	#endif
+	#ifdef AICWF_USB_SUPPORT
+			rwnx_send_rftest_req(g_rwnx_plat->usbdev->rwnx_hw, GET_VENDOR_INFO, 0, NULL, &cfm);
+	#endif
+			memcpy(command, &cfm.rftest_result[0], 1);
+			bytes_written = 1;
+			printk("0x%x\n", cfm.rftest_result[0]);
+		} else if (strcasecmp(argv[0], "GET_FREQ_CAL") == 0) {
+			printk("get freq cal\n");
+	#ifdef AICWF_SDIO_SUPPORT
+			rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, GET_FREQ_CAL, 0, NULL, &cfm);
+	#endif
+			memcpy(command, &cfm.rftest_result[0], 4);
+			bytes_written = 4;
+			printk("cap=0x%x, cap_fine=0x%x\n", cfm.rftest_result[0] & 0x0000ffff, (cfm.rftest_result[0] >> 16) & 0x0000ffff);
+		}  else if (strcasecmp(argv[0], "RDWR_PWRMM") == 0) {
+			printk("read/write txpwr manul mode\n");
+			if (argc <= 1) { // read cur
+	#ifdef AICWF_SDIO_SUPPORT
+				rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, RDWR_PWRMM, 0, NULL, &cfm);
+	#endif
+			} else { // write
+				u8_l pwrmm = (u8_l)command_strtoul(argv[1], NULL, 16);
+				pwrmm = (pwrmm) ? 1 : 0;
+				printk("set pwrmm = %x\r\n", pwrmm);
+	#ifdef AICWF_SDIO_SUPPORT
+				rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, RDWR_PWRMM, sizeof(pwrmm), (u8_l *)&pwrmm, &cfm);
+	#endif
+			}
+			memcpy(command, &cfm.rftest_result[0], 4);
+			bytes_written = 4;
+		} else if (strcasecmp(argv[0], "RDWR_PWRIDX") == 0) {
+			u8_l func = 0;
+			printk("read/write txpwr index\n");
+			if (argc > 1) {
+				func = (u8_l)command_strtoul(argv[1], NULL, 16);
+			}
+			if (func == 0) { // read cur
+	#ifdef AICWF_SDIO_SUPPORT
+				rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, RDWR_PWRIDX, 0, NULL, &cfm);
+	#endif
+			} else if (func <= 2) { // write 2.4g/5g pwr idx
+				if (argc > 3) {
+					u8_l type = (u8_l)command_strtoul(argv[2], NULL, 16);
+					u8_l pwridx = (u8_l)command_strtoul(argv[3], NULL, 10);
+					u8_l buf[3] = {func, type, pwridx};
+					printk("set pwridx:[%x][%x]=%x\r\n", func, type, pwridx);
+					rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, RDWR_PWRIDX, sizeof(buf), buf, &cfm);
+				} else {
+					printk("wrong args\n");
+				}
+			} else {
+				printk("wrong func: %x\n", func);
+			}
+			memcpy(command, &cfm.rftest_result[0], 7);
+			bytes_written = 7;
+		} else if (strcasecmp(argv[0], "RDWR_PWROFST") == 0) {
+			u8_l func = 0;
+			printk("read/write txpwr offset\n");
+			if (argc > 1) {
+				func = (u8_l)command_strtoul(argv[1], NULL, 16);
+			}
+			if (func == 0) { // read cur
+	#ifdef AICWF_SDIO_SUPPORT
+				rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, RDWR_PWROFST, 0, NULL, &cfm);
+	#endif
+			} else if (func <= 2) { // write 2.4g/5g pwr ofst
+				if (argc > 3) {
+					u8_l chgrp = (u8_l)command_strtoul(argv[2], NULL, 16);
+					s8_l pwrofst = (u8_l)command_strtoul(argv[3], NULL, 10);
+					u8_l buf[3] = {func, chgrp, (u8_l)pwrofst};
+					printk("set pwrofst:[%x][%x]=%d\r\n", func, chgrp, pwrofst);
+	#ifdef AICWF_SDIO_SUPPORT
+					rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, RDWR_PWROFST, sizeof(buf), buf, &cfm);
+	#endif
+				} else {
+					printk("wrong args\n");
+				}
+			} else {
+				printk("wrong func: %x\n", func);
+			}
+			memcpy(command, &cfm.rftest_result[0], 7);
+			bytes_written = 7;
+		} else if (strcasecmp(argv[0], "RDWR_DRVIBIT") == 0) {
+			u8_l func = 0;
+			printk("read/write pa drv_ibit\n");
+			if (argc > 1) {
+				func = (u8_l)command_strtoul(argv[1], NULL, 16);
+			}
+			if (func == 0) { // read cur
+	#ifdef AICWF_SDIO_SUPPORT
+				rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, RDWR_DRVIBIT, 0, NULL, &cfm);
+	#endif
+			} else if (func == 1) { // write 2.4g pa drv_ibit
+				if (argc > 2) {
+					u8_l ibit = (u8_l)command_strtoul(argv[2], NULL, 16);
+					u8_l buf[2] = {func, ibit};
+					printk("set drvibit:[%x]=%x\r\n", func, ibit);
+	#ifdef AICWF_SDIO_SUPPORT
+					rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, RDWR_DRVIBIT, sizeof(buf), buf, &cfm);
+	#endif
+				} else {
+					printk("wrong args\n");
+				}
+			} else {
+				printk("wrong func: %x\n", func);
+			}
+			memcpy(command, &cfm.rftest_result[0], 16);
+			bytes_written = 16;
+		} else if (strcasecmp(argv[0], "RDWR_EFUSE_PWROFST") == 0) {
+			u8_l func = 0;
+			printk("read/write txpwr offset into efuse\n");
+			if (argc > 1) {
+				func = (u8_l)command_strtoul(argv[1], NULL, 16);
+			}
+			if (func == 0) { // read cur
+	#ifdef AICWF_SDIO_SUPPORT
+				rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, RDWR_EFUSE_PWROFST, 0, NULL, &cfm);
+	#endif
+			} else if (func <= 2) { // write 2.4g/5g pwr ofst
+				if (argc > 3) {
+					u8_l chgrp = (u8_l)command_strtoul(argv[2], NULL, 16);
+					s8_l pwrofst = (u8_l)command_strtoul(argv[3], NULL, 10);
+					u8_l buf[3] = {func, chgrp, (u8_l)pwrofst};
+					printk("set efuse pwrofst:[%x][%x]=%d\r\n", func, chgrp, pwrofst);
+	#ifdef AICWF_SDIO_SUPPORT
+					rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, RDWR_EFUSE_PWROFST, sizeof(buf), buf, &cfm);
+	#endif
+				} else {
+					printk("wrong args\n");
+				}
+			} else {
+				printk("wrong func: %x\n", func);
+			}
+			memcpy(command, &cfm.rftest_result[0], 7);
+			bytes_written = 7;
+		} else if (strcasecmp(argv[0], "RDWR_EFUSE_DRVIBIT") == 0) {
+			u8_l func = 0;
+			printk("read/write pa drv_ibit into efuse\n");
+			if (argc > 1) {
+				func = (u8_l)command_strtoul(argv[1], NULL, 16);
+			}
+			if (func == 0) { // read cur
+	#ifdef AICWF_SDIO_SUPPORT
+				rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, RDWR_EFUSE_DRVIBIT, 0, NULL, &cfm);
+	#endif
+			} else if (func == 1) { // write 2.4g pa drv_ibit
+				if (argc > 2) {
+				u8_l ibit = (u8_l)command_strtoul(argv[2], NULL, 16);
+				u8_l buf[2] = {func, ibit};
+				printk("set efuse drvibit:[%x]=%x\r\n", func, ibit);
+	#ifdef AICWF_SDIO_SUPPORT
+				rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, RDWR_EFUSE_DRVIBIT, sizeof(buf), buf, &cfm);
+	#endif
+				} else {
+					printk("wrong args\n");
+				}
+			} else {
+				printk("wrong func: %x\n", func);
+			}
+			memcpy(command, &cfm.rftest_result[0], 4);
+			bytes_written = 4;
+		} else if (strcasecmp(argv[0], "SET_PAPR") == 0) {
+			printk("set papr\n");
+			if (argc > 1) {
+				u8_l func = (u8_l) command_strtoul(argv[1], NULL, 10);
+				printk("papr %d\r\n", func);
+	#ifdef AICWF_SDIO_SUPPORT
+				rwnx_send_rftest_req(g_rwnx_plat->sdiodev->rwnx_hw, SET_PAPR, sizeof(func), &func, NULL);
+	#endif
+			} else {
+				printk("wrong args\n");
+			}
+		} else if (strcasecmp(argv[0], "SETSUSPENDMODE") == 0) {
+	#ifdef AICWF_SDIO_SUPPORT
+			setsusp_mode = command_strtoul(argv[1], NULL, 10);
+			rwnx_send_me_set_lp_level(g_rwnx_plat->sdiodev->rwnx_hw, setsusp_mode);
+			if (setsusp_mode == 1) {
+				aicwf_sdio_pwr_stctl(g_rwnx_plat->sdiodev, SDIO_SLEEP_ST);
+
+				ret = aicwf_sdio_writeb(g_rwnx_plat->sdiodev, SDIOWIFI_WAKEUP_REG, 2);
+				if (ret < 0) {
+					sdio_err("reg:%d write failed!\n", SDIOWIFI_WAKEUP_REG);
+				}
+			}
+			printk("set suspend mode %d\n", setsusp_mode);
+	#endif
+		} else {
+			printk("wrong cmd:%s in %s\n", cmd, __func__);
+		}
 #endif
 	} while (0);
 	kfree(cmd);
@@ -1441,8 +1667,6 @@
 	int bytes_written = 0;
 	android_wifi_priv_cmd priv_cmd;
 	int buf_size = 0;
-
-	RWNX_DBG(RWNX_FN_ENTRY_STR);
 
 	///todo: add our lock
 	//net_os_wake_lock(net);
@@ -1502,9 +1726,6 @@
 
 	/* outputs */
 	printk("%s: Android private cmd \"%s\" on %s\n", __FUNCTION__, command, ifr->ifr_name);
-	printk("cmd = %d\n", cmd);
-	printk("buf_size=%d\n", buf_size);
-
 
 	bytes_written = handle_private_cmd(net, command, priv_cmd.total_len);
 	if (bytes_written >= 0) {
@@ -1552,7 +1773,6 @@
 		printk("IOCTL SIOCDEVPRIVATE\n");
 		break;
 	case (SIOCDEVPRIVATE+1):
-		printk("IOCTL PRIVATE\n");
 		android_priv_cmd(net, req, cmd);
 		break;
 	default:
@@ -1858,15 +2078,17 @@
 		atomic_set(&rwnx_hw->p2p_alive_timer_count, 0);
 
 	rwnx_hw->is_p2p_alive = 0;
-	rwnx_send_remove_if (rwnx_hw, rwnx_vif->vif_index, true);
+	if (rwnx_vif->up) {
+		rwnx_send_remove_if (rwnx_hw, rwnx_vif->vif_index, true);
 
-	 /* Ensure that we won't process disconnect ind */
-	 spin_lock_bh(&rwnx_hw->cb_lock);
+		/* Ensure that we won't process disconnect ind */
+		spin_lock_bh(&rwnx_hw->cb_lock);
 
-	 rwnx_vif->up = false;
-	 rwnx_hw->vif_table[rwnx_vif->vif_index] = NULL;
-	 rwnx_hw->vif_started--;
-	 spin_unlock_bh(&rwnx_hw->cb_lock);
+		rwnx_vif->up = false;
+		rwnx_hw->vif_table[rwnx_vif->vif_index] = NULL;
+		rwnx_hw->vif_started--;
+		spin_unlock_bh(&rwnx_hw->cb_lock);
+	}
 }
 
 
@@ -2155,7 +2377,6 @@
 	if (type == NL80211_IFTYPE_P2P_CLIENT || type == NL80211_IFTYPE_P2P_GO)
 		p2p = true;
 
-	if (type == NL80211_IFTYPE_AP || type == NL80211_IFTYPE_P2P_GO) {
 	if (vif->up) {
 	/* Abort scan request on the vif */
 	if (vif->rwnx_hw->scan_request &&
@@ -2198,7 +2419,6 @@
 		vif->vif_index = add_if_cfm.inst_nbr;
 		vif->rwnx_hw->vif_table[add_if_cfm.inst_nbr] = vif;
 		spin_unlock_bh(&vif->rwnx_hw->cb_lock);
-		}
 	}
 	return 0;
 }
@@ -2215,33 +2435,6 @@
 
 static void rwnx_cfgp2p_stop_p2p_device(struct wiphy *wiphy, struct wireless_dev *wdev)
 {
-#if 0
-	int ret = 0;
-	struct bcm_cfg80211 *cfg = wiphy_priv(wiphy);
-
-	if (!cfg)
-		return;
-
-	CFGP2P_DBG(("Enter\n"));
-
-	ret = wl_cfg80211_scan_stop(cfg, wdev);
-	if (unlikely(ret < 0)) {
-		CFGP2P_ERR(("P2P scan stop failed, ret=%d\n", ret));
-	}
-
-	if (!cfg->p2p)
-		return;
-
-	/* Cancel any on-going listen */
-	wl_cfgp2p_cancel_listen(cfg, bcmcfg_to_prmry_ndev(cfg), wdev, TRUE);
-
-	ret = wl_cfgp2p_disable_discovery(cfg);
-	if (unlikely(ret < 0)) {
-		CFGP2P_ERR(("P2P disable discovery failed, ret=%d\n", ret));
-	}
-
-	p2p_on(cfg) = false;
-#endif
 	int ret = 0;
 	struct rwnx_hw *rwnx_hw = wiphy_priv(wiphy);
 	struct rwnx_vif *rwnx_vif = container_of(wdev, struct rwnx_vif, wdev);
@@ -2262,6 +2455,25 @@
 		if (ret)
 			printk("scanu_cancel fail\n");
 	}
+
+	if (rwnx_vif == rwnx_hw->p2p_dev_vif) {
+		rwnx_hw->is_p2p_alive = 0;
+		if (timer_pending(&rwnx_hw->p2p_alive_timer)) {
+			del_timer_sync(&rwnx_hw->p2p_alive_timer);
+		}
+
+		if (rwnx_vif->up) {
+			rwnx_send_remove_if(rwnx_hw, rwnx_vif->vif_index, true);
+			/* Ensure that we won't process disconnect ind */
+			spin_lock_bh(&rwnx_hw->cb_lock);
+			rwnx_vif->up = false;
+			rwnx_hw->vif_table[rwnx_vif->vif_index] = NULL;
+			rwnx_hw->vif_started--;
+			spin_unlock_bh(&rwnx_hw->cb_lock);
+		}
+
+	}
+
 	printk("Exit. P2P interface stopped\n");
 
 	return;
@@ -2477,17 +2689,37 @@
 	struct rwnx_vif *rwnx_vif = netdev_priv(dev);
 	struct sm_connect_cfm sm_connect_cfm;
 	int error = 0;
+	int is_wep = ((sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) ||
+			(sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) ||
+			(sme->crypto.ciphers_pairwise[0] == WLAN_CIPHER_SUITE_WEP40) ||
+			(sme->crypto.ciphers_pairwise[0] == WLAN_CIPHER_SUITE_WEP104));
 
 	RWNX_DBG(RWNX_FN_ENTRY_STR);
 
-	if (rwnx_vif->wep_enabled && rwnx_vif->wep_auth_err && (sme->auth_type == rwnx_vif->last_auth_type)) {
-		if (sme->auth_type == NL80211_AUTHTYPE_SHARED_KEY) {
-			sme->auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM;
-			printk("start connect, auth_type changed, shared --> open\n");
-		}
-		if (sme->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM) {
-			sme->auth_type = NL80211_AUTHTYPE_SHARED_KEY;
-			printk("start connect, auth_type changed, open --> shared\n");
+	if (is_wep) {
+		if (sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC) {
+			if (rwnx_vif->wep_enabled && rwnx_vif->wep_auth_err) {
+				if (rwnx_vif->last_auth_type == NL80211_AUTHTYPE_SHARED_KEY)
+					sme->auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM;
+				else
+					sme->auth_type = NL80211_AUTHTYPE_SHARED_KEY;
+			} else {
+				if ((rwnx_vif->wep_enabled && !rwnx_vif->wep_auth_err))
+					sme->auth_type = rwnx_vif->last_auth_type;
+				else
+				sme->auth_type = NL80211_AUTHTYPE_SHARED_KEY;
+			}
+			printk("auto: use sme->auth_type = %d\r\n", sme->auth_type);
+		} else {
+			if (rwnx_vif->wep_enabled && rwnx_vif->wep_auth_err && (sme->auth_type == rwnx_vif->last_auth_type)) {
+				if (sme->auth_type == NL80211_AUTHTYPE_SHARED_KEY) {
+					sme->auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM;
+					printk("start connect, auth_type changed, shared --> open\n");
+				} else if (sme->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM) {
+					sme->auth_type = NL80211_AUTHTYPE_SHARED_KEY;
+					printk("start connect, auth_type changed, open --> shared\n");
+				}
+			}
 		}
 	}
 
@@ -2501,7 +2733,7 @@
 		key_params.cipher = sme->crypto.cipher_group;
 		rwnx_cfg80211_add_key(wiphy, dev, sme->key_idx, false, NULL, &key_params);
 	}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0) || defined(CONFIG_WPA3_FOR_OLD_KERNEL)
 	else if ((sme->auth_type == NL80211_AUTHTYPE_SAE) &&
 			 !(sme->flags & CONNECT_REQ_EXTERNAL_AUTH_SUPPORT)) {
 		netdev_err(dev, "Doesn't support SAE without external authentication\n");
@@ -2557,7 +2789,7 @@
 	return rwnx_send_sm_disconnect_req(rwnx_hw, rwnx_vif, reason_code);
 }
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0) || defined(CONFIG_WPA3_FOR_OLD_KERNEL)
 /**
  * @external_auth: indicates result of offloaded authentication processing from
  *     user space
@@ -2638,9 +2870,9 @@
 				sta->uapsd_tids &= ~(1 << tid);
 		}
 		memcpy(sta->mac_addr, mac, ETH_ALEN);
-		#if 0
+#ifdef CONFIG_DEBUG_FS
 		rwnx_dbgfs_register_rc_stat(rwnx_hw, sta);
-		#endif
+#endif
 
 		/* Ensure that we won't process PS change or channel switch ind*/
 		spin_lock_bh(&rwnx_hw->cb_lock);
@@ -2657,7 +2889,7 @@
 			memset(&sinfo, 0, sizeof(struct station_info));
 			sinfo.assoc_req_ies = NULL;
 			sinfo.assoc_req_ies_len = 0;
-			#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 83)
+			#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
 			sinfo.filled |= STATION_INFO_ASSOC_REQ_IES;
 			#endif
 			cfg80211_new_sta(rwnx_vif->ndev, sta->mac_addr, &sinfo, GFP_KERNEL);
@@ -2789,10 +3021,10 @@
 #endif /* CONFIG_RWNX_BFMER */
 
 			list_del(&cur->list);
-#if 0
+#ifdef CONFIG_DEBUG_FS
 			rwnx_dbgfs_unregister_rc_stat(rwnx_hw, cur);
 #endif
-			found++;
+			found = true;
 			break;
 		}
 	}
@@ -2805,6 +3037,146 @@
 	return 0;
 }
 
+void apm_staloss_work_process(struct work_struct *work)
+{
+	struct rwnx_hw *rwnx_hw = container_of(work, struct rwnx_hw, apmStalossWork);
+	struct rwnx_sta *cur, *tmp;
+	int error = 0;
+
+#ifdef AICWF_RX_REORDER
+	struct reord_ctrl_info *reord_info, *reord_tmp;
+	u8 *macaddr;
+	struct aicwf_rx_priv *rx_priv;
+#endif
+	struct rwnx_vif *rwnx_vif;
+	bool_l found = false;
+	const u8 *mac = rwnx_hw->sta_mac_addr;
+
+	RWNX_DBG(RWNX_FN_ENTRY_STR);
+
+	// Look for VIF entry
+	list_for_each_entry(rwnx_vif, &rwnx_hw->vifs, list) {
+		if (rwnx_vif->vif_index == rwnx_hw->apm_vif_idx) {
+			found = true;
+			break;
+		}
+	}
+
+	printk("apm vif idx=%d, found=%d, mac addr=%pM\n", rwnx_hw->apm_vif_idx, found, mac);
+	if (!found || !rwnx_vif || (RWNX_VIF_TYPE(rwnx_vif) != NL80211_IFTYPE_AP && RWNX_VIF_TYPE(rwnx_vif) != NL80211_IFTYPE_P2P_GO)) {
+		return;
+	}
+
+	list_for_each_entry_safe(cur, tmp, &rwnx_vif->ap.sta_list, list) {
+		if ((!mac) || (!memcmp(cur->mac_addr, mac, ETH_ALEN))) {
+			netdev_info(rwnx_vif->ndev, "Del sta %d (%pM)", cur->sta_idx, cur->mac_addr);
+			/* Ensure that we won't process PS change ind */
+			spin_lock_bh(&rwnx_hw->cb_lock);
+			cur->ps.active = false;
+			cur->valid = false;
+			spin_unlock_bh(&rwnx_hw->cb_lock);
+
+			if (cur->vif_idx != cur->vlan_idx) {
+				struct rwnx_vif *vlan_vif;
+				vlan_vif = rwnx_hw->vif_table[cur->vlan_idx];
+				if (vlan_vif->up) {
+					if ((RWNX_VIF_TYPE(vlan_vif) == NL80211_IFTYPE_AP_VLAN) &&
+						(vlan_vif->use_4addr)) {
+						vlan_vif->ap_vlan.sta_4a = NULL;
+					} else {
+						WARN(1, "Deleting sta belonging to VLAN other than AP_VLAN 4A");
+					}
+				}
+			}
+		    /*if (rwnx_vif->wdev.iftype == NL80211_IFTYPE_AP || rwnx_vif->wdev.iftype == NL80211_IFTYPE_P2P_GO) {
+				cfg80211_del_sta(rwnx_vif->ndev, cur->mac_addr, GFP_KERNEL);
+			}*/
+
+#ifdef AICWF_RX_REORDER
+#ifdef AICWF_SDIO_SUPPORT
+			rx_priv = rwnx_hw->sdiodev->rx_priv;
+#else
+			rx_priv = rwnx_hw->usbdev->rx_priv;
+#endif
+			if ((rwnx_vif->wdev.iftype == NL80211_IFTYPE_STATION) || (rwnx_vif->wdev.iftype == NL80211_IFTYPE_P2P_CLIENT)) {
+				BUG();//should be other function
+			} else if ((rwnx_vif->wdev.iftype == NL80211_IFTYPE_AP) || (rwnx_vif->wdev.iftype == NL80211_IFTYPE_P2P_GO)) {
+				macaddr = cur->mac_addr;
+				printk("deinit:macaddr:%x,%x,%x,%x,%x,%x\r\n", macaddr[0], macaddr[1], macaddr[2], \
+									   macaddr[3], macaddr[4], macaddr[5]);
+				spin_lock_bh(&rx_priv->stas_reord_lock);
+				list_for_each_entry_safe(reord_info, reord_tmp,
+					&rx_priv->stas_reord_list, list) {
+					printk("reord_mac:%x,%x,%x,%x,%x,%x\r\n", reord_info->mac_addr[0], reord_info->mac_addr[1], reord_info->mac_addr[2], \
+										   reord_info->mac_addr[3], reord_info->mac_addr[4], reord_info->mac_addr[5]);
+					if (!memcmp(reord_info->mac_addr, macaddr, 6)) {
+						reord_deinit_sta(rx_priv, reord_info);
+						break;
+					}
+				}
+				spin_unlock_bh(&rx_priv->stas_reord_lock);
+			}
+#endif
+
+			rwnx_txq_sta_deinit(rwnx_hw, cur);
+			error = rwnx_send_me_sta_del(rwnx_hw, cur->sta_idx, false);
+			if ((error != 0) && (error != -EPIPE))
+				return;
+
+#ifdef CONFIG_RWNX_BFMER
+			// Disable Beamformer if supported
+			rwnx_bfmer_report_del(rwnx_hw, cur);
+			rwnx_mu_group_sta_del(rwnx_hw, cur);
+#endif /* CONFIG_RWNX_BFMER */
+
+			list_del(&cur->list);
+#ifdef CONFIG_DEBUG_FS
+			rwnx_dbgfs_unregister_rc_stat(rwnx_hw, cur);
+#endif
+			found++;
+			break;
+		}
+	}
+
+	if (!found)
+		return;
+
+	rwnx_update_mesh_power_mode(rwnx_vif);
+}
+
+void apm_probe_sta_work_process(struct work_struct *work)
+{
+	struct apm_probe_sta *probe_sta = container_of(work, struct apm_probe_sta, apmprobestaWork);
+	struct rwnx_vif *rwnx_vif = container_of(probe_sta, struct rwnx_vif, sta_probe);
+	bool found = false;
+	struct rwnx_sta *cur, *tmp;
+
+	u8 *mac = rwnx_vif->sta_probe.sta_mac_addr;
+
+	RWNX_DBG(RWNX_FN_ENTRY_STR);
+
+	list_for_each_entry_safe(cur, tmp, &rwnx_vif->ap.sta_list, list) {
+		if (!memcmp(cur->mac_addr, mac, ETH_ALEN)) {
+			found = true;
+			break;
+		}
+	}
+
+	printk("sta %pM found = %d\n", mac, found);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
+	if (found)
+		cfg80211_probe_status(rwnx_vif->ndev, mac, (u64)rwnx_vif->sta_probe.probe_id, 1, 0, false, GFP_ATOMIC);
+	else
+		cfg80211_probe_status(rwnx_vif->ndev, mac, (u64)rwnx_vif->sta_probe.probe_id, 0, 0, false, GFP_ATOMIC);
+#else
+	if (found)
+		cfg80211_probe_status(rwnx_vif->ndev, mac, (u64)rwnx_vif->sta_probe.probe_id, 1, GFP_ATOMIC);
+	else
+		cfg80211_probe_status(rwnx_vif->ndev, mac, (u64)rwnx_vif->sta_probe.probe_id, 0, GFP_ATOMIC);
+
+#endif
+	rwnx_vif->sta_probe.probe_id++;
+}
 /**
  * @change_station: Modify a given station. Note that flags changes are not much
  *	validated in cfg80211, in particular the auth/assoc/authorized flags
@@ -2860,8 +3232,9 @@
 						sta->uapsd_tids &= ~(1 << tid);
 				}
 				memcpy(sta->mac_addr, mac, ETH_ALEN);
+#ifdef CONFIG_DEBUG_FS
 				rwnx_dbgfs_register_rc_stat(rwnx_hw, sta);
-
+#endif
 				/* Ensure that we won't process PS change or channel switch ind*/
 				spin_lock_bh(&rwnx_hw->cb_lock);
 				rwnx_txq_sta_init(rwnx_hw, sta, rwnx_txq_vif_get_status(rwnx_vif));
@@ -2974,6 +3347,12 @@
 
 	RWNX_DBG(RWNX_FN_ENTRY_STR);
 
+	INIT_WORK(&rwnx_vif->sta_probe.apmprobestaWork, apm_probe_sta_work_process);
+	rwnx_vif->sta_probe.apmprobesta_wq = create_singlethread_workqueue("apmprobe_wq");
+	if (!rwnx_vif->sta_probe.apmprobesta_wq) {
+		txrx_err("insufficient memory to create apmprobe_wq.\n");
+		return -ENOBUFS;
+	}
 	if (rwnx_vif->wdev.iftype == NL80211_IFTYPE_P2P_GO)
 		rwnx_hw->is_p2p_connected = 1;
 	/* Forward the information to the LMAC */
@@ -3068,23 +3447,10 @@
 
 	rwnx_send_bcn(rwnx_hw, buf, vif->vif_index, bcn->len);
 
-#if 0
-	// Sync buffer for FW
-	error = rwnx_ipc_elem_var_allocs(rwnx_hw, &elem, bcn->len, DMA_TO_DEVICE,
-										  buf, NULL, NULL);
-	if (error)
-		return error;
-#endif
 	// Forward the information to the LMAC
-	error = rwnx_send_bcn_change(rwnx_hw, vif->vif_index, elem.dma_addr,
+	error = rwnx_send_bcn_change(rwnx_hw, vif->vif_index, 0,
 								 bcn->len, bcn->head_len, bcn->tim_len, NULL);
 
-#if 0
-	rwnx_ipc_elem_var_deallocs(rwnx_hw, &elem);
-#else
-
-
-#endif
 	return error;
 }
 
@@ -3117,6 +3483,9 @@
 	rwnx_txq_vif_deinit(rwnx_hw, rwnx_vif);
 	rwnx_del_bcn(&rwnx_vif->ap.bcn);
 	rwnx_del_csa(rwnx_vif);
+
+	flush_workqueue(rwnx_vif->sta_probe.apmprobesta_wq);
+	destroy_workqueue(rwnx_vif->sta_probe.apmprobesta_wq);
 
 	netif_tx_stop_all_queues(dev);
 	netif_carrier_off(dev);
@@ -3195,9 +3564,33 @@
 int rwnx_cfg80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
 			const u8 *peer, u64 *cookie)
 {
+	//struct rwnx_hw *rwnx_hw = wiphy_priv(wiphy);
+	struct rwnx_vif *vif = netdev_priv(dev);
+	struct rwnx_sta *sta = NULL;
+
+	RWNX_DBG(RWNX_FN_ENTRY_STR);
+
+	if ((RWNX_VIF_TYPE(vif) != NL80211_IFTYPE_AP) && (RWNX_VIF_TYPE(vif) != NL80211_IFTYPE_P2P_GO) &&
+		(RWNX_VIF_TYPE(vif) != NL80211_IFTYPE_AP_VLAN))
+		return -EINVAL;
+	list_for_each_entry(sta, &vif->ap.sta_list, list) {
+	if (sta->valid && ether_addr_equal(sta->mac_addr, peer))
+		break;
+	}
+
+	if (!sta)
+		return -ENOENT;
+
+
+	memcpy(vif->sta_probe.sta_mac_addr, peer, 6);
+	queue_work(vif->sta_probe.apmprobesta_wq, &vif->sta_probe.apmprobestaWork);
+
+	*cookie = vif->sta_probe.probe_id;
+
 	return 0;
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
 /**
  * @mgmt_frame_register: Notify driver that a management frame type was
  *	registered. Note that this callback may not sleep, and cannot run
@@ -3208,6 +3601,7 @@
 				   u16 frame_type, bool reg)
 {
 }
+#endif
 
 /**
  * @set_wiphy_params: Notify that wiphy parameters have changed;
@@ -3256,7 +3650,6 @@
 	return res;
 }
 
-#if 0
 /**
  * @set_power_mgmt: set the power save to one of those two modes:
  *  Power-save off
@@ -3266,6 +3659,7 @@
 										struct net_device *dev,
 										bool enabled, int timeout)
 {
+#if 0
 	struct rwnx_hw *rwnx_hw = wiphy_priv(wiphy);
 	u8 ps_mode;
 
@@ -3285,8 +3679,13 @@
 	}
 
 	return rwnx_send_me_set_ps_mode(rwnx_hw, ps_mode);
-}
+#else
+	/* TODO
+	 * Add handle in the feature!
+	 */
+	return 0;
 #endif
+}
 
 static int rwnx_cfg80211_set_txq_params(struct wiphy *wiphy, struct net_device *dev,
 										struct ieee80211_txq_params *params)
@@ -3332,13 +3731,15 @@
 	struct rwnx_vif *rwnx_vif = container_of(wdev, struct rwnx_vif, wdev);
 	struct rwnx_roc_elem *roc_elem;
 	struct mm_add_if_cfm add_if_cfm;
+	struct mm_remain_on_channel_cfm roc_cfm;
 	int error;
 
 	RWNX_DBG(RWNX_FN_ENTRY_STR);
 
 	/* For debug purpose (use ftrace kernel option) */
+#ifdef CREATE_TRACE_POINTS
 	trace_roc(rwnx_vif->vif_index, chan->center_freq, duration);
-
+#endif
 	/* Check that no other RoC procedure has been launched */
 	if (rwnx_hw->roc_elem) {
 		msleep(2);
@@ -3349,7 +3750,7 @@
 	}
 
 	printk("remain:%d,%d,%d\n", rwnx_vif->vif_index, rwnx_vif->is_p2p_vif, rwnx_hw->is_p2p_alive);
-	if (rwnx_vif->is_p2p_vif) {
+	if (rwnx_vif == rwnx_hw->p2p_dev_vif && !rwnx_vif->up) {
 		if (!rwnx_hw->is_p2p_alive) {
 			error = rwnx_send_add_if (rwnx_hw, rwnx_vif->wdev.address, //wdev->netdev->dev_addr,
 								  RWNX_VIF_TYPE(rwnx_vif), false, &add_if_cfm);
@@ -3396,14 +3797,19 @@
 
 	/* Forward the information to the FMAC */
 	rwnx_hw->roc_elem = roc_elem;
-	error = rwnx_send_roc(rwnx_hw, rwnx_vif, chan, duration);
+	error = rwnx_send_roc(rwnx_hw, rwnx_vif, chan, duration, &roc_cfm);
 
 	/* If no error, keep all the information for handling of end of procedure */
 	if (error == 0) {
-
 		/* Set the cookie value */
 		*cookie = (u64)(rwnx_hw->roc_cookie_cnt);
-
+		if (roc_cfm.status) {
+			// failed to roc
+			rwnx_hw->roc_elem = NULL;
+			kfree(roc_elem);
+			rwnx_txq_offchan_deinit(rwnx_vif);
+			return -EBUSY;
+		}
 	} else {
 		/* Free the allocated element */
 		rwnx_hw->roc_elem = NULL;
@@ -3424,13 +3830,15 @@
 												  u64 cookie)
 {
 	struct rwnx_hw *rwnx_hw = wiphy_priv(wiphy);
+#ifdef CREATE_TRACE_POINTS
 	struct rwnx_vif *rwnx_vif = container_of(wdev, struct rwnx_vif, wdev);//netdev_priv(wdev->netdev);
-
+#endif
 	RWNX_DBG(RWNX_FN_ENTRY_STR);
 
 	/* For debug purpose (use ftrace kernel option) */
+#ifdef CREATE_TRACE_POINTS
 	trace_cancel_roc(rwnx_vif->vif_index);
-
+#endif
 	/* Check if a RoC procedure is pending */
 	if (!rwnx_hw->roc_elem) {
 		return 0;
@@ -3578,11 +3986,11 @@
 	/* Get STA on which management frame has to be sent */
 	rwnx_sta = rwnx_retrieve_sta(rwnx_hw, rwnx_vif, mgmt->da,
 								 mgmt->frame_control, ap);
-
+#ifdef CREATE_TRACE_POINTS
 	trace_mgmt_tx((channel) ? channel->center_freq : 0,
 				  rwnx_vif->vif_index, (rwnx_sta) ? rwnx_sta->sta_idx : 0xFF,
 				  mgmt);
-
+#endif
 	if (ap || rwnx_sta)
 		goto send_frame;
 
@@ -3718,7 +4126,6 @@
 {
 	struct rwnx_hw *rwnx_hw = wiphy_priv(wiphy);
 	struct rwnx_vif *vif = netdev_priv(dev);
-	struct rwnx_ipc_elem_var elem;
 	struct rwnx_bcn *bcn, *bcn_after;
 	struct rwnx_csa *csa;
 	u16 csa_oft[BCN_MAX_CSA_CPT];
@@ -3752,8 +4159,7 @@
 		}
 	}
 
-	error = rwnx_ipc_elem_var_allocs(rwnx_hw, &elem, bcn->len,
-										  DMA_TO_DEVICE, buf, NULL, NULL);
+	error = rwnx_send_bcn(rwnx_hw, buf, vif->vif_index, bcn->len);
 	if (error) {
 		goto end;
 	}
@@ -3775,8 +4181,7 @@
 		goto end;
 	}
 
-	error = rwnx_ipc_elem_var_allocs(rwnx_hw, &csa->elem, bcn_after->len,
-										  DMA_TO_DEVICE, buf, NULL, NULL);
+	error = rwnx_send_bcn(rwnx_hw, buf, vif->vif_index, bcn_after->len);
 	if (error) {
 		goto end;
 	}
@@ -3786,7 +4191,7 @@
 	csa->chandef = params->chandef;
 
 	/* Send new Beacon. FW will extract channel and count from the beacon */
-	error = rwnx_send_bcn_change(rwnx_hw, vif->vif_index, elem.dma_addr,
+	error = rwnx_send_bcn_change(rwnx_hw, vif->vif_index, 0,
 								 bcn->len, bcn->head_len, bcn->tim_len, csa_oft);
 
 	if (error) {
@@ -3794,11 +4199,14 @@
 		goto end;
 	} else {
 		INIT_WORK(&csa->work, rwnx_csa_finish);
-		rwnx_cfg80211_ch_switch_started_notify(dev, &csa->chandef, params->count);
+		rwnx_cfg80211_ch_switch_started_notify(dev, &csa->chandef, params->count
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
+				, params->block_tx
+#endif
+				);
 	}
 
 end:
-	rwnx_ipc_elem_var_deallocs(rwnx_hw, &elem);
 	return error;
 }
 #endif
@@ -3933,7 +4341,9 @@
 
 		/* Set TDLS not active */
 		rwnx_vif->sta.tdls_sta->tdls.active = false;
+#ifdef CONFIG_DEBUG_FS
 		rwnx_dbgfs_unregister_rc_stat(rwnx_hw, rwnx_vif->sta.tdls_sta);
+#endif
 		// Remove TDLS station
 		rwnx_vif->tdls_status = TDLS_LINK_IDLE;
 		rwnx_vif->sta.tdls_sta = NULL;
@@ -4035,102 +4445,9 @@
 	struct rwnx_sta_stats *stats = &sta->stats;
 	struct rx_vector_1 *rx_vect1 = &stats->last_rx.rx_vect1;
 	union rwnx_rate_ctrl_info *rate_info;
-	struct mm_get_sta_txinfo_cfm cfm;
+	struct mm_get_sta_info_cfm cfm;
 
-	sinfo->inactive_time = jiffies_to_msecs(jiffies - vif->rwnx_hw->stats.last_tx);
-	sinfo->rx_bytes = vif->net_stats.rx_bytes;
-	sinfo->tx_bytes = vif->net_stats.tx_bytes;
-	sinfo->tx_packets = vif->net_stats.tx_packets;
-	sinfo->rx_packets = vif->net_stats.rx_packets;
-	sinfo->signal = rx_vect1->rssi1;
-
-	#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)
-	switch (rx_vect1->ch_bw) {
-	case PHY_CHNL_BW_20:
-		sinfo->rxrate.bw = RATE_INFO_BW_20;
-		break;
-	case PHY_CHNL_BW_40:
-		sinfo->rxrate.bw = RATE_INFO_BW_40;
-		break;
-	case PHY_CHNL_BW_80:
-		sinfo->rxrate.bw = RATE_INFO_BW_80;
-		break;
-	case PHY_CHNL_BW_160:
-		sinfo->rxrate.bw = RATE_INFO_BW_160;
-		break;
-	default:
-	#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
-		sinfo->rxrate.bw = RATE_INFO_BW_HE_RU;
-	#else
-		sinfo->rxrate.bw = RATE_INFO_BW_20;
-	#endif
-		break;
-	}
-	#endif
-
-	switch (rx_vect1->format_mod) {
-	case FORMATMOD_NON_HT:
-	case FORMATMOD_NON_HT_DUP_OFDM:
-		sinfo->rxrate.flags = 0;
-		sinfo->rxrate.legacy = legrates_lut_rate[legrates_lut[rx_vect1->leg_rate]];
-		break;
-	case FORMATMOD_HT_MF:
-	case FORMATMOD_HT_GF:
-		sinfo->rxrate.flags = RATE_INFO_FLAGS_MCS;
-		if (rx_vect1->ht.short_gi)
-			sinfo->rxrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
-		sinfo->rxrate.mcs = rx_vect1->ht.mcs;
-		break;
-	case FORMATMOD_VHT:
-		sinfo->rxrate.flags = RATE_INFO_FLAGS_VHT_MCS;
-		if (rx_vect1->vht.short_gi)
-			sinfo->rxrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
-		sinfo->rxrate.mcs = rx_vect1->vht.mcs;
-		sinfo->rxrate.nss = rx_vect1->vht.nss;
-		break;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
-	case FORMATMOD_HE_MU:
-		sinfo->rxrate.he_ru_alloc = rx_vect1->he.ru_size;
-	case FORMATMOD_HE_SU:
-	case FORMATMOD_HE_ER:
-		sinfo->rxrate.flags = RATE_INFO_FLAGS_HE_MCS;
-		sinfo->rxrate.mcs = rx_vect1->he.mcs;
-		sinfo->rxrate.nss = rx_vect1->he.nss;
-		sinfo->rxrate.he_gi = rx_vect1->he.gi_type;
-		sinfo->rxrate.he_dcm = rx_vect1->he.dcm;
-		break;
-#else
-	//kernel not support he
-	case FORMATMOD_HE_MU:
-	case FORMATMOD_HE_SU:
-	case FORMATMOD_HE_ER:
-		sinfo->rxrate.flags = RATE_INFO_FLAGS_VHT_MCS;
-			sinfo->rxrate.mcs = rx_vect1->he.mcs;
-		sinfo->rxrate.nss = rx_vect1->he.nss;
-#endif
-	default:
-		return -EINVAL;
-	}
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
-	sinfo->filled = (STATION_INFO_INACTIVE_TIME |
-					 STATION_INFO_RX_BYTES64 |
-					 STATION_INFO_TX_BYTES64 |
-					 STATION_INFO_RX_PACKETS |
-					 STATION_INFO_TX_PACKETS |
-					 STATION_INFO_SIGNAL |
-					 STATION_INFO_RX_BITRATE);
-#else
-	sinfo->filled = (BIT(NL80211_STA_INFO_INACTIVE_TIME) |
-					 BIT(NL80211_STA_INFO_RX_BYTES64)    |
-					 BIT(NL80211_STA_INFO_TX_BYTES64)    |
-					 BIT(NL80211_STA_INFO_RX_PACKETS)    |
-					 BIT(NL80211_STA_INFO_TX_PACKETS)    |
-					 BIT(NL80211_STA_INFO_SIGNAL)        |
-					 BIT(NL80211_STA_INFO_RX_BITRATE));
-#endif
-
-	rwnx_send_get_sta_txinfo_req(vif->rwnx_hw, sta->sta_idx, &cfm);
+	rwnx_send_get_sta_info_req(vif->rwnx_hw, sta->sta_idx, &cfm);
 	sinfo->tx_failed = cfm.txfailed;
 	rate_info = (union rwnx_rate_ctrl_info *)&cfm.rate_info;
 	switch (rate_info->formatModTx) {
@@ -4192,42 +4509,97 @@
 	sinfo->txrate.nss = 1;
 	sinfo->filled |= (BIT(NL80211_STA_INFO_TX_BITRATE) | BIT(NL80211_STA_INFO_TX_FAILED));
 
-	#if 0
-	// Mesh specific info
-	if (RWNX_VIF_TYPE(vif) == NL80211_IFTYPE_MESH_POINT) {
-		struct mesh_peer_info_cfm peer_info_cfm;
-		if (rwnx_send_mesh_peer_info_req(vif->rwnx_hw, vif, sta->sta_idx,
-										 &peer_info_cfm))
-			return -ENOMEM;
+	sinfo->inactive_time = jiffies_to_msecs(jiffies - vif->rwnx_hw->stats.last_tx);
+	sinfo->rx_bytes = vif->net_stats.rx_bytes;
+	sinfo->tx_bytes = vif->net_stats.tx_bytes;
+	sinfo->tx_packets = vif->net_stats.tx_packets;
+	sinfo->rx_packets = vif->net_stats.rx_packets;
+	sinfo->signal = (s8)cfm.rssi;
+	sinfo->rxrate.nss = 1;
 
-		peer_info_cfm.last_bcn_age = peer_info_cfm.last_bcn_age / 1000;
-		if (peer_info_cfm.last_bcn_age < sinfo->inactive_time)
-			sinfo->inactive_time = peer_info_cfm.last_bcn_age;
-
-		sinfo->llid = peer_info_cfm.local_link_id;
-		sinfo->plid = peer_info_cfm.peer_link_id;
-		sinfo->plink_state = peer_info_cfm.link_state;
-		sinfo->local_pm = peer_info_cfm.local_ps_mode;
-		sinfo->peer_pm = peer_info_cfm.peer_ps_mode;
-		sinfo->nonpeer_pm = peer_info_cfm.non_peer_ps_mode;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
-		sinfo->filled |= (STATION_INFO_LLID |
-						  STATION_INFO_PLID |
-						  STATION_INFO_PLINK_STATE |
-						  STATION_INFO_LOCAL_PM |
-						  STATION_INFO_PEER_PM |
-						  STATION_INFO_NONPEER_PM);
-#else
-		sinfo->filled |= (BIT(NL80211_STA_INFO_LLID) |
-						  BIT(NL80211_STA_INFO_PLID) |
-						  BIT(NL80211_STA_INFO_PLINK_STATE) |
-						  BIT(NL80211_STA_INFO_LOCAL_PM) |
-						  BIT(NL80211_STA_INFO_PEER_PM) |
-						  BIT(NL80211_STA_INFO_NONPEER_PM));
-#endif
+	#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)
+	switch (rx_vect1->ch_bw) {
+	case PHY_CHNL_BW_20:
+		sinfo->rxrate.bw = RATE_INFO_BW_20;
+		break;
+	case PHY_CHNL_BW_40:
+		sinfo->rxrate.bw = RATE_INFO_BW_40;
+		break;
+	case PHY_CHNL_BW_80:
+		sinfo->rxrate.bw = RATE_INFO_BW_80;
+		break;
+	case PHY_CHNL_BW_160:
+		sinfo->rxrate.bw = RATE_INFO_BW_160;
+		break;
+	default:
+	#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
+		sinfo->rxrate.bw = RATE_INFO_BW_HE_RU;
+	#else
+		sinfo->rxrate.bw = RATE_INFO_BW_20;
+	#endif
+		break;
 	}
 	#endif
+
+	switch (rx_vect1->format_mod) {
+	case FORMATMOD_NON_HT:
+	case FORMATMOD_NON_HT_DUP_OFDM:
+		sinfo->rxrate.flags = 0;
+		sinfo->rxrate.legacy = legrates_lut_rate[legrates_lut[rx_vect1->leg_rate]];
+		break;
+	case FORMATMOD_HT_MF:
+	case FORMATMOD_HT_GF:
+		sinfo->rxrate.flags = RATE_INFO_FLAGS_MCS;
+		if (rx_vect1->ht.short_gi)
+			sinfo->rxrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
+		sinfo->rxrate.mcs = rx_vect1->ht.mcs;
+		break;
+	case FORMATMOD_VHT:
+		sinfo->rxrate.flags = RATE_INFO_FLAGS_VHT_MCS;
+		if (rx_vect1->vht.short_gi)
+			sinfo->rxrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
+		sinfo->rxrate.mcs = rx_vect1->vht.mcs;
+		break;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
+	case FORMATMOD_HE_MU:
+		sinfo->rxrate.he_ru_alloc = rx_vect1->he.ru_size;
+	case FORMATMOD_HE_SU:
+	case FORMATMOD_HE_ER:
+		sinfo->rxrate.flags = RATE_INFO_FLAGS_HE_MCS;
+		sinfo->rxrate.mcs = rx_vect1->he.mcs;
+		sinfo->rxrate.he_gi = rx_vect1->he.gi_type;
+		sinfo->rxrate.he_dcm = rx_vect1->he.dcm;
+		break;
+#else
+	//kernel not support he
+	case FORMATMOD_HE_MU:
+	case FORMATMOD_HE_SU:
+	case FORMATMOD_HE_ER:
+		sinfo->rxrate.flags = RATE_INFO_FLAGS_VHT_MCS;
+		sinfo->rxrate.mcs = rx_vect1->he.mcs;
+		break;
+#endif
+	default:
+		return -EINVAL;
+	}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
+	sinfo->filled |= (STATION_INFO_INACTIVE_TIME |
+					 STATION_INFO_RX_BYTES64 |
+					 STATION_INFO_TX_BYTES64 |
+					 STATION_INFO_RX_PACKETS |
+					 STATION_INFO_TX_PACKETS |
+					 STATION_INFO_SIGNAL |
+					 STATION_INFO_RX_BITRATE);
+#else
+	sinfo->filled |= (BIT(NL80211_STA_INFO_INACTIVE_TIME) |
+					 BIT(NL80211_STA_INFO_RX_BYTES64)    |
+					 BIT(NL80211_STA_INFO_TX_BYTES64)    |
+					 BIT(NL80211_STA_INFO_RX_PACKETS)    |
+					 BIT(NL80211_STA_INFO_TX_PACKETS)    |
+					 BIT(NL80211_STA_INFO_SIGNAL)        |
+					 BIT(NL80211_STA_INFO_RX_BITRATE));
+#endif
 
 	return 0;
 }
@@ -4261,7 +4633,7 @@
 	if (sta)
 		return rwnx_fill_station_info(sta, vif, sinfo);
 
-	return -EINVAL;
+	return -ENOENT;
 }
 
 
@@ -4739,12 +5111,14 @@
 	.stop_ap = rwnx_cfg80211_stop_ap,
 	.set_monitor_channel = rwnx_cfg80211_set_monitor_channel,
 	.probe_client = rwnx_cfg80211_probe_client,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
 	.mgmt_frame_register = rwnx_cfg80211_mgmt_frame_register,
+#endif
 	.set_wiphy_params = rwnx_cfg80211_set_wiphy_params,
 	.set_txq_params = rwnx_cfg80211_set_txq_params,
 	.set_tx_power = rwnx_cfg80211_set_tx_power,
 //    .get_tx_power = rwnx_cfg80211_get_tx_power,
-//    .set_power_mgmt = rwnx_cfg80211_set_power_mgmt,
+	.set_power_mgmt = rwnx_cfg80211_set_power_mgmt,
 	.get_station = rwnx_cfg80211_get_station,
 	.remain_on_channel = rwnx_cfg80211_remain_on_channel,
 	.cancel_remain_on_channel = rwnx_cfg80211_cancel_remain_on_channel,
@@ -4763,7 +5137,7 @@
 	.tdls_mgmt = rwnx_cfg80211_tdls_mgmt,
 	.tdls_oper = rwnx_cfg80211_tdls_oper,
 	.change_bss = rwnx_cfg80211_change_bss,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0) || defined(CONFIG_WPA3_FOR_OLD_KERNEL)
 	.external_auth = rwnx_cfg80211_external_auth,
 #endif
 };
@@ -4837,1815 +5211,6 @@
 }
 
 extern int rwnx_init_aic(struct rwnx_hw *rwnx_hw);
-#ifdef AICWF_USB_SUPPORT
-u32 patch_tbl[18][2] = {
-	{0x0044, 0x00000002}, //hosttype
-	{0x0048, 0x00000060},
-	{0x004c, 0x00000046},
-	{0x0050, 0x00000000}, //ipc base
-	{0x0054, 0x001a0000}, //buf base
-	{0x0058, 0x001a0140}, //desc base
-	{0x005c, 0x00001020}, //desc size
-	{0x0060, 0x001a1020}, //pkt base
-	{0x0064, 0x000207e0}, //pkt size
-	{0x0068, 0x00000008},
-	{0x006c, 0x00000040},
-	{0x0070, 0x00000040},
-	{0x0074, 0x00000020},
-	{0x0078, 0x00000000},
-	{0x007c, 0x00000040},
-	{0x0080, 0x00190000},
-	{0x0084, 0x0000fc00},//63kB
-	{0x0088, 0x0019fc00}
-};
-#else
-#ifdef CONFIG_ROM_PATCH_EN
-u32 patch_tbl[][2] = {
-	{0x0044, 0x02000001},
-	{0x0058, 0x001a0000},
-	{0x005c, 0x00002020},
-	{0x0060, 0x001a2020}, //pkt base
-	{0x0064, 0x00021820}, //pkt size
-	{0x0080, 0x00190000},
-	{0x0084, 0x0000fc00},//63kB
-	{0x0088, 0x0019fc00}
-};
-#else
-u32 patch_tbl[][2] = {
-};
-#endif
-#endif
-
-u32 patch_tbl_1[14][2] = {
-	{0x171b24, 0x1c4021}, //61
-	{0x171c00, 0x1c40b1}, //116
-	{0x172124, 0x1c43ed}, //12*8 + 1720c4
-	{0x171bfc, 0x1c4849}, //115,  171a30 + 115 * 4
-	{0x171ee4, 0x1c4941}, //301
-	{0x171ee8, 0x1c4b09}, //302
-	{0x172134, 0x1c4d65}, //14/15/16/17/18 * 8 + 1720c4{0x172134, 0x1c4d65},
-	{0x17213c, 0x1c4d65},
-	{0x172144, 0x1c4d65},
-	{0x17214c, 0x1c4d65},
-	{0x172154, 0x1c4d65},
-	{0x1721d0, 0x1c53dd}, // 1721c4 + 1*8 + 4
-	{0x1721f0, 0x1c5415}, // 1721c4 + 5*8 + 4
-	{0x171eb0, 0x1c54a1}, // 288
-};
-
-u32 func_tbl[1721] = {
-	0x8cc88cc3,
-	0xd8084283,
-	0x1ac0d205,
-	0xbfcc283f,
-	0x20012000,
-	0x20014770,
-	0x20004770,
-	0xbf004770,
-	0x481d4a1c,
-	0xb538491d,
-	0x68056913,
-	0xf8b16914,
-	0xf8b100b0,
-	0xf5a310b2,
-	0xeb0363fa,
-	0x1b1b1345,
-	0x1a5b1a1b,
-	0xdb1a2b00,
-	0x681b4b15,
-	0x68dcb143,
-	0x1ae36913,
-	0x63faf5a3,
-	0x1a5b1a1b,
-	0xdb012b00,
-	0xbd382001,
-	0x681b4b0f,
-	0x3000f9b3,
-	0xda062b00,
-	0x1ae46913,
-	0x549cf504,
-	0x2c003408,
-	0x2000db01,
-	0x4909bd38,
-	0xf44f4809,
-	0xf66b7202,
-	0x2000fad9,
-	0xbf00bd38,
-	0x40501000,
-	0x40328040,
-	0x0017192c,
-	0x00178bf0,
-	0x00173250,
-	0x001c5a3c,
-	0x001c56b4,
-	0x4ff0e92d,
-	0x8c05461c,
-	0x3062f893,
-	0x9020f8d2,
-	0xf8d06987,
-	0xb089b01c,
-	0x02ad4616,
-	0x2012e9dd,
-	0xf8b4b9d3,
-	0xf1bcc068,
-	0xd0150f00,
-	0x6ab38b52,
-	0xf202fb0c,
-	0x07189205,
-	0xf20cfb05,
-	0xd0199206,
-	0xebb72300,
-	0xf44f0a09,
-	0x930776fa,
-	0xf5039b05,
-	0xe9c473c8,
-	0xe071a31f,
-	0xf0402800,
-	0x950680ba,
-	0x0a01f04f,
-	0x6ab28b50,
-	0xf000fb0a,
-	0x90050712,
-	0x8122f040,
-	0xf8df6af2,
-	0xf8dfc2bc,
-	0xf8dc82bc,
-	0x48983000,
-	0x1203f3c2,
-	0x037ff023,
-	0x2002f818,
-	0xf8cc4313,
-	0x6ab33000,
-	0xf3c34a93,
-	0xea4113c0,
-	0xf04f5103,
-	0x60014300,
-	0xf3bf6013,
-	0xbf008f4f,
-	0x00586813,
-	0x4b8dd5fc,
-	0xf9b16819,
-	0x29001000,
-	0x80aef2c0,
-	0x68124a88,
-	0xfa82fa1f,
-	0x07126ab2,
-	0x809df040,
-	0xf8df6af2,
-	0x4882c25c,
-	0x1000f8dc,
-	0x1203f3c2,
-	0x017ff021,
-	0x2002f818,
-	0xf8cc430a,
-	0x6ab22000,
-	0xf3c2497c,
-	0x051212c0,
-	0x0218f042,
-	0x4600f04f,
-	0x600e6002,
-	0x8f4ff3bf,
-	0x680abf00,
-	0xd5fc0056,
-	0xf9b3681b,
-	0x2b003000,
-	0x4a72db6e,
-	0x3062f894,
-	0x22006816,
-	0xebaab2b6,
-	0x92070a06,
-	0x0909ebb7,
-	0x0a0aeb19,
-	0xd0872b00,
-	0x79e5ea4f,
-	0x464b462a,
-	0x46594638,
-	0xfc50f679,
-	0x92021bba,
-	0xfb009a07,
-	0xeb6bf309,
-	0xfb050202,
-	0x92033301,
-	0x0105fba0,
-	0xe9dd4419,
-	0x42992302,
-	0x4290bf08,
-	0xe9cdbf38,
-	0x4b5e0102,
-	0x6702e9dd,
-	0x9b066819,
-	0x018918f6,
-	0x9905d430,
-	0xf5a11a71,
-	0x4b597ac8,
-	0x69194a59,
-	0x691b6812,
-	0x44511a89,
-	0xf5a31acb,
-	0x3b1453a5,
-	0x6a632b00,
-	0x1949bfb8,
-	0xd022428b,
-	0x6a1a4b52,
-	0xd04142a2,
-	0xf1044d51,
-	0xf8d50018,
-	0x479831e0,
-	0x30a8f8d5,
-	0xb0094620,
-	0x4ff0e8bd,
-	0xf8904718,
-	0xf1baa002,
-	0xd1010f00,
-	0xa003f890,
-	0xf00afb05,
-	0xe73d9006,
-	0x98054946,
-	0xeba11a09,
-	0x44b20a0a,
-	0xb009e7cb,
-	0x8ff0e8bd,
-	0x0058680b,
-	0x4941d48d,
-	0xf44f4841,
-	0xf66b72ae,
-	0x2200f98f,
-	0x3062f894,
-	0xf5aa9207,
-	0xf44f7afa,
-	0xe78776fa,
-	0x00516812,
-	0xaf4ef53f,
-	0x48384937,
-	0x72aef44f,
-	0xf97cf66b,
-	0x7afaf44f,
-	0xe7474b2c,
-	0x62614a2c,
-	0x01926812,
-	0x4a32d4b8,
-	0x68124d32,
-	0x1024f893,
-	0x4207f3c2,
-	0x2d23f885,
-	0x4a2fbb61,
-	0x6812492f,
-	0x20016809,
-	0xf885b2d2,
-	0xf8832d24,
-	0x780b0024,
-	0xd1054283,
-	0x4a2b492a,
-	0x6813600b,
-	0x60134303,
-	0x2d23f895,
-	0x3d24f895,
-	0xd21b429a,
-	0x681b4b17,
-	0x3000f9b3,
-	0xda0d2b00,
-	0x2d23f895,
-	0x3d24f895,
-	0xd307429a,
-	0x48214920,
-	0xf44f4d15,
-	0xf66b7221,
-	0xe787f96f,
-	0xe7854d12,
-	0xf44f2200,
-	0x920776fa,
-	0xe7354692,
-	0x4b124814,
-	0x1d23f895,
-	0x2d24f895,
-	0x6806681b,
-	0xb2f64816,
-	0x96000c1b,
-	0xff82f66a,
-	0xbf00e7d4,
-	0x40328160,
-	0x4032816c,
-	0x00173250,
-	0x4032004c,
-	0x40501000,
-	0x403280a4,
-	0x00178d3c,
-	0x00171a30,
-	0xfffffe70,
-	0x001c5a20,
-	0x001c56e0,
-	0x40328044,
-	0x001e4000,
-	0x40320090,
-	0x00173270,
-	0x40328070,
-	0x40328074,
-	0x001c5a58,
-	0x001c5718,
-	0x001c5704,
-	0x40328164,
-	0x00041830,
-	0x4ff0e92d,
-	0x9354f8df,
-	0xb020f8d9,
-	0xf44fb083,
-	0xf6692000,
-	0xf1bbfd9b,
-	0xf0000f00,
-	0x4cb480f1,
-	0xa33cf8df,
-	0x4fb37fa1,
-	0x8338f8df,
-	0x29004eb2,
-	0x80e6f000,
-	0xd50e0708,
-	0xf8db4bb0,
-	0x681b0070,
-	0x2010f8da,
-	0x4403685b,
-	0x2b001a9b,
-	0x80c7f2c0,
-	0x01f7f001,
-	0x074a77a1,
-	0x8095f100,
-	0xd515078b,
-	0x3004f8db,
-	0x0302f023,
-	0x3004f8cb,
-	0x301df899,
-	0xd1082b05,
-	0x48a34da2,
-	0x31d8f8d5,
-	0x23004798,
-	0xf8897fa1,
-	0xf001301d,
-	0x77a101fd,
-	0xd52d07cd,
-	0x01586833,
-	0x809ff140,
-	0x0c096831,
-	0x7f7cf411,
-	0x80a6f000,
-	0x4b983910,
-	0x01fff001,
-	0x1281eb01,
-	0x03c2eb03,
-	0x2021f893,
-	0xf0002a00,
-	0x4a93809d,
-	0x68137f99,
-	0xf9b34a92,
-	0xf44f3000,
-	0xfb0060a4,
-	0x2b002201,
-	0xf2c09200,
-	0x683b809c,
-	0x2fe0f413,
-	0x80a5f000,
-	0xf0017fa1,
-	0x77a101fe,
-	0xd59e068a,
-	0x49894e88,
-	0xf3c56835,
-	0x463a1741,
-	0xf66a2002,
-	0x2300ff23,
-	0x1547f3c5,
-	0x3078f88b,
-	0xf0402f00,
-	0x4e7b80af,
-	0x4d824a81,
-	0xf4236813,
-	0x60137300,
-	0x3004f8db,
-	0x21d8f8d6,
-	0x0301f023,
-	0x3004f8cb,
-	0x0028f10b,
-	0x682a4790,
-	0x2b027813,
-	0x8114f000,
-	0x680b4974,
-	0x0301f023,
-	0x7813600b,
-	0xd1122b01,
-	0x41fff501,
-	0x4a733134,
-	0x3010f8da,
-	0xf8b26808,
-	0xf8d610b2,
-	0xeb0321e0,
-	0x1a591340,
-	0x0018f10b,
-	0x682b4790,
-	0x2b02781b,
-	0x80b4f000,
-	0xf0017fa1,
-	0x77a101df,
-	0x4968e74f,
-	0x20024d5d,
-	0xfedcf66a,
-	0x68634966,
-	0xf022680a,
-	0x600a0204,
-	0xf4436822,
-	0x431a7300,
-	0xf8d5614a,
-	0x60631498,
-	0x0063f89b,
-	0x3494f8d5,
-	0x4798465a,
-	0x7fa1683b,
-	0x737cf023,
-	0xf8d8603b,
-	0xf0013000,
-	0xf44301fb,
-	0xf8c80380,
-	0x77a13000,
-	0x4856e742,
-	0xfe66f66a,
-	0x2200e782,
-	0x006cf89b,
-	0xf6584611,
-	0xb160fd17,
-	0xe72f7fa1,
-	0xf66a4850,
-	0xe775fe59,
-	0xf66a484f,
-	0xe771fe55,
-	0xe8bdb003,
-	0xf8da8ff0,
-	0x7fa13010,
-	0x3070f8cb,
-	0x4593e71e,
-	0xaf61f43f,
-	0x48494948,
-	0x22e6f240,
-	0xf818f66b,
-	0xf413683b,
-	0xf47f2fe0,
-	0x6832af5b,
-	0x49446833,
-	0xf3c30fd0,
-	0x46057380,
-	0x20024602,
-	0xf66a9301,
-	0x9b01fe81,
-	0x0205ea53,
-	0xf43f4628,
-	0x4d2baf49,
-	0x46199a00,
-	0x323cf8d5,
-	0x68334798,
-	0x4300f023,
-	0x68336033,
-	0x4380f023,
-	0xe7396033,
-	0x2010f8da,
-	0x529cf502,
-	0x32084631,
-	0xf8dae005,
-	0x1ad33010,
-	0xf2c02b00,
-	0x680b80b2,
-	0xd5f6071b,
-	0x8080f8df,
-	0x3000f8d8,
-	0x0308f023,
-	0x3000f8c8,
-	0x3000f8d8,
-	0xd51206de,
-	0x49274e15,
-	0xf66a2002,
-	0xf8d6fe4b,
-	0xf005323c,
-	0x08780101,
-	0x4798465a,
-	0x3000f8d8,
-	0x0310f023,
-	0x3000f8c8,
-	0x4b1fe722,
-	0x4e0b491f,
-	0x601d2501,
-	0xf66a2002,
-	0x4b1dfe35,
-	0xe717601d,
-	0x22304b1c,
-	0xf657601a,
-	0xe745fddb,
-	0x00178bb8,
-	0x40320074,
-	0x40320070,
-	0x00173244,
-	0x00171a30,
-	0x00178d48,
-	0x00175aa8,
-	0x00173250,
-	0x00177738,
-	0x4032008c,
-	0x001c57ec,
-	0x4033b390,
-	0x00173270,
-	0x0017192c,
-	0x001c578c,
-	0x4032004c,
-	0x001c5790,
-	0x001c57a8,
-	0x001c57bc,
-	0x001c5a70,
-	0x001c57d0,
-	0x001c57e0,
-	0x001c580c,
-	0x40328564,
-	0x001c5818,
-	0x40328568,
-	0x40320038,
-	0x00178d3c,
-	0x40501000,
-	0x4032006c,
-	0x8310f3ef,
-	0xd40307d8,
-	0x4b31b672,
-	0x601a2201,
-	0x4f314b30,
-	0x3201681a,
-	0x2100601a,
-	0x6039683a,
-	0x080ff002,
-	0x2010f8da,
-	0x46164631,
-	0xf247460a,
-	0xe0045030,
-	0x1010f8da,
-	0x42811b89,
-	0x6839d81b,
-	0xd1f70709,
-	0x49264825,
-	0xc000f8d0,
-	0x4616680f,
-	0x2010f8da,
-	0x0f00f1b8,
-	0x4a22d11a,
-	0x60112104,
-	0xb132681a,
-	0x3a01491a,
-	0x680b601a,
-	0xb103b90a,
-	0x682ab662,
-	0x491ce6b0,
-	0x20029200,
-	0xfdb0f66a,
-	0x9a004b14,
-	0x4919e7d3,
-	0xf66a2002,
-	0xe74bfda9,
-	0x070cea07,
-	0xd4e0077f,
-	0x1600e9cd,
-	0x46164680,
-	0x077ae001,
-	0x9a00d412,
-	0x7000f8d8,
-	0xf8da6812,
-	0xf2471010,
-	0x1b895030,
-	0xea074281,
-	0xd9f00702,
-	0x2002490b,
-	0xfd8cf66a,
-	0xe7ea4b02,
-	0xe7c49e01,
-	0x0017569c,
-	0x00172600,
-	0x40320038,
-	0x4032806c,
-	0x40328074,
-	0x40328070,
-	0x001c5828,
-	0x001c57f8,
-	0x001c5834,
-	0xf890b5f8,
-	0x2b003064,
-	0xf890d03a,
-	0x4604308a,
-	0xd1362b00,
-	0xf8944e32,
-	0x4a32306c,
-	0x6a674932,
-	0xeb036a09,
-	0xeb021383,
-	0x42a103c3,
-	0x443d685d,
-	0xf8d6d044,
-	0x462931e0,
-	0x0018f104,
-	0x46204798,
-	0xfafaf65e,
-	0x1080f8d4,
-	0x3214f8d6,
-	0x46204439,
-	0xf8d64798,
-	0x462a30a4,
-	0x46204639,
-	0xb9784798,
-	0x3078f894,
-	0x49216862,
-	0xb2db3301,
-	0x0201f042,
-	0xf8846809,
-	0x60623078,
-	0x4293780a,
-	0xd029d811,
-	0x3b01bdf8,
-	0x2b01b2db,
-	0x308af880,
-	0x2b02d912,
-	0xd1c04e13,
-	0x0063f890,
-	0x31c0f8d6,
-	0x47982100,
-	0xf8d6e7b9,
-	0xf8941164,
-	0x4622006c,
-	0x40f8e8bd,
-	0xbb84f658,
-	0x40f8e8bd,
-	0xbb3af65e,
-	0x62654b0c,
-	0x30b5f893,
-	0xd1ba2b00,
-	0x681b4b0a,
-	0x2b02781b,
-	0xe7b4d1af,
-	0xe8bd4620,
-	0xf66540f8,
-	0xbf00b8d1,
-	0x00171a30,
-	0x00175aa8,
-	0x00178d3c,
-	0x00173244,
-	0x0017192c,
-	0x00173270,
-	0x4c5cb538,
-	0x68224b5c,
-	0xf002495c,
-	0x701a020f,
-	0xf66a2002,
-	0x6823fcef,
-	0xd02e0718,
-	0x4a594958,
-	0x2000680b,
-	0x4300f023,
-	0x6020600b,
-	0x07596813,
-	0x4b55d5fc,
-	0x4a554952,
-	0x60182004,
-	0xf043680b,
-	0x600b4300,
-	0xf0436813,
-	0x60136300,
-	0x20024950,
-	0xfcd0f66a,
-	0x4a4f4b47,
-	0x494f4847,
-	0x601c2420,
-	0x24016813,
-	0x0310f043,
-	0x70446013,
-	0x781b680b,
-	0xd0382b03,
-	0xd0062b01,
-	0x4a44bd38,
-	0xf0236813,
-	0x60136300,
-	0x4a45e7e2,
-	0x035b6813,
-	0x4a44d5fc,
-	0x311c6911,
-	0x1acb6913,
-	0xdafb2b00,
-	0x681c4b41,
-	0x4b41b174,
-	0xf9b3681b,
-	0x2b003000,
-	0x4a3fdb4e,
-	0xf8b268e3,
-	0x4a3a10b2,
-	0x21041a5b,
-	0x60916313,
-	0x4a3c493b,
-	0xf443680b,
-	0x600b4300,
-	0xf4436d13,
-	0x65134300,
-	0xf0236dd3,
-	0xf0430303,
-	0xf0434300,
-	0x65d30301,
-	0x4b2fbd38,
-	0xb174681c,
-	0x681b4b2e,
-	0x3000f9b3,
-	0xdb152b00,
-	0x68e34a2c,
-	0x10b2f8b2,
-	0x1a5b4a27,
-	0x63132104,
-	0x4b2b6091,
-	0xf042681a,
-	0x601a0201,
-	0x075a681b,
-	0x4b28d5ae,
-	0x7200f44f,
-	0xbd38601a,
-	0x4d214b1e,
-	0x68e3691a,
-	0x10b2f8b5,
-	0x1a521a9a,
-	0xdae32a00,
-	0x48224921,
-	0x32dbf240,
-	0xfddef66a,
-	0xf8b568e3,
-	0xe7d910b2,
-	0x69124d17,
-	0xf8b568e3,
-	0x1a9a10b2,
-	0x2a001a52,
-	0x4918daab,
-	0xf2404818,
-	0xf66a32e9,
-	0x68e3fdcb,
-	0x10b2f8b5,
-	0xbf00e7a1,
-	0x40320038,
-	0x00172604,
-	0x001c5844,
-	0x40328074,
-	0x4032806c,
-	0x40328070,
-	0x40328048,
-	0x001c584c,
-	0x40580010,
-	0x00173274,
-	0x40041020,
-	0x40501000,
-	0x00178bf0,
-	0x00173250,
-	0x0017192c,
-	0x40240014,
-	0x40506000,
-	0x40044084,
-	0x40044100,
-	0x001c5a8c,
-	0x001c5854,
-	0xf890b380,
-	0xb36b3064,
-	0x47f0e92d,
-	0x4a7b4b7a,
-	0xf8df4e7b,
-	0xf8df920c,
-	0x4d7a8240,
-	0x460c487a,
-	0x2702497a,
-	0xc470f8d1,
-	0x7180f8c3,
-	0x49786892,
-	0xc044f8c2,
-	0x601f2201,
-	0xf8d97032,
-	0x680b2010,
-	0xf0236072,
-	0x600b0302,
-	0x1000f8d8,
-	0xc0b2f8b5,
-	0x68018f8b,
-	0xebb34463,
-	0xea4f1f41,
-	0xd3021a41,
-	0x87f0e8bd,
-	0x496b4770,
-	0xf66a4638,
-	0xf8d9fbdf,
-	0x68f32010,
-	0x2b001a9b,
-	0xf2804b67,
-	0xf89380a2,
-	0xf8932d23,
-	0x2a012d24,
-	0xf893d90a,
-	0x68612d23,
-	0xf0002a00,
-	0xf893809e,
-	0x3a012d23,
-	0xaa02fb01,
-	0x3d23f893,
-	0x4652495d,
-	0xf66a2002,
-	0xf8d8fbbf,
-	0xf8b53000,
-	0x8f9a00b2,
-	0x4b594955,
-	0xc178f8df,
-	0x680b691c,
-	0xebaa4402,
-	0xf0220202,
-	0xf0030703,
-	0x433b0303,
-	0x600b4f53,
-	0x60b2683b,
-	0x0301f043,
-	0xf8dc603b,
-	0xf8dc3000,
-	0xf3c31000,
-	0xf4210309,
-	0xf043717f,
-	0xf0210301,
-	0x430b0103,
-	0x3000f8cc,
-	0x4422683b,
-	0x60f2075b,
-	0x4b47d503,
-	0x7200f44f,
-	0x4a46601a,
-	0x68134c46,
-	0xf043493d,
-	0x60130308,
-	0xf0436823,
-	0x60230302,
-	0xf5a2680b,
-	0x3a1022fe,
-	0x0301f043,
-	0x6911600b,
-	0x7196f501,
-	0x1a5b6913,
-	0xdbfb2b00,
-	0x681b4b3b,
-	0x2b01781b,
-	0x493ad188,
-	0x6a4b4c3a,
-	0xf0236824,
-	0xf04303ff,
-	0x624b03df,
-	0xf4236a4b,
-	0xf443437f,
-	0x624b435f,
-	0x4b34b194,
-	0xf9b3681b,
-	0x2b003000,
-	0x68e2db31,
-	0x48316861,
-	0xfb04f66a,
-	0x10b2f8b5,
-	0x4a2568e3,
-	0x21041a5b,
-	0x60916313,
-	0x4a28492c,
-	0xf443680b,
-	0x600b4300,
-	0xf4436d13,
-	0x65134300,
-	0xf0236dd3,
-	0xf0430303,
-	0xf0434300,
-	0x65d30301,
-	0xf4436813,
-	0x60135380,
-	0x4922e74e,
-	0x3d23f893,
-	0x46524638,
-	0xfb2ef66a,
-	0xf893e76d,
-	0x3a012d24,
-	0xaa02fb01,
-	0x6913e760,
-	0x1ad368e2,
-	0x28001a18,
-	0x4919dac8,
-	0xf2404819,
-	0xf66a4231,
-	0xe7c0fca1,
-	0xe000e100,
-	0xe000ed00,
-	0x00173254,
-	0x0017192c,
-	0x40328040,
-	0x00171a30,
-	0x40320084,
-	0x001c589c,
-	0x001e4000,
-	0x001c58b8,
-	0x40501000,
-	0x40044084,
-	0x40044100,
-	0x40580010,
-	0x40580018,
-	0x00173274,
-	0x40506000,
-	0x00178bf0,
-	0x00173250,
-	0x001c58c8,
-	0x40240014,
-	0x001c58a4,
-	0x001c5aac,
-	0x001c5854,
-	0x00173244,
-	0x4ff0e92d,
-	0x4abd4bbc,
-	0xf852681b,
-	0xf9b34020,
-	0x4abb3000,
-	0x8b02ed2d,
-	0x02c0eb02,
-	0xee082b00,
-	0xb08b2a10,
-	0xea4f4683,
-	0xf2c005c0,
-	0x462082c4,
-	0xf8d0f669,
-	0xf8534bb2,
-	0xf1b9903b,
-	0xf0000f00,
-	0x230080e5,
-	0x3303e9cd,
-	0xf5059302,
-	0x9301629e,
-	0xf10b469a,
-	0x9208039e,
-	0x464c9305,
-	0xf898e079,
-	0x06df3004,
-	0x80d2f140,
-	0xf4226932,
-	0x9a010900,
-	0x9010f8c6,
-	0x065d3201,
-	0xf1009201,
-	0x4fa180e0,
-	0xf8d74620,
-	0x47983418,
-	0xf4036b63,
-	0xf5b31360,
-	0xbf081f20,
-	0xf3ef46a2,
-	0x07d98310,
-	0xb672d403,
-	0x22014b99,
-	0x4d99601a,
-	0xee18682b,
-	0x33010a10,
-	0xf669602b,
-	0x6b63f951,
-	0x1360f403,
-	0x1f60f5b3,
-	0x80a9f000,
-	0xb133682b,
-	0x3b014a8f,
-	0x602b6812,
-	0xb102b90b,
-	0xf8dfb662,
-	0xf8d88240,
-	0x78193000,
-	0xf419b391,
-	0xd1050300,
-	0x002ef9b4,
-	0x28008de2,
-	0x817ef2c0,
-	0x302cf894,
-	0x202af894,
-	0xf8b44884,
-	0xeb03c008,
-	0x441303c3,
-	0x530ef203,
-	0xf8502901,
-	0xeba22023,
-	0xf840020c,
-	0xf0002023,
-	0x6ce080d5,
-	0xf650b138,
-	0xf8d8fd4f,
-	0x781e3000,
-	0xf0002e01,
-	0x4621810f,
-	0xf66a4658,
-	0x6b63fc95,
-	0x1360f403,
-	0x1f60f5b3,
-	0x80eaf000,
-	0xf8534b6d,
-	0x2c00403b,
-	0xf8d4d05c,
-	0x6d268048,
-	0x0f00f1b8,
-	0xaf7ff47f,
-	0x8310f3ef,
-	0xd40307d9,
-	0x4b67b672,
-	0x601a2201,
-	0x682b4d66,
-	0x0a10ee18,
-	0x602b3301,
-	0xf8ecf669,
-	0xb133682b,
-	0x3b014a60,
-	0x602b6812,
-	0xb102b90b,
-	0x4f5cb662,
-	0x9178f8df,
-	0x817cf8df,
-	0xf6764620,
-	0xf8d7ff21,
-	0x46203418,
-	0xf8d74798,
-	0x220033ac,
-	0xf18bfa5f,
-	0x47984620,
-	0x302cf894,
-	0x102af894,
-	0xeb038922,
-	0x440b03c3,
-	0x530ef203,
-	0x1023f859,
-	0xf8491a8a,
-	0xf8d82023,
-	0x781b3000,
-	0xd0642b01,
-	0xd0532b02,
-	0xd1082b03,
-	0x3054f894,
-	0xf0002b01,
-	0x8de381db,
-	0xf10007d9,
-	0x4621814c,
-	0xf66a4658,
-	0x4b3ffc31,
-	0x403bf853,
-	0xd1a22c00,
-	0xecbdb00b,
-	0xe8bd8b02,
-	0x4b388ff0,
-	0xf9b3681b,
-	0x2b003000,
-	0x808bf2c0,
-	0xe9dd4650,
-	0xf6761201,
-	0x4640fee7,
-	0xfbeef659,
-	0xe9cd2300,
-	0x469a3301,
-	0xf8d8e742,
-	0xb1b220dc,
-	0x8ce38811,
-	0x1311eba3,
-	0x030bf3c3,
-	0x71fef240,
-	0xd816428b,
-	0xea4f2b3f,
-	0xd8121113,
-	0x0241eb02,
-	0x030ff003,
-	0xfa428852,
-	0x07d8f303,
-	0x9b02d509,
-	0x93023301,
-	0x0304f44f,
-	0x0903ea49,
-	0x9010f8c6,
-	0xf44fe6fb,
-	0xe7f72380,
-	0x3054f894,
-	0xf0002b01,
-	0x8de38117,
-	0xd5ae07da,
-	0xf6682080,
-	0xf8d8ff75,
-	0x781b3000,
-	0xf894e79c,
-	0x2b013054,
-	0x80f7f000,
-	0x07db8de3,
-	0x2080d59f,
-	0xff66f668,
-	0x3000f8d8,
-	0xe78b781b,
-	0x3054f894,
-	0xf47f2b01,
-	0xf890af26,
-	0xf0433f20,
-	0xf1060302,
-	0xf8800110,
-	0x22043f20,
-	0xf6512012,
-	0x8ba1fd2b,
-	0x46224809,
-	0xf91ef66a,
-	0xbf00e713,
-	0x00173250,
-	0x0003fc40,
-	0x00175980,
-	0x00171a30,
-	0x0017569c,
-	0x00172600,
-	0x00173278,
-	0x001c5904,
-	0x00173274,
-	0x2b009b03,
-	0x808bf040,
-	0xf48bfa5f,
-	0xf6682080,
-	0x4620ff2f,
-	0xfebef659,
-	0x93032300,
-	0xf1bae706,
-	0xf47f0f00,
-	0x49aaaf71,
-	0xf24048aa,
-	0xf66a42e7,
-	0xe769fac7,
-	0xe9d34ba8,
-	0x69130201,
-	0x46804798,
-	0xf43f2800,
-	0xf650aee8,
-	0x4603fd49,
-	0xf0002800,
-	0x22008096,
-	0x600249a1,
-	0x605a6808,
-	0x609a4440,
-	0xf3ef6018,
-	0x07d28210,
-	0x812ef140,
-	0x6829489c,
-	0x31016802,
-	0x0201f042,
-	0x60026029,
-	0x68124a98,
-	0xd4fb0790,
-	0x68124a97,
-	0xf0002a00,
-	0x4e968116,
-	0x2a006872,
-	0x8149f000,
-	0x4a926053,
-	0x681289b0,
-	0x4b906073,
-	0x30013201,
-	0x601a81b0,
-	0x68134a8c,
-	0x0301f023,
-	0x29006013,
-	0xaeadf43f,
-	0x39014b8b,
-	0x6029681b,
-	0xf47f2900,
-	0x2b00aea6,
-	0xaea3f43f,
-	0xe6a0b662,
-	0x49866d20,
-	0x64a36503,
-	0xf8946103,
-	0x63e3502b,
-	0xf3c29b05,
-	0x20a4020e,
-	0x0201f042,
-	0x3005fb10,
-	0x63a4f44f,
-	0x1305fb03,
-	0xeb0185e2,
-	0x4a7c00c0,
-	0x46219304,
-	0xffe2f668,
-	0xf4036b63,
-	0xf5b31360,
-	0xd0021f60,
-	0x93032301,
-	0x9804e686,
-	0xfd60f656,
-	0xf43f2800,
-	0x4d73af6f,
-	0x31fff895,
-	0xf47f2b00,
-	0x9b04af69,
-	0xf8cd9a08,
-	0xfa5fb00c,
-	0xf8ddf48b,
-	0x46d39014,
-	0x4698189e,
-	0xe00946ba,
-	0xff74f668,
-	0x3424f8da,
-	0x46214638,
-	0xf8954798,
-	0xb92331ff,
-	0x7039f858,
-	0x2f004630,
-	0x46dad1f0,
-	0xb00cf8dd,
-	0x2080e74a,
-	0xfe7af668,
-	0x4640e6af,
-	0xfb92f650,
-	0xf899e647,
-	0x22043f20,
-	0x0302f043,
-	0x0110f106,
-	0xf8892012,
-	0xf6513f20,
-	0x8de3fc43,
-	0xf53f07da,
-	0xe6fdaefc,
-	0xf6539306,
-	0x9b06f95d,
-	0x28009007,
-	0x80c0f000,
-	0x4b509309,
-	0x2a00681a,
-	0x80c2f000,
-	0xf6684618,
-	0x9b07ff39,
-	0xf04f2204,
-	0x21120e00,
-	0x70994684,
-	0xf883701a,
-	0xf883e001,
-	0xf106e003,
-	0x18980110,
-	0xc018f8cd,
-	0xfdc4f678,
-	0x8a194b42,
-	0xf5b19b09,
-	0xd85a7fc3,
-	0xb29b1c4b,
-	0x00ca9309,
-	0x4b3e9806,
-	0x68188181,
-	0x4b3d9907,
-	0x0c02eb00,
-	0x0e01f04f,
-	0x1004f8cc,
-	0x400b5881,
-	0x6380f043,
-	0x0308f043,
-	0xf8995083,
-	0x4a333782,
-	0x82119909,
-	0xf8894473,
-	0x9b063782,
-	0x22082100,
-	0xc004f8c3,
-	0xe00ef883,
-	0x609a6019,
-	0x8310f3ef,
-	0xd40307db,
-	0x4b25b672,
-	0xe000f8c3,
-	0x482a682b,
-	0x33019906,
-	0xf668602b,
-	0xf8d7fea5,
-	0x47983444,
-	0xb133682b,
-	0x3b014a1d,
-	0x602b6812,
-	0xb102b90b,
-	0x8de3b662,
-	0xf53f07d8,
-	0xe67cae7b,
-	0x69324b1f,
-	0x601a681b,
-	0xffaef64e,
-	0x4b1de61d,
-	0x421c681b,
-	0xad37f47f,
-	0x481b490a,
-	0x6293f44f,
-	0xf988f66a,
-	0x2200e52f,
-	0x46119309,
-	0x4a17e7a4,
-	0xbb6a6812,
-	0x4e094a15,
-	0xe6e86013,
-	0x4a08b672,
-	0xe6cd6016,
-	0x001c5ad0,
-	0x001c58ec,
-	0x001755b4,
-	0x001719e4,
-	0x40240060,
-	0x40240064,
-	0x0017559c,
-	0x0017569c,
-	0x00177738,
-	0x001c4001,
-	0x00175780,
-	0x0017469c,
-	0x001755d4,
-	0x31ff0000,
-	0x001746a4,
-	0x00180000,
-	0x0017a5a0,
-	0x001c58d4,
-	0x40240068,
-	0x9306480b,
-	0xff78f669,
-	0x9b066829,
-	0x4809e7ca,
-	0xf6699306,
-	0x6829ff71,
-	0xe6b09b06,
-	0xb00b4806,
-	0x8b02ecbd,
-	0x4ff0e8bd,
-	0xbcdef64f,
-	0xe7f64803,
-	0x001c591c,
-	0x001c5924,
-	0x001c5938,
-	0x001c594c,
-	0xf240b530,
-	0xb0834003,
-	0x4619460d,
-	0xf6682308,
-	0xe9d5f98d,
-	0x46043200,
-	0x3200e9c0,
-	0xe9cd4611,
-	0x48042200,
-	0xff48f669,
-	0xf6684620,
-	0x2000f9af,
-	0xbd30b003,
-	0x001c5970,
-	0x460cb570,
-	0x4619b084,
-	0x4012f240,
-	0xf6682308,
-	0x6822f971,
-	0x429a4b12,
-	0xd0104605,
-	0x686168a3,
-	0xe9c54810,
-	0xe9cd2300,
-	0x92003301,
-	0xf669461a,
-	0x4628ff27,
-	0xf98ef668,
-	0xb0042000,
-	0xe9d4bd70,
-	0x68116301,
-	0x404b4808,
-	0x404b4033,
-	0xe9d46013,
-	0x680a1300,
-	0x68a29200,
-	0xff12f669,
-	0xe7dd6822,
-	0x40344058,
-	0x001c59cc,
-	0x001c59b0,
-	0xbf002332,
-	0xf0133b01,
-	0xd1fa03ff,
-	0xbf004770,
-	0xbf0023c8,
-	0xf0133b01,
-	0xd1fa03ff,
-	0xbf004770,
-	0x49724a71,
-	0xf8df6813,
-	0xf023c208,
-	0xb5f00302,
-	0x680b6013,
-	0x4c6f4a6e,
-	0xf4234f6f,
-	0x600b6300,
-	0x496e6813,
-	0xf4232800,
-	0xbf1c7380,
-	0x468c4627,
-	0x20326013,
-	0x3801bf00,
-	0x00fff010,
-	0xf8dfd1fa,
-	0x4a63e18c,
-	0x3000f8de,
-	0xf4234e65,
-	0xf8ce5380,
-	0x68133000,
-	0x7300f423,
-	0xf8de6013,
-	0xf4433000,
-	0xf8ce6380,
-	0xf8de3000,
-	0xf4433000,
-	0xf8ce6300,
-	0x46723000,
-	0x1cc125ff,
-	0x4664b2c9,
-	0xf0236813,
-	0x430b03ff,
-	0xf8546013,
-	0x60333b04,
-	0xf4436813,
-	0x60137380,
-	0xbf00bf00,
-	0xbf00bf00,
-	0x049b6813,
-	0x3901d5fc,
-	0x428db2c9,
-	0x3004d1e8,
-	0x28803504,
-	0xf10cb2ed,
-	0xd1de0c10,
-	0x3000f8de,
-	0x6380f423,
-	0x3000f8ce,
-	0xbf0023c8,
-	0xf0133b01,
-	0xd1fa03ff,
-	0x493f4c3e,
-	0x48436822,
-	0x6200f422,
-	0x680a6022,
-	0x0280f042,
-	0x680a600a,
-	0x7280f442,
-	0x600a3f04,
-	0xf022680a,
-	0x431a021f,
-	0xf857600a,
-	0x60022f04,
-	0xf042680a,
-	0x600a0220,
-	0xbf00bf00,
-	0xbf00bf00,
-	0x0552680a,
-	0x3301d5fc,
-	0xd1e92b10,
-	0xf023680b,
-	0x600b0380,
-	0xbf0023c8,
-	0xf0133b01,
-	0xd1fa03ff,
-	0x4a2d4927,
-	0xf423680b,
-	0x600b7380,
-	0xf4436813,
-	0x60131300,
-	0xbf002332,
-	0xf0133b01,
-	0xd1fa03ff,
-	0x4a1f4b1e,
-	0x4d256819,
-	0x48264c25,
-	0xf4414e26,
-	0x60195180,
-	0xf4416811,
-	0x60117100,
-	0xf4416819,
-	0x60196100,
-	0x4b216811,
-	0x7180f441,
-	0x682a6011,
-	0xf442491f,
-	0x602a5280,
-	0xf4226822,
-	0x60222280,
-	0xf0226802,
-	0x60025200,
-	0x60306818,
-	0x45bbf5a5,
-	0x685c3d78,
-	0x689d602c,
-	0x4a16600d,
-	0x601568dd,
-	0x691d4815,
-	0xe9d36005,
-	0x4c145005,
-	0x602569db,
-	0x61136108,
-	0xbf00bdf0,
-	0x40580018,
-	0x40344060,
-	0x4034406c,
-	0x001718a4,
-	0x00171824,
-	0x00171624,
-	0x40344064,
-	0x40344070,
-	0x40344058,
-	0x40342014,
-	0x40342018,
-	0x4034201c,
-	0x4033c218,
-	0x001718e4,
-	0x4033c220,
-	0x4033c224,
-	0x4033c228,
-	0x4033c22c,
-	0x00171324,
-	0x6c616821,
-	0x6e6f615f,
-	0x656d6974,
-	0x69745f72,
-	0x705f656d,
-	0x28747361,
-	0x656d6974,
-	0x743e2d72,
-	0x20656d69,
-	0x3035202b,
-	0x00293030,
-	0x616d786e,
-	0x69745f63,
-	0x6f5f656d,
-	0x69615f6e,
-	0x61765f72,
-	0x5f64696c,
-	0x66746567,
-	0x21202928,
-	0x0030203d,
-	0x6d697464,
-	0x2c64253a,
-	0x252c6425,
-	0x64252c64,
-	0x00000a0d,
-	0x6f76282a,
-	0x6974616c,
-	0x7520656c,
-	0x38746e69,
-	0x2a20745f,
-	0x5f672629,
-	0x5f6e6f61,
-	0x72616873,
-	0x642e6465,
-	0x5f6d6974,
-	0x5f746e63,
-	0x736e6f61,
-	0x65726168,
-	0x203c2064,
-	0x6f76282a,
-	0x6974616c,
-	0x7520656c,
-	0x38746e69,
-	0x2a20745f,
-	0x5f672629,
-	0x5f6e6f61,
-	0x72616873,
-	0x642e6465,
-	0x5f6d6974,
-	0x69726570,
-	0x615f646f,
-	0x68736e6f,
-	0x64657261,
-	0x00000000,
-	0x00002c4c,
-	0x654b849b,
-	0x78646979,
-	0x766e6920,
-	0x64696c61,
-	0x3230252c,
-	0x00000a58,
-	0x6e49849b,
-	0x696c6176,
-	0x656b2064,
-	0x78646979,
-	0x0000000a,
-	0x6e49849b,
-	0x696c6176,
-	0x54532064,
-	0x64253a41,
-	0x0000000a,
-	0x5f666976,
-	0x20617473,
-	0x76203d3d,
-	0x00006669,
-	0x64253d54,
-	0x0d64252c,
-	0x0000000a,
-	0x3a4e4342,
-	0x0a0d6425,
-	0x00000000,
-	0x206e6362,
-	0x656e6f64,
-	0x6d697420,
-	0x74756f65,
-	0x00000a0d,
-	0x20736366,
-	0x0a0d6b6f,
-	0x00000000,
-	0x20736366,
-	0x20746f6e,
-	0x0a0d6b6f,
-	0x00000000,
-	0x656c6469,
-	0x72726520,
-	0x00000a0d,
-	0x656c6469,
-	0x746e6920,
-	0x72726520,
-	0x00000a0d,
-	0x2c642564,
-	0x00000000,
-	0x0a0d6564,
-	0x00000000,
-	0x6c616821,
-	0x63616d5f,
-	0x745f7768,
-	0x5f656d69,
-	0x74736170,
-	0x6d697428,
-	0x3e2d7265,
-	0x656d6974,
-	0x67202d20,
-	0x6669775f,
-	0x65735f69,
-	0x6e697474,
-	0x702e7367,
-	0x6f5f7277,
-	0x5f6e6570,
-	0x64737973,
-	0x79616c65,
-	0x00000029,
-	0x78253d74,
-	0x00000a0d,
-	0x20746f6e,
-	0x74736170,
-	0x6425203a,
-	0x0d64252c,
-	0x0000000a,
-	0x73736170,
-	0x6425203a,
-	0x0d64252c,
-	0x0000000a,
-	0x3a706c73,
-	0x252c7825,
-	0x000a0d78,
-	0x655f656b,
-	0x675f7476,
-	0x29287465,
-	0x65202620,
-	0x625f7476,
-	0x00007469,
-	0x65647874,
-	0x665f6373,
-	0x74737269,
-	0x203d2120,
-	0x4c4c554e,
-	0x00000000,
-	0x73212121,
-	0x20646e65,
-	0x206d6663,
-	0x78253a31,
-	0x0d78252c,
-	0x0000000a,
-	0x0d677562,
-	0x0000000a,
-	0x6f696473,
-	0x69617420,
-	0x7265206c,
-	0x0d726f72,
-	0x0000000a,
-	0x3a727265,
-	0x206f6e20,
-	0x2067736d,
-	0x21746b70,
-	0x00000a0d,
-	0x21727265,
-	0x74202121,
-	0x63206c78,
-	0x6e206d66,
-	0x7562206f,
-	0x72656666,
-	0x726f6620,
-	0x62737520,
-	0x00000a0d,
-	0x4244819d,
-	0x57203a47,
-	0x69746972,
-	0x6d20676e,
-	0x726f6d65,
-	0x69772079,
-	0x30206874,
-	0x38302578,
-	0x202f2078,
-	0x203a6425,
-	0x2578305b,
-	0x5d783830,
-	0x30203d20,
-	0x38302578,
-	0x202f2078,
-	0x000a6425,
-	0x6b73616d,
-	0x69727720,
-	0x253a6574,
-	0x78252c78,
-	0x2c78252c,
-	0x0a0d7825,
-	0x00000000,
-	0x4244819d,
-	0x57203a47,
-	0x69746972,
-	0x6d20676e,
-	0x726f6d65,
-	0x69772079,
-	0x6d206874,
-	0x3a6b7361,
-	0x30257830,
-	0x202c7838,
-	0x61746164,
-	0x2578303a,
-	0x20783830,
-	0x6425202f,
-	0x305b203a,
-	0x38302578,
-	0x3d205d78,
-	0x25783020,
-	0x20783830,
-	0x6425202f,
-	0x0000000a,
-	0x5f6c6168,
-	0x6863616d,
-	0x78725f77,
-	0x6e63625f,
-	0x7275645f,
-	0x6f697461,
-	0x0000006e,
-	0x5f6c6168,
-	0x6863616d,
-	0x6c735f77,
-	0x5f706565,
-	0x63656863,
-	0x61705f6b,
-	0x00686374,
-	0x745f6d6d,
-	0x5f747462,
-	0x706d6f63,
-	0x5f657475,
-	0x63746170,
-	0x00000068,
-	0x735f6d6d,
-	0x7065656c,
-	0x6f666e69,
-	0x5f78725f,
-	0x5f747665,
-	0x63746170,
-	0x00000068,
-	0x786e7772,
-	0x656c735f,
-	0x635f7065,
-	0x61676b6c,
-	0x635f6574,
-	0x69666e6f,
-	0x61705f67,
-	0x00686374,
-	0x786e7772,
-	0x656c735f,
-	0x645f7065,
-	0x73706565,
-	0x7065656c,
-	0x6e6f635f,
-	0x5f676966,
-	0x63746170,
-	0x00000068,
-	0x5f6c7874,
-	0x5f6d6663,
-	0x5f747665,
-	0x63746170,
-	0x00000068,
-
-};
-
-u32 syscfg_tbl[][2] = {
-	//{0x40500014, 0x00000102}, // 1)
-	//{0x40500018, 0x0000010D}, // 2)
-	//{0x40500004, 0x00000010}, // 3) the order should not be changed
-	//{0x40503004, 0x11100000},//fix gpio
-	#ifdef CONFIG_PMIC_SETTING
-	#if 1 // U02 bootrom only
-	{0x40040000, 0x00001AC8}, // 1) fix panic
-	{0x40040084, 0x00011580},
-	{0x40040080, 0x00000001},
-	{0x40100058, 0x00000000},
-	#endif
-	{0x50000000, 0x03220204}, // 2) pmic interface init
-	{0x50019150, 0x00000002}, // 3) for 26m xtal, set div1
-	{0x50017008, 0x00000000}, // 4) stop wdg
-	#endif /* CONFIG_PMIC_SETTING */
-};
-
-u32 syscfg_tbl_masked[][3] = {
-	{0x40506024, 0x000000FF, 0x000000DF}, // for clk gate lp_level
-	#ifdef CONFIG_PMIC_SETTING
-	//{0x50017008, 0x00000002, 0x00000000}, // stop wdg
-	#endif /* CONFIG_PMIC_SETTING */
-};
-
-u32 rf_tbl_masked[][3] = {
-	{0x40344058, 0x00800000, 0x00000000},// pll trx
-};
 
 #if IS_ENABLED(CONFIG_SUNXI_ADDR_MGT)
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
@@ -6663,6 +5228,7 @@
  *
  */
 extern int aicwf_vendor_init(struct wiphy *wiphy);
+extern txpwr_idx_conf_t nvram_txpwr_idx;
 
 int rwnx_cfg80211_init(struct rwnx_plat *rwnx_plat, void **platform_data)
 {
@@ -6675,8 +5241,10 @@
 	u8 dflt_mac[ETH_ALEN] = { 0x88, 0x00, 0x33, 0x77, 0x10, 0x99};
 	u8 addr_str[20];
 	struct mm_set_rf_calib_cfm cfm;
+	struct mm_get_fw_version_cfm fw_version;
 	u8_l mac_addr_efuse[ETH_ALEN];
 	struct aicbsp_feature_t feature;
+	struct mm_set_stack_start_cfm set_start_cfm;
 	(void)addr_str;
 
 	RWNX_DBG(RWNX_FN_ENTRY_STR);
@@ -6707,8 +5275,8 @@
 #endif
 	rwnx_hw->mod_params = &rwnx_mod_params;
 	rwnx_hw->tcp_pacing_shift = 7;
-	rwnx_hw->band_5g_support = feature.band_5g_support;
 
+	aicwf_wakeup_lock_init(rwnx_hw);
 	rwnx_init_aic(rwnx_hw);
 	/* set device pointer for wiphy */
 	set_wiphy_dev(wiphy, rwnx_hw->dev);
@@ -6753,7 +5321,35 @@
 	/* Cookie can not be 0 */
 	rwnx_hw->roc_cookie_cnt = 1;
 
+	INIT_LIST_HEAD(&rwnx_hw->vifs);
+	INIT_LIST_HEAD(&rwnx_hw->defrag_list);
+	spin_lock_init(&rwnx_hw->defrag_lock);
+	mutex_init(&rwnx_hw->mutex);
+	mutex_init(&rwnx_hw->dbgdump_elem.mutex);
+	spin_lock_init(&rwnx_hw->tx_lock);
+	spin_lock_init(&rwnx_hw->cb_lock);
+
+	INIT_WORK(&rwnx_hw->apmStalossWork, apm_staloss_work_process);
+	rwnx_hw->apmStaloss_wq = create_singlethread_workqueue("apmStaloss_wq");
+	if (!rwnx_hw->apmStaloss_wq) {
+		txrx_err("insufficient memory to create apmStaloss workqueue.\n");
+		goto err_cache;
+	}
+
 	wiphy->mgmt_stypes = rwnx_default_mgmt_stypes;
+
+	rwnx_hw->fwlog_en = feature.fwlog_en;
+	ret = rwnx_send_set_stack_start_req(rwnx_hw, 1, feature.hwinfo < 0, feature.hwinfo, feature.fwlog_en, &set_start_cfm);
+	if (ret)
+		goto err_lmac_reqs;
+
+	printk("is 5g support = %d, vendor_info = 0x%02X\n", set_start_cfm.is_5g_support, set_start_cfm.vendor_info);
+	rwnx_hw->band_5g_support = set_start_cfm.is_5g_support;
+	rwnx_hw->vendor_info = (feature.hwinfo < 0) ? set_start_cfm.vendor_info : feature.hwinfo;
+
+	ret = rwnx_send_get_fw_version_req(rwnx_hw, &fw_version);
+	memcpy(wiphy->fw_version, fw_version.fw_version, fw_version.fw_version_len > 32 ? 32 : fw_version.fw_version_len);
+	printk("Firmware Version: %s", fw_version.fw_version);
 
 	wiphy->bands[NL80211_BAND_2GHZ] = &rwnx_band_2GHz;
 	if (rwnx_hw->band_5g_support)
@@ -6796,7 +5392,7 @@
 		#endif
 		0;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0) || defined(CONFIG_WPA3_FOR_OLD_KERNEL)
 	wiphy->features |= NL80211_FEATURE_SAE;
 #endif
 
@@ -6824,13 +5420,6 @@
 
 	tasklet_init(&rwnx_hw->task, rwnx_task, (unsigned long)rwnx_hw);
 
-	INIT_LIST_HEAD(&rwnx_hw->vifs);
-
-	mutex_init(&rwnx_hw->mutex);
-	mutex_init(&rwnx_hw->dbgdump_elem.mutex);
-	spin_lock_init(&rwnx_hw->tx_lock);
-	spin_lock_init(&rwnx_hw->cb_lock);
-
 	//system_config(rwnx_hw);
 
 	ret = rwnx_platform_on(rwnx_hw, NULL);
@@ -6845,8 +5434,15 @@
 
 	//rf_config(rwnx_hw);
 #endif
-
 	ret = rwnx_send_rf_calib_req(rwnx_hw, &cfm);
+	if (ret)
+		goto err_lmac_reqs;
+
+	ret = rwnx_send_txpwr_idx_req(rwnx_hw);
+	if (ret)
+		goto err_lmac_reqs;
+
+	ret = rwnx_send_txpwr_ofst_req(rwnx_hw);
 	if (ret)
 		goto err_lmac_reqs;
 #if 0
@@ -6922,14 +5518,13 @@
 	rwnx_send_me_chan_config_req(rwnx_hw);
 	*platform_data = rwnx_hw;
 
-#if 0
+#ifdef CONFIG_DEBUG_FS
 	ret = rwnx_dbgfs_register(rwnx_hw, "rwnx");
 	if (ret) {
 		wiphy_err(wiphy, "Failed to register debugfs entries");
 		goto err_debugfs;
 	}
 #endif
-
 	rtnl_lock();
 
 	/* Add an initial station interface */
@@ -6949,18 +5544,20 @@
 	return 0;
 
 err_add_interface:
-//err_debugfs:
-
+#ifdef CONFIG_DEBUG_FS
+	rwnx_dbgfs_unregister(rwnx_hw);
+err_debugfs:
+#endif
 	wiphy_unregister(rwnx_hw->wiphy);
 err_register_wiphy:
 err_lmac_reqs:
 	printk("err_lmac_reqs\n");
-	//rwnx_fw_trace_dump(rwnx_hw);
 	rwnx_platform_off(rwnx_hw, NULL);
 err_platon:
 //err_config:
 	kmem_cache_destroy(rwnx_hw->sw_txhdr_cache);
 err_cache:
+	aicwf_wakeup_lock_deinit(rwnx_hw);
 	wiphy_free(wiphy);
 err_out:
 	return ret;
@@ -6971,15 +5568,42 @@
  */
 void rwnx_cfg80211_deinit(struct rwnx_hw *rwnx_hw)
 {
+	struct mm_set_stack_start_cfm set_start_cfm;
+	struct defrag_ctrl_info *defrag_ctrl = NULL;
+
 	RWNX_DBG(RWNX_FN_ENTRY_STR);
 
+#ifdef AICWF_USB_SUPPORT
+	if (rwnx_hw->usbdev->bus_if->state != BUS_DOWN_ST)
+#else
+	if (rwnx_hw->sdiodev->bus_if->state != BUS_DOWN_ST)
+#endif
+		rwnx_send_set_stack_start_req(rwnx_hw, 0, 0, 0, 0, &set_start_cfm);
+
+	rwnx_hw->fwlog_en = 0;
+	spin_lock_bh(&rwnx_hw->defrag_lock);
+	if (!list_empty(&rwnx_hw->defrag_list)) {
+		list_for_each_entry(defrag_ctrl, &rwnx_hw->defrag_list, list) {
+			list_del_init(&defrag_ctrl->list);
+			if (timer_pending(&defrag_ctrl->defrag_timer))
+				del_timer_sync(&defrag_ctrl->defrag_timer);
+			dev_kfree_skb(defrag_ctrl->skb);
+			kfree(defrag_ctrl);
+		}
+	}
+	spin_unlock_bh(&rwnx_hw->defrag_lock);
+#ifdef CONFIG_DEBUG_FS
 	rwnx_dbgfs_unregister(rwnx_hw);
+#endif
+	flush_workqueue(rwnx_hw->apmStaloss_wq);
+	destroy_workqueue(rwnx_hw->apmStaloss_wq);
 
 	rwnx_wdev_unregister(rwnx_hw);
 	wiphy_unregister(rwnx_hw->wiphy);
 	rwnx_radar_detection_deinit(&rwnx_hw->radar);
 	rwnx_platform_off(rwnx_hw, NULL);
 	kmem_cache_destroy(rwnx_hw->sw_txhdr_cache);
+	aicwf_wakeup_lock_deinit(rwnx_hw);
 	wiphy_free(rwnx_hw->wiphy);
 }
 
@@ -6999,11 +5623,19 @@
 //static DECLARE_WORK(aicsmac_driver_work, aicsmac_driver_register);
 
 struct completion hostif_register_done;
+static int rwnx_driver_err = -1;
 
 #define REGISTRATION_TIMEOUT                     9000
 
 void aicwf_hostif_ready(void)
 {
+	rwnx_driver_err = 0;
+	complete(&hostif_register_done);
+}
+
+void aicwf_hostif_fail(void)
+{
+	rwnx_driver_err = 1;
 	complete(&hostif_register_done);
 }
 
@@ -7012,19 +5644,23 @@
 	RWNX_DBG(RWNX_FN_ENTRY_STR);
 	rwnx_print_version();
 
-	init_completion(&hostif_register_done);
+	if (aicbsp_set_subsys(AIC_WIFI, AIC_PWR_ON) < 0) {
+		printk("%s, set power on fail!\n", __func__);
+		return -ENODEV;
+	}
 
-	aicbsp_set_subsys(AIC_WIFI, AIC_PWR_ON);
+	init_completion(&hostif_register_done);
 	aicsmac_driver_register();
 
-	if ((wait_for_completion_timeout(&hostif_register_done, msecs_to_jiffies(REGISTRATION_TIMEOUT)) == 0)) {
+	if ((wait_for_completion_timeout(&hostif_register_done, msecs_to_jiffies(REGISTRATION_TIMEOUT)) == 0) || rwnx_driver_err) {
 		printk("register_driver timeout or error\n");
 #ifdef AICWF_SDIO_SUPPORT
 		aicwf_sdio_exit();
 #endif /* AICWF_SDIO_SUPPORT */
 #ifdef AICWF_USB_SUPPORT
-	   aicwf_usb_exit();
+		aicwf_usb_exit();
 #endif /*AICWF_USB_SUPPORT */
+		aicbsp_set_subsys(AIC_WIFI, AIC_PWR_OFF);
 		return -ENODEV;
 	}
 

--
Gitblit v1.6.2