Merge remote-tracking branch 'stable/linux-3.0.y' into develop-3.0
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / wifi_sys / rkwifi_sys_iface.c
1 \r
2 #include <linux/kernel.h>\r
3 #include <linux/module.h>\r
4 #include <linux/init.h>\r
5 #include <linux/device.h>\r
6 #include <linux/err.h>\r
7 \r
8 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))\r
9 static ssize_t wifi_chip_read(struct class *cls, struct class_attribute *attr, char *_buf)\r
10 #else\r
11 static ssize_t wifi_chip_read(struct class *cls, char *_buf)\r
12 #endif\r
13 {\r
14     int count = 0;\r
15 \r
16 #ifdef CONFIG_BCM4329\r
17     count = sprintf(_buf, "%s", "BCM4329");\r
18     printk("Current WiFi chip is BCM4329.\n");\r
19 #endif\r
20 \r
21 #ifdef CONFIG_RTL8192CU\r
22     count = sprintf(_buf, "%s", "RTL8188CU");\r
23     printk("Current WiFi chip is RTL8188CU.\n");\r
24 #endif\r
25 \r
26 #ifdef CONFIG_RTL8188EU\r
27     count = sprintf(_buf, "%s", "RTL8188EU");\r
28     printk("Current WiFi chip is RTL8188EU.\n");\r
29 #endif\r
30 \r
31 #ifdef CONFIG_BCM4330\r
32     count = sprintf(_buf, "%s", "BCM4330");\r
33     printk("Current WiFi chip is BCM4330.\n");\r
34 #endif\r
35 \r
36 #ifdef CONFIG_RK901\r
37     count = sprintf(_buf, "%s", "RK901");\r
38     printk("Current WiFi chip is RK901.\n");\r
39 #endif\r
40 \r
41 #ifdef CONFIG_RK903\r
42     count = sprintf(_buf, "%s", "RK903");\r
43     printk("Current WiFi chip is RK903.\n");\r
44 #endif\r
45     \r
46 #ifdef CONFIG_RT5370\r
47     count = sprintf(_buf, "%s", "RT5370");\r
48     printk("Current WiFi chip is RT5370.\n");\r
49 #endif\r
50 \r
51 #ifdef CONFIG_MT5931\r
52     count = sprintf(_buf, "%s", "MT5931");\r
53     printk("Current WiFi chip is MT5931.\n");\r
54 #endif\r
55 \r
56 #ifdef CONFIG_MT5931_MT6622\r
57     count = sprintf(_buf, "%s", "MT5931");\r
58     printk("Current WiFi chip is MT5931.\n");\r
59 #endif\r
60 \r
61     return count;\r
62 }\r
63 \r
64 /*\r
65 static ssize_t wifi_channel_write(struct class *cls, const char *_buf, size_t _count)\r
66 {\r
67     int ret, channel;\r
68     \r
69     if (wifi_enabled == 0)\r
70     {\r
71         printk("WiFi is disabled.\n");\r
72         return _count;\r
73     }\r
74     \r
75     channel = simple_strtol(_buf, NULL, 10);\r
76     \r
77     ret = wifi_emi_set_channel(channel);\r
78     if (ret != 0)\r
79     {\r
80         //printk("Set channel=%d fail.\n", channel);\r
81     }\r
82     else\r
83     {\r
84         //printk("Set channel=%d successfully.\n", channel);\r
85         wifi_channel = channel;\r
86     }\r
87     \r
88     return _count;\r
89 }\r
90 */\r
91 \r
92 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37))\r
93 static ssize_t wifi_p2p_read(struct class *cls, struct class_attribute *attr, char *_buf)\r
94 #else\r
95 static ssize_t wifi_p2p_read(struct class *cls, char *_buf)\r
96 #endif\r
97 {\r
98         int count = 0;\r
99 \r
100 #ifdef CONFIG_BCM4329\r
101     count = sprintf(_buf, "%s", "false");\r
102         printk("Current WiFi chip BCM4329 doesn't support direct.(%s)\n", _buf);\r
103 #endif\r
104 \r
105 #ifdef CONFIG_RTL8192CU\r
106     count = sprintf(_buf, "%s", "false");\r
107         printk("Current WiFi chip RTL8188 support direct.(%s)\n", _buf);\r
108 #endif\r
109 \r
110 #ifdef CONFIG_RK903\r
111     count = sprintf(_buf, "%s", "true");\r
112             printk("Current WiFi chip RK903 support direct.(%s)\n", _buf);\r
113 #endif\r
114 \r
115 #ifdef CONFIG_BCM4330\r
116     count = sprintf(_buf, "%s", "true");\r
117         printk("Current WiFi chip BCM4330 support direct.(%s)\n", _buf);\r
118 #endif\r
119 \r
120         return count;\r
121 }\r
122 \r
123 static struct class *rkwifi_class = NULL;\r
124 static CLASS_ATTR(chip, 0664, wifi_chip_read, NULL);\r
125 static CLASS_ATTR(p2p, 0664, wifi_p2p_read, NULL);\r
126 \r
127 int rkwifi_sysif_init(void)\r
128 {\r
129     int ret;\r
130     \r
131     printk("Rockchip WiFi SYS interface (V1.00) ... \n");\r
132     \r
133     rkwifi_class = NULL;\r
134     \r
135     rkwifi_class = class_create(THIS_MODULE, "rkwifi");\r
136     if (IS_ERR(rkwifi_class)) \r
137     {   \r
138         printk("Create class rkwifi_class failed.\n");\r
139         return -ENOMEM;\r
140     }\r
141     \r
142     ret =  class_create_file(rkwifi_class, &class_attr_chip);\r
143     ret =  class_create_file(rkwifi_class, &class_attr_p2p);\r
144     \r
145     return 0;\r
146 }\r
147 \r
148 void rkwifi_sysif_exit(void)\r
149 {\r
150     // need to remove the sys files and class\r
151     class_remove_file(rkwifi_class, &class_attr_chip);\r
152     class_destroy(rkwifi_class);\r
153     \r
154     rkwifi_class = NULL;\r
155 }\r
156 \r
157 module_init(rkwifi_sysif_init);\r
158 module_exit(rkwifi_sysif_exit);\r
159 \r
160 MODULE_AUTHOR("Yongle Lai");\r
161 MODULE_DESCRIPTION("WiFi SYS @ Rockchip");\r
162 MODULE_LICENSE("GPL");\r
163 \r