Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nu11secur1ty
GitHub Repository: nu11secur1ty/Kali-Linux
Path: blob/master/ALFA-W1F1/RTL8814AU/platform/platform_ARM_SUN50IW1P1_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_SUN50IW1P1
19
*/
20
#include <drv_types.h>
21
#ifdef CONFIG_GPIO_WAKEUP
22
#include <linux/gpio.h>
23
#endif
24
25
#ifdef CONFIG_MMC
26
#if defined(CONFIG_PLATFORM_ARM_SUN50IW1P1)
27
extern void sunxi_mmc_rescan_card(unsigned ids);
28
extern void sunxi_wlan_set_power(int on);
29
extern int sunxi_wlan_get_bus_index(void);
30
extern int sunxi_wlan_get_oob_irq(void);
31
extern int sunxi_wlan_get_oob_irq_flags(void);
32
#endif
33
#ifdef CONFIG_GPIO_WAKEUP
34
extern unsigned int oob_irq;
35
#endif
36
#endif /* CONFIG_MMC */
37
38
/*
39
* Return:
40
* 0: power on successfully
41
* others: power on failed
42
*/
43
int platform_wifi_power_on(void)
44
{
45
int ret = 0;
46
47
#ifdef CONFIG_MMC
48
{
49
50
#if defined(CONFIG_PLATFORM_ARM_SUN50IW1P1)
51
int wlan_bus_index = sunxi_wlan_get_bus_index();
52
if (wlan_bus_index < 0)
53
return wlan_bus_index;
54
55
sunxi_wlan_set_power(1);
56
mdelay(100);
57
sunxi_mmc_rescan_card(wlan_bus_index);
58
#endif
59
RTW_INFO("%s: power up, rescan card.\n", __FUNCTION__);
60
61
#ifdef CONFIG_GPIO_WAKEUP
62
#if defined(CONFIG_PLATFORM_ARM_SUN50IW1P1)
63
oob_irq = sunxi_wlan_get_oob_irq();
64
#endif
65
#endif /* CONFIG_GPIO_WAKEUP */
66
}
67
#endif /* CONFIG_MMC */
68
69
return ret;
70
}
71
72
void platform_wifi_power_off(void)
73
{
74
#ifdef CONFIG_MMC
75
#if defined(CONFIG_PLATFORM_ARM_SUN50IW1P1)
76
int wlan_bus_index = sunxi_wlan_get_bus_index();
77
if (wlan_bus_index < 0)
78
return;
79
80
sunxi_mmc_rescan_card(wlan_bus_index);
81
mdelay(100);
82
sunxi_wlan_set_power(0);
83
#endif
84
RTW_INFO("%s: remove card, power off.\n", __FUNCTION__);
85
#endif /* CONFIG_MMC */
86
}
87
88