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_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
#include <drv_types.h>
16
17
#ifdef CONFIG_MMC_SUNXI_POWER_CONTROL
18
#ifdef CONFIG_WITS_EVB_V13
19
#define SDIOID 0
20
#else /* !CONFIG_WITS_EVB_V13 */
21
#define SDIOID (CONFIG_CHIP_ID == 1123 ? 3 : 1)
22
#endif /* !CONFIG_WITS_EVB_V13 */
23
24
#define SUNXI_SDIO_WIFI_NUM_RTL8189ES 10
25
extern void sunximmc_rescan_card(unsigned id, unsigned insert);
26
extern int mmc_pm_get_mod_type(void);
27
extern int mmc_pm_gpio_ctrl(char *name, int level);
28
/*
29
* rtl8189es_shdn = port:PH09<1><default><default><0>
30
* rtl8189es_wakeup = port:PH10<1><default><default><1>
31
* rtl8189es_vdd_en = port:PH11<1><default><default><0>
32
* rtl8189es_vcc_en = port:PH12<1><default><default><0>
33
*/
34
35
int rtl8189es_sdio_powerup(void)
36
{
37
mmc_pm_gpio_ctrl("rtl8189es_vdd_en", 1);
38
udelay(100);
39
mmc_pm_gpio_ctrl("rtl8189es_vcc_en", 1);
40
udelay(50);
41
mmc_pm_gpio_ctrl("rtl8189es_shdn", 1);
42
return 0;
43
}
44
45
int rtl8189es_sdio_poweroff(void)
46
{
47
mmc_pm_gpio_ctrl("rtl8189es_shdn", 0);
48
mmc_pm_gpio_ctrl("rtl8189es_vcc_en", 0);
49
mmc_pm_gpio_ctrl("rtl8189es_vdd_en", 0);
50
return 0;
51
}
52
#endif /* CONFIG_MMC_SUNXI_POWER_CONTROL */
53
54
/*
55
* Return:
56
* 0: power on successfully
57
* others: power on failed
58
*/
59
int platform_wifi_power_on(void)
60
{
61
int ret = 0;
62
#ifdef CONFIG_MMC_SUNXI_POWER_CONTROL
63
unsigned int mod_sel = mmc_pm_get_mod_type();
64
#endif /* CONFIG_MMC_SUNXI_POWER_CONTROL */
65
66
67
#ifdef CONFIG_MMC_SUNXI_POWER_CONTROL
68
if (mod_sel == SUNXI_SDIO_WIFI_NUM_RTL8189ES) {
69
rtl8189es_sdio_powerup();
70
sunximmc_rescan_card(SDIOID, 1);
71
printk("[rtl8189es] %s: power up, rescan card.\n", __FUNCTION__);
72
} else {
73
ret = -1;
74
printk("[rtl8189es] %s: mod_sel = %d is incorrect.\n", __FUNCTION__, mod_sel);
75
}
76
#endif /* CONFIG_MMC_SUNXI_POWER_CONTROL */
77
78
return ret;
79
}
80
81
void platform_wifi_power_off(void)
82
{
83
#ifdef CONFIG_MMC_SUNXI_POWER_CONTROL
84
sunximmc_rescan_card(SDIOID, 0);
85
#ifdef CONFIG_RTL8188E
86
rtl8189es_sdio_poweroff();
87
printk("[rtl8189es] %s: remove card, power off.\n", __FUNCTION__);
88
#endif /* CONFIG_RTL8188E */
89
#endif /* CONFIG_MMC_SUNXI_POWER_CONTROL */
90
}
91
92