2 * Copyright (c) 2008-2011 Atheros Communications Inc.
4 * Modified for iPXE by Scott K Logan <logans@cottsay.net> July 2011
5 * Original from Linux kernel 3.0.1
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #include <ipxe/vsprintf.h>
25 #include "ar9003_mac.h"
27 static int ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type);
29 /* Private hardware callbacks */
31 static void ath9k_hw_init_cal_settings(struct ath_hw *ah)
33 ath9k_hw_private_ops(ah)->init_cal_settings(ah);
36 static void ath9k_hw_init_mode_regs(struct ath_hw *ah)
38 ath9k_hw_private_ops(ah)->init_mode_regs(ah);
41 static u32 ath9k_hw_compute_pll_control(struct ath_hw *ah,
42 struct ath9k_channel *chan)
44 return ath9k_hw_private_ops(ah)->compute_pll_control(ah, chan);
47 static void ath9k_hw_init_mode_gain_regs(struct ath_hw *ah)
49 if (!ath9k_hw_private_ops(ah)->init_mode_gain_regs)
52 ath9k_hw_private_ops(ah)->init_mode_gain_regs(ah);
55 static void ath9k_hw_ani_cache_ini_regs(struct ath_hw *ah)
57 /* You will not have this callback if using the old ANI */
58 if (!ath9k_hw_private_ops(ah)->ani_cache_ini_regs)
61 ath9k_hw_private_ops(ah)->ani_cache_ini_regs(ah);
64 /********************/
65 /* Helper Functions */
66 /********************/
68 static void ath9k_hw_set_clockrate(struct ath_hw *ah)
70 struct ath_common *common = ath9k_hw_common(ah);
71 struct net80211_device *dev = common->dev;
72 unsigned int clockrate;
74 if (!ah->curchan) /* should really check for CCK instead */
75 clockrate = ATH9K_CLOCK_RATE_CCK;
76 else if ((dev->channels + dev->channel)->band == NET80211_BAND_2GHZ)
77 clockrate = ATH9K_CLOCK_RATE_2GHZ_OFDM;
78 else if (ah->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK)
79 clockrate = ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM;
81 clockrate = ATH9K_CLOCK_RATE_5GHZ_OFDM;
83 common->clockrate = clockrate;
86 static u32 ath9k_hw_mac_to_clks(struct ath_hw *ah, u32 usecs)
88 struct ath_common *common = ath9k_hw_common(ah);
90 return usecs * common->clockrate;
93 int ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout)
97 for (i = 0; i < (timeout / AH_TIME_QUANTUM); i++) {
98 if ((REG_READ(ah, reg) & mask) == val)
101 udelay(AH_TIME_QUANTUM);
105 "timeout (%d us) on reg 0x%x: 0x%08x & 0x%08x != 0x%08x\n",
106 timeout, reg, REG_READ(ah, reg), mask, val);
111 void ath9k_hw_write_array(struct ath_hw *ah, struct ar5416IniArray *array,
112 int column, unsigned int *writecnt)
116 ENABLE_REGWRITE_BUFFER(ah);
117 for (r = 0; r < array->ia_rows; r++) {
118 REG_WRITE(ah, INI_RA(array, r, 0),
119 INI_RA(array, r, column));
122 REGWRITE_BUFFER_FLUSH(ah);
125 u32 ath9k_hw_reverse_bits(u32 val, u32 n)
130 for (i = 0, retval = 0; i < n; i++) {
131 retval = (retval << 1) | (val & 1);
137 u16 ath9k_hw_computetxtime(struct ath_hw *ah,
139 u32 frameLen, u16 rateix,
142 u32 bitsPerSymbol, numBits, numSymbols, phyTime, txTime;
149 phyTime = CCK_PREAMBLE_BITS + CCK_PLCP_BITS;
152 numBits = frameLen << 3;
153 txTime = CCK_SIFS_TIME + phyTime + ((numBits * 1000) / kbps);
156 if (ah->curchan && IS_CHAN_QUARTER_RATE(ah->curchan)) {
157 bitsPerSymbol = (kbps * OFDM_SYMBOL_TIME_QUARTER) / 1000;
158 numBits = OFDM_PLCP_BITS + (frameLen << 3);
159 numSymbols = DIV_ROUND_UP(numBits, bitsPerSymbol);
160 txTime = OFDM_SIFS_TIME_QUARTER
161 + OFDM_PREAMBLE_TIME_QUARTER
162 + (numSymbols * OFDM_SYMBOL_TIME_QUARTER);
163 } else if (ah->curchan &&
164 IS_CHAN_HALF_RATE(ah->curchan)) {
165 bitsPerSymbol = (kbps * OFDM_SYMBOL_TIME_HALF) / 1000;
166 numBits = OFDM_PLCP_BITS + (frameLen << 3);
167 numSymbols = DIV_ROUND_UP(numBits, bitsPerSymbol);
168 txTime = OFDM_SIFS_TIME_HALF +
169 OFDM_PREAMBLE_TIME_HALF
170 + (numSymbols * OFDM_SYMBOL_TIME_HALF);
172 bitsPerSymbol = (kbps * OFDM_SYMBOL_TIME) / 1000;
173 numBits = OFDM_PLCP_BITS + (frameLen << 3);
174 numSymbols = DIV_ROUND_UP(numBits, bitsPerSymbol);
175 txTime = OFDM_SIFS_TIME + OFDM_PREAMBLE_TIME
176 + (numSymbols * OFDM_SYMBOL_TIME);
181 "Unknown phy %d (rate ix %d)\n", phy, rateix);
189 void ath9k_hw_get_channel_centers(struct ath_hw *ah __unused,
190 struct ath9k_channel *chan,
191 struct chan_centers *centers)
195 if (!IS_CHAN_HT40(chan)) {
196 centers->ctl_center = centers->ext_center =
197 centers->synth_center = chan->channel;
201 if ((chan->chanmode == CHANNEL_A_HT40PLUS) ||
202 (chan->chanmode == CHANNEL_G_HT40PLUS)) {
203 centers->synth_center =
204 chan->channel + HT40_CHANNEL_CENTER_SHIFT;
207 centers->synth_center =
208 chan->channel - HT40_CHANNEL_CENTER_SHIFT;
212 centers->ctl_center =
213 centers->synth_center - (extoff * HT40_CHANNEL_CENTER_SHIFT);
214 /* 25 MHz spacing is supported by hw but not on upper layers */
215 centers->ext_center =
216 centers->synth_center + (extoff * HT40_CHANNEL_CENTER_SHIFT);
223 static void ath9k_hw_read_revisions(struct ath_hw *ah)
227 switch (ah->hw_version.devid) {
228 case AR5416_AR9100_DEVID:
229 ah->hw_version.macVersion = AR_SREV_VERSION_9100;
231 case AR9300_DEVID_AR9340:
232 ah->hw_version.macVersion = AR_SREV_VERSION_9340;
233 val = REG_READ(ah, AR_SREV);
234 ah->hw_version.macRev = MS(val, AR_SREV_REVISION2);
238 val = REG_READ(ah, AR_SREV) & AR_SREV_ID;
241 val = REG_READ(ah, AR_SREV);
242 ah->hw_version.macVersion =
243 (val & AR_SREV_VERSION2) >> AR_SREV_TYPE2_S;
244 ah->hw_version.macRev = MS(val, AR_SREV_REVISION2);
245 ah->is_pciexpress = (val & AR_SREV_TYPE2_HOST_MODE) ? 0 : 1;
247 if (!AR_SREV_9100(ah))
248 ah->hw_version.macVersion = MS(val, AR_SREV_VERSION);
250 ah->hw_version.macRev = val & AR_SREV_REVISION;
252 if (ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCIE)
253 ah->is_pciexpress = 1;
257 /************************************/
258 /* HW Attach, Detach, Init Routines */
259 /************************************/
261 static void ath9k_hw_disablepcie(struct ath_hw *ah)
263 if (!AR_SREV_5416(ah))
266 REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00);
267 REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);
268 REG_WRITE(ah, AR_PCIE_SERDES, 0x28000029);
269 REG_WRITE(ah, AR_PCIE_SERDES, 0x57160824);
270 REG_WRITE(ah, AR_PCIE_SERDES, 0x25980579);
271 REG_WRITE(ah, AR_PCIE_SERDES, 0x00000000);
272 REG_WRITE(ah, AR_PCIE_SERDES, 0x1aaabe40);
273 REG_WRITE(ah, AR_PCIE_SERDES, 0xbe105554);
274 REG_WRITE(ah, AR_PCIE_SERDES, 0x000e1007);
276 REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
279 /* This should work for all families including legacy */
280 static int ath9k_hw_chip_test(struct ath_hw *ah)
282 u32 regAddr[2] = { AR_STA_ID0 };
284 static const u32 patternData[4] = {
285 0x55555555, 0xaaaaaaaa, 0x66666666, 0x99999999
289 if (!AR_SREV_9300_20_OR_LATER(ah)) {
291 regAddr[1] = AR_PHY_BASE + (8 << 2);
295 for (i = 0; i < loop_max; i++) {
296 u32 addr = regAddr[i];
299 regHold[i] = REG_READ(ah, addr);
300 for (j = 0; j < 0x100; j++) {
301 wrData = (j << 16) | j;
302 REG_WRITE(ah, addr, wrData);
303 rdData = REG_READ(ah, addr);
304 if (rdData != wrData) {
306 "address test failed addr: 0x%08x - wr:0x%08x != rd:0x%08x\n",
307 addr, wrData, rdData);
311 for (j = 0; j < 4; j++) {
312 wrData = patternData[j];
313 REG_WRITE(ah, addr, wrData);
314 rdData = REG_READ(ah, addr);
315 if (wrData != rdData) {
317 "address test failed addr: 0x%08x - wr:0x%08x != rd:0x%08x\n",
318 addr, wrData, rdData);
322 REG_WRITE(ah, regAddr[i], regHold[i]);
329 static void ath9k_hw_init_config(struct ath_hw *ah)
333 ah->config.dma_beacon_response_time = 2;
334 ah->config.sw_beacon_response_time = 10;
335 ah->config.additional_swba_backoff = 0;
336 ah->config.ack_6mb = 0x0;
337 ah->config.cwm_ignore_extcca = 0;
338 ah->config.pcie_powersave_enable = 0;
339 ah->config.pcie_clock_req = 0;
340 ah->config.pcie_waen = 0;
341 ah->config.analog_shiftreg = 1;
342 ah->config.enable_ani = 1;
344 for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
345 ah->config.spurchans[i][0] = AR_NO_SPUR;
346 ah->config.spurchans[i][1] = AR_NO_SPUR;
349 /* PAPRD needs some more work to be enabled */
350 ah->config.paprd_disable = 1;
352 ah->config.rx_intr_mitigation = 1;
353 ah->config.pcieSerDesWrite = 1;
356 static void ath9k_hw_init_defaults(struct ath_hw *ah)
358 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
360 regulatory->country_code = CTRY_DEFAULT;
361 regulatory->power_limit = MAX_RATE_POWER;
362 regulatory->tp_scale = ATH9K_TP_SCALE_MAX;
364 ah->hw_version.magic = AR5416_MAGIC;
365 ah->hw_version.subvendorid = 0;
368 ah->sta_id1_defaults =
369 AR_STA_ID1_CRPT_MIC_ENABLE |
370 AR_STA_ID1_MCAST_KSRCH;
371 if (AR_SREV_9100(ah))
372 ah->sta_id1_defaults |= AR_STA_ID1_AR9100_BA_FIX;
373 ah->enable_32kHz_clock = DONT_USE_32KHZ;
375 ah->globaltxtimeout = (u32) -1;
376 ah->power_mode = ATH9K_PM_UNDEFINED;
379 static int ath9k_hw_init_macaddr(struct ath_hw *ah)
381 struct ath_common *common = ath9k_hw_common(ah);
385 static const u32 EEP_MAC[] = { EEP_MAC_LSW, EEP_MAC_MID, EEP_MAC_MSW };
388 for (i = 0; i < 3; i++) {
389 eeval = ah->eep_ops->get_eeprom(ah, EEP_MAC[i]);
391 common->macaddr[2 * i] = eeval >> 8;
392 common->macaddr[2 * i + 1] = eeval & 0xff;
394 if (sum == 0 || sum == 0xffff * 3)
395 return -EADDRNOTAVAIL;
400 static int ath9k_hw_post_init(struct ath_hw *ah)
402 struct ath_common *common = ath9k_hw_common(ah);
405 if (common->bus_ops->ath_bus_type != ATH_USB) {
406 if (!ath9k_hw_chip_test(ah))
410 if (!AR_SREV_9300_20_OR_LATER(ah)) {
411 ecode = ar9002_hw_rf_claim(ah);
416 ecode = ath9k_hw_eeprom_init(ah);
421 "Eeprom VER: %d, REV: %d\n",
422 ah->eep_ops->get_eeprom_ver(ah),
423 ah->eep_ops->get_eeprom_rev(ah));
425 ecode = ath9k_hw_rf_alloc_ext_banks(ah);
428 "Failed allocating banks for external radio\n");
429 ath9k_hw_rf_free_ext_banks(ah);
433 if (!AR_SREV_9100(ah) && !AR_SREV_9340(ah)) {
434 ath9k_hw_ani_setup(ah);
435 ath9k_hw_ani_init(ah);
441 static void ath9k_hw_attach_ops(struct ath_hw *ah)
443 if (AR_SREV_9300_20_OR_LATER(ah))
444 ar9003_hw_attach_ops(ah);
446 ar9002_hw_attach_ops(ah);
449 /* Called for all hardware families */
450 static int __ath9k_hw_init(struct ath_hw *ah)
452 struct ath_common *common = ath9k_hw_common(ah);
455 ath9k_hw_read_revisions(ah);
458 * Read back AR_WA into a permanent copy and set bits 14 and 17.
459 * We need to do this to avoid RMW of this register. We cannot
460 * read the reg when chip is asleep.
462 ah->WARegVal = REG_READ(ah, AR_WA);
463 ah->WARegVal |= (AR_WA_D3_L1_DISABLE |
464 AR_WA_ASPM_TIMER_BASED_DISABLE);
466 if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON)) {
467 DBG("ath9k: Couldn't reset chip\n");
471 ath9k_hw_init_defaults(ah);
472 ath9k_hw_init_config(ah);
474 ath9k_hw_attach_ops(ah);
476 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) {
477 DBG("ath9k: Couldn't wakeup chip\n");
481 if (ah->config.serialize_regmode == SER_REG_MODE_AUTO) {
482 if (ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCI ||
483 ((AR_SREV_9160(ah) || AR_SREV_9280(ah)) &&
484 !ah->is_pciexpress)) {
485 ah->config.serialize_regmode =
488 ah->config.serialize_regmode =
493 DBG2("ath9k: serialize_regmode is %d\n",
494 ah->config.serialize_regmode);
496 if (AR_SREV_9285(ah) || AR_SREV_9271(ah))
497 ah->config.max_txtrig_level = MAX_TX_FIFO_THRESHOLD >> 1;
499 ah->config.max_txtrig_level = MAX_TX_FIFO_THRESHOLD;
501 switch (ah->hw_version.macVersion) {
502 case AR_SREV_VERSION_5416_PCI:
503 case AR_SREV_VERSION_5416_PCIE:
504 case AR_SREV_VERSION_9160:
505 case AR_SREV_VERSION_9100:
506 case AR_SREV_VERSION_9280:
507 case AR_SREV_VERSION_9285:
508 case AR_SREV_VERSION_9287:
509 case AR_SREV_VERSION_9271:
510 case AR_SREV_VERSION_9300:
511 case AR_SREV_VERSION_9485:
512 case AR_SREV_VERSION_9340:
516 "Mac Chip Rev 0x%02x.%x is not supported by this driver\n",
517 ah->hw_version.macVersion, ah->hw_version.macRev);
521 if (AR_SREV_9271(ah) || AR_SREV_9100(ah) || AR_SREV_9340(ah))
522 ah->is_pciexpress = 0;
524 ah->hw_version.phyRev = REG_READ(ah, AR_PHY_CHIP_ID);
525 ath9k_hw_init_cal_settings(ah);
527 ah->ani_function = ATH9K_ANI_ALL;
528 if (AR_SREV_9280_20_OR_LATER(ah) && !AR_SREV_9300_20_OR_LATER(ah))
529 ah->ani_function &= ~ATH9K_ANI_NOISE_IMMUNITY_LEVEL;
530 if (!AR_SREV_9300_20_OR_LATER(ah))
531 ah->ani_function &= ~ATH9K_ANI_MRC_CCK;
533 ath9k_hw_init_mode_regs(ah);
536 if (ah->is_pciexpress)
537 ath9k_hw_configpcipowersave(ah, 0, 0);
539 ath9k_hw_disablepcie(ah);
541 if (!AR_SREV_9300_20_OR_LATER(ah))
542 ar9002_hw_cck_chan14_spread(ah);
544 r = ath9k_hw_post_init(ah);
548 ath9k_hw_init_mode_gain_regs(ah);
549 r = ath9k_hw_fill_cap_info(ah);
553 r = ath9k_hw_init_macaddr(ah);
555 DBG("ath9k: Failed to initialize MAC address\n");
559 if (AR_SREV_9285(ah) || AR_SREV_9271(ah))
560 ah->tx_trig_level = (AR_FTRIG_256B >> AR_FTRIG_S);
562 ah->tx_trig_level = (AR_FTRIG_512B >> AR_FTRIG_S);
564 common->state = ATH_HW_INITIALIZED;
569 int ath9k_hw_init(struct ath_hw *ah)
572 struct ath_common *common = ath9k_hw_common(ah);
574 /* These are all the AR5008/AR9001/AR9002 hardware family of chipsets */
575 switch (ah->hw_version.devid) {
576 case AR5416_DEVID_PCI:
577 case AR5416_DEVID_PCIE:
578 case AR5416_AR9100_DEVID:
579 case AR9160_DEVID_PCI:
580 case AR9280_DEVID_PCI:
581 case AR9280_DEVID_PCIE:
582 case AR9285_DEVID_PCIE:
583 case AR9287_DEVID_PCI:
584 case AR9287_DEVID_PCIE:
585 case AR2427_DEVID_PCIE:
586 case AR9300_DEVID_PCIE:
587 case AR9300_DEVID_AR9485_PCIE:
588 case AR9300_DEVID_AR9340:
591 if (common->bus_ops->ath_bus_type == ATH_USB)
593 DBG("ath9k: Hardware device ID 0x%04x not supported\n",
594 ah->hw_version.devid);
598 ret = __ath9k_hw_init(ah);
601 "Unable to initialize hardware; initialization status: %d\n",
609 u32 ar9003_get_pll_sqsum_dvc(struct ath_hw *ah)
611 REG_CLR_BIT(ah, PLL3, PLL3_DO_MEAS_MASK);
613 REG_SET_BIT(ah, PLL3, PLL3_DO_MEAS_MASK);
615 while ((REG_READ(ah, PLL4) & PLL4_MEAS_DONE) == 0)
618 return (REG_READ(ah, PLL3) & SQSUM_DVC_MASK) >> 3;
621 static void ath9k_hw_init_pll(struct ath_hw *ah,
622 struct ath9k_channel *chan)
626 if (AR_SREV_9485(ah)) {
628 /* program BB PLL ki and kd value, ki=0x4, kd=0x40 */
629 REG_RMW_FIELD(ah, AR_CH0_BB_DPLL2,
630 AR_CH0_BB_DPLL2_PLL_PWD, 0x1);
631 REG_RMW_FIELD(ah, AR_CH0_BB_DPLL2,
632 AR_CH0_DPLL2_KD, 0x40);
633 REG_RMW_FIELD(ah, AR_CH0_BB_DPLL2,
634 AR_CH0_DPLL2_KI, 0x4);
636 REG_RMW_FIELD(ah, AR_CH0_BB_DPLL1,
637 AR_CH0_BB_DPLL1_REFDIV, 0x5);
638 REG_RMW_FIELD(ah, AR_CH0_BB_DPLL1,
639 AR_CH0_BB_DPLL1_NINI, 0x58);
640 REG_RMW_FIELD(ah, AR_CH0_BB_DPLL1,
641 AR_CH0_BB_DPLL1_NFRAC, 0x0);
643 REG_RMW_FIELD(ah, AR_CH0_BB_DPLL2,
644 AR_CH0_BB_DPLL2_OUTDIV, 0x1);
645 REG_RMW_FIELD(ah, AR_CH0_BB_DPLL2,
646 AR_CH0_BB_DPLL2_LOCAL_PLL, 0x1);
647 REG_RMW_FIELD(ah, AR_CH0_BB_DPLL2,
648 AR_CH0_BB_DPLL2_EN_NEGTRIG, 0x1);
650 /* program BB PLL phase_shift to 0x6 */
651 REG_RMW_FIELD(ah, AR_CH0_BB_DPLL3,
652 AR_CH0_BB_DPLL3_PHASE_SHIFT, 0x6);
654 REG_RMW_FIELD(ah, AR_CH0_BB_DPLL2,
655 AR_CH0_BB_DPLL2_PLL_PWD, 0x0);
657 } else if (AR_SREV_9340(ah)) {
658 u32 regval, pll2_divint, pll2_divfrac, refdiv;
660 REG_WRITE(ah, AR_RTC_PLL_CONTROL, 0x1142c);
663 REG_SET_BIT(ah, AR_PHY_PLL_MODE, 0x1 << 16);
666 if (ah->is_clk_25mhz) {
668 pll2_divfrac = 0x1eb85;
676 regval = REG_READ(ah, AR_PHY_PLL_MODE);
677 regval |= (0x1 << 16);
678 REG_WRITE(ah, AR_PHY_PLL_MODE, regval);
681 REG_WRITE(ah, AR_PHY_PLL_CONTROL, (refdiv << 27) |
682 (pll2_divint << 18) | pll2_divfrac);
685 regval = REG_READ(ah, AR_PHY_PLL_MODE);
686 regval = (regval & 0x80071fff) | (0x1 << 30) | (0x1 << 13) |
687 (0x4 << 26) | (0x18 << 19);
688 REG_WRITE(ah, AR_PHY_PLL_MODE, regval);
689 REG_WRITE(ah, AR_PHY_PLL_MODE,
690 REG_READ(ah, AR_PHY_PLL_MODE) & 0xfffeffff);
694 pll = ath9k_hw_compute_pll_control(ah, chan);
696 REG_WRITE(ah, AR_RTC_PLL_CONTROL, pll);
698 if (AR_SREV_9485(ah) || AR_SREV_9340(ah))
701 /* Switch the core clock for ar9271 to 117Mhz */
702 if (AR_SREV_9271(ah)) {
704 REG_WRITE(ah, 0x50040, 0x304);
707 udelay(RTC_PLL_SETTLE_DELAY);
709 REG_WRITE(ah, AR_RTC_SLEEP_CLK, AR_RTC_FORCE_DERIVED_CLK);
711 if (AR_SREV_9340(ah)) {
712 if (ah->is_clk_25mhz) {
713 REG_WRITE(ah, AR_RTC_DERIVED_CLK, 0x17c << 1);
714 REG_WRITE(ah, AR_SLP32_MODE, 0x0010f3d7);
715 REG_WRITE(ah, AR_SLP32_INC, 0x0001e7ae);
717 REG_WRITE(ah, AR_RTC_DERIVED_CLK, 0x261 << 1);
718 REG_WRITE(ah, AR_SLP32_MODE, 0x0010f400);
719 REG_WRITE(ah, AR_SLP32_INC, 0x0001e800);
725 static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah)
727 u32 sync_default = AR_INTR_SYNC_DEFAULT;
728 u32 imr_reg = AR_IMR_TXERR |
733 if (AR_SREV_9340(ah))
734 sync_default &= ~AR_INTR_SYNC_HOST1_FATAL;
736 if (AR_SREV_9300_20_OR_LATER(ah)) {
737 imr_reg |= AR_IMR_RXOK_HP;
738 if (ah->config.rx_intr_mitigation)
739 imr_reg |= AR_IMR_RXINTM | AR_IMR_RXMINTR;
741 imr_reg |= AR_IMR_RXOK_LP;
744 if (ah->config.rx_intr_mitigation)
745 imr_reg |= AR_IMR_RXINTM | AR_IMR_RXMINTR;
747 imr_reg |= AR_IMR_RXOK;
750 if (ah->config.tx_intr_mitigation)
751 imr_reg |= AR_IMR_TXINTM | AR_IMR_TXMINTR;
753 imr_reg |= AR_IMR_TXOK;
755 ENABLE_REGWRITE_BUFFER(ah);
757 REG_WRITE(ah, AR_IMR, imr_reg);
758 // ah->imrs2_reg |= AR_IMR_S2_GTT;
759 REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg);
761 if (!AR_SREV_9100(ah)) {
762 REG_WRITE(ah, AR_INTR_SYNC_CAUSE, 0xFFFFFFFF);
763 REG_WRITE(ah, AR_INTR_SYNC_ENABLE, sync_default);
764 REG_WRITE(ah, AR_INTR_SYNC_MASK, 0);
767 REGWRITE_BUFFER_FLUSH(ah);
769 if (AR_SREV_9300_20_OR_LATER(ah)) {
770 REG_WRITE(ah, AR_INTR_PRIO_ASYNC_ENABLE, 0);
771 REG_WRITE(ah, AR_INTR_PRIO_ASYNC_MASK, 0);
772 REG_WRITE(ah, AR_INTR_PRIO_SYNC_ENABLE, 0);
773 REG_WRITE(ah, AR_INTR_PRIO_SYNC_MASK, 0);
777 static void ath9k_hw_setslottime(struct ath_hw *ah, u32 us)
779 u32 val = ath9k_hw_mac_to_clks(ah, us);
780 val = min(val, (u32) 0xFFFF);
781 REG_WRITE(ah, AR_D_GBL_IFS_SLOT, val);
784 static void ath9k_hw_set_ack_timeout(struct ath_hw *ah, u32 us)
786 u32 val = ath9k_hw_mac_to_clks(ah, us);
787 val = min(val, (u32) MS(0xFFFFFFFF, AR_TIME_OUT_ACK));
788 REG_RMW_FIELD(ah, AR_TIME_OUT, AR_TIME_OUT_ACK, val);
791 static void ath9k_hw_set_cts_timeout(struct ath_hw *ah, u32 us)
793 u32 val = ath9k_hw_mac_to_clks(ah, us);
794 val = min(val, (u32) MS(0xFFFFFFFF, AR_TIME_OUT_CTS));
795 REG_RMW_FIELD(ah, AR_TIME_OUT, AR_TIME_OUT_CTS, val);
798 static int ath9k_hw_set_global_txtimeout(struct ath_hw *ah, u32 tu)
802 "bad global tx timeout %d\n", tu);
803 ah->globaltxtimeout = (u32) -1;
806 REG_RMW_FIELD(ah, AR_GTXTO, AR_GTXTO_TIMEOUT_LIMIT, tu);
807 ah->globaltxtimeout = tu;
812 void ath9k_hw_init_global_settings(struct ath_hw *ah)
818 DBG2("ath9k: ah->misc_mode 0x%x\n",
821 if (ah->misc_mode != 0)
822 REG_SET_BIT(ah, AR_PCU_MISC, ah->misc_mode);
824 if ((ah->dev->channels + ah->dev->channel)->band == NET80211_BAND_5GHZ)
829 /* As defined by IEEE 802.11-2007 17.3.8.6 */
830 slottime = ah->slottime + 3 * ah->coverage_class;
831 acktimeout = slottime + sifstime;
834 * Workaround for early ACK timeouts, add an offset to match the
835 * initval's 64us ack timeout value.
836 * This was initially only meant to work around an issue with delayed
837 * BA frames in some implementations, but it has been found to fix ACK
838 * timeout issues in other cases as well.
840 if ((ah->dev->channels + ah->dev->channel)->band == NET80211_BAND_2GHZ)
841 acktimeout += 64 - sifstime - ah->slottime;
843 ath9k_hw_setslottime(ah, ah->slottime);
844 ath9k_hw_set_ack_timeout(ah, acktimeout);
845 ath9k_hw_set_cts_timeout(ah, acktimeout);
846 if (ah->globaltxtimeout != (u32) -1)
847 ath9k_hw_set_global_txtimeout(ah, ah->globaltxtimeout);
850 void ath9k_hw_deinit(struct ath_hw *ah)
852 struct ath_common *common = ath9k_hw_common(ah);
854 if (common->state < ATH_HW_INITIALIZED)
857 ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP);
860 ath9k_hw_rf_free_ext_banks(ah);
867 u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, struct ath9k_channel *chan)
869 u32 ctl = ath_regd_get_band_ctl(reg, chan->chan->band);
873 else if (IS_CHAN_G(chan))
881 /****************************************/
882 /* Reset and Channel Switching Routines */
883 /****************************************/
885 static inline void ath9k_hw_set_dma(struct ath_hw *ah)
887 struct ath_common *common = ath9k_hw_common(ah);
889 ENABLE_REGWRITE_BUFFER(ah);
892 * set AHB_MODE not to do cacheline prefetches
894 if (!AR_SREV_9300_20_OR_LATER(ah))
895 REG_SET_BIT(ah, AR_AHB_MODE, AR_AHB_PREFETCH_RD_EN);
898 * let mac dma reads be in 128 byte chunks
900 REG_RMW(ah, AR_TXCFG, AR_TXCFG_DMASZ_128B, AR_TXCFG_DMASZ_MASK);
902 REGWRITE_BUFFER_FLUSH(ah);
905 * Restore TX Trigger Level to its pre-reset value.
906 * The initial value depends on whether aggregation is enabled, and is
907 * adjusted whenever underruns are detected.
909 if (!AR_SREV_9300_20_OR_LATER(ah))
910 REG_RMW_FIELD(ah, AR_TXCFG, AR_FTRIG, ah->tx_trig_level);
912 ENABLE_REGWRITE_BUFFER(ah);
915 * let mac dma writes be in 128 byte chunks
917 REG_RMW(ah, AR_RXCFG, AR_RXCFG_DMASZ_128B, AR_RXCFG_DMASZ_MASK);
920 * Setup receive FIFO threshold to hold off TX activities
922 REG_WRITE(ah, AR_RXFIFO_CFG, 0x200);
924 if (AR_SREV_9300_20_OR_LATER(ah)) {
925 REG_RMW_FIELD(ah, AR_RXBP_THRESH, AR_RXBP_THRESH_HP, 0x1);
926 REG_RMW_FIELD(ah, AR_RXBP_THRESH, AR_RXBP_THRESH_LP, 0x1);
928 ath9k_hw_set_rx_bufsize(ah, common->rx_bufsize -
929 ah->caps.rx_status_len);
933 * reduce the number of usable entries in PCU TXBUF to avoid
934 * wrap around issues.
936 if (AR_SREV_9285(ah)) {
937 /* For AR9285 the number of Fifos are reduced to half.
938 * So set the usable tx buf size also to half to
939 * avoid data/delimiter underruns
941 REG_WRITE(ah, AR_PCU_TXBUF_CTRL,
942 AR_9285_PCU_TXBUF_CTRL_USABLE_SIZE);
943 } else if (!AR_SREV_9271(ah)) {
944 REG_WRITE(ah, AR_PCU_TXBUF_CTRL,
945 AR_PCU_TXBUF_CTRL_USABLE_SIZE);
948 REGWRITE_BUFFER_FLUSH(ah);
950 if (AR_SREV_9300_20_OR_LATER(ah))
951 ath9k_hw_reset_txstatus_ring(ah);
954 static void ath9k_hw_set_operating_mode(struct ath_hw *ah)
956 u32 mask = AR_STA_ID1_STA_AP | AR_STA_ID1_ADHOC;
957 u32 set = AR_STA_ID1_KSRCH_MODE;
959 REG_CLR_BIT(ah, AR_CFG, AR_CFG_AP_ADHOC_INDICATION);
961 REG_RMW(ah, AR_STA_ID1, set, mask);
964 void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah __unused, u32 coef_scaled,
965 u32 *coef_mantissa, u32 *coef_exponent)
967 u32 coef_exp, coef_man;
969 for (coef_exp = 31; coef_exp > 0; coef_exp--)
970 if ((coef_scaled >> coef_exp) & 0x1)
973 coef_exp = 14 - (coef_exp - COEF_SCALE_S);
975 coef_man = coef_scaled + (1 << (COEF_SCALE_S - coef_exp - 1));
977 *coef_mantissa = coef_man >> (COEF_SCALE_S - coef_exp);
978 *coef_exponent = coef_exp - 16;
981 static int ath9k_hw_set_reset(struct ath_hw *ah, int type)
986 if (AR_SREV_9100(ah)) {
987 REG_RMW_FIELD(ah, AR_RTC_DERIVED_CLK,
988 AR_RTC_DERIVED_CLK_PERIOD, 1);
989 (void)REG_READ(ah, AR_RTC_DERIVED_CLK);
992 ENABLE_REGWRITE_BUFFER(ah);
994 if (AR_SREV_9300_20_OR_LATER(ah)) {
995 REG_WRITE(ah, AR_WA, ah->WARegVal);
999 REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN |
1000 AR_RTC_FORCE_WAKE_ON_INT);
1002 if (AR_SREV_9100(ah)) {
1003 rst_flags = AR_RTC_RC_MAC_WARM | AR_RTC_RC_MAC_COLD |
1004 AR_RTC_RC_COLD_RESET | AR_RTC_RC_WARM_RESET;
1006 tmpReg = REG_READ(ah, AR_INTR_SYNC_CAUSE);
1008 (AR_INTR_SYNC_LOCAL_TIMEOUT |
1009 AR_INTR_SYNC_RADM_CPL_TIMEOUT)) {
1011 REG_WRITE(ah, AR_INTR_SYNC_ENABLE, 0);
1014 if (!AR_SREV_9300_20_OR_LATER(ah))
1016 REG_WRITE(ah, AR_RC, val);
1018 } else if (!AR_SREV_9300_20_OR_LATER(ah))
1019 REG_WRITE(ah, AR_RC, AR_RC_AHB);
1021 rst_flags = AR_RTC_RC_MAC_WARM;
1022 if (type == ATH9K_RESET_COLD)
1023 rst_flags |= AR_RTC_RC_MAC_COLD;
1026 REG_WRITE(ah, AR_RTC_RC, rst_flags);
1028 REGWRITE_BUFFER_FLUSH(ah);
1032 REG_WRITE(ah, AR_RTC_RC, 0);
1033 if (!ath9k_hw_wait(ah, AR_RTC_RC, AR_RTC_RC_M, 0, AH_WAIT_TIMEOUT)) {
1035 "RTC stuck in MAC reset\n");
1039 if (!AR_SREV_9100(ah))
1040 REG_WRITE(ah, AR_RC, 0);
1042 if (AR_SREV_9100(ah))
1048 static int ath9k_hw_set_reset_power_on(struct ath_hw *ah)
1050 ENABLE_REGWRITE_BUFFER(ah);
1052 if (AR_SREV_9300_20_OR_LATER(ah)) {
1053 REG_WRITE(ah, AR_WA, ah->WARegVal);
1057 REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN |
1058 AR_RTC_FORCE_WAKE_ON_INT);
1060 if (!AR_SREV_9100(ah) && !AR_SREV_9300_20_OR_LATER(ah))
1061 REG_WRITE(ah, AR_RC, AR_RC_AHB);
1063 REG_WRITE(ah, AR_RTC_RESET, 0);
1065 REGWRITE_BUFFER_FLUSH(ah);
1067 if (!AR_SREV_9300_20_OR_LATER(ah))
1070 if (!AR_SREV_9100(ah) && !AR_SREV_9300_20_OR_LATER(ah))
1071 REG_WRITE(ah, AR_RC, 0);
1073 REG_WRITE(ah, AR_RTC_RESET, 1);
1075 if (!ath9k_hw_wait(ah,
1081 "RTC not waking up\n");
1085 return ath9k_hw_set_reset(ah, ATH9K_RESET_WARM);
1088 static int ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type)
1090 if (AR_SREV_9300_20_OR_LATER(ah)) {
1091 REG_WRITE(ah, AR_WA, ah->WARegVal);
1095 REG_WRITE(ah, AR_RTC_FORCE_WAKE,
1096 AR_RTC_FORCE_WAKE_EN | AR_RTC_FORCE_WAKE_ON_INT);
1099 case ATH9K_RESET_POWER_ON:
1100 return ath9k_hw_set_reset_power_on(ah);
1101 case ATH9K_RESET_WARM:
1102 case ATH9K_RESET_COLD:
1103 return ath9k_hw_set_reset(ah, type);
1109 static int ath9k_hw_chip_reset(struct ath_hw *ah,
1110 struct ath9k_channel *chan)
1112 if (AR_SREV_9280(ah) && ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL)) {
1113 if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON))
1115 } else if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM))
1118 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
1121 ah->chip_fullsleep = 0;
1122 ath9k_hw_init_pll(ah, chan);
1123 ath9k_hw_set_rfmode(ah, chan);
1128 static int ath9k_hw_channel_change(struct ath_hw *ah,
1129 struct ath9k_channel *chan)
1131 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
1132 struct net80211_channel *channel = chan->chan;
1136 for (qnum = 0; qnum < AR_NUM_QCU; qnum++) {
1137 if (ath9k_hw_numtxpending(ah, qnum)) {
1139 "Transmit frames pending on queue %d\n", qnum);
1144 if (!ath9k_hw_rfbus_req(ah)) {
1145 DBG("ath9k: Could not kill baseband RX\n");
1149 ath9k_hw_set_channel_regs(ah, chan);
1151 r = ath9k_hw_rf_set_freq(ah, chan);
1153 DBG("ath9k: Failed to set channel\n");
1156 ath9k_hw_set_clockrate(ah);
1158 ah->eep_ops->set_txpower(ah, chan,
1159 ath9k_regd_get_ctl(regulatory, chan),
1161 channel->maxpower * 2,
1162 min((u32) MAX_RATE_POWER,
1163 (u32) regulatory->power_limit), 0);
1165 ath9k_hw_rfbus_done(ah);
1167 if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan))
1168 ath9k_hw_set_delta_slope(ah, chan);
1170 ath9k_hw_spur_mitigate_freq(ah, chan);
1175 static void ath9k_hw_apply_gpio_override(struct ath_hw *ah)
1177 u32 gpio_mask = ah->gpio_mask;
1180 for (i = 0; gpio_mask; i++, gpio_mask >>= 1) {
1181 if (!(gpio_mask & 1))
1184 ath9k_hw_cfg_output(ah, i, AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
1185 ath9k_hw_set_gpio(ah, i, !!(ah->gpio_val & BIT(i)));
1189 int ath9k_hw_check_alive(struct ath_hw *ah)
1194 if (AR_SREV_9285_12_OR_LATER(ah))
1198 reg = REG_READ(ah, AR_OBS_BUS_1);
1200 if ((reg & 0x7E7FFFEF) == 0x00702400)
1203 switch (reg & 0x7E000B00) {
1211 } while (count-- > 0);
1216 int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
1217 struct ath9k_hw_cal_data *caldata, int bChannelChange)
1219 struct ath_common *common = ath9k_hw_common(ah);
1221 struct ath9k_channel *curchan = ah->curchan;
1226 ah->txchainmask = common->tx_chainmask;
1227 ah->rxchainmask = common->rx_chainmask;
1229 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
1232 if (curchan && !ah->chip_fullsleep)
1233 ath9k_hw_getnf(ah, curchan);
1235 ah->caldata = caldata;
1237 (chan->channel != caldata->channel ||
1238 (chan->channelFlags & ~CHANNEL_CW_INT) !=
1239 (caldata->channelFlags & ~CHANNEL_CW_INT))) {
1240 /* Operating channel changed, reset channel calibration data */
1241 memset(caldata, 0, sizeof(*caldata));
1242 ath9k_init_nfcal_hist_buffer(ah, chan);
1245 if (bChannelChange &&
1246 (ah->chip_fullsleep != 1) &&
1247 (ah->curchan != NULL) &&
1248 (chan->channel != ah->curchan->channel) &&
1249 ((chan->channelFlags & CHANNEL_ALL) ==
1250 (ah->curchan->channelFlags & CHANNEL_ALL)) &&
1251 (!AR_SREV_9280(ah) || AR_DEVID_7010(ah))) {
1253 if (ath9k_hw_channel_change(ah, chan)) {
1254 ath9k_hw_loadnf(ah, ah->curchan);
1255 ath9k_hw_start_nfcal(ah, 1);
1256 if (AR_SREV_9271(ah))
1257 ar9002_hw_load_ani_reg(ah, chan);
1262 saveDefAntenna = REG_READ(ah, AR_DEF_ANTENNA);
1263 if (saveDefAntenna == 0)
1266 macStaId1 = REG_READ(ah, AR_STA_ID1) & AR_STA_ID1_BASE_RATE_11B;
1268 saveLedState = REG_READ(ah, AR_CFG_LED) &
1269 (AR_CFG_LED_ASSOC_CTL | AR_CFG_LED_MODE_SEL |
1270 AR_CFG_LED_BLINK_THRESH_SEL | AR_CFG_LED_BLINK_SLOW);
1272 ath9k_hw_mark_phy_inactive(ah);
1274 ah->paprd_table_write_done = 0;
1276 /* Only required on the first reset */
1277 if (AR_SREV_9271(ah) && ah->htc_reset_init) {
1279 AR9271_RESET_POWER_DOWN_CONTROL,
1280 AR9271_RADIO_RF_RST);
1284 if (!ath9k_hw_chip_reset(ah, chan)) {
1285 DBG("ath9k: Chip reset failed\n");
1289 /* Only required on the first reset */
1290 if (AR_SREV_9271(ah) && ah->htc_reset_init) {
1291 ah->htc_reset_init = 0;
1293 AR9271_RESET_POWER_DOWN_CONTROL,
1294 AR9271_GATE_MAC_CTL);
1298 if (AR_SREV_9280_20_OR_LATER(ah))
1299 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, AR_GPIO_JTAG_DISABLE);
1301 if (!AR_SREV_9300_20_OR_LATER(ah))
1302 ar9002_hw_enable_async_fifo(ah);
1304 r = ath9k_hw_process_ini(ah, chan);
1308 /* Setup MFP options for CCMP */
1309 if (AR_SREV_9280_20_OR_LATER(ah)) {
1310 /* Mask Retry(b11), PwrMgt(b12), MoreData(b13) to 0 in mgmt
1311 * frames when constructing CCMP AAD. */
1312 REG_RMW_FIELD(ah, AR_AES_MUTE_MASK1, AR_AES_MUTE_MASK1_FC_MGMT,
1314 ah->sw_mgmt_crypto = 0;
1315 } else if (AR_SREV_9160_10_OR_LATER(ah)) {
1316 /* Disable hardware crypto for management frames */
1317 REG_CLR_BIT(ah, AR_PCU_MISC_MODE2,
1318 AR_PCU_MISC_MODE2_MGMT_CRYPTO_ENABLE);
1319 REG_SET_BIT(ah, AR_PCU_MISC_MODE2,
1320 AR_PCU_MISC_MODE2_NO_CRYPTO_FOR_NON_DATA_PKT);
1321 ah->sw_mgmt_crypto = 1;
1323 ah->sw_mgmt_crypto = 1;
1325 if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan))
1326 ath9k_hw_set_delta_slope(ah, chan);
1328 ath9k_hw_spur_mitigate_freq(ah, chan);
1329 ah->eep_ops->set_board_values(ah, chan);
1331 ENABLE_REGWRITE_BUFFER(ah);
1333 REG_WRITE(ah, AR_STA_ID0, get_unaligned_le32(common->macaddr));
1334 REG_WRITE(ah, AR_STA_ID1, get_unaligned_le16(common->macaddr + 4)
1336 | AR_STA_ID1_RTS_USE_DEF
1338 ack_6mb ? AR_STA_ID1_ACKCTS_6MB : 0)
1339 | ah->sta_id1_defaults);
1340 ath_hw_setbssidmask(common);
1341 REG_WRITE(ah, AR_DEF_ANTENNA, saveDefAntenna);
1342 ath9k_hw_write_associd(ah);
1343 REG_WRITE(ah, AR_ISR, ~0);
1344 REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR);
1346 REGWRITE_BUFFER_FLUSH(ah);
1348 ath9k_hw_set_operating_mode(ah);
1350 r = ath9k_hw_rf_set_freq(ah, chan);
1354 ath9k_hw_set_clockrate(ah);
1356 ENABLE_REGWRITE_BUFFER(ah);
1358 for (i = 0; i < AR_NUM_DCU; i++)
1359 REG_WRITE(ah, AR_DQCUMASK(i), 1 << i);
1361 REGWRITE_BUFFER_FLUSH(ah);
1364 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
1365 ath9k_hw_resettxqueue(ah, i);
1367 ath9k_hw_init_interrupt_masks(ah);
1368 ath9k_hw_ani_cache_ini_regs(ah);
1370 if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
1371 ath9k_hw_cfg_gpio_input(ah, ah->rfkill_gpio);
1373 ath9k_hw_init_global_settings(ah);
1375 if (!AR_SREV_9300_20_OR_LATER(ah)) {
1376 ar9002_hw_update_async_fifo(ah);
1377 ar9002_hw_enable_wep_aggregation(ah);
1380 REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PRESERVE_SEQNUM);
1382 ath9k_hw_set_dma(ah);
1384 REG_WRITE(ah, AR_OBS, 8);
1386 if (ah->config.rx_intr_mitigation) {
1387 REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 500);
1388 REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_FIRST, 2000);
1391 if (ah->config.tx_intr_mitigation) {
1392 REG_RMW_FIELD(ah, AR_TIMT, AR_TIMT_LAST, 300);
1393 REG_RMW_FIELD(ah, AR_TIMT, AR_TIMT_FIRST, 750);
1396 ath9k_hw_init_bb(ah, chan);
1398 if (!ath9k_hw_init_cal(ah, chan))
1401 ENABLE_REGWRITE_BUFFER(ah);
1403 ath9k_hw_restore_chainmask(ah);
1404 REG_WRITE(ah, AR_CFG_LED, saveLedState | AR_CFG_SCLK_32KHZ);
1406 REGWRITE_BUFFER_FLUSH(ah);
1409 * For big endian systems turn on swapping for descriptors
1411 if (AR_SREV_9100(ah)) {
1413 mask = REG_READ(ah, AR_CFG);
1414 if (mask & (AR_CFG_SWRB | AR_CFG_SWTB | AR_CFG_SWRG)) {
1416 "CFG Byte Swap Set 0x%x\n", mask);
1419 INIT_CONFIG_STATUS | AR_CFG_SWRB | AR_CFG_SWTB;
1420 REG_WRITE(ah, AR_CFG, mask);
1422 "Setting CFG 0x%x\n", REG_READ(ah, AR_CFG));
1425 if (common->bus_ops->ath_bus_type == ATH_USB) {
1426 /* Configure AR9271 target WLAN */
1427 if (AR_SREV_9271(ah))
1428 REG_WRITE(ah, AR_CFG, AR_CFG_SWRB | AR_CFG_SWTB);
1430 REG_WRITE(ah, AR_CFG, AR_CFG_SWTD | AR_CFG_SWRD);
1432 #if __BYTE_ORDER == __BIG_ENDIAN
1433 else if (AR_SREV_9340(ah))
1434 REG_RMW(ah, AR_CFG, AR_CFG_SWRB | AR_CFG_SWTB, 0);
1436 REG_WRITE(ah, AR_CFG, AR_CFG_SWTD | AR_CFG_SWRD);
1440 if (AR_SREV_9300_20_OR_LATER(ah)) {
1441 ar9003_hw_disable_phy_restart(ah);
1444 ath9k_hw_apply_gpio_override(ah);
1449 /******************************/
1450 /* Power Management (Chipset) */
1451 /******************************/
1454 * Notify Power Mgt is disabled in self-generated frames.
1455 * If requested, force chip to sleep.
1457 static void ath9k_set_power_sleep(struct ath_hw *ah, int setChip)
1459 REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV);
1462 * Clear the RTC force wake bit to allow the
1463 * mac to go to sleep.
1465 REG_CLR_BIT(ah, AR_RTC_FORCE_WAKE,
1466 AR_RTC_FORCE_WAKE_EN);
1467 if (!AR_SREV_9100(ah) && !AR_SREV_9300_20_OR_LATER(ah))
1468 REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF);
1470 /* Shutdown chip. Active low */
1471 if (!AR_SREV_5416(ah) && !AR_SREV_9271(ah))
1472 REG_CLR_BIT(ah, (AR_RTC_RESET),
1476 /* Clear Bit 14 of AR_WA after putting chip into Full Sleep mode. */
1477 if (AR_SREV_9300_20_OR_LATER(ah))
1478 REG_WRITE(ah, AR_WA,
1479 ah->WARegVal & ~AR_WA_D3_L1_DISABLE);
1482 static int ath9k_hw_set_power_awake(struct ath_hw *ah, int setChip)
1487 /* Set Bits 14 and 17 of AR_WA before powering on the chip. */
1488 if (AR_SREV_9300_20_OR_LATER(ah)) {
1489 REG_WRITE(ah, AR_WA, ah->WARegVal);
1494 if ((REG_READ(ah, AR_RTC_STATUS) &
1495 AR_RTC_STATUS_M) == AR_RTC_STATUS_SHUTDOWN) {
1496 if (ath9k_hw_set_reset_reg(ah,
1497 ATH9K_RESET_POWER_ON) != 1) {
1500 if (!AR_SREV_9300_20_OR_LATER(ah))
1501 ath9k_hw_init_pll(ah, NULL);
1503 if (AR_SREV_9100(ah))
1504 REG_SET_BIT(ah, AR_RTC_RESET,
1507 REG_SET_BIT(ah, AR_RTC_FORCE_WAKE,
1508 AR_RTC_FORCE_WAKE_EN);
1511 for (i = POWER_UP_TIME / 50; i > 0; i--) {
1512 val = REG_READ(ah, AR_RTC_STATUS) & AR_RTC_STATUS_M;
1513 if (val == AR_RTC_STATUS_ON)
1516 REG_SET_BIT(ah, AR_RTC_FORCE_WAKE,
1517 AR_RTC_FORCE_WAKE_EN);
1521 "Failed to wakeup in %dus\n",
1522 POWER_UP_TIME / 20);
1527 REG_CLR_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV);
1532 int ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode)
1534 int status = 1, setChip = 1;
1535 static const char *modes[] = {
1542 if (ah->power_mode == mode)
1545 DBG2("ath9k: %s -> %s\n",
1546 modes[ah->power_mode], modes[mode]);
1549 case ATH9K_PM_AWAKE:
1550 status = ath9k_hw_set_power_awake(ah, setChip);
1552 case ATH9K_PM_FULL_SLEEP:
1553 ath9k_set_power_sleep(ah, setChip);
1554 ah->chip_fullsleep = 1;
1557 DBG("ath9k: Unknown power mode %d\n", mode);
1560 ah->power_mode = mode;
1565 /*******************/
1566 /* HW Capabilities */
1567 /*******************/
1569 int ath9k_hw_fill_cap_info(struct ath_hw *ah)
1571 struct ath9k_hw_capabilities *pCap = &ah->caps;
1572 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
1573 struct ath_common *common = ath9k_hw_common(ah);
1576 u8 ant_div_ctl1, tx_chainmask, rx_chainmask;
1578 eeval = ah->eep_ops->get_eeprom(ah, EEP_REG_0);
1579 regulatory->current_rd = eeval;
1581 eeval = ah->eep_ops->get_eeprom(ah, EEP_REG_1);
1582 if (AR_SREV_9285_12_OR_LATER(ah))
1583 eeval |= AR9285_RDEXT_DEFAULT;
1584 regulatory->current_rd_ext = eeval;
1586 if (ah->hw_version.subvendorid == AR_SUBVENDOR_ID_NEW_A) {
1587 if (regulatory->current_rd == 0x64 ||
1588 regulatory->current_rd == 0x65)
1589 regulatory->current_rd += 5;
1590 else if (regulatory->current_rd == 0x41)
1591 regulatory->current_rd = 0x43;
1593 "regdomain mapped to 0x%x\n", regulatory->current_rd);
1596 eeval = ah->eep_ops->get_eeprom(ah, EEP_OP_MODE);
1597 if ((eeval & (AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A)) == 0) {
1599 "no band has been marked as supported in EEPROM\n");
1603 if (eeval & AR5416_OPFLAGS_11A)
1604 pCap->hw_caps |= ATH9K_HW_CAP_5GHZ;
1606 if (eeval & AR5416_OPFLAGS_11G)
1607 pCap->hw_caps |= ATH9K_HW_CAP_2GHZ;
1609 pCap->tx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_TX_MASK);
1611 * For AR9271 we will temporarilly uses the rx chainmax as read from
1614 if ((ah->hw_version.devid == AR5416_DEVID_PCI) &&
1615 !(eeval & AR5416_OPFLAGS_11A) &&
1616 !(AR_SREV_9271(ah)))
1617 /* CB71: GPIO 0 is pulled down to indicate 3 rx chains */
1618 pCap->rx_chainmask = ath9k_hw_gpio_get(ah, 0) ? 0x5 : 0x7;
1619 else if (AR_SREV_9100(ah))
1620 pCap->rx_chainmask = 0x7;
1622 /* Use rx_chainmask from EEPROM. */
1623 pCap->rx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_RX_MASK);
1625 ah->misc_mode |= AR_PCU_MIC_NEW_LOC_ENA;
1627 /* enable key search for every frame in an aggregate */
1628 if (AR_SREV_9300_20_OR_LATER(ah))
1629 ah->misc_mode |= AR_PCU_ALWAYS_PERFORM_KEYSEARCH;
1631 common->crypt_caps |= ATH_CRYPT_CAP_CIPHER_AESCCM;
1633 pCap->hw_caps &= ~ATH9K_HW_CAP_HT;
1635 if (AR_SREV_9271(ah))
1636 pCap->num_gpio_pins = AR9271_NUM_GPIO;
1637 else if (AR_DEVID_7010(ah))
1638 pCap->num_gpio_pins = AR7010_NUM_GPIO;
1639 else if (AR_SREV_9285_12_OR_LATER(ah))
1640 pCap->num_gpio_pins = AR9285_NUM_GPIO;
1641 else if (AR_SREV_9280_20_OR_LATER(ah))
1642 pCap->num_gpio_pins = AR928X_NUM_GPIO;
1644 pCap->num_gpio_pins = AR_NUM_GPIO;
1646 if (AR_SREV_9160_10_OR_LATER(ah) || AR_SREV_9100(ah)) {
1647 pCap->hw_caps |= ATH9K_HW_CAP_CST;
1648 pCap->rts_aggr_limit = ATH_AMPDU_LIMIT_MAX;
1650 pCap->rts_aggr_limit = (8 * 1024);
1653 ah->rfsilent = ah->eep_ops->get_eeprom(ah, EEP_RF_SILENT);
1654 if (ah->rfsilent & EEP_RFSILENT_ENABLED) {
1656 MS(ah->rfsilent, EEP_RFSILENT_GPIO_SEL);
1657 ah->rfkill_polarity =
1658 MS(ah->rfsilent, EEP_RFSILENT_POLARITY);
1660 pCap->hw_caps |= ATH9K_HW_CAP_RFSILENT;
1663 pCap->hw_caps &= ~ATH9K_HW_CAP_AUTOSLEEP;
1665 if (AR_SREV_9280(ah) || AR_SREV_9285(ah))
1666 pCap->hw_caps &= ~ATH9K_HW_CAP_4KB_SPLITTRANS;
1668 pCap->hw_caps |= ATH9K_HW_CAP_4KB_SPLITTRANS;
1670 if (AR_SREV_9300_20_OR_LATER(ah)) {
1671 pCap->hw_caps |= ATH9K_HW_CAP_FASTCLOCK;
1672 if (!AR_SREV_9485(ah))
1673 pCap->hw_caps |= ATH9K_HW_CAP_LDPC;
1675 pCap->rx_hp_qdepth = ATH9K_HW_RX_HP_QDEPTH;
1676 pCap->rx_lp_qdepth = ATH9K_HW_RX_LP_QDEPTH;
1677 pCap->rx_status_len = sizeof(struct ar9003_rxs);
1678 pCap->tx_desc_len = sizeof(struct ar9003_txc);
1679 pCap->txs_len = sizeof(struct ar9003_txs);
1680 if (!ah->config.paprd_disable &&
1681 ah->eep_ops->get_eeprom(ah, EEP_PAPRD))
1682 pCap->hw_caps |= ATH9K_HW_CAP_PAPRD;
1684 pCap->tx_desc_len = sizeof(struct ath_desc);
1685 if (AR_SREV_9280_20(ah) &&
1686 ((ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV) <=
1687 AR5416_EEP_MINOR_VER_16) ||
1688 ah->eep_ops->get_eeprom(ah, EEP_FSTCLK_5G)))
1689 pCap->hw_caps |= ATH9K_HW_CAP_FASTCLOCK;
1692 if (AR_SREV_9300_20_OR_LATER(ah))
1693 pCap->hw_caps |= ATH9K_HW_CAP_RAC_SUPPORTED;
1695 if (AR_SREV_9300_20_OR_LATER(ah))
1696 ah->ent_mode = REG_READ(ah, AR_ENT_OTP);
1698 if (AR_SREV_9287_11_OR_LATER(ah) || AR_SREV_9271(ah))
1699 pCap->hw_caps |= ATH9K_HW_CAP_SGI_20;
1701 if (AR_SREV_9285(ah))
1702 if (ah->eep_ops->get_eeprom(ah, EEP_MODAL_VER) >= 3) {
1704 ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1);
1705 if ((ant_div_ctl1 & 0x1) && ((ant_div_ctl1 >> 3) & 0x1))
1706 pCap->hw_caps |= ATH9K_HW_CAP_ANT_DIV_COMB;
1708 if (AR_SREV_9300_20_OR_LATER(ah)) {
1709 if (ah->eep_ops->get_eeprom(ah, EEP_CHAIN_MASK_REDUCE))
1710 pCap->hw_caps |= ATH9K_HW_CAP_APM;
1714 if (AR_SREV_9485(ah)) {
1715 ant_div_ctl1 = ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1);
1717 * enable the diversity-combining algorithm only when
1718 * both enable_lna_div and enable_fast_div are set
1719 * Table for Diversity
1720 * ant_div_alt_lnaconf bit 0-1
1721 * ant_div_main_lnaconf bit 2-3
1722 * ant_div_alt_gaintb bit 4
1723 * ant_div_main_gaintb bit 5
1724 * enable_ant_div_lnadiv bit 6
1725 * enable_ant_fast_div bit 7
1727 if ((ant_div_ctl1 >> 0x6) == 0x3)
1728 pCap->hw_caps |= ATH9K_HW_CAP_ANT_DIV_COMB;
1731 if (AR_SREV_9485_10(ah)) {
1732 pCap->pcie_lcr_extsync_en = 1;
1733 pCap->pcie_lcr_offset = 0x80;
1736 tx_chainmask = pCap->tx_chainmask;
1737 rx_chainmask = pCap->rx_chainmask;
1738 while (tx_chainmask || rx_chainmask) {
1739 if (tx_chainmask & BIT(0))
1740 pCap->max_txchains++;
1741 if (rx_chainmask & BIT(0))
1742 pCap->max_rxchains++;
1751 /****************************/
1752 /* GPIO / RFKILL / Antennae */
1753 /****************************/
1755 static void ath9k_hw_gpio_cfg_output_mux(struct ath_hw *ah,
1759 u32 gpio_shift, tmp;
1762 addr = AR_GPIO_OUTPUT_MUX3;
1764 addr = AR_GPIO_OUTPUT_MUX2;
1766 addr = AR_GPIO_OUTPUT_MUX1;
1768 gpio_shift = (gpio % 6) * 5;
1770 if (AR_SREV_9280_20_OR_LATER(ah)
1771 || (addr != AR_GPIO_OUTPUT_MUX1)) {
1772 REG_RMW(ah, addr, (type << gpio_shift),
1773 (0x1f << gpio_shift));
1775 tmp = REG_READ(ah, addr);
1776 tmp = ((tmp & 0x1F0) << 1) | (tmp & ~0x1F0);
1777 tmp &= ~(0x1f << gpio_shift);
1778 tmp |= (type << gpio_shift);
1779 REG_WRITE(ah, addr, tmp);
1783 void ath9k_hw_cfg_gpio_input(struct ath_hw *ah, u32 gpio)
1787 if (AR_DEVID_7010(ah)) {
1789 REG_RMW(ah, AR7010_GPIO_OE,
1790 (AR7010_GPIO_OE_AS_INPUT << gpio_shift),
1791 (AR7010_GPIO_OE_MASK << gpio_shift));
1795 gpio_shift = gpio << 1;
1798 (AR_GPIO_OE_OUT_DRV_NO << gpio_shift),
1799 (AR_GPIO_OE_OUT_DRV << gpio_shift));
1802 u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio)
1804 #define MS_REG_READ(x, y) \
1805 (MS(REG_READ(ah, AR_GPIO_IN_OUT), x##_GPIO_IN_VAL) & (AR_GPIO_BIT(y)))
1807 if (gpio >= ah->caps.num_gpio_pins)
1810 if (AR_DEVID_7010(ah)) {
1812 val = REG_READ(ah, AR7010_GPIO_IN);
1813 return (MS(val, AR7010_GPIO_IN_VAL) & AR_GPIO_BIT(gpio)) == 0;
1814 } else if (AR_SREV_9300_20_OR_LATER(ah))
1815 return (MS(REG_READ(ah, AR_GPIO_IN), AR9300_GPIO_IN_VAL) &
1816 AR_GPIO_BIT(gpio)) != 0;
1817 else if (AR_SREV_9271(ah))
1818 return MS_REG_READ(AR9271, gpio) != 0;
1819 else if (AR_SREV_9287_11_OR_LATER(ah))
1820 return MS_REG_READ(AR9287, gpio) != 0;
1821 else if (AR_SREV_9285_12_OR_LATER(ah))
1822 return MS_REG_READ(AR9285, gpio) != 0;
1823 else if (AR_SREV_9280_20_OR_LATER(ah))
1824 return MS_REG_READ(AR928X, gpio) != 0;
1826 return MS_REG_READ(AR, gpio) != 0;
1829 void ath9k_hw_cfg_output(struct ath_hw *ah, u32 gpio,
1834 if (AR_DEVID_7010(ah)) {
1836 REG_RMW(ah, AR7010_GPIO_OE,
1837 (AR7010_GPIO_OE_AS_OUTPUT << gpio_shift),
1838 (AR7010_GPIO_OE_MASK << gpio_shift));
1842 ath9k_hw_gpio_cfg_output_mux(ah, gpio, ah_signal_type);
1843 gpio_shift = 2 * gpio;
1846 (AR_GPIO_OE_OUT_DRV_ALL << gpio_shift),
1847 (AR_GPIO_OE_OUT_DRV << gpio_shift));
1850 void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val)
1852 if (AR_DEVID_7010(ah)) {
1854 REG_RMW(ah, AR7010_GPIO_OUT, ((val&1) << gpio),
1859 if (AR_SREV_9271(ah))
1862 REG_RMW(ah, AR_GPIO_IN_OUT, ((val & 1) << gpio),
1866 u32 ath9k_hw_getdefantenna(struct ath_hw *ah)
1868 return REG_READ(ah, AR_DEF_ANTENNA) & 0x7;
1871 void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna)
1873 REG_WRITE(ah, AR_DEF_ANTENNA, (antenna & 0x7));
1876 /*********************/
1877 /* General Operation */
1878 /*********************/
1880 u32 ath9k_hw_getrxfilter(struct ath_hw *ah)
1882 u32 bits = REG_READ(ah, AR_RX_FILTER);
1883 u32 phybits = REG_READ(ah, AR_PHY_ERR);
1885 if (phybits & AR_PHY_ERR_RADAR)
1886 bits |= ATH9K_RX_FILTER_PHYRADAR;
1887 if (phybits & (AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING))
1888 bits |= ATH9K_RX_FILTER_PHYERR;
1893 void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits)
1897 ENABLE_REGWRITE_BUFFER(ah);
1899 REG_WRITE(ah, AR_RX_FILTER, bits);
1902 if (bits & ATH9K_RX_FILTER_PHYRADAR)
1903 phybits |= AR_PHY_ERR_RADAR;
1904 if (bits & ATH9K_RX_FILTER_PHYERR)
1905 phybits |= AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING;
1906 REG_WRITE(ah, AR_PHY_ERR, phybits);
1909 REG_SET_BIT(ah, AR_RXCFG, AR_RXCFG_ZLFDMA);
1911 REG_CLR_BIT(ah, AR_RXCFG, AR_RXCFG_ZLFDMA);
1913 REGWRITE_BUFFER_FLUSH(ah);
1916 int ath9k_hw_phy_disable(struct ath_hw *ah)
1918 if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM))
1921 ath9k_hw_init_pll(ah, NULL);
1925 int ath9k_hw_disable(struct ath_hw *ah)
1927 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
1930 if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_COLD))
1933 ath9k_hw_init_pll(ah, NULL);
1937 void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, int test)
1939 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
1940 struct ath9k_channel *chan = ah->curchan;
1941 struct net80211_channel *channel = chan->chan;
1943 regulatory->power_limit = min(limit, (u32) MAX_RATE_POWER);
1945 ah->eep_ops->set_txpower(ah, chan,
1946 ath9k_regd_get_ctl(regulatory, chan),
1948 channel->maxpower * 2,
1949 min((u32) MAX_RATE_POWER,
1950 (u32) regulatory->power_limit), test);
1953 void ath9k_hw_setopmode(struct ath_hw *ah)
1955 ath9k_hw_set_operating_mode(ah);
1958 void ath9k_hw_setmcastfilter(struct ath_hw *ah, u32 filter0, u32 filter1)
1960 REG_WRITE(ah, AR_MCAST_FIL0, filter0);
1961 REG_WRITE(ah, AR_MCAST_FIL1, filter1);
1964 void ath9k_hw_write_associd(struct ath_hw *ah)
1966 struct ath_common *common = ath9k_hw_common(ah);
1968 REG_WRITE(ah, AR_BSS_ID0, get_unaligned_le32(common->curbssid));
1969 REG_WRITE(ah, AR_BSS_ID1, get_unaligned_le16(common->curbssid + 4) |
1970 ((common->curaid & 0x3fff) << AR_BSS_ID1_AID_S));
1973 void ath9k_hw_set11nmac2040(struct ath_hw *ah)
1979 REG_WRITE(ah, AR_2040_MODE, macmode);
1985 } ath_mac_bb_names[] = {
1986 /* Devices with external radios */
1987 { AR_SREV_VERSION_5416_PCI, "5416" },
1988 { AR_SREV_VERSION_5416_PCIE, "5418" },
1989 { AR_SREV_VERSION_9100, "9100" },
1990 { AR_SREV_VERSION_9160, "9160" },
1991 /* Single-chip solutions */
1992 { AR_SREV_VERSION_9280, "9280" },
1993 { AR_SREV_VERSION_9285, "9285" },
1994 { AR_SREV_VERSION_9287, "9287" },
1995 { AR_SREV_VERSION_9271, "9271" },
1996 { AR_SREV_VERSION_9300, "9300" },
1997 { AR_SREV_VERSION_9485, "9485" },
2000 /* For devices with external radios */
2004 } ath_rf_names[] = {
2006 { AR_RAD5133_SREV_MAJOR, "5133" },
2007 { AR_RAD5122_SREV_MAJOR, "5122" },
2008 { AR_RAD2133_SREV_MAJOR, "2133" },
2009 { AR_RAD2122_SREV_MAJOR, "2122" }
2013 * Return the MAC/BB name. "????" is returned if the MAC/BB is unknown.
2015 static const char *ath9k_hw_mac_bb_name(u32 mac_bb_version)
2019 for (i=0; i<ARRAY_SIZE(ath_mac_bb_names); i++) {
2020 if (ath_mac_bb_names[i].version == mac_bb_version) {
2021 return ath_mac_bb_names[i].name;
2029 * Return the RF name. "????" is returned if the RF is unknown.
2030 * Used for devices with external radios.
2032 static const char *ath9k_hw_rf_name(u16 rf_version)
2036 for (i=0; i<ARRAY_SIZE(ath_rf_names); i++) {
2037 if (ath_rf_names[i].version == rf_version) {
2038 return ath_rf_names[i].name;
2045 void ath9k_hw_name(struct ath_hw *ah, char *hw_name, size_t len)
2049 /* chipsets >= AR9280 are single-chip */
2050 if (AR_SREV_9280_20_OR_LATER(ah)) {
2051 used = snprintf(hw_name, len,
2052 "Atheros AR%s Rev:%x",
2053 ath9k_hw_mac_bb_name(ah->hw_version.macVersion),
2054 ah->hw_version.macRev);
2057 used = snprintf(hw_name, len,
2058 "Atheros AR%s MAC/BB Rev:%x AR%s RF Rev:%x",
2059 ath9k_hw_mac_bb_name(ah->hw_version.macVersion),
2060 ah->hw_version.macRev,
2061 ath9k_hw_rf_name((ah->hw_version.analog5GhzRev &
2062 AR_RADIO_SREV_MAJOR)),
2063 ah->hw_version.phyRev);
2066 hw_name[used] = '\0';