[Feature][T106][task-view-74]Based on baseline p56u06 first and fifth patch WiFi part and patch caused mac failure and gpio setting input low failure modification

	Only Configure: Yes
	Affected branch: master
	Affected module: wifi
	Is it affected on both ZXIC and MTK:only ZXIC
	Self-test: Yes
	Doc Update:No

Change-Id: I06a6b61b6e229f4f9f4e949e98c0454110be810c
(cherry picked from commit c08ce0473788b867365d436b4275e58672c7e43a)
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/pwr_ctrl.c b/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/pwr_ctrl.c
index a5d27f4..a57002a 100755
--- a/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/pwr_ctrl.c
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/pwr_ctrl.c
@@ -36,6 +36,7 @@
 
 static unsigned int pwr_buck3v3_init_flag	= 0;
 static unsigned int pwr_buck3v3_status  		= 0;
+extern void sd_io_config(u32 sd_index,bool active_flag);
 
 void pwr_buck3v3_init(void)
 {
@@ -264,6 +265,8 @@
 	int ret = 0;
 	if(bval)	
 	{	
+		if (get_wifi_enable() == 1)
+			sd_io_config(0, 1);
 #ifdef CONFIG_AIC8800_MIFI_EN
 	   ret=gpio_request(ZX29_GPIO_85,"aic_mifi_en");
 	   if(ret){
@@ -317,6 +320,8 @@
 	}	
 	else	
 	{	
+		if (get_wifi_enable() == 1)
+			sd_io_config(0, 0);
 #ifdef CONFIG_AIC8800_MIFI_EN
 		gpio_direction_output(ZX29_GPIO_85, 0);	
 		gpio_direction_output(ZX29_GPIO_130, 0);
@@ -341,6 +346,8 @@
 	int ret = 0;
 	if(bval)	
 	{	
+		if (get_wifi_enable() == 1)
+			sd_io_config(0, 0);
 #ifdef CONFIG_AIC8800_MIFI_EN
 	   gpio_direction_output(ZX29_GPIO_85, 0);
 	   gpio_direction_output(ZX29_GPIO_130, 0);
@@ -357,7 +364,9 @@
 	   printk("qqq aic dis succ.\n");
 	}	
 	else	
-	{	
+	{		
+		if (get_wifi_enable() == 1)
+			sd_io_config(0, 1);
 #ifdef CONFIG_AIC8800_MIFI_EN
 		gpio_direction_output(ZX29_GPIO_85, 1);
 		gpio_direction_output(ZX29_GPIO_130, 1);
@@ -381,6 +390,8 @@
 	int ret = 0;
 	if(bval)	
 	{	
+		if (get_wifi_enable() == 1)
+			sd_io_config(0, 1);
 #ifdef CONFIG_AIC8800_MIFI_EN
 	   gpio_direction_output(ZX29_GPIO_85, 1);
 	   gpio_direction_output(ZX29_GPIO_130, 1);
@@ -398,6 +409,8 @@
 	}	
 	else	
 	{	
+		if (get_wifi_enable() == 1)
+			sd_io_config(0, 0);
 #ifdef CONFIG_AIC8800_MIFI_EN
 	   gpio_direction_output(ZX29_GPIO_85, 0);
 	   gpio_direction_output(ZX29_GPIO_130, 0);
diff --git a/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc-pltfm.c b/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc-pltfm.c
index 1100d88..76b9bfb 100755
--- a/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc-pltfm.c
+++ b/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc-pltfm.c
@@ -40,15 +40,36 @@
 #endif
 #include <mach/iomap.h>
 #include <mach/gpio.h>
-//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
-static struct dw_mci *dw_mci_host_ptr[2];
-volatile u8 mmc0_data1_flag = 0xff;
-//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
-
 //youchen@2024-06-20 add for lynq nv config begin
 #include <lynq/lynq_ap_nv_cfg.h>
 //youchen@2024-06-20 add for lynq nv config end
 
+//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
+struct dw_mci *dw_mci_host_ptr[2];
+volatile u8 mmc0_data1_flag = 0xff;
+//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
+#define CONFIG_GPIO_FUNC(pin, config, pd_pu) \
+do { \
+    rc = zx29_gpio_config(pin, config); \
+    if (rc) { \
+        printk("mmc gpio" #pin " config err !rc = %d\n",  rc); \
+    } \    
+    zx29_gpio_pd_pu_set(pin, pd_pu); \
+} while (0)
+
+
+#define CONFIG_GPIO_GPIO(pin, config, pd_pu) \
+	do { \
+		rc = zx29_gpio_config(pin, config); \
+		if (rc) { \
+			printk("mmc gpio" #pin " config err !rc = %d\n",  rc); \
+		} \
+		zx29_gpio_set_direction(pin, GPIO_IN);\
+		zx29_gpio_pd_pu_set(pin, pd_pu); \
+	} while (0)
+
+/* Ended by AICoder, pid:u6c95fe12ad564314e1a081cb0286316caa77330 */
+
 static void dw_mci_rockchip_prepare_command(struct dw_mci *host, u32 *cmdr)
 {
 	*cmdr |= SDMMC_CMD_USE_HOLD_REG;
@@ -137,162 +158,71 @@
 DEVICE_ATTR(dw_regvalue, S_IRUGO | S_IWUSR, dw_regvalue_show, dw_regvalue_store);
 
 //zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
-int sd_io_config(u32 sd_index, bool active_flag)
+void sd_io_config(u32 sd_index,bool active_flag)
 {
 	int rc = 0;
+
 	struct dw_mci_board *brd;
-	if(dw_mci_host_ptr[sd_index] == NULL){
-		printk("%s mmc%d not used or failed\n",__func__,sd_index);
-		return 0;
-	}
-	brd = dw_mci_host_ptr[sd_index]->pdata;
-	if (active_flag)
-	{
-		if (sd_index == 0)
-		{
-			if (dw_mci_host_ptr[sd_index]->quirks & DW_MCI_QUIRK_SDIO)
-			{
-				if (mmc0_data1_flag != 0x1)
-				{
-					irq_set_irq_wake(brd->data1_irq, 1);
-					mmc0_data1_flag = 0x1;
-				}
+
+
+	if((dw_mci_host_ptr[sd_index] != NULL)&&(sd_index == 0)){
+		brd= dw_mci_host_ptr[sd_index]->pdata;
+
+		if (dw_mci_host_ptr[sd_index]->quirks & DW_MCI_QUIRK_SDIO) {
+			
+			if(mmc0_data1_flag != active_flag){
+				
+				irq_set_irq_wake(brd->data1_irq,active_flag);
+				mmc0_data1_flag = active_flag;
 			}
-			rc = zx29_gpio_config(ZX29_GPIO_66, GPIO66_EMMC_CLK);
-			if (rc)
-				printk("%s gpio66 config err !rc = %d\n", __func__, rc);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_66, IO_CFG_PULL_DOWN);
-			rc = zx29_gpio_config(ZX29_GPIO_67, GPIO67_EMMC_CMD);
-			if (rc)
-				printk("%s gpio67 config err !rc = %d\n", __func__, rc);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_67, IO_CFG_PULL_UP);
-			rc = zx29_gpio_config(ZX29_GPIO_68, GPIO68_EMMC_DATA0);
-			if (rc)
-				printk("%s gpio68 config err !rc = %d\n", __func__, rc);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_68, IO_CFG_PULL_UP);
-			rc = zx29_gpio_config(ZX29_GPIO_69, GPIO69_EMMC_DATA1);
-			if (rc)
-				printk("%s gpio69 config err !rc = %d\n", __func__, rc);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_69, IO_CFG_PULL_UP);
-			rc = zx29_gpio_config(ZX29_GPIO_70, GPIO70_EMMC_DATA2);
-			if (rc)
-				printk("%s gpio70 config err !rc = %d\n", __func__, rc);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_70, IO_CFG_PULL_UP);
-			rc = zx29_gpio_config(ZX29_GPIO_71, GPIO71_EMMC_DATA3);
-			if (rc)
-				printk("%s gpio71 config err !rc = %d\n", __func__, rc);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_71, IO_CFG_PULL_UP);
 		}
-		else if (sd_index == 1)
-		{
-			rc = zx29_gpio_config(ZX29_GPIO_72, GPIO72_SD1_HOST_SDCLK);
-			if (rc)
-				printk("%s gpio72 config err !rc = %d\n", __func__, rc);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_72, IO_CFG_PULL_DISABLE);
-			rc = zx29_gpio_config(ZX29_GPIO_73, GPIO73_SD1_CMD);
-			if (rc)
-				printk("%s gpio73 config err !rc = %d\n", __func__, rc);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_73, IO_CFG_PULL_UP);
-			rc = zx29_gpio_config(ZX29_GPIO_74, GPIO74_SD1_DATA0);
-			if (rc)
-				printk("%s gpio74 config err !rc = %d\n", __func__, rc);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_74, IO_CFG_PULL_UP);
-			rc = zx29_gpio_config(ZX29_GPIO_75, GPIO75_SD1_DATA1);
-			if (rc)
-				printk("%s gpio75 config err !rc = %d\n", __func__, rc);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_75, IO_CFG_PULL_UP);
-			rc = zx29_gpio_config(ZX29_GPIO_76, GPIO76_SD1_DATA2);
-			if (rc)
-				printk("%s gpio76 config err !rc = %d\n", __func__, rc);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_76, IO_CFG_PULL_UP);
-			rc = zx29_gpio_config(ZX29_GPIO_77, GPIO77_SD1_DATA3);
-			if (rc)
-				printk("%s gpio77 config err !rc = %d\n", __func__, rc);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_77, IO_CFG_PULL_UP);
+	}
+	printk("%s, set active_flag=%d\n", __func__,active_flag);
+	
+	if(active_flag){
+		if(sd_index == 0) {
+
+			CONFIG_GPIO_FUNC(ZX29_GPIO_66, GPIO66_EMMC_CLK, IO_CFG_PULL_DOWN);			
+			CONFIG_GPIO_FUNC(ZX29_GPIO_67, GPIO67_EMMC_CMD, IO_CFG_PULL_UP);		
+			CONFIG_GPIO_FUNC(ZX29_GPIO_68, GPIO68_EMMC_DATA0, IO_CFG_PULL_UP);			
+			CONFIG_GPIO_FUNC(ZX29_GPIO_69, GPIO69_EMMC_DATA1, IO_CFG_PULL_UP);			
+			CONFIG_GPIO_FUNC(ZX29_GPIO_70, GPIO70_EMMC_DATA2, IO_CFG_PULL_UP); 					
+			CONFIG_GPIO_FUNC(ZX29_GPIO_71, GPIO71_EMMC_DATA3, IO_CFG_PULL_UP); 
+		}
+		else if(sd_index == 1) {
+			CONFIG_GPIO_FUNC(ZX29_GPIO_72, GPIO72_SD1_HOST_SDCLK, IO_CFG_PULL_DOWN);			
+			CONFIG_GPIO_FUNC(ZX29_GPIO_73, GPIO73_SD1_CMD, IO_CFG_PULL_UP);			
+			CONFIG_GPIO_FUNC(ZX29_GPIO_74, GPIO74_SD1_DATA0, IO_CFG_PULL_UP);			
+			CONFIG_GPIO_FUNC(ZX29_GPIO_75, GPIO75_SD1_DATA1, IO_CFG_PULL_UP);
+			CONFIG_GPIO_FUNC(ZX29_GPIO_76, GPIO76_SD1_DATA2, IO_CFG_PULL_UP);		
+			CONFIG_GPIO_FUNC(ZX29_GPIO_77, GPIO77_SD1_DATA3, IO_CFG_PULL_UP);			
 		}
 		else
-			printk("%s index error %d\n", __func__, sd_index);
+			printk("%s index error %d\n",__func__,sd_index);
 	}
-	else
-	{
-		if (sd_index == 0)
-		{
-			if (dw_mci_host_ptr[sd_index]->quirks & DW_MCI_QUIRK_SDIO)
-			{
-				if (mmc0_data1_flag != 0x0)
-				{
-					irq_set_irq_wake(brd->data1_irq, 0);
-					mmc0_data1_flag = 0x0;
-				}
-			}
-			rc = zx29_gpio_config(ZX29_GPIO_66, GPIO66_GPIO66);
-			if (rc)
-				printk("%s gpio66 err !rc = %d\n", __func__, rc);
-			zx29_gpio_set_direction(ZX29_GPIO_66, GPIO_IN);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_66, IO_CFG_PULL_DOWN);
-			rc = zx29_gpio_config(ZX29_GPIO_67, GPIO67_GPIO67);
-			if (rc)
-				printk("%s gpio67 err !rc = %d\n", __func__, rc);
-			zx29_gpio_set_direction(ZX29_GPIO_67, GPIO_IN);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_67, IO_CFG_PULL_DOWN);
-			rc = zx29_gpio_config(ZX29_GPIO_68, GPIO68_GPIO68);
-			if (rc)
-				printk("%s gpio68 err !rc = %d\n", __func__, rc);
-			zx29_gpio_set_direction(ZX29_GPIO_68, GPIO_IN);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_68, IO_CFG_PULL_DOWN);
-			rc = zx29_gpio_config(ZX29_GPIO_69, GPIO69_GPIO69);
-			if (rc)
-				printk("%s gpio69 err !rc = %d\n", __func__, rc);
-			zx29_gpio_set_direction(ZX29_GPIO_69, GPIO_IN);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_69, IO_CFG_PULL_DOWN);
-			rc = zx29_gpio_config(ZX29_GPIO_70, GPIO70_GPIO70);
-			if (rc)
-				printk("%s gpio70 err !rc = %d\n", __func__, rc);
-			zx29_gpio_set_direction(ZX29_GPIO_70, GPIO_IN);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_70, IO_CFG_PULL_DOWN);
-			rc = zx29_gpio_config(ZX29_GPIO_71, GPIO71_GPIO71);
-			if (rc)
-				printk("%s gpio71 err !rc = %d\n", __func__, rc);
-			zx29_gpio_set_direction(ZX29_GPIO_71, GPIO_IN);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_71, IO_CFG_PULL_DOWN);
+	else{
+		if(sd_index == 0) {
+
+			CONFIG_GPIO_GPIO(ZX29_GPIO_66, GPIO66_GPIO66, IO_CFG_PULL_DOWN);		
+			CONFIG_GPIO_GPIO(ZX29_GPIO_67, GPIO67_GPIO67, IO_CFG_PULL_DOWN); 			
+			CONFIG_GPIO_GPIO(ZX29_GPIO_68, GPIO68_GPIO68, IO_CFG_PULL_DOWN); 			
+			CONFIG_GPIO_GPIO(ZX29_GPIO_69, GPIO69_GPIO69, IO_CFG_PULL_DOWN); 		
+			CONFIG_GPIO_GPIO(ZX29_GPIO_70, GPIO70_GPIO70, IO_CFG_PULL_DOWN); 			
+			CONFIG_GPIO_GPIO(ZX29_GPIO_71, GPIO71_GPIO71, IO_CFG_PULL_DOWN); 
 		}
-		else if (sd_index == 1)
-		{
-			rc = zx29_gpio_config(ZX29_GPIO_72, GPIO72_GPIO72);
-			if (rc)
-				printk("%s gpio72 err !rc = %d\n", __func__, rc);
-			zx29_gpio_set_direction(ZX29_GPIO_72, GPIO_IN);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_72, IO_CFG_PULL_DOWN);
-			rc = zx29_gpio_config(ZX29_GPIO_73, GPIO73_GPIO73);
-			if (rc)
-				printk("%s gpio73 err !rc = %d\n", __func__, rc);
-			zx29_gpio_set_direction(ZX29_GPIO_73, GPIO_IN);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_73, IO_CFG_PULL_DOWN);
-			rc = zx29_gpio_config(ZX29_GPIO_74, GPIO74_GPIO74);
-			if (rc)
-				printk("%s gpio74 err !rc = %d\n", __func__, rc);
-			zx29_gpio_set_direction(ZX29_GPIO_74, GPIO_IN);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_74, IO_CFG_PULL_DOWN);
-			rc = zx29_gpio_config(ZX29_GPIO_75, GPIO75_GPIO75);
-			if (rc)
-				printk("%s gpio75 err !rc = %d\n", __func__, rc);
-			zx29_gpio_set_direction(ZX29_GPIO_75, GPIO_IN);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_75, IO_CFG_PULL_DOWN);
-			rc = zx29_gpio_config(ZX29_GPIO_76, GPIO76_GPIO76);
-			if (rc)
-				printk("%s gpio76 err !rc = %d\n", __func__, rc);
-			zx29_gpio_set_direction(ZX29_GPIO_76, GPIO_IN);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_76, IO_CFG_PULL_DOWN);
-			rc = zx29_gpio_config(ZX29_GPIO_77, GPIO77_GPIO77);
-			if (rc)
-				printk("%s gpio77 err !rc = %d\n", __func__, rc);
-			zx29_gpio_set_direction(ZX29_GPIO_77, GPIO_IN);
-			zx29_gpio_pd_pu_set(ZX29_GPIO_77, IO_CFG_PULL_DOWN);
+		else if(sd_index == 1) {
+			CONFIG_GPIO_GPIO(ZX29_GPIO_72, GPIO72_GPIO72, IO_CFG_PULL_DOWN);		
+			CONFIG_GPIO_GPIO(ZX29_GPIO_73, GPIO73_GPIO73, IO_CFG_PULL_DOWN);
+			CONFIG_GPIO_GPIO(ZX29_GPIO_74, GPIO74_GPIO74, IO_CFG_PULL_DOWN);
+			CONFIG_GPIO_GPIO(ZX29_GPIO_75, GPIO75_GPIO75, IO_CFG_PULL_DOWN); 		
+			CONFIG_GPIO_GPIO(ZX29_GPIO_76, GPIO76_GPIO76, IO_CFG_PULL_DOWN);		
+			CONFIG_GPIO_GPIO(ZX29_GPIO_77, GPIO77_GPIO77, IO_CFG_PULL_DOWN);					
 		}
 		else
-			printk("%s index error %d\n", __func__, sd_index);
+			printk("%s index error %d\n",__func__,sd_index);
+
 	}
-	return rc;
+
 }
 //zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
 
@@ -401,17 +331,14 @@
 	}
 #endif
 //zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
-	if (host->pdata->quirks & DW_MCI_QUIRK_AUTO_GATE)
-	{
+	if(host->pdata->quirks & DW_MCI_QUIRK_AUTO_GATE) {
 		int rv = clk_set_auto_gate(sdmmc_wclk, true);
 		if (rv)
 			pr_err("%s: Failed to enable auto gate of sdmmc_wclk\n", __func__);
 		rv = clk_set_auto_gate(sdmmc_aclk, true);
 		if (rv)
 			pr_err("%s: Failed to enable auto gate of sdmmc_aclk\n", __func__);
-	}
-	else
-	{
+	}else{
 		int rv = clk_set_auto_gate(sdmmc_wclk, false);
 		if (rv)
 			pr_err("%s: Failed to disable auto gate of sdmmc_wclk\n", __func__);
@@ -424,9 +351,9 @@
 //zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
 #if defined CONFIG_ARCH_ZX297520V3
 	if(host->host_id == 0) {
-//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
-#if CONFIG_AIC8800D80L
-		sd_io_config(host->host_id,0);
+			
+#if ((defined CONFIG_AIC8800)||(defined CONFIG_AIC8800D80L))
+		 sd_io_config(host->host_id,0);
 #else
 //zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
 		rc=gpio_request(ZX29_GPIO_66,"sd0_clk");
diff --git a/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc.c b/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc.c
index 0aed35b..bd9e9e7 100755
--- a/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc.c
+++ b/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc.c
@@ -102,9 +102,7 @@
 
 static struct dw_mci* dw_mmc_host[] = {NULL, NULL, NULL, NULL};
 static unsigned int enable_wifi_irq = 0;
-//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
-extern volatile u8 mmc0_data1_flag;
-//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
+
 //#pragma GCC optimize("O0")
 
 /* Common flag combinations */
@@ -4162,16 +4160,9 @@
 
 	//ret = irq_set_irq_wake(host->irq, 1);
 //zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
-#ifndef CONFIG_AIC8800D80L
+#if !((defined CONFIG_AIC8800)||(defined CONFIG_AIC8800D80L))
 	if (host->quirks & DW_MCI_QUIRK_SDIO) {
-		irq_set_irq_wake(brd->data1_irq, 1);
-	}
-#else
-	if ((host->quirks & DW_MCI_QUIRK_SDIO)&&(mmc0_data1_flag !=0x0)) {
-		if(mmc0_data1_flag != 0x1){
 			irq_set_irq_wake(brd->data1_irq, 1);
-			mmc0_data1_flag = 0x1;
-		}
 	}
 #endif
 //zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/aic88-generic-wlan.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/aic88-generic-wlan.c
index a3cd95b..2a0dbef 100644
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/aic88-generic-wlan.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/aic88-generic-wlan.c
@@ -26,6 +26,7 @@
 
 //extern void ssv6x5x_wifi_enable(int bval);
 extern void aic8800_wifi_enable(int bval);
+extern void aic8800_wifi_disable(int bval);
 extern int aicwf_prealloc_init(void);
 extern void aicwf_prealloc_exit(void);
 int initWlan(void)
@@ -33,6 +34,7 @@
     int ret=0;
     printk(KERN_ERR "qqq wlan.c initWlan@@@\n");
 	aic8800_wifi_enable(1);
+	aic8800_wifi_disable(1);
     ret = aicwf_prealloc_init();
     if (ret)
         return ret;
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/aicwf_sdio.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/aicwf_sdio.c
index 5fc63bd..144a6eb 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/aicwf_sdio.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/aicwf_sdio.c
@@ -597,7 +597,7 @@
                 up(&sdiodev->pwrctl_wakeup_sema);
                 return 0;
             }
-            sdio_dbg("w\n");
+            //sdio_dbg("w\n");
             while(write_retry) {
                 ret = aicwf_sdio_writeb(sdiodev, SDIOWIFI_WAKEUP_REG, 1);
                 if (ret) {
@@ -651,7 +651,7 @@
                 && !rwnx_hw->is_p2p_connected) {
         down(&sdiodev->pwrctl_wakeup_sema);
         if (rwnx_hw->vif_started) {
-            sdio_dbg("s\n");
+            //sdio_dbg("s\n");
             ret = aicwf_sdio_writeb(sdiodev, SDIOWIFI_SLEEP_REG, 0x10);
             if (ret)
                	sdio_err("Write sleep fail!\n");
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_main.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_main.c
index b0a1015..8f402de 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_main.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_main.c
@@ -1159,6 +1159,8 @@
     RDWR_EFUSE_PWROFSTFINE,
     RDWR_EFUSE_SDIOCFG,
     RDWR_EFUSE_USBVIDPID,
+    SET_SRRC,
+    SET_FSS,
 
     #ifdef CONFIG_RFTEST_USB_BT
     BT_CMD_BASE = 0x100,
@@ -1713,6 +1715,26 @@
                 bytes_written = -EINVAL;
                 break;
             }
+        } else if (strcasecmp(argv[0], "SET_SRRC") == 0) {
+           if (argc > 1) {
+               u8_l func = (u8_l) command_strtoul(argv[1], NULL, 10);
+               printk("set srrc %d\r\n", func);
+               rwnx_send_rftest_req(p_rwnx_hw, SET_SRRC, sizeof(func), &func, NULL);
+            } else {
+               printk("wrong args\n");
+               bytes_written = -EINVAL;
+               break;
+            }
+         } else if (strcasecmp(argv[0], "SET_FSS") == 0) {
+            if (argc > 1) {
+                u8_l func = (u8_l) command_strtoul(argv[1], NULL, 10);
+                printk("set fss: %d\r\n", func);
+                rwnx_send_rftest_req(p_rwnx_hw, SET_FSS, sizeof(func), &func, NULL);
+            } else {
+                printk("wrong args\n");
+                bytes_written = -EINVAL;
+                break;
+            }
         }  else if (strcasecmp(argv[0], "SET_TXPWR_LOSS") == 0) {
             if (argc > 1) {
                 s8_l func = (s8_l)command_strtoul(argv[1], NULL, 10);
@@ -3495,6 +3517,9 @@
                     }
                 }
             }
+			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
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_platform.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_platform.c
index 06b86c3..f5449e2 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_platform.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_platform.c
@@ -33,6 +33,7 @@
 struct rwnx_plat *g_rwnx_plat = NULL;
 extern int testmode;
 
+s8_l loss_value_global = 0;
 extern u8 chip_sub_id;
 extern u8 chip_mcu_id;
 extern u8 btenable;
@@ -898,8 +899,10 @@
 void set_txpwr_loss_ofst(s8_l value)
 {
     nvram_info.txpwr_loss.loss_enable = 1;
-    nvram_info.txpwr_loss.loss_value = value;
-    printk("%s:value:%d\r\n",      __func__, value);
+    nvram_info.txpwr_loss.loss_value = loss_value_global;
+    nvram_info.txpwr_loss.loss_value += value;
+
+    printk("%s:value:%d, loss_value=%d\r\n",      __func__, value, nvram_info.txpwr_loss.loss_value);
 }
 #ifdef CONFIG_SET_AP_PS
 int get_userconfig_set_ap_ps_lvl(ap_ps_conf_t *ap_ps_lvl)
@@ -1041,6 +1044,7 @@
         nvram_info.txpwr_loss.loss_enable = rwnx_atoi(value);
     } else if (!strcmp(command, "loss_value")) {
         nvram_info.txpwr_loss.loss_value = rwnx_atoi(value);
+	loss_value_global = nvram_info.txpwr_loss.loss_value;
     } else if (!strcmp(command, "ofst_enable")) {
         nvram_info.txpwr_ofst.enable = rwnx_atoi(value);
     } else if (!strcmp(command, "ofst_chan_1_4")) {
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/wifi_dev_aic88.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/wifi_dev_aic88.c
index d40d04a..9cdbf7a 100644
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/wifi_dev_aic88.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/wifi_dev_aic88.c
@@ -12,6 +12,7 @@
 extern int rwnx_mod_init(void);
 extern void rwnx_mod_exit(void);
 extern int testmode;
+int aic_runmode = 0;
 extern void aic8800_wifi_disable(int bval);
 extern void aic8800_wifi_re_enable(int bval);
 void dw_mci_rescan_card(unsigned id, unsigned insert);
@@ -47,24 +48,41 @@
 
 	switch (cmd) {
 	case WIFI_IOCTL_STOP: {
+		if((aic_runmode == WIFI_IOCTL_START) || (aic_runmode == WIFI_IOCTL_START_TESTMODE)){
 	      printk(KERN_INFO "@@@exit Wlan@@@\n");
 		rwnx_mod_exit();
 		aic8800_wifi_disable(1);
 		testmode = 0;
+			if(!ret)
+			aic_runmode = WIFI_IOCTL_STOP;
+		}else
+			printk("aic wifi not load %d,cant stop!\n", aic_runmode);
 		break;
 	}
 	case WIFI_IOCTL_START: {
+		if(!aic_runmode){
 	      printk(KERN_INFO "@@@initWlan@@@\n");
 		  aic8800_wifi_re_enable(1);
 		  dw_mci_rescan_card(0,1);
              ret = rwnx_mod_init();
+			if(!ret)
+			aic_runmode = WIFI_IOCTL_START;
+		}else
+			printk("aic wifi has loaded %d,cant start in normal!\n", aic_runmode);
 		break;	
 	}
 	
 	case WIFI_IOCTL_START_TESTMODE: {
+		if(!aic_runmode){
 	      printk(KERN_INFO "@@@initWlan Testmode@@@\n");
 		  	 testmode = 1;
+			  aic8800_wifi_re_enable(1);
+			  dw_mci_rescan_card(0, 1);
              ret = rwnx_mod_init();
+			  if(!ret)
+			  aic_runmode = WIFI_IOCTL_START_TESTMODE;
+		}else
+			printk("aic wifi has loaded %d,cant start in testmode!\n", aic_runmode);
 		break;	
 	}
 
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/Makefile b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/Makefile
index 40c1e43..1775314 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/Makefile
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/Makefile
@@ -130,7 +130,7 @@
 CONFIG_USB_BT =y
 CONFIG_MAC_RANDOM_IF_NO_MAC_IN_EFUSE ?= y
 CONFIG_SDIO_PWRCTRL ?= n
-CONFIG_WPA3_FOR_OLD_KERNEL ?= n
+CONFIG_WPA3_FOR_OLD_KERNEL ?= y
 CONFIG_USB_MSG_OUT_EP =y
 CONFIG_USB_MSG_IN_EP =y
 CONFIG_USB_TX_AGGR=n
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/aic88-generic-wlan.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/aic88-generic-wlan.c
index 7f592b2..657aafa 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/aic88-generic-wlan.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/aic88-generic-wlan.c
@@ -26,6 +26,7 @@
 
 //extern void ssv6x5x_wifi_enable(int bval);
 extern void aic8800_wifi_enable(int bval);
+extern void aic8800_wifi_disable(int bval);
 extern int aicwf_prealloc_init(void);
 extern void aicwf_prealloc_exit(void);
 int initWlan(void)
@@ -33,6 +34,7 @@
     int ret=0;
     printk(KERN_ERR "qqq wlan.c initWlan@@@\n");
 	aic8800_wifi_enable(1);
+	aic8800_wifi_disable(1);
     ret = aicwf_prealloc_init();
     if (ret)
         return ret;
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_cmds.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_cmds.c
index e1fb977..8ed61c8 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_cmds.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_cmds.c
@@ -564,7 +564,8 @@
     bool found = false;
 
    // RWNX_DBG(RWNX_FN_ENTRY_STR);
-   printk("msgind: %d, sz=%d\n", msg->id, cmd_mgr->queue_sz);
+    if(!(msg->id == 73) && !(msg->id == 74))
+   		printk("msgind: %d, sz=%d\n", msg->id, cmd_mgr->queue_sz);
 #ifdef CREATE_TRACE_POINTS
     trace_msg_recv(msg->id);
 #endif
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_main.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_main.c
index 6a271a4..6991db8 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_main.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_main.c
@@ -520,6 +520,7 @@
 bool_l func_flag = true;
 int testmode = 0;
 int adap_test = 0;
+int sec_chan_high = 0;
 
 u8 chip_id = 0;
 u8 chip_rom_id = 0;
@@ -987,6 +988,7 @@
 {
     struct rwnx_vif *rwnx_vif = netdev_priv(dev);
     struct rwnx_hw *rwnx_hw = rwnx_vif->rwnx_hw;
+	int ret = 0;
 #if defined(AICWF_USB_SUPPORT)
     struct aicwf_bus *bus_if = NULL;
     struct aic_usb_dev *usbdev = NULL;
@@ -1025,7 +1027,14 @@
 #else
         cfg80211_scan_done(rwnx_hw->scan_request, true);
 #endif
+		//make sure close ok in scan request
         rwnx_hw->scan_request = NULL;
+		ret = rwnx_send_scanu_cancel_req(rwnx_hw, NULL);
+		mdelay(35);//make sure FW take effect
+		if(ret){
+			printk("rwnx_scanu_cancel fail.\n");
+			return ret;
+		}
     }
 
 #if defined(AICWF_USB_SUPPORT)
@@ -1752,7 +1761,7 @@
                 s8_l func = (s8_l)command_strtoul(argv[1], NULL, 10);
                 printk("set txpwr loss: %d\n", func);
                 set_txpwr_loss_ofst(func);
-                rwnx_send_txpwr_lvl_req(p_rwnx_hw);
+                rwnx_send_txpwr_lvl_v3_req(p_rwnx_hw);
             } else {
                 printk("wrong args\n");
                 bytes_written = -EINVAL;
@@ -8866,6 +8875,7 @@
 //module_init(rwnx_mod_init);
 //module_exit(rwnx_mod_exit);
 
+module_param(sec_chan_high, int, 0660);
 module_param(testmode, int, 0660);
 
 MODULE_FIRMWARE(RWNX_CONFIG_FW_NAME);
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_mod_params.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_mod_params.c
index 7d6644f..8a87a31 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_mod_params.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_mod_params.c
@@ -894,7 +894,7 @@
 #endif
 	        rwnx_hw->vht_cap_5G.cap &= ~IEEE80211_VHT_CAP_SHORT_GI_80;
 	    }
-
+		rwnx_hw->vht_cap_5G.cap |= IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK;
 	} 
 	printk("%s, 5vht_capa_info=0x%x\n", __func__, rwnx_hw->vht_cap_5G.cap);
 #endif
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_msg_rx.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_msg_rx.c
index ee7b1ee..8fb475b 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_msg_rx.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_msg_rx.c
@@ -541,7 +541,7 @@
     struct mm_traffic_req_ind *ind = (struct mm_traffic_req_ind *)msg->param;
     struct rwnx_sta *sta = &rwnx_hw->sta_table[ind->sta_idx];
 
-    RWNX_DBG(RWNX_FN_ENTRY_STR);
+    //RWNX_DBG(RWNX_FN_ENTRY_STR);
 
     netdev_dbg(rwnx_hw->vif_table[sta->vif_idx]->ndev,
                "Sta %d, asked for %d pkt", sta->sta_idx, ind->pkt_cnt);
@@ -720,6 +720,7 @@
         }
 }
 #endif
+extern int sec_chan_high;
 static inline int rwnx_rx_sm_connect_ind(struct rwnx_hw *rwnx_hw,
                                          struct rwnx_cmd *cmd,
                                          struct ipc_e2a_msg *msg)
@@ -763,7 +764,17 @@
         sta->center_freq = ind->center_freq;
         sta->center_freq1 = ind->center_freq1;
         sta->center_freq2 = ind->center_freq2;
+		printk("width %d center_freq %d freq1 %d \n",ind->width,ind->center_freq,ind->center_freq1);
+		if(ind->width > 0){
+			if(ind->center_freq < ind->center_freq1)
+				sec_chan_high = 1;
+			else
+				sec_chan_high = 0;			
+		}else
+			sec_chan_high = 2;
+
         rwnx_vif->sta.ap = sta;
+		printk("band %d width %d sta_idx%d\n",ind->band,ind->width,sta->sta_idx);
         chan = ieee80211_get_channel(rwnx_hw->wiphy, ind->center_freq);
         cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT);
         if (!rwnx_hw->mod_params->ht_on)
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_msg_tx.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_msg_tx.c
index c1796f9..a4f875b 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_msg_tx.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_msg_tx.c
@@ -1791,14 +1791,15 @@
     }
 #elif defined(CONFIG_VHT_FOR_OLD_KERNEL)
     if (sta->vht) {
-        const struct ieee80211_vht_cap *vht_capa = rwnx_vht_capa;
+        //const struct ieee80211_vht_cap *vht_capa = &rwnx_hw->vht_cap_2G;//rwnx_vht_capa;
 
         req->flags |= STA_VHT_CAPA;
-        req->vht_cap.vht_capa_info = cpu_to_le32(vht_capa->vht_cap_info);
-        req->vht_cap.rx_highest = cpu_to_le16(vht_capa->supp_mcs.rx_highest);
-        req->vht_cap.rx_mcs_map = cpu_to_le16(vht_capa->supp_mcs.rx_mcs_map);
-        req->vht_cap.tx_highest = cpu_to_le16(vht_capa->supp_mcs.tx_highest);
-        req->vht_cap.tx_mcs_map = cpu_to_le16(vht_capa->supp_mcs.tx_mcs_map);
+        req->vht_cap.vht_capa_info = rwnx_vht_capa->cap;
+		printk("vht_cap.vht_capa_info %x rwnx_vht_capa cap %x \n",req->vht_cap.vht_capa_info,rwnx_vht_capa->cap);
+        req->vht_cap.rx_highest = cpu_to_le16(rwnx_vht_capa->vht_mcs.rx_highest);
+        req->vht_cap.rx_mcs_map = cpu_to_le16(rwnx_vht_capa->vht_mcs.rx_mcs_map);
+        req->vht_cap.tx_highest = cpu_to_le16(rwnx_vht_capa->vht_mcs.tx_highest);
+        req->vht_cap.tx_mcs_map = cpu_to_le16(rwnx_vht_capa->vht_mcs.tx_mcs_map);
     }
 #endif
 
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/wifi_dev_aic88.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/wifi_dev_aic88.c
index 18b3a9c..2cf4065 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/wifi_dev_aic88.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/wifi_dev_aic88.c
@@ -15,11 +15,9 @@
 extern int rwnx_mod_init(void);
 extern void rwnx_mod_exit(void);
 extern int testmode;
+int aic_runmode = 0;
 extern void aic8800_wifi_disable(int bval);
 extern void aic8800_wifi_re_enable(int bval);
-//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
-extern int sd_io_config(u32 sd_index, bool active_flag);
-//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
 void dw_mci_rescan_card(unsigned id, unsigned insert);
 struct wifi_dev {
 	uint32_t dev_state;
@@ -56,44 +54,50 @@
 	//zw.wang The WiFi-related control pins gpio132 and gpio91 are still affected after the uboot removes mmc0 on 20240531 on end
 	switch (cmd) {
 	case WIFI_IOCTL_STOP: {
+		if((aic_runmode == WIFI_IOCTL_START) || (aic_runmode == WIFI_IOCTL_START_TESTMODE)){
 	      printk(KERN_INFO "@@@exit Wlan@@@\n");
 		rwnx_mod_exit();
 		aic8800_wifi_disable(1);
-		//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
-		ret = sd_io_config(0, 0);
-		if(ret)
-			printk(KERN_ERR "sd_io_config func fail, flag = %d ret = %d\n",0,ret);
-		//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
 		testmode = 0;
+			if(!ret)
+			aic_runmode = WIFI_IOCTL_STOP;
+		}else
+			printk("aic wifi not load %d,cant stop!\n", aic_runmode);
 		break;
 	}
 	case WIFI_IOCTL_START: {
+		if(!aic_runmode){
 	      printk(KERN_INFO "@@@initWlan@@@\n");
-		//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
-		ret = sd_io_config(0, 1);
-		if(ret)
-			printk(KERN_ERR "sd_io_config func fail, flag = %d ret = %d\n",1,ret);
-		//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
 		aic8800_wifi_re_enable(1);
                 dw_mci_rescan_card(0, 1);
              	ret = rwnx_mod_init();
+		if(!ret)
+			aic_runmode = WIFI_IOCTL_START;
 		//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on start
 		if(ret)
 		{
 			printk(KERN_ERR "qqq  rwnx_mod_init fail, ret = %d\n",ret);
 			aic8800_wifi_disable(1);
-			ret = sd_io_config(0, 0);
 			if(ret)
 				printk(KERN_ERR "sd_io_config func fail, flag = %d ret = %d\n",0,ret);
 		}
+		}else
+			printk("aic wifi has loaded %d,cant start in normal!\n", aic_runmode);
 		//zw.wang The sdio0 pin is configured in gpio mode before and after wifi uninstallation on 20240521 on end
 		break;	
 	}
 
 	case WIFI_IOCTL_START_TESTMODE: {
+		if(!aic_runmode){
 	      printk(KERN_INFO "@@@initWlan Testmode@@@\n");
 		  	 testmode = 1;
+			  aic8800_wifi_re_enable(1);
+			  dw_mci_rescan_card(0, 1);
              ret = rwnx_mod_init();
+			  if(!ret)
+			  aic_runmode = WIFI_IOCTL_START_TESTMODE;
+		}else
+			printk("aic wifi has loaded %d,cant start in testmode!\n", aic_runmode);
 		break;	
 	}
 
diff --git a/ap/os/linux/linux-3.4.x/include/linux/nl80211.h b/ap/os/linux/linux-3.4.x/include/linux/nl80211.h
index c014680..b0d47fb 100755
--- a/ap/os/linux/linux-3.4.x/include/linux/nl80211.h
+++ b/ap/os/linux/linux-3.4.x/include/linux/nl80211.h
@@ -688,7 +688,7 @@
 	NL80211_CMD_UNEXPECTED_4ADDR_FRAME,
 
 	NL80211_CMD_SET_NOACK_MAP,
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	NL80211_CMD_CH_SWITCH_NOTIFY,
 
 	NL80211_CMD_START_P2P_DEVICE,
@@ -1548,7 +1548,7 @@
 	NL80211_ATTR_RX_SIGNAL_DBM,
 
 	NL80211_ATTR_BG_SCAN_PERIOD,
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	NL80211_ATTR_WDEV,
 
 	NL80211_ATTR_USER_REG_HINT_TYPE,
@@ -1753,7 +1753,7 @@
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	NUM_NL80211_ATTR = __NL80211_ATTR_AFTER_LAST,
 #endif
 	NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
@@ -2631,7 +2631,7 @@
 	NL80211_AUTHTYPE_SHARED_KEY,
 	NL80211_AUTHTYPE_FT,
 	NL80211_AUTHTYPE_NETWORK_EAP,
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	NL80211_AUTHTYPE_SAE,
 	NL80211_AUTHTYPE_FILS_SK,
 	NL80211_AUTHTYPE_FILS_SK_PFS,
@@ -2666,7 +2666,7 @@
 enum nl80211_mfp {
 	NL80211_MFP_NO,
 	NL80211_MFP_REQUIRED,
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	NL80211_MFP_OPTIONAL,
 #endif
 };
@@ -3161,7 +3161,7 @@
 	NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P =	1<<2,
 	NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U =	1<<3,
 };
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 /**
  * nl80211_external_auth_action - Action to perform with external
  *     authentication request. Used by NL80211_ATTR_EXTERNAL_AUTH_ACTION.
diff --git a/ap/os/linux/linux-3.4.x/include/net/cfg80211.h b/ap/os/linux/linux-3.4.x/include/net/cfg80211.h
index 4580f0e..a090989 100755
--- a/ap/os/linux/linux-3.4.x/include/net/cfg80211.h
+++ b/ap/os/linux/linux-3.4.x/include/net/cfg80211.h
@@ -1078,7 +1078,7 @@
  */
 enum cfg80211_assoc_req_flags {
 	ASSOC_REQ_DISABLE_HT			= BIT(0),
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	ASSOC_REQ_DISABLE_VHT			= BIT(1),
 	ASSOC_REQ_USE_RRM			= BIT(2),
 	CONNECT_REQ_EXTERNAL_AUTH_SUPPORT	= BIT(3),
@@ -1232,7 +1232,7 @@
 	u8 *ie;
 	size_t ie_len;
 	bool privacy;
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	enum nl80211_mfp mfp;
 #endif
 	struct cfg80211_crypto_settings crypto;
@@ -1333,7 +1333,7 @@
 	u8 replay_ctr[NL80211_REPLAY_CTR_LEN];
 };
 
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 /**
  * struct cfg80211_external_auth_params - Trigger External authentication.
  *
@@ -1744,7 +1744,7 @@
 				  u16 noack_map);
 
 	struct ieee80211_channel *(*get_channel)(struct wiphy *wiphy);
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	int     (*external_auth)(struct wiphy *wiphy, struct net_device *dev,
 				 struct cfg80211_external_auth_params *params);
 #endif
@@ -2330,7 +2330,7 @@
 	} sme_state;
 	struct cfg80211_conn *conn;
 	struct cfg80211_cached_keys *connect_keys;
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	u32 conn_owner_nlportid;
 	u8 disconnect_bssid[ETH_ALEN];
 #endif
@@ -3393,7 +3393,7 @@
 				 const u8 *frame, size_t len,
 				 int freq, int sig_dbm, gfp_t gfp);
 
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 /**
  * cfg80211_external_auth_request - userspace request for authentication
  * @netdev: network device
diff --git a/ap/os/linux/linux-3.4.x/include/net/netlink.h b/ap/os/linux/linux-3.4.x/include/net/netlink.h
index 3996aaf..cba811f 100755
--- a/ap/os/linux/linux-3.4.x/include/net/netlink.h
+++ b/ap/os/linux/linux-3.4.x/include/net/netlink.h
@@ -174,7 +174,7 @@
 	NLA_NESTED_COMPAT,
 	NLA_NUL_STRING,
 	NLA_BINARY,
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	NLA_S8,
 	NLA_S16,
 	NLA_S32,
@@ -790,7 +790,7 @@
  */
 static inline int nla_put_u32(struct sk_buff *skb, int attrtype, u32 value)
 {
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	u32 tmp = value;
 
 	return nla_put(skb, attrtype, sizeof(u32), &tmp);
diff --git a/ap/os/linux/linux-3.4.x/net/core/net-sysfs.c b/ap/os/linux/linux-3.4.x/net/core/net-sysfs.c
index eb6e8eb..6693e8d 100644
--- a/ap/os/linux/linux-3.4.x/net/core/net-sysfs.c
+++ b/ap/os/linux/linux-3.4.x/net/core/net-sysfs.c
@@ -1258,7 +1258,7 @@
 		goto exit;
 #endif
 	
-#ifdef CONFIG_AIC8800   
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	if((strcmp(net->name,"wlan0") == 0) || (strcmp(net->name,"wlan0-vxd") == 0) || (strcmp(net->name,"wlan0-va1") == 0)){		
 		if(strncmp(kobj->name, "tx-", 3) != 0)
 			kobject_uevent(kobj, KOBJ_ADD);
diff --git a/ap/os/linux/linux-3.4.x/net/wireless/nl80211.c b/ap/os/linux/linux-3.4.x/net/wireless/nl80211.c
index 72d765e..3971fd0 100755
--- a/ap/os/linux/linux-3.4.x/net/wireless/nl80211.c
+++ b/ap/os/linux/linux-3.4.x/net/wireless/nl80211.c
@@ -206,7 +206,7 @@
 	[NL80211_ATTR_NOACK_MAP] = { .type = NLA_U16 },
 	[NL80211_ATTR_INACTIVITY_TIMEOUT] = { .type = NLA_U16 },
 	[NL80211_ATTR_BG_SCAN_PERIOD] = { .type = NLA_U16 },
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	#if 0
 	[NL80211_ATTR_WDEV] = { .type = NLA_U64 },
 	[NL80211_ATTR_USER_REG_HINT_TYPE] = { .type = NLA_U32 },
@@ -4981,7 +4981,7 @@
 	err = cfg80211_join_ibss(rdev, dev, &ibss, connkeys);
 	if (err)
 		kfree(connkeys);
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	else if (info->attrs[NL80211_ATTR_SOCKET_OWNER]) {
 		printk("lemon %s sock_ow\n", __func__);
 		//dev->ieee80211_ptr->conn_owner_nlportid = info->snd_portid;
@@ -5277,7 +5277,7 @@
 		connect.ie = nla_data(info->attrs[NL80211_ATTR_IE]);
 		connect.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
 	}
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	if (info->attrs[NL80211_ATTR_USE_MFP]) {
 		connect.mfp = nla_get_u32(info->attrs[NL80211_ATTR_USE_MFP]);
 		if (connect.mfp != NL80211_MFP_REQUIRED &&
@@ -5319,7 +5319,7 @@
 		       nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]),
 		       sizeof(connect.ht_capa));
 	}
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	if (nla_get_flag(info->attrs[NL80211_ATTR_EXTERNAL_AUTH_SUPPORT])) {
 		if (!info->attrs[NL80211_ATTR_SOCKET_OWNER]) {
 			kzfree(connkeys);
@@ -5335,7 +5335,7 @@
 	err = cfg80211_connect(rdev, dev, &connect, connkeys);
 	if (err)
 		kfree(connkeys);
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	if (!err && info->attrs[NL80211_ATTR_SOCKET_OWNER]) {
 		//dev->ieee80211_ptr->conn_owner_nlportid = info->snd_portid;
 		dev->ieee80211_ptr->conn_owner_nlportid = info->snd_pid;
@@ -6447,7 +6447,7 @@
 
 	return 0;
 }
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 static inline int
 rdev_external_auth(struct cfg80211_registered_device *rdev,
 		   struct net_device *dev,
@@ -6909,7 +6909,7 @@
 		.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
 				  NL80211_FLAG_NEED_RTNL,
 	},
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 	{
 		.cmd = NL80211_CMD_EXTERNAL_AUTH,
 		//.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
@@ -8267,7 +8267,7 @@
 }
 EXPORT_SYMBOL(cfg80211_report_obss_beacon);
 
-#if defined(CONFIG_AIC8800)
+#if (defined CONFIG_AIC8800 || defined CONFIG_AIC8800D80L)
 int cfg80211_external_auth_request(struct net_device *dev,
 				   struct cfg80211_external_auth_params *params,
 				   gfp_t gfp)