net: wireless: rockchip_wlan: add rtl8723cs support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723cs / platform / platform_sprd_sdio.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 #include <drv_types.h>
21
22 extern void sdhci_bus_scan(void);
23 #ifndef ANDROID_2X
24 extern int sdhci_device_attached(void);
25 #endif
26
27 /*
28  * Return:
29  *      0:      power on successfully
30  *      others: power on failed
31  */
32 int platform_wifi_power_on(void)
33 {
34         int ret = 0;
35
36
37 #ifdef CONFIG_RTL8188E
38         rtw_wifi_gpio_wlan_ctrl(WLAN_POWER_ON);
39 #endif /* CONFIG_RTL8188E */
40
41         /* Pull up pwd pin, make wifi leave power down mode. */
42         rtw_wifi_gpio_init();
43         rtw_wifi_gpio_wlan_ctrl(WLAN_PWDN_ON);
44
45 #if (MP_DRIVER == 1) && (defined(CONFIG_RTL8723A) || defined(CONFIG_RTL8723B))
46         /* Pull up BT reset pin. */
47         rtw_wifi_gpio_wlan_ctrl(WLAN_BT_PWDN_ON);
48 #endif
49         rtw_mdelay_os(5);
50
51         sdhci_bus_scan();
52 #ifdef CONFIG_RTL8723B
53         /* YJ,test,130305 */
54         rtw_mdelay_os(1000);
55 #endif
56 #ifdef ANDROID_2X
57         rtw_mdelay_os(200);
58 #else /* !ANDROID_2X */
59         if (1) {
60                 int i = 0;
61
62                 for (i = 0; i <= 50; i++) {
63                         msleep(10);
64                         if (sdhci_device_attached())
65                                 break;
66                         printk("%s delay times:%d\n", __func__, i);
67                 }
68         }
69 #endif /* !ANDROID_2X */
70
71         return ret;
72 }
73
74 void platform_wifi_power_off(void)
75 {
76         /* Pull down pwd pin, make wifi enter power down mode. */
77         rtw_wifi_gpio_wlan_ctrl(WLAN_PWDN_OFF);
78         rtw_mdelay_os(5);
79         rtw_wifi_gpio_deinit();
80
81 #ifdef CONFIG_RTL8188E
82         rtw_wifi_gpio_wlan_ctrl(WLAN_POWER_OFF);
83 #endif /* CONFIG_RTL8188E */
84
85 #ifdef CONFIG_WOWLAN
86         if (mmc_host)
87                 mmc_host->pm_flags &= ~MMC_PM_KEEP_POWER;
88 #endif /* CONFIG_WOWLAN */
89 }