platform_sprd_sdio.c 2.2 KB

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