This source file includes following definitions.
- ath5k_hw_get_frame_duration
- ath5k_hw_get_default_slottime
- ath5k_hw_get_default_sifs
- ath5k_hw_update_mib_counters
- ath5k_hw_write_rate_duration
- ath5k_hw_set_ack_timeout
- ath5k_hw_set_cts_timeout
- ath5k_hw_set_lladdr
- ath5k_hw_set_bssid
- ath5k_hw_set_bssid_mask
- ath5k_hw_set_mcast_filter
- ath5k_hw_get_rx_filter
- ath5k_hw_set_rx_filter
- ath5k_hw_get_tsf64
- ath5k_hw_set_tsf64
- ath5k_hw_reset_tsf
- ath5k_hw_init_beacon_timers
- ath5k_check_timer_win
- ath5k_hw_check_beacon_timers
- ath5k_hw_set_coverage_class
- ath5k_hw_start_rx_pcu
- ath5k_hw_stop_rx_pcu
- ath5k_hw_set_opmode
- ath5k_hw_pcu_init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 #include <asm/unaligned.h>
28
29 #include "ath5k.h"
30 #include "reg.h"
31 #include "debug.h"
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 static const unsigned int ack_rates_high[] =
83
84 { 0,
85 1,
86 1,
87 1,
88 4,
89 4,
90 6,
91 6,
92 8,
93 8,
94 8,
95 8 };
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112 int
113 ath5k_hw_get_frame_duration(struct ath5k_hw *ah, enum nl80211_band band,
114 int len, struct ieee80211_rate *rate, bool shortpre)
115 {
116 int sifs, preamble, plcp_bits, sym_time;
117 int bitrate, bits, symbols, symbol_bits;
118 int dur;
119
120
121 if (!ah->ah_bwmode) {
122 __le16 raw_dur = ieee80211_generic_frame_duration(ah->hw,
123 NULL, band, len, rate);
124
125
126 dur = le16_to_cpu(raw_dur);
127 if (shortpre)
128 dur -= 96;
129
130 return dur;
131 }
132
133 bitrate = rate->bitrate;
134 preamble = AR5K_INIT_OFDM_PREAMPLE_TIME;
135 plcp_bits = AR5K_INIT_OFDM_PLCP_BITS;
136 sym_time = AR5K_INIT_OFDM_SYMBOL_TIME;
137
138 switch (ah->ah_bwmode) {
139 case AR5K_BWMODE_40MHZ:
140 sifs = AR5K_INIT_SIFS_TURBO;
141 preamble = AR5K_INIT_OFDM_PREAMBLE_TIME_MIN;
142 break;
143 case AR5K_BWMODE_10MHZ:
144 sifs = AR5K_INIT_SIFS_HALF_RATE;
145 preamble *= 2;
146 sym_time *= 2;
147 bitrate = DIV_ROUND_UP(bitrate, 2);
148 break;
149 case AR5K_BWMODE_5MHZ:
150 sifs = AR5K_INIT_SIFS_QUARTER_RATE;
151 preamble *= 4;
152 sym_time *= 4;
153 bitrate = DIV_ROUND_UP(bitrate, 4);
154 break;
155 default:
156 sifs = AR5K_INIT_SIFS_DEFAULT_BG;
157 break;
158 }
159
160 bits = plcp_bits + (len << 3);
161
162 symbol_bits = bitrate * sym_time;
163 symbols = DIV_ROUND_UP(bits * 10, symbol_bits);
164
165 dur = sifs + preamble + (sym_time * symbols);
166
167 return dur;
168 }
169
170
171
172
173
174 unsigned int
175 ath5k_hw_get_default_slottime(struct ath5k_hw *ah)
176 {
177 struct ieee80211_channel *channel = ah->ah_current_channel;
178 unsigned int slot_time;
179
180 switch (ah->ah_bwmode) {
181 case AR5K_BWMODE_40MHZ:
182 slot_time = AR5K_INIT_SLOT_TIME_TURBO;
183 break;
184 case AR5K_BWMODE_10MHZ:
185 slot_time = AR5K_INIT_SLOT_TIME_HALF_RATE;
186 break;
187 case AR5K_BWMODE_5MHZ:
188 slot_time = AR5K_INIT_SLOT_TIME_QUARTER_RATE;
189 break;
190 case AR5K_BWMODE_DEFAULT:
191 default:
192 slot_time = AR5K_INIT_SLOT_TIME_DEFAULT;
193 if ((channel->hw_value == AR5K_MODE_11B) && !ah->ah_short_slot)
194 slot_time = AR5K_INIT_SLOT_TIME_B;
195 break;
196 }
197
198 return slot_time;
199 }
200
201
202
203
204
205 unsigned int
206 ath5k_hw_get_default_sifs(struct ath5k_hw *ah)
207 {
208 struct ieee80211_channel *channel = ah->ah_current_channel;
209 unsigned int sifs;
210
211 switch (ah->ah_bwmode) {
212 case AR5K_BWMODE_40MHZ:
213 sifs = AR5K_INIT_SIFS_TURBO;
214 break;
215 case AR5K_BWMODE_10MHZ:
216 sifs = AR5K_INIT_SIFS_HALF_RATE;
217 break;
218 case AR5K_BWMODE_5MHZ:
219 sifs = AR5K_INIT_SIFS_QUARTER_RATE;
220 break;
221 case AR5K_BWMODE_DEFAULT:
222 default:
223 sifs = AR5K_INIT_SIFS_DEFAULT_BG;
224 if (channel->band == NL80211_BAND_5GHZ)
225 sifs = AR5K_INIT_SIFS_DEFAULT_A;
226 break;
227 }
228
229 return sifs;
230 }
231
232
233
234
235
236
237
238
239
240
241
242 void
243 ath5k_hw_update_mib_counters(struct ath5k_hw *ah)
244 {
245 struct ath5k_statistics *stats = &ah->stats;
246
247
248 stats->ack_fail += ath5k_hw_reg_read(ah, AR5K_ACK_FAIL);
249 stats->rts_fail += ath5k_hw_reg_read(ah, AR5K_RTS_FAIL);
250 stats->rts_ok += ath5k_hw_reg_read(ah, AR5K_RTS_OK);
251 stats->fcs_error += ath5k_hw_reg_read(ah, AR5K_FCS_FAIL);
252 stats->beacons += ath5k_hw_reg_read(ah, AR5K_BEACON_CNT);
253 }
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276 static inline void
277 ath5k_hw_write_rate_duration(struct ath5k_hw *ah)
278 {
279 struct ieee80211_rate *rate;
280 unsigned int i;
281
282 u8 band = NL80211_BAND_2GHZ;
283
284
285 for (i = 0; i < ah->sbands[band].n_bitrates; i++) {
286 u32 reg;
287 u16 tx_time;
288
289 if (ah->ah_ack_bitrate_high)
290 rate = &ah->sbands[band].bitrates[ack_rates_high[i]];
291
292 else if (i < 4)
293 rate = &ah->sbands[band].bitrates[0];
294
295 else
296 rate = &ah->sbands[band].bitrates[4];
297
298
299 reg = AR5K_RATE_DUR(rate->hw_value);
300
301
302
303
304
305
306
307 tx_time = ath5k_hw_get_frame_duration(ah, band, 10,
308 rate, false);
309
310 ath5k_hw_reg_write(ah, tx_time, reg);
311
312 if (!(rate->flags & IEEE80211_RATE_SHORT_PREAMBLE))
313 continue;
314
315 tx_time = ath5k_hw_get_frame_duration(ah, band, 10, rate, true);
316 ath5k_hw_reg_write(ah, tx_time,
317 reg + (AR5K_SET_SHORT_PREAMBLE << 2));
318 }
319 }
320
321
322
323
324
325
326 static int
327 ath5k_hw_set_ack_timeout(struct ath5k_hw *ah, unsigned int timeout)
328 {
329 if (ath5k_hw_clocktoh(ah, AR5K_REG_MS(0xffffffff, AR5K_TIME_OUT_ACK))
330 <= timeout)
331 return -EINVAL;
332
333 AR5K_REG_WRITE_BITS(ah, AR5K_TIME_OUT, AR5K_TIME_OUT_ACK,
334 ath5k_hw_htoclock(ah, timeout));
335
336 return 0;
337 }
338
339
340
341
342
343
344 static int
345 ath5k_hw_set_cts_timeout(struct ath5k_hw *ah, unsigned int timeout)
346 {
347 if (ath5k_hw_clocktoh(ah, AR5K_REG_MS(0xffffffff, AR5K_TIME_OUT_CTS))
348 <= timeout)
349 return -EINVAL;
350
351 AR5K_REG_WRITE_BITS(ah, AR5K_TIME_OUT, AR5K_TIME_OUT_CTS,
352 ath5k_hw_htoclock(ah, timeout));
353
354 return 0;
355 }
356
357
358
359
360
361
362
363
364
365
366
367
368
369 int
370 ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac)
371 {
372 struct ath_common *common = ath5k_hw_common(ah);
373 u32 low_id, high_id;
374 u32 pcu_reg;
375
376
377 memcpy(common->macaddr, mac, ETH_ALEN);
378
379 pcu_reg = ath5k_hw_reg_read(ah, AR5K_STA_ID1) & 0xffff0000;
380
381 low_id = get_unaligned_le32(mac);
382 high_id = get_unaligned_le16(mac + 4);
383
384 ath5k_hw_reg_write(ah, low_id, AR5K_STA_ID0);
385 ath5k_hw_reg_write(ah, pcu_reg | high_id, AR5K_STA_ID1);
386
387 return 0;
388 }
389
390
391
392
393
394
395
396
397 void
398 ath5k_hw_set_bssid(struct ath5k_hw *ah)
399 {
400 struct ath_common *common = ath5k_hw_common(ah);
401 u16 tim_offset = 0;
402
403
404
405
406 if (ah->ah_version == AR5K_AR5212)
407 ath_hw_setbssidmask(common);
408
409
410
411
412 ath5k_hw_reg_write(ah,
413 get_unaligned_le32(common->curbssid),
414 AR5K_BSS_ID0);
415 ath5k_hw_reg_write(ah,
416 get_unaligned_le16(common->curbssid + 4) |
417 ((common->curaid & 0x3fff) << AR5K_BSS_ID1_AID_S),
418 AR5K_BSS_ID1);
419
420 if (common->curaid == 0) {
421 ath5k_hw_disable_pspoll(ah);
422 return;
423 }
424
425 AR5K_REG_WRITE_BITS(ah, AR5K_BEACON, AR5K_BEACON_TIM,
426 tim_offset ? tim_offset + 4 : 0);
427
428 ath5k_hw_enable_pspoll(ah, NULL, 0);
429 }
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446 void
447 ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask)
448 {
449 struct ath_common *common = ath5k_hw_common(ah);
450
451
452
453 memcpy(common->bssidmask, mask, ETH_ALEN);
454 if (ah->ah_version == AR5K_AR5212)
455 ath_hw_setbssidmask(common);
456 }
457
458
459
460
461
462
463
464 void
465 ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1)
466 {
467 ath5k_hw_reg_write(ah, filter0, AR5K_MCAST_FILTER0);
468 ath5k_hw_reg_write(ah, filter1, AR5K_MCAST_FILTER1);
469 }
470
471
472
473
474
475
476
477
478
479
480
481 u32
482 ath5k_hw_get_rx_filter(struct ath5k_hw *ah)
483 {
484 u32 data, filter = 0;
485
486 filter = ath5k_hw_reg_read(ah, AR5K_RX_FILTER);
487
488
489 if (ah->ah_version == AR5K_AR5212) {
490 data = ath5k_hw_reg_read(ah, AR5K_PHY_ERR_FIL);
491
492 if (data & AR5K_PHY_ERR_FIL_RADAR)
493 filter |= AR5K_RX_FILTER_RADARERR;
494 if (data & (AR5K_PHY_ERR_FIL_OFDM | AR5K_PHY_ERR_FIL_CCK))
495 filter |= AR5K_RX_FILTER_PHYERR;
496 }
497
498 return filter;
499 }
500
501
502
503
504
505
506
507
508
509
510 void
511 ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter)
512 {
513 u32 data = 0;
514
515
516 if (ah->ah_version == AR5K_AR5212) {
517 if (filter & AR5K_RX_FILTER_RADARERR)
518 data |= AR5K_PHY_ERR_FIL_RADAR;
519 if (filter & AR5K_RX_FILTER_PHYERR)
520 data |= AR5K_PHY_ERR_FIL_OFDM | AR5K_PHY_ERR_FIL_CCK;
521 }
522
523
524
525
526 if (ah->ah_version == AR5K_AR5210 &&
527 (filter & AR5K_RX_FILTER_RADARERR)) {
528 filter &= ~AR5K_RX_FILTER_RADARERR;
529 filter |= AR5K_RX_FILTER_PROM;
530 }
531
532
533 if (data)
534 AR5K_REG_ENABLE_BITS(ah, AR5K_RXCFG, AR5K_RXCFG_ZLFDMA);
535 else
536 AR5K_REG_DISABLE_BITS(ah, AR5K_RXCFG, AR5K_RXCFG_ZLFDMA);
537
538
539 ath5k_hw_reg_write(ah, filter & 0xff, AR5K_RX_FILTER);
540
541
542 if (ah->ah_version == AR5K_AR5212)
543 ath5k_hw_reg_write(ah, data, AR5K_PHY_ERR_FIL);
544
545 }
546
547
548
549
550
551
552 #define ATH5K_MAX_TSF_READ 10
553
554
555
556
557
558
559
560 u64
561 ath5k_hw_get_tsf64(struct ath5k_hw *ah)
562 {
563 u32 tsf_lower, tsf_upper1, tsf_upper2;
564 int i;
565 unsigned long flags;
566
567
568 local_irq_save(flags);
569
570
571
572
573
574
575
576
577
578
579
580
581
582 tsf_upper1 = ath5k_hw_reg_read(ah, AR5K_TSF_U32);
583 for (i = 0; i < ATH5K_MAX_TSF_READ; i++) {
584 tsf_lower = ath5k_hw_reg_read(ah, AR5K_TSF_L32);
585 tsf_upper2 = ath5k_hw_reg_read(ah, AR5K_TSF_U32);
586 if (tsf_upper2 == tsf_upper1)
587 break;
588 tsf_upper1 = tsf_upper2;
589 }
590
591 local_irq_restore(flags);
592
593 WARN_ON(i == ATH5K_MAX_TSF_READ);
594
595 return ((u64)tsf_upper1 << 32) | tsf_lower;
596 }
597
598 #undef ATH5K_MAX_TSF_READ
599
600
601
602
603
604
605
606
607 void
608 ath5k_hw_set_tsf64(struct ath5k_hw *ah, u64 tsf64)
609 {
610 ath5k_hw_reg_write(ah, tsf64 & 0xffffffff, AR5K_TSF_L32);
611 ath5k_hw_reg_write(ah, (tsf64 >> 32) & 0xffffffff, AR5K_TSF_U32);
612 }
613
614
615
616
617
618
619
620 void
621 ath5k_hw_reset_tsf(struct ath5k_hw *ah)
622 {
623 u32 val;
624
625 val = ath5k_hw_reg_read(ah, AR5K_BEACON) | AR5K_BEACON_RESET_TSF;
626
627
628
629
630
631
632
633 ath5k_hw_reg_write(ah, val, AR5K_BEACON);
634 ath5k_hw_reg_write(ah, val, AR5K_BEACON);
635 }
636
637
638
639
640
641
642
643
644
645
646 void
647 ath5k_hw_init_beacon_timers(struct ath5k_hw *ah, u32 next_beacon, u32 interval)
648 {
649 u32 timer1, timer2, timer3;
650
651
652
653
654 switch (ah->opmode) {
655 case NL80211_IFTYPE_MONITOR:
656 case NL80211_IFTYPE_STATION:
657
658
659
660
661 if (ah->ah_version == AR5K_AR5210) {
662 timer1 = 0xffffffff;
663 timer2 = 0xffffffff;
664 } else {
665 timer1 = 0x0000ffff;
666 timer2 = 0x0007ffff;
667 }
668
669 AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1, AR5K_STA_ID1_PCF);
670 break;
671 case NL80211_IFTYPE_ADHOC:
672 AR5K_REG_ENABLE_BITS(ah, AR5K_TXCFG, AR5K_TXCFG_ADHOC_BCN_ATIM);
673
674 default:
675
676
677
678 timer1 = (next_beacon - AR5K_TUNE_DMA_BEACON_RESP) << 3;
679 timer2 = (next_beacon - AR5K_TUNE_SW_BEACON_RESP) << 3;
680 break;
681 }
682
683
684
685
686 timer3 = next_beacon + 1;
687
688
689
690
691
692 if (ah->opmode == NL80211_IFTYPE_AP ||
693 ah->opmode == NL80211_IFTYPE_MESH_POINT)
694 ath5k_hw_reg_write(ah, 0, AR5K_TIMER0);
695
696 ath5k_hw_reg_write(ah, next_beacon, AR5K_TIMER0);
697 ath5k_hw_reg_write(ah, timer1, AR5K_TIMER1);
698 ath5k_hw_reg_write(ah, timer2, AR5K_TIMER2);
699 ath5k_hw_reg_write(ah, timer3, AR5K_TIMER3);
700
701
702 if (interval & AR5K_BEACON_RESET_TSF)
703 ath5k_hw_reset_tsf(ah);
704
705 ath5k_hw_reg_write(ah, interval & (AR5K_BEACON_PERIOD |
706 AR5K_BEACON_ENABLE),
707 AR5K_BEACON);
708
709
710
711
712
713
714 if (ah->ah_version == AR5K_AR5210)
715 ath5k_hw_reg_write(ah, AR5K_ISR_BMISS, AR5K_ISR);
716 else
717 ath5k_hw_reg_write(ah, AR5K_ISR_BMISS, AR5K_PISR);
718
719
720
721
722 AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1, AR5K_STA_ID1_PWR_SV);
723
724 }
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739 static inline bool
740 ath5k_check_timer_win(int a, int b, int window, int intval)
741 {
742
743
744
745
746
747
748 if ((b - a == window) ||
749 (a - b == intval - window) ||
750 ((a | 0x10000) - b == intval - window) ||
751 ((b | 0x10000) - a == window))
752 return true;
753 return false;
754 }
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795 bool
796 ath5k_hw_check_beacon_timers(struct ath5k_hw *ah, int intval)
797 {
798 unsigned int nbtt, atim, dma;
799
800 nbtt = ath5k_hw_reg_read(ah, AR5K_TIMER0);
801 atim = ath5k_hw_reg_read(ah, AR5K_TIMER3);
802 dma = ath5k_hw_reg_read(ah, AR5K_TIMER1) >> 3;
803
804
805
806
807
808 if (ath5k_check_timer_win(nbtt, atim, 1, intval) &&
809 ath5k_check_timer_win(dma, nbtt, AR5K_TUNE_DMA_BEACON_RESP,
810 intval))
811 return true;
812 return false;
813 }
814
815
816
817
818
819
820
821
822 void
823 ath5k_hw_set_coverage_class(struct ath5k_hw *ah, u8 coverage_class)
824 {
825
826 int slot_time = ath5k_hw_get_default_slottime(ah) + 3 * coverage_class;
827 int ack_timeout = ath5k_hw_get_default_sifs(ah) + slot_time;
828 int cts_timeout = ack_timeout;
829
830 ath5k_hw_set_ifs_intervals(ah, slot_time);
831 ath5k_hw_set_ack_timeout(ah, ack_timeout);
832 ath5k_hw_set_cts_timeout(ah, cts_timeout);
833
834 ah->ah_coverage_class = coverage_class;
835 }
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850 void
851 ath5k_hw_start_rx_pcu(struct ath5k_hw *ah)
852 {
853 AR5K_REG_DISABLE_BITS(ah, AR5K_DIAG_SW, AR5K_DIAG_SW_DIS_RX);
854 }
855
856
857
858
859
860
861
862 void
863 ath5k_hw_stop_rx_pcu(struct ath5k_hw *ah)
864 {
865 AR5K_REG_ENABLE_BITS(ah, AR5K_DIAG_SW, AR5K_DIAG_SW_DIS_RX);
866 }
867
868
869
870
871
872
873
874
875 int
876 ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype op_mode)
877 {
878 struct ath_common *common = ath5k_hw_common(ah);
879 u32 pcu_reg, beacon_reg, low_id, high_id;
880
881 ATH5K_DBG(ah, ATH5K_DEBUG_MODE, "mode %d\n", op_mode);
882
883
884 pcu_reg = ath5k_hw_reg_read(ah, AR5K_STA_ID1) & 0xffff0000;
885 pcu_reg &= ~(AR5K_STA_ID1_ADHOC | AR5K_STA_ID1_AP
886 | AR5K_STA_ID1_KEYSRCH_MODE
887 | (ah->ah_version == AR5K_AR5210 ?
888 (AR5K_STA_ID1_PWR_SV | AR5K_STA_ID1_NO_PSPOLL) : 0));
889
890 beacon_reg = 0;
891
892 switch (op_mode) {
893 case NL80211_IFTYPE_ADHOC:
894 pcu_reg |= AR5K_STA_ID1_ADHOC | AR5K_STA_ID1_KEYSRCH_MODE;
895 beacon_reg |= AR5K_BCR_ADHOC;
896 if (ah->ah_version == AR5K_AR5210)
897 pcu_reg |= AR5K_STA_ID1_NO_PSPOLL;
898 else
899 AR5K_REG_ENABLE_BITS(ah, AR5K_CFG, AR5K_CFG_IBSS);
900 break;
901
902 case NL80211_IFTYPE_AP:
903 case NL80211_IFTYPE_MESH_POINT:
904 pcu_reg |= AR5K_STA_ID1_AP | AR5K_STA_ID1_KEYSRCH_MODE;
905 beacon_reg |= AR5K_BCR_AP;
906 if (ah->ah_version == AR5K_AR5210)
907 pcu_reg |= AR5K_STA_ID1_NO_PSPOLL;
908 else
909 AR5K_REG_DISABLE_BITS(ah, AR5K_CFG, AR5K_CFG_IBSS);
910 break;
911
912 case NL80211_IFTYPE_STATION:
913 pcu_reg |= AR5K_STA_ID1_KEYSRCH_MODE
914 | (ah->ah_version == AR5K_AR5210 ?
915 AR5K_STA_ID1_PWR_SV : 0);
916
917 case NL80211_IFTYPE_MONITOR:
918 pcu_reg |= AR5K_STA_ID1_KEYSRCH_MODE
919 | (ah->ah_version == AR5K_AR5210 ?
920 AR5K_STA_ID1_NO_PSPOLL : 0);
921 break;
922
923 default:
924 return -EINVAL;
925 }
926
927
928
929
930 low_id = get_unaligned_le32(common->macaddr);
931 high_id = get_unaligned_le16(common->macaddr + 4);
932 ath5k_hw_reg_write(ah, low_id, AR5K_STA_ID0);
933 ath5k_hw_reg_write(ah, pcu_reg | high_id, AR5K_STA_ID1);
934
935
936
937
938 if (ah->ah_version == AR5K_AR5210)
939 ath5k_hw_reg_write(ah, beacon_reg, AR5K_BCR);
940
941 return 0;
942 }
943
944
945
946
947
948
949
950
951
952
953 void
954 ath5k_hw_pcu_init(struct ath5k_hw *ah, enum nl80211_iftype op_mode)
955 {
956
957 ath5k_hw_set_bssid(ah);
958
959
960 ath5k_hw_set_opmode(ah, op_mode);
961
962
963
964
965
966 if (ah->ah_version == AR5K_AR5212 &&
967 ah->nvifs)
968 ath5k_hw_write_rate_duration(ah);
969
970
971
972
973
974
975
976
977
978 ath5k_hw_reg_write(ah, (AR5K_TUNE_RSSI_THRES |
979 AR5K_TUNE_BMISS_THRES <<
980 AR5K_RSSI_THR_BMISS_S),
981 AR5K_RSSI_THR);
982
983
984 if (ah->ah_mac_srev >= AR5K_SREV_AR2413) {
985 ath5k_hw_reg_write(ah, 0x000100aa, AR5K_MIC_QOS_CTL);
986 ath5k_hw_reg_write(ah, 0x00003210, AR5K_MIC_QOS_SEL);
987 }
988
989
990 if (ah->ah_version == AR5K_AR5212) {
991 ath5k_hw_reg_write(ah,
992 AR5K_REG_SM(2, AR5K_QOS_NOACK_2BIT_VALUES) |
993 AR5K_REG_SM(5, AR5K_QOS_NOACK_BIT_OFFSET) |
994 AR5K_REG_SM(0, AR5K_QOS_NOACK_BYTE_OFFSET),
995 AR5K_QOS_NOACK);
996 }
997
998
999 if (ah->ah_coverage_class > 0)
1000 ath5k_hw_set_coverage_class(ah, ah->ah_coverage_class);
1001
1002
1003 if (ah->ah_version == AR5K_AR5212) {
1004 u32 val = AR5K_STA_ID1_BASE_RATE_11B | AR5K_STA_ID1_ACKCTS_6MB;
1005 if (ah->ah_ack_bitrate_high)
1006 AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1, val);
1007 else
1008 AR5K_REG_ENABLE_BITS(ah, AR5K_STA_ID1, val);
1009 }
1010 return;
1011 }