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 <linux/semaphore.h>
26 #include <asm/io.h>
27 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0))
28 #include <linux/printk.h>
29 #include <linux/err.h>
30 #else
31 #include <config/printk.h>
32 #endif
33 extern void sdio_reinit(void);
34 extern void extern_wifi_set_enable(int is_on);
35 extern int wifi_setup_dt(void);
36 #define GPIO_REG_WRITEL(val,reg) do{__raw_writel(val, CTL_PIN_BASE + (reg));}while(0)
37 struct semaphore icomm_chipup_sem;
38 static int g_wifidev_registered = 0;
39 char ssvcabrio_fw_name[50] = "ssv6051-sw.bin";
40 extern int ssvdevice_init(void);
41 extern void ssvdevice_exit(void);
42 #ifdef CONFIG_SSV_SUPPORT_AES_ASM
43 extern int aes_init(void);
44 extern void aes_fini(void);
45 extern int sha1_mod_init(void);
46 extern void sha1_mod_fini(void);
47 #endif
initWlan(void)48 int initWlan(void)
49 {
50 int ret=0;
51 if (wifi_setup_dt()) {
52 printk("wifi_dt : fail to setup dt\n");
53 goto fail;
54 }
55 extern_wifi_set_enable(0);
56 mdelay(200);
57 extern_wifi_set_enable(1);
58 mdelay(200);
59 sdio_reinit();
60 mdelay(100);
61 g_wifidev_registered = 1;
62 fail:
63 up(&icomm_chipup_sem);
64 return ret;
65 }
exitWlan(void)66 void exitWlan(void)
67 {
68 if (g_wifidev_registered)
69 {
70 ssvdevice_exit();
71 extern_wifi_set_enable(0);
72 g_wifidev_registered = 0;
73 }
74 return;
75 }
generic_wifi_init_module(void)76 static __init int generic_wifi_init_module(void)
77 {
78 int ret;
79 printk("%s\n", __func__);
80 sema_init(&icomm_chipup_sem, 0);
81 #ifdef CONFIG_SSV_SUPPORT_AES_ASM
82 sha1_mod_init();
83 aes_init();
84 #endif
85 ret = initWlan();
86 if (down_timeout(&icomm_chipup_sem,
87 msecs_to_jiffies(1000)) != 0) {
88 ret = -EINVAL;
89 printk(KERN_ALERT "%s: platform_driver_register timeout\n", __FUNCTION__);
90 goto out;
91 }
92 ret = ssvdevice_init();
93 out:
94 return ret;
95 }
generic_wifi_exit_module(void)96 static __exit void generic_wifi_exit_module(void)
97 {
98 printk("%s\n", __func__);
99 #ifdef CONFIG_SSV_SUPPORT_AES_ASM
100 aes_fini();
101 sha1_mod_fini();
102 #endif
103 exitWlan();
104 }
105 EXPORT_SYMBOL(generic_wifi_init_module);
106 EXPORT_SYMBOL(generic_wifi_exit_module);
107 module_init(generic_wifi_init_module);
108 module_exit(generic_wifi_exit_module);
109 MODULE_LICENSE("Dual BSD/GPL");
110