platform_ARM_SUN50IW1P1_sdio.c 2.2 KB

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