2 * Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
3 * Copyright (c) 2006-2008 Nick Kossifidis <mickflemm@gmail.com>
4 * Copyright (c) 2007-2008 Luis Rodriguez <mcgrof@winlab.rutgers.edu>
5 * Copyright (c) 2007-2008 Pavel Roskin <proski@gnu.org>
6 * Copyright (c) 2007-2008 Jiri Slaby <jirislaby@gmail.com>
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 /*****************************\
23 Reset functions and helpers
24 \*****************************/
26 #include <asm/unaligned.h>
28 #include <linux/pci.h> /* To determine if a card is pci-e */
29 #include <linux/log2.h>
36 * Check if a register write has been completed
38 int ath5k_hw_register_timeout(struct ath5k_hw
*ah
, u32 reg
, u32 flag
, u32 val
,
44 for (i
= AR5K_TUNE_REGISTER_TIMEOUT
; i
> 0; i
--) {
45 data
= ath5k_hw_reg_read(ah
, reg
);
46 if (is_set
&& (data
& flag
))
48 else if ((data
& flag
) == val
)
53 return (i
<= 0) ? -EAGAIN
: 0;
57 * ath5k_hw_write_ofdm_timings - set OFDM timings on AR5212
59 * @ah: the &struct ath5k_hw
60 * @channel: the currently set channel upon reset
62 * Write the delta slope coefficient (used on pilot tracking ?) for OFDM
63 * operation on the AR5212 upon reset. This is a helper for ath5k_hw_reset().
65 * Since delta slope is floating point we split it on its exponent and
66 * mantissa and provide these values on hw.
68 * For more infos i think this patent is related
69 * http://www.freepatentsonline.com/7184495.html
71 static inline int ath5k_hw_write_ofdm_timings(struct ath5k_hw
*ah
,
72 struct ieee80211_channel
*channel
)
74 /* Get exponent and mantissa and set it */
75 u32 coef_scaled
, coef_exp
, coef_man
,
76 ds_coef_exp
, ds_coef_man
, clock
;
78 BUG_ON(!(ah
->ah_version
== AR5K_AR5212
) ||
79 !(channel
->hw_value
& CHANNEL_OFDM
));
82 * ALGO: coef = (5 * clock / carrier_freq) / 2
83 * we scale coef by shifting clock value by 24 for
84 * better precision since we use integers */
85 /* TODO: Half/quarter rate */
86 clock
= (channel
->hw_value
& CHANNEL_TURBO
) ? 80 : 40;
87 coef_scaled
= ((5 * (clock
<< 24)) / 2) / channel
->center_freq
;
90 * ALGO: coef_exp = 14 - highest set bit position */
91 coef_exp
= ilog2(coef_scaled
);
93 /* Doesn't make sense if it's zero*/
94 if (!coef_scaled
|| !coef_exp
)
97 /* Note: we've shifted coef_scaled by 24 */
98 coef_exp
= 14 - (coef_exp
- 24);
101 /* Get mantissa (significant digits)
102 * ALGO: coef_mant = floor(coef_scaled* 2^coef_exp+0.5) */
103 coef_man
= coef_scaled
+
104 (1 << (24 - coef_exp
- 1));
106 /* Calculate delta slope coefficient exponent
107 * and mantissa (remove scaling) and set them on hw */
108 ds_coef_man
= coef_man
>> (24 - coef_exp
);
109 ds_coef_exp
= coef_exp
- 16;
111 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_TIMING_3
,
112 AR5K_PHY_TIMING_3_DSC_MAN
, ds_coef_man
);
113 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_TIMING_3
,
114 AR5K_PHY_TIMING_3_DSC_EXP
, ds_coef_exp
);
121 * index into rates for control rates, we can set it up like this because
122 * this is only used for AR5212 and we know it supports G mode
124 static const unsigned int control_rates
[] =
125 { 0, 1, 1, 1, 4, 4, 6, 6, 8, 8, 8, 8 };
128 * ath5k_hw_write_rate_duration - fill rate code to duration table
130 * @ah: the &struct ath5k_hw
131 * @mode: one of enum ath5k_driver_mode
133 * Write the rate code to duration table upon hw reset. This is a helper for
134 * ath5k_hw_reset(). It seems all this is doing is setting an ACK timeout on
135 * the hardware, based on current mode, for each rate. The rates which are
136 * capable of short preamble (802.11b rates 2Mbps, 5.5Mbps, and 11Mbps) have
137 * different rate code so we write their value twice (one for long preample
138 * and one for short).
140 * Note: Band doesn't matter here, if we set the values for OFDM it works
141 * on both a and g modes. So all we have to do is set values for all g rates
142 * that include all OFDM and CCK rates. If we operate in turbo or xr/half/
143 * quarter rate mode, we need to use another set of bitrates (that's why we
144 * need the mode parameter) but we don't handle these proprietary modes yet.
146 static inline void ath5k_hw_write_rate_duration(struct ath5k_hw
*ah
,
149 struct ath5k_softc
*sc
= ah
->ah_sc
;
150 struct ieee80211_rate
*rate
;
153 /* Write rate duration table */
154 for (i
= 0; i
< sc
->sbands
[IEEE80211_BAND_2GHZ
].n_bitrates
; i
++) {
158 rate
= &sc
->sbands
[IEEE80211_BAND_2GHZ
].bitrates
[control_rates
[i
]];
160 /* Set ACK timeout */
161 reg
= AR5K_RATE_DUR(rate
->hw_value
);
163 /* An ACK frame consists of 10 bytes. If you add the FCS,
164 * which ieee80211_generic_frame_duration() adds,
165 * its 14 bytes. Note we use the control rate and not the
166 * actual rate for this rate. See mac80211 tx.c
167 * ieee80211_duration() for a brief description of
168 * what rate we should choose to TX ACKs. */
169 tx_time
= le16_to_cpu(ieee80211_generic_frame_duration(sc
->hw
,
172 ath5k_hw_reg_write(ah
, tx_time
, reg
);
174 if (!(rate
->flags
& IEEE80211_RATE_SHORT_PREAMBLE
))
178 * We're not distinguishing short preamble here,
179 * This is true, all we'll get is a longer value here
180 * which is not necessarilly bad. We could use
181 * export ieee80211_frame_duration() but that needs to be
182 * fixed first to be properly used by mac802111 drivers:
184 * - remove erp stuff and let the routine figure ofdm
186 * - remove passing argument ieee80211_local as
187 * drivers don't have access to it
188 * - move drivers using ieee80211_generic_frame_duration()
191 ath5k_hw_reg_write(ah
, tx_time
,
192 reg
+ (AR5K_SET_SHORT_PREAMBLE
<< 2));
199 static int ath5k_hw_nic_reset(struct ath5k_hw
*ah
, u32 val
)
202 u32 mask
= val
? val
: ~0U;
204 /* Read-and-clear RX Descriptor Pointer*/
205 ath5k_hw_reg_read(ah
, AR5K_RXDP
);
208 * Reset the device and wait until success
210 ath5k_hw_reg_write(ah
, val
, AR5K_RESET_CTL
);
212 /* Wait at least 128 PCI clocks */
215 if (ah
->ah_version
== AR5K_AR5210
) {
216 val
&= AR5K_RESET_CTL_PCU
| AR5K_RESET_CTL_DMA
217 | AR5K_RESET_CTL_MAC
| AR5K_RESET_CTL_PHY
;
218 mask
&= AR5K_RESET_CTL_PCU
| AR5K_RESET_CTL_DMA
219 | AR5K_RESET_CTL_MAC
| AR5K_RESET_CTL_PHY
;
221 val
&= AR5K_RESET_CTL_PCU
| AR5K_RESET_CTL_BASEBAND
;
222 mask
&= AR5K_RESET_CTL_PCU
| AR5K_RESET_CTL_BASEBAND
;
225 ret
= ath5k_hw_register_timeout(ah
, AR5K_RESET_CTL
, mask
, val
, false);
228 * Reset configuration register (for hw byte-swap). Note that this
229 * is only set for big endian. We do the necessary magic in
232 if ((val
& AR5K_RESET_CTL_PCU
) == 0)
233 ath5k_hw_reg_write(ah
, AR5K_INIT_CFG
, AR5K_CFG
);
241 static int ath5k_hw_set_power(struct ath5k_hw
*ah
, enum ath5k_power_mode mode
,
242 bool set_chip
, u16 sleep_duration
)
247 staid
= ath5k_hw_reg_read(ah
, AR5K_STA_ID1
);
251 staid
&= ~AR5K_STA_ID1_DEFAULT_ANTENNA
;
253 case AR5K_PM_NETWORK_SLEEP
:
255 ath5k_hw_reg_write(ah
,
256 AR5K_SLEEP_CTL_SLE_ALLOW
|
260 staid
|= AR5K_STA_ID1_PWR_SV
;
263 case AR5K_PM_FULL_SLEEP
:
265 ath5k_hw_reg_write(ah
, AR5K_SLEEP_CTL_SLE_SLP
,
268 staid
|= AR5K_STA_ID1_PWR_SV
;
273 staid
&= ~AR5K_STA_ID1_PWR_SV
;
278 data
= ath5k_hw_reg_read(ah
, AR5K_SLEEP_CTL
);
280 /* If card is down we 'll get 0xffff... so we
281 * need to clean this up before we write the register
283 if (data
& 0xffc00000)
286 /* Preserve sleep duration etc */
287 data
= data
& ~AR5K_SLEEP_CTL_SLE
;
289 ath5k_hw_reg_write(ah
, data
| AR5K_SLEEP_CTL_SLE_WAKE
,
293 for (i
= 200; i
> 0; i
--) {
294 /* Check if the chip did wake up */
295 if ((ath5k_hw_reg_read(ah
, AR5K_PCICFG
) &
296 AR5K_PCICFG_SPWR_DN
) == 0)
299 /* Wait a bit and retry */
301 ath5k_hw_reg_write(ah
, data
| AR5K_SLEEP_CTL_SLE_WAKE
,
305 /* Fail if the chip didn't wake up */
316 ath5k_hw_reg_write(ah
, staid
, AR5K_STA_ID1
);
324 * Put MAC and Baseband on warm reset and
325 * keep that state (don't clean sleep control
326 * register). After this MAC and Baseband are
327 * disabled and a full reset is needed to come
328 * back. This way we save as much power as possible
329 * without puting the card on full sleep.
331 int ath5k_hw_on_hold(struct ath5k_hw
*ah
)
333 struct pci_dev
*pdev
= ah
->ah_sc
->pdev
;
337 /* Make sure device is awake */
338 ret
= ath5k_hw_set_power(ah
, AR5K_PM_AWAKE
, true, 0);
340 ATH5K_ERR(ah
->ah_sc
, "failed to wakeup the MAC Chip\n");
345 * Put chipset on warm reset...
347 * Note: puting PCI core on warm reset on PCI-E cards
348 * results card to hang and always return 0xffff... so
349 * we ingore that flag for PCI-E cards. On PCI cards
350 * this flag gets cleared after 64 PCI clocks.
352 bus_flags
= (pdev
->is_pcie
) ? 0 : AR5K_RESET_CTL_PCI
;
354 if (ah
->ah_version
== AR5K_AR5210
) {
355 ret
= ath5k_hw_nic_reset(ah
, AR5K_RESET_CTL_PCU
|
356 AR5K_RESET_CTL_MAC
| AR5K_RESET_CTL_DMA
|
357 AR5K_RESET_CTL_PHY
| AR5K_RESET_CTL_PCI
);
360 ret
= ath5k_hw_nic_reset(ah
, AR5K_RESET_CTL_PCU
|
361 AR5K_RESET_CTL_BASEBAND
| bus_flags
);
365 ATH5K_ERR(ah
->ah_sc
, "failed to put device on warm reset\n");
369 /* ...wakeup again!*/
370 ret
= ath5k_hw_set_power(ah
, AR5K_PM_AWAKE
, true, 0);
372 ATH5K_ERR(ah
->ah_sc
, "failed to put device on hold\n");
380 * Bring up MAC + PHY Chips and program PLL
381 * TODO: Half/Quarter rate support
383 int ath5k_hw_nic_wakeup(struct ath5k_hw
*ah
, int flags
, bool initial
)
385 struct pci_dev
*pdev
= ah
->ah_sc
->pdev
;
386 u32 turbo
, mode
, clock
, bus_flags
;
393 /* Wakeup the device */
394 ret
= ath5k_hw_set_power(ah
, AR5K_PM_AWAKE
, true, 0);
396 ATH5K_ERR(ah
->ah_sc
, "failed to wakeup the MAC Chip\n");
401 * Put chipset on warm reset...
403 * Note: puting PCI core on warm reset on PCI-E cards
404 * results card to hang and always return 0xffff... so
405 * we ingore that flag for PCI-E cards. On PCI cards
406 * this flag gets cleared after 64 PCI clocks.
408 bus_flags
= (pdev
->is_pcie
) ? 0 : AR5K_RESET_CTL_PCI
;
410 if (ah
->ah_version
== AR5K_AR5210
) {
411 ret
= ath5k_hw_nic_reset(ah
, AR5K_RESET_CTL_PCU
|
412 AR5K_RESET_CTL_MAC
| AR5K_RESET_CTL_DMA
|
413 AR5K_RESET_CTL_PHY
| AR5K_RESET_CTL_PCI
);
416 ret
= ath5k_hw_nic_reset(ah
, AR5K_RESET_CTL_PCU
|
417 AR5K_RESET_CTL_BASEBAND
| bus_flags
);
421 ATH5K_ERR(ah
->ah_sc
, "failed to reset the MAC Chip\n");
425 /* ...wakeup again!...*/
426 ret
= ath5k_hw_set_power(ah
, AR5K_PM_AWAKE
, true, 0);
428 ATH5K_ERR(ah
->ah_sc
, "failed to resume the MAC Chip\n");
432 /* ...clear reset control register and pull device out of
434 if (ath5k_hw_nic_reset(ah
, 0)) {
435 ATH5K_ERR(ah
->ah_sc
, "failed to warm reset the MAC Chip\n");
439 /* On initialization skip PLL programming since we don't have
440 * a channel / mode set yet */
444 if (ah
->ah_version
!= AR5K_AR5210
) {
446 * Get channel mode flags
449 if (ah
->ah_radio
>= AR5K_RF5112
) {
450 mode
= AR5K_PHY_MODE_RAD_RF5112
;
451 clock
= AR5K_PHY_PLL_RF5112
;
453 mode
= AR5K_PHY_MODE_RAD_RF5111
; /*Zero*/
454 clock
= AR5K_PHY_PLL_RF5111
; /*Zero*/
457 if (flags
& CHANNEL_2GHZ
) {
458 mode
|= AR5K_PHY_MODE_FREQ_2GHZ
;
459 clock
|= AR5K_PHY_PLL_44MHZ
;
461 if (flags
& CHANNEL_CCK
) {
462 mode
|= AR5K_PHY_MODE_MOD_CCK
;
463 } else if (flags
& CHANNEL_OFDM
) {
464 if (ah
->ah_version
== AR5K_AR5211
)
465 mode
|= AR5K_PHY_MODE_MOD_OFDM
;
467 mode
|= AR5K_PHY_MODE_MOD_DYN
;
470 "invalid radio modulation mode\n");
473 } else if (flags
& CHANNEL_5GHZ
) {
474 mode
|= AR5K_PHY_MODE_FREQ_5GHZ
;
476 if (ah
->ah_radio
== AR5K_RF5413
)
477 clock
= AR5K_PHY_PLL_40MHZ_5413
;
479 clock
|= AR5K_PHY_PLL_40MHZ
;
481 if (flags
& CHANNEL_OFDM
)
482 mode
|= AR5K_PHY_MODE_MOD_OFDM
;
485 "invalid radio modulation mode\n");
489 ATH5K_ERR(ah
->ah_sc
, "invalid radio frequency mode\n");
493 if (flags
& CHANNEL_TURBO
)
494 turbo
= AR5K_PHY_TURBO_MODE
| AR5K_PHY_TURBO_SHORT
;
495 } else { /* Reset the device */
497 /* ...enable Atheros turbo mode if requested */
498 if (flags
& CHANNEL_TURBO
)
499 ath5k_hw_reg_write(ah
, AR5K_PHY_TURBO_MODE
,
503 if (ah
->ah_version
!= AR5K_AR5210
) {
505 /* ...update PLL if needed */
506 if (ath5k_hw_reg_read(ah
, AR5K_PHY_PLL
) != clock
) {
507 ath5k_hw_reg_write(ah
, clock
, AR5K_PHY_PLL
);
511 /* ...set the PHY operating mode */
512 ath5k_hw_reg_write(ah
, mode
, AR5K_PHY_MODE
);
513 ath5k_hw_reg_write(ah
, turbo
, AR5K_PHY_TURBO
);
519 static void ath5k_hw_set_sleep_clock(struct ath5k_hw
*ah
, bool enable
)
521 struct ath5k_eeprom_info
*ee
= &ah
->ah_capabilities
.cap_eeprom
;
522 u32 scal
, spending
, usec32
;
524 /* Only set 32KHz settings if we have an external
525 * 32KHz crystal present */
526 if ((AR5K_EEPROM_HAS32KHZCRYSTAL(ee
->ee_misc1
) ||
527 AR5K_EEPROM_HAS32KHZCRYSTAL_OLD(ee
->ee_misc1
)) &&
531 AR5K_REG_WRITE_BITS(ah
, AR5K_USEC_5211
, AR5K_USEC_32
, 1);
532 /* Set up tsf increment on each cycle */
533 AR5K_REG_WRITE_BITS(ah
, AR5K_TSF_PARM
, AR5K_TSF_PARM_INC
, 61);
535 /* Set baseband sleep control registers
536 * and sleep control rate */
537 ath5k_hw_reg_write(ah
, 0x1f, AR5K_PHY_SCR
);
539 if ((ah
->ah_radio
== AR5K_RF5112
) ||
540 (ah
->ah_radio
== AR5K_RF5413
) ||
541 (ah
->ah_mac_version
== (AR5K_SREV_AR2417
>> 4)))
545 ath5k_hw_reg_write(ah
, spending
, AR5K_PHY_SPENDING
);
547 if ((ah
->ah_radio
== AR5K_RF5112
) ||
548 (ah
->ah_radio
== AR5K_RF5413
) ||
549 (ah
->ah_mac_version
== (AR5K_SREV_AR2417
>> 4))) {
550 ath5k_hw_reg_write(ah
, 0x26, AR5K_PHY_SLMT
);
551 ath5k_hw_reg_write(ah
, 0x0d, AR5K_PHY_SCAL
);
552 ath5k_hw_reg_write(ah
, 0x07, AR5K_PHY_SCLOCK
);
553 ath5k_hw_reg_write(ah
, 0x3f, AR5K_PHY_SDELAY
);
554 AR5K_REG_WRITE_BITS(ah
, AR5K_PCICFG
,
555 AR5K_PCICFG_SLEEP_CLOCK_RATE
, 0x02);
557 ath5k_hw_reg_write(ah
, 0x0a, AR5K_PHY_SLMT
);
558 ath5k_hw_reg_write(ah
, 0x0c, AR5K_PHY_SCAL
);
559 ath5k_hw_reg_write(ah
, 0x03, AR5K_PHY_SCLOCK
);
560 ath5k_hw_reg_write(ah
, 0x20, AR5K_PHY_SDELAY
);
561 AR5K_REG_WRITE_BITS(ah
, AR5K_PCICFG
,
562 AR5K_PCICFG_SLEEP_CLOCK_RATE
, 0x03);
565 /* Enable sleep clock operation */
566 AR5K_REG_ENABLE_BITS(ah
, AR5K_PCICFG
,
567 AR5K_PCICFG_SLEEP_CLOCK_EN
);
571 /* Disable sleep clock operation and
572 * restore default parameters */
573 AR5K_REG_DISABLE_BITS(ah
, AR5K_PCICFG
,
574 AR5K_PCICFG_SLEEP_CLOCK_EN
);
576 AR5K_REG_WRITE_BITS(ah
, AR5K_PCICFG
,
577 AR5K_PCICFG_SLEEP_CLOCK_RATE
, 0);
579 ath5k_hw_reg_write(ah
, 0x1f, AR5K_PHY_SCR
);
580 ath5k_hw_reg_write(ah
, AR5K_PHY_SLMT_32MHZ
, AR5K_PHY_SLMT
);
582 if (ah
->ah_mac_version
== (AR5K_SREV_AR2417
>> 4))
583 scal
= AR5K_PHY_SCAL_32MHZ_2417
;
584 else if (ee
->ee_is_hb63
)
585 scal
= AR5K_PHY_SCAL_32MHZ_HB63
;
587 scal
= AR5K_PHY_SCAL_32MHZ
;
588 ath5k_hw_reg_write(ah
, scal
, AR5K_PHY_SCAL
);
590 ath5k_hw_reg_write(ah
, AR5K_PHY_SCLOCK_32MHZ
, AR5K_PHY_SCLOCK
);
591 ath5k_hw_reg_write(ah
, AR5K_PHY_SDELAY_32MHZ
, AR5K_PHY_SDELAY
);
593 if ((ah
->ah_radio
== AR5K_RF5112
) ||
594 (ah
->ah_radio
== AR5K_RF5413
) ||
595 (ah
->ah_mac_version
== (AR5K_SREV_AR2417
>> 4)))
599 ath5k_hw_reg_write(ah
, spending
, AR5K_PHY_SPENDING
);
601 if ((ah
->ah_radio
== AR5K_RF5112
) ||
602 (ah
->ah_radio
== AR5K_RF5413
))
606 AR5K_REG_WRITE_BITS(ah
, AR5K_USEC_5211
, AR5K_USEC_32
, usec32
);
608 AR5K_REG_WRITE_BITS(ah
, AR5K_TSF_PARM
, AR5K_TSF_PARM_INC
, 1);
612 /* TODO: Half/Quarter rate */
613 static void ath5k_hw_tweak_initval_settings(struct ath5k_hw
*ah
,
614 struct ieee80211_channel
*channel
)
616 if (ah
->ah_version
== AR5K_AR5212
&&
617 ah
->ah_phy_revision
>= AR5K_SREV_PHY_5212A
) {
619 /* Setup ADC control */
620 ath5k_hw_reg_write(ah
,
622 AR5K_PHY_ADC_CTL_INBUFGAIN_OFF
) |
624 AR5K_PHY_ADC_CTL_INBUFGAIN_ON
) |
625 AR5K_PHY_ADC_CTL_PWD_DAC_OFF
|
626 AR5K_PHY_ADC_CTL_PWD_ADC_OFF
),
631 /* Disable barker RSSI threshold */
632 AR5K_REG_DISABLE_BITS(ah
, AR5K_PHY_DAG_CCK_CTL
,
633 AR5K_PHY_DAG_CCK_CTL_EN_RSSI_THR
);
635 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_DAG_CCK_CTL
,
636 AR5K_PHY_DAG_CCK_CTL_RSSI_THR
, 2);
638 /* Set the mute mask */
639 ath5k_hw_reg_write(ah
, 0x0000000f, AR5K_SEQ_MASK
);
642 /* Clear PHY_BLUETOOTH to allow RX_CLEAR line debug */
643 if (ah
->ah_phy_revision
>= AR5K_SREV_PHY_5212B
)
644 ath5k_hw_reg_write(ah
, 0, AR5K_PHY_BLUETOOTH
);
646 /* Enable DCU double buffering */
647 if (ah
->ah_phy_revision
> AR5K_SREV_PHY_5212B
)
648 AR5K_REG_DISABLE_BITS(ah
, AR5K_TXCFG
,
649 AR5K_TXCFG_DCU_DBL_BUF_DIS
);
651 /* Set DAC/ADC delays */
652 if (ah
->ah_version
== AR5K_AR5212
) {
654 struct ath5k_eeprom_info
*ee
= &ah
->ah_capabilities
.cap_eeprom
;
655 if (ah
->ah_mac_version
== (AR5K_SREV_AR2417
>> 4))
656 scal
= AR5K_PHY_SCAL_32MHZ_2417
;
657 else if (ee
->ee_is_hb63
)
658 scal
= AR5K_PHY_SCAL_32MHZ_HB63
;
660 scal
= AR5K_PHY_SCAL_32MHZ
;
661 ath5k_hw_reg_write(ah
, scal
, AR5K_PHY_SCAL
);
665 if ((ah
->ah_radio
== AR5K_RF5413
) ||
666 (ah
->ah_mac_version
== (AR5K_SREV_AR2417
>> 4))) {
669 if (channel
->center_freq
== 2462 ||
670 channel
->center_freq
== 2467)
673 /* Only update if needed */
674 if (ath5k_hw_reg_read(ah
, AR5K_PHY_FAST_ADC
) != fast_adc
)
675 ath5k_hw_reg_write(ah
, fast_adc
,
679 /* Fix for first revision of the RF5112 RF chipset */
680 if (ah
->ah_radio
== AR5K_RF5112
&&
681 ah
->ah_radio_5ghz_revision
<
682 AR5K_SREV_RAD_5112A
) {
684 ath5k_hw_reg_write(ah
, AR5K_PHY_CCKTXCTL_WORLD
,
686 if (channel
->hw_value
& CHANNEL_5GHZ
)
690 ath5k_hw_reg_write(ah
, data
, AR5K_PHY_FRAME_CTL
);
693 if (ah
->ah_mac_srev
< AR5K_SREV_AR5211
) {
695 /* 5311 has different tx/rx latency masks
696 * from 5211, since we deal 5311 the same
697 * as 5211 when setting initvals, shift
698 * values here to their proper locations */
699 usec_reg
= ath5k_hw_reg_read(ah
, AR5K_USEC_5211
);
700 ath5k_hw_reg_write(ah
, usec_reg
& (AR5K_USEC_1
|
702 AR5K_USEC_TX_LATENCY_5211
|
704 AR5K_USEC_RX_LATENCY_5210
)),
706 /* Clear QCU/DCU clock gating register */
707 ath5k_hw_reg_write(ah
, 0, AR5K_QCUDCU_CLKGT
);
708 /* Set DAC/ADC delays */
709 ath5k_hw_reg_write(ah
, 0x08, AR5K_PHY_SCAL
);
710 /* Enable PCU FIFO corruption ECO */
711 AR5K_REG_ENABLE_BITS(ah
, AR5K_DIAG_SW_5211
,
712 AR5K_DIAG_SW_ECO_ENABLE
);
716 static void ath5k_hw_commit_eeprom_settings(struct ath5k_hw
*ah
,
717 struct ieee80211_channel
*channel
, u8 ee_mode
)
719 struct ath5k_eeprom_info
*ee
= &ah
->ah_capabilities
.cap_eeprom
;
720 s16 cck_ofdm_pwr_delta
;
722 /* Adjust power delta for channel 14 */
723 if (channel
->center_freq
== 2484)
725 ((ee
->ee_cck_ofdm_power_delta
-
726 ee
->ee_scaled_cck_delta
) * 2) / 10;
729 (ee
->ee_cck_ofdm_power_delta
* 2) / 10;
731 /* Set CCK to OFDM power delta on tx power
732 * adjustment register */
733 if (ah
->ah_phy_revision
>= AR5K_SREV_PHY_5212A
) {
734 if (channel
->hw_value
== CHANNEL_G
)
735 ath5k_hw_reg_write(ah
,
736 AR5K_REG_SM((ee
->ee_cck_ofdm_gain_delta
* -1),
737 AR5K_PHY_TX_PWR_ADJ_CCK_GAIN_DELTA
) |
738 AR5K_REG_SM((cck_ofdm_pwr_delta
* -1),
739 AR5K_PHY_TX_PWR_ADJ_CCK_PCDAC_INDEX
),
740 AR5K_PHY_TX_PWR_ADJ
);
742 ath5k_hw_reg_write(ah
, 0, AR5K_PHY_TX_PWR_ADJ
);
744 /* For older revs we scale power on sw during tx power
746 ah
->ah_txpower
.txp_cck_ofdm_pwr_delta
= cck_ofdm_pwr_delta
;
747 ah
->ah_txpower
.txp_cck_ofdm_gainf_delta
=
748 ee
->ee_cck_ofdm_gain_delta
;
751 ath5k_hw_set_antenna_switch(ah
, ee_mode
);
753 /* Noise floor threshold */
754 ath5k_hw_reg_write(ah
,
755 AR5K_PHY_NF_SVAL(ee
->ee_noise_floor_thr
[ee_mode
]),
758 if ((channel
->hw_value
& CHANNEL_TURBO
) &&
759 (ah
->ah_ee_version
>= AR5K_EEPROM_VERSION_5_0
)) {
760 /* Switch settling time (Turbo) */
761 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_SETTLING
,
762 AR5K_PHY_SETTLING_SWITCH
,
763 ee
->ee_switch_settling_turbo
[ee_mode
]);
765 /* Tx/Rx attenuation (Turbo) */
766 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_GAIN
,
767 AR5K_PHY_GAIN_TXRX_ATTEN
,
768 ee
->ee_atn_tx_rx_turbo
[ee_mode
]);
770 /* ADC/PGA desired size (Turbo) */
771 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_DESIRED_SIZE
,
772 AR5K_PHY_DESIRED_SIZE_ADC
,
773 ee
->ee_adc_desired_size_turbo
[ee_mode
]);
775 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_DESIRED_SIZE
,
776 AR5K_PHY_DESIRED_SIZE_PGA
,
777 ee
->ee_pga_desired_size_turbo
[ee_mode
]);
779 /* Tx/Rx margin (Turbo) */
780 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_GAIN_2GHZ
,
781 AR5K_PHY_GAIN_2GHZ_MARGIN_TXRX
,
782 ee
->ee_margin_tx_rx_turbo
[ee_mode
]);
785 /* Switch settling time */
786 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_SETTLING
,
787 AR5K_PHY_SETTLING_SWITCH
,
788 ee
->ee_switch_settling
[ee_mode
]);
790 /* Tx/Rx attenuation */
791 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_GAIN
,
792 AR5K_PHY_GAIN_TXRX_ATTEN
,
793 ee
->ee_atn_tx_rx
[ee_mode
]);
795 /* ADC/PGA desired size */
796 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_DESIRED_SIZE
,
797 AR5K_PHY_DESIRED_SIZE_ADC
,
798 ee
->ee_adc_desired_size
[ee_mode
]);
800 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_DESIRED_SIZE
,
801 AR5K_PHY_DESIRED_SIZE_PGA
,
802 ee
->ee_pga_desired_size
[ee_mode
]);
805 if (ah
->ah_ee_version
>= AR5K_EEPROM_VERSION_4_1
)
806 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_GAIN_2GHZ
,
807 AR5K_PHY_GAIN_2GHZ_MARGIN_TXRX
,
808 ee
->ee_margin_tx_rx
[ee_mode
]);
812 ath5k_hw_reg_write(ah
,
813 (ee
->ee_tx_end2xpa_disable
[ee_mode
] << 24) |
814 (ee
->ee_tx_end2xpa_disable
[ee_mode
] << 16) |
815 (ee
->ee_tx_frm2xpa_enable
[ee_mode
] << 8) |
816 (ee
->ee_tx_frm2xpa_enable
[ee_mode
]), AR5K_PHY_RF_CTL4
);
819 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_RF_CTL3
,
820 AR5K_PHY_RF_CTL3_TXE2XLNA_ON
,
821 ee
->ee_tx_end2xlna_enable
[ee_mode
]);
824 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_NF
,
825 AR5K_PHY_NF_THRESH62
,
826 ee
->ee_thr_62
[ee_mode
]);
828 /* False detect backoff for channels
829 * that have spur noise. Write the new
830 * cyclic power RSSI threshold. */
831 if (ath5k_hw_chan_has_spur_noise(ah
, channel
))
832 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_OFDM_SELFCORR
,
833 AR5K_PHY_OFDM_SELFCORR_CYPWR_THR1
,
834 AR5K_INIT_CYCRSSI_THR1
+
835 ee
->ee_false_detect
[ee_mode
]);
837 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_OFDM_SELFCORR
,
838 AR5K_PHY_OFDM_SELFCORR_CYPWR_THR1
,
839 AR5K_INIT_CYCRSSI_THR1
);
841 /* I/Q correction (set enable bit last to match HAL sources) */
842 /* TODO: Per channel i/q infos ? */
843 if (ah
->ah_ee_version
>= AR5K_EEPROM_VERSION_4_0
) {
844 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_IQ
, AR5K_PHY_IQ_CORR_Q_I_COFF
,
845 ee
->ee_i_cal
[ee_mode
]);
846 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_IQ
, AR5K_PHY_IQ_CORR_Q_Q_COFF
,
847 ee
->ee_q_cal
[ee_mode
]);
848 AR5K_REG_ENABLE_BITS(ah
, AR5K_PHY_IQ
, AR5K_PHY_IQ_CORR_ENABLE
);
851 /* Heavy clipping -disable for now */
852 if (ah
->ah_ee_version
>= AR5K_EEPROM_VERSION_5_1
)
853 ath5k_hw_reg_write(ah
, 0, AR5K_PHY_HEAVY_CLIP_ENABLE
);
857 * Main reset function
859 int ath5k_hw_reset(struct ath5k_hw
*ah
, enum nl80211_iftype op_mode
,
860 struct ieee80211_channel
*channel
, bool change_channel
)
862 struct ath_common
*common
= ath5k_hw_common(ah
);
863 u32 s_seq
[10], s_led
[3], staid1_flags
, tsf_up
, tsf_lo
;
865 u8 mode
, freq
, ee_mode
;
876 * Save some registers before a reset
878 /*DCU/Antenna selection not available on 5210*/
879 if (ah
->ah_version
!= AR5K_AR5210
) {
881 switch (channel
->hw_value
& CHANNEL_MODES
) {
883 mode
= AR5K_MODE_11A
;
884 freq
= AR5K_INI_RFGAIN_5GHZ
;
885 ee_mode
= AR5K_EEPROM_MODE_11A
;
888 mode
= AR5K_MODE_11G
;
889 freq
= AR5K_INI_RFGAIN_2GHZ
;
890 ee_mode
= AR5K_EEPROM_MODE_11G
;
893 mode
= AR5K_MODE_11B
;
894 freq
= AR5K_INI_RFGAIN_2GHZ
;
895 ee_mode
= AR5K_EEPROM_MODE_11B
;
898 mode
= AR5K_MODE_11A_TURBO
;
899 freq
= AR5K_INI_RFGAIN_5GHZ
;
900 ee_mode
= AR5K_EEPROM_MODE_11A
;
903 if (ah
->ah_version
== AR5K_AR5211
) {
905 "TurboG mode not available on 5211");
908 mode
= AR5K_MODE_11G_TURBO
;
909 freq
= AR5K_INI_RFGAIN_2GHZ
;
910 ee_mode
= AR5K_EEPROM_MODE_11G
;
913 if (ah
->ah_version
== AR5K_AR5211
) {
915 "XR mode not available on 5211");
919 freq
= AR5K_INI_RFGAIN_5GHZ
;
920 ee_mode
= AR5K_EEPROM_MODE_11A
;
924 "invalid channel: %d\n", channel
->center_freq
);
928 if (change_channel
) {
930 * Save frame sequence count
931 * For revs. after Oahu, only save
932 * seq num for DCU 0 (Global seq num)
934 if (ah
->ah_mac_srev
< AR5K_SREV_AR5211
) {
936 for (i
= 0; i
< 10; i
++)
937 s_seq
[i
] = ath5k_hw_reg_read(ah
,
938 AR5K_QUEUE_DCU_SEQNUM(i
));
941 s_seq
[0] = ath5k_hw_reg_read(ah
,
942 AR5K_QUEUE_DCU_SEQNUM(0));
945 if (ah
->ah_version
== AR5K_AR5211
) {
946 tsf_up
= ath5k_hw_reg_read(ah
, AR5K_TSF_U32
);
947 tsf_lo
= ath5k_hw_reg_read(ah
, AR5K_TSF_L32
);
951 if (ah
->ah_version
== AR5K_AR5212
) {
952 /* Restore normal 32/40MHz clock operation
953 * to avoid register access delay on certain
955 ath5k_hw_set_sleep_clock(ah
, false);
957 /* Since we are going to write rf buffer
958 * check if we have any pending gain_F
959 * optimization settings */
960 if (change_channel
&& ah
->ah_rf_banks
!= NULL
)
961 ath5k_hw_gainf_calibrate(ah
);
966 s_led
[0] = ath5k_hw_reg_read(ah
, AR5K_PCICFG
) &
967 AR5K_PCICFG_LEDSTATE
;
968 s_led
[1] = ath5k_hw_reg_read(ah
, AR5K_GPIOCR
);
969 s_led
[2] = ath5k_hw_reg_read(ah
, AR5K_GPIODO
);
971 /* AR5K_STA_ID1 flags, only preserve antenna
972 * settings and ack/cts rate mode */
973 staid1_flags
= ath5k_hw_reg_read(ah
, AR5K_STA_ID1
) &
974 (AR5K_STA_ID1_DEFAULT_ANTENNA
|
975 AR5K_STA_ID1_DESC_ANTENNA
|
976 AR5K_STA_ID1_RTS_DEF_ANTENNA
|
977 AR5K_STA_ID1_ACKCTS_6MB
|
978 AR5K_STA_ID1_BASE_RATE_11B
|
979 AR5K_STA_ID1_SELFGEN_DEF_ANT
);
981 /* Wakeup the device */
982 ret
= ath5k_hw_nic_wakeup(ah
, channel
->hw_value
, false);
986 /* PHY access enable */
987 if (ah
->ah_mac_srev
>= AR5K_SREV_AR5211
)
988 ath5k_hw_reg_write(ah
, AR5K_PHY_SHIFT_5GHZ
, AR5K_PHY(0));
990 ath5k_hw_reg_write(ah
, AR5K_PHY_SHIFT_5GHZ
| 0x40,
993 /* Write initial settings */
994 ret
= ath5k_hw_write_initvals(ah
, mode
, change_channel
);
1001 if (ah
->ah_version
!= AR5K_AR5210
) {
1004 * Write initial RF gain settings
1005 * This should work for both 5111/5112
1007 ret
= ath5k_hw_rfgain_init(ah
, freq
);
1014 * Tweak initval settings for revised
1015 * chipsets and add some more config
1018 ath5k_hw_tweak_initval_settings(ah
, channel
);
1023 ret
= ath5k_hw_txpower(ah
, channel
, ee_mode
,
1024 ah
->ah_txpower
.txp_max_pwr
/ 2);
1028 if (ah
->ah_version
== AR5K_AR5212
&&
1029 ah
->ah_sc
->vif
!= NULL
)
1030 ath5k_hw_write_rate_duration(ah
, mode
);
1035 ret
= ath5k_hw_rfregs_init(ah
, channel
, mode
);
1040 /* Write OFDM timings on 5212*/
1041 if (ah
->ah_version
== AR5K_AR5212
&&
1042 channel
->hw_value
& CHANNEL_OFDM
) {
1044 ret
= ath5k_hw_write_ofdm_timings(ah
, channel
);
1048 /* Spur info is available only from EEPROM versions
1049 * bigger than 5.3 but but the EEPOM routines will use
1050 * static values for older versions */
1051 if (ah
->ah_mac_srev
>= AR5K_SREV_AR5424
)
1052 ath5k_hw_set_spur_mitigation_filter(ah
,
1056 /*Enable/disable 802.11b mode on 5111
1057 (enable 2111 frequency converter + CCK)*/
1058 if (ah
->ah_radio
== AR5K_RF5111
) {
1059 if (mode
== AR5K_MODE_11B
)
1060 AR5K_REG_ENABLE_BITS(ah
, AR5K_TXCFG
,
1063 AR5K_REG_DISABLE_BITS(ah
, AR5K_TXCFG
,
1067 /* Commit values from EEPROM */
1068 ath5k_hw_commit_eeprom_settings(ah
, channel
, ee_mode
);
1072 * For 5210 we do all initialization using
1073 * initvals, so we don't have to modify
1074 * any settings (5210 also only supports
1078 /* Disable phy and wait */
1079 ath5k_hw_reg_write(ah
, AR5K_PHY_ACT_DISABLE
, AR5K_PHY_ACT
);
1084 * Restore saved values
1087 /*DCU/Antenna selection not available on 5210*/
1088 if (ah
->ah_version
!= AR5K_AR5210
) {
1090 if (change_channel
) {
1091 if (ah
->ah_mac_srev
< AR5K_SREV_AR5211
) {
1092 for (i
= 0; i
< 10; i
++)
1093 ath5k_hw_reg_write(ah
, s_seq
[i
],
1094 AR5K_QUEUE_DCU_SEQNUM(i
));
1096 ath5k_hw_reg_write(ah
, s_seq
[0],
1097 AR5K_QUEUE_DCU_SEQNUM(0));
1101 if (ah
->ah_version
== AR5K_AR5211
) {
1102 ath5k_hw_reg_write(ah
, tsf_up
, AR5K_TSF_U32
);
1103 ath5k_hw_reg_write(ah
, tsf_lo
, AR5K_TSF_L32
);
1109 AR5K_REG_ENABLE_BITS(ah
, AR5K_PCICFG
, s_led
[0]);
1112 ath5k_hw_reg_write(ah
, s_led
[1], AR5K_GPIOCR
);
1113 ath5k_hw_reg_write(ah
, s_led
[2], AR5K_GPIODO
);
1115 /* Restore sta_id flags and preserve our mac address*/
1116 ath5k_hw_reg_write(ah
,
1117 get_unaligned_le32(common
->macaddr
),
1119 ath5k_hw_reg_write(ah
,
1120 staid1_flags
| get_unaligned_le16(common
->macaddr
+ 4),
1128 /* Restore bssid and bssid mask */
1129 ath5k_hw_set_associd(ah
);
1131 /* Set PCU config */
1132 ath5k_hw_set_opmode(ah
, op_mode
);
1134 /* Clear any pending interrupts
1135 * PISR/SISR Not available on 5210 */
1136 if (ah
->ah_version
!= AR5K_AR5210
)
1137 ath5k_hw_reg_write(ah
, 0xffffffff, AR5K_PISR
);
1139 /* Set RSSI/BRSSI thresholds
1141 * Note: If we decide to set this value
1142 * dynamicaly, have in mind that when AR5K_RSSI_THR
1143 * register is read it might return 0x40 if we haven't
1144 * wrote anything to it plus BMISS RSSI threshold is zeroed.
1145 * So doing a save/restore procedure here isn't the right
1146 * choice. Instead store it on ath5k_hw */
1147 ath5k_hw_reg_write(ah
, (AR5K_TUNE_RSSI_THRES
|
1148 AR5K_TUNE_BMISS_THRES
<<
1149 AR5K_RSSI_THR_BMISS_S
),
1152 /* MIC QoS support */
1153 if (ah
->ah_mac_srev
>= AR5K_SREV_AR2413
) {
1154 ath5k_hw_reg_write(ah
, 0x000100aa, AR5K_MIC_QOS_CTL
);
1155 ath5k_hw_reg_write(ah
, 0x00003210, AR5K_MIC_QOS_SEL
);
1158 /* QoS NOACK Policy */
1159 if (ah
->ah_version
== AR5K_AR5212
) {
1160 ath5k_hw_reg_write(ah
,
1161 AR5K_REG_SM(2, AR5K_QOS_NOACK_2BIT_VALUES
) |
1162 AR5K_REG_SM(5, AR5K_QOS_NOACK_BIT_OFFSET
) |
1163 AR5K_REG_SM(0, AR5K_QOS_NOACK_BYTE_OFFSET
),
1172 /* Set channel on PHY */
1173 ret
= ath5k_hw_channel(ah
, channel
);
1178 * Enable the PHY and wait until completion
1179 * This includes BaseBand and Synthesizer
1182 ath5k_hw_reg_write(ah
, AR5K_PHY_ACT_ENABLE
, AR5K_PHY_ACT
);
1185 * On 5211+ read activation -> rx delay
1188 * TODO: Half/quarter rate support
1190 if (ah
->ah_version
!= AR5K_AR5210
) {
1192 delay
= ath5k_hw_reg_read(ah
, AR5K_PHY_RX_DELAY
) &
1193 AR5K_PHY_RX_DELAY_M
;
1194 delay
= (channel
->hw_value
& CHANNEL_CCK
) ?
1195 ((delay
<< 2) / 22) : (delay
/ 10);
1197 udelay(100 + (2 * delay
));
1203 * Perform ADC test to see if baseband is ready
1204 * Set tx hold and check adc test register
1206 phy_tst1
= ath5k_hw_reg_read(ah
, AR5K_PHY_TST1
);
1207 ath5k_hw_reg_write(ah
, AR5K_PHY_TST1_TXHOLD
, AR5K_PHY_TST1
);
1208 for (i
= 0; i
<= 20; i
++) {
1209 if (!(ath5k_hw_reg_read(ah
, AR5K_PHY_ADC_TEST
) & 0x10))
1213 ath5k_hw_reg_write(ah
, phy_tst1
, AR5K_PHY_TST1
);
1216 * Start automatic gain control calibration
1218 * During AGC calibration RX path is re-routed to
1219 * a power detector so we don't receive anything.
1221 * This method is used to calibrate some static offsets
1222 * used together with on-the fly I/Q calibration (the
1223 * one performed via ath5k_hw_phy_calibrate), that doesn't
1224 * interrupt rx path.
1226 * While rx path is re-routed to the power detector we also
1227 * start a noise floor calibration, to measure the
1228 * card's noise floor (the noise we measure when we are not
1229 * transmiting or receiving anything).
1231 * If we are in a noisy environment AGC calibration may time
1232 * out and/or noise floor calibration might timeout.
1234 AR5K_REG_ENABLE_BITS(ah
, AR5K_PHY_AGCCTL
,
1235 AR5K_PHY_AGCCTL_CAL
| AR5K_PHY_AGCCTL_NF
);
1237 /* At the same time start I/Q calibration for QAM constellation
1238 * -no need for CCK- */
1239 ah
->ah_calibration
= false;
1240 if (!(mode
== AR5K_MODE_11B
)) {
1241 ah
->ah_calibration
= true;
1242 AR5K_REG_WRITE_BITS(ah
, AR5K_PHY_IQ
,
1243 AR5K_PHY_IQ_CAL_NUM_LOG_MAX
, 15);
1244 AR5K_REG_ENABLE_BITS(ah
, AR5K_PHY_IQ
,
1248 /* Wait for gain calibration to finish (we check for I/Q calibration
1249 * during ath5k_phy_calibrate) */
1250 if (ath5k_hw_register_timeout(ah
, AR5K_PHY_AGCCTL
,
1251 AR5K_PHY_AGCCTL_CAL
, 0, false)) {
1252 ATH5K_ERR(ah
->ah_sc
, "gain calibration timeout (%uMHz)\n",
1253 channel
->center_freq
);
1256 /* Restore antenna mode */
1257 ath5k_hw_set_antenna_mode(ah
, ah
->ah_ant_mode
);
1259 /* Restore slot time and ACK timeouts */
1260 if (ah
->ah_coverage_class
> 0)
1261 ath5k_hw_set_coverage_class(ah
, ah
->ah_coverage_class
);
1264 * Configure QCUs/DCUs
1267 /* TODO: HW Compression support for data queues */
1268 /* TODO: Burst prefetch for data queues */
1271 * Reset queues and start beacon timers at the end of the reset routine
1272 * This also sets QCU mask on each DCU for 1:1 qcu to dcu mapping
1273 * Note: If we want we can assign multiple qcus on one dcu.
1275 for (i
= 0; i
< ah
->ah_capabilities
.cap_queues
.q_tx_num
; i
++) {
1276 ret
= ath5k_hw_reset_tx_queue(ah
, i
);
1278 ATH5K_ERR(ah
->ah_sc
,
1279 "failed to reset TX queue #%d\n", i
);
1286 * Configure DMA/Interrupts
1289 if (ah
->ah_version
!= AR5K_AR5210
) {
1290 AR5K_REG_WRITE_BITS(ah
, AR5K_TXCFG
,
1291 AR5K_TXCFG_SDMAMR
, AR5K_DMASIZE_128B
);
1292 AR5K_REG_WRITE_BITS(ah
, AR5K_RXCFG
,
1293 AR5K_RXCFG_SDMAMW
, AR5K_DMASIZE_128B
);
1296 /* Pre-enable interrupts on 5211/5212*/
1297 if (ah
->ah_version
!= AR5K_AR5210
)
1298 ath5k_hw_set_imr(ah
, ah
->ah_imr
);
1300 /* Enable 32KHz clock function for AR5212+ chips
1301 * Set clocks to 32KHz operation and use an
1302 * external 32KHz crystal when sleeping if one
1304 if (ah
->ah_version
== AR5K_AR5212
&&
1305 op_mode
!= NL80211_IFTYPE_AP
)
1306 ath5k_hw_set_sleep_clock(ah
, true);
1309 * Disable beacons and reset the TSF
1311 AR5K_REG_DISABLE_BITS(ah
, AR5K_BEACON
, AR5K_BEACON_ENABLE
);
1312 ath5k_hw_reset_tsf(ah
);