Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nu11secur1ty
GitHub Repository: nu11secur1ty/Kali-Linux
Path: blob/master/ALFA-W1F1/RTL8814AU/platform/platform_ARM_SUNxI_usb.c
1307 views
1
/******************************************************************************
2
*
3
* Copyright(c) 2013 - 2017 Realtek Corporation.
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
*****************************************************************************/
15
/*
16
* Description:
17
* This file can be applied to following platforms:
18
* CONFIG_PLATFORM_ARM_SUNXI Series platform
19
*
20
*/
21
22
#include <drv_types.h>
23
#include <mach/sys_config.h>
24
25
#ifdef CONFIG_PLATFORM_ARM_SUNxI
26
extern int sw_usb_disable_hcd(__u32 usbc_no);
27
extern int sw_usb_enable_hcd(__u32 usbc_no);
28
static int usb_wifi_host = 2;
29
#endif
30
31
#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
32
extern int sw_usb_disable_hcd(__u32 usbc_no);
33
extern int sw_usb_enable_hcd(__u32 usbc_no);
34
extern void wifi_pm_power(int on);
35
static script_item_u item;
36
#endif
37
38
#ifdef CONFIG_PLATFORM_ARM_SUN8I
39
extern int sunxi_usb_disable_hcd(__u32 usbc_no);
40
extern int sunxi_usb_enable_hcd(__u32 usbc_no);
41
extern void wifi_pm_power(int on);
42
static script_item_u item;
43
#endif
44
45
46
int platform_wifi_power_on(void)
47
{
48
int ret = 0;
49
50
#ifdef CONFIG_PLATFORM_ARM_SUNxI
51
#ifndef CONFIG_RTL8723A
52
{
53
/* ----------get usb_wifi_usbc_num------------- */
54
ret = script_parser_fetch("usb_wifi_para", "usb_wifi_usbc_num", (int *)&usb_wifi_host, 64);
55
if (ret != 0) {
56
RTW_INFO("ERR: script_parser_fetch usb_wifi_usbc_num failed\n");
57
ret = -ENOMEM;
58
goto exit;
59
}
60
RTW_INFO("sw_usb_enable_hcd: usbc_num = %d\n", usb_wifi_host);
61
sw_usb_enable_hcd(usb_wifi_host);
62
}
63
#endif /* CONFIG_RTL8723A */
64
#endif /* CONFIG_PLATFORM_ARM_SUNxI */
65
66
#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
67
{
68
script_item_value_type_e type;
69
70
type = script_get_item("wifi_para", "wifi_usbc_id", &item);
71
if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
72
printk("ERR: script_get_item wifi_usbc_id failed\n");
73
ret = -ENOMEM;
74
goto exit;
75
}
76
77
printk("sw_usb_enable_hcd: usbc_num = %d\n", item.val);
78
wifi_pm_power(1);
79
mdelay(10);
80
81
#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
82
sw_usb_enable_hcd(item.val);
83
#endif
84
}
85
#endif /* defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I) */
86
87
#if defined(CONFIG_PLATFORM_ARM_SUN8I)
88
{
89
script_item_value_type_e type;
90
91
type = script_get_item("wifi_para", "wifi_usbc_id", &item);
92
if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
93
printk("ERR: script_get_item wifi_usbc_id failed\n");
94
ret = -ENOMEM;
95
goto exit;
96
}
97
98
printk("sw_usb_enable_hcd: usbc_num = %d\n", item.val);
99
wifi_pm_power(1);
100
mdelay(10);
101
102
#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
103
sunxi_usb_enable_hcd(item.val);
104
#endif
105
}
106
#endif /* CONFIG_PLATFORM_ARM_SUN8I */
107
108
exit:
109
return ret;
110
}
111
112
void platform_wifi_power_off(void)
113
{
114
115
#ifdef CONFIG_PLATFORM_ARM_SUNxI
116
#ifndef CONFIG_RTL8723A
117
RTW_INFO("sw_usb_disable_hcd: usbc_num = %d\n", usb_wifi_host);
118
sw_usb_disable_hcd(usb_wifi_host);
119
#endif /* ifndef CONFIG_RTL8723A */
120
#endif /* CONFIG_PLATFORM_ARM_SUNxI */
121
122
#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
123
#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
124
sw_usb_disable_hcd(item.val);
125
#endif
126
wifi_pm_power(0);
127
#endif /* defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I) */
128
129
#if defined(CONFIG_PLATFORM_ARM_SUN8I)
130
#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
131
sunxi_usb_disable_hcd(item.val);
132
#endif
133
wifi_pm_power(0);
134
#endif /* defined(CONFIG_PLATFORM_ARM_SUN8I) */
135
136
}
137
138