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