wifi:rfkill:bcmdhd: insmod wifi driver after android started.
authorgwl <gwl@rock-chips.com>
Tue, 18 Mar 2014 02:21:53 +0000 (10:21 +0800)
committergwl <gwl@rock-chips.com>
Tue, 18 Mar 2014 02:21:53 +0000 (10:21 +0800)
arch/arm/boot/dts/rk3188-tb.dts
drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/Makefile
drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_gpio.c
drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_linux.c
drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/rkversion.c
drivers/net/wireless/rockchip_wlan/rkwifi/rk_wifi_config.c
drivers/net/wireless/rockchip_wlan/wifi_sys/rkwifi_sys_iface.c
include/linux/rfkill-wlan.h
net/rfkill/rfkill-wlan.c

index 02308cc8e93bd25396604cb1669eccb1b6865ced..fa6f6bf590e440140d8f72b9b7af279989767fc5 100755 (executable)
        supports-highspeed;             
        supports-sdio;
 
-       status = "diabled";
+       status = "okay";
 };
 
 
index e4b4ed2c4f696e8767e2e7014de58a4828ebee3d..2205af16fe36e25070508300d7077e10fc02d631 100644 (file)
@@ -15,7 +15,7 @@ DHDCFLAGS = -Wall -Wstrict-prototypes -Dlinux -DBCMDRIVER                 \
        -DMMC_SDIO_ABORT -DBCMSDIO -DBCMLXSDMMC -DBCMPLATFORM_BUS             \
        -DWIFI_ACT_FRAME -DARP_OFFLOAD_SUPPORT                                \
        -DKEEP_ALIVE -DPKT_FILTER_SUPPORT -DGET_CUSTOM_MAC_ENABLE             \
-       -DEMBEDDED_PLATFORM -DENABLE_INSMOD_NO_FW_LOAD -DPNO_SUPPORT          \
+       -DEMBEDDED_PLATFORM -DPNO_SUPPORT          \
        -DDHD_USE_IDLECOUNT -DSET_RANDOM_MAC_SOFTAP -DVSDB                    \
        -DWL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST -DSDIO_CRC_ERROR_FIX       \
        -DESCAN_RESULT_PATCH -DHT40_GO -DPASS_ARP_PACKET -DSUPPORT_PM2_ONLY   \
@@ -24,7 +24,7 @@ DHDCFLAGS = -Wall -Wstrict-prototypes -Dlinux -DBCMDRIVER                 \
        -DWL_SUPPORT_BACKPORTED_KPATCHES                                      \
        -Idrivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd \
     -Idrivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/include
-
+#-DENABLE_INSMOD_NO_FW_LOAD
 DHDOFILES = aiutils.o bcmsdh_sdmmc_linux.o dhd_linux.o siutils.o bcmutils.o   \
        dhd_linux_sched.o bcmwifi_channels.o dhd_sdio.o bcmevent.o dhd_bta.o hndpmu.o  \
        bcmsdh.o dhd_cdc.o bcmsdh_linux.o dhd_common.o dhd_wlfc.o dhd_ip.o linux_osl.o \
index 7cd273097d349c9fef560b4284b2251a0cddbda2..79103d69761cf9eff42f8c63eeb351a69ab4cc88 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
+#include <linux/rfkill-wlan.h>
 
 #ifdef CUSTOMER_HW
 #ifdef CUSTOMER_OOB
@@ -43,14 +44,13 @@ int bcm_wlan_get_oob_irq(void)
 }
 #endif
 
-extern int rockchip_wifi_power(int on);
-
 void bcm_wlan_power_on(int flag)
 {
        if (flag == 1) {
                printk("======== PULL WL_REG_ON HIGH! ========\n");
                rockchip_wifi_power(1);
         msleep(100);
+        rockchip_wifi_set_carddetect();
        } else {
                printk("======== PULL WL_REG_ON HIGH! (flag = %d) ========\n", flag);
                rockchip_wifi_power(1);
index 7d48d53019f77c35d336f6507e83abc6bbee3c41..0e35b1763674dae19b73e3ce6ad251e4cbd9a31a 100644 (file)
@@ -4879,6 +4879,7 @@ dhd_module_cleanup(void)
 extern bool g_wifi_poweron;
 #endif /* CONFIG_WIFI_CONTROL_FUNC */
 
+
 static int 
 dhd_module_init(void)
 {
@@ -5020,7 +5021,7 @@ fail_0:
 extern char WIFI_MODULE_NAME[];
 extern char RKWIFI_DRV_VERSION[];
 
-static int __init rockchip_wifi_init_module(void)
+int rockchip_wifi_init_module(void)
 {
     printk("=======================================================\n");
     printk("==== Launching Wi-Fi driver! (Powered by Rockchip) ====\n");
@@ -5030,7 +5031,7 @@ static int __init rockchip_wifi_init_module(void)
     return dhd_module_init();
 }
 
-static void __exit rockchip_wifi_exit_module(void)
+void rockchip_wifi_exit_module(void)
 {
     printk("=======================================================\n");
     printk("== Dis-launching Wi-Fi driver! (Powered by Rockchip) ==\n");
@@ -5038,8 +5039,10 @@ static void __exit rockchip_wifi_exit_module(void)
     dhd_module_cleanup();
 }
 
-late_initcall(rockchip_wifi_init_module);
-module_exit(rockchip_wifi_exit_module);
+EXPORT_SYMBOL(rockchip_wifi_init_module);
+EXPORT_SYMBOL(rockchip_wifi_exit_module);
+//late_initcall(rockchip_wifi_init_module);
+//module_exit(rockchip_wifi_exit_module);
 /*
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
 #ifdef USE_LATE_INITCALL_SYNC
index 132928310ccae659771f337aee44daebe6557832..7654d8d1a67308a733f72c38f1a1987e71dac258 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 
-const char RKWIFI_DRV_VERSION[] = "4.75.WFD";
+const char RKWIFI_DRV_VERSION[] = "4.76.WFD";
 
 const char WIFI_MODULE_NAME[] = "";
 const char CONFIG_BCMDHD_FW_PATH[] = "";
index 0cedd82d260245458c3f508b152e7f4e419c7293..67ac0f88719603d0dacefb541f2d5c77e34ccc55 100644 (file)
 #include <linux/module.h>
 #include <linux/kernel.h>
 
-/* Set INIT_COUNTRY_CODE 
- * "US" ---> 11 channels, this is default setting. 
- * "EU" ---> 13 channels
- * "JP" ---> 14 channels
- */
-
-int rkwifi_set_country_code(char *code)
-{
-       sprintf(code, "%s", "EU");
-       return 0;
-}
-
 /* 
  * Set Firmware Path
  */
@@ -107,12 +95,4 @@ int rkwifi_set_firmware(char *fw, char *nvram)
        return 0;
 }
 
-extern int wifi_pcba_test;
-int rkwifi_pcba_status(void) 
-{
-    return wifi_pcba_test;
-}
-
-EXPORT_SYMBOL(rkwifi_set_country_code);
 EXPORT_SYMBOL(rkwifi_set_firmware);
-EXPORT_SYMBOL(rkwifi_pcba_status);
index 9c3a74b8906eb5fc23988ebba1b3c5e8e0a86a9b..12485130c081e06c8c8c9b425bfbcb60c99a3273 100755 (executable)
@@ -8,50 +8,12 @@
 #include <linux/syscalls.h>
 #include <linux/fs.h>
 #include <asm/uaccess.h>
+#include <linux/rfkill-wlan.h>
 
-#ifdef CONFIG_MACH_RK_FAC
-#include <plat/config.h>
-extern int wifi_type;
-#endif 
-#if 1//(LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))
 static ssize_t wifi_chip_read(struct class *cls, struct class_attribute *attr, char *_buf)
-#else
-static ssize_t wifi_chip_read(struct class *cls, char *_buf)
-#endif
 {
     int count = 0;
 
-#ifdef CONFIG_MACH_RK_FAC
-    if(wifi_type==WIFI_TYPE_RTL8188CU) {
-        count = sprintf(_buf, "%s", "RTL8188CU");
-        printk("Current WiFi chip is RTL8188CU.\n");
-        return count;
-    } else if(wifi_type==WIFI_TYPE_RTL8188EU) {
-        count = sprintf(_buf, "%s", "RTL8188EU");
-        printk("Current WiFi chip is RTL8188EU.\n");
-        return count;
-    } else if(wifi_type==WIFI_TYPE_MT7601) {
-        count = sprintf(_buf, "%s", "MT7601");
-        printk("Current WiFi chip is MT7601.\n");
-        return count;
-    } else if(wifi_type==WIFI_TYPE_RTL8188ETV) {
-        count = sprintf(_buf, "%s", "RTL8188ETV");
-        printk("Current WiFi chip is RTL8188ETV.\n");
-        return count;
-    } else if(wifi_type==WIFI_TYPE_MT5370) {
-        count = sprintf(_buf, "%s", "MT5370");
-        printk("Current WiFi chip is MT5370.\n");
-        return count;
-    } else {
-        //printk("NOT surpport type %d\n",wifi_type);
-    }
-#endif
-
-#ifdef CONFIG_BCM4329
-    count = sprintf(_buf, "%s", "BCM4329");
-    printk("Current WiFi chip is BCM4329.\n");
-#endif
-
 #ifdef CONFIG_RTL8192CU
     count = sprintf(_buf, "%s", "RTL8188CU");
     printk("Current WiFi chip is RTL8188CU.\n");
@@ -77,11 +39,6 @@ static ssize_t wifi_chip_read(struct class *cls, char *_buf)
     printk("Current WiFi chip is RTL8723BS.\n");
 #endif
 
-#ifdef CONFIG_RTL8189ES
-    count = sprintf(_buf, "%s", "RTL8189ES");
-    printk("Current WiFi chip is RTL8189ES.\n");
-#endif
-
 #ifdef CONFIG_BCM4330
     count = sprintf(_buf, "%s", "BCM4330");
     printk("Current WiFi chip is BCM4330.\n");
@@ -147,11 +104,6 @@ static ssize_t wifi_chip_read(struct class *cls, char *_buf)
        printk("Current WiFi chip is MT6620.\n");
 #endif
 
-#ifdef CONFIG_RT5370
-    count = sprintf(_buf, "%s", "RT5370");
-    printk("Current WiFi chip is RT5370.\n");
-#endif
-
 #ifdef CONFIG_MT5931
     count = sprintf(_buf, "%s", "MT5931");
     printk("Current WiFi chip is MT5931.\n");
@@ -172,12 +124,6 @@ static ssize_t wifi_chip_read(struct class *cls, char *_buf)
     printk("Current WiFi chip is MT7601.\n");
 #endif
 
-
-#ifdef CONFIG_RTL8723AS
-    count = sprintf(_buf, "%s", "RTL8723AS");
-    printk("Current WiFi chip is RTL8723AS.\n");
-#endif
-
 #ifdef CONFIG_ESP8089
     count = sprintf(_buf, "%s", "ESP8089");
     printk("Current WiFi chip is ESP8089.\n");
@@ -186,200 +132,55 @@ static ssize_t wifi_chip_read(struct class *cls, char *_buf)
     return count;
 }
 
-/*
-static ssize_t wifi_channel_write(struct class *cls, const char *_buf, size_t _count)
+static ssize_t wifi_power_write(struct class *cls, struct class_attribute *attr, const char *_buf, size_t _count)
 {
-    int ret, channel;
-    
-    if (wifi_enabled == 0)
-    {
-        printk("WiFi is disabled.\n");
-        return _count;
-    }
-    
-    channel = simple_strtol(_buf, NULL, 10);
-    
-    ret = wifi_emi_set_channel(channel);
-    if (ret != 0)
-    {
-        //printk("Set channel=%d fail.\n", channel);
-    }
-    else
-    {
-        //printk("Set channel=%d successfully.\n", channel);
-        wifi_channel = channel;
+    int poweren = 0;
+    poweren = simple_strtol(_buf, NULL, 10);
+    printk("%s: poweren = %d\n", __func__, poweren);
+    if(poweren > 0) {
+        rockchip_wifi_power(1);
+    } else {
+        rockchip_wifi_power(0);
     }
-    
-    return _count;
-}
-*/
-
-#if 1//(LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))
-static ssize_t wifi_p2p_read(struct class *cls, struct class_attribute *attr, char *_buf)
-#else
-static ssize_t wifi_p2p_read(struct class *cls, char *_buf)
-#endif
-{
-       int count = 0;
-
-#ifdef CONFIG_BK3515A_COMBO
-       count = sprintf(_buf, "%s", "BK3515A");
-       printk("Current WiFi chip is ESP8089+BK3515A Combo.\n");
-#endif
 
-#ifdef CONFIG_BCM4329
-    count = sprintf(_buf, "%s", "false");
-       printk("Current WiFi chip BCM4329 doesn't support direct.(%s)\n", _buf);
-#endif
-
-#ifdef CONFIG_RTL8192CU
-    count = sprintf(_buf, "%s", "false");
-       printk("Current WiFi chip RTL8188 support direct.(%s)\n", _buf);
-#endif
-
-#ifdef CONFIG_RK903
-    count = sprintf(_buf, "%s", "true");
-           printk("Current WiFi chip RK903 support direct.(%s)\n", _buf);
-#endif
-
-#ifdef CONFIG_BCM4330
-    count = sprintf(_buf, "%s", "true");
-       printk("Current WiFi chip BCM4330 support direct.(%s)\n", _buf);
-#endif
-
-       return count;
+return _count;
 }
 
-int wifi_pcba_test = 0;
+extern int rockchip_wifi_init_module(void);
+extern void rockchip_wifi_exit_module(void);
+static struct semaphore driver_sem;
+static int wifi_driver_insmod = 0;
 
-#if 1//(LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))
-static ssize_t wifi_pcba_read(struct class *cls, struct class_attribute *attr, char *_buf)
-#else
-static ssize_t wifi_pcba_read(struct class *cls, char *_buf)
-#endif
+static ssize_t wifi_driver_write(struct class *cls, struct class_attribute *attr, const char *_buf, size_t _count)
 {
-        int count = 0;
-
-        count = sprintf(_buf, "%d", wifi_pcba_test);
-        return count;
-}
-
-#if 1//(LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))
-static ssize_t wifi_pcba_write(struct class *cls, struct class_attribute *attr, const char *_buf, size_t _count)
-#else
-static ssize_t wifi_pcba_write(struct class *cls, char *_buf, size_t _count)
-#endif 
-{
-        wifi_pcba_test = simple_strtol(_buf, NULL, 10);
-        if(wifi_pcba_test > 0) {
-            wifi_pcba_test = 1;
-        }
+    int enable = 0, ret = 0;
+    
+    down(&driver_sem);
+    enable = simple_strtol(_buf, NULL, 10);
+    //printk("%s: enable = %d\n", __func__, enable);
+    if (wifi_driver_insmod == enable) {
+        printk("%s: wifi driver already %s\n", __func__, enable? "insmod":"rmmod");
+       up(&driver_sem);
         return _count;
-}
-
-#ifdef CONFIG_AIDC
-int check_wifi_type_from_id(int id, char * _buf) {
-       int count = 0;
-
-       switch(id) {
-               case 0x8179:
-                       count = sprintf(_buf, "%s", "RTL8188EU");
-               printk("Current WiFi chip is RTL8188EU.\n");
-                       break;
-               case 0x0179:
-                       count = sprintf(_buf, "%s", "RTL8188EU");
-               printk("Current WiFi chip is RTL8188ETV.\n");
-                       break;
-               case 0x5370:
-                       count = sprintf(_buf, "%s", "RT5370");
-               printk("Current WiFi chip is RT5370.\n");
-                       break;
-               case 0x0724:
-                       count = sprintf(_buf, "%s", "RTL8723AU");
-               printk("Current WiFi chip is RTL8723AU.\n");
-                       break;
-               case 0x8176:
-                       count = sprintf(_buf, "%s", "RTL8188CU");
-               printk("Current WiFi chip is RTL8188CU.\n");
-                       break;
-               case 0x018A:
-                       count = sprintf(_buf, "%s", "RTL8188CU");
-               printk("Current WiFi chip is RTL8188CTV.\n");
-                       break;
-               default:
-               printk("Unsupported usb wifi.............\n");
-       }       
-       return count;   
-}
+    }
+    if(enable > 0) {
+        ret = rockchip_wifi_init_module();
+        if (ret >= 0)
+            wifi_driver_insmod = enable;
+    } else {
+        rockchip_wifi_exit_module();
+        wifi_driver_insmod = enable;
+    }   
 
-extern int rk29sdk_wifi_power(int on);
-extern int wifi_activate_usb(void);
-extern int wifi_deactivate_usb(void);
-#define USB_IDP_SYS_PATCH_1 "/sys/bus/usb/devices/1-1/idProduct"
-#define USB_IDP_SYS_PATCH_2 "/sys/bus/usb/devices/2-1/idProduct"
-#define USB_IDV_SYS_PATCH_1 "/sys/bus/usb/devices/1-1/idVendor"
-#define USB_IDV_SYS_PATCH_2 "/sys/bus/usb/devices/2-1/idVendor"
-#define USB_PRODUCT_SYS_PATCH "/sys/bus/usb/devices/1-1/product"
-//5370 802.11 n WLAN
-//8723 802.11n WLAN Adapter
-//8188eu 802.11n NIC
-//8188cu 802.11n WLAN Adapter
-char aidc_type[20] = {0};
-
-#if 1//(LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))
-static ssize_t wifi_aidc_read(struct class *cls, struct class_attribute *attr, char *_buf)
-#else
-static ssize_t wifi_aidc_read(struct class *cls, char *_buf)
-#endif
-{
-        int count = 0, retry = 10, idP = 0;// idV = 0;
-               ssize_t nread;
-               loff_t pos = 0;
-               char usbid[20] = {0};
-               struct file *file = NULL;
-               mm_segment_t old_fs;
-                
-               sprintf(_buf, "%s", "UNKNOW");
-               wifi_activate_usb();
-               msleep(2000);
-               old_fs = get_fs();
-               set_fs(KERNEL_DS);
-               while(retry--) {
-                       file = filp_open(USB_IDP_SYS_PATCH_2, O_RDONLY, 0);
-                       if (IS_ERR(file)) {
-                               printk("\nCannot open \"%s\", retry = %d\n", USB_IDP_SYS_PATCH_2, retry);
-                               file = filp_open(USB_IDP_SYS_PATCH_1, O_RDONLY, 0);
-                               if (IS_ERR(file)) {
-                               printk("\nCannot open \"%s\", retry = %d\n", USB_IDP_SYS_PATCH_1, retry);
-                                       msleep(500);
-                                       continue;
-                               }
-                       }
-                       break;
-       }
-               if(retry <= 0) {
-                       set_fs(old_fs);
-                       return count;
-               }
-               nread = vfs_read(file, (char __user *)usbid, sizeof(usbid), &pos);
-               set_fs(old_fs);
-               filp_close(file, NULL);
-               wifi_deactivate_usb();
-               idP = simple_strtol(usbid, NULL, 16);
-               printk("Get usb wifi idProduct = 0X%04X\n", idP);
-               count = check_wifi_type_from_id(idP, _buf);
-
-        return count;
+    up(&driver_sem);
+    //printk("%s: ret = %d\n", __func__, ret);
+    return _count; 
 }
-#endif //CONFIG_AIDC
 
 static struct class *rkwifi_class = NULL;
 static CLASS_ATTR(chip, 0664, wifi_chip_read, NULL);
-static CLASS_ATTR(p2p, 0664, wifi_p2p_read, NULL);
-static CLASS_ATTR(pcba, 0664, wifi_pcba_read, wifi_pcba_write);
-#ifdef CONFIG_AIDC
-static CLASS_ATTR(aidc, 0664, wifi_aidc_read, NULL);
-#endif
+static CLASS_ATTR(power, 0222, NULL, wifi_power_write);
+static CLASS_ATTR(driver, 0222, NULL, wifi_driver_write);
 
 int rkwifi_sysif_init(void)
 {
@@ -397,11 +198,9 @@ int rkwifi_sysif_init(void)
     }
     
     ret =  class_create_file(rkwifi_class, &class_attr_chip);
-    ret =  class_create_file(rkwifi_class, &class_attr_p2p);
-    ret =  class_create_file(rkwifi_class, &class_attr_pcba);
-#ifdef CONFIG_AIDC
-    ret =  class_create_file(rkwifi_class, &class_attr_aidc);
-#endif
+    ret =  class_create_file(rkwifi_class, &class_attr_power);
+    ret =  class_create_file(rkwifi_class, &class_attr_driver);
+    sema_init(&driver_sem, 1);
     
     return 0;
 }
@@ -410,11 +209,8 @@ void rkwifi_sysif_exit(void)
 {
     // need to remove the sys files and class
     class_remove_file(rkwifi_class, &class_attr_chip);
-    class_remove_file(rkwifi_class, &class_attr_p2p);
-    class_remove_file(rkwifi_class, &class_attr_pcba);
-#ifdef CONFIG_AIDC
-    class_remove_file(rkwifi_class, &class_attr_aidc);
-#endif
+    class_remove_file(rkwifi_class, &class_attr_power);
+    class_remove_file(rkwifi_class, &class_attr_driver);
     class_destroy(rkwifi_class);
     
     rkwifi_class = NULL;
@@ -423,7 +219,7 @@ void rkwifi_sysif_exit(void)
 module_init(rkwifi_sysif_init);
 module_exit(rkwifi_sysif_exit);
 
-MODULE_AUTHOR("Yongle Lai");
+MODULE_AUTHOR("Yongle Lai & gwl");
 MODULE_DESCRIPTION("WiFi SYS @ Rockchip");
 MODULE_LICENSE("GPL");
 
index d7fcba686231893470e23f59382dfb89a7400ce0..7d80cee25d375a48422372a471012fb9280ae29d 100755 (executable)
@@ -40,6 +40,7 @@ struct rksdmmc_gpio_wifi_moudle {
 
 void *rockchip_mem_prealloc(int section, unsigned long size);
 int rockchip_wifi_power(int on);
+int rockchip_wifi_set_carddetect(void);
 int rockchip_wifi_reset(int on);
 int rockchip_wifi_mac_addr(unsigned char *buf);
 void *rockchip_wifi_country_code(char *ccode);
index 81356127038bfe5e4b2ed9edd30060aaa0a865f7..49789bca1fe5e4d999b537ea2de40804ef585189 100755 (executable)
@@ -263,6 +263,18 @@ int rockchip_wifi_power(int on)
 }
 EXPORT_SYMBOL(rockchip_wifi_power);
 
+/**************************************************************************
+ *
+ * Wifi Sdio Detect Func
+ *
+ *************************************************************************/
+extern int mmc_host_rescan(struct mmc_host *host);
+int rockchip_wifi_set_carddetect(void)
+{
+    return mmc_host_rescan(NULL);//NULL => SDIO host
+}
+EXPORT_SYMBOL(rockchip_wifi_set_carddetect);
+
 /**************************************************************************
  *
  * Wifi Reset Func
@@ -502,7 +514,7 @@ static int rfkill_wlan_probe(struct platform_device *pdev)
     // Turn off wifi power as default
     if (gpio_is_valid(pdata->power_n.io))
     {
-        gpio_direction_output(pdata->power_n.io, pdata->power_n.enable);
+        gpio_direction_output(pdata->power_n.io, !pdata->power_n.enable);
     }
 
 #if BCM_STATIC_MEMORY_SUPPORT