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 62 #ifndef __iwl_fw_api_coex_h__ 63 #define __iwl_fw_api_coex_h__ 64 65 #include <linux/types.h> 66 #include <linux/bitops.h> 67 68 #define BITS(nb) (BIT(nb) - 1) 69 70 enum iwl_bt_coex_lut_type { 71 BT_COEX_TIGHT_LUT = 0, 72 BT_COEX_LOOSE_LUT, 73 BT_COEX_TX_DIS_LUT, 74 75 BT_COEX_MAX_LUT, 76 BT_COEX_INVALID_LUT = 0xff, 77 }; /* BT_COEX_DECISION_LUT_INDEX_API_E_VER_1 */ 78 79 #define BT_REDUCED_TX_POWER_BIT BIT(7) 80 81 enum iwl_bt_coex_mode { 82 BT_COEX_DISABLE = 0x0, 83 BT_COEX_NW = 0x1, 84 BT_COEX_BT = 0x2, 85 BT_COEX_WIFI = 0x3, 86 }; /* BT_COEX_MODES_E */ 87 88 enum iwl_bt_coex_enabled_modules { 89 BT_COEX_MPLUT_ENABLED = BIT(0), 90 BT_COEX_MPLUT_BOOST_ENABLED = BIT(1), 91 BT_COEX_SYNC2SCO_ENABLED = BIT(2), 92 BT_COEX_CORUN_ENABLED = BIT(3), 93 BT_COEX_HIGH_BAND_RET = BIT(4), 94 }; /* BT_COEX_MODULES_ENABLE_E_VER_1 */ 95 96 /** 97 * struct iwl_bt_coex_cmd - bt coex configuration command 98 * @mode: &enum iwl_bt_coex_mode 99 * @enabled_modules: &enum iwl_bt_coex_enabled_modules 100 * 101 * The structure is used for the BT_COEX command. 102 */ 103 struct iwl_bt_coex_cmd { 104 __le32 mode; 105 __le32 enabled_modules; 106 } __packed; /* BT_COEX_CMD_API_S_VER_6 */ 107 108 /** 109 * struct iwl_bt_coex_reduced_txp_update_cmd 110 * @reduced_txp: bit BT_REDUCED_TX_POWER_BIT to enable / disable, rest of the 111 * bits are the sta_id (value) 112 */ 113 struct iwl_bt_coex_reduced_txp_update_cmd { 114 __le32 reduced_txp; 115 } __packed; /* BT_COEX_UPDATE_REDUCED_TX_POWER_API_S_VER_1 */ 116 117 /** 118 * struct iwl_bt_coex_ci_cmd - bt coex channel inhibition command 119 * @bt_primary_ci: primary channel inhibition bitmap 120 * @primary_ch_phy_id: primary channel PHY ID 121 * @bt_secondary_ci: secondary channel inhibition bitmap 122 * @secondary_ch_phy_id: secondary channel PHY ID 123 * 124 * Used for BT_COEX_CI command 125 */ 126 struct iwl_bt_coex_ci_cmd { 127 __le64 bt_primary_ci; 128 __le32 primary_ch_phy_id; 129 130 __le64 bt_secondary_ci; 131 __le32 secondary_ch_phy_id; 132 } __packed; /* BT_CI_MSG_API_S_VER_2 */ 133 134 #define BT_MBOX(n_dw, _msg, _pos, _nbits) \ 135 BT_MBOX##n_dw##_##_msg##_POS = (_pos), \ 136 BT_MBOX##n_dw##_##_msg = BITS(_nbits) << BT_MBOX##n_dw##_##_msg##_POS 137 138 enum iwl_bt_mxbox_dw0 { 139 BT_MBOX(0, LE_SLAVE_LAT, 0, 3), 140 BT_MBOX(0, LE_PROF1, 3, 1), 141 BT_MBOX(0, LE_PROF2, 4, 1), 142 BT_MBOX(0, LE_PROF_OTHER, 5, 1), 143 BT_MBOX(0, CHL_SEQ_N, 8, 4), 144 BT_MBOX(0, INBAND_S, 13, 1), 145 BT_MBOX(0, LE_MIN_RSSI, 16, 4), 146 BT_MBOX(0, LE_SCAN, 20, 1), 147 BT_MBOX(0, LE_ADV, 21, 1), 148 BT_MBOX(0, LE_MAX_TX_POWER, 24, 4), 149 BT_MBOX(0, OPEN_CON_1, 28, 2), 150 }; 151 152 enum iwl_bt_mxbox_dw1 { 153 BT_MBOX(1, BR_MAX_TX_POWER, 0, 4), 154 BT_MBOX(1, IP_SR, 4, 1), 155 BT_MBOX(1, LE_MSTR, 5, 1), 156 BT_MBOX(1, AGGR_TRFC_LD, 8, 6), 157 BT_MBOX(1, MSG_TYPE, 16, 3), 158 BT_MBOX(1, SSN, 19, 2), 159 }; 160 161 enum iwl_bt_mxbox_dw2 { 162 BT_MBOX(2, SNIFF_ACT, 0, 3), 163 BT_MBOX(2, PAG, 3, 1), 164 BT_MBOX(2, INQUIRY, 4, 1), 165 BT_MBOX(2, CONN, 5, 1), 166 BT_MBOX(2, SNIFF_INTERVAL, 8, 5), 167 BT_MBOX(2, DISC, 13, 1), 168 BT_MBOX(2, SCO_TX_ACT, 16, 2), 169 BT_MBOX(2, SCO_RX_ACT, 18, 2), 170 BT_MBOX(2, ESCO_RE_TX, 20, 2), 171 BT_MBOX(2, SCO_DURATION, 24, 6), 172 }; 173 174 enum iwl_bt_mxbox_dw3 { 175 BT_MBOX(3, SCO_STATE, 0, 1), 176 BT_MBOX(3, SNIFF_STATE, 1, 1), 177 BT_MBOX(3, A2DP_STATE, 2, 1), 178 BT_MBOX(3, ACL_STATE, 3, 1), 179 BT_MBOX(3, MSTR_STATE, 4, 1), 180 BT_MBOX(3, OBX_STATE, 5, 1), 181 BT_MBOX(3, A2DP_SRC, 6, 1), 182 BT_MBOX(3, OPEN_CON_2, 8, 2), 183 BT_MBOX(3, TRAFFIC_LOAD, 10, 2), 184 BT_MBOX(3, CHL_SEQN_LSB, 12, 1), 185 BT_MBOX(3, INBAND_P, 13, 1), 186 BT_MBOX(3, MSG_TYPE_2, 16, 3), 187 BT_MBOX(3, SSN_2, 19, 2), 188 BT_MBOX(3, UPDATE_REQUEST, 21, 1), 189 }; 190 191 enum iwl_bt_mxbox_dw4 { 192 BT_MBOX(4, ATS_BT_INTERVAL, 0, 7), 193 BT_MBOX(4, ATS_BT_ACTIVE_MAX_TH, 7, 7), 194 }; 195 196 #define BT_MBOX_MSG(_notif, _num, _field) \ 197 ((le32_to_cpu((_notif)->mbox_msg[(_num)]) & BT_MBOX##_num##_##_field)\ 198 >> BT_MBOX##_num##_##_field##_POS) 199 200 #define BT_MBOX_PRINT(_num, _field, _end) \ 201 pos += scnprintf(buf + pos, bufsz - pos, \ 202 "\t%s: %d%s", \ 203 #_field, \ 204 BT_MBOX_MSG(notif, _num, _field), \ 205 true ? "\n" : ", "); 206 enum iwl_bt_activity_grading { 207 BT_OFF = 0, 208 BT_ON_NO_CONNECTION = 1, 209 BT_LOW_TRAFFIC = 2, 210 BT_HIGH_TRAFFIC = 3, 211 212 BT_MAX_AG, 213 }; /* BT_COEX_BT_ACTIVITY_GRADING_API_E_VER_1 */ 214 215 enum iwl_bt_ci_compliance { 216 BT_CI_COMPLIANCE_NONE = 0, 217 BT_CI_COMPLIANCE_PRIMARY = 1, 218 BT_CI_COMPLIANCE_SECONDARY = 2, 219 BT_CI_COMPLIANCE_BOTH = 3, 220 }; /* BT_COEX_CI_COMPLIENCE_E_VER_1 */ 221 222 /** 223 * struct iwl_bt_coex_profile_notif - notification about BT coex 224 * @mbox_msg: message from BT to WiFi 225 * @msg_idx: the index of the message 226 * @bt_ci_compliance: enum %iwl_bt_ci_compliance 227 * @primary_ch_lut: LUT used for primary channel &enum iwl_bt_coex_lut_type 228 * @secondary_ch_lut: LUT used for secondary channel &enum iwl_bt_coex_lut_type 229 * @bt_activity_grading: the activity of BT &enum iwl_bt_activity_grading 230 * @ttc_status: is TTC enabled - one bit per PHY 231 * @rrc_status: is RRC enabled - one bit per PHY 232 * @reserved: reserved 233 */ 234 struct iwl_bt_coex_profile_notif { 235 __le32 mbox_msg[8]; 236 __le32 msg_idx; 237 __le32 bt_ci_compliance; 238 239 __le32 primary_ch_lut; 240 __le32 secondary_ch_lut; 241 __le32 bt_activity_grading; 242 u8 ttc_status; 243 u8 rrc_status; 244 __le16 reserved; 245 } __packed; /* BT_COEX_PROFILE_NTFY_API_S_VER_5 */ 246 247 /** 248 * struct iwl_bt_coex_profile_notif - notification about BT coex 249 * @mbox_msg: message from BT to WiFi 250 * @msg_idx: the index of the message 251 * @bt_ci_compliance: enum %iwl_bt_ci_compliance 252 * @primary_ch_lut: LUT used for primary channel &enum iwl_bt_coex_lut_type 253 * @secondary_ch_lut: LUT used for secondary channel &enum iwl_bt_coex_lut_type 254 * @bt_activity_grading: the activity of BT &enum iwl_bt_activity_grading 255 * @ttc_status: is TTC enabled - one bit per PHY 256 * @rrc_status: is RRC enabled - one bit per PHY 257 * @reserved: reserved 258 */ 259 struct iwl_bt_coex_profile_notif_v4 { 260 __le32 mbox_msg[4]; 261 __le32 msg_idx; 262 __le32 bt_ci_compliance; 263 264 __le32 primary_ch_lut; 265 __le32 secondary_ch_lut; 266 __le32 bt_activity_grading; 267 u8 ttc_status; 268 u8 rrc_status; 269 __le16 reserved; 270 } __packed; /* BT_COEX_PROFILE_NTFY_API_S_VER_4 */ 271 272 #endif /* __iwl_fw_api_coex_h__ */ 273