diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2008-09-02 23:26:49 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-09-08 14:23:19 -0400 |
commit | e7b635814b640c6fd9dca1c254dc22fac6fb9a1a (patch) | |
tree | ff09a16f4a704b81dedde80a68728ddc4e423505 /drivers/net/wireless | |
parent | 926f0b2ef24041db876ec7213fbddd7cd4555951 (diff) |
iwlwifi: cleanup PCI register handling
This patch cleans up pci registers handling.
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/net/wireless')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-4965-hw.h | 13 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-4965.c | 6 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-5000.c | 6 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn.c | 9 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-commands.h | 4 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-power.c | 27 |
6 files changed, 31 insertions, 34 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h index fce950f4163c..f4793a609443 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h | |||
@@ -98,16 +98,17 @@ | |||
98 | #define IWL_RSSI_OFFSET 44 | 98 | #define IWL_RSSI_OFFSET 44 |
99 | 99 | ||
100 | 100 | ||
101 | #include "iwl-commands.h" | ||
102 | 101 | ||
103 | /* PCI registers */ | 102 | /* PCI registers */ |
104 | #define PCI_LINK_CTRL 0x0F0 /* 1 byte */ | 103 | #define PCI_CFG_RETRY_TIMEOUT 0x041 |
105 | #define PCI_POWER_SOURCE 0x0C8 | 104 | #define PCI_CFG_POWER_SOURCE 0x0C8 |
106 | #define PCI_REG_WUM8 0x0E8 | 105 | #define PCI_REG_WUM8 0x0E8 |
106 | #define PCI_CFG_LINK_CTRL 0x0F0 | ||
107 | 107 | ||
108 | /* PCI register values */ | 108 | /* PCI register values */ |
109 | #define PCI_LINK_VAL_L0S_EN 0x01 | 109 | #define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 |
110 | #define PCI_LINK_VAL_L1_EN 0x02 | 110 | #define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 |
111 | #define PCI_CFG_CMD_REG_INT_DIS_MSK 0x04 | ||
111 | #define PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT (0x80000000) | 112 | #define PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT (0x80000000) |
112 | 113 | ||
113 | #define TFD_QUEUE_SIZE_MAX (256) | 114 | #define TFD_QUEUE_SIZE_MAX (256) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c index e2581229d8b2..46e076af8f7e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c | |||
@@ -399,7 +399,7 @@ static void iwl4965_nic_config(struct iwl_priv *priv) | |||
399 | unsigned long flags; | 399 | unsigned long flags; |
400 | u32 val; | 400 | u32 val; |
401 | u16 radio_cfg; | 401 | u16 radio_cfg; |
402 | u8 val_link; | 402 | u16 link; |
403 | 403 | ||
404 | spin_lock_irqsave(&priv->lock, flags); | 404 | spin_lock_irqsave(&priv->lock, flags); |
405 | 405 | ||
@@ -410,10 +410,10 @@ static void iwl4965_nic_config(struct iwl_priv *priv) | |||
410 | val & ~(1 << 11)); | 410 | val & ~(1 << 11)); |
411 | } | 411 | } |
412 | 412 | ||
413 | pci_read_config_byte(priv->pci_dev, PCI_LINK_CTRL, &val_link); | 413 | pci_read_config_word(priv->pci_dev, PCI_CFG_LINK_CTRL, &link); |
414 | 414 | ||
415 | /* L1 is enabled by BIOS */ | 415 | /* L1 is enabled by BIOS */ |
416 | if ((val_link & PCI_LINK_VAL_L1_EN) == PCI_LINK_VAL_L1_EN) | 416 | if ((link & PCI_CFG_LINK_CTRL_VAL_L1_EN) == PCI_CFG_LINK_CTRL_VAL_L1_EN) |
417 | /* diable L0S disabled L1A enabled */ | 417 | /* diable L0S disabled L1A enabled */ |
418 | iwl_set_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); | 418 | iwl_set_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); |
419 | else | 419 | else |
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index 8b6a72949ac0..ef9d3399dfd2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c | |||
@@ -208,14 +208,14 @@ static void iwl5000_nic_config(struct iwl_priv *priv) | |||
208 | { | 208 | { |
209 | unsigned long flags; | 209 | unsigned long flags; |
210 | u16 radio_cfg; | 210 | u16 radio_cfg; |
211 | u8 val_link; | 211 | u16 link; |
212 | 212 | ||
213 | spin_lock_irqsave(&priv->lock, flags); | 213 | spin_lock_irqsave(&priv->lock, flags); |
214 | 214 | ||
215 | pci_read_config_byte(priv->pci_dev, PCI_LINK_CTRL, &val_link); | 215 | pci_read_config_word(priv->pci_dev, PCI_CFG_LINK_CTRL, &link); |
216 | 216 | ||
217 | /* L1 is enabled by BIOS */ | 217 | /* L1 is enabled by BIOS */ |
218 | if ((val_link & PCI_LINK_VAL_L1_EN) == PCI_LINK_VAL_L1_EN) | 218 | if ((link & PCI_CFG_LINK_CTRL_VAL_L1_EN) == PCI_CFG_LINK_CTRL_VAL_L1_EN) |
219 | /* diable L0S disabled L1A enabled */ | 219 | /* diable L0S disabled L1A enabled */ |
220 | iwl_set_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); | 220 | iwl_set_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); |
221 | else | 221 | else |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index ffaf3f2e8a9e..250473138f30 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c | |||
@@ -1273,7 +1273,7 @@ int iwl4965_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src) | |||
1273 | 1273 | ||
1274 | if (src == IWL_PWR_SRC_VAUX) { | 1274 | if (src == IWL_PWR_SRC_VAUX) { |
1275 | u32 val; | 1275 | u32 val; |
1276 | ret = pci_read_config_dword(priv->pci_dev, PCI_POWER_SOURCE, | 1276 | ret = pci_read_config_dword(priv->pci_dev, PCI_CFG_POWER_SOURCE, |
1277 | &val); | 1277 | &val); |
1278 | 1278 | ||
1279 | if (val & PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT) | 1279 | if (val & PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT) |
@@ -4229,9 +4229,6 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
4229 | 4229 | ||
4230 | pci_set_drvdata(pdev, priv); | 4230 | pci_set_drvdata(pdev, priv); |
4231 | 4231 | ||
4232 | /* We disable the RETRY_TIMEOUT register (0x41) to keep | ||
4233 | * PCI Tx retries from interfering with C3 CPU state */ | ||
4234 | pci_write_config_byte(pdev, 0x41, 0x00); | ||
4235 | 4232 | ||
4236 | /*********************** | 4233 | /*********************** |
4237 | * 3. Read REV register | 4234 | * 3. Read REV register |
@@ -4251,6 +4248,10 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
4251 | ": Detected Intel Wireless WiFi Link %s REV=0x%X\n", | 4248 | ": Detected Intel Wireless WiFi Link %s REV=0x%X\n", |
4252 | priv->cfg->name, priv->hw_rev); | 4249 | priv->cfg->name, priv->hw_rev); |
4253 | 4250 | ||
4251 | /* We disable the RETRY_TIMEOUT register (0x41) to keep | ||
4252 | * PCI Tx retries from interfering with C3 CPU state */ | ||
4253 | pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); | ||
4254 | |||
4254 | /* amp init */ | 4255 | /* amp init */ |
4255 | err = priv->cfg->ops->lib->apm_ops.init(priv); | 4256 | err = priv->cfg->ops->lib->apm_ops.init(priv); |
4256 | if (err < 0) { | 4257 | if (err < 0) { |
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h index 28b5b09996ed..fbd8cc1f51df 100644 --- a/drivers/net/wireless/iwlwifi/iwl-commands.h +++ b/drivers/net/wireless/iwlwifi/iwl-commands.h | |||
@@ -2026,8 +2026,8 @@ struct iwl4965_spectrum_notification { | |||
2026 | * bit 2 - '0' PM have to walk up every DTIM | 2026 | * bit 2 - '0' PM have to walk up every DTIM |
2027 | * '1' PM could sleep over DTIM till listen Interval. | 2027 | * '1' PM could sleep over DTIM till listen Interval. |
2028 | * PCI power managed | 2028 | * PCI power managed |
2029 | * bit 3 - '0' (PCI_LINK_CTRL & 0x1) | 2029 | * bit 3 - '0' (PCI_CFG_LINK_CTRL & 0x1) |
2030 | * '1' !(PCI_LINK_CTRL & 0x1) | 2030 | * '1' !(PCI_CFG_LINK_CTRL & 0x1) |
2031 | * Force sleep Modes | 2031 | * Force sleep Modes |
2032 | * bit 31/30- '00' use both mac/xtal sleeps | 2032 | * bit 31/30- '00' use both mac/xtal sleeps |
2033 | * '01' force Mac sleep | 2033 | * '01' force Mac sleep |
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c index a099c9e30e55..eb6312d867d1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-power.c +++ b/drivers/net/wireless/iwlwifi/iwl-power.c | |||
@@ -152,9 +152,10 @@ static u16 iwl_get_auto_power_mode(struct iwl_priv *priv) | |||
152 | /* initialize to default */ | 152 | /* initialize to default */ |
153 | static int iwl_power_init_handle(struct iwl_priv *priv) | 153 | static int iwl_power_init_handle(struct iwl_priv *priv) |
154 | { | 154 | { |
155 | int ret = 0, i; | ||
156 | struct iwl_power_mgr *pow_data; | 155 | struct iwl_power_mgr *pow_data; |
157 | int size = sizeof(struct iwl_power_vec_entry) * IWL_POWER_MAX; | 156 | int size = sizeof(struct iwl_power_vec_entry) * IWL_POWER_MAX; |
157 | struct iwl_powertable_cmd *cmd; | ||
158 | int i; | ||
158 | u16 pci_pm; | 159 | u16 pci_pm; |
159 | 160 | ||
160 | IWL_DEBUG_POWER("Initialize power \n"); | 161 | IWL_DEBUG_POWER("Initialize power \n"); |
@@ -167,25 +168,19 @@ static int iwl_power_init_handle(struct iwl_priv *priv) | |||
167 | memcpy(&pow_data->pwr_range_1[0], &range_1[0], size); | 168 | memcpy(&pow_data->pwr_range_1[0], &range_1[0], size); |
168 | memcpy(&pow_data->pwr_range_2[0], &range_2[0], size); | 169 | memcpy(&pow_data->pwr_range_2[0], &range_2[0], size); |
169 | 170 | ||
170 | ret = pci_read_config_word(priv->pci_dev, | 171 | pci_read_config_word(priv->pci_dev, PCI_CFG_LINK_CTRL, &pci_pm); |
171 | PCI_LINK_CTRL, &pci_pm); | ||
172 | if (ret != 0) | ||
173 | return 0; | ||
174 | else { | ||
175 | struct iwl_powertable_cmd *cmd; | ||
176 | 172 | ||
177 | IWL_DEBUG_POWER("adjust power command flags\n"); | 173 | IWL_DEBUG_POWER("adjust power command flags\n"); |
178 | 174 | ||
179 | for (i = 0; i < IWL_POWER_MAX; i++) { | 175 | for (i = 0; i < IWL_POWER_MAX; i++) { |
180 | cmd = &pow_data->pwr_range_0[i].cmd; | 176 | cmd = &pow_data->pwr_range_0[i].cmd; |
181 | 177 | ||
182 | if (pci_pm & 0x1) | 178 | if (pci_pm & PCI_CFG_LINK_CTRL_VAL_L0S_EN) |
183 | cmd->flags &= ~IWL_POWER_PCI_PM_MSK; | 179 | cmd->flags &= ~IWL_POWER_PCI_PM_MSK; |
184 | else | 180 | else |
185 | cmd->flags |= IWL_POWER_PCI_PM_MSK; | 181 | cmd->flags |= IWL_POWER_PCI_PM_MSK; |
186 | } | ||
187 | } | 182 | } |
188 | return ret; | 183 | return 0; |
189 | } | 184 | } |
190 | 185 | ||
191 | /* adjust power command according to dtim period and power level*/ | 186 | /* adjust power command according to dtim period and power level*/ |