Merge tag 'cramfs_fixes' of git://git.linaro.org/people/nicolas.pitre/linux
[linux-2.6-microblaze.git] / drivers / net / wireless / intel / iwlwifi / dvm / tt.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.
4  *
5  * Portions of this file are derived from the ipw3945 project, as well
6  * as portions of the ieee80211 subsystem header files.
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of version 2 of the GNU General Public License as
10  * published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  * more details.
16  *
17  * The full GNU General Public License is included in this distribution in the
18  * file called LICENSE.
19  *
20  * Contact Information:
21  *  Intel Linux Wireless <linuxwifi@intel.com>
22  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
23  *****************************************************************************/
24 #ifndef __iwl_tt_setting_h__
25 #define __iwl_tt_setting_h__
26
27 #include "commands.h"
28
29 #define IWL_ABSOLUTE_ZERO               0
30 #define IWL_ABSOLUTE_MAX                0xFFFFFFFF
31 #define IWL_TT_INCREASE_MARGIN  5
32 #define IWL_TT_CT_KILL_MARGIN   3
33
34 enum iwl_antenna_ok {
35         IWL_ANT_OK_NONE,
36         IWL_ANT_OK_SINGLE,
37         IWL_ANT_OK_MULTI,
38 };
39
40 /* Thermal Throttling State Machine states */
41 enum  iwl_tt_state {
42         IWL_TI_0,       /* normal temperature, system power state */
43         IWL_TI_1,       /* high temperature detect, low power state */
44         IWL_TI_2,       /* higher temperature detected, lower power state */
45         IWL_TI_CT_KILL, /* critical temperature detected, lowest power state */
46         IWL_TI_STATE_MAX
47 };
48
49 /**
50  * struct iwl_tt_restriction - Thermal Throttling restriction table
51  * @tx_stream: number of tx stream allowed
52  * @is_ht: ht enable/disable
53  * @rx_stream: number of rx stream allowed
54  *
55  * This table is used by advance thermal throttling management
56  * based on the current thermal throttling state, and determines
57  * the number of tx/rx streams and the status of HT operation.
58  */
59 struct iwl_tt_restriction {
60         enum iwl_antenna_ok tx_stream;
61         enum iwl_antenna_ok rx_stream;
62         bool is_ht;
63 };
64
65 /**
66  * struct iwl_tt_trans - Thermal Throttling transaction table
67  * @next_state:  next thermal throttling mode
68  * @tt_low: low temperature threshold to change state
69  * @tt_high: high temperature threshold to change state
70  *
71  * This is used by the advanced thermal throttling algorithm
72  * to determine the next thermal state to go based on the
73  * current temperature.
74  */
75 struct iwl_tt_trans {
76         enum iwl_tt_state next_state;
77         u32 tt_low;
78         u32 tt_high;
79 };
80
81 /**
82  * struct iwl_tt_mgnt - Thermal Throttling Management structure
83  * @advanced_tt:    advanced thermal throttle required
84  * @state:          current Thermal Throttling state
85  * @tt_power_mode:  Thermal Throttling power mode index
86  *                  being used to set power level when
87  *                  when thermal throttling state != IWL_TI_0
88  *                  the tt_power_mode should set to different
89  *                  power mode based on the current tt state
90  * @tt_previous_temperature: last measured temperature
91  * @iwl_tt_restriction: ptr to restriction tbl, used by advance
92  *                  thermal throttling to determine how many tx/rx streams
93  *                  should be used in tt state; and can HT be enabled or not
94  * @iwl_tt_trans: ptr to adv trans table, used by advance thermal throttling
95  *                  state transaction
96  * @ct_kill_toggle: used to toggle the CSR bit when checking uCode temperature
97  * @ct_kill_exit_tm: timer to exit thermal kill
98  */
99 struct iwl_tt_mgmt {
100         enum iwl_tt_state state;
101         bool advanced_tt;
102         u8 tt_power_mode;
103         bool ct_kill_toggle;
104 #ifdef CONFIG_IWLWIFI_DEBUG
105         s32 tt_previous_temp;
106 #endif
107         struct iwl_tt_restriction *restriction;
108         struct iwl_tt_trans *transaction;
109         struct timer_list ct_kill_exit_tm;
110         struct timer_list ct_kill_waiting_tm;
111 };
112
113 u8 iwl_tt_current_power_mode(struct iwl_priv *priv);
114 bool iwl_tt_is_low_power_state(struct iwl_priv *priv);
115 bool iwl_ht_enabled(struct iwl_priv *priv);
116 enum iwl_antenna_ok iwl_tx_ant_restriction(struct iwl_priv *priv);
117 enum iwl_antenna_ok iwl_rx_ant_restriction(struct iwl_priv *priv);
118 void iwl_tt_enter_ct_kill(struct iwl_priv *priv);
119 void iwl_tt_exit_ct_kill(struct iwl_priv *priv);
120 void iwl_tt_handler(struct iwl_priv *priv);
121 void iwl_tt_initialize(struct iwl_priv *priv);
122 void iwl_tt_exit(struct iwl_priv *priv);
123
124 #endif  /* __iwl_tt_setting_h__ */