diff options
author | Nick Kossifidis <mickflemm@gmail.com> | 2010-11-23 14:00:37 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-11-30 13:52:33 -0500 |
commit | c297560206adf0cda8ce38ef9b20b0a025754c4d (patch) | |
tree | 1e4cb7213a112bba110cdd4bf28519c4d1d30a34 | |
parent | fa3d2feeff4723cce8d4722902492d60b7f75fcc (diff) |
ath5k: Put core clock initialization on a new function
* Handle all usec parameters in one function. It's much cleaner
this way.
Signed-off-by: Nick Kossifidis <mickflemm@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/ath/ath5k/ath5k.h | 26 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath5k/phy.c | 1 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath5k/qcu.c | 4 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath5k/reset.c | 130 |
4 files changed, 134 insertions, 27 deletions
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h index b1429da41a80..c9535447a8ab 100644 --- a/drivers/net/wireless/ath/ath5k/ath5k.h +++ b/drivers/net/wireless/ath/ath5k/ath5k.h | |||
@@ -242,14 +242,6 @@ | |||
242 | #define AR5K_INIT_SLG_RETRY AR5K_INIT_SSH_RETRY | 242 | #define AR5K_INIT_SLG_RETRY AR5K_INIT_SSH_RETRY |
243 | #define AR5K_INIT_TX_RETRY 10 | 243 | #define AR5K_INIT_TX_RETRY 10 |
244 | 244 | ||
245 | #define AR5K_INIT_TRANSMIT_LATENCY ( \ | ||
246 | (AR5K_INIT_TX_LATENCY << 14) | (AR5K_INIT_USEC_32 << 7) | \ | ||
247 | (AR5K_INIT_USEC) \ | ||
248 | ) | ||
249 | #define AR5K_INIT_TRANSMIT_LATENCY_TURBO ( \ | ||
250 | (AR5K_INIT_TX_LATENCY << 14) | (AR5K_INIT_USEC_32 << 7) | \ | ||
251 | (AR5K_INIT_USEC_TURBO) \ | ||
252 | ) | ||
253 | #define AR5K_INIT_PROTO_TIME_CNTRL ( \ | 245 | #define AR5K_INIT_PROTO_TIME_CNTRL ( \ |
254 | (AR5K_INIT_CARR_SENSE_EN << 26) | (AR5K_INIT_EIFS << 12) | \ | 246 | (AR5K_INIT_CARR_SENSE_EN << 26) | (AR5K_INIT_EIFS << 12) | \ |
255 | (AR5K_INIT_PROG_IFS) \ | 247 | (AR5K_INIT_PROG_IFS) \ |
@@ -259,6 +251,24 @@ | |||
259 | (AR5K_INIT_PROG_IFS_TURBO) \ | 251 | (AR5K_INIT_PROG_IFS_TURBO) \ |
260 | ) | 252 | ) |
261 | 253 | ||
254 | /* Rx latency for 5 and 10MHz operation (max ?) */ | ||
255 | #define AR5K_INIT_RX_LAT_MAX 63 | ||
256 | /* Tx latencies from initvals (5212 only but no problem | ||
257 | * because we only tweak them on 5212) */ | ||
258 | #define AR5K_INIT_TX_LAT_A 54 | ||
259 | #define AR5K_INIT_TX_LAT_BG 384 | ||
260 | /* Tx latency for 40MHz (turbo) operation (min ?) */ | ||
261 | #define AR5K_INIT_TX_LAT_MIN 32 | ||
262 | |||
263 | /* Tx frame to Tx data start delay */ | ||
264 | #define AR5K_INIT_TXF2TXD_START_DEFAULT 14 | ||
265 | #define AR5K_INIT_TXF2TXD_START_DELAY_10MHZ 12 | ||
266 | #define AR5K_INIT_TXF2TXD_START_DELAY_5MHZ 13 | ||
267 | |||
268 | /* Default Tx/Rx latencies (same for 5211)*/ | ||
269 | #define AR5K_INIT_TX_LATENCY_5210 54 | ||
270 | #define AR5K_INIT_RX_LATENCY_5210 29 | ||
271 | |||
262 | 272 | ||
263 | /* GENERIC CHIPSET DEFINITIONS */ | 273 | /* GENERIC CHIPSET DEFINITIONS */ |
264 | 274 | ||
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c index 02869c7d596b..706fc461be61 100644 --- a/drivers/net/wireless/ath/ath5k/phy.c +++ b/drivers/net/wireless/ath/ath5k/phy.c | |||
@@ -1235,7 +1235,6 @@ static int ath5k_hw_channel(struct ath5k_hw *ah, | |||
1235 | } | 1235 | } |
1236 | 1236 | ||
1237 | ah->ah_current_channel = channel; | 1237 | ah->ah_current_channel = channel; |
1238 | ath5k_hw_set_clockrate(ah); | ||
1239 | 1238 | ||
1240 | return 0; | 1239 | return 0; |
1241 | } | 1240 | } |
diff --git a/drivers/net/wireless/ath/ath5k/qcu.c b/drivers/net/wireless/ath/ath5k/qcu.c index 778fb59d89f5..f89bc9403f8f 100644 --- a/drivers/net/wireless/ath/ath5k/qcu.c +++ b/drivers/net/wireless/ath/ath5k/qcu.c | |||
@@ -253,10 +253,6 @@ int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue) | |||
253 | ath5k_hw_reg_write(ah, (ah->ah_bwmode == AR5K_BWMODE_40MHZ) ? | 253 | ath5k_hw_reg_write(ah, (ah->ah_bwmode == AR5K_BWMODE_40MHZ) ? |
254 | AR5K_INIT_ACK_CTS_TIMEOUT_TURBO : | 254 | AR5K_INIT_ACK_CTS_TIMEOUT_TURBO : |
255 | AR5K_INIT_ACK_CTS_TIMEOUT, AR5K_SLOT_TIME); | 255 | AR5K_INIT_ACK_CTS_TIMEOUT, AR5K_SLOT_TIME); |
256 | /* Set Transmit Latency */ | ||
257 | ath5k_hw_reg_write(ah, (ah->ah_bwmode == AR5K_BWMODE_40MHZ) ? | ||
258 | AR5K_INIT_TRANSMIT_LATENCY_TURBO : | ||
259 | AR5K_INIT_TRANSMIT_LATENCY, AR5K_USEC_5210); | ||
260 | 256 | ||
261 | /* Set IFS0 */ | 257 | /* Set IFS0 */ |
262 | if (ah->ah_bwmode == AR5K_BWMODE_40MHZ) { | 258 | if (ah->ah_bwmode == AR5K_BWMODE_40MHZ) { |
diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c index 91a2b2166def..7db984ce90fb 100644 --- a/drivers/net/wireless/ath/ath5k/reset.c +++ b/drivers/net/wireless/ath/ath5k/reset.c | |||
@@ -86,16 +86,21 @@ unsigned int ath5k_hw_clocktoh(struct ath5k_hw *ah, unsigned int clock) | |||
86 | } | 86 | } |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * ath5k_hw_set_clockrate - Set common->clockrate for the current channel | 89 | * ath5k_hw_init_core_clock - Initialize core clock |
90 | * | 90 | * |
91 | * @ah: The &struct ath5k_hw | 91 | * @ah The &struct ath5k_hw |
92 | * | ||
93 | * Initialize core clock parameters (usec, usec32, latencies etc). | ||
92 | */ | 94 | */ |
93 | void ath5k_hw_set_clockrate(struct ath5k_hw *ah) | 95 | static void ath5k_hw_init_core_clock(struct ath5k_hw *ah) |
94 | { | 96 | { |
95 | struct ieee80211_channel *channel = ah->ah_current_channel; | 97 | struct ieee80211_channel *channel = ah->ah_current_channel; |
96 | struct ath_common *common = ath5k_hw_common(ah); | 98 | struct ath_common *common = ath5k_hw_common(ah); |
97 | int clock; | 99 | u32 usec_reg, txlat, rxlat, usec, clock, sclock, txf2txs; |
98 | 100 | ||
101 | /* | ||
102 | * Set core clock frequency | ||
103 | */ | ||
99 | if (channel->hw_value & CHANNEL_5GHZ) | 104 | if (channel->hw_value & CHANNEL_5GHZ) |
100 | clock = 40; /* 802.11a */ | 105 | clock = 40; /* 802.11a */ |
101 | else if (channel->hw_value & CHANNEL_CCK) | 106 | else if (channel->hw_value & CHANNEL_CCK) |
@@ -103,11 +108,109 @@ void ath5k_hw_set_clockrate(struct ath5k_hw *ah) | |||
103 | else | 108 | else |
104 | clock = 44; /* 802.11g */ | 109 | clock = 44; /* 802.11g */ |
105 | 110 | ||
106 | /* Clock rate in turbo modes is twice the normal rate */ | 111 | /* Use clock multiplier for non-default |
107 | if (channel->hw_value & CHANNEL_TURBO) | 112 | * bwmode */ |
113 | switch (ah->ah_bwmode) { | ||
114 | case AR5K_BWMODE_40MHZ: | ||
108 | clock *= 2; | 115 | clock *= 2; |
116 | break; | ||
117 | case AR5K_BWMODE_10MHZ: | ||
118 | clock /= 2; | ||
119 | break; | ||
120 | case AR5K_BWMODE_5MHZ: | ||
121 | clock /= 4; | ||
122 | break; | ||
123 | default: | ||
124 | break; | ||
125 | } | ||
109 | 126 | ||
110 | common->clockrate = clock; | 127 | common->clockrate = clock; |
128 | |||
129 | /* | ||
130 | * Set USEC parameters | ||
131 | */ | ||
132 | /* Set USEC counter on PCU*/ | ||
133 | usec = clock - 1; | ||
134 | usec = AR5K_REG_SM(usec, AR5K_USEC_1); | ||
135 | |||
136 | /* Set usec duration on DCU */ | ||
137 | if (ah->ah_version != AR5K_AR5210) | ||
138 | AR5K_REG_WRITE_BITS(ah, AR5K_DCU_GBL_IFS_MISC, | ||
139 | AR5K_DCU_GBL_IFS_MISC_USEC_DUR, | ||
140 | clock); | ||
141 | |||
142 | /* Set 32MHz USEC counter */ | ||
143 | if ((ah->ah_radio == AR5K_RF5112) || | ||
144 | (ah->ah_radio == AR5K_RF5413)) | ||
145 | /* Remain on 40MHz clock ? */ | ||
146 | sclock = 40 - 1; | ||
147 | else | ||
148 | sclock = 32 - 1; | ||
149 | sclock = AR5K_REG_SM(sclock, AR5K_USEC_32); | ||
150 | |||
151 | /* | ||
152 | * Set tx/rx latencies | ||
153 | */ | ||
154 | usec_reg = ath5k_hw_reg_read(ah, AR5K_USEC_5211); | ||
155 | txlat = AR5K_REG_MS(usec_reg, AR5K_USEC_TX_LATENCY_5211); | ||
156 | rxlat = AR5K_REG_MS(usec_reg, AR5K_USEC_RX_LATENCY_5211); | ||
157 | |||
158 | /* | ||
159 | * 5210 initvals don't include usec settings | ||
160 | * so we need to use magic values here for | ||
161 | * tx/rx latencies | ||
162 | */ | ||
163 | if (ah->ah_version == AR5K_AR5210) { | ||
164 | /* same for turbo */ | ||
165 | txlat = AR5K_INIT_TX_LATENCY_5210; | ||
166 | rxlat = AR5K_INIT_RX_LATENCY_5210; | ||
167 | } | ||
168 | |||
169 | if (ah->ah_mac_srev < AR5K_SREV_AR5211) { | ||
170 | /* 5311 has different tx/rx latency masks | ||
171 | * from 5211, since we deal 5311 the same | ||
172 | * as 5211 when setting initvals, shift | ||
173 | * values here to their proper locations | ||
174 | * | ||
175 | * Note: Initvals indicate tx/rx/ latencies | ||
176 | * are the same for turbo mode */ | ||
177 | txlat = AR5K_REG_SM(txlat, AR5K_USEC_TX_LATENCY_5210); | ||
178 | rxlat = AR5K_REG_SM(rxlat, AR5K_USEC_RX_LATENCY_5210); | ||
179 | } else | ||
180 | switch (ah->ah_bwmode) { | ||
181 | case AR5K_BWMODE_10MHZ: | ||
182 | txlat = AR5K_REG_SM(txlat * 2, | ||
183 | AR5K_USEC_TX_LATENCY_5211); | ||
184 | rxlat = AR5K_REG_SM(AR5K_INIT_RX_LAT_MAX, | ||
185 | AR5K_USEC_RX_LATENCY_5211); | ||
186 | txf2txs = AR5K_INIT_TXF2TXD_START_DELAY_10MHZ; | ||
187 | break; | ||
188 | case AR5K_BWMODE_5MHZ: | ||
189 | txlat = AR5K_REG_SM(txlat * 4, | ||
190 | AR5K_USEC_TX_LATENCY_5211); | ||
191 | rxlat = AR5K_REG_SM(AR5K_INIT_RX_LAT_MAX, | ||
192 | AR5K_USEC_RX_LATENCY_5211); | ||
193 | txf2txs = AR5K_INIT_TXF2TXD_START_DELAY_5MHZ; | ||
194 | break; | ||
195 | case AR5K_BWMODE_40MHZ: | ||
196 | txlat = AR5K_INIT_TX_LAT_MIN; | ||
197 | rxlat = AR5K_REG_SM(rxlat / 2, | ||
198 | AR5K_USEC_RX_LATENCY_5211); | ||
199 | txf2txs = AR5K_INIT_TXF2TXD_START_DEFAULT; | ||
200 | break; | ||
201 | default: | ||
202 | break; | ||
203 | } | ||
204 | |||
205 | usec_reg = (usec | sclock | txlat | rxlat); | ||
206 | ath5k_hw_reg_write(ah, usec_reg, AR5K_USEC); | ||
207 | |||
208 | /* On 5112 set tx frane to tx data start delay */ | ||
209 | if (ah->ah_radio == AR5K_RF5112) { | ||
210 | AR5K_REG_WRITE_BITS(ah, AR5K_PHY_RF_CTL2, | ||
211 | AR5K_PHY_RF_CTL2_TXF2TXD_START, | ||
212 | txf2txs); | ||
213 | } | ||
111 | } | 214 | } |
112 | 215 | ||
113 | /* | 216 | /* |
@@ -122,7 +225,7 @@ void ath5k_hw_set_clockrate(struct ath5k_hw *ah) | |||
122 | static void ath5k_hw_set_sleep_clock(struct ath5k_hw *ah, bool enable) | 225 | static void ath5k_hw_set_sleep_clock(struct ath5k_hw *ah, bool enable) |
123 | { | 226 | { |
124 | struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; | 227 | struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; |
125 | u32 scal, spending, usec32; | 228 | u32 scal, spending; |
126 | 229 | ||
127 | /* Only set 32KHz settings if we have an external | 230 | /* Only set 32KHz settings if we have an external |
128 | * 32KHz crystal present */ | 231 | * 32KHz crystal present */ |
@@ -179,6 +282,7 @@ static void ath5k_hw_set_sleep_clock(struct ath5k_hw *ah, bool enable) | |||
179 | AR5K_REG_WRITE_BITS(ah, AR5K_PCICFG, | 282 | AR5K_REG_WRITE_BITS(ah, AR5K_PCICFG, |
180 | AR5K_PCICFG_SLEEP_CLOCK_RATE, 0); | 283 | AR5K_PCICFG_SLEEP_CLOCK_RATE, 0); |
181 | 284 | ||
285 | /* Set DAC/ADC delays */ | ||
182 | ath5k_hw_reg_write(ah, 0x1f, AR5K_PHY_SCR); | 286 | ath5k_hw_reg_write(ah, 0x1f, AR5K_PHY_SCR); |
183 | ath5k_hw_reg_write(ah, AR5K_PHY_SLMT_32MHZ, AR5K_PHY_SLMT); | 287 | ath5k_hw_reg_write(ah, AR5K_PHY_SLMT_32MHZ, AR5K_PHY_SLMT); |
184 | 288 | ||
@@ -201,13 +305,7 @@ static void ath5k_hw_set_sleep_clock(struct ath5k_hw *ah, bool enable) | |||
201 | spending = 0x18; | 305 | spending = 0x18; |
202 | ath5k_hw_reg_write(ah, spending, AR5K_PHY_SPENDING); | 306 | ath5k_hw_reg_write(ah, spending, AR5K_PHY_SPENDING); |
203 | 307 | ||
204 | if ((ah->ah_radio == AR5K_RF5112) || | 308 | /* Set up tsf increment on each cycle */ |
205 | (ah->ah_radio == AR5K_RF5413)) | ||
206 | usec32 = 39; | ||
207 | else | ||
208 | usec32 = 31; | ||
209 | AR5K_REG_WRITE_BITS(ah, AR5K_USEC_5211, AR5K_USEC_32, usec32); | ||
210 | |||
211 | AR5K_REG_WRITE_BITS(ah, AR5K_TSF_PARM, AR5K_TSF_PARM_INC, 1); | 309 | AR5K_REG_WRITE_BITS(ah, AR5K_TSF_PARM, AR5K_TSF_PARM_INC, 1); |
212 | } | 310 | } |
213 | } | 311 | } |
@@ -822,6 +920,7 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, | |||
822 | freq = 0; | 920 | freq = 0; |
823 | mode = 0; | 921 | mode = 0; |
824 | 922 | ||
923 | |||
825 | /* | 924 | /* |
826 | * Stop PCU | 925 | * Stop PCU |
827 | */ | 926 | */ |
@@ -971,6 +1070,9 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, | |||
971 | if (ret) | 1070 | if (ret) |
972 | return ret; | 1071 | return ret; |
973 | 1072 | ||
1073 | /* Initialize core clock settings */ | ||
1074 | ath5k_hw_init_core_clock(ah); | ||
1075 | |||
974 | /* | 1076 | /* |
975 | * Tweak initval settings for revised | 1077 | * Tweak initval settings for revised |
976 | * chipsets and add some more config | 1078 | * chipsets and add some more config |