Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /******************************************************************************
0003  *
0004  * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.
0005  *
0006  * Portions of this file are derived from the ipw3945 project, as well
0007  * as portions of the ieee80211 subsystem header files.
0008  *****************************************************************************/
0009 #ifndef __iwl_tt_setting_h__
0010 #define __iwl_tt_setting_h__
0011 
0012 #include "commands.h"
0013 
0014 #define IWL_ABSOLUTE_ZERO       0
0015 #define IWL_ABSOLUTE_MAX        0xFFFFFFFF
0016 #define IWL_TT_INCREASE_MARGIN  5
0017 #define IWL_TT_CT_KILL_MARGIN   3
0018 
0019 enum iwl_antenna_ok {
0020     IWL_ANT_OK_NONE,
0021     IWL_ANT_OK_SINGLE,
0022     IWL_ANT_OK_MULTI,
0023 };
0024 
0025 /* Thermal Throttling State Machine states */
0026 enum  iwl_tt_state {
0027     IWL_TI_0,   /* normal temperature, system power state */
0028     IWL_TI_1,   /* high temperature detect, low power state */
0029     IWL_TI_2,   /* higher temperature detected, lower power state */
0030     IWL_TI_CT_KILL, /* critical temperature detected, lowest power state */
0031     IWL_TI_STATE_MAX
0032 };
0033 
0034 /**
0035  * struct iwl_tt_restriction - Thermal Throttling restriction table
0036  * @tx_stream: number of tx stream allowed
0037  * @is_ht: ht enable/disable
0038  * @rx_stream: number of rx stream allowed
0039  *
0040  * This table is used by advance thermal throttling management
0041  * based on the current thermal throttling state, and determines
0042  * the number of tx/rx streams and the status of HT operation.
0043  */
0044 struct iwl_tt_restriction {
0045     enum iwl_antenna_ok tx_stream;
0046     enum iwl_antenna_ok rx_stream;
0047     bool is_ht;
0048 };
0049 
0050 /**
0051  * struct iwl_tt_trans - Thermal Throttling transaction table
0052  * @next_state:  next thermal throttling mode
0053  * @tt_low: low temperature threshold to change state
0054  * @tt_high: high temperature threshold to change state
0055  *
0056  * This is used by the advanced thermal throttling algorithm
0057  * to determine the next thermal state to go based on the
0058  * current temperature.
0059  */
0060 struct iwl_tt_trans {
0061     enum iwl_tt_state next_state;
0062     u32 tt_low;
0063     u32 tt_high;
0064 };
0065 
0066 /**
0067  * struct iwl_tt_mgnt - Thermal Throttling Management structure
0068  * @advanced_tt:    advanced thermal throttle required
0069  * @state:          current Thermal Throttling state
0070  * @tt_power_mode:  Thermal Throttling power mode index
0071  *          being used to set power level when
0072  *          when thermal throttling state != IWL_TI_0
0073  *          the tt_power_mode should set to different
0074  *          power mode based on the current tt state
0075  * @tt_previous_temperature: last measured temperature
0076  * @iwl_tt_restriction: ptr to restriction tbl, used by advance
0077  *          thermal throttling to determine how many tx/rx streams
0078  *          should be used in tt state; and can HT be enabled or not
0079  * @iwl_tt_trans: ptr to adv trans table, used by advance thermal throttling
0080  *          state transaction
0081  * @ct_kill_toggle: used to toggle the CSR bit when checking uCode temperature
0082  * @ct_kill_exit_tm: timer to exit thermal kill
0083  */
0084 struct iwl_tt_mgmt {
0085     enum iwl_tt_state state;
0086     bool advanced_tt;
0087     u8 tt_power_mode;
0088     bool ct_kill_toggle;
0089 #ifdef CONFIG_IWLWIFI_DEBUG
0090     s32 tt_previous_temp;
0091 #endif
0092     struct iwl_tt_restriction *restriction;
0093     struct iwl_tt_trans *transaction;
0094     struct timer_list ct_kill_exit_tm;
0095     struct timer_list ct_kill_waiting_tm;
0096 };
0097 
0098 u8 iwl_tt_current_power_mode(struct iwl_priv *priv);
0099 bool iwl_tt_is_low_power_state(struct iwl_priv *priv);
0100 bool iwl_ht_enabled(struct iwl_priv *priv);
0101 enum iwl_antenna_ok iwl_tx_ant_restriction(struct iwl_priv *priv);
0102 enum iwl_antenna_ok iwl_rx_ant_restriction(struct iwl_priv *priv);
0103 void iwl_tt_enter_ct_kill(struct iwl_priv *priv);
0104 void iwl_tt_exit_ct_kill(struct iwl_priv *priv);
0105 void iwl_tt_handler(struct iwl_priv *priv);
0106 void iwl_tt_initialize(struct iwl_priv *priv);
0107 void iwl_tt_exit(struct iwl_priv *priv);
0108 
0109 #endif  /* __iwl_tt_setting_h__ */