diff options
author | Wey-Yi Guy <wey-yi.w.guy@intel.com> | 2009-09-11 13:38:14 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-10-07 16:39:32 -0400 |
commit | f2d0d0e2bab7a325071dbaba3bef51c90868e1e6 (patch) | |
tree | a61e9e036b0172483105834d064aa7f1a1a252b9 /drivers/net/wireless/iwlwifi | |
parent | c812ee24855e20f43cf211e51e3eb53fe6dc6f1d (diff) |
iwlwifi: Adjust blink rate to compensate Clock difference
Adjust led blink rate to compensate on a MAC Clock difference on every
HW. Led blink rate analysis showed an average deviation of 0% on 3945,
5% on 4965 HW and 20% on 5000 series and up.
Need to compensate on the led on/off time per HW according to the
deviation to achieve the desired led frequency
The calculation is: (100-averageDeviation)/100 * blinkTime
For code efficiency the calculation will be:
compensation = (100 - averageDeviation) * 64 / 100
NewBlinkTime = (compensation * BlinkTime) / 64
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-1000.c | 1 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-4965.c | 1 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-5000.c | 6 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-6000.c | 5 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-core.h | 4 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-led.c | 33 |
7 files changed, 50 insertions, 2 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index 89f360befc30..1dd8db2f6f23 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c | |||
@@ -164,5 +164,6 @@ struct iwl_cfg iwl1000_bgn_cfg = { | |||
164 | .max_ll_items = OTP_MAX_LL_ITEMS_1000, | 164 | .max_ll_items = OTP_MAX_LL_ITEMS_1000, |
165 | .shadow_ram_support = false, | 165 | .shadow_ram_support = false, |
166 | .ht_greenfield_support = true, | 166 | .ht_greenfield_support = true, |
167 | .led_compensation = 51, | ||
167 | }; | 168 | }; |
168 | 169 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c index e70c5b0af364..33e40c21eb72 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945.c | |||
@@ -2894,6 +2894,7 @@ static struct iwl_cfg iwl3945_bg_cfg = { | |||
2894 | .mod_params = &iwl3945_mod_params, | 2894 | .mod_params = &iwl3945_mod_params, |
2895 | .use_isr_legacy = true, | 2895 | .use_isr_legacy = true, |
2896 | .ht_greenfield_support = false, | 2896 | .ht_greenfield_support = false, |
2897 | .led_compensation = 64, | ||
2897 | }; | 2898 | }; |
2898 | 2899 | ||
2899 | static struct iwl_cfg iwl3945_abg_cfg = { | 2900 | static struct iwl_cfg iwl3945_abg_cfg = { |
@@ -2908,6 +2909,7 @@ static struct iwl_cfg iwl3945_abg_cfg = { | |||
2908 | .mod_params = &iwl3945_mod_params, | 2909 | .mod_params = &iwl3945_mod_params, |
2909 | .use_isr_legacy = true, | 2910 | .use_isr_legacy = true, |
2910 | .ht_greenfield_support = false, | 2911 | .ht_greenfield_support = false, |
2912 | .led_compensation = 64, | ||
2911 | }; | 2913 | }; |
2912 | 2914 | ||
2913 | struct pci_device_id iwl3945_hw_card_ids[] = { | 2915 | struct pci_device_id iwl3945_hw_card_ids[] = { |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c index a22a0501c190..2500ab2e1d91 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c | |||
@@ -2355,6 +2355,7 @@ struct iwl_cfg iwl4965_agn_cfg = { | |||
2355 | .use_isr_legacy = true, | 2355 | .use_isr_legacy = true, |
2356 | .ht_greenfield_support = false, | 2356 | .ht_greenfield_support = false, |
2357 | .broken_powersave = true, | 2357 | .broken_powersave = true, |
2358 | .led_compensation = 61, | ||
2358 | }; | 2359 | }; |
2359 | 2360 | ||
2360 | /* Module firmware */ | 2361 | /* Module firmware */ |
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index e1b378528c72..c81fd4bc32b4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c | |||
@@ -1656,6 +1656,7 @@ struct iwl_cfg iwl5300_agn_cfg = { | |||
1656 | .valid_rx_ant = ANT_ABC, | 1656 | .valid_rx_ant = ANT_ABC, |
1657 | .need_pll_cfg = true, | 1657 | .need_pll_cfg = true, |
1658 | .ht_greenfield_support = true, | 1658 | .ht_greenfield_support = true, |
1659 | .led_compensation = 51, | ||
1659 | }; | 1660 | }; |
1660 | 1661 | ||
1661 | struct iwl_cfg iwl5100_bg_cfg = { | 1662 | struct iwl_cfg iwl5100_bg_cfg = { |
@@ -1673,6 +1674,7 @@ struct iwl_cfg iwl5100_bg_cfg = { | |||
1673 | .valid_rx_ant = ANT_AB, | 1674 | .valid_rx_ant = ANT_AB, |
1674 | .need_pll_cfg = true, | 1675 | .need_pll_cfg = true, |
1675 | .ht_greenfield_support = true, | 1676 | .ht_greenfield_support = true, |
1677 | .led_compensation = 51, | ||
1676 | }; | 1678 | }; |
1677 | 1679 | ||
1678 | struct iwl_cfg iwl5100_abg_cfg = { | 1680 | struct iwl_cfg iwl5100_abg_cfg = { |
@@ -1690,6 +1692,7 @@ struct iwl_cfg iwl5100_abg_cfg = { | |||
1690 | .valid_rx_ant = ANT_AB, | 1692 | .valid_rx_ant = ANT_AB, |
1691 | .need_pll_cfg = true, | 1693 | .need_pll_cfg = true, |
1692 | .ht_greenfield_support = true, | 1694 | .ht_greenfield_support = true, |
1695 | .led_compensation = 51, | ||
1693 | }; | 1696 | }; |
1694 | 1697 | ||
1695 | struct iwl_cfg iwl5100_agn_cfg = { | 1698 | struct iwl_cfg iwl5100_agn_cfg = { |
@@ -1707,6 +1710,7 @@ struct iwl_cfg iwl5100_agn_cfg = { | |||
1707 | .valid_rx_ant = ANT_AB, | 1710 | .valid_rx_ant = ANT_AB, |
1708 | .need_pll_cfg = true, | 1711 | .need_pll_cfg = true, |
1709 | .ht_greenfield_support = true, | 1712 | .ht_greenfield_support = true, |
1713 | .led_compensation = 51, | ||
1710 | }; | 1714 | }; |
1711 | 1715 | ||
1712 | struct iwl_cfg iwl5350_agn_cfg = { | 1716 | struct iwl_cfg iwl5350_agn_cfg = { |
@@ -1724,6 +1728,7 @@ struct iwl_cfg iwl5350_agn_cfg = { | |||
1724 | .valid_rx_ant = ANT_ABC, | 1728 | .valid_rx_ant = ANT_ABC, |
1725 | .need_pll_cfg = true, | 1729 | .need_pll_cfg = true, |
1726 | .ht_greenfield_support = true, | 1730 | .ht_greenfield_support = true, |
1731 | .led_compensation = 51, | ||
1727 | }; | 1732 | }; |
1728 | 1733 | ||
1729 | struct iwl_cfg iwl5150_agn_cfg = { | 1734 | struct iwl_cfg iwl5150_agn_cfg = { |
@@ -1741,6 +1746,7 @@ struct iwl_cfg iwl5150_agn_cfg = { | |||
1741 | .valid_rx_ant = ANT_AB, | 1746 | .valid_rx_ant = ANT_AB, |
1742 | .need_pll_cfg = true, | 1747 | .need_pll_cfg = true, |
1743 | .ht_greenfield_support = true, | 1748 | .ht_greenfield_support = true, |
1749 | .led_compensation = 51, | ||
1744 | }; | 1750 | }; |
1745 | 1751 | ||
1746 | MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX)); | 1752 | MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX)); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index 4b3fb4095678..48b2b7d2170c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c | |||
@@ -258,6 +258,7 @@ struct iwl_cfg iwl6000h_2agn_cfg = { | |||
258 | .max_ll_items = OTP_MAX_LL_ITEMS_6x00, | 258 | .max_ll_items = OTP_MAX_LL_ITEMS_6x00, |
259 | .shadow_ram_support = true, | 259 | .shadow_ram_support = true, |
260 | .ht_greenfield_support = true, | 260 | .ht_greenfield_support = true, |
261 | .led_compensation = 51, | ||
261 | }; | 262 | }; |
262 | 263 | ||
263 | /* | 264 | /* |
@@ -281,6 +282,7 @@ struct iwl_cfg iwl6000i_2agn_cfg = { | |||
281 | .max_ll_items = OTP_MAX_LL_ITEMS_6x00, | 282 | .max_ll_items = OTP_MAX_LL_ITEMS_6x00, |
282 | .shadow_ram_support = true, | 283 | .shadow_ram_support = true, |
283 | .ht_greenfield_support = true, | 284 | .ht_greenfield_support = true, |
285 | .led_compensation = 51, | ||
284 | }; | 286 | }; |
285 | 287 | ||
286 | struct iwl_cfg iwl6050_2agn_cfg = { | 288 | struct iwl_cfg iwl6050_2agn_cfg = { |
@@ -301,6 +303,7 @@ struct iwl_cfg iwl6050_2agn_cfg = { | |||
301 | .max_ll_items = OTP_MAX_LL_ITEMS_6x00, | 303 | .max_ll_items = OTP_MAX_LL_ITEMS_6x00, |
302 | .shadow_ram_support = true, | 304 | .shadow_ram_support = true, |
303 | .ht_greenfield_support = true, | 305 | .ht_greenfield_support = true, |
306 | .led_compensation = 51, | ||
304 | }; | 307 | }; |
305 | 308 | ||
306 | struct iwl_cfg iwl6000_3agn_cfg = { | 309 | struct iwl_cfg iwl6000_3agn_cfg = { |
@@ -321,6 +324,7 @@ struct iwl_cfg iwl6000_3agn_cfg = { | |||
321 | .max_ll_items = OTP_MAX_LL_ITEMS_6x00, | 324 | .max_ll_items = OTP_MAX_LL_ITEMS_6x00, |
322 | .shadow_ram_support = true, | 325 | .shadow_ram_support = true, |
323 | .ht_greenfield_support = true, | 326 | .ht_greenfield_support = true, |
327 | .led_compensation = 51, | ||
324 | }; | 328 | }; |
325 | 329 | ||
326 | struct iwl_cfg iwl6050_3agn_cfg = { | 330 | struct iwl_cfg iwl6050_3agn_cfg = { |
@@ -341,6 +345,7 @@ struct iwl_cfg iwl6050_3agn_cfg = { | |||
341 | .max_ll_items = OTP_MAX_LL_ITEMS_6x00, | 345 | .max_ll_items = OTP_MAX_LL_ITEMS_6x00, |
342 | .shadow_ram_support = true, | 346 | .shadow_ram_support = true, |
343 | .ht_greenfield_support = true, | 347 | .ht_greenfield_support = true, |
348 | .led_compensation = 51, | ||
344 | }; | 349 | }; |
345 | 350 | ||
346 | MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX)); | 351 | MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX)); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index e50103a956b1..79ea42531e28 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h | |||
@@ -213,6 +213,9 @@ struct iwl_mod_params { | |||
213 | * @pa_type: used by 6000 series only to identify the type of Power Amplifier | 213 | * @pa_type: used by 6000 series only to identify the type of Power Amplifier |
214 | * @max_ll_items: max number of OTP blocks | 214 | * @max_ll_items: max number of OTP blocks |
215 | * @shadow_ram_support: shadow support for OTP memory | 215 | * @shadow_ram_support: shadow support for OTP memory |
216 | * @led_compensation: compensate on the led on/off time per HW according | ||
217 | * to the deviation to achieve the desired led frequency. | ||
218 | * The detail algorithm is described in iwl-led.c | ||
216 | * | 219 | * |
217 | * We enable the driver to be backward compatible wrt API version. The | 220 | * We enable the driver to be backward compatible wrt API version. The |
218 | * driver specifies which APIs it supports (with @ucode_api_max being the | 221 | * driver specifies which APIs it supports (with @ucode_api_max being the |
@@ -255,6 +258,7 @@ struct iwl_cfg { | |||
255 | const bool shadow_ram_support; | 258 | const bool shadow_ram_support; |
256 | const bool ht_greenfield_support; | 259 | const bool ht_greenfield_support; |
257 | const bool broken_powersave; | 260 | const bool broken_powersave; |
261 | u16 led_compensation; | ||
258 | }; | 262 | }; |
259 | 263 | ||
260 | /*************************** | 264 | /*************************** |
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c index 41addd1c7261..f547233c5b79 100644 --- a/drivers/net/wireless/iwlwifi/iwl-led.c +++ b/drivers/net/wireless/iwlwifi/iwl-led.c | |||
@@ -78,6 +78,29 @@ static const struct { | |||
78 | #define IWL_MAX_BLINK_TBL (ARRAY_SIZE(blink_tbl) - 1) /* exclude SOLID_ON */ | 78 | #define IWL_MAX_BLINK_TBL (ARRAY_SIZE(blink_tbl) - 1) /* exclude SOLID_ON */ |
79 | #define IWL_SOLID_BLINK_IDX (ARRAY_SIZE(blink_tbl) - 1) | 79 | #define IWL_SOLID_BLINK_IDX (ARRAY_SIZE(blink_tbl) - 1) |
80 | 80 | ||
81 | /* | ||
82 | * Adjust led blink rate to compensate on a MAC Clock difference on every HW | ||
83 | * Led blink rate analysis showed an average deviation of 0% on 3945, | ||
84 | * 5% on 4965 HW and 20% on 5000 series and up. | ||
85 | * Need to compensate on the led on/off time per HW according to the deviation | ||
86 | * to achieve the desired led frequency | ||
87 | * The calculation is: (100-averageDeviation)/100 * blinkTime | ||
88 | * For code efficiency the calculation will be: | ||
89 | * compensation = (100 - averageDeviation) * 64 / 100 | ||
90 | * NewBlinkTime = (compensation * BlinkTime) / 64 | ||
91 | */ | ||
92 | static inline u8 iwl_blink_compensation(struct iwl_priv *priv, | ||
93 | u8 time, u16 compensation) | ||
94 | { | ||
95 | if (!compensation) { | ||
96 | IWL_ERR(priv, "undefined blink compensation: " | ||
97 | "use pre-defined blinking time\n"); | ||
98 | return time; | ||
99 | } | ||
100 | |||
101 | return (u8)((time * compensation) >> 6); | ||
102 | } | ||
103 | |||
81 | /* [0-256] -> [0..8] FIXME: we need [0..10] */ | 104 | /* [0-256] -> [0..8] FIXME: we need [0..10] */ |
82 | static inline int iwl_brightness_to_idx(enum led_brightness brightness) | 105 | static inline int iwl_brightness_to_idx(enum led_brightness brightness) |
83 | { | 106 | { |
@@ -114,8 +137,14 @@ static int iwl_led_pattern(struct iwl_priv *priv, int led_id, | |||
114 | 137 | ||
115 | BUG_ON(idx > IWL_MAX_BLINK_TBL); | 138 | BUG_ON(idx > IWL_MAX_BLINK_TBL); |
116 | 139 | ||
117 | led_cmd.on = blink_tbl[idx].on_time; | 140 | IWL_DEBUG_LED(priv, "Led blink time compensation= %u\n", |
118 | led_cmd.off = blink_tbl[idx].off_time; | 141 | priv->cfg->led_compensation); |
142 | led_cmd.on = | ||
143 | iwl_blink_compensation(priv, blink_tbl[idx].on_time, | ||
144 | priv->cfg->led_compensation); | ||
145 | led_cmd.off = | ||
146 | iwl_blink_compensation(priv, blink_tbl[idx].off_time, | ||
147 | priv->cfg->led_compensation); | ||
119 | 148 | ||
120 | return iwl_send_led_cmd(priv, &led_cmd); | 149 | return iwl_send_led_cmd(priv, &led_cmd); |
121 | } | 150 | } |