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) 2012 - 2014 Intel Corporation. All rights reserved.
9  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
10  * Copyright(c) 2016 - 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) 2012 - 2014 Intel Corporation. All rights reserved.
31  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
32  * Copyright(c) 2016 - 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 
63 #ifndef __iwl_fw_api_phy_h__
64 #define __iwl_fw_api_phy_h__
65 
66 /**
67  * enum iwl_phy_ops_subcmd_ids - PHY group commands
68  */
69 enum iwl_phy_ops_subcmd_ids {
70 	/**
71 	 * @CMD_DTS_MEASUREMENT_TRIGGER_WIDE:
72 	 * Uses either &struct iwl_dts_measurement_cmd or
73 	 * &struct iwl_ext_dts_measurement_cmd
74 	 */
75 	CMD_DTS_MEASUREMENT_TRIGGER_WIDE = 0x0,
76 
77 	/**
78 	 * @CTDP_CONFIG_CMD: &struct iwl_mvm_ctdp_cmd
79 	 */
80 	CTDP_CONFIG_CMD = 0x03,
81 
82 	/**
83 	 * @TEMP_REPORTING_THRESHOLDS_CMD: &struct temp_report_ths_cmd
84 	 */
85 	TEMP_REPORTING_THRESHOLDS_CMD = 0x04,
86 
87 	/**
88 	 * @GEO_TX_POWER_LIMIT: &struct iwl_geo_tx_power_profiles_cmd
89 	 */
90 	GEO_TX_POWER_LIMIT = 0x05,
91 
92 	/**
93 	 * @CT_KILL_NOTIFICATION: &struct ct_kill_notif
94 	 */
95 	CT_KILL_NOTIFICATION = 0xFE,
96 
97 	/**
98 	 * @DTS_MEASUREMENT_NOTIF_WIDE:
99 	 * &struct iwl_dts_measurement_notif_v1 or
100 	 * &struct iwl_dts_measurement_notif_v2
101 	 */
102 	DTS_MEASUREMENT_NOTIF_WIDE = 0xFF,
103 };
104 
105 /* DTS measurements */
106 
107 enum iwl_dts_measurement_flags {
108 	DTS_TRIGGER_CMD_FLAGS_TEMP	= BIT(0),
109 	DTS_TRIGGER_CMD_FLAGS_VOLT	= BIT(1),
110 };
111 
112 /**
113  * struct iwl_dts_measurement_cmd - request DTS temp and/or voltage measurements
114  *
115  * @flags: indicates which measurements we want as specified in
116  *	&enum iwl_dts_measurement_flags
117  */
118 struct iwl_dts_measurement_cmd {
119 	__le32 flags;
120 } __packed; /* TEMPERATURE_MEASUREMENT_TRIGGER_CMD_S */
121 
122 /**
123 * enum iwl_dts_control_measurement_mode - DTS measurement type
124 * @DTS_AUTOMATIC: Automatic mode (full SW control). Provide temperature read
125 *                 back (latest value. Not waiting for new value). Use automatic
126 *                 SW DTS configuration.
127 * @DTS_REQUEST_READ: Request DTS read. Configure DTS with manual settings,
128 *                    trigger DTS reading and provide read back temperature read
129 *                    when available.
130 * @DTS_OVER_WRITE: over-write the DTS temperatures in the SW until next read
131 * @DTS_DIRECT_WITHOUT_MEASURE: DTS returns its latest temperature result,
132 *                              without measurement trigger.
133 */
134 enum iwl_dts_control_measurement_mode {
135 	DTS_AUTOMATIC			= 0,
136 	DTS_REQUEST_READ		= 1,
137 	DTS_OVER_WRITE			= 2,
138 	DTS_DIRECT_WITHOUT_MEASURE	= 3,
139 };
140 
141 /**
142 * enum iwl_dts_used - DTS to use or used for measurement in the DTS request
143 * @DTS_USE_TOP: Top
144 * @DTS_USE_CHAIN_A: chain A
145 * @DTS_USE_CHAIN_B: chain B
146 * @DTS_USE_CHAIN_C: chain C
147 * @XTAL_TEMPERATURE: read temperature from xtal
148 */
149 enum iwl_dts_used {
150 	DTS_USE_TOP		= 0,
151 	DTS_USE_CHAIN_A		= 1,
152 	DTS_USE_CHAIN_B		= 2,
153 	DTS_USE_CHAIN_C		= 3,
154 	XTAL_TEMPERATURE	= 4,
155 };
156 
157 /**
158 * enum iwl_dts_bit_mode - bit-mode to use in DTS request read mode
159 * @DTS_BIT6_MODE: bit 6 mode
160 * @DTS_BIT8_MODE: bit 8 mode
161 */
162 enum iwl_dts_bit_mode {
163 	DTS_BIT6_MODE	= 0,
164 	DTS_BIT8_MODE	= 1,
165 };
166 
167 /**
168  * struct iwl_ext_dts_measurement_cmd - request extended DTS temp measurements
169  * @control_mode: see &enum iwl_dts_control_measurement_mode
170  * @temperature: used when over write DTS mode is selected
171  * @sensor: set temperature sensor to use. See &enum iwl_dts_used
172  * @avg_factor: average factor to DTS in request DTS read mode
173  * @bit_mode: value defines the DTS bit mode to use. See &enum iwl_dts_bit_mode
174  * @step_duration: step duration for the DTS
175  */
176 struct iwl_ext_dts_measurement_cmd {
177 	__le32 control_mode;
178 	__le32 temperature;
179 	__le32 sensor;
180 	__le32 avg_factor;
181 	__le32 bit_mode;
182 	__le32 step_duration;
183 } __packed; /* XVT_FW_DTS_CONTROL_MEASUREMENT_REQUEST_API_S */
184 
185 /**
186  * struct iwl_dts_measurement_notif_v1 - measurements notification
187  *
188  * @temp: the measured temperature
189  * @voltage: the measured voltage
190  */
191 struct iwl_dts_measurement_notif_v1 {
192 	__le32 temp;
193 	__le32 voltage;
194 } __packed; /* TEMPERATURE_MEASUREMENT_TRIGGER_NTFY_S_VER_1*/
195 
196 /**
197  * struct iwl_dts_measurement_notif_v2 - measurements notification
198  *
199  * @temp: the measured temperature
200  * @voltage: the measured voltage
201  * @threshold_idx: the trip index that was crossed
202  */
203 struct iwl_dts_measurement_notif_v2 {
204 	__le32 temp;
205 	__le32 voltage;
206 	__le32 threshold_idx;
207 } __packed; /* TEMPERATURE_MEASUREMENT_TRIGGER_NTFY_S_VER_2 */
208 
209 /**
210  * struct ct_kill_notif - CT-kill entry notification
211  *
212  * @temperature: the current temperature in celsius
213  * @reserved: reserved
214  */
215 struct ct_kill_notif {
216 	__le16 temperature;
217 	__le16 reserved;
218 } __packed; /* GRP_PHY_CT_KILL_NTF */
219 
220 /**
221 * enum ctdp_cmd_operation - CTDP command operations
222 * @CTDP_CMD_OPERATION_START: update the current budget
223 * @CTDP_CMD_OPERATION_STOP: stop ctdp
224 * @CTDP_CMD_OPERATION_REPORT: get the average budget
225 */
226 enum iwl_mvm_ctdp_cmd_operation {
227 	CTDP_CMD_OPERATION_START	= 0x1,
228 	CTDP_CMD_OPERATION_STOP		= 0x2,
229 	CTDP_CMD_OPERATION_REPORT	= 0x4,
230 };/* CTDP_CMD_OPERATION_TYPE_E */
231 
232 /**
233  * struct iwl_mvm_ctdp_cmd - track and manage the FW power consumption budget
234  *
235  * @operation: see &enum iwl_mvm_ctdp_cmd_operation
236  * @budget: the budget in milliwatt
237  * @window_size: defined in API but not used
238  */
239 struct iwl_mvm_ctdp_cmd {
240 	__le32 operation;
241 	__le32 budget;
242 	__le32 window_size;
243 } __packed;
244 
245 #define IWL_MAX_DTS_TRIPS	8
246 
247 /**
248  * struct temp_report_ths_cmd - set temperature thresholds
249  *
250  * @num_temps: number of temperature thresholds passed
251  * @thresholds: array with the thresholds to be configured
252  */
253 struct temp_report_ths_cmd {
254 	__le32 num_temps;
255 	__le16 thresholds[IWL_MAX_DTS_TRIPS];
256 } __packed; /* GRP_PHY_TEMP_REPORTING_THRESHOLDS_CMD */
257 
258 #endif /* __iwl_fw_api_phy_h__ */
259