Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nu11secur1ty
GitHub Repository: nu11secur1ty/Kali-Linux
Path: blob/master/ALFA-W1F1/RTL8814AU/platform/platform_ARM_SUNnI_sdio.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_SUN6I
19
* CONFIG_PLATFORM_ARM_SUN7I
20
* CONFIG_PLATFORM_ARM_SUN8I
21
*/
22
#include <drv_types.h>
23
#include <mach/sys_config.h>
24
#ifdef CONFIG_GPIO_WAKEUP
25
#include <linux/gpio.h>
26
#endif
27
28
#ifdef CONFIG_MMC
29
static int sdc_id = -1;
30
static signed int gpio_eint_wlan = -1;
31
static u32 eint_wlan_handle = 0;
32
33
#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
34
extern void sw_mci_rescan_card(unsigned id, unsigned insert);
35
#elif defined(CONFIG_PLATFORM_ARM_SUN8I)
36
extern void sunxi_mci_rescan_card(unsigned id, unsigned insert);
37
#endif
38
39
#ifdef CONFIG_PLATFORM_ARM_SUN8I_W5P1
40
extern int get_rf_mod_type(void);
41
#else
42
extern int wifi_pm_get_mod_type(void);
43
#endif
44
45
extern void wifi_pm_power(int on);
46
#ifdef CONFIG_GPIO_WAKEUP
47
extern unsigned int oob_irq;
48
#endif
49
#endif /* CONFIG_MMC */
50
51
/*
52
* Return:
53
* 0: power on successfully
54
* others: power on failed
55
*/
56
int platform_wifi_power_on(void)
57
{
58
int ret = 0;
59
60
#ifdef CONFIG_MMC
61
{
62
script_item_u val;
63
script_item_value_type_e type;
64
65
#ifdef CONFIG_PLATFORM_ARM_SUN8I_W5P1
66
unsigned int mod_sel = get_rf_mod_type();
67
#else
68
unsigned int mod_sel = wifi_pm_get_mod_type();
69
#endif
70
71
type = script_get_item("wifi_para", "wifi_sdc_id", &val);
72
if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
73
RTW_INFO("get wifi_sdc_id failed\n");
74
ret = -1;
75
} else {
76
sdc_id = val.val;
77
RTW_INFO("----- %s sdc_id: %d, mod_sel: %d\n", __FUNCTION__, sdc_id, mod_sel);
78
79
#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
80
sw_mci_rescan_card(sdc_id, 1);
81
#elif defined(CONFIG_PLATFORM_ARM_SUN8I)
82
sunxi_mci_rescan_card(sdc_id, 1);
83
#endif
84
mdelay(100);
85
wifi_pm_power(1);
86
87
RTW_INFO("%s: power up, rescan card.\n", __FUNCTION__);
88
}
89
90
#ifdef CONFIG_GPIO_WAKEUP
91
#ifdef CONFIG_PLATFORM_ARM_SUN8I_W5P1
92
type = script_get_item("wifi_para", "wl_host_wake", &val);
93
#else
94
#ifdef CONFIG_RTL8723B
95
type = script_get_item("wifi_para", "rtl8723bs_wl_host_wake", &val);
96
#endif
97
#ifdef CONFIG_RTL8188E
98
type = script_get_item("wifi_para", "rtl8189es_host_wake", &val);
99
#endif
100
#endif /* CONFIG_PLATFORM_ARM_SUN8I_W5P1 */
101
if (SCIRPT_ITEM_VALUE_TYPE_PIO != type) {
102
RTW_INFO("No definition of wake up host PIN\n");
103
ret = -1;
104
} else {
105
gpio_eint_wlan = val.gpio.gpio;
106
#ifdef CONFIG_PLATFORM_ARM_SUN8I
107
oob_irq = gpio_to_irq(gpio_eint_wlan);
108
#endif
109
}
110
#endif /* CONFIG_GPIO_WAKEUP */
111
}
112
#endif /* CONFIG_MMC */
113
114
return ret;
115
}
116
117
void platform_wifi_power_off(void)
118
{
119
#ifdef CONFIG_MMC
120
#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
121
sw_mci_rescan_card(sdc_id, 0);
122
#elif defined(CONFIG_PLATFORM_ARM_SUN8I)
123
sunxi_mci_rescan_card(sdc_id, 0);
124
#endif
125
mdelay(100);
126
wifi_pm_power(0);
127
128
RTW_INFO("%s: remove card, power off.\n", __FUNCTION__);
129
#endif /* CONFIG_MMC */
130
}
131
132