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