iPXE
ath5k_reset.c File Reference
#include <ipxe/pci.h>
#include <unistd.h>
#include "ath5k.h"
#include "reg.h"
#include "base.h"

Go to the source code of this file.

Macros

#define _ATH5K_RESET

Functions

 FILE_LICENCE (MIT)
 FILE_SECBOOT (FORBIDDEN)
static int fls (int x)
static int ath5k_hw_write_ofdm_timings (struct ath5k_hw *ah, struct net80211_channel *channel)
 ath5k_hw_write_ofdm_timings - set OFDM timings on AR5212
static void ath5k_hw_write_rate_duration (struct ath5k_hw *ah, unsigned int mode __unused)
 ath5k_hw_write_rate_duration - fill rate code to duration table
static int ath5k_hw_nic_reset (struct ath5k_hw *ah, u32 val)
int ath5k_hw_wake (struct ath5k_hw *ah)
int ath5k_hw_nic_wakeup (struct ath5k_hw *ah, int flags, int initial __unused)
static int ath5k_hw_chan_has_spur_noise (struct ath5k_hw *ah, struct net80211_channel *channel)
static void ath5k_hw_tweak_initval_settings (struct ath5k_hw *ah, struct net80211_channel *channel)
static void ath5k_hw_commit_eeprom_settings (struct ath5k_hw *ah, struct net80211_channel *channel, u8 *ant, u8 ee_mode)
int ath5k_hw_reset (struct ath5k_hw *ah, struct net80211_channel *channel, int change_channel)

Macro Definition Documentation

◆ _ATH5K_RESET

#define _ATH5K_RESET

Definition at line 27 of file ath5k_reset.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( MIT )

◆ FILE_SECBOOT()

FILE_SECBOOT ( FORBIDDEN )

◆ fls()

int fls ( int x)
static

Definition at line 41 of file ath5k_reset.c.

42{
43 int r = 32;
44
45 if (!x)
46 return 0;
47 if (!(x & 0xffff0000u)) {
48 x <<= 16;
49 r -= 16;
50 }
51 if (!(x & 0xff000000u)) {
52 x <<= 8;
53 r -= 8;
54 }
55 if (!(x & 0xf0000000u)) {
56 x <<= 4;
57 r -= 4;
58 }
59 if (!(x & 0xc0000000u)) {
60 x <<= 2;
61 r -= 2;
62 }
63 if (!(x & 0x80000000u)) {
64 x <<= 1;
65 r -= 1;
66 }
67 return r;
68}
static const uint8_t r[3][4]
MD4 shift amounts.
Definition md4.c:54
static unsigned int x
Definition pixbuf.h:63

References r, and x.

◆ ath5k_hw_write_ofdm_timings()

int ath5k_hw_write_ofdm_timings ( struct ath5k_hw * ah,
struct net80211_channel * channel )
static

ath5k_hw_write_ofdm_timings - set OFDM timings on AR5212

@ah: the &struct ath5k_hw @channel: the currently set channel upon reset

Write the delta slope coefficient (used on pilot tracking ?) for OFDM operation on the AR5212 upon reset. This is a helper for ath5k_hw_reset().

Since delta slope is floating point we split it on its exponent and mantissa and provide these values on hw.

For more infos i think this patent is related http://www.freepatentsonline.com/7184495.html

Definition at line 86 of file ath5k_reset.c.

88{
89 /* Get exponent and mantissa and set it */
90 u32 coef_scaled, coef_exp, coef_man,
91 ds_coef_exp, ds_coef_man, clock;
92
93 if (!(ah->ah_version == AR5K_AR5212) ||
94 !(channel->hw_value & CHANNEL_OFDM)) {
95 DBG("ath5k: attempt to set OFDM timings on non-OFDM channel\n");
96 return -EFAULT;
97 }
98
99 /* Get coefficient
100 * ALGO: coef = (5 * clock * carrier_freq) / 2)
101 * we scale coef by shifting clock value by 24 for
102 * better precision since we use integers */
103 /* TODO: Half/quarter rate */
104 clock = ath5k_hw_htoclock(1, channel->hw_value & CHANNEL_TURBO);
105
106 coef_scaled = ((5 * (clock << 24)) / 2) / channel->center_freq;
107
108 /* Get exponent
109 * ALGO: coef_exp = 14 - highest set bit position */
110 coef_exp = fls(coef_scaled) - 1;
111
112 /* Doesn't make sense if it's zero*/
113 if (!coef_scaled || !coef_exp)
114 return -EINVAL;
115
116 /* Note: we've shifted coef_scaled by 24 */
117 coef_exp = 14 - (coef_exp - 24);
118
119
120 /* Get mantissa (significant digits)
121 * ALGO: coef_mant = floor(coef_scaled* 2^coef_exp+0.5) */
122 coef_man = coef_scaled +
123 (1 << (24 - coef_exp - 1));
124
125 /* Calculate delta slope coefficient exponent
126 * and mantissa (remove scaling) and set them on hw */
127 ds_coef_man = coef_man >> (24 - coef_exp);
128 ds_coef_exp = coef_exp - 16;
129
131 AR5K_PHY_TIMING_3_DSC_MAN, ds_coef_man);
133 AR5K_PHY_TIMING_3_DSC_EXP, ds_coef_exp);
134
135 return 0;
136}
#define AR5K_PHY_TIMING_3
Definition reg.h:1913
#define AR5K_PHY_TIMING_3_DSC_EXP
Definition reg.h:1916
#define AR5K_PHY_TIMING_3_DSC_MAN
Definition reg.h:1914
#define CHANNEL_OFDM
Definition ath5k.h:633
#define CHANNEL_TURBO
Definition ath5k.h:631
#define AR5K_REG_WRITE_BITS(ah, _reg, _flags, _val)
Definition ath5k.h:98
@ AR5K_AR5212
Definition ath5k.h:258
static unsigned int ath5k_hw_htoclock(unsigned int usec, int turbo)
Definition ath5k.h:1199
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
#define EINVAL
Invalid argument.
Definition errno.h:429
#define EFAULT
Bad address.
Definition errno.h:394
#define fls(x)
Find last (i.e.
Definition strings.h:167
uint32_t channel
RNDIS channel.
Definition netvsc.h:3
uint8_t ah
Definition registers.h:1
#define u32
Definition vga.h:21

References ah, AR5K_AR5212, AR5K_PHY_TIMING_3, AR5K_PHY_TIMING_3_DSC_EXP, AR5K_PHY_TIMING_3_DSC_MAN, AR5K_REG_WRITE_BITS, ath5k_hw_htoclock(), channel, CHANNEL_OFDM, CHANNEL_TURBO, DBG, EFAULT, EINVAL, fls, and u32.

Referenced by ath5k_hw_reset().

◆ ath5k_hw_write_rate_duration()

void ath5k_hw_write_rate_duration ( struct ath5k_hw * ah,
unsigned int mode __unused )
inlinestatic

ath5k_hw_write_rate_duration - fill rate code to duration table

@ah: the &struct ath5k_hw @mode: one of enum ath5k_driver_mode

Write the rate code to duration table upon hw reset. This is a helper for ath5k_hw_reset(). It seems all this is doing is setting an ACK timeout on the hardware, based on current mode, for each rate. The rates which are capable of short preamble (802.11b rates 2Mbps, 5.5Mbps, and 11Mbps) have different rate code so we write their value twice (one for long preample and one for short).

Note: Band doesn't matter here, if we set the values for OFDM it works on both a and g modes. So all we have to do is set values for all g rates that include all OFDM and CCK rates. If we operate in turbo or xr/half/ quarter rate mode, we need to use another set of bitrates (that's why we need the mode parameter) but we don't handle these proprietary modes yet.

Definition at line 157 of file ath5k_reset.c.

159{
160 struct ath5k_softc *sc = ah->ah_sc;
161 u16 rate;
162 int i;
163
164 /* Write rate duration table */
165 for (i = 0; i < sc->hwinfo->nr_rates[NET80211_BAND_2GHZ]; i++) {
166 u32 reg;
167 u16 tx_time;
168
169 rate = sc->hwinfo->rates[NET80211_BAND_2GHZ][i];
170
171 /* Set ACK timeout */
173
174 /* An ACK frame consists of 10 bytes. If you add the FCS,
175 * it's 14 bytes. Note we use the control rate and not the
176 * actual rate for this rate. See mac80211 tx.c
177 * ieee80211_duration() for a brief description of
178 * what rate we should choose to TX ACKs. */
179 tx_time = net80211_duration(sc->dev, 14, rate);
180
181 ath5k_hw_reg_write(ah, tx_time, reg);
182
183 if (rate != 20 && rate != 55 && rate != 110)
184 continue;
185
186 /*
187 * We're not distinguishing short preamble here,
188 * This is true, all we'll get is a longer value here
189 * which is not necessarilly bad.
190 */
191 ath5k_hw_reg_write(ah, tx_time,
193 }
194}
#define AR5K_RATE_DUR(_n)
Definition reg.h:1787
int ath5k_bitrate_to_hw_rix(int bitrate)
Definition ath5k.c:719
static void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
Definition ath5k.h:1224
#define AR5K_SET_SHORT_PREAMBLE
Definition ath5k.h:728
#define NET80211_BAND_2GHZ
The 2.4 GHz ISM band, unlicensed in most countries.
Definition net80211.h:45
u16 net80211_duration(struct net80211_device *dev, int bytes, u16 rate)
Calculate one frame's contribution to 802.11 duration field.
Definition net80211.c:442
static unsigned int unsigned int reg
Definition myson.h:162
struct net80211_device * dev
Definition base.h:92
struct net80211_hw_info * hwinfo
Definition base.h:94
int nr_rates[NET80211_NR_BANDS]
Number of supported rates, indexed by band.
Definition net80211.h:511
u16 rates[NET80211_NR_BANDS][NET80211_MAX_RATES]
List of transmission rates supported by the card, indexed by band.
Definition net80211.h:508
#define u16
Definition vga.h:20

References __unused, ah, AR5K_RATE_DUR, AR5K_SET_SHORT_PREAMBLE, ath5k_bitrate_to_hw_rix(), ath5k_hw_reg_write(), ath5k_softc::dev, ath5k_softc::hwinfo, mode, NET80211_BAND_2GHZ, net80211_duration(), net80211_hw_info::nr_rates, net80211_hw_info::rates, reg, u16, and u32.

Referenced by ath5k_hw_reset().

◆ ath5k_hw_nic_reset()

int ath5k_hw_nic_reset ( struct ath5k_hw * ah,
u32 val )
static

Definition at line 199 of file ath5k_reset.c.

200{
201 int ret;
202 u32 mask = val ? val : ~0U;
203
204 /* Read-and-clear RX Descriptor Pointer*/
206
207 /*
208 * Reset the device and wait until success
209 */
211
212 /* Wait at least 128 PCI clocks */
213 udelay(15);
214
215 if (ah->ah_version == AR5K_AR5210) {
220 } else {
223 }
224
225 ret = ath5k_hw_register_timeout(ah, AR5K_RESET_CTL, mask, val, 0);
226
227 /*
228 * Reset configuration register (for hw byte-swap). Note that this
229 * is only set for big endian. We do the necessary magic in
230 * AR5K_INIT_CFG.
231 */
232 if ((val & AR5K_RESET_CTL_PCU) == 0)
234
235 return ret;
236}
#define AR5K_RESET_CTL_BASEBAND
Definition reg.h:840
#define AR5K_RXDP
Definition reg.h:67
#define AR5K_RESET_CTL_DMA
Definition reg.h:839
#define AR5K_CFG
Definition reg.h:72
#define AR5K_RESET_CTL
Definition reg.h:837
#define AR5K_RESET_CTL_PCU
Definition reg.h:838
#define AR5K_RESET_CTL_MAC
Definition reg.h:841
#define AR5K_RESET_CTL_PHY
Definition reg.h:842
#define AR5K_INIT_CFG
Definition ath5k.h:203
static u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
Definition ath5k.h:1216
@ AR5K_AR5210
Definition ath5k.h:256
void __asmcall int val
Definition setjmp.h:12
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition timer.c:61

References ah, AR5K_AR5210, AR5K_CFG, AR5K_INIT_CFG, AR5K_RESET_CTL, AR5K_RESET_CTL_BASEBAND, AR5K_RESET_CTL_DMA, AR5K_RESET_CTL_MAC, AR5K_RESET_CTL_PCU, AR5K_RESET_CTL_PHY, AR5K_RXDP, ath5k_hw_reg_read(), ath5k_hw_reg_write(), u32, udelay(), and val.

Referenced by ath5k_hw_nic_wakeup().

◆ ath5k_hw_wake()

int ath5k_hw_wake ( struct ath5k_hw * ah)

Definition at line 241 of file ath5k_reset.c.

242{
243 unsigned int i;
244 u32 staid, data;
245
247 staid &= ~AR5K_STA_ID1_PWR_SV;
248
249 /* Preserve sleep duration */
251 if (data & 0xffc00000)
252 data = 0;
253 else
254 data = data & 0xfffcffff;
255
257 udelay(15);
258
259 for (i = 50; i > 0; i--) {
260 /* Check if the chip did wake up */
263 break;
264
265 /* Wait a bit and retry */
266 udelay(200);
268 }
269
270 /* Fail if the chip didn't wake up */
271 if (i <= 0)
272 return -EIO;
273
275
276 return 0;
277}
#define AR5K_PCICFG_SPWR_DN
Definition reg.h:897
#define AR5K_PCICFG
Definition reg.h:877
#define AR5K_STA_ID1
Definition reg.h:1123
#define AR5K_SLEEP_CTL
Definition reg.h:848
#define AR5K_STA_ID1_PWR_SV
Definition reg.h:1127
uint8_t data[48]
Additional event data.
Definition ena.h:11
#define EIO
Input/output error.
Definition errno.h:434

References ah, AR5K_PCICFG, AR5K_PCICFG_SPWR_DN, AR5K_SLEEP_CTL, AR5K_STA_ID1, AR5K_STA_ID1_PWR_SV, ath5k_hw_reg_read(), ath5k_hw_reg_write(), data, EIO, u32, and udelay().

Referenced by ath5k_hw_nic_wakeup().

◆ ath5k_hw_nic_wakeup()

int ath5k_hw_nic_wakeup ( struct ath5k_hw * ah,
int flags,
int initial __unused )

Definition at line 283 of file ath5k_reset.c.

284{
285 struct pci_device *pdev = ah->ah_sc->pdev;
286 u32 turbo, mode, clock, bus_flags;
287 int ret;
288
289 turbo = 0;
290 mode = 0;
291 clock = 0;
292
293 /* Wakeup the device */
294 ret = ath5k_hw_wake(ah);
295 if (ret) {
296 DBG("ath5k: failed to wake up the MAC chip\n");
297 return ret;
298 }
299
300 if (ah->ah_version != AR5K_AR5210) {
301 /*
302 * Get channel mode flags
303 */
304
305 if (ah->ah_radio >= AR5K_RF5112) {
307 clock = AR5K_PHY_PLL_RF5112;
308 } else {
310 clock = AR5K_PHY_PLL_RF5111; /*Zero*/
311 }
312
313 if (flags & CHANNEL_2GHZ) {
315 clock |= AR5K_PHY_PLL_44MHZ;
316
317 if (flags & CHANNEL_CCK) {
319 } else if (flags & CHANNEL_OFDM) {
320 /* XXX Dynamic OFDM/CCK is not supported by the
321 * AR5211 so we set MOD_OFDM for plain g (no
322 * CCK headers) operation. We need to test
323 * this, 5211 might support ofdm-only g after
324 * all, there are also initial register values
325 * in the code for g mode (see initvals.c). */
326 if (ah->ah_version == AR5K_AR5211)
328 else
330 } else {
331 DBG("ath5k: invalid radio modulation mode\n");
332 return -EINVAL;
333 }
334 } else if (flags & CHANNEL_5GHZ) {
336
337 if (ah->ah_radio == AR5K_RF5413)
339 else
340 clock |= AR5K_PHY_PLL_40MHZ;
341
342 if (flags & CHANNEL_OFDM)
344 else {
345 DBG("ath5k: invalid radio modulation mode\n");
346 return -EINVAL;
347 }
348 } else {
349 DBG("ath5k: invalid radio frequency mode\n");
350 return -EINVAL;
351 }
352
353 if (flags & CHANNEL_TURBO)
355 } else { /* Reset the device */
356
357 /* ...enable Atheros turbo mode if requested */
358 if (flags & CHANNEL_TURBO)
361 }
362
363 /* reseting PCI on PCI-E cards results card to hang
364 * and always return 0xffff... so we ingore that flag
365 * for PCI-E cards */
367 bus_flags = 0;
368 else
369 bus_flags = AR5K_RESET_CTL_PCI;
370
371 /* Reset chipset */
372 if (ah->ah_version == AR5K_AR5210) {
376 mdelay(2);
377 } else {
379 AR5K_RESET_CTL_BASEBAND | bus_flags);
380 }
381 if (ret) {
382 DBG("ath5k: failed to reset the MAC chip\n");
383 return -EIO;
384 }
385
386 /* ...wakeup again!*/
387 ret = ath5k_hw_wake(ah);
388 if (ret) {
389 DBG("ath5k: failed to resume the MAC chip\n");
390 return ret;
391 }
392
393 /* ...final warm reset */
394 if (ath5k_hw_nic_reset(ah, 0)) {
395 DBG("ath5k: failed to warm reset the MAC chip\n");
396 return -EIO;
397 }
398
399 if (ah->ah_version != AR5K_AR5210) {
400
401 /* ...update PLL if needed */
402 if (ath5k_hw_reg_read(ah, AR5K_PHY_PLL) != clock) {
404 udelay(300);
405 }
406
407 /* ...set the PHY operating mode */
410 }
411
412 return 0;
413}
#define AR5K_PHY_TURBO_SHORT
Definition reg.h:1893
#define AR5K_PHY_TURBO
Definition reg.h:1891
#define AR5K_PHY_MODE
Definition reg.h:2487
#define AR5K_PHY_PLL_44MHZ
Definition reg.h:2103
#define AR5K_PHY_MODE_FREQ_2GHZ
Definition reg.h:2493
#define AR5K_PHY_MODE_MOD_CCK
Definition reg.h:2490
#define AR5K_RESET_CTL_PCI
Definition reg.h:843
#define AR5K_PHY_PLL_40MHZ_5413
Definition reg.h:2097
#define AR5K_PHY_PLL_RF5112
Definition reg.h:2107
#define AR5K_PHY_MODE_RAD_RF5112
Definition reg.h:2497
#define AR5K_PHY_PLL
Definition reg.h:2092
#define AR5K_PHY_PLL_RF5111
Definition reg.h:2106
#define AR5K_PHY_MODE_MOD_OFDM
Definition reg.h:2489
#define AR5K_PHY_PLL_40MHZ
Definition reg.h:2098
#define AR5K_PHY_TURBO_MODE
Definition reg.h:1892
#define AR5K_PHY_MODE_RAD_RF5111
Definition reg.h:2496
#define AR5K_PHY_MODE_MOD_DYN
Definition reg.h:2494
#define AR5K_PHY_MODE_FREQ_5GHZ
Definition reg.h:2492
#define CHANNEL_CCK
Definition ath5k.h:632
#define CHANNEL_5GHZ
Definition ath5k.h:635
@ AR5K_AR5211
Definition ath5k.h:257
@ AR5K_RF5112
Definition ath5k.h:265
@ AR5K_RF5413
Definition ath5k.h:267
#define CHANNEL_2GHZ
Definition ath5k.h:634
int ath5k_hw_wake(struct ath5k_hw *ah)
static int ath5k_hw_nic_reset(struct ath5k_hw *ah, u32 val)
uint8_t flags
Flags.
Definition ena.h:7
uint16_t mode
Acceleration mode.
Definition ena.h:15
#define PCI_CAP_ID_EXP
PCI Express.
Definition pci.h:98
int pci_find_capability(struct pci_device *pci, int cap)
Look for a PCI capability.
Definition pciextra.c:39
A PCI device.
Definition pci.h:211
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition timer.c:79

References __unused, ah, AR5K_AR5210, AR5K_AR5211, AR5K_PHY_MODE, AR5K_PHY_MODE_FREQ_2GHZ, AR5K_PHY_MODE_FREQ_5GHZ, AR5K_PHY_MODE_MOD_CCK, AR5K_PHY_MODE_MOD_DYN, AR5K_PHY_MODE_MOD_OFDM, AR5K_PHY_MODE_RAD_RF5111, AR5K_PHY_MODE_RAD_RF5112, AR5K_PHY_PLL, AR5K_PHY_PLL_40MHZ, AR5K_PHY_PLL_40MHZ_5413, AR5K_PHY_PLL_44MHZ, AR5K_PHY_PLL_RF5111, AR5K_PHY_PLL_RF5112, AR5K_PHY_TURBO, AR5K_PHY_TURBO_MODE, AR5K_PHY_TURBO_SHORT, AR5K_RESET_CTL_BASEBAND, AR5K_RESET_CTL_DMA, AR5K_RESET_CTL_MAC, AR5K_RESET_CTL_PCI, AR5K_RESET_CTL_PCU, AR5K_RESET_CTL_PHY, AR5K_RF5112, AR5K_RF5413, ath5k_hw_nic_reset(), ath5k_hw_reg_read(), ath5k_hw_reg_write(), ath5k_hw_wake(), CHANNEL_2GHZ, CHANNEL_5GHZ, CHANNEL_CCK, CHANNEL_OFDM, CHANNEL_TURBO, DBG, EINVAL, EIO, flags, mdelay(), mode, PCI_CAP_ID_EXP, pci_find_capability(), u32, and udelay().

Referenced by ath5k_hw_attach(), and ath5k_hw_reset().

◆ ath5k_hw_chan_has_spur_noise()

int ath5k_hw_chan_has_spur_noise ( struct ath5k_hw * ah,
struct net80211_channel * channel )
static

Definition at line 415 of file ath5k_reset.c.

417{
418 u8 refclk_freq;
419
420 if ((ah->ah_radio == AR5K_RF5112) ||
421 (ah->ah_radio == AR5K_RF5413) ||
422 (ah->ah_mac_version == (AR5K_SREV_AR2417 >> 4)))
423 refclk_freq = 40;
424 else
425 refclk_freq = 32;
426
427 if ((channel->center_freq % refclk_freq != 0) &&
428 ((channel->center_freq % refclk_freq < 10) ||
429 (channel->center_freq % refclk_freq > 22)))
430 return 1;
431 else
432 return 0;
433}
#define AR5K_SREV_AR2417
Definition ath5k.h:307
#define u8
Definition igbvf_osdep.h:40

References ah, AR5K_RF5112, AR5K_RF5413, AR5K_SREV_AR2417, channel, and u8.

Referenced by ath5k_hw_commit_eeprom_settings().

◆ ath5k_hw_tweak_initval_settings()

void ath5k_hw_tweak_initval_settings ( struct ath5k_hw * ah,
struct net80211_channel * channel )
static

Definition at line 436 of file ath5k_reset.c.

438{
439 if (ah->ah_version == AR5K_AR5212 &&
440 ah->ah_phy_revision >= AR5K_SREV_PHY_5212A) {
441
442 /* Setup ADC control */
444 (AR5K_REG_SM(2,
446 AR5K_REG_SM(2,
451
452
453
454 /* Disable barker RSSI threshold */
457
460
461 /* Set the mute mask */
462 ath5k_hw_reg_write(ah, 0x0000000f, AR5K_SEQ_MASK);
463 }
464
465 /* Clear PHY_BLUETOOTH to allow RX_CLEAR line debug */
466 if (ah->ah_phy_revision >= AR5K_SREV_PHY_5212B)
468
469 /* Enable DCU double buffering */
470 if (ah->ah_phy_revision > AR5K_SREV_PHY_5212B)
473
474 /* Set DAC/ADC delays */
475 if (ah->ah_version == AR5K_AR5212) {
476 u32 scal;
477 if (ah->ah_mac_version == (AR5K_SREV_AR2417 >> 4))
479 else if (ath5k_eeprom_is_hb63(ah))
481 else
482 scal = AR5K_PHY_SCAL_32MHZ;
484 }
485
486 /* Set fast ADC */
487 if ((ah->ah_radio == AR5K_RF5413) ||
488 (ah->ah_mac_version == (AR5K_SREV_AR2417 >> 4))) {
489 u32 fast_adc = 1;
490
491 if (channel->center_freq == 2462 ||
492 channel->center_freq == 2467)
493 fast_adc = 0;
494
495 /* Only update if needed */
496 if (ath5k_hw_reg_read(ah, AR5K_PHY_FAST_ADC) != fast_adc)
497 ath5k_hw_reg_write(ah, fast_adc,
499 }
500
501 /* Fix for first revision of the RF5112 RF chipset */
502 if (ah->ah_radio == AR5K_RF5112 &&
503 ah->ah_radio_5ghz_revision <
505 u32 data;
508 if (channel->hw_value & CHANNEL_5GHZ)
509 data = 0xffb81020;
510 else
511 data = 0xffb80d20;
513 }
514
515 if (ah->ah_mac_srev < AR5K_SREV_AR5211) {
516 u32 usec_reg;
517 /* 5311 has different tx/rx latency masks
518 * from 5211, since we deal 5311 the same
519 * as 5211 when setting initvals, shift
520 * values here to their proper locations */
522 ath5k_hw_reg_write(ah, usec_reg & (AR5K_USEC_1 |
525 AR5K_REG_SM(29,
528 /* Clear QCU/DCU clock gating register */
530 /* Set DAC/ADC delays */
532 /* Enable PCU FIFO corruption ECO */
535 }
536}
#define AR5K_PHY_SCAL
Definition reg.h:2084
#define AR5K_USEC_TX_LATENCY_5211
Definition reg.h:1223
#define AR5K_PHY_BLUETOOTH
Definition reg.h:2541
#define AR5K_PHY_DAG_CCK_CTL_EN_RSSI_THR
Definition reg.h:2535
#define AR5K_USEC_32
Definition reg.h:1221
#define AR5K_PHY_DAG_CCK_CTL_RSSI_THR
Definition reg.h:2536
#define AR5K_USEC_1
Definition reg.h:1219
#define AR5K_PHY_SCAL_32MHZ_2417
Definition reg.h:2086
#define AR5K_DIAG_SW_ECO_ENABLE
Definition reg.h:1415
#define AR5K_PHY_DAG_CCK_CTL
Definition reg.h:2534
#define AR5K_USEC_5211
Definition reg.h:1216
#define AR5K_PHY_FRAME_CTL
Definition reg.h:2268
#define AR5K_QCUDCU_CLKGT
Definition reg.h:275
#define AR5K_PHY_ADC_CTL
Definition reg.h:1942
#define AR5K_PHY_ADC_CTL_INBUFGAIN_ON
Definition reg.h:1948
#define AR5K_TXCFG
Definition reg.h:171
#define AR5K_DIAG_SW_5211
Definition reg.h:1386
#define AR5K_PHY_SCAL_32MHZ
Definition reg.h:2085
#define AR5K_USEC_RX_LATENCY_5210
Definition reg.h:1229
#define AR5K_PHY_CCKTXCTL
Definition reg.h:2505
#define AR5K_PHY_ADC_CTL_PWD_DAC_OFF
Definition reg.h:1945
#define AR5K_PHY_FAST_ADC
Definition reg.h:2539
#define AR5K_PHY_CCKTXCTL_WORLD
Definition reg.h:2506
#define AR5K_SEQ_MASK
Definition reg.h:1482
#define AR5K_PHY_ADC_CTL_PWD_ADC_OFF
Definition reg.h:1947
#define AR5K_TXCFG_DCU_DBL_BUF_DIS
Definition reg.h:192
#define AR5K_PHY_SCAL_32MHZ_HB63
Definition reg.h:2087
#define AR5K_PHY_ADC_CTL_INBUFGAIN_OFF
Definition reg.h:1943
#define AR5K_REG_SM(_val, _flags)
Definition ath5k.h:86
#define AR5K_REG_ENABLE_BITS(ah, _reg, _flags)
Definition ath5k.h:106
#define AR5K_SREV_PHY_5212A
Definition ath5k.h:329
int ath5k_eeprom_is_hb63(struct ath5k_hw *ah)
#define AR5K_SREV_RAD_5112A
Definition ath5k.h:314
#define AR5K_SREV_AR5211
Definition ath5k.h:294
#define AR5K_SREV_PHY_5212B
Definition ath5k.h:330
#define AR5K_REG_DISABLE_BITS(ah, _reg, _flags)
Definition ath5k.h:109

References ah, AR5K_AR5212, AR5K_DIAG_SW_5211, AR5K_DIAG_SW_ECO_ENABLE, AR5K_PHY_ADC_CTL, AR5K_PHY_ADC_CTL_INBUFGAIN_OFF, AR5K_PHY_ADC_CTL_INBUFGAIN_ON, AR5K_PHY_ADC_CTL_PWD_ADC_OFF, AR5K_PHY_ADC_CTL_PWD_DAC_OFF, AR5K_PHY_BLUETOOTH, AR5K_PHY_CCKTXCTL, AR5K_PHY_CCKTXCTL_WORLD, AR5K_PHY_DAG_CCK_CTL, AR5K_PHY_DAG_CCK_CTL_EN_RSSI_THR, AR5K_PHY_DAG_CCK_CTL_RSSI_THR, AR5K_PHY_FAST_ADC, AR5K_PHY_FRAME_CTL, AR5K_PHY_SCAL, AR5K_PHY_SCAL_32MHZ, AR5K_PHY_SCAL_32MHZ_2417, AR5K_PHY_SCAL_32MHZ_HB63, AR5K_QCUDCU_CLKGT, AR5K_REG_DISABLE_BITS, AR5K_REG_ENABLE_BITS, AR5K_REG_SM, AR5K_REG_WRITE_BITS, AR5K_RF5112, AR5K_RF5413, AR5K_SEQ_MASK, AR5K_SREV_AR2417, AR5K_SREV_AR5211, AR5K_SREV_PHY_5212A, AR5K_SREV_PHY_5212B, AR5K_SREV_RAD_5112A, AR5K_TXCFG, AR5K_TXCFG_DCU_DBL_BUF_DIS, AR5K_USEC_1, AR5K_USEC_32, AR5K_USEC_5211, AR5K_USEC_RX_LATENCY_5210, AR5K_USEC_TX_LATENCY_5211, ath5k_eeprom_is_hb63(), ath5k_hw_reg_read(), ath5k_hw_reg_write(), channel, CHANNEL_5GHZ, data, and u32.

Referenced by ath5k_hw_reset().

◆ ath5k_hw_commit_eeprom_settings()

void ath5k_hw_commit_eeprom_settings ( struct ath5k_hw * ah,
struct net80211_channel * channel,
u8 * ant,
u8 ee_mode )
static

Definition at line 538 of file ath5k_reset.c.

540{
541 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
542 s16 cck_ofdm_pwr_delta;
543
544 /* Adjust power delta for channel 14 */
545 if (channel->center_freq == 2484)
546 cck_ofdm_pwr_delta =
548 ee->ee_scaled_cck_delta) * 2) / 10;
549 else
550 cck_ofdm_pwr_delta =
551 (ee->ee_cck_ofdm_power_delta * 2) / 10;
552
553 /* Set CCK to OFDM power delta on tx power
554 * adjustment register */
555 if (ah->ah_phy_revision >= AR5K_SREV_PHY_5212A) {
556 if (channel->hw_value == CHANNEL_G)
560 AR5K_REG_SM((cck_ofdm_pwr_delta * -1),
563 else
565 } else {
566 /* For older revs we scale power on sw during tx power
567 * setup */
568 ah->ah_txpower.txp_cck_ofdm_pwr_delta = cck_ofdm_pwr_delta;
569 ah->ah_txpower.txp_cck_ofdm_gainf_delta =
571 }
572
573 /* Set antenna idle switch table */
576 (ah->ah_antenna[ee_mode][0] |
578
579 /* Set antenna switch table */
580 ath5k_hw_reg_write(ah, ah->ah_antenna[ee_mode][ant[0]],
582 ath5k_hw_reg_write(ah, ah->ah_antenna[ee_mode][ant[1]],
584
585 /* Noise floor threshold */
589
590 if ((channel->hw_value & CHANNEL_TURBO) &&
591 (ah->ah_ee_version >= AR5K_EEPROM_VERSION_5_0)) {
592 /* Switch settling time (Turbo) */
595 ee->ee_switch_settling_turbo[ee_mode]);
596
597 /* Tx/Rx attenuation (Turbo) */
600 ee->ee_atn_tx_rx_turbo[ee_mode]);
601
602 /* ADC/PGA desired size (Turbo) */
605 ee->ee_adc_desired_size_turbo[ee_mode]);
606
609 ee->ee_pga_desired_size_turbo[ee_mode]);
610
611 /* Tx/Rx margin (Turbo) */
614 ee->ee_margin_tx_rx_turbo[ee_mode]);
615
616 } else {
617 /* Switch settling time */
620 ee->ee_switch_settling[ee_mode]);
621
622 /* Tx/Rx attenuation */
625 ee->ee_atn_tx_rx[ee_mode]);
626
627 /* ADC/PGA desired size */
630 ee->ee_adc_desired_size[ee_mode]);
631
634 ee->ee_pga_desired_size[ee_mode]);
635
636 /* Tx/Rx margin */
637 if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_1)
640 ee->ee_margin_tx_rx[ee_mode]);
641 }
642
643 /* XPA delays */
645 (ee->ee_tx_end2xpa_disable[ee_mode] << 24) |
646 (ee->ee_tx_end2xpa_disable[ee_mode] << 16) |
647 (ee->ee_tx_frm2xpa_enable[ee_mode] << 8) |
648 (ee->ee_tx_frm2xpa_enable[ee_mode]), AR5K_PHY_RF_CTL4);
649
650 /* XLNA delay */
653 ee->ee_tx_end2xlna_enable[ee_mode]);
654
655 /* Thresh64 (ANI) */
658 ee->ee_thr_62[ee_mode]);
659
660
661 /* False detect backoff for channels
662 * that have spur noise. Write the new
663 * cyclic power RSSI threshold. */
668 ee->ee_false_detect[ee_mode]);
669 else
673
674 /* I/Q correction
675 * TODO: Per channel i/q infos ? */
678 (ee->ee_i_cal[ee_mode] << AR5K_PHY_IQ_CORR_Q_I_COFF_S) |
679 ee->ee_q_cal[ee_mode]);
680
681 /* Heavy clipping -disable for now */
682 if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_5_1)
684
685 return;
686}
#define AR5K_EEPROM_VERSION_5_0
Definition eeprom.h:60
#define AR5K_EEPROM_VERSION_4_1
Definition eeprom.h:52
#define AR5K_EEPROM_VERSION_5_1
Definition eeprom.h:61
#define AR5K_PHY_RF_CTL3
Definition reg.h:1938
#define AR5K_PHY_SETTLING
Definition reg.h:1970
#define AR5K_PHY_IQ
Definition reg.h:2185
#define AR5K_PHY_ANT_CTL
Definition reg.h:2163
#define AR5K_PHY_TX_PWR_ADJ_CCK_PCDAC_INDEX
Definition reg.h:2296
#define AR5K_PHY_RF_CTL4
Definition reg.h:1951
#define AR5K_PHY_IQ_CORR_Q_I_COFF_S
Definition reg.h:2188
#define AR5K_PHY_NF
Definition reg.h:2032
#define AR5K_PHY_DESIRED_SIZE_ADC
Definition reg.h:1993
#define AR5K_PHY_NFTHRES
Definition reg.h:2329
#define AR5K_PHY_DESIRED_SIZE
Definition reg.h:1992
#define AR5K_PHY_GAIN
Definition reg.h:1979
#define AR5K_PHY_GAIN_2GHZ_MARGIN_TXRX
Definition reg.h:2526
#define AR5K_PHY_RF_CTL3_TXE2XLNA_ON
Definition reg.h:1939
#define AR5K_PHY_TX_PWR_ADJ
Definition reg.h:2293
#define AR5K_PHY_GAIN_TXRX_ATTEN
Definition reg.h:1980
#define AR5K_PHY_TX_PWR_ADJ_CCK_GAIN_DELTA
Definition reg.h:2294
#define AR5K_PHY_NF_SVAL(_n)
Definition reg.h:2037
#define AR5K_PHY_ANT_SWITCH_TABLE_0
Definition reg.h:2323
#define AR5K_PHY_HEAVY_CLIP_ENABLE
Definition reg.h:2459
#define AR5K_PHY_ANT_CTL_SWTABLE_IDLE
Definition reg.h:2167
#define AR5K_PHY_OFDM_SELFCORR_CYPWR_THR1
Definition reg.h:2207
#define AR5K_PHY_DESIRED_SIZE_PGA
Definition reg.h:1995
#define AR5K_PHY_NF_THRESH62
Definition reg.h:2038
#define AR5K_PHY_OFDM_SELFCORR
Definition reg.h:2205
#define AR5K_PHY_SETTLING_SWITCH
Definition reg.h:1973
#define AR5K_PHY_ANT_SWITCH_TABLE_1
Definition reg.h:2324
#define AR5K_PHY_ANT_CTL_TXRX_EN
Definition reg.h:2164
#define AR5K_PHY_GAIN_2GHZ
Definition reg.h:2525
#define AR5K_PHY_IQ_CORR_ENABLE
Definition reg.h:2189
#define CHANNEL_G
Definition ath5k.h:642
#define AR5K_INIT_CYCRSSI_THR1
Definition ath5k.h:211
static int ath5k_hw_chan_has_spur_noise(struct ath5k_hw *ah, struct net80211_channel *channel)
int16_t s16
Definition stdint.h:21
u16 ee_cck_ofdm_power_delta
Definition eeprom.h:392
u16 ee_switch_settling_turbo[AR5K_EEPROM_N_MODES]
Definition eeprom.h:415
u16 ee_tx_frm2xpa_enable[AR5K_EEPROM_N_MODES]
Definition eeprom.h:408
u16 ee_cck_ofdm_gain_delta
Definition eeprom.h:391
s8 ee_adc_desired_size_turbo[AR5K_EEPROM_N_MODES]
Definition eeprom.h:447
u16 ee_atn_tx_rx[AR5K_EEPROM_N_MODES]
Definition eeprom.h:402
s8 ee_pga_desired_size[AR5K_EEPROM_N_MODES]
Definition eeprom.h:446
s16 ee_noise_floor_thr[AR5K_EEPROM_N_MODES]
Definition eeprom.h:444
u16 ee_atn_tx_rx_turbo[AR5K_EEPROM_N_MODES]
Definition eeprom.h:417
u16 ee_switch_settling[AR5K_EEPROM_N_MODES]
Definition eeprom.h:401
u16 ee_q_cal[AR5K_EEPROM_N_MODES]
Definition eeprom.h:397
s8 ee_pga_desired_size_turbo[AR5K_EEPROM_N_MODES]
Definition eeprom.h:448
u16 ee_tx_end2xlna_enable[AR5K_EEPROM_N_MODES]
Definition eeprom.h:406
u16 ee_scaled_cck_delta
Definition eeprom.h:393
u16 ee_i_cal[AR5K_EEPROM_N_MODES]
Definition eeprom.h:396
u16 ee_false_detect[AR5K_EEPROM_N_MODES]
Definition eeprom.h:420
u16 ee_margin_tx_rx[AR5K_EEPROM_N_MODES]
Definition eeprom.h:414
u16 ee_thr_62[AR5K_EEPROM_N_MODES]
Definition eeprom.h:409
s8 ee_adc_desired_size[AR5K_EEPROM_N_MODES]
Definition eeprom.h:445
u16 ee_margin_tx_rx_turbo[AR5K_EEPROM_N_MODES]
Definition eeprom.h:416
u16 ee_tx_end2xpa_disable[AR5K_EEPROM_N_MODES]
Definition eeprom.h:407

References ah, AR5K_EEPROM_VERSION_4_1, AR5K_EEPROM_VERSION_5_0, AR5K_EEPROM_VERSION_5_1, AR5K_INIT_CYCRSSI_THR1, AR5K_PHY_ANT_CTL, AR5K_PHY_ANT_CTL_SWTABLE_IDLE, AR5K_PHY_ANT_CTL_TXRX_EN, AR5K_PHY_ANT_SWITCH_TABLE_0, AR5K_PHY_ANT_SWITCH_TABLE_1, AR5K_PHY_DESIRED_SIZE, AR5K_PHY_DESIRED_SIZE_ADC, AR5K_PHY_DESIRED_SIZE_PGA, AR5K_PHY_GAIN, AR5K_PHY_GAIN_2GHZ, AR5K_PHY_GAIN_2GHZ_MARGIN_TXRX, AR5K_PHY_GAIN_TXRX_ATTEN, AR5K_PHY_HEAVY_CLIP_ENABLE, AR5K_PHY_IQ, AR5K_PHY_IQ_CORR_ENABLE, AR5K_PHY_IQ_CORR_Q_I_COFF_S, AR5K_PHY_NF, AR5K_PHY_NF_SVAL, AR5K_PHY_NF_THRESH62, AR5K_PHY_NFTHRES, AR5K_PHY_OFDM_SELFCORR, AR5K_PHY_OFDM_SELFCORR_CYPWR_THR1, AR5K_PHY_RF_CTL3, AR5K_PHY_RF_CTL3_TXE2XLNA_ON, AR5K_PHY_RF_CTL4, AR5K_PHY_SETTLING, AR5K_PHY_SETTLING_SWITCH, AR5K_PHY_TX_PWR_ADJ, AR5K_PHY_TX_PWR_ADJ_CCK_GAIN_DELTA, AR5K_PHY_TX_PWR_ADJ_CCK_PCDAC_INDEX, AR5K_REG_ENABLE_BITS, AR5K_REG_SM, AR5K_REG_WRITE_BITS, AR5K_SREV_PHY_5212A, ath5k_hw_chan_has_spur_noise(), ath5k_hw_reg_write(), channel, CHANNEL_G, CHANNEL_TURBO, ath5k_eeprom_info::ee_adc_desired_size, ath5k_eeprom_info::ee_adc_desired_size_turbo, ath5k_eeprom_info::ee_atn_tx_rx, ath5k_eeprom_info::ee_atn_tx_rx_turbo, ath5k_eeprom_info::ee_cck_ofdm_gain_delta, ath5k_eeprom_info::ee_cck_ofdm_power_delta, ath5k_eeprom_info::ee_false_detect, ath5k_eeprom_info::ee_i_cal, ath5k_eeprom_info::ee_margin_tx_rx, ath5k_eeprom_info::ee_margin_tx_rx_turbo, ath5k_eeprom_info::ee_noise_floor_thr, ath5k_eeprom_info::ee_pga_desired_size, ath5k_eeprom_info::ee_pga_desired_size_turbo, ath5k_eeprom_info::ee_q_cal, ath5k_eeprom_info::ee_scaled_cck_delta, ath5k_eeprom_info::ee_switch_settling, ath5k_eeprom_info::ee_switch_settling_turbo, ath5k_eeprom_info::ee_thr_62, ath5k_eeprom_info::ee_tx_end2xlna_enable, ath5k_eeprom_info::ee_tx_end2xpa_disable, ath5k_eeprom_info::ee_tx_frm2xpa_enable, and u8.

Referenced by ath5k_hw_reset().

◆ ath5k_hw_reset()

int ath5k_hw_reset ( struct ath5k_hw * ah,
struct net80211_channel * channel,
int change_channel )

Definition at line 691 of file ath5k_reset.c.

693{
694 u32 s_seq[10], s_ant, s_led[3], staid1_flags;
695 u32 phy_tst1;
696 u8 mode, freq, ee_mode, ant[2];
697 int i, ret;
698
699 s_ant = 0;
700 ee_mode = 0;
701 staid1_flags = 0;
702 freq = 0;
703 mode = 0;
704
705 /*
706 * Save some registers before a reset
707 */
708 /*DCU/Antenna selection not available on 5210*/
709 if (ah->ah_version != AR5K_AR5210) {
710
711 switch (channel->hw_value & CHANNEL_MODES) {
712 case CHANNEL_A:
715 ee_mode = AR5K_EEPROM_MODE_11A;
716 break;
717 case CHANNEL_G:
720 ee_mode = AR5K_EEPROM_MODE_11G;
721 break;
722 case CHANNEL_B:
725 ee_mode = AR5K_EEPROM_MODE_11B;
726 break;
727 case CHANNEL_T:
730 ee_mode = AR5K_EEPROM_MODE_11A;
731 break;
732 case CHANNEL_TG:
733 if (ah->ah_version == AR5K_AR5211) {
734 DBG("ath5k: TurboG not available on 5211\n");
735 return -EINVAL;
736 }
739 ee_mode = AR5K_EEPROM_MODE_11G;
740 break;
741 case CHANNEL_XR:
742 if (ah->ah_version == AR5K_AR5211) {
743 DBG("ath5k: XR mode not available on 5211\n");
744 return -EINVAL;
745 }
748 ee_mode = AR5K_EEPROM_MODE_11A;
749 break;
750 default:
751 DBG("ath5k: invalid channel (%d MHz)\n",
752 channel->center_freq);
753 return -EINVAL;
754 }
755
756 if (change_channel) {
757 /*
758 * Save frame sequence count
759 * For revs. after Oahu, only save
760 * seq num for DCU 0 (Global seq num)
761 */
762 if (ah->ah_mac_srev < AR5K_SREV_AR5211) {
763
764 for (i = 0; i < 10; i++)
765 s_seq[i] = ath5k_hw_reg_read(ah,
767
768 } else {
769 s_seq[0] = ath5k_hw_reg_read(ah,
771 }
772 }
773
774 /* Save default antenna */
776
777 if (ah->ah_version == AR5K_AR5212) {
778 /* Since we are going to write rf buffer
779 * check if we have any pending gain_F
780 * optimization settings */
781 if (change_channel && ah->ah_rf_banks != NULL)
783 }
784 }
785
786 /*GPIOs*/
787 s_led[0] = ath5k_hw_reg_read(ah, AR5K_PCICFG) &
789 s_led[1] = ath5k_hw_reg_read(ah, AR5K_GPIOCR);
790 s_led[2] = ath5k_hw_reg_read(ah, AR5K_GPIODO);
791
792 /* AR5K_STA_ID1 flags, only preserve antenna
793 * settings and ack/cts rate mode */
794 staid1_flags = ath5k_hw_reg_read(ah, AR5K_STA_ID1) &
801
802 /* Wakeup the device */
803 ret = ath5k_hw_nic_wakeup(ah, channel->hw_value, 0);
804 if (ret)
805 return ret;
806
807 /* PHY access enable */
808 if (ah->ah_mac_srev >= AR5K_SREV_AR5211)
810 else
812 AR5K_PHY(0));
813
814 /* Write initial settings */
815 ret = ath5k_hw_write_initvals(ah, mode, change_channel);
816 if (ret)
817 return ret;
818
819 /*
820 * 5211/5212 Specific
821 */
822 if (ah->ah_version != AR5K_AR5210) {
823
824 /*
825 * Write initial RF gain settings
826 * This should work for both 5111/5112
827 */
828 ret = ath5k_hw_rfgain_init(ah, freq);
829 if (ret)
830 return ret;
831
832 mdelay(1);
833
834 /*
835 * Tweak initval settings for revised
836 * chipsets and add some more config
837 * bits
838 */
840
841 /*
842 * Set TX power (FIXME)
843 */
844 ret = ath5k_hw_txpower(ah, channel, ee_mode,
846 if (ret)
847 return ret;
848
849 /* Write rate duration table only on AR5212 */
850 if (ah->ah_version == AR5K_AR5212)
852
853 /*
854 * Write RF buffer
855 */
857 if (ret)
858 return ret;
859
860
861 /* Write OFDM timings on 5212*/
862 if (ah->ah_version == AR5K_AR5212 &&
863 channel->hw_value & CHANNEL_OFDM) {
865 if (ret)
866 return ret;
867 }
868
869 /*Enable/disable 802.11b mode on 5111
870 (enable 2111 frequency converter + CCK)*/
871 if (ah->ah_radio == AR5K_RF5111) {
872 if (mode == AR5K_MODE_11B)
875 else
878 }
879
880 /*
881 * In case a fixed antenna was set as default
882 * write the same settings on both AR5K_PHY_ANT_SWITCH_TABLE
883 * registers.
884 */
885 if (s_ant != 0) {
886 if (s_ant == AR5K_ANT_FIXED_A) /* 1 - Main */
887 ant[0] = ant[1] = AR5K_ANT_FIXED_A;
888 else /* 2 - Aux */
889 ant[0] = ant[1] = AR5K_ANT_FIXED_B;
890 } else {
891 ant[0] = AR5K_ANT_FIXED_A;
892 ant[1] = AR5K_ANT_FIXED_B;
893 }
894
895 /* Commit values from EEPROM */
897
898 } else {
899 /*
900 * For 5210 we do all initialization using
901 * initvals, so we don't have to modify
902 * any settings (5210 also only supports
903 * a/aturbo modes)
904 */
905 mdelay(1);
906 /* Disable phy and wait */
908 mdelay(1);
909 }
910
911 /*
912 * Restore saved values
913 */
914
915 /*DCU/Antenna selection not available on 5210*/
916 if (ah->ah_version != AR5K_AR5210) {
917
918 if (change_channel) {
919 if (ah->ah_mac_srev < AR5K_SREV_AR5211) {
920 for (i = 0; i < 10; i++)
921 ath5k_hw_reg_write(ah, s_seq[i],
923 } else {
924 ath5k_hw_reg_write(ah, s_seq[0],
926 }
927 }
928
930 }
931
932 /* Ledstate */
934
935 /* Gpio settings */
938
939 /* Restore sta_id flags and preserve our mac address*/
940 ath5k_hw_reg_write(ah, AR5K_LOW_ID(ah->ah_sta_id),
942 ath5k_hw_reg_write(ah, staid1_flags | AR5K_HIGH_ID(ah->ah_sta_id),
944
945
946 /*
947 * Configure PCU
948 */
949
950 /* Restore bssid and bssid mask */
951 /* XXX: add ah->aid once mac80211 gives this to us */
952 ath5k_hw_set_associd(ah, ah->ah_bssid, 0);
953
954 /* Set PCU config */
956
957 /* Clear any pending interrupts
958 * PISR/SISR Not available on 5210 */
959 if (ah->ah_version != AR5K_AR5210)
960 ath5k_hw_reg_write(ah, 0xffffffff, AR5K_PISR);
961
962 /* Set RSSI/BRSSI thresholds
963 *
964 * Note: If we decide to set this value
965 * dynamicaly, have in mind that when AR5K_RSSI_THR
966 * register is read it might return 0x40 if we haven't
967 * wrote anything to it plus BMISS RSSI threshold is zeroed.
968 * So doing a save/restore procedure here isn't the right
969 * choice. Instead store it on ath5k_hw */
974
975 /* MIC QoS support */
976 if (ah->ah_mac_srev >= AR5K_SREV_AR2413) {
979 }
980
981 /* QoS NOACK Policy */
982 if (ah->ah_version == AR5K_AR5212) {
988 }
989
990
991 /*
992 * Configure PHY
993 */
994
995 /* Set channel on PHY */
997 if (ret)
998 return ret;
999
1000 /*
1001 * Enable the PHY and wait until completion
1002 * This includes BaseBand and Synthesizer
1003 * activation.
1004 */
1006
1007 /*
1008 * On 5211+ read activation -> rx delay
1009 * and use it.
1010 *
1011 * TODO: Half/quarter rate support
1012 */
1013 if (ah->ah_version != AR5K_AR5210) {
1014 u32 delay;
1017 delay = (channel->hw_value & CHANNEL_CCK) ?
1018 ((delay << 2) / 22) : (delay / 10);
1019
1020 udelay(100 + (2 * delay));
1021 } else {
1022 mdelay(1);
1023 }
1024
1025 /*
1026 * Perform ADC test to see if baseband is ready
1027 * Set tx hold and check adc test register
1028 */
1029 phy_tst1 = ath5k_hw_reg_read(ah, AR5K_PHY_TST1);
1031 for (i = 0; i <= 20; i++) {
1032 if (!(ath5k_hw_reg_read(ah, AR5K_PHY_ADC_TEST) & 0x10))
1033 break;
1034 udelay(200);
1035 }
1037
1038 /*
1039 * Start automatic gain control calibration
1040 *
1041 * During AGC calibration RX path is re-routed to
1042 * a power detector so we don't receive anything.
1043 *
1044 * This method is used to calibrate some static offsets
1045 * used together with on-the fly I/Q calibration (the
1046 * one performed via ath5k_hw_phy_calibrate), that doesn't
1047 * interrupt rx path.
1048 *
1049 * While rx path is re-routed to the power detector we also
1050 * start a noise floor calibration, to measure the
1051 * card's noise floor (the noise we measure when we are not
1052 * transmiting or receiving anything).
1053 *
1054 * If we are in a noisy environment AGC calibration may time
1055 * out and/or noise floor calibration might timeout.
1056 */
1059
1060 /* At the same time start I/Q calibration for QAM constellation
1061 * -no need for CCK- */
1062 ah->ah_calibration = 0;
1063 if (!(mode == AR5K_MODE_11B)) {
1064 ah->ah_calibration = 1;
1069 }
1070
1071 /* Wait for gain calibration to finish (we check for I/Q calibration
1072 * during ath5k_phy_calibrate) */
1073 if (ath5k_hw_register_timeout(ah, AR5K_PHY_AGCCTL,
1074 AR5K_PHY_AGCCTL_CAL, 0, 0)) {
1075 DBG("ath5k: gain calibration timeout (%d MHz)\n",
1076 channel->center_freq);
1077 }
1078
1079 /*
1080 * If we run NF calibration before AGC, it always times out.
1081 * Binary HAL starts NF and AGC calibration at the same time
1082 * and only waits for AGC to finish. Also if AGC or NF cal.
1083 * times out, reset doesn't fail on binary HAL. I believe
1084 * that's wrong because since rx path is routed to a detector,
1085 * if cal. doesn't finish we won't have RX. Sam's HAL for AR5210/5211
1086 * enables noise floor calibration after offset calibration and if noise
1087 * floor calibration fails, reset fails. I believe that's
1088 * a better approach, we just need to find a polling interval
1089 * that suits best, even if reset continues we need to make
1090 * sure that rx path is ready.
1091 */
1093
1094
1095 /*
1096 * Configure QCUs/DCUs
1097 */
1098
1099 /* TODO: HW Compression support for data queues */
1100 /* TODO: Burst prefetch for data queues */
1101
1102 /*
1103 * Reset queues and start beacon timers at the end of the reset routine
1104 * This also sets QCU mask on each DCU for 1:1 qcu to dcu mapping
1105 * Note: If we want we can assign multiple qcus on one dcu.
1106 */
1108 if (ret) {
1109 DBG("ath5k: failed to reset TX queue\n");
1110 return ret;
1111 }
1112
1113 /*
1114 * Configure DMA/Interrupts
1115 */
1116
1117 /*
1118 * Set Rx/Tx DMA Configuration
1119 *
1120 * Set standard DMA size (128). Note that
1121 * a DMA size of 512 causes rx overruns and tx errors
1122 * on pci-e cards (tested on 5424 but since rx overruns
1123 * also occur on 5416/5418 with madwifi we set 128
1124 * for all PCI-E cards to be safe).
1125 *
1126 * XXX: need to check 5210 for this
1127 * TODO: Check out tx triger level, it's always 64 on dumps but I
1128 * guess we can tweak it and see how it goes ;-)
1129 */
1130 if (ah->ah_version != AR5K_AR5210) {
1135 }
1136
1137 /* Pre-enable interrupts on 5211/5212*/
1138 if (ah->ah_version != AR5K_AR5210)
1139 ath5k_hw_set_imr(ah, ah->ah_imr);
1140
1141 /*
1142 * Setup RFKill interrupt if rfkill flag is set on eeprom.
1143 * TODO: Use gpio pin and polarity infos from eeprom
1144 * TODO: Handle this in ath5k_intr because it'll result
1145 * a nasty interrupt storm.
1146 */
1147#if 0
1148 if (AR5K_EEPROM_HDR_RFKILL(ah->ah_capabilities.cap_eeprom.ee_header)) {
1150 ah->ah_gpio[0] = ath5k_hw_get_gpio(ah, 0);
1151 if (ah->ah_gpio[0] == 0)
1153 else
1155 }
1156#endif
1157
1158 /*
1159 * Disable beacons and reset the register
1160 */
1163
1164 return 0;
1165}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
@ AR5K_ANT_FIXED_B
Definition eeprom.h:236
@ AR5K_ANT_FIXED_A
Definition eeprom.h:235
#define AR5K_EEPROM_HDR_RFKILL(_v)
Definition eeprom.h:75
#define AR5K_EEPROM_MODE_11A
Definition eeprom.h:64
#define AR5K_EEPROM_MODE_11B
Definition eeprom.h:65
#define AR5K_EEPROM_MODE_11G
Definition eeprom.h:66
#define AR5K_PHY_IQ_RUN
Definition reg.h:2192
#define AR5K_RSSI_THR
Definition reg.h:1177
#define AR5K_PHY_ADC_TEST
Definition reg.h:2418
#define AR5K_QOS_NOACK_BIT_OFFSET
Definition reg.h:1700
#define AR5K_PHY_AGCCTL_CAL
Definition reg.h:2024
#define AR5K_BEACON_RESET_TSF
Definition reg.h:1244
#define AR5K_STA_ID1_ACKCTS_6MB
Definition reg.h:1137
#define AR5K_MIC_QOS_CTL
Definition reg.h:1727
#define AR5K_QOS_NOACK_BYTE_OFFSET
Definition reg.h:1702
#define AR5K_PHY_IQ_CAL_NUM_LOG_MAX
Definition reg.h:2190
#define AR5K_PHY_ACT_ENABLE
Definition reg.h:1928
#define AR5K_BEACON_ENABLE
Definition reg.h:1243
#define AR5K_PHY_AGCCTL
Definition reg.h:2023
#define AR5K_STA_ID1_RTS_DEF_ANTENNA
Definition reg.h:1136
#define AR5K_RXCFG
Definition reg.h:198
#define AR5K_PHY_ACT
Definition reg.h:1927
#define AR5K_TXCFG_B_MODE
Definition reg.h:174
#define AR5K_BEACON
Definition reg.h:1237
#define AR5K_PISR
Definition reg.h:288
#define AR5K_TXCFG_SDMAMR
Definition reg.h:172
#define AR5K_GPIODO
Definition reg.h:943
#define AR5K_RSSI_THR_BMISS_S
Definition reg.h:1185
#define AR5K_RXCFG_SDMAMW
Definition reg.h:199
#define AR5K_STA_ID1_DEFAULT_ANTENNA
Definition reg.h:1134
#define AR5K_PHY_ACT_DISABLE
Definition reg.h:1929
#define AR5K_PHY_TST1
Definition reg.h:1901
#define AR5K_MIC_QOS_SEL
Definition reg.h:1734
#define AR5K_PHY_RX_DELAY
Definition reg.h:2173
#define AR5K_PCICFG_LEDSTATE
Definition reg.h:906
#define AR5K_STA_ID1_DESC_ANTENNA
Definition reg.h:1135
#define AR5K_GPIOCR
Definition reg.h:930
#define AR5K_PHY(_n)
Definition reg.h:1856
#define AR5K_STA_ID0
Definition reg.h:1117
#define AR5K_PHY_TST1_TXHOLD
Definition reg.h:1903
#define AR5K_QOS_NOACK_2BIT_VALUES
Definition reg.h:1698
#define AR5K_STA_ID1_SELFGEN_DEF_ANT
Definition reg.h:1139
#define AR5K_QOS_NOACK
Definition reg.h:1697
#define AR5K_QUEUE_DCU_SEQNUM(_q)
Definition reg.h:754
#define AR5K_PHY_SHIFT_5GHZ
Definition reg.h:1879
#define AR5K_PHY_RX_DELAY_M
Definition reg.h:2174
#define AR5K_STA_ID1_BASE_RATE_11B
Definition reg.h:1138
#define AR5K_DEFAULT_ANTENNA
Definition reg.h:1471
int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah)
Definition ath5k_qcu.c:98
#define CHANNEL_B
Definition ath5k.h:641
#define CHANNEL_TG
Definition ath5k.h:644
#define CHANNEL_XR
Definition ath5k.h:638
#define AR5K_TUNE_BMISS_THRES
Definition ath5k.h:180
@ AR5K_MODE_11G_TURBO
Definition ath5k.h:398
@ AR5K_MODE_11A_TURBO
Definition ath5k.h:395
@ AR5K_MODE_XR
Definition ath5k.h:399
@ AR5K_MODE_11B
Definition ath5k.h:396
@ AR5K_MODE_11A
Definition ath5k.h:394
@ AR5K_MODE_11G
Definition ath5k.h:397
int ath5k_hw_rfgain_init(struct ath5k_hw *ah, unsigned int freq)
Definition ath5k_phy.c:453
int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, int change_channel)
u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio)
Definition ath5k_gpio.c:65
#define AR5K_LOW_ID(_a)
Definition ath5k.h:154
#define CHANNEL_MODES
Definition ath5k.h:653
#define AR5K_INI_RFGAIN_2GHZ
Definition ath5k.h:142
int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio)
Definition ath5k_gpio.c:35
int ath5k_hw_set_opmode(struct ath5k_hw *ah)
ath5k_hw_set_opmode - Set PCU operating mode
Definition ath5k_pcu.c:49
int ath5k_hw_noise_floor_calibration(struct ath5k_hw *ah, short freq)
ath5k_hw_noise_floor_calibration - perform PHY noise floor calibration
Definition ath5k_phy.c:1128
#define CHANNEL_T
Definition ath5k.h:643
void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, u32 interrupt_level)
Definition ath5k_gpio.c:99
int ath5k_hw_rfregs_init(struct ath5k_hw *ah, struct net80211_channel *channel, unsigned int mode)
Definition ath5k_phy.c:515
enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask)
ath5k_hw_set_imr - Set interrupt mask
Definition ath5k_dma.c:549
#define AR5K_TUNE_RSSI_THRES
Definition ath5k.h:174
@ AR5K_DMASIZE_128B
Definition ath5k.h:556
#define AR5K_INI_RFGAIN_5GHZ
Definition ath5k.h:141
@ AR5K_RF5111
Definition ath5k.h:264
#define AR5K_HIGH_ID(_a)
Definition ath5k.h:158
int ath5k_hw_channel(struct ath5k_hw *ah, struct net80211_channel *channel)
Definition ath5k_phy.c:1049
#define CHANNEL_A
Definition ath5k.h:640
int ath5k_hw_txpower(struct ath5k_hw *ah, struct net80211_channel *channel, u8 ee_mode, u8 txpower)
Definition ath5k_phy.c:2475
#define AR5K_TUNE_DEFAULT_TXPOWER
Definition ath5k.h:194
enum ath5k_rfgain ath5k_hw_gainf_calibrate(struct ath5k_hw *ah)
Definition ath5k_phy.c:390
#define AR5K_SREV_AR2413
Definition ath5k.h:298
void ath5k_hw_set_associd(struct ath5k_hw *ah, const u8 *bssid, u16 assoc_id)
ath5k_hw_set_associd - Set BSSID for association
Definition ath5k_pcu.c:229
static void ath5k_hw_tweak_initval_settings(struct ath5k_hw *ah, struct net80211_channel *channel)
static void ath5k_hw_commit_eeprom_settings(struct ath5k_hw *ah, struct net80211_channel *channel, u8 *ant, u8 ee_mode)
static int ath5k_hw_write_ofdm_timings(struct ath5k_hw *ah, struct net80211_channel *channel)
ath5k_hw_write_ofdm_timings - set OFDM timings on AR5212
Definition ath5k_reset.c:86
static void ath5k_hw_write_rate_duration(struct ath5k_hw *ah, unsigned int mode __unused)
ath5k_hw_write_rate_duration - fill rate code to duration table
int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, int initial __unused)
#define delay(nanosec)
Definition epic100.c:49

References ah, AR5K_ANT_FIXED_A, AR5K_ANT_FIXED_B, AR5K_AR5210, AR5K_AR5211, AR5K_AR5212, AR5K_BEACON, AR5K_BEACON_ENABLE, AR5K_BEACON_RESET_TSF, AR5K_DEFAULT_ANTENNA, AR5K_DMASIZE_128B, AR5K_EEPROM_HDR_RFKILL, AR5K_EEPROM_MODE_11A, AR5K_EEPROM_MODE_11B, AR5K_EEPROM_MODE_11G, AR5K_GPIOCR, AR5K_GPIODO, AR5K_HIGH_ID, AR5K_INI_RFGAIN_2GHZ, AR5K_INI_RFGAIN_5GHZ, AR5K_LOW_ID, AR5K_MIC_QOS_CTL, AR5K_MIC_QOS_SEL, AR5K_MODE_11A, AR5K_MODE_11A_TURBO, AR5K_MODE_11B, AR5K_MODE_11G, AR5K_MODE_11G_TURBO, AR5K_MODE_XR, AR5K_PCICFG, AR5K_PCICFG_LEDSTATE, AR5K_PHY, AR5K_PHY_ACT, AR5K_PHY_ACT_DISABLE, AR5K_PHY_ACT_ENABLE, AR5K_PHY_ADC_TEST, AR5K_PHY_AGCCTL, AR5K_PHY_AGCCTL_CAL, AR5K_PHY_IQ, AR5K_PHY_IQ_CAL_NUM_LOG_MAX, AR5K_PHY_IQ_RUN, AR5K_PHY_RX_DELAY, AR5K_PHY_RX_DELAY_M, AR5K_PHY_SHIFT_5GHZ, AR5K_PHY_TST1, AR5K_PHY_TST1_TXHOLD, AR5K_PISR, AR5K_QOS_NOACK, AR5K_QOS_NOACK_2BIT_VALUES, AR5K_QOS_NOACK_BIT_OFFSET, AR5K_QOS_NOACK_BYTE_OFFSET, AR5K_QUEUE_DCU_SEQNUM, AR5K_REG_DISABLE_BITS, AR5K_REG_ENABLE_BITS, AR5K_REG_SM, AR5K_REG_WRITE_BITS, AR5K_RF5111, AR5K_RSSI_THR, AR5K_RSSI_THR_BMISS_S, AR5K_RXCFG, AR5K_RXCFG_SDMAMW, AR5K_SREV_AR2413, AR5K_SREV_AR5211, AR5K_STA_ID0, AR5K_STA_ID1, AR5K_STA_ID1_ACKCTS_6MB, AR5K_STA_ID1_BASE_RATE_11B, AR5K_STA_ID1_DEFAULT_ANTENNA, AR5K_STA_ID1_DESC_ANTENNA, AR5K_STA_ID1_RTS_DEF_ANTENNA, AR5K_STA_ID1_SELFGEN_DEF_ANT, AR5K_TUNE_BMISS_THRES, AR5K_TUNE_DEFAULT_TXPOWER, AR5K_TUNE_RSSI_THRES, AR5K_TXCFG, AR5K_TXCFG_B_MODE, AR5K_TXCFG_SDMAMR, ath5k_hw_channel(), ath5k_hw_commit_eeprom_settings(), ath5k_hw_gainf_calibrate(), ath5k_hw_get_gpio(), ath5k_hw_nic_wakeup(), ath5k_hw_noise_floor_calibration(), ath5k_hw_reg_read(), ath5k_hw_reg_write(), ath5k_hw_reset_tx_queue(), ath5k_hw_rfgain_init(), ath5k_hw_rfregs_init(), ath5k_hw_set_associd(), ath5k_hw_set_gpio_input(), ath5k_hw_set_gpio_intr(), ath5k_hw_set_imr(), ath5k_hw_set_opmode(), ath5k_hw_tweak_initval_settings(), ath5k_hw_txpower(), ath5k_hw_write_initvals(), ath5k_hw_write_ofdm_timings(), ath5k_hw_write_rate_duration(), channel, CHANNEL_A, CHANNEL_B, CHANNEL_CCK, CHANNEL_G, CHANNEL_MODES, CHANNEL_OFDM, CHANNEL_T, CHANNEL_TG, CHANNEL_XR, DBG, delay, EINVAL, mdelay(), mode, NULL, u32, u8, and udelay().

Referenced by ath5k_reset().