platform_ARM_SUN50IW1P1_sdio.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. /*
  21. * Description:
  22. * This file can be applied to following platforms:
  23. * CONFIG_PLATFORM_ARM_SUN50IW1P1
  24. */
  25. #include <drv_types.h>
  26. #ifdef CONFIG_GPIO_WAKEUP
  27. #include <linux/gpio.h>
  28. #endif
  29. #ifdef CONFIG_MMC
  30. #if defined(CONFIG_PLATFORM_ARM_SUN50IW1P1)
  31. extern void sunxi_mmc_rescan_card(unsigned ids);
  32. extern void sunxi_wlan_set_power(int on);
  33. extern int sunxi_wlan_get_bus_index(void);
  34. extern int sunxi_wlan_get_oob_irq(void);
  35. extern int sunxi_wlan_get_oob_irq_flags(void);
  36. #endif
  37. #ifdef CONFIG_GPIO_WAKEUP
  38. extern unsigned int oob_irq;
  39. #endif
  40. #endif /* CONFIG_MMC */
  41. /*
  42. * Return:
  43. * 0: power on successfully
  44. * others: power on failed
  45. */
  46. int platform_wifi_power_on(void)
  47. {
  48. int ret = 0;
  49. #ifdef CONFIG_MMC
  50. {
  51. #if defined(CONFIG_PLATFORM_ARM_SUN50IW1P1)
  52. int wlan_bus_index = sunxi_wlan_get_bus_index();
  53. if (wlan_bus_index < 0)
  54. return wlan_bus_index;
  55. sunxi_wlan_set_power(1);
  56. mdelay(100);
  57. sunxi_mmc_rescan_card(wlan_bus_index);
  58. #endif
  59. RTW_INFO("%s: power up, rescan card.\n", __FUNCTION__);
  60. #ifdef CONFIG_GPIO_WAKEUP
  61. #if defined(CONFIG_PLATFORM_ARM_SUN50IW1P1)
  62. oob_irq = sunxi_wlan_get_oob_irq();
  63. #endif
  64. #endif /* CONFIG_GPIO_WAKEUP */
  65. }
  66. #endif /* CONFIG_MMC */
  67. return ret;
  68. }
  69. void platform_wifi_power_off(void)
  70. {
  71. #ifdef CONFIG_MMC
  72. #if defined(CONFIG_PLATFORM_ARM_SUN50IW1P1)
  73. int wlan_bus_index = sunxi_wlan_get_bus_index();
  74. if (wlan_bus_index < 0)
  75. return;
  76. sunxi_mmc_rescan_card(wlan_bus_index);
  77. mdelay(100);
  78. sunxi_wlan_set_power(0);
  79. #endif
  80. RTW_INFO("%s: remove card, power off.\n", __FUNCTION__);
  81. #endif /* CONFIG_MMC */
  82. }