coex.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /******************************************************************************
  2. *
  3. * This file is provided under a dual BSD/GPLv2 license. When using or
  4. * redistributing this file, you may do so under either license.
  5. *
  6. * GPL LICENSE SUMMARY
  7. *
  8. * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
  9. * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
  10. * Copyright(c) 2017 Intel Deutschland GmbH
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of version 2 of the GNU General Public License as
  14. * published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * General Public License for more details.
  20. *
  21. * The full GNU General Public License is included in this distribution
  22. * in the file called COPYING.
  23. *
  24. * Contact Information:
  25. * Intel Linux Wireless <linuxwifi@intel.com>
  26. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  27. *
  28. * BSD LICENSE
  29. *
  30. * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
  31. * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
  32. * Copyright(c) 2017 Intel Deutschland GmbH
  33. * All rights reserved.
  34. *
  35. * Redistribution and use in source and binary forms, with or without
  36. * modification, are permitted provided that the following conditions
  37. * are met:
  38. *
  39. * * Redistributions of source code must retain the above copyright
  40. * notice, this list of conditions and the following disclaimer.
  41. * * Redistributions in binary form must reproduce the above copyright
  42. * notice, this list of conditions and the following disclaimer in
  43. * the documentation and/or other materials provided with the
  44. * distribution.
  45. * * Neither the name Intel Corporation nor the names of its
  46. * contributors may be used to endorse or promote products derived
  47. * from this software without specific prior written permission.
  48. *
  49. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  50. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  51. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  52. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  53. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  54. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  55. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  56. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  57. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  58. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  59. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  60. *****************************************************************************/
  61. #ifndef __iwl_fw_api_coex_h__
  62. #define __iwl_fw_api_coex_h__
  63. #include <linux/types.h>
  64. #include <linux/bitops.h>
  65. #define BITS(nb) (BIT(nb) - 1)
  66. enum iwl_bt_coex_lut_type {
  67. BT_COEX_TIGHT_LUT = 0,
  68. BT_COEX_LOOSE_LUT,
  69. BT_COEX_TX_DIS_LUT,
  70. BT_COEX_MAX_LUT,
  71. BT_COEX_INVALID_LUT = 0xff,
  72. }; /* BT_COEX_DECISION_LUT_INDEX_API_E_VER_1 */
  73. #define BT_REDUCED_TX_POWER_BIT BIT(7)
  74. enum iwl_bt_coex_mode {
  75. BT_COEX_DISABLE = 0x0,
  76. BT_COEX_NW = 0x1,
  77. BT_COEX_BT = 0x2,
  78. BT_COEX_WIFI = 0x3,
  79. }; /* BT_COEX_MODES_E */
  80. enum iwl_bt_coex_enabled_modules {
  81. BT_COEX_MPLUT_ENABLED = BIT(0),
  82. BT_COEX_MPLUT_BOOST_ENABLED = BIT(1),
  83. BT_COEX_SYNC2SCO_ENABLED = BIT(2),
  84. BT_COEX_CORUN_ENABLED = BIT(3),
  85. BT_COEX_HIGH_BAND_RET = BIT(4),
  86. }; /* BT_COEX_MODULES_ENABLE_E_VER_1 */
  87. /**
  88. * struct iwl_bt_coex_cmd - bt coex configuration command
  89. * @mode: &enum iwl_bt_coex_mode
  90. * @enabled_modules: &enum iwl_bt_coex_enabled_modules
  91. *
  92. * The structure is used for the BT_COEX command.
  93. */
  94. struct iwl_bt_coex_cmd {
  95. __le32 mode;
  96. __le32 enabled_modules;
  97. } __packed; /* BT_COEX_CMD_API_S_VER_6 */
  98. /**
  99. * struct iwl_bt_coex_reduced_txp_update_cmd
  100. * @reduced_txp: bit BT_REDUCED_TX_POWER_BIT to enable / disable, rest of the
  101. * bits are the sta_id (value)
  102. */
  103. struct iwl_bt_coex_reduced_txp_update_cmd {
  104. __le32 reduced_txp;
  105. } __packed; /* BT_COEX_UPDATE_REDUCED_TX_POWER_API_S_VER_1 */
  106. /**
  107. * struct iwl_bt_coex_ci_cmd - bt coex channel inhibition command
  108. * @bt_primary_ci: primary channel inhibition bitmap
  109. * @primary_ch_phy_id: primary channel PHY ID
  110. * @bt_secondary_ci: secondary channel inhibition bitmap
  111. * @secondary_ch_phy_id: secondary channel PHY ID
  112. *
  113. * Used for BT_COEX_CI command
  114. */
  115. struct iwl_bt_coex_ci_cmd {
  116. __le64 bt_primary_ci;
  117. __le32 primary_ch_phy_id;
  118. __le64 bt_secondary_ci;
  119. __le32 secondary_ch_phy_id;
  120. } __packed; /* BT_CI_MSG_API_S_VER_2 */
  121. #define BT_MBOX(n_dw, _msg, _pos, _nbits) \
  122. BT_MBOX##n_dw##_##_msg##_POS = (_pos), \
  123. BT_MBOX##n_dw##_##_msg = BITS(_nbits) << BT_MBOX##n_dw##_##_msg##_POS
  124. enum iwl_bt_mxbox_dw0 {
  125. BT_MBOX(0, LE_SLAVE_LAT, 0, 3),
  126. BT_MBOX(0, LE_PROF1, 3, 1),
  127. BT_MBOX(0, LE_PROF2, 4, 1),
  128. BT_MBOX(0, LE_PROF_OTHER, 5, 1),
  129. BT_MBOX(0, CHL_SEQ_N, 8, 4),
  130. BT_MBOX(0, INBAND_S, 13, 1),
  131. BT_MBOX(0, LE_MIN_RSSI, 16, 4),
  132. BT_MBOX(0, LE_SCAN, 20, 1),
  133. BT_MBOX(0, LE_ADV, 21, 1),
  134. BT_MBOX(0, LE_MAX_TX_POWER, 24, 4),
  135. BT_MBOX(0, OPEN_CON_1, 28, 2),
  136. };
  137. enum iwl_bt_mxbox_dw1 {
  138. BT_MBOX(1, BR_MAX_TX_POWER, 0, 4),
  139. BT_MBOX(1, IP_SR, 4, 1),
  140. BT_MBOX(1, LE_MSTR, 5, 1),
  141. BT_MBOX(1, AGGR_TRFC_LD, 8, 6),
  142. BT_MBOX(1, MSG_TYPE, 16, 3),
  143. BT_MBOX(1, SSN, 19, 2),
  144. };
  145. enum iwl_bt_mxbox_dw2 {
  146. BT_MBOX(2, SNIFF_ACT, 0, 3),
  147. BT_MBOX(2, PAG, 3, 1),
  148. BT_MBOX(2, INQUIRY, 4, 1),
  149. BT_MBOX(2, CONN, 5, 1),
  150. BT_MBOX(2, SNIFF_INTERVAL, 8, 5),
  151. BT_MBOX(2, DISC, 13, 1),
  152. BT_MBOX(2, SCO_TX_ACT, 16, 2),
  153. BT_MBOX(2, SCO_RX_ACT, 18, 2),
  154. BT_MBOX(2, ESCO_RE_TX, 20, 2),
  155. BT_MBOX(2, SCO_DURATION, 24, 6),
  156. };
  157. enum iwl_bt_mxbox_dw3 {
  158. BT_MBOX(3, SCO_STATE, 0, 1),
  159. BT_MBOX(3, SNIFF_STATE, 1, 1),
  160. BT_MBOX(3, A2DP_STATE, 2, 1),
  161. BT_MBOX(3, ACL_STATE, 3, 1),
  162. BT_MBOX(3, MSTR_STATE, 4, 1),
  163. BT_MBOX(3, OBX_STATE, 5, 1),
  164. BT_MBOX(3, A2DP_SRC, 6, 1),
  165. BT_MBOX(3, OPEN_CON_2, 8, 2),
  166. BT_MBOX(3, TRAFFIC_LOAD, 10, 2),
  167. BT_MBOX(3, CHL_SEQN_LSB, 12, 1),
  168. BT_MBOX(3, INBAND_P, 13, 1),
  169. BT_MBOX(3, MSG_TYPE_2, 16, 3),
  170. BT_MBOX(3, SSN_2, 19, 2),
  171. BT_MBOX(3, UPDATE_REQUEST, 21, 1),
  172. };
  173. #define BT_MBOX_MSG(_notif, _num, _field) \
  174. ((le32_to_cpu((_notif)->mbox_msg[(_num)]) & BT_MBOX##_num##_##_field)\
  175. >> BT_MBOX##_num##_##_field##_POS)
  176. #define BT_MBOX_PRINT(_num, _field, _end) \
  177. pos += scnprintf(buf + pos, bufsz - pos, \
  178. "\t%s: %d%s", \
  179. #_field, \
  180. BT_MBOX_MSG(notif, _num, _field), \
  181. true ? "\n" : ", ");
  182. enum iwl_bt_activity_grading {
  183. BT_OFF = 0,
  184. BT_ON_NO_CONNECTION = 1,
  185. BT_LOW_TRAFFIC = 2,
  186. BT_HIGH_TRAFFIC = 3,
  187. BT_MAX_AG,
  188. }; /* BT_COEX_BT_ACTIVITY_GRADING_API_E_VER_1 */
  189. enum iwl_bt_ci_compliance {
  190. BT_CI_COMPLIANCE_NONE = 0,
  191. BT_CI_COMPLIANCE_PRIMARY = 1,
  192. BT_CI_COMPLIANCE_SECONDARY = 2,
  193. BT_CI_COMPLIANCE_BOTH = 3,
  194. }; /* BT_COEX_CI_COMPLIENCE_E_VER_1 */
  195. /**
  196. * struct iwl_bt_coex_profile_notif - notification about BT coex
  197. * @mbox_msg: message from BT to WiFi
  198. * @msg_idx: the index of the message
  199. * @bt_ci_compliance: enum %iwl_bt_ci_compliance
  200. * @primary_ch_lut: LUT used for primary channel &enum iwl_bt_coex_lut_type
  201. * @secondary_ch_lut: LUT used for secondary channel &enum iwl_bt_coex_lut_type
  202. * @bt_activity_grading: the activity of BT &enum iwl_bt_activity_grading
  203. * @ttc_status: is TTC enabled - one bit per PHY
  204. * @rrc_status: is RRC enabled - one bit per PHY
  205. * @reserved: reserved
  206. */
  207. struct iwl_bt_coex_profile_notif {
  208. __le32 mbox_msg[4];
  209. __le32 msg_idx;
  210. __le32 bt_ci_compliance;
  211. __le32 primary_ch_lut;
  212. __le32 secondary_ch_lut;
  213. __le32 bt_activity_grading;
  214. u8 ttc_status;
  215. u8 rrc_status;
  216. __le16 reserved;
  217. } __packed; /* BT_COEX_PROFILE_NTFY_API_S_VER_4 */
  218. #endif /* __iwl_fw_api_coex_h__ */