modify wifi: load driver when kernel bootup:
authorhwg <hwg@rock-chips.com>
Wed, 1 Apr 2015 13:22:35 +0000 (21:22 +0800)
committerhwg <hwg@rock-chips.com>
Wed, 1 Apr 2015 13:30:34 +0000 (21:30 +0800)
 can increase speed of wifi open/close
 can solve memory alloc fail when open wifi

13 files changed:
drivers/net/wireless/Kconfig
drivers/net/wireless/rockchip_wlan/esp8089/esp_driver/esp_init.c
drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_linux.c
drivers/net/wireless/rockchip_wlan/rtl8188eu/os_dep/linux/usb_intf.c
drivers/net/wireless/rockchip_wlan/rtl8189es/os_dep/linux/sdio_intf.c
drivers/net/wireless/rockchip_wlan/rtl8192cu/os_dep/linux/usb_intf.c
drivers/net/wireless/rockchip_wlan/rtl8192du/os_dep/linux/usb_intf.c
drivers/net/wireless/rockchip_wlan/rtl8723au/os_dep/linux/usb_intf.c
drivers/net/wireless/rockchip_wlan/rtl8723bs-vq0/os_dep/linux/sdio_intf.c
drivers/net/wireless/rockchip_wlan/rtl8723bs/os_dep/linux/sdio_intf.c
drivers/net/wireless/rockchip_wlan/rtl8723bu/os_dep/linux/usb_intf.c
drivers/net/wireless/rockchip_wlan/rtl8812au/os_dep/linux/usb_intf.c
drivers/net/wireless/rockchip_wlan/wifi_sys/rkwifi_sys_iface.c

index 94c07fe4a96e45c399078c11674f721838813980..544aa86f0d8aa1cc657a4d02ffbd6802e1cd8892 100755 (executable)
@@ -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"
index a0f1d324e4dabc8ee0762f06dd65710f06f21284..dee93eed9ec8cd09d9499f0f53626e10d6ca5ceb 100755 (executable)
@@ -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);
index a5782113f9ed0271152eb2f2c38c3cb598f5205c..2f678e6f171e8a2603f0f81596b563e7f2025b41 100755 (executable)
@@ -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);
index 50fc3fa9ef6faa9817c4cfe9cc27a5392445fc64..90e3b61dcbc1c3e307cfcf8b8b67f0a924791cc4 100755 (executable)
@@ -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);
 
index e77364aedcc6be8d3fa8e350e7b9e26427397595..324a9a00c7581a18245e4ccab96d951eb4ed10e0 100755 (executable)
@@ -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);
index d498a7580e69dffb03ee8662c7b8c7e8cd71f6e1..0760173cba1af356c8b1edcef6b5aa3afbee9fb5 100755 (executable)
@@ -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);
 
index 1771f3609d4c29e269d3efb364183c85bf1c53ee..cc00439654cb9ac64836330945465595532d3779 100644 (file)
@@ -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);
index 5ab4d0b81a7ea7334abbc518e33a25e56dfcae8d..353d4c279211c8b66349b18ec4ad0b3f230e0181 100755 (executable)
@@ -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);
index d3a7927d84f917ff6ed1473db7a35b99f3e88ebd..0376168cb212300ed7228674c72382602025695e 100755 (executable)
@@ -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);
index 2e7decce45ebcdd169a4185452aecb74d47b2f1d..a6577d6bfc8c4d741d8c912d086595673da893ae 100755 (executable)
@@ -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);
index 571c4b8420bfec0be5e09f6bb0feb23ab65de665..1ea0e5aed86c052bb0dd24c5a34c2ba5057b09df 100755 (executable)
@@ -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);
 
index 915238461f258867bbf1b049b48fd6ea5490e1df..9624c780ec2a80e53e415f5ea7c41c274abc3a77 100755 (executable)
@@ -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);
index d9f05c81e38b7c6ec25e24037cc131c316e7c064..9aac4e58b53b92dc4f9f36aa739271a674a2320a 100755 (executable)
@@ -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;