1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * Copyright (C) 2012-2014, 2019-2020 Intel Corporation
4  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
5  * Copyright (C) 2016-2017 Intel Deutschland GmbH
6  */
7 #ifndef __iwl_fw_api_phy_h__
8 #define __iwl_fw_api_phy_h__
9 
10 /**
11  * enum iwl_phy_ops_subcmd_ids - PHY group commands
12  */
13 enum iwl_phy_ops_subcmd_ids {
14 	/**
15 	 * @CMD_DTS_MEASUREMENT_TRIGGER_WIDE:
16 	 * Uses either &struct iwl_dts_measurement_cmd or
17 	 * &struct iwl_ext_dts_measurement_cmd
18 	 */
19 	CMD_DTS_MEASUREMENT_TRIGGER_WIDE = 0x0,
20 
21 	/**
22 	 * @CTDP_CONFIG_CMD: &struct iwl_mvm_ctdp_cmd
23 	 */
24 	CTDP_CONFIG_CMD = 0x03,
25 
26 	/**
27 	 * @TEMP_REPORTING_THRESHOLDS_CMD: &struct temp_report_ths_cmd
28 	 */
29 	TEMP_REPORTING_THRESHOLDS_CMD = 0x04,
30 
31 	/**
32 	 * @GEO_TX_POWER_LIMIT: &struct iwl_geo_tx_power_profiles_cmd
33 	 */
34 	GEO_TX_POWER_LIMIT = 0x05,
35 
36 	/**
37 	 * @PER_PLATFORM_ANT_GAIN_CMD: &struct iwl_ppag_table_cmd
38 	 */
39 	PER_PLATFORM_ANT_GAIN_CMD = 0x07,
40 
41 	/**
42 	 * @CT_KILL_NOTIFICATION: &struct ct_kill_notif
43 	 */
44 	CT_KILL_NOTIFICATION = 0xFE,
45 
46 	/**
47 	 * @DTS_MEASUREMENT_NOTIF_WIDE:
48 	 * &struct iwl_dts_measurement_notif_v1 or
49 	 * &struct iwl_dts_measurement_notif_v2
50 	 */
51 	DTS_MEASUREMENT_NOTIF_WIDE = 0xFF,
52 };
53 
54 /* DTS measurements */
55 
56 enum iwl_dts_measurement_flags {
57 	DTS_TRIGGER_CMD_FLAGS_TEMP	= BIT(0),
58 	DTS_TRIGGER_CMD_FLAGS_VOLT	= BIT(1),
59 };
60 
61 /**
62  * struct iwl_dts_measurement_cmd - request DTS temp and/or voltage measurements
63  *
64  * @flags: indicates which measurements we want as specified in
65  *	&enum iwl_dts_measurement_flags
66  */
67 struct iwl_dts_measurement_cmd {
68 	__le32 flags;
69 } __packed; /* TEMPERATURE_MEASUREMENT_TRIGGER_CMD_S */
70 
71 /**
72 * enum iwl_dts_control_measurement_mode - DTS measurement type
73 * @DTS_AUTOMATIC: Automatic mode (full SW control). Provide temperature read
74 *                 back (latest value. Not waiting for new value). Use automatic
75 *                 SW DTS configuration.
76 * @DTS_REQUEST_READ: Request DTS read. Configure DTS with manual settings,
77 *                    trigger DTS reading and provide read back temperature read
78 *                    when available.
79 * @DTS_OVER_WRITE: over-write the DTS temperatures in the SW until next read
80 * @DTS_DIRECT_WITHOUT_MEASURE: DTS returns its latest temperature result,
81 *                              without measurement trigger.
82 */
83 enum iwl_dts_control_measurement_mode {
84 	DTS_AUTOMATIC			= 0,
85 	DTS_REQUEST_READ		= 1,
86 	DTS_OVER_WRITE			= 2,
87 	DTS_DIRECT_WITHOUT_MEASURE	= 3,
88 };
89 
90 /**
91 * enum iwl_dts_used - DTS to use or used for measurement in the DTS request
92 * @DTS_USE_TOP: Top
93 * @DTS_USE_CHAIN_A: chain A
94 * @DTS_USE_CHAIN_B: chain B
95 * @DTS_USE_CHAIN_C: chain C
96 * @XTAL_TEMPERATURE: read temperature from xtal
97 */
98 enum iwl_dts_used {
99 	DTS_USE_TOP		= 0,
100 	DTS_USE_CHAIN_A		= 1,
101 	DTS_USE_CHAIN_B		= 2,
102 	DTS_USE_CHAIN_C		= 3,
103 	XTAL_TEMPERATURE	= 4,
104 };
105 
106 /**
107 * enum iwl_dts_bit_mode - bit-mode to use in DTS request read mode
108 * @DTS_BIT6_MODE: bit 6 mode
109 * @DTS_BIT8_MODE: bit 8 mode
110 */
111 enum iwl_dts_bit_mode {
112 	DTS_BIT6_MODE	= 0,
113 	DTS_BIT8_MODE	= 1,
114 };
115 
116 /**
117  * struct iwl_ext_dts_measurement_cmd - request extended DTS temp measurements
118  * @control_mode: see &enum iwl_dts_control_measurement_mode
119  * @temperature: used when over write DTS mode is selected
120  * @sensor: set temperature sensor to use. See &enum iwl_dts_used
121  * @avg_factor: average factor to DTS in request DTS read mode
122  * @bit_mode: value defines the DTS bit mode to use. See &enum iwl_dts_bit_mode
123  * @step_duration: step duration for the DTS
124  */
125 struct iwl_ext_dts_measurement_cmd {
126 	__le32 control_mode;
127 	__le32 temperature;
128 	__le32 sensor;
129 	__le32 avg_factor;
130 	__le32 bit_mode;
131 	__le32 step_duration;
132 } __packed; /* XVT_FW_DTS_CONTROL_MEASUREMENT_REQUEST_API_S */
133 
134 /**
135  * struct iwl_dts_measurement_notif_v1 - measurements notification
136  *
137  * @temp: the measured temperature
138  * @voltage: the measured voltage
139  */
140 struct iwl_dts_measurement_notif_v1 {
141 	__le32 temp;
142 	__le32 voltage;
143 } __packed; /* TEMPERATURE_MEASUREMENT_TRIGGER_NTFY_S_VER_1*/
144 
145 /**
146  * struct iwl_dts_measurement_notif_v2 - measurements notification
147  *
148  * @temp: the measured temperature
149  * @voltage: the measured voltage
150  * @threshold_idx: the trip index that was crossed
151  */
152 struct iwl_dts_measurement_notif_v2 {
153 	__le32 temp;
154 	__le32 voltage;
155 	__le32 threshold_idx;
156 } __packed; /* TEMPERATURE_MEASUREMENT_TRIGGER_NTFY_S_VER_2 */
157 
158 /**
159  * struct iwl_dts_measurement_resp - measurements response
160  *
161  * @temp: the measured temperature
162  */
163 struct iwl_dts_measurement_resp {
164 	__le32 temp;
165 } __packed; /* CMD_DTS_MEASUREMENT_RSP_API_S_VER_1 */
166 
167 /**
168  * struct ct_kill_notif - CT-kill entry notification
169  *
170  * @temperature: the current temperature in celsius
171  * @reserved: reserved
172  */
173 struct ct_kill_notif {
174 	__le16 temperature;
175 	__le16 reserved;
176 } __packed; /* GRP_PHY_CT_KILL_NTF */
177 
178 /**
179 * enum ctdp_cmd_operation - CTDP command operations
180 * @CTDP_CMD_OPERATION_START: update the current budget
181 * @CTDP_CMD_OPERATION_STOP: stop ctdp
182 * @CTDP_CMD_OPERATION_REPORT: get the average budget
183 */
184 enum iwl_mvm_ctdp_cmd_operation {
185 	CTDP_CMD_OPERATION_START	= 0x1,
186 	CTDP_CMD_OPERATION_STOP		= 0x2,
187 	CTDP_CMD_OPERATION_REPORT	= 0x4,
188 };/* CTDP_CMD_OPERATION_TYPE_E */
189 
190 /**
191  * struct iwl_mvm_ctdp_cmd - track and manage the FW power consumption budget
192  *
193  * @operation: see &enum iwl_mvm_ctdp_cmd_operation
194  * @budget: the budget in milliwatt
195  * @window_size: defined in API but not used
196  */
197 struct iwl_mvm_ctdp_cmd {
198 	__le32 operation;
199 	__le32 budget;
200 	__le32 window_size;
201 } __packed;
202 
203 #define IWL_MAX_DTS_TRIPS	8
204 
205 /**
206  * struct temp_report_ths_cmd - set temperature thresholds
207  *
208  * @num_temps: number of temperature thresholds passed
209  * @thresholds: array with the thresholds to be configured
210  */
211 struct temp_report_ths_cmd {
212 	__le32 num_temps;
213 	__le16 thresholds[IWL_MAX_DTS_TRIPS];
214 } __packed; /* GRP_PHY_TEMP_REPORTING_THRESHOLDS_CMD */
215 
216 #endif /* __iwl_fw_api_phy_h__ */
217