xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/ssv6xxx/platforms/xm-hi3518-generic-wlan.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (c) 2015 South Silicon Valley Microelectronics Inc.
3  * Copyright (c) 2015 iComm Corporation
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  * See the GNU General Public License for more details.
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #include <linux/irq.h>
18 #include <linux/version.h>
19 #include <linux/module.h>
20 #include <linux/vmalloc.h>
21 #include <linux/gpio.h>
22 #include <linux/mmc/host.h>
23 #include <linux/delay.h>
24 #include <linux/regulator/consumer.h>
25 #include <asm/io.h>
26 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0))
27 #include <linux/printk.h>
28 #include <linux/err.h>
29 #else
30 #include <config/printk.h>
31 #endif
32 #define GPIO_REG_WRITEL(val,reg) do{__raw_writel(val, CTL_PIN_BASE + (reg));}while(0)
33 extern void mmc_rescan_sdio(void);
34 extern void wifi_power(int on);
35 static int g_wifidev_registered = 0;
36 extern int ssvdevice_init(void);
37 extern void ssvdevice_exit(void);
38 #ifdef CONFIG_SSV_SUPPORT_AES_ASM
39 extern int aes_init(void);
40 extern void aes_fini(void);
41 extern int sha1_mod_init(void);
42 extern void sha1_mod_fini(void);
43 #endif
initWlan(void)44 int initWlan(void)
45 {
46     int ret=0;
47     wifi_power(0);
48     mdelay(10);
49     wifi_power(1);
50     mdelay(120);
51  mmc_rescan_sdio();
52     mdelay(120);
53     g_wifidev_registered = 1;
54     ret = ssvdevice_init();
55     return ret;
56 }
exitWlan(void)57 void exitWlan(void)
58 {
59     if (g_wifidev_registered)
60     {
61         ssvdevice_exit();
62         wifi_power(0);
63         g_wifidev_registered = 0;
64     }
65     return;
66 }
generic_wifi_init_module(void)67 static __init int generic_wifi_init_module(void)
68 {
69  printk("%s\n", __func__);
70 #ifdef CONFIG_SSV_SUPPORT_AES_ASM
71  sha1_mod_init();
72  aes_init();
73 #endif
74  return initWlan();
75 }
generic_wifi_exit_module(void)76 static __exit void generic_wifi_exit_module(void)
77 {
78  printk("%s\n", __func__);
79 #ifdef CONFIG_SSV_SUPPORT_AES_ASM
80         aes_fini();
81         sha1_mod_fini();
82 #endif
83  exitWlan();
84 }
85 EXPORT_SYMBOL(generic_wifi_init_module);
86 EXPORT_SYMBOL(generic_wifi_exit_module);
87 module_init(generic_wifi_init_module);
88 module_exit(generic_wifi_exit_module);
89 MODULE_LICENSE("Dual BSD/GPL");
90