From: hwg <hwg@rock-chips.com>
Date: Wed, 1 Apr 2015 13:22:35 +0000 (+0800)
Subject: modify wifi: load driver when kernel bootup:
X-Git-Tag: firefly_0821_release~4221
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e3a332d3c293a085b495f3a939c61c57063190c4;p=firefly-linux-kernel-4.4.55.git

modify wifi: load driver when kernel bootup:
 can increase speed of wifi open/close
 can solve memory alloc fail when open wifi
---

diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 94c07fe4a96e..544aa86f0d8a 100755
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -25,6 +25,12 @@ if WLAN
 #	  bool "rda 5990p"
 #	  ---help---
 #	    rda5990P fm bt wifi
+
+config WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    bool "Wifi load driver when kernel bootup"
+    default y
+    ---help---
+      Wifi driver will be load (use late_initcall) when kernel bootup
 	    
 menuconfig RTL_WIRELESS_SOLUTION
     bool "Realtek Wireless Device Driver Support"
diff --git a/drivers/net/wireless/rockchip_wlan/esp8089/esp_driver/esp_init.c b/drivers/net/wireless/rockchip_wlan/esp8089/esp_driver/esp_init.c
index a0f1d324e4da..dee93eed9ec8 100755
--- a/drivers/net/wireless/rockchip_wlan/esp8089/esp_driver/esp_init.c
+++ b/drivers/net/wireless/rockchip_wlan/esp8089/esp_driver/esp_init.c
@@ -92,20 +92,33 @@ static void /*__exit */ esp_exit(void)
 	esp_common_exit();
 }
 
+#include <linux/rfkill-wlan.h>
+extern int get_wifi_chip_type(void);
+
 int rockchip_wifi_init_module_esp8089(void)
 {
-		
-	return esp_init();		
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type != WIFI_ESP8089) return 0;
+#endif
+	return esp_init();
 }
 
 void rockchip_wifi_exit_module_esp8089(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type != WIFI_ESP8089) return;
+#endif
 	esp_exit(); 
-		 
 }
 
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+late_initcall(rockchip_wifi_init_module_esp8089);
+module_exit(rockchip_wifi_exit_module_esp8089);
+#else
 EXPORT_SYMBOL(rockchip_wifi_init_module_esp8089);
 EXPORT_SYMBOL(rockchip_wifi_exit_module_esp8089);
-
+#endif
 //module_init(esp_init);
 //module_exit(esp_exit);
diff --git a/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_linux.c b/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_linux.c
index a5782113f9ed..2f678e6f171e 100755
--- a/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_linux.c
+++ b/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_linux.c
@@ -7045,11 +7045,17 @@ dhd_reboot_callback(struct notifier_block *this, unsigned long code, void *unuse
 	return NOTIFY_DONE;
 }
 
+#include <linux/rfkill-wlan.h>
+extern int get_wifi_chip_type(void);
 extern char WIFI_MODULE_NAME[];
 extern char RKWIFI_DRV_VERSION[];
 
 int rockchip_wifi_init_module_rkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type > WIFI_AP6XXX_SERIES) return 0;
+#endif
     printk("=======================================================\n");
     printk("==== Launching Wi-Fi driver! (Powered by Rockchip) ====\n");
     printk("=======================================================\n");
@@ -7060,14 +7066,23 @@ int rockchip_wifi_init_module_rkwifi(void)
 
 void rockchip_wifi_exit_module_rkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();    
+    if (type > WIFI_AP6XXX_SERIES) return;
+#endif
     printk("=======================================================\n");
     printk("== Dis-launching Wi-Fi driver! (Powered by Rockchip) ==\n");
     printk("=======================================================\n");
     dhd_module_exit();
 }
 
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+late_initcall(rockchip_wifi_init_module_rkwifi);
+module_exit(rockchip_wifi_exit_module_rkwifi);
+#else
 EXPORT_SYMBOL(rockchip_wifi_init_module_rkwifi);
 EXPORT_SYMBOL(rockchip_wifi_exit_module_rkwifi);
+#endif
 //#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
 //#if defined(CONFIG_DEFERRED_INITCALLS)
 //deferred_module_init(dhd_module_init);
diff --git a/drivers/net/wireless/rockchip_wlan/rtl8188eu/os_dep/linux/usb_intf.c b/drivers/net/wireless/rockchip_wlan/rtl8188eu/os_dep/linux/usb_intf.c
index 50fc3fa9ef6f..90e3b61dcbc1 100755
--- a/drivers/net/wireless/rockchip_wlan/rtl8188eu/os_dep/linux/usb_intf.c
+++ b/drivers/net/wireless/rockchip_wlan/rtl8188eu/os_dep/linux/usb_intf.c
@@ -1938,9 +1938,14 @@ static void rtw_drv_halt(void)
 
 #include "wifi_version.h"
 #include <linux/rfkill-wlan.h>
+extern int get_wifi_chip_type(void);
 
 int rockchip_wifi_init_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return 0;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Launching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -1953,6 +1958,10 @@ int rockchip_wifi_init_module_rtkwifi(void)
 
 void rockchip_wifi_exit_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Dislaunching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -1962,8 +1971,13 @@ void rockchip_wifi_exit_module_rtkwifi(void)
     rockchip_wifi_power(0);
 }
 
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+late_initcall(rockchip_wifi_init_module_rtkwifi);
+module_exit(rockchip_wifi_exit_module_rtkwifi);
+#else
 EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
 EXPORT_SYMBOL(rockchip_wifi_exit_module_rtkwifi);
+#endif
 //module_init(rtw_drv_entry);
 //module_exit(rtw_drv_halt);
 
diff --git a/drivers/net/wireless/rockchip_wlan/rtl8189es/os_dep/linux/sdio_intf.c b/drivers/net/wireless/rockchip_wlan/rtl8189es/os_dep/linux/sdio_intf.c
index e77364aedcc6..324a9a00c758 100755
--- a/drivers/net/wireless/rockchip_wlan/rtl8189es/os_dep/linux/sdio_intf.c
+++ b/drivers/net/wireless/rockchip_wlan/rtl8189es/os_dep/linux/sdio_intf.c
@@ -1056,9 +1056,14 @@ int rtw_sdio_set_power(int on)
 
 #include "wifi_version.h"
 #include <linux/rfkill-wlan.h>
+extern int get_wifi_chip_type(void);
 
 int rockchip_wifi_init_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return 0;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Launching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -1072,6 +1077,10 @@ int rockchip_wifi_init_module_rtkwifi(void)
 
 void rockchip_wifi_exit_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Dislaunching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -1082,12 +1091,12 @@ void rockchip_wifi_exit_module_rtkwifi(void)
     rockchip_wifi_power(0);
 }
 
-#ifdef CONFIG_RTL8189ES
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+late_initcall(rockchip_wifi_init_module_rtkwifi);
+module_exit(rockchip_wifi_exit_module_rtkwifi);
+#else
 EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
 EXPORT_SYMBOL(rockchip_wifi_exit_module_rtkwifi);
-#else
-module_init(rockchip_wifi_init_module_rtkwifi);
-module_exit(rockchip_wifi_exit_module_rtkwifi);
 #endif
 //module_init(rtw_drv_entry);
 //module_exit(rtw_drv_halt);
diff --git a/drivers/net/wireless/rockchip_wlan/rtl8192cu/os_dep/linux/usb_intf.c b/drivers/net/wireless/rockchip_wlan/rtl8192cu/os_dep/linux/usb_intf.c
index d498a7580e69..0760173cba1a 100755
--- a/drivers/net/wireless/rockchip_wlan/rtl8192cu/os_dep/linux/usb_intf.c
+++ b/drivers/net/wireless/rockchip_wlan/rtl8192cu/os_dep/linux/usb_intf.c
@@ -1617,9 +1617,14 @@ static void rtw_drv_halt(void)
 
 #include "wifi_version.h"
 #include <linux/rfkill-wlan.h>
+extern int get_wifi_chip_type(void);
 
 int rockchip_wifi_init_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();    
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return 0;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Launching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -1632,6 +1637,10 @@ int rockchip_wifi_init_module_rtkwifi(void)
 
 void rockchip_wifi_exit_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Dislaunching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -1641,8 +1650,13 @@ void rockchip_wifi_exit_module_rtkwifi(void)
     rockchip_wifi_power(0);
 }
 
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+late_initcall(rockchip_wifi_init_module_rtkwifi);
+module_exit(rockchip_wifi_exit_module_rtkwifi);
+#else
 EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
 EXPORT_SYMBOL(rockchip_wifi_exit_module_rtkwifi);
+#endif
 //module_init(rtw_drv_entry);
 //module_exit(rtw_drv_halt);
 
diff --git a/drivers/net/wireless/rockchip_wlan/rtl8192du/os_dep/linux/usb_intf.c b/drivers/net/wireless/rockchip_wlan/rtl8192du/os_dep/linux/usb_intf.c
index 1771f3609d4c..cc00439654cb 100644
--- a/drivers/net/wireless/rockchip_wlan/rtl8192du/os_dep/linux/usb_intf.c
+++ b/drivers/net/wireless/rockchip_wlan/rtl8192du/os_dep/linux/usb_intf.c
@@ -1646,9 +1646,14 @@ static void rtw_drv_halt(void)
 
 #include "wifi_version.h"
 #include <linux/rfkill-wlan.h>
+extern int get_wifi_chip_type(void);
 
 int rockchip_wifi_init_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return 0;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Launching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -1661,6 +1666,10 @@ int rockchip_wifi_init_module_rtkwifi(void)
 
 void rockchip_wifi_exit_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Dislaunching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -1670,12 +1679,12 @@ void rockchip_wifi_exit_module_rtkwifi(void)
     rockchip_wifi_power(0);
 }
 
-#ifdef CONFIG_RTL8192DU
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+late_initcall(rockchip_wifi_init_module_rtkwifi);
+module_exit(rockchip_wifi_exit_module_rtkwifi);
+#else
 EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
 EXPORT_SYMBOL(rockchip_wifi_exit_module_rtkwifi);
-#else
-module_init(rockchip_wifi_init_module_rtkwifi);
-module_exit(rockchip_wifi_exit_module_rtkwifi);
 #endif
 //module_init(rtw_drv_entry);
 //module_exit(rtw_drv_halt);
diff --git a/drivers/net/wireless/rockchip_wlan/rtl8723au/os_dep/linux/usb_intf.c b/drivers/net/wireless/rockchip_wlan/rtl8723au/os_dep/linux/usb_intf.c
index 5ab4d0b81a7e..353d4c279211 100755
--- a/drivers/net/wireless/rockchip_wlan/rtl8723au/os_dep/linux/usb_intf.c
+++ b/drivers/net/wireless/rockchip_wlan/rtl8723au/os_dep/linux/usb_intf.c
@@ -2158,9 +2158,14 @@ static void /*exit*/ rtw_drv_halt(void)
 
 #include "wifi_version.h"
 #include <linux/rfkill-wlan.h>
+extern int get_wifi_chip_type(void);
 
 int rockchip_wifi_init_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return 0;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Launching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -2173,6 +2178,10 @@ int rockchip_wifi_init_module_rtkwifi(void)
 
 void rockchip_wifi_exit_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Dislaunching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -2182,12 +2191,12 @@ void rockchip_wifi_exit_module_rtkwifi(void)
     rockchip_wifi_power(0);
 }
 
-#ifdef CONFIG_RTL8723AU
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+late_initcall(rockchip_wifi_init_module_rtkwifi);
+module_exit(rockchip_wifi_exit_module_rtkwifi);
+#else
 EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
 EXPORT_SYMBOL(rockchip_wifi_exit_module_rtkwifi);
-#else
-module_init(rockchip_wifi_init_module_rtkwifi);
-module_exit(rockchip_wifi_exit_module_rtkwifi);
 #endif
 //module_init(rtw_drv_entry);
 //module_exit(rtw_drv_halt);
diff --git a/drivers/net/wireless/rockchip_wlan/rtl8723bs-vq0/os_dep/linux/sdio_intf.c b/drivers/net/wireless/rockchip_wlan/rtl8723bs-vq0/os_dep/linux/sdio_intf.c
index d3a7927d84f9..0376168cb212 100755
--- a/drivers/net/wireless/rockchip_wlan/rtl8723bs-vq0/os_dep/linux/sdio_intf.c
+++ b/drivers/net/wireless/rockchip_wlan/rtl8723bs-vq0/os_dep/linux/sdio_intf.c
@@ -1039,12 +1039,17 @@ int rtw_sdio_set_power(int on)
 #endif //CONFIG_PLATFORM_INTEL_BYT
 
 #include "wifi_version.h"
-
+#include <linux/rfkill-wlan.h>
+extern int get_wifi_chip_type(void);
 extern int rockchip_wifi_power(int on);
 extern int rockchip_wifi_set_carddetect(int val);
 
 int rockchip_wifi_init_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return 0;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Launching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -1058,6 +1063,10 @@ int rockchip_wifi_init_module_rtkwifi(void)
 
 void rockchip_wifi_exit_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Dislaunching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -1070,12 +1079,12 @@ void rockchip_wifi_exit_module_rtkwifi(void)
     rockchip_wifi_power(0);
 }
 
-#ifdef CONFIG_RTL8723BS_VQ0
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+late_initcall(rockchip_wifi_init_module_rtkwifi);
+module_exit(rockchip_wifi_exit_module_rtkwifi);
+#else
 EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
 EXPORT_SYMBOL(rockchip_wifi_exit_module_rtkwifi);
-#else
-module_init(rockchip_wifi_init_module_rtkwifi);
-module_exit(rockchip_wifi_exit_module_rtkwifi);
 #endif
 //module_init(rtw_drv_entry);
 //module_exit(rtw_drv_halt);
diff --git a/drivers/net/wireless/rockchip_wlan/rtl8723bs/os_dep/linux/sdio_intf.c b/drivers/net/wireless/rockchip_wlan/rtl8723bs/os_dep/linux/sdio_intf.c
index 2e7decce45eb..a6577d6bfc8c 100755
--- a/drivers/net/wireless/rockchip_wlan/rtl8723bs/os_dep/linux/sdio_intf.c
+++ b/drivers/net/wireless/rockchip_wlan/rtl8723bs/os_dep/linux/sdio_intf.c
@@ -1039,15 +1039,17 @@ int rtw_sdio_set_power(int on)
 #endif //CONFIG_PLATFORM_INTEL_BYT
 
 #include "wifi_version.h"
-
+#include <linux/rfkill-wlan.h>
 extern int rockchip_wifi_power(int on);
 extern int rockchip_wifi_set_carddetect(int val);
-
-
-
+extern int get_wifi_chip_type(void);
 
 int rockchip_wifi_init_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return 0;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Launching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -1061,6 +1063,10 @@ int rockchip_wifi_init_module_rtkwifi(void)
 
 void rockchip_wifi_exit_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Dislaunching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -1073,12 +1079,12 @@ void rockchip_wifi_exit_module_rtkwifi(void)
     rockchip_wifi_power(0);
 }
 
-#ifdef CONFIG_RTL8723BS
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+late_initcall(rockchip_wifi_init_module_rtkwifi);
+module_exit(rockchip_wifi_exit_module_rtkwifi);
+#else
 EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
 EXPORT_SYMBOL(rockchip_wifi_exit_module_rtkwifi);
-#else
-module_init(rockchip_wifi_init_module_rtkwifi);
-module_exit(rockchip_wifi_exit_module_rtkwifi);
 #endif
 //module_init(rtw_drv_entry);
 //module_exit(rtw_drv_halt);
diff --git a/drivers/net/wireless/rockchip_wlan/rtl8723bu/os_dep/linux/usb_intf.c b/drivers/net/wireless/rockchip_wlan/rtl8723bu/os_dep/linux/usb_intf.c
index 571c4b8420bf..1ea0e5aed86c 100755
--- a/drivers/net/wireless/rockchip_wlan/rtl8723bu/os_dep/linux/usb_intf.c
+++ b/drivers/net/wireless/rockchip_wlan/rtl8723bu/os_dep/linux/usb_intf.c
@@ -1751,6 +1751,8 @@ static void rtw_drv_halt(void)
 }
 
 #include "wifi_version.h"
+#include <linux/rfkill-wlan.h>
+extern int get_wifi_chip_type(void);
 //extern int wifi_activate_usb(void);
 //extern int wifi_deactivate_usb(void);
 extern int rockchip_wifi_power(int on);
@@ -1758,6 +1760,10 @@ extern int rockchip_wifi_set_carddetect(int val);
 
 int rockchip_wifi_init_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return 0;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Launching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -1769,6 +1775,10 @@ int rockchip_wifi_init_module_rtkwifi(void)
 
 void rockchip_wifi_exit_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Dislaunching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -1779,9 +1789,13 @@ void rockchip_wifi_exit_module_rtkwifi(void)
   // wifi_deactivate_usb();
 }
 
-
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+late_initcall(rockchip_wifi_init_module_rtkwifi);
+module_exit(rockchip_wifi_exit_module_rtkwifi);
+#else
 EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
 EXPORT_SYMBOL(rockchip_wifi_exit_module_rtkwifi);
+#endif
 //module_init(rtw_drv_entry);
 //module_exit(rtw_drv_halt);
 
diff --git a/drivers/net/wireless/rockchip_wlan/rtl8812au/os_dep/linux/usb_intf.c b/drivers/net/wireless/rockchip_wlan/rtl8812au/os_dep/linux/usb_intf.c
index 915238461f25..9624c780ec2a 100755
--- a/drivers/net/wireless/rockchip_wlan/rtl8812au/os_dep/linux/usb_intf.c
+++ b/drivers/net/wireless/rockchip_wlan/rtl8812au/os_dep/linux/usb_intf.c
@@ -1753,9 +1753,14 @@ static void rtw_drv_halt(void)
 
 #include "wifi_version.h"
 #include <linux/rfkill-wlan.h>
+extern int get_wifi_chip_type(void);
 
 int rockchip_wifi_init_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return 0;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Launching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -1768,6 +1773,10 @@ int rockchip_wifi_init_module_rtkwifi(void)
 
 void rockchip_wifi_exit_module_rtkwifi(void)
 {
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    int type = get_wifi_chip_type();
+    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return;
+#endif
     printk("\n");
     printk("=======================================================\n");
     printk("==== Dislaunching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -1777,12 +1786,12 @@ void rockchip_wifi_exit_module_rtkwifi(void)
     rockchip_wifi_power(0);
 }
 
-#ifdef CONFIG_RTL8812AU
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+late_initcall(rockchip_wifi_init_module_rtkwifi);
+module_exit(rockchip_wifi_exit_module_rtkwifi);
+#else
 EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
 EXPORT_SYMBOL(rockchip_wifi_exit_module_rtkwifi);
-#else
-module_init(rockchip_wifi_init_module_rtkwifi);
-module_exit(rockchip_wifi_exit_module_rtkwifi);
 #endif
 //module_init(rtw_drv_entry);
 //module_exit(rtw_drv_halt);
diff --git a/drivers/net/wireless/rockchip_wlan/wifi_sys/rkwifi_sys_iface.c b/drivers/net/wireless/rockchip_wlan/wifi_sys/rkwifi_sys_iface.c
index d9f05c81e38b..9aac4e58b53b 100755
--- a/drivers/net/wireless/rockchip_wlan/wifi_sys/rkwifi_sys_iface.c
+++ b/drivers/net/wireless/rockchip_wlan/wifi_sys/rkwifi_sys_iface.c
@@ -153,6 +153,9 @@ static int wifi_driver_insmod = 0;
 static int wifi_init_exit_module(int enable)
 {
     int ret = 0;
+
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+#else
     int type = get_wifi_chip_type();
 //#ifdef CONFIG_RKWIFI
     if (type < WIFI_AP6XXX_SERIES) {
@@ -181,7 +184,7 @@ static int wifi_init_exit_module(int enable)
         return ret;
     }
 //#endif
-
+#endif
     return ret;
 }
 
@@ -215,6 +218,9 @@ static struct class *rkwifi_class = NULL;
 static CLASS_ATTR(chip, 0664, wifi_chip_read, NULL);
 static CLASS_ATTR(power, 0660, NULL, wifi_power_write);
 static CLASS_ATTR(driver, 0660, NULL, wifi_driver_write);
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+static CLASS_ATTR(preload, 0660, NULL, NULL);
+#endif
 
 int rkwifi_sysif_init(void)
 {
@@ -234,6 +240,9 @@ int rkwifi_sysif_init(void)
     ret =  class_create_file(rkwifi_class, &class_attr_chip);
     ret =  class_create_file(rkwifi_class, &class_attr_power);
     ret =  class_create_file(rkwifi_class, &class_attr_driver);
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    ret =  class_create_file(rkwifi_class, &class_attr_preload);
+#endif
     sema_init(&driver_sem, 1);
     
     return 0;
@@ -245,6 +254,9 @@ void rkwifi_sysif_exit(void)
     class_remove_file(rkwifi_class, &class_attr_chip);
     class_remove_file(rkwifi_class, &class_attr_power);
     class_remove_file(rkwifi_class, &class_attr_driver);
+#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
+    class_remove_file(rkwifi_class, &class_attr_preload);
+#endif
     class_destroy(rkwifi_class);
     
     rkwifi_class = NULL;