ARM: shmobile: kzm9d dts: Add chosen/stdout-path
[cascardo/linux.git] / drivers / net / wireless / iwlwifi / mvm / fw-api-power.h
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 - 2014 Intel Mobile Communications GmbH
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of version 2 of the GNU General Public License as
13  * published by the Free Software Foundation.
14  *
15  * This program is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
23  * USA
24  *
25  * The full GNU General Public License is included in this distribution
26  * in the file called COPYING.
27  *
28  * Contact Information:
29  *  Intel Linux Wireless <ilw@linux.intel.com>
30  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
31  *
32  * BSD LICENSE
33  *
34  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
35  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
36  * All rights reserved.
37  *
38  * Redistribution and use in source and binary forms, with or without
39  * modification, are permitted provided that the following conditions
40  * are met:
41  *
42  *  * Redistributions of source code must retain the above copyright
43  *    notice, this list of conditions and the following disclaimer.
44  *  * Redistributions in binary form must reproduce the above copyright
45  *    notice, this list of conditions and the following disclaimer in
46  *    the documentation and/or other materials provided with the
47  *    distribution.
48  *  * Neither the name Intel Corporation nor the names of its
49  *    contributors may be used to endorse or promote products derived
50  *    from this software without specific prior written permission.
51  *
52  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
53  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
54  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
55  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
56  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
57  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
58  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
59  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
60  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
61  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
62  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63  *
64  *****************************************************************************/
65
66 #ifndef __fw_api_power_h__
67 #define __fw_api_power_h__
68
69 /* Power Management Commands, Responses, Notifications */
70
71 /* Radio LP RX Energy Threshold measured in dBm */
72 #define POWER_LPRX_RSSI_THRESHOLD       75
73 #define POWER_LPRX_RSSI_THRESHOLD_MAX   94
74 #define POWER_LPRX_RSSI_THRESHOLD_MIN   30
75
76 /**
77  * enum iwl_scan_flags - masks for power table command flags
78  * @POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning off
79  *              receiver and transmitter. '0' - does not allow.
80  * @POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK: '0' Driver disables power management,
81  *              '1' Driver enables PM (use rest of parameters)
82  * @POWER_FLAGS_SKIP_OVER_DTIM_MSK: '0' PM have to walk up every DTIM,
83  *              '1' PM could sleep over DTIM till listen Interval.
84  * @POWER_FLAGS_SNOOZE_ENA_MSK: Enable snoozing only if uAPSD is enabled and all
85  *              access categories are both delivery and trigger enabled.
86  * @POWER_FLAGS_BT_SCO_ENA: Enable BT SCO coex only if uAPSD and
87  *              PBW Snoozing enabled
88  * @POWER_FLAGS_ADVANCE_PM_ENA_MSK: Advanced PM (uAPSD) enable mask
89  * @POWER_FLAGS_LPRX_ENA_MSK: Low Power RX enable.
90  * @POWER_FLAGS_AP_UAPSD_MISBEHAVING_ENA_MSK: AP/GO's uAPSD misbehaving
91  *              detection enablement
92 */
93 enum iwl_power_flags {
94         POWER_FLAGS_POWER_SAVE_ENA_MSK          = BIT(0),
95         POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK    = BIT(1),
96         POWER_FLAGS_SKIP_OVER_DTIM_MSK          = BIT(2),
97         POWER_FLAGS_SNOOZE_ENA_MSK              = BIT(5),
98         POWER_FLAGS_BT_SCO_ENA                  = BIT(8),
99         POWER_FLAGS_ADVANCE_PM_ENA_MSK          = BIT(9),
100         POWER_FLAGS_LPRX_ENA_MSK                = BIT(11),
101         POWER_FLAGS_UAPSD_MISBEHAVING_ENA_MSK   = BIT(12),
102 };
103
104 #define IWL_POWER_VEC_SIZE 5
105
106 /**
107  * struct iwl_powertable_cmd - legacy power command. Beside old API support this
108  *      is used also with a new power API for device wide power settings.
109  * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
110  *
111  * @flags:              Power table command flags from POWER_FLAGS_*
112  * @keep_alive_seconds: Keep alive period in seconds. Default - 25 sec.
113  *                      Minimum allowed:- 3 * DTIM. Keep alive period must be
114  *                      set regardless of power scheme or current power state.
115  *                      FW use this value also when PM is disabled.
116  * @rx_data_timeout:    Minimum time (usec) from last Rx packet for AM to
117  *                      PSM transition - legacy PM
118  * @tx_data_timeout:    Minimum time (usec) from last Tx packet for AM to
119  *                      PSM transition - legacy PM
120  * @sleep_interval:     not in use
121  * @skip_dtim_periods:  Number of DTIM periods to skip if Skip over DTIM flag
122  *                      is set. For example, if it is required to skip over
123  *                      one DTIM, this value need to be set to 2 (DTIM periods).
124  * @lprx_rssi_threshold: Signal strength up to which LP RX can be enabled.
125  *                      Default: 80dbm
126  */
127 struct iwl_powertable_cmd {
128         /* PM_POWER_TABLE_CMD_API_S_VER_6 */
129         __le16 flags;
130         u8 keep_alive_seconds;
131         u8 debug_flags;
132         __le32 rx_data_timeout;
133         __le32 tx_data_timeout;
134         __le32 sleep_interval[IWL_POWER_VEC_SIZE];
135         __le32 skip_dtim_periods;
136         __le32 lprx_rssi_threshold;
137 } __packed;
138
139 /**
140  * enum iwl_device_power_flags - masks for device power command flags
141  * @DEVIC_POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning off
142  *      receiver and transmitter. '0' - does not allow. This flag should be
143  *      always set to '1' unless one need to disable actual power down for debug
144  *      purposes.
145  * @DEVICE_POWER_FLAGS_CAM_MSK: '1' CAM (Continuous Active Mode) is set, meaning
146  *      that power management is disabled. '0' Power management is enabled, one
147  *      of power schemes is applied.
148 */
149 enum iwl_device_power_flags {
150         DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK   = BIT(0),
151         DEVICE_POWER_FLAGS_CAM_MSK              = BIT(13),
152 };
153
154 /**
155  * struct iwl_device_power_cmd - device wide power command.
156  * DEVICE_POWER_CMD = 0x77 (command, has simple generic response)
157  *
158  * @flags:      Power table command flags from DEVICE_POWER_FLAGS_*
159  */
160 struct iwl_device_power_cmd {
161         /* PM_POWER_TABLE_CMD_API_S_VER_6 */
162         __le16 flags;
163         __le16 reserved;
164 } __packed;
165
166 /**
167  * struct iwl_mac_power_cmd - New power command containing uAPSD support
168  * MAC_PM_POWER_TABLE = 0xA9 (command, has simple generic response)
169  * @id_and_color:       MAC contex identifier
170  * @flags:              Power table command flags from POWER_FLAGS_*
171  * @keep_alive_seconds: Keep alive period in seconds. Default - 25 sec.
172  *                      Minimum allowed:- 3 * DTIM. Keep alive period must be
173  *                      set regardless of power scheme or current power state.
174  *                      FW use this value also when PM is disabled.
175  * @rx_data_timeout:    Minimum time (usec) from last Rx packet for AM to
176  *                      PSM transition - legacy PM
177  * @tx_data_timeout:    Minimum time (usec) from last Tx packet for AM to
178  *                      PSM transition - legacy PM
179  * @sleep_interval:     not in use
180  * @skip_dtim_periods:  Number of DTIM periods to skip if Skip over DTIM flag
181  *                      is set. For example, if it is required to skip over
182  *                      one DTIM, this value need to be set to 2 (DTIM periods).
183  * @rx_data_timeout_uapsd: Minimum time (usec) from last Rx packet for AM to
184  *                      PSM transition - uAPSD
185  * @tx_data_timeout_uapsd: Minimum time (usec) from last Tx packet for AM to
186  *                      PSM transition - uAPSD
187  * @lprx_rssi_threshold: Signal strength up to which LP RX can be enabled.
188  *                      Default: 80dbm
189  * @num_skip_dtim:      Number of DTIMs to skip if Skip over DTIM flag is set
190  * @snooze_interval:    Maximum time between attempts to retrieve buffered data
191  *                      from the AP [msec]
192  * @snooze_window:      A window of time in which PBW snoozing insures that all
193  *                      packets received. It is also the minimum time from last
194  *                      received unicast RX packet, before client stops snoozing
195  *                      for data. [msec]
196  * @snooze_step:        TBD
197  * @qndp_tid:           TID client shall use for uAPSD QNDP triggers
198  * @uapsd_ac_flags:     Set trigger-enabled and delivery-enabled indication for
199  *                      each corresponding AC.
200  *                      Use IEEE80211_WMM_IE_STA_QOSINFO_AC* for correct values.
201  * @uapsd_max_sp:       Use IEEE80211_WMM_IE_STA_QOSINFO_SP_* for correct
202  *                      values.
203  * @heavy_tx_thld_packets:      TX threshold measured in number of packets
204  * @heavy_rx_thld_packets:      RX threshold measured in number of packets
205  * @heavy_tx_thld_percentage:   TX threshold measured in load's percentage
206  * @heavy_rx_thld_percentage:   RX threshold measured in load's percentage
207  * @limited_ps_threshold:
208 */
209 struct iwl_mac_power_cmd {
210         /* CONTEXT_DESC_API_T_VER_1 */
211         __le32 id_and_color;
212
213         /* CLIENT_PM_POWER_TABLE_S_VER_1 */
214         __le16 flags;
215         __le16 keep_alive_seconds;
216         __le32 rx_data_timeout;
217         __le32 tx_data_timeout;
218         __le32 rx_data_timeout_uapsd;
219         __le32 tx_data_timeout_uapsd;
220         u8 lprx_rssi_threshold;
221         u8 skip_dtim_periods;
222         __le16 snooze_interval;
223         __le16 snooze_window;
224         u8 snooze_step;
225         u8 qndp_tid;
226         u8 uapsd_ac_flags;
227         u8 uapsd_max_sp;
228         u8 heavy_tx_thld_packets;
229         u8 heavy_rx_thld_packets;
230         u8 heavy_tx_thld_percentage;
231         u8 heavy_rx_thld_percentage;
232         u8 limited_ps_threshold;
233         u8 reserved;
234 } __packed;
235
236 /*
237  * struct iwl_uapsd_misbehaving_ap_notif - FW sends this notification when
238  * associated AP is identified as improperly implementing uAPSD protocol.
239  * PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION = 0x78
240  * @sta_id: index of station in uCode's station table - associated AP ID in
241  *          this context.
242  */
243 struct iwl_uapsd_misbehaving_ap_notif {
244         __le32 sta_id;
245         u8 mac_id;
246         u8 reserved[3];
247 } __packed;
248
249 /**
250  * struct iwl_beacon_filter_cmd
251  * REPLY_BEACON_FILTERING_CMD = 0xd2 (command)
252  * @id_and_color: MAC contex identifier
253  * @bf_energy_delta: Used for RSSI filtering, if in 'normal' state. Send beacon
254  *      to driver if delta in Energy values calculated for this and last
255  *      passed beacon is greater than this threshold. Zero value means that
256  *      the Energy change is ignored for beacon filtering, and beacon will
257  *      not be forced to be sent to driver regardless of this delta. Typical
258  *      energy delta 5dB.
259  * @bf_roaming_energy_delta: Used for RSSI filtering, if in 'roaming' state.
260  *      Send beacon to driver if delta in Energy values calculated for this
261  *      and last passed beacon is greater than this threshold. Zero value
262  *      means that the Energy change is ignored for beacon filtering while in
263  *      Roaming state, typical energy delta 1dB.
264  * @bf_roaming_state: Used for RSSI filtering. If absolute Energy values
265  *      calculated for current beacon is less than the threshold, use
266  *      Roaming Energy Delta Threshold, otherwise use normal Energy Delta
267  *      Threshold. Typical energy threshold is -72dBm.
268  * @bf_temp_threshold: This threshold determines the type of temperature
269  *      filtering (Slow or Fast) that is selected (Units are in Celsuis):
270  *      If the current temperature is above this threshold - Fast filter
271  *      will be used, If the current temperature is below this threshold -
272  *      Slow filter will be used.
273  * @bf_temp_fast_filter: Send Beacon to driver if delta in temperature values
274  *      calculated for this and the last passed beacon is greater than this
275  *      threshold. Zero value means that the temperature change is ignored for
276  *      beacon filtering; beacons will not be  forced to be sent to driver
277  *      regardless of whether its temerature has been changed.
278  * @bf_temp_slow_filter: Send Beacon to driver if delta in temperature values
279  *      calculated for this and the last passed beacon is greater than this
280  *      threshold. Zero value means that the temperature change is ignored for
281  *      beacon filtering; beacons will not be forced to be sent to driver
282  *      regardless of whether its temerature has been changed.
283  * @bf_enable_beacon_filter: 1, beacon filtering is enabled; 0, disabled.
284  * @bf_filter_escape_timer: Send beacons to to driver if no beacons were passed
285  *      for a specific period of time. Units: Beacons.
286  * @ba_escape_timer: Fully receive and parse beacon if no beacons were passed
287  *      for a longer period of time then this escape-timeout. Units: Beacons.
288  * @ba_enable_beacon_abort: 1, beacon abort is enabled; 0, disabled.
289  */
290 struct iwl_beacon_filter_cmd {
291         __le32 bf_energy_delta;
292         __le32 bf_roaming_energy_delta;
293         __le32 bf_roaming_state;
294         __le32 bf_temp_threshold;
295         __le32 bf_temp_fast_filter;
296         __le32 bf_temp_slow_filter;
297         __le32 bf_enable_beacon_filter;
298         __le32 bf_debug_flag;
299         __le32 bf_escape_timer;
300         __le32 ba_escape_timer;
301         __le32 ba_enable_beacon_abort;
302 } __packed;
303
304 /* Beacon filtering and beacon abort */
305 #define IWL_BF_ENERGY_DELTA_DEFAULT 5
306 #define IWL_BF_ENERGY_DELTA_D0I3 20
307 #define IWL_BF_ENERGY_DELTA_MAX 255
308 #define IWL_BF_ENERGY_DELTA_MIN 0
309
310 #define IWL_BF_ROAMING_ENERGY_DELTA_DEFAULT 1
311 #define IWL_BF_ROAMING_ENERGY_DELTA_D0I3 20
312 #define IWL_BF_ROAMING_ENERGY_DELTA_MAX 255
313 #define IWL_BF_ROAMING_ENERGY_DELTA_MIN 0
314
315 #define IWL_BF_ROAMING_STATE_DEFAULT 72
316 #define IWL_BF_ROAMING_STATE_D0I3 72
317 #define IWL_BF_ROAMING_STATE_MAX 255
318 #define IWL_BF_ROAMING_STATE_MIN 0
319
320 #define IWL_BF_TEMP_THRESHOLD_DEFAULT 112
321 #define IWL_BF_TEMP_THRESHOLD_D0I3 112
322 #define IWL_BF_TEMP_THRESHOLD_MAX 255
323 #define IWL_BF_TEMP_THRESHOLD_MIN 0
324
325 #define IWL_BF_TEMP_FAST_FILTER_DEFAULT 1
326 #define IWL_BF_TEMP_FAST_FILTER_D0I3 1
327 #define IWL_BF_TEMP_FAST_FILTER_MAX 255
328 #define IWL_BF_TEMP_FAST_FILTER_MIN 0
329
330 #define IWL_BF_TEMP_SLOW_FILTER_DEFAULT 5
331 #define IWL_BF_TEMP_SLOW_FILTER_D0I3 5
332 #define IWL_BF_TEMP_SLOW_FILTER_MAX 255
333 #define IWL_BF_TEMP_SLOW_FILTER_MIN 0
334
335 #define IWL_BF_ENABLE_BEACON_FILTER_DEFAULT 1
336
337 #define IWL_BF_DEBUG_FLAG_DEFAULT 0
338 #define IWL_BF_DEBUG_FLAG_D0I3 0
339
340 #define IWL_BF_ESCAPE_TIMER_DEFAULT 50
341 #define IWL_BF_ESCAPE_TIMER_D0I3 0
342 #define IWL_BF_ESCAPE_TIMER_MAX 1024
343 #define IWL_BF_ESCAPE_TIMER_MIN 0
344
345 #define IWL_BA_ESCAPE_TIMER_DEFAULT 6
346 #define IWL_BA_ESCAPE_TIMER_D0I3 6
347 #define IWL_BA_ESCAPE_TIMER_D3 9
348 #define IWL_BA_ESCAPE_TIMER_MAX 1024
349 #define IWL_BA_ESCAPE_TIMER_MIN 0
350
351 #define IWL_BA_ENABLE_BEACON_ABORT_DEFAULT 1
352
353 #define IWL_BF_CMD_CONFIG(mode)                                      \
354         .bf_energy_delta = cpu_to_le32(IWL_BF_ENERGY_DELTA ## mode),          \
355         .bf_roaming_energy_delta =                                            \
356                 cpu_to_le32(IWL_BF_ROAMING_ENERGY_DELTA ## mode),             \
357         .bf_roaming_state = cpu_to_le32(IWL_BF_ROAMING_STATE ## mode),        \
358         .bf_temp_threshold = cpu_to_le32(IWL_BF_TEMP_THRESHOLD ## mode),      \
359         .bf_temp_fast_filter = cpu_to_le32(IWL_BF_TEMP_FAST_FILTER ## mode),  \
360         .bf_temp_slow_filter = cpu_to_le32(IWL_BF_TEMP_SLOW_FILTER ## mode),  \
361         .bf_debug_flag = cpu_to_le32(IWL_BF_DEBUG_FLAG ## mode),              \
362         .bf_escape_timer = cpu_to_le32(IWL_BF_ESCAPE_TIMER ## mode),          \
363         .ba_escape_timer = cpu_to_le32(IWL_BA_ESCAPE_TIMER ## mode)
364
365 #define IWL_BF_CMD_CONFIG_DEFAULTS IWL_BF_CMD_CONFIG(_DEFAULT)
366 #define IWL_BF_CMD_CONFIG_D0I3 IWL_BF_CMD_CONFIG(_D0I3)
367 #endif