Merge branch 'develop-3.10-next' of 10.10.10.29:rk/kernel into develop-3.10-next
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723bu / platform / platform_ARM_SUNxI_usb.c
1 /******************************************************************************\r
2  *\r
3  * Copyright(c) 2013 Realtek Corporation. All rights reserved.\r
4  *\r
5  * This program is free software; you can redistribute it and/or modify it\r
6  * under the terms of version 2 of the GNU General Public License as\r
7  * published by the Free Software Foundation.\r
8  *\r
9  * This program is distributed in the hope that it will be useful, but WITHOUT\r
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
12  * more details.\r
13  *\r
14  * You should have received a copy of the GNU General Public License along with\r
15  * this program; if not, write to the Free Software Foundation, Inc.,\r
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA\r
17  *\r
18  *\r
19  ******************************************************************************/\r
20 /*\r
21  * Description:\r
22  *      This file can be applied to following platforms:\r
23  *      CONFIG_PLATFORM_ARM_SUNXI Series platform \r
24  *      \r
25  */\r
26  \r
27 #include <drv_types.h>\r
28 #include <mach/sys_config.h>\r
29 \r
30 #ifdef CONFIG_PLATFORM_ARM_SUNxI\r
31 extern int sw_usb_disable_hcd(__u32 usbc_no);\r
32 extern int sw_usb_enable_hcd(__u32 usbc_no);\r
33 static int usb_wifi_host = 2;\r
34 #endif\r
35 \r
36 #if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)\r
37 extern int sw_usb_disable_hcd(__u32 usbc_no);\r
38 extern int sw_usb_enable_hcd(__u32 usbc_no);\r
39 extern void wifi_pm_power(int on);\r
40 static script_item_u item;\r
41 #endif\r
42 \r
43 #ifdef CONFIG_PLATFORM_ARM_SUN8I\r
44 extern int sunxi_usb_disable_hcd(__u32 usbc_no);\r
45 extern int sunxi_usb_enable_hcd(__u32 usbc_no);\r
46 extern void wifi_pm_power(int on);\r
47 static script_item_u item;\r
48 #endif\r
49 \r
50 \r
51 int platform_wifi_power_on(void)\r
52 {\r
53         int ret = 0;\r
54 \r
55 #ifdef CONFIG_PLATFORM_ARM_SUNxI\r
56 #ifndef CONFIG_RTL8723A\r
57         {\r
58                 /* ----------get usb_wifi_usbc_num------------- */\r
59                 ret = script_parser_fetch("usb_wifi_para", "usb_wifi_usbc_num", (int *)&usb_wifi_host, 64);\r
60                 if(ret != 0){\r
61                         DBG_8192C("ERR: script_parser_fetch usb_wifi_usbc_num failed\n");\r
62                         ret = -ENOMEM;\r
63                         goto exit;\r
64                 }\r
65                 DBG_8192C("sw_usb_enable_hcd: usbc_num = %d\n", usb_wifi_host);\r
66                 sw_usb_enable_hcd(usb_wifi_host);\r
67         }\r
68 #endif //CONFIG_RTL8723A\r
69 #endif //CONFIG_PLATFORM_ARM_SUNxI\r
70 \r
71 #if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)\r
72         {\r
73                 script_item_value_type_e type;\r
74 \r
75                 type = script_get_item("wifi_para", "wifi_usbc_id", &item);\r
76                 if(SCIRPT_ITEM_VALUE_TYPE_INT != type){\r
77                         printk("ERR: script_get_item wifi_usbc_id failed\n");\r
78                         ret = -ENOMEM;\r
79                         goto exit;\r
80                 }\r
81 \r
82                 printk("sw_usb_enable_hcd: usbc_num = %d\n", item.val);\r
83                 wifi_pm_power(1);\r
84                 mdelay(10);\r
85         \r
86                 #if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))\r
87                 sw_usb_enable_hcd(item.val);\r
88                 #endif\r
89         }\r
90 #endif //defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)\r
91 \r
92 #if defined(CONFIG_PLATFORM_ARM_SUN8I)\r
93         {\r
94                 script_item_value_type_e type;\r
95 \r
96                 type = script_get_item("wifi_para", "wifi_usbc_id", &item);\r
97                 if(SCIRPT_ITEM_VALUE_TYPE_INT != type){\r
98                         printk("ERR: script_get_item wifi_usbc_id failed\n");\r
99                         ret = -ENOMEM;\r
100                         goto exit;\r
101                 }\r
102 \r
103                 printk("sw_usb_enable_hcd: usbc_num = %d\n", item.val);\r
104                 wifi_pm_power(1);\r
105                 mdelay(10);\r
106         \r
107                 #if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))\r
108                 sunxi_usb_enable_hcd(item.val);\r
109                 #endif\r
110         }\r
111 #endif //CONFIG_PLATFORM_ARM_SUN8I\r
112 \r
113 exit:\r
114         return ret;\r
115 }\r
116 \r
117 void platform_wifi_power_off(void)\r
118 {\r
119 \r
120 #ifdef CONFIG_PLATFORM_ARM_SUNxI\r
121 #ifndef CONFIG_RTL8723A\r
122         DBG_8192C("sw_usb_disable_hcd: usbc_num = %d\n", usb_wifi_host);\r
123         sw_usb_disable_hcd(usb_wifi_host);\r
124 #endif //ifndef CONFIG_RTL8723A\r
125 #endif  //CONFIG_PLATFORM_ARM_SUNxI\r
126 \r
127 #if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)\r
128         #if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))\r
129         sw_usb_disable_hcd(item.val);\r
130         #endif\r
131         wifi_pm_power(0);\r
132 #endif //defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)\r
133 \r
134 #if defined(CONFIG_PLATFORM_ARM_SUN8I)\r
135         #if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))\r
136         sunxi_usb_disable_hcd(item.val);\r
137         #endif\r
138         wifi_pm_power(0);\r
139 #endif //defined(CONFIG_PLATFORM_ARM_SUN8I) \r
140 \r
141 }\r
142 \r