platform_sprd_sdio.c 2.0 KB

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