platform_ARM_SUNxI_usb.c 3.8 KB

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