a4e2502fe5b9e4cf729988a6916f3bb3985451dc
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723bs / platform / platform_sprd_sdio.c
1 /******************************************************************************\r
2  *\r
3  * Copyright(c) 2013 Realtek Corporation. All rights reserved.\r
4  *\r
5  * This program is free software; you can redistribute it and/or modify it\r
6  * under the terms of version 2 of the GNU General Public License as\r
7  * published by the Free Software Foundation.\r
8  *\r
9  * This program is distributed in the hope that it will be useful, but WITHOUT\r
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
12  * more details.\r
13  *\r
14  * You should have received a copy of the GNU General Public License along with\r
15  * this program; if not, write to the Free Software Foundation, Inc.,\r
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA\r
17  *\r
18  *\r
19  ******************************************************************************/\r
20 #include <drv_types.h>\r
21 \r
22 extern void sdhci_bus_scan(void);\r
23 #ifndef ANDROID_2X\r
24 extern int sdhci_device_attached(void);\r
25 #endif\r
26 \r
27 /*\r
28  * Return:\r
29  *      0:      power on successfully\r
30  *      others: power on failed\r
31  */\r
32 int platform_wifi_power_on(void)\r
33 {\r
34         int ret = 0;\r
35 \r
36 \r
37 #ifdef CONFIG_RTL8188E\r
38         rtw_wifi_gpio_wlan_ctrl(WLAN_POWER_ON);\r
39 #endif // CONFIG_RTL8188E\r
40 \r
41         /* Pull up pwd pin, make wifi leave power down mode. */\r
42         rtw_wifi_gpio_init();\r
43         rtw_wifi_gpio_wlan_ctrl(WLAN_PWDN_ON);\r
44 \r
45 #if (MP_DRIVER == 1) && (defined(CONFIG_RTL8723A)||defined(CONFIG_RTL8723B))\r
46         // Pull up BT reset pin.\r
47         rtw_wifi_gpio_wlan_ctrl(WLAN_BT_PWDN_ON);\r
48 #endif\r
49         rtw_mdelay_os(5);\r
50 \r
51         sdhci_bus_scan();\r
52 #ifdef CONFIG_RTL8723B\r
53         //YJ,test,130305\r
54         rtw_mdelay_os(1000);\r
55 #endif\r
56 #ifdef ANDROID_2X\r
57         rtw_mdelay_os(200);\r
58 #else // !ANDROID_2X\r
59         if (1) {\r
60                 int i = 0;\r
61 \r
62                 for (i = 0; i <= 50; i++) {\r
63                         msleep(10);\r
64                         if (sdhci_device_attached())\r
65                                 break;\r
66                         printk("%s delay times:%d\n", __func__, i);\r
67                 }\r
68         }\r
69 #endif // !ANDROID_2X\r
70 \r
71         return ret;\r
72 }\r
73 \r
74 void platform_wifi_power_off(void)\r
75 {\r
76         /* Pull down pwd pin, make wifi enter power down mode. */\r
77         rtw_wifi_gpio_wlan_ctrl(WLAN_PWDN_OFF);\r
78         rtw_mdelay_os(5);\r
79         rtw_wifi_gpio_deinit();\r
80 \r
81 #ifdef CONFIG_RTL8188E\r
82         rtw_wifi_gpio_wlan_ctrl(WLAN_POWER_OFF);\r
83 #endif // CONFIG_RTL8188E\r
84 \r
85 #ifdef CONFIG_WOWLAN\r
86         if(mmc_host)\r
87                 mmc_host->pm_flags &= ~MMC_PM_KEEP_POWER;\r
88 #endif // CONFIG_WOWLAN\r
89 }\r