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
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
11 static ssize_t wifi_chip_read(struct class *cls, char *_buf)
\r
16 #ifdef CONFIG_BCM4329
\r
17 count = sprintf(_buf, "%s", "BCM4329");
\r
18 printk("Current WiFi chip is BCM4329.\n");
\r
21 #ifdef CONFIG_RTL8192CU
\r
22 count = sprintf(_buf, "%s", "RTL8188CU");
\r
23 printk("Current WiFi chip is RTL8188CU.\n");
\r
26 #ifdef CONFIG_RTL8188EU
\r
27 count = sprintf(_buf, "%s", "RTL8188EU");
\r
28 printk("Current WiFi chip is RTL8188EU.\n");
\r
31 #ifdef CONFIG_BCM4330
\r
32 count = sprintf(_buf, "%s", "BCM4330");
\r
33 printk("Current WiFi chip is BCM4330.\n");
\r
37 count = sprintf(_buf, "%s", "RK901");
\r
38 printk("Current WiFi chip is RK901.\n");
\r
42 count = sprintf(_buf, "%s", "RK903");
\r
43 printk("Current WiFi chip is RK903.\n");
\r
46 #ifdef CONFIG_RT5370
\r
47 count = sprintf(_buf, "%s", "RT5370");
\r
48 printk("Current WiFi chip is RT5370.\n");
\r
51 #ifdef CONFIG_MT5931
\r
52 count = sprintf(_buf, "%s", "MT5931");
\r
53 printk("Current WiFi chip is MT5931.\n");
\r
56 #ifdef CONFIG_MT5931_MT6622
\r
57 count = sprintf(_buf, "%s", "MT5931");
\r
58 printk("Current WiFi chip is MT5931.\n");
\r
65 static ssize_t wifi_channel_write(struct class *cls, const char *_buf, size_t _count)
\r
69 if (wifi_enabled == 0)
\r
71 printk("WiFi is disabled.\n");
\r
75 channel = simple_strtol(_buf, NULL, 10);
\r
77 ret = wifi_emi_set_channel(channel);
\r
80 //printk("Set channel=%d fail.\n", channel);
\r
84 //printk("Set channel=%d successfully.\n", channel);
\r
85 wifi_channel = channel;
\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
95 static ssize_t wifi_p2p_read(struct class *cls, char *_buf)
\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
105 #ifdef CONFIG_RTL8192CU
\r
106 count = sprintf(_buf, "%s", "false");
\r
107 printk("Current WiFi chip RTL8188 support direct.(%s)\n", _buf);
\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
115 #ifdef CONFIG_BCM4330
\r
116 count = sprintf(_buf, "%s", "true");
\r
117 printk("Current WiFi chip BCM4330 support direct.(%s)\n", _buf);
\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
127 int rkwifi_sysif_init(void)
\r
131 printk("Rockchip WiFi SYS interface (V1.00) ... \n");
\r
133 rkwifi_class = NULL;
\r
135 rkwifi_class = class_create(THIS_MODULE, "rkwifi");
\r
136 if (IS_ERR(rkwifi_class))
\r
138 printk("Create class rkwifi_class failed.\n");
\r
142 ret = class_create_file(rkwifi_class, &class_attr_chip);
\r
143 ret = class_create_file(rkwifi_class, &class_attr_p2p);
\r
148 void rkwifi_sysif_exit(void)
\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
154 rkwifi_class = NULL;
\r
157 module_init(rkwifi_sysif_init);
\r
158 module_exit(rkwifi_sysif_exit);
\r
160 MODULE_AUTHOR("Yongle Lai");
\r
161 MODULE_DESCRIPTION("WiFi SYS @ Rockchip");
\r
162 MODULE_LICENSE("GPL");
\r