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