platform_ARM_SUNxI_usb.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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_SUNXI Series platform
  24. *
  25. */
  26. #include <drv_types.h>
  27. #include <mach/sys_config.h>
  28. #ifdef CONFIG_PLATFORM_ARM_SUNxI
  29. extern int sw_usb_disable_hcd(__u32 usbc_no);
  30. extern int sw_usb_enable_hcd(__u32 usbc_no);
  31. static int usb_wifi_host = 2;
  32. #endif
  33. #if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
  34. extern int sw_usb_disable_hcd(__u32 usbc_no);
  35. extern int sw_usb_enable_hcd(__u32 usbc_no);
  36. extern void wifi_pm_power(int on);
  37. static script_item_u item;
  38. #endif
  39. #ifdef CONFIG_PLATFORM_ARM_SUN8I
  40. extern int sunxi_usb_disable_hcd(__u32 usbc_no);
  41. extern int sunxi_usb_enable_hcd(__u32 usbc_no);
  42. extern void wifi_pm_power(int on);
  43. static script_item_u item;
  44. #endif
  45. int platform_wifi_power_on(void)
  46. {
  47. int ret = 0;
  48. #ifdef CONFIG_PLATFORM_ARM_SUNxI
  49. #ifndef CONFIG_RTL8723A
  50. {
  51. /* ----------get usb_wifi_usbc_num------------- */
  52. ret = script_parser_fetch("usb_wifi_para", "usb_wifi_usbc_num", (int *)&usb_wifi_host, 64);
  53. if (ret != 0) {
  54. RTW_INFO("ERR: script_parser_fetch usb_wifi_usbc_num failed\n");
  55. ret = -ENOMEM;
  56. goto exit;
  57. }
  58. RTW_INFO("sw_usb_enable_hcd: usbc_num = %d\n", usb_wifi_host);
  59. sw_usb_enable_hcd(usb_wifi_host);
  60. }
  61. #endif /* CONFIG_RTL8723A */
  62. #endif /* CONFIG_PLATFORM_ARM_SUNxI */
  63. #if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
  64. {
  65. script_item_value_type_e type;
  66. type = script_get_item("wifi_para", "wifi_usbc_id", &item);
  67. if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
  68. printk("ERR: script_get_item wifi_usbc_id failed\n");
  69. ret = -ENOMEM;
  70. goto exit;
  71. }
  72. printk("sw_usb_enable_hcd: usbc_num = %d\n", item.val);
  73. wifi_pm_power(1);
  74. mdelay(10);
  75. #if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
  76. sw_usb_enable_hcd(item.val);
  77. #endif
  78. }
  79. #endif /* defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I) */
  80. #if defined(CONFIG_PLATFORM_ARM_SUN8I)
  81. {
  82. script_item_value_type_e type;
  83. type = script_get_item("wifi_para", "wifi_usbc_id", &item);
  84. if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
  85. printk("ERR: script_get_item wifi_usbc_id failed\n");
  86. ret = -ENOMEM;
  87. goto exit;
  88. }
  89. printk("sw_usb_enable_hcd: usbc_num = %d\n", item.val);
  90. wifi_pm_power(1);
  91. mdelay(10);
  92. #if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
  93. sunxi_usb_enable_hcd(item.val);
  94. #endif
  95. }
  96. #endif /* CONFIG_PLATFORM_ARM_SUN8I */
  97. exit:
  98. return ret;
  99. }
  100. void platform_wifi_power_off(void)
  101. {
  102. #ifdef CONFIG_PLATFORM_ARM_SUNxI
  103. #ifndef CONFIG_RTL8723A
  104. RTW_INFO("sw_usb_disable_hcd: usbc_num = %d\n", usb_wifi_host);
  105. sw_usb_disable_hcd(usb_wifi_host);
  106. #endif /* ifndef CONFIG_RTL8723A */
  107. #endif /* CONFIG_PLATFORM_ARM_SUNxI */
  108. #if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
  109. #if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
  110. sw_usb_disable_hcd(item.val);
  111. #endif
  112. wifi_pm_power(0);
  113. #endif /* defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I) */
  114. #if defined(CONFIG_PLATFORM_ARM_SUN8I)
  115. #if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
  116. sunxi_usb_disable_hcd(item.val);
  117. #endif
  118. wifi_pm_power(0);
  119. #endif /* defined(CONFIG_PLATFORM_ARM_SUN8I) */
  120. }