rtl_btc.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2009-2013 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. * The full GNU General Public License is included in this distribution in the
  15. * file called LICENSE.
  16. *
  17. * Contact Information:
  18. * wlanfae <wlanfae@realtek.com>
  19. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  20. * Hsinchu 300, Taiwan.
  21. *
  22. * Larry Finger <Larry.Finger@lwfinger.net>
  23. *
  24. *****************************************************************************/
  25. #include "../wifi.h"
  26. #include "rtl_btc.h"
  27. #include "halbt_precomp.h"
  28. #include <linux/vmalloc.h>
  29. #include <linux/module.h>
  30. static struct rtl_btc_ops rtl_btc_operation = {
  31. .btc_init_variables = rtl_btc_init_variables,
  32. .btc_init_hal_vars = rtl_btc_init_hal_vars,
  33. .btc_init_hw_config = rtl_btc_init_hw_config,
  34. .btc_ips_notify = rtl_btc_ips_notify,
  35. .btc_scan_notify = rtl_btc_scan_notify,
  36. .btc_connect_notify = rtl_btc_connect_notify,
  37. .btc_mediastatus_notify = rtl_btc_mediastatus_notify,
  38. .btc_periodical = rtl_btc_periodical,
  39. .btc_halt_notify = rtl_btc_halt_notify,
  40. .btc_btinfo_notify = rtl_btc_btinfo_notify,
  41. .btc_is_limited_dig = rtl_btc_is_limited_dig,
  42. .btc_is_disable_edca_turbo = rtl_btc_is_disable_edca_turbo,
  43. .btc_is_bt_disabled = rtl_btc_is_bt_disabled,
  44. };
  45. void rtl_btc_init_variables(struct rtl_priv *rtlpriv)
  46. {
  47. exhalbtc_initlize_variables(rtlpriv);
  48. }
  49. void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv)
  50. {
  51. u8 ant_num;
  52. u8 bt_exist;
  53. u8 bt_type;
  54. ant_num = rtl_get_hwpg_ant_num(rtlpriv);
  55. RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
  56. "%s, antNum is %d\n", __func__, ant_num);
  57. bt_exist = rtl_get_hwpg_bt_exist(rtlpriv);
  58. RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
  59. "%s, bt_exist is %d\n", __func__, bt_exist);
  60. exhalbtc_set_bt_exist(bt_exist);
  61. bt_type = rtl_get_hwpg_bt_type(rtlpriv);
  62. RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "%s, bt_type is %d\n",
  63. __func__, bt_type);
  64. exhalbtc_set_chip_type(bt_type);
  65. exhalbtc_set_ant_num(BT_COEX_ANT_TYPE_PG, ant_num);
  66. }
  67. void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv)
  68. {
  69. exhalbtc_init_hw_config(&gl_bt_coexist);
  70. exhalbtc_init_coex_dm(&gl_bt_coexist);
  71. }
  72. void rtl_btc_ips_notify(struct rtl_priv *rtlpriv, u8 type)
  73. {
  74. exhalbtc_ips_notify(&gl_bt_coexist, type);
  75. }
  76. void rtl_btc_scan_notify(struct rtl_priv *rtlpriv, u8 scantype)
  77. {
  78. exhalbtc_scan_notify(&gl_bt_coexist, scantype);
  79. }
  80. void rtl_btc_connect_notify(struct rtl_priv *rtlpriv, u8 action)
  81. {
  82. exhalbtc_connect_notify(&gl_bt_coexist, action);
  83. }
  84. void rtl_btc_mediastatus_notify(struct rtl_priv *rtlpriv,
  85. enum _RT_MEDIA_STATUS mstatus)
  86. {
  87. exhalbtc_mediastatus_notify(&gl_bt_coexist, mstatus);
  88. }
  89. void rtl_btc_periodical(struct rtl_priv *rtlpriv)
  90. {
  91. exhalbtc_periodical(&gl_bt_coexist);
  92. }
  93. void rtl_btc_halt_notify(void)
  94. {
  95. exhalbtc_halt_notify(&gl_bt_coexist);
  96. }
  97. void rtl_btc_btinfo_notify(struct rtl_priv *rtlpriv, u8 *tmp_buf, u8 length)
  98. {
  99. exhalbtc_bt_info_notify(&gl_bt_coexist, tmp_buf, length);
  100. }
  101. bool rtl_btc_is_limited_dig(struct rtl_priv *rtlpriv)
  102. {
  103. return gl_bt_coexist.bt_info.limited_dig;
  104. }
  105. bool rtl_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv)
  106. {
  107. bool bt_change_edca = false;
  108. u32 cur_edca_val;
  109. u32 edca_bt_hs_uplink = 0x5ea42b, edca_bt_hs_downlink = 0x5ea42b;
  110. u32 edca_hs;
  111. u32 edca_addr = 0x504;
  112. cur_edca_val = rtl_read_dword(rtlpriv, edca_addr);
  113. if (halbtc_is_wifi_uplink(rtlpriv)) {
  114. if (cur_edca_val != edca_bt_hs_uplink) {
  115. edca_hs = edca_bt_hs_uplink;
  116. bt_change_edca = true;
  117. }
  118. } else {
  119. if (cur_edca_val != edca_bt_hs_downlink) {
  120. edca_hs = edca_bt_hs_downlink;
  121. bt_change_edca = true;
  122. }
  123. }
  124. if (bt_change_edca)
  125. rtl_write_dword(rtlpriv, edca_addr, edca_hs);
  126. return true;
  127. }
  128. bool rtl_btc_is_bt_disabled(struct rtl_priv *rtlpriv)
  129. {
  130. if (gl_bt_coexist.bt_info.bt_disabled)
  131. return true;
  132. else
  133. return false;
  134. }
  135. struct rtl_btc_ops *rtl_btc_get_ops_pointer(void)
  136. {
  137. return &rtl_btc_operation;
  138. }
  139. EXPORT_SYMBOL(rtl_btc_get_ops_pointer);
  140. u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
  141. {
  142. u8 num;
  143. if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2)
  144. num = 2;
  145. else
  146. num = 1;
  147. return num;
  148. }
  149. enum _RT_MEDIA_STATUS mgnt_link_status_query(struct ieee80211_hw *hw)
  150. {
  151. struct rtl_priv *rtlpriv = rtl_priv(hw);
  152. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  153. enum _RT_MEDIA_STATUS m_status = RT_MEDIA_DISCONNECT;
  154. u8 bibss = (mac->opmode == NL80211_IFTYPE_ADHOC) ? 1 : 0;
  155. if (bibss || rtlpriv->mac80211.link_state >= MAC80211_LINKED)
  156. m_status = RT_MEDIA_CONNECT;
  157. return m_status;
  158. }
  159. u8 rtl_get_hwpg_bt_exist(struct rtl_priv *rtlpriv)
  160. {
  161. return rtlpriv->btcoexist.btc_info.btcoexist;
  162. }
  163. u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv)
  164. {
  165. return rtlpriv->btcoexist.btc_info.bt_type;
  166. }
  167. MODULE_AUTHOR("Page He <page_he@realsil.com.cn>");
  168. MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
  169. MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>");
  170. MODULE_LICENSE("GPL");
  171. MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core");
  172. static int __init rtl_btcoexist_module_init(void)
  173. {
  174. return 0;
  175. }
  176. static void __exit rtl_btcoexist_module_exit(void)
  177. {
  178. return;
  179. }
  180. module_init(rtl_btcoexist_module_init);
  181. module_exit(rtl_btcoexist_module_exit);