rtl_btc.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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 <linux/vmalloc.h>
  27. #include <linux/module.h>
  28. #include "rtl_btc.h"
  29. #include "halbt_precomp.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_lps_notify = rtl_btc_lps_notify,
  36. .btc_scan_notify = rtl_btc_scan_notify,
  37. .btc_connect_notify = rtl_btc_connect_notify,
  38. .btc_mediastatus_notify = rtl_btc_mediastatus_notify,
  39. .btc_periodical = rtl_btc_periodical,
  40. .btc_halt_notify = rtl_btc_halt_notify,
  41. .btc_btinfo_notify = rtl_btc_btinfo_notify,
  42. .btc_is_limited_dig = rtl_btc_is_limited_dig,
  43. .btc_is_disable_edca_turbo = rtl_btc_is_disable_edca_turbo,
  44. .btc_is_bt_disabled = rtl_btc_is_bt_disabled,
  45. .btc_special_packet_notify = rtl_btc_special_packet_notify,
  46. };
  47. void rtl_btc_init_variables(struct rtl_priv *rtlpriv)
  48. {
  49. exhalbtc_initlize_variables(rtlpriv);
  50. }
  51. void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv)
  52. {
  53. u8 ant_num;
  54. u8 bt_exist;
  55. u8 bt_type;
  56. ant_num = rtl_get_hwpg_ant_num(rtlpriv);
  57. RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
  58. "%s, antNum is %d\n", __func__, ant_num);
  59. bt_exist = rtl_get_hwpg_bt_exist(rtlpriv);
  60. RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
  61. "%s, bt_exist is %d\n", __func__, bt_exist);
  62. exhalbtc_set_bt_exist(bt_exist);
  63. bt_type = rtl_get_hwpg_bt_type(rtlpriv);
  64. RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "%s, bt_type is %d\n",
  65. __func__, bt_type);
  66. exhalbtc_set_chip_type(bt_type);
  67. exhalbtc_set_ant_num(BT_COEX_ANT_TYPE_PG, ant_num);
  68. }
  69. void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv)
  70. {
  71. exhalbtc_init_hw_config(&gl_bt_coexist);
  72. exhalbtc_init_coex_dm(&gl_bt_coexist);
  73. }
  74. void rtl_btc_ips_notify(struct rtl_priv *rtlpriv, u8 type)
  75. {
  76. exhalbtc_ips_notify(&gl_bt_coexist, type);
  77. }
  78. void rtl_btc_lps_notify(struct rtl_priv *rtlpriv, u8 type)
  79. {
  80. exhalbtc_lps_notify(&gl_bt_coexist, type);
  81. }
  82. void rtl_btc_scan_notify(struct rtl_priv *rtlpriv, u8 scantype)
  83. {
  84. exhalbtc_scan_notify(&gl_bt_coexist, scantype);
  85. }
  86. void rtl_btc_connect_notify(struct rtl_priv *rtlpriv, u8 action)
  87. {
  88. exhalbtc_connect_notify(&gl_bt_coexist, action);
  89. }
  90. void rtl_btc_mediastatus_notify(struct rtl_priv *rtlpriv,
  91. enum rt_media_status mstatus)
  92. {
  93. exhalbtc_mediastatus_notify(&gl_bt_coexist, mstatus);
  94. }
  95. void rtl_btc_periodical(struct rtl_priv *rtlpriv)
  96. {
  97. /*rtl_bt_dm_monitor();*/
  98. exhalbtc_periodical(&gl_bt_coexist);
  99. }
  100. void rtl_btc_halt_notify(void)
  101. {
  102. exhalbtc_halt_notify(&gl_bt_coexist);
  103. }
  104. void rtl_btc_btinfo_notify(struct rtl_priv *rtlpriv, u8 *tmp_buf, u8 length)
  105. {
  106. exhalbtc_bt_info_notify(&gl_bt_coexist, tmp_buf, length);
  107. }
  108. bool rtl_btc_is_limited_dig(struct rtl_priv *rtlpriv)
  109. {
  110. return gl_bt_coexist.bt_info.limited_dig;
  111. }
  112. bool rtl_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv)
  113. {
  114. bool bt_change_edca = false;
  115. u32 cur_edca_val;
  116. u32 edca_bt_hs_uplink = 0x5ea42b, edca_bt_hs_downlink = 0x5ea42b;
  117. u32 edca_hs;
  118. u32 edca_addr = 0x504;
  119. cur_edca_val = rtl_read_dword(rtlpriv, edca_addr);
  120. if (halbtc_is_wifi_uplink(rtlpriv)) {
  121. if (cur_edca_val != edca_bt_hs_uplink) {
  122. edca_hs = edca_bt_hs_uplink;
  123. bt_change_edca = true;
  124. }
  125. } else {
  126. if (cur_edca_val != edca_bt_hs_downlink) {
  127. edca_hs = edca_bt_hs_downlink;
  128. bt_change_edca = true;
  129. }
  130. }
  131. if (bt_change_edca)
  132. rtl_write_dword(rtlpriv, edca_addr, edca_hs);
  133. return true;
  134. }
  135. bool rtl_btc_is_bt_disabled(struct rtl_priv *rtlpriv)
  136. {
  137. /* It seems 'bt_disabled' is never be initialized or set. */
  138. if (gl_bt_coexist.bt_info.bt_disabled)
  139. return true;
  140. else
  141. return false;
  142. }
  143. void rtl_btc_special_packet_notify(struct rtl_priv *rtlpriv, u8 pkt_type)
  144. {
  145. return exhalbtc_special_packet_notify(&gl_bt_coexist, pkt_type);
  146. }
  147. struct rtl_btc_ops *rtl_btc_get_ops_pointer(void)
  148. {
  149. return &rtl_btc_operation;
  150. }
  151. EXPORT_SYMBOL(rtl_btc_get_ops_pointer);
  152. u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
  153. {
  154. u8 num;
  155. if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2)
  156. num = 2;
  157. else
  158. num = 1;
  159. return num;
  160. }
  161. enum rt_media_status mgnt_link_status_query(struct ieee80211_hw *hw)
  162. {
  163. struct rtl_priv *rtlpriv = rtl_priv(hw);
  164. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  165. enum rt_media_status m_status = RT_MEDIA_DISCONNECT;
  166. u8 bibss = (mac->opmode == NL80211_IFTYPE_ADHOC) ? 1 : 0;
  167. if (bibss || rtlpriv->mac80211.link_state >= MAC80211_LINKED)
  168. m_status = RT_MEDIA_CONNECT;
  169. return m_status;
  170. }
  171. u8 rtl_get_hwpg_bt_exist(struct rtl_priv *rtlpriv)
  172. {
  173. return rtlpriv->btcoexist.btc_info.btcoexist;
  174. }
  175. u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv)
  176. {
  177. return rtlpriv->btcoexist.btc_info.bt_type;
  178. }
  179. MODULE_AUTHOR("Page He <page_he@realsil.com.cn>");
  180. MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
  181. MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>");
  182. MODULE_LICENSE("GPL");
  183. MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core");
  184. static int __init rtl_btcoexist_module_init(void)
  185. {
  186. return 0;
  187. }
  188. static void __exit rtl_btcoexist_module_exit(void)
  189. {
  190. return;
  191. }
  192. module_init(rtl_btcoexist_module_init);
  193. module_exit(rtl_btcoexist_module_exit);