aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorEsti Kummer <stkumer@localhost.localdomain>2008-07-18 01:52:58 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-08-04 15:09:06 -0400
commit298df1f62aa69881528bf0f1c3c14395bc447846 (patch)
tree0b372342e79a1ef5746179d57fe6c7c5ada9496b /drivers
parentca579617d81baf5865498eb5fae58e453ee77c2c (diff)
iwlwifi: corrects power_level in sysfs
This patch corrects power_level in sysfs. Signed-off-by: Esti Kummer <ester.kummer@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Zhu Yi <yi.zhu@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c27
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.h31
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c63
3 files changed, 58 insertions, 63 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index e3c71beb01ef..028e3053c0ca 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -82,7 +82,7 @@
82 82
83/* default power management (not Tx power) table values */ 83/* default power management (not Tx power) table values */
84/* for tim 0-10 */ 84/* for tim 0-10 */
85static struct iwl_power_vec_entry range_0[IWL_POWER_AC] = { 85static struct iwl_power_vec_entry range_0[IWL_POWER_MAX] = {
86 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, 86 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
87 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0}, 87 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0},
88 {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0}, 88 {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0},
@@ -93,7 +93,7 @@ static struct iwl_power_vec_entry range_0[IWL_POWER_AC] = {
93 93
94 94
95/* for tim = 3-10 */ 95/* for tim = 3-10 */
96static struct iwl_power_vec_entry range_1[IWL_POWER_AC] = { 96static struct iwl_power_vec_entry range_1[IWL_POWER_MAX] = {
97 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, 97 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
98 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 4)}, 0}, 98 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 4)}, 0},
99 {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(1, 2, 3, 4, 7)}, 0}, 99 {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(1, 2, 3, 4, 7)}, 0},
@@ -103,7 +103,7 @@ static struct iwl_power_vec_entry range_1[IWL_POWER_AC] = {
103}; 103};
104 104
105/* for tim > 11 */ 105/* for tim > 11 */
106static struct iwl_power_vec_entry range_2[IWL_POWER_AC] = { 106static struct iwl_power_vec_entry range_2[IWL_POWER_MAX] = {
107 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, 107 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
108 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 0xFF)}, 0}, 108 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 0xFF)}, 0},
109 {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(2, 4, 6, 7, 0xFF)}, 0}, 109 {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(2, 4, 6, 7, 0xFF)}, 0},
@@ -124,7 +124,7 @@ static int iwl_set_power(struct iwl_priv *priv, void *cmd)
124 */ 124 */
125static u16 iwl_get_auto_power_mode(struct iwl_priv *priv) 125static u16 iwl_get_auto_power_mode(struct iwl_priv *priv)
126{ 126{
127 u16 mode = priv->power_data.user_power_setting; 127 u16 mode;
128 128
129 switch (priv->power_data.user_power_setting) { 129 switch (priv->power_data.user_power_setting) {
130 case IWL_POWER_AUTO: 130 case IWL_POWER_AUTO:
@@ -136,12 +136,16 @@ static u16 iwl_get_auto_power_mode(struct iwl_priv *priv)
136 else 136 else
137 mode = IWL_POWER_ON_AC_DISASSOC; 137 mode = IWL_POWER_ON_AC_DISASSOC;
138 break; 138 break;
139 /* FIXME: remove battery and ac from here */
139 case IWL_POWER_BATTERY: 140 case IWL_POWER_BATTERY:
140 mode = IWL_POWER_INDEX_3; 141 mode = IWL_POWER_INDEX_3;
141 break; 142 break;
142 case IWL_POWER_AC: 143 case IWL_POWER_AC:
143 mode = IWL_POWER_MODE_CAM; 144 mode = IWL_POWER_MODE_CAM;
144 break; 145 break;
146 default:
147 mode = priv->power_data.user_power_setting;
148 break;
145 } 149 }
146 return mode; 150 return mode;
147} 151}
@@ -151,7 +155,7 @@ static int iwl_power_init_handle(struct iwl_priv *priv)
151{ 155{
152 int ret = 0, i; 156 int ret = 0, i;
153 struct iwl_power_mgr *pow_data; 157 struct iwl_power_mgr *pow_data;
154 int size = sizeof(struct iwl_power_vec_entry) * IWL_POWER_AC; 158 int size = sizeof(struct iwl_power_vec_entry) * IWL_POWER_MAX;
155 u16 pci_pm; 159 u16 pci_pm;
156 160
157 IWL_DEBUG_POWER("Initialize power \n"); 161 IWL_DEBUG_POWER("Initialize power \n");
@@ -173,7 +177,7 @@ static int iwl_power_init_handle(struct iwl_priv *priv)
173 177
174 IWL_DEBUG_POWER("adjust power command flags\n"); 178 IWL_DEBUG_POWER("adjust power command flags\n");
175 179
176 for (i = 0; i < IWL_POWER_AC; i++) { 180 for (i = 0; i < IWL_POWER_MAX; i++) {
177 cmd = &pow_data->pwr_range_0[i].cmd; 181 cmd = &pow_data->pwr_range_0[i].cmd;
178 182
179 if (pci_pm & 0x1) 183 if (pci_pm & 0x1)
@@ -265,17 +269,18 @@ int iwl_power_update_mode(struct iwl_priv *priv, u8 refresh)
265 * else user level */ 269 * else user level */
266 270
267 switch (setting->system_power_setting) { 271 switch (setting->system_power_setting) {
268 case IWL_POWER_AUTO: 272 case IWL_POWER_SYS_AUTO:
269 final_mode = iwl_get_auto_power_mode(priv); 273 final_mode = iwl_get_auto_power_mode(priv);
270 break; 274 break;
271 case IWL_POWER_BATTERY: 275 case IWL_POWER_SYS_BATTERY:
272 final_mode = IWL_POWER_INDEX_3; 276 final_mode = IWL_POWER_INDEX_3;
273 break; 277 break;
274 case IWL_POWER_AC: 278 case IWL_POWER_SYS_AC:
275 final_mode = IWL_POWER_MODE_CAM; 279 final_mode = IWL_POWER_MODE_CAM;
276 break; 280 break;
277 default: 281 default:
278 final_mode = setting->system_power_setting; 282 final_mode = IWL_POWER_INDEX_3;
283 WARN_ON(1);
279 } 284 }
280 285
281 if (setting->critical_power_setting > final_mode) 286 if (setting->critical_power_setting > final_mode)
@@ -394,7 +399,7 @@ void iwl_power_initialize(struct iwl_priv *priv)
394 iwl_power_init_handle(priv); 399 iwl_power_init_handle(priv);
395 priv->power_data.user_power_setting = IWL_POWER_AUTO; 400 priv->power_data.user_power_setting = IWL_POWER_AUTO;
396 priv->power_data.power_disabled = 0; 401 priv->power_data.power_disabled = 0;
397 priv->power_data.system_power_setting = IWL_POWER_AUTO; 402 priv->power_data.system_power_setting = IWL_POWER_SYS_AUTO;
398 priv->power_data.is_battery_active = 0; 403 priv->power_data.is_battery_active = 0;
399 priv->power_data.power_disabled = 0; 404 priv->power_data.power_disabled = 0;
400 priv->power_data.critical_power_setting = 0; 405 priv->power_data.critical_power_setting = 0;
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.h b/drivers/net/wireless/iwlwifi/iwl-power.h
index 801f6143a42c..abcbbf96a84e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.h
+++ b/drivers/net/wireless/iwlwifi/iwl-power.h
@@ -33,12 +33,25 @@
33 33
34struct iwl_priv; 34struct iwl_priv;
35 35
36#define IWL_POWER_MODE_CAM 0x00 /* Continuously Aware Mode, always on */ 36enum {
37#define IWL_POWER_INDEX_3 0x03 37 IWL_POWER_MODE_CAM, /* Continuously Aware Mode, always on */
38#define IWL_POWER_INDEX_5 0x05 38 IWL_POWER_INDEX_1,
39#define IWL_POWER_AC 0x06 39 IWL_POWER_INDEX_2,
40#define IWL_POWER_BATTERY 0x07 40 IWL_POWER_INDEX_3,
41#define IWL_POWER_AUTO 0x08 41 IWL_POWER_INDEX_4,
42 IWL_POWER_INDEX_5,
43 IWL_POWER_AUTO,
44 IWL_POWER_MAX = IWL_POWER_AUTO,
45 IWL_POWER_AC,
46 IWL_POWER_BATTERY,
47};
48
49enum {
50 IWL_POWER_SYS_AUTO,
51 IWL_POWER_SYS_AC,
52 IWL_POWER_SYS_BATTERY,
53};
54
42#define IWL_POWER_LIMIT 0x08 55#define IWL_POWER_LIMIT 0x08
43#define IWL_POWER_MASK 0x0F 56#define IWL_POWER_MASK 0x0F
44#define IWL_POWER_ENABLED 0x10 57#define IWL_POWER_ENABLED 0x10
@@ -52,9 +65,9 @@ struct iwl_power_vec_entry {
52 65
53struct iwl_power_mgr { 66struct iwl_power_mgr {
54 spinlock_t lock; 67 spinlock_t lock;
55 struct iwl_power_vec_entry pwr_range_0[IWL_POWER_AC]; 68 struct iwl_power_vec_entry pwr_range_0[IWL_POWER_MAX];
56 struct iwl_power_vec_entry pwr_range_1[IWL_POWER_AC]; 69 struct iwl_power_vec_entry pwr_range_1[IWL_POWER_MAX];
57 struct iwl_power_vec_entry pwr_range_2[IWL_POWER_AC]; 70 struct iwl_power_vec_entry pwr_range_2[IWL_POWER_MAX];
58 u32 dtim_period; 71 u32 dtim_period;
59 /* final power level that used to calculate final power command */ 72 /* final power level that used to calculate final power command */
60 u8 power_mode; 73 u8 power_mode;
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index 71f5da3fe5c4..2001b09738ff 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -3800,76 +3800,53 @@ static ssize_t store_power_level(struct device *d,
3800 const char *buf, size_t count) 3800 const char *buf, size_t count)
3801{ 3801{
3802 struct iwl_priv *priv = dev_get_drvdata(d); 3802 struct iwl_priv *priv = dev_get_drvdata(d);
3803 int rc; 3803 int ret;
3804 int mode; 3804 int mode;
3805 3805
3806 mode = simple_strtoul(buf, NULL, 0); 3806 mode = simple_strtoul(buf, NULL, 0);
3807 mutex_lock(&priv->mutex); 3807 mutex_lock(&priv->mutex);
3808 3808
3809 if (!iwl_is_ready(priv)) { 3809 if (!iwl_is_ready(priv)) {
3810 rc = -EAGAIN; 3810 ret = -EAGAIN;
3811 goto out; 3811 goto out;
3812 } 3812 }
3813 3813
3814 rc = iwl_power_set_user_mode(priv, mode); 3814 ret = iwl_power_set_user_mode(priv, mode);
3815 if (rc) { 3815 if (ret) {
3816 IWL_DEBUG_MAC80211("failed setting power mode.\n"); 3816 IWL_DEBUG_MAC80211("failed setting power mode.\n");
3817 goto out; 3817 goto out;
3818 } 3818 }
3819 rc = count; 3819 ret = count;
3820 3820
3821 out: 3821 out:
3822 mutex_unlock(&priv->mutex); 3822 mutex_unlock(&priv->mutex);
3823 return rc; 3823 return ret;
3824} 3824}
3825 3825
3826#define MAX_WX_STRING 80
3827
3828/* Values are in microsecond */
3829static const s32 timeout_duration[] = {
3830 350000,
3831 250000,
3832 75000,
3833 37000,
3834 25000,
3835};
3836static const s32 period_duration[] = {
3837 400000,
3838 700000,
3839 1000000,
3840 1000000,
3841 1000000
3842};
3843
3844static ssize_t show_power_level(struct device *d, 3826static ssize_t show_power_level(struct device *d,
3845 struct device_attribute *attr, char *buf) 3827 struct device_attribute *attr, char *buf)
3846{ 3828{
3847 struct iwl_priv *priv = dev_get_drvdata(d); 3829 struct iwl_priv *priv = dev_get_drvdata(d);
3830 int mode = priv->power_data.user_power_setting;
3831 int system = priv->power_data.system_power_setting;
3848 int level = priv->power_data.power_mode; 3832 int level = priv->power_data.power_mode;
3849 char *p = buf; 3833 char *p = buf;
3850 3834
3851 p += sprintf(p, "%d ", level); 3835 switch (system) {
3852 switch (level) { 3836 case IWL_POWER_SYS_AUTO:
3853 case IWL_POWER_MODE_CAM: 3837 p += sprintf(p, "SYSTEM:auto");
3854 case IWL_POWER_AC:
3855 p += sprintf(p, "(AC)");
3856 break; 3838 break;
3857 case IWL_POWER_BATTERY: 3839 case IWL_POWER_SYS_AC:
3858 p += sprintf(p, "(BATTERY)"); 3840 p += sprintf(p, "SYSTEM:ac");
3841 break;
3842 case IWL_POWER_SYS_BATTERY:
3843 p += sprintf(p, "SYSTEM:battery");
3859 break; 3844 break;
3860 default:
3861 p += sprintf(p,
3862 "(Timeout %dms, Period %dms)",
3863 timeout_duration[level - 1] / 1000,
3864 period_duration[level - 1] / 1000);
3865 } 3845 }
3866/* 3846
3867 if (!(priv->power_mode & IWL_POWER_ENABLED)) 3847 p += sprintf(p, "\tMODE:%s", (mode < IWL_POWER_AUTO)?"fixed":"auto");
3868 p += sprintf(p, " OFF\n"); 3848 p += sprintf(p, "\tINDEX:%d", level);
3869 else 3849 p += sprintf(p, "\n");
3870 p += sprintf(p, " \n");
3871*/
3872 p += sprintf(p, " \n");
3873 return (p - buf + 1); 3850 return (p - buf + 1);
3874} 3851}
3875 3852