Lines Matching +full:mac +full:-
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
78 #define RF_LO_WRITE(mac, lo) bwi_rf_lo_write((mac), (lo)) argument
81 (ieee80211_ieee2mhz((chan), IEEE80211_CHAN_2GHZ) - 2400)
106 #define SAVE_RF_REG(mac, regs, n) (regs)->rf_##n = RF_READ((mac), 0x##n) argument
107 #define RESTORE_RF_REG(mac, regs, n) RF_WRITE((mac), 0x##n, (regs)->rf_##n) argument
109 #define SAVE_PHY_REG(mac, regs, n) (regs)->phy_##n = PHY_READ((mac), 0x##n) argument
110 #define RESTORE_PHY_REG(mac, regs, n) PHY_WRITE((mac), 0x##n, (regs)->phy_##n) argument
159 bwi_nrssi_11g(struct bwi_mac *mac) in bwi_nrssi_11g() argument
165 val = (int16_t)__SHIFTOUT(PHY_READ(mac, 0x47f), NRSSI_11G_MASK); in bwi_nrssi_11g()
167 val -= 64; in bwi_nrssi_11g()
174 bwi_get_rf_lo(struct bwi_mac *mac, uint16_t rf_atten, uint16_t bbp_atten) in bwi_get_rf_lo() argument
181 return &mac->mac_rf.rf_lo[n]; in bwi_get_rf_lo()
185 bwi_rf_lo_isused(struct bwi_mac *mac, const struct bwi_rf_lo *lo) in bwi_rf_lo_isused() argument
187 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_lo_isused()
190 idx = lo - rf->rf_lo; in bwi_rf_lo_isused()
193 return isset(rf->rf_lo_used, idx); in bwi_rf_lo_isused()
197 bwi_rf_write(struct bwi_mac *mac, uint16_t ctrl, uint16_t data) in bwi_rf_write() argument
199 struct bwi_softc *sc = mac->mac_sc; in bwi_rf_write()
206 bwi_rf_read(struct bwi_mac *mac, uint16_t ctrl) in bwi_rf_read() argument
208 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_read()
209 struct bwi_softc *sc = mac->mac_sc; in bwi_rf_read()
211 ctrl |= rf->rf_ctrl_rd; in bwi_rf_read()
212 if (rf->rf_ctrl_adj) { in bwi_rf_read()
225 bwi_rf_attach(struct bwi_mac *mac) in bwi_rf_attach() argument
227 struct bwi_softc *sc = mac->mac_sc; in bwi_rf_attach()
228 struct bwi_phy *phy = &mac->mac_phy; in bwi_rf_attach()
229 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_attach()
236 if (sc->sc_bbp_id == BWI_BBPID_BCM4317) { in bwi_rf_attach()
242 if (sc->sc_bbp_rev == 0) in bwi_rf_attach()
244 else if (sc->sc_bbp_rev == 1) in bwi_rf_attach()
262 device_printf(sc->sc_dev, "RF: manu 0x%03x, type 0x%04x, rev %u\n", in bwi_rf_attach()
268 rf->rf_ctrl_rd = 0; in bwi_rf_attach()
269 rf->rf_ctrl_adj = 0; in bwi_rf_attach()
270 switch (phy->phy_mode) { in bwi_rf_attach()
275 device_printf(sc->sc_dev, "only BCM2060 rev 1 RF " in bwi_rf_attach()
279 rf->rf_ctrl_rd = BWI_RF_CTRL_RD_11A; in bwi_rf_attach()
280 rf->rf_on = bwi_rf_on_11a; in bwi_rf_attach()
281 rf->rf_off = bwi_rf_off_11a; in bwi_rf_attach()
282 rf->rf_calc_rssi = bwi_rf_calc_rssi_bcm2060; in bwi_rf_attach()
283 rf->rf_calc_noise = bwi_rf_calc_noise_bcm2060; in bwi_rf_attach()
287 rf->rf_ctrl_rd = BWI_RF_CTRL_RD_11BG; in bwi_rf_attach()
288 rf->rf_calc_rssi = bwi_rf_calc_rssi_bcm2050; in bwi_rf_attach()
289 rf->rf_calc_noise = bwi_rf_calc_noise_bcm2050; in bwi_rf_attach()
291 rf->rf_ctrl_adj = 1; in bwi_rf_attach()
292 rf->rf_calc_rssi = bwi_rf_calc_rssi_bcm2053; in bwi_rf_attach()
293 rf->rf_calc_noise = bwi_rf_calc_noise_bcm2053; in bwi_rf_attach()
295 device_printf(sc->sc_dev, "only BCM2050/BCM2053 RF " in bwi_rf_attach()
299 rf->rf_on = bwi_rf_on_11bg; in bwi_rf_attach()
300 rf->rf_off = bwi_rf_off_11bg; in bwi_rf_attach()
301 rf->rf_calc_nrssi_slope = bwi_rf_calc_nrssi_slope_11b; in bwi_rf_attach()
302 rf->rf_set_nrssi_thr = bwi_rf_set_nrssi_thr_11b; in bwi_rf_attach()
303 if (phy->phy_rev == 6) in bwi_rf_attach()
304 rf->rf_lo_update = bwi_rf_lo_update_11g; in bwi_rf_attach()
306 rf->rf_lo_update = bwi_rf_lo_update_11b; in bwi_rf_attach()
310 device_printf(sc->sc_dev, "only BCM2050 RF " in bwi_rf_attach()
314 rf->rf_ctrl_rd = BWI_RF_CTRL_RD_11BG; in bwi_rf_attach()
315 rf->rf_on = bwi_rf_on_11bg; in bwi_rf_attach()
316 if (mac->mac_rev >= 5) in bwi_rf_attach()
317 rf->rf_off = bwi_rf_off_11g_rev5; in bwi_rf_attach()
319 rf->rf_off = bwi_rf_off_11bg; in bwi_rf_attach()
320 rf->rf_calc_nrssi_slope = bwi_rf_calc_nrssi_slope_11g; in bwi_rf_attach()
321 rf->rf_set_nrssi_thr = bwi_rf_set_nrssi_thr_11g; in bwi_rf_attach()
322 rf->rf_calc_rssi = bwi_rf_calc_rssi_bcm2050; in bwi_rf_attach()
323 rf->rf_calc_noise = bwi_rf_calc_noise_bcm2050; in bwi_rf_attach()
324 rf->rf_lo_update = bwi_rf_lo_update_11g; in bwi_rf_attach()
327 device_printf(sc->sc_dev, "unsupported PHY mode\n"); in bwi_rf_attach()
331 rf->rf_type = type; in bwi_rf_attach()
332 rf->rf_rev = rev; in bwi_rf_attach()
333 rf->rf_manu = manu; in bwi_rf_attach()
334 rf->rf_curchan = IEEE80211_CHAN_ANY; in bwi_rf_attach()
335 rf->rf_ant_mode = BWI_ANT_MODE_AUTO; in bwi_rf_attach()
340 bwi_rf_set_chan(struct bwi_mac *mac, u_int chan, int work_around) in bwi_rf_set_chan() argument
342 struct bwi_softc *sc = mac->mac_sc; in bwi_rf_set_chan()
347 MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_CHAN, chan); in bwi_rf_set_chan()
352 bwi_rf_work_around(mac, chan); in bwi_rf_set_chan()
357 if (sc->sc_locale == BWI_SPROM_LOCALE_JAPAN) in bwi_rf_set_chan()
358 HFLAGS_CLRBITS(mac, BWI_HFLAG_NOT_JAPAN); in bwi_rf_set_chan()
360 HFLAGS_SETBITS(mac, BWI_HFLAG_NOT_JAPAN); in bwi_rf_set_chan()
367 mac->mac_rf.rf_curchan = chan; in bwi_rf_set_chan()
371 bwi_rf_get_gains(struct bwi_mac *mac) in bwi_rf_get_gains() argument
385 struct bwi_softc *sc = mac->mac_sc; in bwi_rf_get_gains()
386 struct bwi_phy *phy = &mac->mac_phy; in bwi_rf_get_gains()
387 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_get_gains()
397 save_phy[i] = PHY_READ(mac, save_phy_regs[i]); in bwi_rf_get_gains()
398 PHY_READ(mac, 0x2d); /* dummy read */ in bwi_rf_get_gains()
401 save_rf[i] = RF_READ(mac, save_rf_regs[i]); in bwi_rf_get_gains()
403 PHY_CLRBITS(mac, 0x429, 0xc000); in bwi_rf_get_gains()
404 PHY_SETBITS(mac, 0x1, 0x8000); in bwi_rf_get_gains()
406 PHY_SETBITS(mac, 0x811, 0x2); in bwi_rf_get_gains()
407 PHY_CLRBITS(mac, 0x812, 0x2); in bwi_rf_get_gains()
408 PHY_SETBITS(mac, 0x811, 0x1); in bwi_rf_get_gains()
409 PHY_CLRBITS(mac, 0x812, 0x1); in bwi_rf_get_gains()
411 PHY_SETBITS(mac, 0x814, 0x1); in bwi_rf_get_gains()
412 PHY_CLRBITS(mac, 0x815, 0x1); in bwi_rf_get_gains()
413 PHY_SETBITS(mac, 0x814, 0x2); in bwi_rf_get_gains()
414 PHY_CLRBITS(mac, 0x815, 0x2); in bwi_rf_get_gains()
416 PHY_SETBITS(mac, 0x811, 0xc); in bwi_rf_get_gains()
417 PHY_SETBITS(mac, 0x812, 0xc); in bwi_rf_get_gains()
418 PHY_SETBITS(mac, 0x811, 0x30); in bwi_rf_get_gains()
419 PHY_FILT_SETBITS(mac, 0x812, 0xffcf, 0x10); in bwi_rf_get_gains()
421 PHY_WRITE(mac, 0x5a, 0x780); in bwi_rf_get_gains()
422 PHY_WRITE(mac, 0x59, 0xc810); in bwi_rf_get_gains()
423 PHY_WRITE(mac, 0x58, 0xd); in bwi_rf_get_gains()
424 PHY_SETBITS(mac, 0xa, 0x2000); in bwi_rf_get_gains()
426 PHY_SETBITS(mac, 0x814, 0x4); in bwi_rf_get_gains()
427 PHY_CLRBITS(mac, 0x815, 0x4); in bwi_rf_get_gains()
429 PHY_FILT_SETBITS(mac, 0x3, 0xff9f, 0x40); in bwi_rf_get_gains()
431 if (rf->rf_rev == 8) { in bwi_rf_get_gains()
433 RF_WRITE(mac, 0x43, loop1_max); in bwi_rf_get_gains()
436 RF_WRITE(mac, 0x52, 0x0); in bwi_rf_get_gains()
437 RF_FILT_SETBITS(mac, 0x43, 0xfff0, loop1_max); in bwi_rf_get_gains()
440 bwi_phy_set_bbp_atten(mac, 11); in bwi_rf_get_gains()
442 if (phy->phy_rev >= 3) in bwi_rf_get_gains()
443 PHY_WRITE(mac, 0x80f, 0xc020); in bwi_rf_get_gains()
445 PHY_WRITE(mac, 0x80f, 0x8020); in bwi_rf_get_gains()
446 PHY_WRITE(mac, 0x810, 0); in bwi_rf_get_gains()
448 PHY_FILT_SETBITS(mac, 0x2b, 0xffc0, 0x1); in bwi_rf_get_gains()
449 PHY_FILT_SETBITS(mac, 0x2b, 0xc0ff, 0x800); in bwi_rf_get_gains()
450 PHY_SETBITS(mac, 0x811, 0x100); in bwi_rf_get_gains()
451 PHY_CLRBITS(mac, 0x812, 0x3000); in bwi_rf_get_gains()
453 if ((sc->sc_card_flags & BWI_CARD_F_EXT_LNA) && in bwi_rf_get_gains()
454 phy->phy_rev >= 7) { in bwi_rf_get_gains()
455 PHY_SETBITS(mac, 0x811, 0x800); in bwi_rf_get_gains()
456 PHY_SETBITS(mac, 0x812, 0x8000); in bwi_rf_get_gains()
458 RF_CLRBITS(mac, 0x7a, 0xff08); in bwi_rf_get_gains()
467 RF_WRITE(mac, 0x43, i); in bwi_rf_get_gains()
469 if (bwi_rf_gain_max_reached(mac, j)) in bwi_rf_get_gains()
482 PHY_SETBITS(mac, 0x812, 0x30); in bwi_rf_get_gains()
484 for (i = loop2 - 8; i < 16; ++i) { in bwi_rf_get_gains()
485 trsw -= 3; in bwi_rf_get_gains()
486 if (bwi_rf_gain_max_reached(mac, i)) in bwi_rf_get_gains()
498 PHY_WRITE(mac, save_phy_regs[i], save_phy[i]); in bwi_rf_get_gains()
500 bwi_phy_set_bbp_atten(mac, mac->mac_tpctl.bbp_atten); in bwi_rf_get_gains()
503 RF_WRITE(mac, save_rf_regs[i], save_rf[i]); in bwi_rf_get_gains()
505 PHY_WRITE(mac, save_phy_regs[2], save_phy[2] | 0x3); in bwi_rf_get_gains()
507 PHY_WRITE(mac, save_phy_regs[2], save_phy[2]); in bwi_rf_get_gains()
508 PHY_WRITE(mac, save_phy_regs[3], save_phy[3]); in bwi_rf_get_gains()
509 PHY_WRITE(mac, save_phy_regs[0], save_phy[0]); in bwi_rf_get_gains()
510 PHY_WRITE(mac, save_phy_regs[1], save_phy[1]); in bwi_rf_get_gains()
515 rf->rf_lo_gain = (loop2 * 6) - (loop1 * 4) - 11; in bwi_rf_get_gains()
516 rf->rf_rx_gain = trsw * 2; in bwi_rf_get_gains()
517 DPRINTF(mac->mac_sc, BWI_DBG_RF | BWI_DBG_INIT, in bwi_rf_get_gains()
519 rf->rf_lo_gain, rf->rf_rx_gain); in bwi_rf_get_gains()
526 bwi_rf_init(struct bwi_mac *mac) in bwi_rf_init() argument
528 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_init()
530 if (rf->rf_type == BWI_RF_T_BCM2060) { in bwi_rf_init()
533 if (rf->rf_flags & BWI_RF_F_INITED) in bwi_rf_init()
534 RF_WRITE(mac, 0x78, rf->rf_calib); in bwi_rf_init()
536 bwi_rf_init_bcm2050(mac); in bwi_rf_init()
541 bwi_rf_off_11a(struct bwi_mac *mac) in bwi_rf_off_11a() argument
543 RF_WRITE(mac, 0x4, 0xff); in bwi_rf_off_11a()
544 RF_WRITE(mac, 0x5, 0xfb); in bwi_rf_off_11a()
546 PHY_SETBITS(mac, 0x10, 0x8); in bwi_rf_off_11a()
547 PHY_SETBITS(mac, 0x11, 0x8); in bwi_rf_off_11a()
549 PHY_WRITE(mac, 0x15, 0xaa00); in bwi_rf_off_11a()
553 bwi_rf_off_11bg(struct bwi_mac *mac) in bwi_rf_off_11bg() argument
555 PHY_WRITE(mac, 0x15, 0xaa00); in bwi_rf_off_11bg()
559 bwi_rf_off_11g_rev5(struct bwi_mac *mac) in bwi_rf_off_11g_rev5() argument
561 PHY_SETBITS(mac, 0x811, 0x8c); in bwi_rf_off_11g_rev5()
562 PHY_CLRBITS(mac, 0x812, 0x8c); in bwi_rf_off_11g_rev5()
566 bwi_rf_work_around(struct bwi_mac *mac, u_int chan) in bwi_rf_work_around() argument
568 struct bwi_softc *sc = mac->mac_sc; in bwi_rf_work_around()
569 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_work_around()
572 device_printf(sc->sc_dev, "%s invalid channel!!\n", __func__); in bwi_rf_work_around()
576 if (rf->rf_type != BWI_RF_T_BCM2050 || rf->rf_rev >= 6) in bwi_rf_work_around()
588 bwi_rf_lo_find(struct bwi_mac *mac, const struct bwi_tpctl *tpctl) in bwi_rf_lo_find() argument
598 if (tpctl->tp_ctrl1 == 3) in bwi_rf_lo_find()
601 bbp_atten = tpctl->bbp_atten; in bwi_rf_lo_find()
602 rf_atten = tpctl->rf_atten; in bwi_rf_lo_find()
626 return bwi_get_rf_lo(mac, rf_atten, bbp_atten); in bwi_rf_lo_find()
630 bwi_rf_lo_adjust(struct bwi_mac *mac, const struct bwi_tpctl *tpctl) in bwi_rf_lo_adjust() argument
634 lo = bwi_rf_lo_find(mac, tpctl); in bwi_rf_lo_adjust()
635 RF_LO_WRITE(mac, lo); in bwi_rf_lo_adjust()
639 bwi_rf_lo_write(struct bwi_mac *mac, const struct bwi_rf_lo *lo) in bwi_rf_lo_write() argument
643 val = (uint8_t)lo->ctrl_lo; in bwi_rf_lo_write()
644 val |= ((uint8_t)lo->ctrl_hi) << 8; in bwi_rf_lo_write()
646 PHY_WRITE(mac, BWI_PHYR_RF_LO, val); in bwi_rf_lo_write()
650 bwi_rf_gain_max_reached(struct bwi_mac *mac, int idx) in bwi_rf_gain_max_reached() argument
652 PHY_FILT_SETBITS(mac, 0x812, 0xf0ff, idx << 8); in bwi_rf_gain_max_reached()
653 PHY_FILT_SETBITS(mac, 0x15, 0xfff, 0xa000); in bwi_rf_gain_max_reached()
654 PHY_SETBITS(mac, 0x15, 0xf000); in bwi_rf_gain_max_reached()
658 return (PHY_READ(mac, 0x2d) >= 0xdfc); in bwi_rf_gain_max_reached()
675 bwi_phy812_value(struct bwi_mac *mac, uint16_t lpd) in bwi_phy812_value() argument
677 struct bwi_softc *sc = mac->mac_sc; in bwi_phy812_value()
678 struct bwi_phy *phy = &mac->mac_phy; in bwi_phy812_value()
679 struct bwi_rf *rf = &mac->mac_rf; in bwi_phy812_value()
682 if ((phy->phy_flags & BWI_PHY_F_LINKED) == 0) in bwi_phy812_value()
685 lo_gain = rf->rf_lo_gain; in bwi_phy812_value()
686 if (rf->rf_rev == 8) in bwi_phy812_value()
692 lo_gain -= 0x46; in bwi_phy812_value()
695 lo_gain -= 0x3a; in bwi_phy812_value()
698 lo_gain -= 0x2e; in bwi_phy812_value()
701 lo_gain -= 0x10; in bwi_phy812_value()
706 lo_gain -= (6 * loop); in bwi_phy812_value()
711 if (phy->phy_rev >= 7 && (sc->sc_card_flags & BWI_CARD_F_EXT_LNA)) { in bwi_phy812_value()
747 bwi_rf_init_bcm2050(struct bwi_mac *mac) in bwi_rf_init_bcm2050() argument
768 struct bwi_softc *sc = mac->mac_sc; in bwi_rf_init_bcm2050()
769 struct bwi_phy *phy = &mac->mac_phy; in bwi_rf_init_bcm2050()
770 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_init_bcm2050()
777 save_rf[i] = RF_READ(mac, save_rf_regs[i]); in bwi_rf_init_bcm2050()
779 save_phy_comm[i] = PHY_READ(mac, save_phy_regs_comm[i]); in bwi_rf_init_bcm2050()
781 if (phy->phy_mode == IEEE80211_MODE_11B) { in bwi_rf_init_bcm2050()
782 phyr_30 = PHY_READ(mac, 0x30); in bwi_rf_init_bcm2050()
785 PHY_WRITE(mac, 0x30, 0xff); in bwi_rf_init_bcm2050()
787 } else if ((phy->phy_flags & BWI_PHY_F_LINKED) || phy->phy_rev >= 2) { in bwi_rf_init_bcm2050()
790 PHY_READ(mac, save_phy_regs_11g[i]); in bwi_rf_init_bcm2050()
793 PHY_SETBITS(mac, 0x814, 0x3); in bwi_rf_init_bcm2050()
794 PHY_CLRBITS(mac, 0x815, 0x3); in bwi_rf_init_bcm2050()
795 PHY_CLRBITS(mac, 0x429, 0x8000); in bwi_rf_init_bcm2050()
796 PHY_CLRBITS(mac, 0x802, 0x3); in bwi_rf_init_bcm2050()
798 phyr_80f = PHY_READ(mac, 0x80f); in bwi_rf_init_bcm2050()
799 phyr_810 = PHY_READ(mac, 0x810); in bwi_rf_init_bcm2050()
801 if (phy->phy_rev >= 3) in bwi_rf_init_bcm2050()
802 PHY_WRITE(mac, 0x80f, 0xc020); in bwi_rf_init_bcm2050()
804 PHY_WRITE(mac, 0x80f, 0x8020); in bwi_rf_init_bcm2050()
805 PHY_WRITE(mac, 0x810, 0); in bwi_rf_init_bcm2050()
807 phy812_val = bwi_phy812_value(mac, 0x011); in bwi_rf_init_bcm2050()
808 PHY_WRITE(mac, 0x812, phy812_val); in bwi_rf_init_bcm2050()
809 if (phy->phy_rev < 7 || in bwi_rf_init_bcm2050()
810 (sc->sc_card_flags & BWI_CARD_F_EXT_LNA) == 0) in bwi_rf_init_bcm2050()
811 PHY_WRITE(mac, 0x811, 0x1b3); in bwi_rf_init_bcm2050()
813 PHY_WRITE(mac, 0x811, 0x9b3); in bwi_rf_init_bcm2050()
817 phyr_35 = PHY_READ(mac, 0x35); in bwi_rf_init_bcm2050()
818 PHY_CLRBITS(mac, 0x35, 0x80); in bwi_rf_init_bcm2050()
823 if (phy->phy_version == 0) { in bwi_rf_init_bcm2050()
826 if (phy->phy_version >= 2) in bwi_rf_init_bcm2050()
827 PHY_FILT_SETBITS(mac, 0x3, 0xffbf, 0x40); in bwi_rf_init_bcm2050()
831 calib = bwi_rf_calibval(mac); in bwi_rf_init_bcm2050()
833 if (phy->phy_mode == IEEE80211_MODE_11B) in bwi_rf_init_bcm2050()
834 RF_WRITE(mac, 0x78, 0x26); in bwi_rf_init_bcm2050()
836 if ((phy->phy_flags & BWI_PHY_F_LINKED) || phy->phy_rev >= 2) { in bwi_rf_init_bcm2050()
837 phy812_val = bwi_phy812_value(mac, 0x011); in bwi_rf_init_bcm2050()
838 PHY_WRITE(mac, 0x812, phy812_val); in bwi_rf_init_bcm2050()
841 PHY_WRITE(mac, 0x15, 0xbfaf); in bwi_rf_init_bcm2050()
842 PHY_WRITE(mac, 0x2b, 0x1403); in bwi_rf_init_bcm2050()
844 if ((phy->phy_flags & BWI_PHY_F_LINKED) || phy->phy_rev >= 2) { in bwi_rf_init_bcm2050()
845 phy812_val = bwi_phy812_value(mac, 0x001); in bwi_rf_init_bcm2050()
846 PHY_WRITE(mac, 0x812, phy812_val); in bwi_rf_init_bcm2050()
849 PHY_WRITE(mac, 0x15, 0xbfa0); in bwi_rf_init_bcm2050()
851 RF_SETBITS(mac, 0x51, 0x4); in bwi_rf_init_bcm2050()
852 if (rf->rf_rev == 8) { in bwi_rf_init_bcm2050()
853 RF_WRITE(mac, 0x43, 0x1f); in bwi_rf_init_bcm2050()
855 RF_WRITE(mac, 0x52, 0); in bwi_rf_init_bcm2050()
856 RF_FILT_SETBITS(mac, 0x43, 0xfff0, 0x9); in bwi_rf_init_bcm2050()
860 PHY_WRITE(mac, 0x58, 0); in bwi_rf_init_bcm2050()
862 PHY_WRITE(mac, 0x5a, 0x480); in bwi_rf_init_bcm2050()
863 PHY_WRITE(mac, 0x59, 0xc810); in bwi_rf_init_bcm2050()
865 PHY_WRITE(mac, 0x58, 0xd); in bwi_rf_init_bcm2050()
866 if ((phy->phy_flags & BWI_PHY_F_LINKED) || phy->phy_rev >= 2) { in bwi_rf_init_bcm2050()
867 phy812_val = bwi_phy812_value(mac, 0x101); in bwi_rf_init_bcm2050()
868 PHY_WRITE(mac, 0x812, phy812_val); in bwi_rf_init_bcm2050()
870 PHY_WRITE(mac, 0x15, 0xafb0); in bwi_rf_init_bcm2050()
873 if ((phy->phy_flags & BWI_PHY_F_LINKED) || phy->phy_rev >= 2) { in bwi_rf_init_bcm2050()
874 phy812_val = bwi_phy812_value(mac, 0x101); in bwi_rf_init_bcm2050()
875 PHY_WRITE(mac, 0x812, phy812_val); in bwi_rf_init_bcm2050()
877 PHY_WRITE(mac, 0x15, 0xefb0); in bwi_rf_init_bcm2050()
880 if ((phy->phy_flags & BWI_PHY_F_LINKED) || phy->phy_rev >= 2) { in bwi_rf_init_bcm2050()
881 phy812_val = bwi_phy812_value(mac, 0x100); in bwi_rf_init_bcm2050()
882 PHY_WRITE(mac, 0x812, phy812_val); in bwi_rf_init_bcm2050()
884 PHY_WRITE(mac, 0x15, 0xfff0); in bwi_rf_init_bcm2050()
887 test_lim += PHY_READ(mac, 0x2d); in bwi_rf_init_bcm2050()
889 PHY_WRITE(mac, 0x58, 0); in bwi_rf_init_bcm2050()
890 if ((phy->phy_flags & BWI_PHY_F_LINKED) || phy->phy_rev >= 2) { in bwi_rf_init_bcm2050()
891 phy812_val = bwi_phy812_value(mac, 0x101); in bwi_rf_init_bcm2050()
892 PHY_WRITE(mac, 0x812, phy812_val); in bwi_rf_init_bcm2050()
894 PHY_WRITE(mac, 0x15, 0xafb0); in bwi_rf_init_bcm2050()
902 PHY_WRITE(mac, 0x58, 0); in bwi_rf_init_bcm2050()
907 RF_WRITE(mac, 0x78, rfr_78); in bwi_rf_init_bcm2050()
912 PHY_WRITE(mac, 0x5a, 0xd80); in bwi_rf_init_bcm2050()
913 PHY_WRITE(mac, 0x59, 0xc810); in bwi_rf_init_bcm2050()
915 PHY_WRITE(mac, 0x58, 0xd); in bwi_rf_init_bcm2050()
916 if ((phy->phy_flags & BWI_PHY_F_LINKED) || in bwi_rf_init_bcm2050()
917 phy->phy_rev >= 2) { in bwi_rf_init_bcm2050()
918 phy812_val = bwi_phy812_value(mac, 0x101); in bwi_rf_init_bcm2050()
919 PHY_WRITE(mac, 0x812, phy812_val); in bwi_rf_init_bcm2050()
921 PHY_WRITE(mac, 0x15, 0xafb0); in bwi_rf_init_bcm2050()
924 if ((phy->phy_flags & BWI_PHY_F_LINKED) || in bwi_rf_init_bcm2050()
925 phy->phy_rev >= 2) { in bwi_rf_init_bcm2050()
926 phy812_val = bwi_phy812_value(mac, 0x101); in bwi_rf_init_bcm2050()
927 PHY_WRITE(mac, 0x812, phy812_val); in bwi_rf_init_bcm2050()
929 PHY_WRITE(mac, 0x15, 0xefb0); in bwi_rf_init_bcm2050()
932 if ((phy->phy_flags & BWI_PHY_F_LINKED) || in bwi_rf_init_bcm2050()
933 phy->phy_rev >= 2) { in bwi_rf_init_bcm2050()
934 phy812_val = bwi_phy812_value(mac, 0x100); in bwi_rf_init_bcm2050()
935 PHY_WRITE(mac, 0x812, phy812_val); in bwi_rf_init_bcm2050()
937 PHY_WRITE(mac, 0x15, 0xfff0); in bwi_rf_init_bcm2050()
940 test += PHY_READ(mac, 0x2d); in bwi_rf_init_bcm2050()
942 PHY_WRITE(mac, 0x58, 0); in bwi_rf_init_bcm2050()
943 if ((phy->phy_flags & BWI_PHY_F_LINKED) || in bwi_rf_init_bcm2050()
944 phy->phy_rev >= 2) { in bwi_rf_init_bcm2050()
945 phy812_val = bwi_phy812_value(mac, 0x101); in bwi_rf_init_bcm2050()
946 PHY_WRITE(mac, 0x812, phy812_val); in bwi_rf_init_bcm2050()
948 PHY_WRITE(mac, 0x15, 0xafb0); in bwi_rf_init_bcm2050()
958 rf->rf_calib = rfr_78; in bwi_rf_init_bcm2050()
960 rf->rf_calib = calib; in bwi_rf_init_bcm2050()
961 if (rf->rf_calib != 0xffff) { in bwi_rf_init_bcm2050()
963 "RF calibration value: 0x%04x\n", rf->rf_calib); in bwi_rf_init_bcm2050()
964 rf->rf_flags |= BWI_RF_F_INITED; in bwi_rf_init_bcm2050()
970 PHY_WRITE(mac, save_phy_regs_comm[0], save_phy_comm[0]); in bwi_rf_init_bcm2050()
975 RF_WRITE(mac, save_rf_regs[pos], save_rf[pos]); in bwi_rf_init_bcm2050()
978 PHY_WRITE(mac, save_phy_regs_comm[i], save_phy_comm[i]); in bwi_rf_init_bcm2050()
981 if (phy->phy_version != 0) in bwi_rf_init_bcm2050()
984 PHY_WRITE(mac, 0x35, phyr_35); in bwi_rf_init_bcm2050()
985 bwi_rf_work_around(mac, rf->rf_curchan); in bwi_rf_init_bcm2050()
987 if (phy->phy_mode == IEEE80211_MODE_11B) { in bwi_rf_init_bcm2050()
988 PHY_WRITE(mac, 0x30, phyr_30); in bwi_rf_init_bcm2050()
990 } else if ((phy->phy_flags & BWI_PHY_F_LINKED) || phy->phy_rev >= 2) { in bwi_rf_init_bcm2050()
995 PHY_WRITE(mac, save_phy_regs_11g[i], in bwi_rf_init_bcm2050()
999 PHY_WRITE(mac, 0x80f, phyr_80f); in bwi_rf_init_bcm2050()
1000 PHY_WRITE(mac, 0x810, phyr_810); in bwi_rf_init_bcm2050()
1009 bwi_rf_calibval(struct bwi_mac *mac) in bwi_rf_calibval() argument
1011 /* http://bcm-specs.sipsolutions.net/RCCTable */ in bwi_rf_calibval()
1019 val = RF_READ(mac, BWI_RFR_BBP_ATTEN); in bwi_rf_calibval()
1041 * http://bcm-specs.sipsolutions.net/TSSI_to_DBM_Table
1060 f * 4096 - _bwi_adjust_devide(m2 * f, 16) * f, 2048); in bwi_rf_calc_txpower()
1061 d = abs(q - f); in bwi_rf_calc_txpower()
1073 if (dbm < -127) in bwi_rf_calc_txpower()
1074 dbm = -127; in bwi_rf_calc_txpower()
1083 bwi_rf_map_txpower(struct bwi_mac *mac) in bwi_rf_map_txpower() argument
1085 struct bwi_softc *sc = mac->mac_sc; in bwi_rf_map_txpower()
1086 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_map_txpower()
1087 struct bwi_phy *phy = &mac->mac_phy; in bwi_rf_map_txpower()
1096 if (phy->phy_mode == IEEE80211_MODE_11A) { in bwi_rf_map_txpower()
1097 rf->rf_txpower_max = __SHIFTOUT(val, in bwi_rf_map_txpower()
1100 rf->rf_txpower_max = __SHIFTOUT(val, in bwi_rf_map_txpower()
1103 if ((sc->sc_card_flags & BWI_CARD_F_PA_GPIO9) && in bwi_rf_map_txpower()
1104 phy->phy_mode == IEEE80211_MODE_11G) in bwi_rf_map_txpower()
1105 rf->rf_txpower_max -= 3; in bwi_rf_map_txpower()
1107 if (rf->rf_txpower_max <= 0) { in bwi_rf_map_txpower()
1108 device_printf(sc->sc_dev, "invalid max txpower in sprom\n"); in bwi_rf_map_txpower()
1109 rf->rf_txpower_max = 74; in bwi_rf_map_txpower()
1112 "max txpower from sprom: %d dBm\n", rf->rf_txpower_max); in bwi_rf_map_txpower()
1120 if (phy->phy_mode == IEEE80211_MODE_11A) in bwi_rf_map_txpower()
1125 device_printf(sc->sc_dev, "invalid antenna gain in sprom\n"); in bwi_rf_map_txpower()
1132 reg_txpower_max = 90 - ant_gain - 6; /* XXX magic number */ in bwi_rf_map_txpower()
1139 if (rf->rf_txpower_max > reg_txpower_max) in bwi_rf_map_txpower()
1140 rf->rf_txpower_max = reg_txpower_max; in bwi_rf_map_txpower()
1142 "max txpower %d dBm\n", rf->rf_txpower_max); in bwi_rf_map_txpower()
1148 if (sc->sc_bbp_id == BWI_BBPID_BCM4301 && in bwi_rf_map_txpower()
1149 rf->rf_type != BWI_RF_T_BCM2050) { in bwi_rf_map_txpower()
1150 rf->rf_idle_tssi0 = BWI_DEFAULT_IDLE_TSSI; in bwi_rf_map_txpower()
1151 bcopy(bwi_txpower_map_11b, rf->rf_txpower_map0, in bwi_rf_map_txpower()
1152 sizeof(rf->rf_txpower_map0)); in bwi_rf_map_txpower()
1156 #define IS_VALID_PA_PARAM(p) ((p) != 0 && (p) != -1) in bwi_rf_map_txpower()
1161 if (phy->phy_mode == IEEE80211_MODE_11A) in bwi_rf_map_txpower()
1176 if (phy->phy_mode == IEEE80211_MODE_11A) { in bwi_rf_map_txpower()
1177 device_printf(sc->sc_dev, in bwi_rf_map_txpower()
1182 if (phy->phy_mode == IEEE80211_MODE_11G) { in bwi_rf_map_txpower()
1194 rf->rf_idle_tssi0 = BWI_DEFAULT_IDLE_TSSI; in bwi_rf_map_txpower()
1195 bcopy(txpower_map, rf->rf_txpower_map0, in bwi_rf_map_txpower()
1196 sizeof(rf->rf_txpower_map0)); in bwi_rf_map_txpower()
1212 if (phy->phy_mode == IEEE80211_MODE_11A) in bwi_rf_map_txpower()
1217 rf->rf_idle_tssi0 = (int)__SHIFTOUT(val, mask); in bwi_rf_map_txpower()
1218 if (!IS_VALID_PA_PARAM(rf->rf_idle_tssi0)) in bwi_rf_map_txpower()
1219 rf->rf_idle_tssi0 = 62; in bwi_rf_map_txpower()
1227 "%s\n", "TSSI-TX power map:"); in bwi_rf_map_txpower()
1229 error = bwi_rf_calc_txpower(&rf->rf_txpower_map0[i], i, in bwi_rf_map_txpower()
1232 device_printf(sc->sc_dev, in bwi_rf_map_txpower()
1245 "%d ", rf->rf_txpower_map0[i]); in bwi_rf_map_txpower()
1251 "idle tssi0: %d\n", rf->rf_idle_tssi0); in bwi_rf_map_txpower()
1256 bwi_rf_lo_update_11g(struct bwi_mac *mac) in bwi_rf_lo_update_11g() argument
1258 struct bwi_softc *sc = mac->mac_sc; in bwi_rf_lo_update_11g()
1259 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_lo_update_11g()
1260 struct bwi_phy *phy = &mac->mac_phy; in bwi_rf_lo_update_11g()
1261 struct bwi_tpctl *tpctl = &mac->mac_tpctl; in bwi_rf_lo_update_11g()
1270 orig_chan = rf->rf_curchan; in bwi_rf_lo_update_11g()
1273 if (phy->phy_flags & BWI_PHY_F_LINKED) { in bwi_rf_lo_update_11g()
1274 SAVE_PHY_REG(mac, ®s, 429); in bwi_rf_lo_update_11g()
1275 SAVE_PHY_REG(mac, ®s, 802); in bwi_rf_lo_update_11g()
1277 PHY_WRITE(mac, 0x429, regs.phy_429 & 0x7fff); in bwi_rf_lo_update_11g()
1278 PHY_WRITE(mac, 0x802, regs.phy_802 & 0xfffc); in bwi_rf_lo_update_11g()
1285 SAVE_PHY_REG(mac, ®s, 15); in bwi_rf_lo_update_11g()
1286 SAVE_PHY_REG(mac, ®s, 2a); in bwi_rf_lo_update_11g()
1287 SAVE_PHY_REG(mac, ®s, 35); in bwi_rf_lo_update_11g()
1288 SAVE_PHY_REG(mac, ®s, 60); in bwi_rf_lo_update_11g()
1289 SAVE_RF_REG(mac, ®s, 43); in bwi_rf_lo_update_11g()
1290 SAVE_RF_REG(mac, ®s, 7a); in bwi_rf_lo_update_11g()
1291 SAVE_RF_REG(mac, ®s, 52); in bwi_rf_lo_update_11g()
1292 if (phy->phy_flags & BWI_PHY_F_LINKED) { in bwi_rf_lo_update_11g()
1293 SAVE_PHY_REG(mac, ®s, 811); in bwi_rf_lo_update_11g()
1294 SAVE_PHY_REG(mac, ®s, 812); in bwi_rf_lo_update_11g()
1295 SAVE_PHY_REG(mac, ®s, 814); in bwi_rf_lo_update_11g()
1296 SAVE_PHY_REG(mac, ®s, 815); in bwi_rf_lo_update_11g()
1300 bwi_rf_set_chan(mac, 6, 0); in bwi_rf_lo_update_11g()
1302 if (phy->phy_flags & BWI_PHY_F_LINKED) { in bwi_rf_lo_update_11g()
1303 PHY_WRITE(mac, 0x429, regs.phy_429 & 0x7fff); in bwi_rf_lo_update_11g()
1304 PHY_WRITE(mac, 0x802, regs.phy_802 & 0xfffc); in bwi_rf_lo_update_11g()
1305 bwi_mac_dummy_xmit(mac); in bwi_rf_lo_update_11g()
1307 RF_WRITE(mac, 0x43, 0x6); in bwi_rf_lo_update_11g()
1309 bwi_phy_set_bbp_atten(mac, 2); in bwi_rf_lo_update_11g()
1313 PHY_WRITE(mac, 0x2e, 0x7f); in bwi_rf_lo_update_11g()
1314 PHY_WRITE(mac, 0x80f, 0x78); in bwi_rf_lo_update_11g()
1315 PHY_WRITE(mac, 0x35, regs.phy_35 & 0xff7f); in bwi_rf_lo_update_11g()
1316 RF_WRITE(mac, 0x7a, regs.rf_7a & 0xfff0); in bwi_rf_lo_update_11g()
1317 PHY_WRITE(mac, 0x2b, 0x203); in bwi_rf_lo_update_11g()
1318 PHY_WRITE(mac, 0x2a, 0x8a3); in bwi_rf_lo_update_11g()
1320 if (phy->phy_flags & BWI_PHY_F_LINKED) { in bwi_rf_lo_update_11g()
1321 PHY_WRITE(mac, 0x814, regs.phy_814 | 0x3); in bwi_rf_lo_update_11g()
1322 PHY_WRITE(mac, 0x815, regs.phy_815 & 0xfffc); in bwi_rf_lo_update_11g()
1323 PHY_WRITE(mac, 0x811, 0x1b3); in bwi_rf_lo_update_11g()
1324 PHY_WRITE(mac, 0x812, 0xb2); in bwi_rf_lo_update_11g()
1327 if ((sc->sc_flags & BWI_F_RUNNING) == 0) in bwi_rf_lo_update_11g()
1328 tpctl->tp_ctrl2 = bwi_rf_get_tp_ctrl2(mac); in bwi_rf_lo_update_11g()
1329 PHY_WRITE(mac, 0x80f, 0x8078); in bwi_rf_lo_update_11g()
1334 devi_ctrl = _bwi_rf_lo_update_11g(mac, regs.rf_7a); in bwi_rf_lo_update_11g()
1339 if (phy->phy_flags & BWI_PHY_F_LINKED) { in bwi_rf_lo_update_11g()
1340 PHY_WRITE(mac, 0x15, 0xe300); in bwi_rf_lo_update_11g()
1341 PHY_WRITE(mac, 0x812, (devi_ctrl << 8) | 0xa0); in bwi_rf_lo_update_11g()
1343 PHY_WRITE(mac, 0x812, (devi_ctrl << 8) | 0xa2); in bwi_rf_lo_update_11g()
1345 PHY_WRITE(mac, 0x812, (devi_ctrl << 8) | 0xa3); in bwi_rf_lo_update_11g()
1347 PHY_WRITE(mac, 0x15, devi_ctrl | 0xefa0); in bwi_rf_lo_update_11g()
1350 if ((sc->sc_flags & BWI_F_RUNNING) == 0) in bwi_rf_lo_update_11g()
1352 bwi_rf_lo_adjust(mac, tpctl); in bwi_rf_lo_update_11g()
1354 PHY_WRITE(mac, 0x2e, 0x807f); in bwi_rf_lo_update_11g()
1355 if (phy->phy_flags & BWI_PHY_F_LINKED) in bwi_rf_lo_update_11g()
1356 PHY_WRITE(mac, 0x2f, 0x202); in bwi_rf_lo_update_11g()
1358 PHY_WRITE(mac, 0x2f, 0x101); in bwi_rf_lo_update_11g()
1362 RESTORE_PHY_REG(mac, ®s, 15); in bwi_rf_lo_update_11g()
1363 RESTORE_PHY_REG(mac, ®s, 2a); in bwi_rf_lo_update_11g()
1364 RESTORE_PHY_REG(mac, ®s, 35); in bwi_rf_lo_update_11g()
1365 RESTORE_PHY_REG(mac, ®s, 60); in bwi_rf_lo_update_11g()
1367 RESTORE_RF_REG(mac, ®s, 43); in bwi_rf_lo_update_11g()
1368 RESTORE_RF_REG(mac, ®s, 7a); in bwi_rf_lo_update_11g()
1371 regs.rf_52 |= (RF_READ(mac, 0x52) & 0xf); in bwi_rf_lo_update_11g()
1372 RF_WRITE(mac, 0x52, regs.rf_52); in bwi_rf_lo_update_11g()
1376 if (phy->phy_flags & BWI_PHY_F_LINKED) { in bwi_rf_lo_update_11g()
1377 RESTORE_PHY_REG(mac, ®s, 811); in bwi_rf_lo_update_11g()
1378 RESTORE_PHY_REG(mac, ®s, 812); in bwi_rf_lo_update_11g()
1379 RESTORE_PHY_REG(mac, ®s, 814); in bwi_rf_lo_update_11g()
1380 RESTORE_PHY_REG(mac, ®s, 815); in bwi_rf_lo_update_11g()
1381 RESTORE_PHY_REG(mac, ®s, 429); in bwi_rf_lo_update_11g()
1382 RESTORE_PHY_REG(mac, ®s, 802); in bwi_rf_lo_update_11g()
1385 bwi_rf_set_chan(mac, orig_chan, 1); in bwi_rf_lo_update_11g()
1389 bwi_rf_lo_devi_measure(struct bwi_mac *mac, uint16_t ctrl) in bwi_rf_lo_devi_measure() argument
1391 struct bwi_phy *phy = &mac->mac_phy; in bwi_rf_lo_devi_measure()
1395 if (phy->phy_flags & BWI_PHY_F_LINKED) in bwi_rf_lo_devi_measure()
1399 if (phy->phy_flags & BWI_PHY_F_LINKED) { in bwi_rf_lo_devi_measure()
1400 PHY_WRITE(mac, 0x15, 0xe300); in bwi_rf_lo_devi_measure()
1401 PHY_WRITE(mac, 0x812, ctrl | 0xb0); in bwi_rf_lo_devi_measure()
1403 PHY_WRITE(mac, 0x812, ctrl | 0xb2); in bwi_rf_lo_devi_measure()
1405 PHY_WRITE(mac, 0x812, ctrl | 0xb3); in bwi_rf_lo_devi_measure()
1407 PHY_WRITE(mac, 0x15, 0xf300); in bwi_rf_lo_devi_measure()
1409 PHY_WRITE(mac, 0x15, ctrl | 0xefa0); in bwi_rf_lo_devi_measure()
1411 PHY_WRITE(mac, 0x15, ctrl | 0xefe0); in bwi_rf_lo_devi_measure()
1413 PHY_WRITE(mac, 0x15, ctrl | 0xffe0); in bwi_rf_lo_devi_measure()
1416 devi += PHY_READ(mac, 0x2d); in bwi_rf_lo_devi_measure()
1422 bwi_rf_get_tp_ctrl2(struct bwi_mac *mac) in bwi_rf_get_tp_ctrl2() argument
1428 RF_WRITE(mac, 0x52, 0); in bwi_rf_get_tp_ctrl2()
1430 devi_min = bwi_rf_lo_devi_measure(mac, 0); in bwi_rf_get_tp_ctrl2()
1435 RF_WRITE(mac, 0x52, i); in bwi_rf_get_tp_ctrl2()
1437 devi = bwi_rf_lo_devi_measure(mac, 0); in bwi_rf_get_tp_ctrl2()
1448 _bwi_rf_lo_update_11g(struct bwi_mac *mac, uint16_t orig_rf7a) in _bwi_rf_lo_update_11g() argument
1456 { 0, 3, 1, 5, 7, 3, 2, 0, 4, 6, -1, -1, -1, -1 }; in _bwi_rf_lo_update_11g()
1460 struct bwi_softc *sc = mac->mac_sc; in _bwi_rf_lo_update_11g()
1474 if ((sc->sc_flags & BWI_F_RUNNING) == 0) { in _bwi_rf_lo_update_11g()
1478 lo = bwi_get_rf_lo(mac, in _bwi_rf_lo_update_11g()
1482 lo = bwi_get_rf_lo(mac, in _bwi_rf_lo_update_11g()
1507 lo = bwi_get_rf_lo(mac, in _bwi_rf_lo_update_11g()
1509 if (!bwi_rf_lo_isused(mac, lo)) in _bwi_rf_lo_update_11g()
1517 RF_WRITE(mac, BWI_RFR_ATTEN, rf_atten); in _bwi_rf_lo_update_11g()
1519 tp_ctrl2 = mac->mac_tpctl.tp_ctrl2; in _bwi_rf_lo_update_11g()
1522 RF_WRITE(mac, BWI_RFR_TXPWR, tp_ctrl2); in _bwi_rf_lo_update_11g()
1526 bwi_phy_set_bbp_atten(mac, bbp_atten * 2); in _bwi_rf_lo_update_11g()
1531 RF_WRITE(mac, 0x7a, rf7a); in _bwi_rf_lo_update_11g()
1533 lo = bwi_get_rf_lo(mac, in _bwi_rf_lo_update_11g()
1535 bwi_rf_lo_measure_11g(mac, &lo_save, lo, devi_ctrl); in _bwi_rf_lo_update_11g()
1545 bwi_rf_lo_measure_11g(struct bwi_mac *mac, const struct bwi_rf_lo *src_lo, in bwi_rf_lo_measure_11g() argument
1554 LO_ADJUST(1, -1), in bwi_rf_lo_measure_11g()
1555 LO_ADJUST(0, -1), in bwi_rf_lo_measure_11g()
1556 LO_ADJUST(-1, -1), in bwi_rf_lo_measure_11g()
1557 LO_ADJUST(-1, 0), in bwi_rf_lo_measure_11g()
1558 LO_ADJUST(-1, 1), in bwi_rf_lo_measure_11g()
1568 RF_LO_WRITE(mac, &lo_min); in bwi_rf_lo_measure_11g()
1569 devi_min = bwi_rf_lo_devi_measure(mac, devi_ctrl); in bwi_rf_lo_measure_11g()
1582 i = adjust_state - 1; in bwi_rf_lo_measure_11g()
1585 i = adjust_state - 2; in bwi_rf_lo_measure_11g()
1594 fin -= LO_ADJUST_MAX; in bwi_rf_lo_measure_11g()
1603 rf_lo_adjust[i - 1].ctrl_hi; in bwi_rf_lo_measure_11g()
1605 rf_lo_adjust[i - 1].ctrl_lo; in bwi_rf_lo_measure_11g()
1610 RF_LO_WRITE(mac, &lo); in bwi_rf_lo_measure_11g()
1611 devi = bwi_rf_lo_devi_measure(mac, devi_ctrl); in bwi_rf_lo_measure_11g()
1626 } while (loop_count-- && found); in bwi_rf_lo_measure_11g()
1635 bwi_rf_calc_nrssi_slope_11b(struct bwi_mac *mac) in bwi_rf_calc_nrssi_slope_11b() argument
1645 struct bwi_softc *sc = mac->mac_sc; in bwi_rf_calc_nrssi_slope_11b()
1646 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_calc_nrssi_slope_11b()
1647 struct bwi_phy *phy = &mac->mac_phy; in bwi_rf_calc_nrssi_slope_11b()
1658 save_rf[i] = RF_READ(mac, save_rf_regs[i]); in bwi_rf_calc_nrssi_slope_11b()
1660 save_phy[i] = PHY_READ(mac, save_phy_regs[i]); in bwi_rf_calc_nrssi_slope_11b()
1669 if (phy->phy_rev >= 5) in bwi_rf_calc_nrssi_slope_11b()
1670 RF_CLRBITS(mac, 0x7a, 0xff80); in bwi_rf_calc_nrssi_slope_11b()
1672 RF_CLRBITS(mac, 0x7a, 0xfff0); in bwi_rf_calc_nrssi_slope_11b()
1673 PHY_WRITE(mac, 0x30, 0xff); in bwi_rf_calc_nrssi_slope_11b()
1677 PHY_WRITE(mac, 0x26, 0); in bwi_rf_calc_nrssi_slope_11b()
1678 PHY_SETBITS(mac, 0x15, 0x20); in bwi_rf_calc_nrssi_slope_11b()
1679 PHY_WRITE(mac, 0x2a, 0x8a3); in bwi_rf_calc_nrssi_slope_11b()
1680 RF_SETBITS(mac, 0x7a, 0x80); in bwi_rf_calc_nrssi_slope_11b()
1682 nrssi[0] = (int16_t)PHY_READ(mac, 0x27); in bwi_rf_calc_nrssi_slope_11b()
1687 RF_CLRBITS(mac, 0x7a, 0xff80); in bwi_rf_calc_nrssi_slope_11b()
1688 if (phy->phy_version >= 2) in bwi_rf_calc_nrssi_slope_11b()
1690 else if (phy->phy_version == 0) in bwi_rf_calc_nrssi_slope_11b()
1695 PHY_WRITE(mac, 0x20, 0x3f3f); in bwi_rf_calc_nrssi_slope_11b()
1696 PHY_WRITE(mac, 0x15, 0xf330); in bwi_rf_calc_nrssi_slope_11b()
1698 RF_WRITE(mac, 0x5a, 0x60); in bwi_rf_calc_nrssi_slope_11b()
1699 RF_CLRBITS(mac, 0x43, 0xff0f); in bwi_rf_calc_nrssi_slope_11b()
1701 PHY_WRITE(mac, 0x5a, 0x480); in bwi_rf_calc_nrssi_slope_11b()
1702 PHY_WRITE(mac, 0x59, 0x810); in bwi_rf_calc_nrssi_slope_11b()
1703 PHY_WRITE(mac, 0x58, 0xd); in bwi_rf_calc_nrssi_slope_11b()
1707 nrssi[1] = (int16_t)PHY_READ(mac, 0x27); in bwi_rf_calc_nrssi_slope_11b()
1712 PHY_WRITE(mac, save_phy_regs[0], save_phy[0]); in bwi_rf_calc_nrssi_slope_11b()
1713 RF_WRITE(mac, save_rf_regs[0], save_rf[0]); in bwi_rf_calc_nrssi_slope_11b()
1718 PHY_WRITE(mac, save_phy_regs[i], save_phy[i]); in bwi_rf_calc_nrssi_slope_11b()
1720 bwi_rf_work_around(mac, rf->rf_curchan); in bwi_rf_calc_nrssi_slope_11b()
1722 if (phy->phy_version != 0) in bwi_rf_calc_nrssi_slope_11b()
1726 PHY_WRITE(mac, save_phy_regs[i], save_phy[i]); in bwi_rf_calc_nrssi_slope_11b()
1729 RF_WRITE(mac, save_rf_regs[i], save_rf[i]); in bwi_rf_calc_nrssi_slope_11b()
1735 rf->rf_nrssi_slope = 0x10000; in bwi_rf_calc_nrssi_slope_11b()
1737 rf->rf_nrssi_slope = 0x400000 / (nrssi[0] - nrssi[1]); in bwi_rf_calc_nrssi_slope_11b()
1738 if (nrssi[0] <= -4) { in bwi_rf_calc_nrssi_slope_11b()
1739 rf->rf_nrssi[0] = nrssi[0]; in bwi_rf_calc_nrssi_slope_11b()
1740 rf->rf_nrssi[1] = nrssi[1]; in bwi_rf_calc_nrssi_slope_11b()
1748 bwi_rf_set_nrssi_ofs_11g(struct bwi_mac *mac) in bwi_rf_set_nrssi_ofs_11g() argument
1766 struct bwi_phy *phy = &mac->mac_phy; in bwi_rf_set_nrssi_ofs_11g()
1775 save_phy_comm[i] = PHY_READ(mac, save_phy_comm_regs[i]); in bwi_rf_set_nrssi_ofs_11g()
1777 save_rf[i] = RF_READ(mac, save_rf_regs[i]); in bwi_rf_set_nrssi_ofs_11g()
1779 PHY_CLRBITS(mac, 0x429, 0x8000); in bwi_rf_set_nrssi_ofs_11g()
1780 PHY_FILT_SETBITS(mac, 0x1, 0x3fff, 0x4000); in bwi_rf_set_nrssi_ofs_11g()
1781 PHY_SETBITS(mac, 0x811, 0xc); in bwi_rf_set_nrssi_ofs_11g()
1782 PHY_FILT_SETBITS(mac, 0x812, 0xfff3, 0x4); in bwi_rf_set_nrssi_ofs_11g()
1783 PHY_CLRBITS(mac, 0x802, 0x3); in bwi_rf_set_nrssi_ofs_11g()
1785 if (phy->phy_rev >= 6) { in bwi_rf_set_nrssi_ofs_11g()
1787 save_phy6[i] = PHY_READ(mac, save_phy6_regs[i]); in bwi_rf_set_nrssi_ofs_11g()
1789 PHY_WRITE(mac, 0x2e, 0); in bwi_rf_set_nrssi_ofs_11g()
1790 PHY_WRITE(mac, 0x2f, 0); in bwi_rf_set_nrssi_ofs_11g()
1791 PHY_WRITE(mac, 0x80f, 0); in bwi_rf_set_nrssi_ofs_11g()
1792 PHY_WRITE(mac, 0x810, 0); in bwi_rf_set_nrssi_ofs_11g()
1793 PHY_SETBITS(mac, 0x478, 0x100); in bwi_rf_set_nrssi_ofs_11g()
1794 PHY_SETBITS(mac, 0x801, 0x40); in bwi_rf_set_nrssi_ofs_11g()
1795 PHY_SETBITS(mac, 0x60, 0x40); in bwi_rf_set_nrssi_ofs_11g()
1796 PHY_SETBITS(mac, 0x14, 0x200); in bwi_rf_set_nrssi_ofs_11g()
1799 RF_SETBITS(mac, 0x7a, 0x70); in bwi_rf_set_nrssi_ofs_11g()
1800 RF_SETBITS(mac, 0x7a, 0x80); in bwi_rf_set_nrssi_ofs_11g()
1804 nrssi = bwi_nrssi_11g(mac); in bwi_rf_set_nrssi_ofs_11g()
1806 for (i = 7; i >= 4; --i) { in bwi_rf_set_nrssi_ofs_11g()
1807 RF_WRITE(mac, 0x7b, i); in bwi_rf_set_nrssi_ofs_11g()
1809 nrssi = bwi_nrssi_11g(mac); in bwi_rf_set_nrssi_ofs_11g()
1818 RF_CLRBITS(mac, 0x7a, 0xff80); in bwi_rf_set_nrssi_ofs_11g()
1820 PHY_SETBITS(mac, 0x814, 0x1); in bwi_rf_set_nrssi_ofs_11g()
1821 PHY_CLRBITS(mac, 0x815, 0x1); in bwi_rf_set_nrssi_ofs_11g()
1822 PHY_SETBITS(mac, 0x811, 0xc); in bwi_rf_set_nrssi_ofs_11g()
1823 PHY_SETBITS(mac, 0x812, 0xc); in bwi_rf_set_nrssi_ofs_11g()
1824 PHY_SETBITS(mac, 0x811, 0x30); in bwi_rf_set_nrssi_ofs_11g()
1825 PHY_SETBITS(mac, 0x812, 0x30); in bwi_rf_set_nrssi_ofs_11g()
1826 PHY_WRITE(mac, 0x5a, 0x480); in bwi_rf_set_nrssi_ofs_11g()
1827 PHY_WRITE(mac, 0x59, 0x810); in bwi_rf_set_nrssi_ofs_11g()
1828 PHY_WRITE(mac, 0x58, 0xd); in bwi_rf_set_nrssi_ofs_11g()
1829 if (phy->phy_version == 0) in bwi_rf_set_nrssi_ofs_11g()
1830 PHY_WRITE(mac, 0x3, 0x122); in bwi_rf_set_nrssi_ofs_11g()
1832 PHY_SETBITS(mac, 0xa, 0x2000); in bwi_rf_set_nrssi_ofs_11g()
1833 PHY_SETBITS(mac, 0x814, 0x4); in bwi_rf_set_nrssi_ofs_11g()
1834 PHY_CLRBITS(mac, 0x815, 0x4); in bwi_rf_set_nrssi_ofs_11g()
1835 PHY_FILT_SETBITS(mac, 0x3, 0xff9f, 0x40); in bwi_rf_set_nrssi_ofs_11g()
1836 RF_SETBITS(mac, 0x7a, 0xf); in bwi_rf_set_nrssi_ofs_11g()
1842 bwi_set_gains(mac, &gains); in bwi_rf_set_nrssi_ofs_11g()
1844 RF_FILT_SETBITS(mac, 0x43, 0xf0, 0xf); in bwi_rf_set_nrssi_ofs_11g()
1847 nrssi = bwi_nrssi_11g(mac); in bwi_rf_set_nrssi_ofs_11g()
1848 if (nrssi == -32) { in bwi_rf_set_nrssi_ofs_11g()
1850 RF_WRITE(mac, 0x7b, i); in bwi_rf_set_nrssi_ofs_11g()
1852 nrssi = bwi_nrssi_11g(mac); in bwi_rf_set_nrssi_ofs_11g()
1853 if (nrssi > -31 && rf7b == 0xffff) in bwi_rf_set_nrssi_ofs_11g()
1862 RF_WRITE(mac, 0x7b, rf7b); in bwi_rf_set_nrssi_ofs_11g()
1867 if (phy->phy_rev >= 6) { in bwi_rf_set_nrssi_ofs_11g()
1869 PHY_WRITE(mac, save_phy6_regs[phy6_idx], in bwi_rf_set_nrssi_ofs_11g()
1876 PHY_WRITE(mac, save_phy_comm_regs[i], save_phy_comm[i]); in bwi_rf_set_nrssi_ofs_11g()
1878 for (i = SAVE_RF_MAX - 1; i >= 0; --i) in bwi_rf_set_nrssi_ofs_11g()
1879 RF_WRITE(mac, save_rf_regs[i], save_rf[i]); in bwi_rf_set_nrssi_ofs_11g()
1881 PHY_SETBITS(mac, 0x802, 0x3); in bwi_rf_set_nrssi_ofs_11g()
1882 PHY_SETBITS(mac, 0x429, 0x8000); in bwi_rf_set_nrssi_ofs_11g()
1884 bwi_set_gains(mac, NULL); in bwi_rf_set_nrssi_ofs_11g()
1886 if (phy->phy_rev >= 6) { in bwi_rf_set_nrssi_ofs_11g()
1888 PHY_WRITE(mac, save_phy6_regs[phy6_idx], in bwi_rf_set_nrssi_ofs_11g()
1893 PHY_WRITE(mac, save_phy_comm_regs[0], save_phy_comm[0]); in bwi_rf_set_nrssi_ofs_11g()
1894 PHY_WRITE(mac, save_phy_comm_regs[2], save_phy_comm[2]); in bwi_rf_set_nrssi_ofs_11g()
1895 PHY_WRITE(mac, save_phy_comm_regs[1], save_phy_comm[1]); in bwi_rf_set_nrssi_ofs_11g()
1903 bwi_rf_calc_nrssi_slope_11g(struct bwi_mac *mac) in bwi_rf_calc_nrssi_slope_11g() argument
1918 struct bwi_softc *sc = mac->mac_sc; in bwi_rf_calc_nrssi_slope_11g()
1919 struct bwi_phy *phy = &mac->mac_phy; in bwi_rf_calc_nrssi_slope_11g()
1920 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_calc_nrssi_slope_11g()
1929 if (rf->rf_rev >= 9) in bwi_rf_calc_nrssi_slope_11g()
1931 else if (rf->rf_rev == 8) in bwi_rf_calc_nrssi_slope_11g()
1932 bwi_rf_set_nrssi_ofs_11g(mac); in bwi_rf_calc_nrssi_slope_11g()
1934 PHY_CLRBITS(mac, 0x429, 0x8000); in bwi_rf_calc_nrssi_slope_11g()
1935 PHY_CLRBITS(mac, 0x802, 0x3); in bwi_rf_calc_nrssi_slope_11g()
1944 save_rf[i] = RF_READ(mac, save_rf_regs[i]); in bwi_rf_calc_nrssi_slope_11g()
1946 save_phy_comm[i] = PHY_READ(mac, save_phy_comm_regs[i]); in bwi_rf_calc_nrssi_slope_11g()
1951 if (phy->phy_rev >= 3) { in bwi_rf_calc_nrssi_slope_11g()
1953 save_phy3[i] = PHY_READ(mac, save_phy3_regs[i]); in bwi_rf_calc_nrssi_slope_11g()
1955 PHY_WRITE(mac, 0x2e, 0); in bwi_rf_calc_nrssi_slope_11g()
1956 PHY_WRITE(mac, 0x810, 0); in bwi_rf_calc_nrssi_slope_11g()
1958 if (phy->phy_rev == 4 || phy->phy_rev == 6 || in bwi_rf_calc_nrssi_slope_11g()
1959 phy->phy_rev == 7) { in bwi_rf_calc_nrssi_slope_11g()
1960 PHY_SETBITS(mac, 0x478, 0x100); in bwi_rf_calc_nrssi_slope_11g()
1961 PHY_SETBITS(mac, 0x810, 0x40); in bwi_rf_calc_nrssi_slope_11g()
1962 } else if (phy->phy_rev == 3 || phy->phy_rev == 5) { in bwi_rf_calc_nrssi_slope_11g()
1963 PHY_CLRBITS(mac, 0x810, 0x40); in bwi_rf_calc_nrssi_slope_11g()
1966 PHY_SETBITS(mac, 0x60, 0x40); in bwi_rf_calc_nrssi_slope_11g()
1967 PHY_SETBITS(mac, 0x14, 0x200); in bwi_rf_calc_nrssi_slope_11g()
1973 RF_SETBITS(mac, 0x7a, 0x70); in bwi_rf_calc_nrssi_slope_11g()
1979 bwi_set_gains(mac, &gains); in bwi_rf_calc_nrssi_slope_11g()
1981 RF_CLRBITS(mac, 0x7a, 0xff08); in bwi_rf_calc_nrssi_slope_11g()
1982 if (phy->phy_rev >= 2) { in bwi_rf_calc_nrssi_slope_11g()
1983 PHY_FILT_SETBITS(mac, 0x811, 0xffcf, 0x30); in bwi_rf_calc_nrssi_slope_11g()
1984 PHY_FILT_SETBITS(mac, 0x812, 0xffcf, 0x10); in bwi_rf_calc_nrssi_slope_11g()
1987 RF_SETBITS(mac, 0x7a, 0x80); in bwi_rf_calc_nrssi_slope_11g()
1989 nrssi[0] = bwi_nrssi_11g(mac); in bwi_rf_calc_nrssi_slope_11g()
1994 RF_CLRBITS(mac, 0x7a, 0xff80); in bwi_rf_calc_nrssi_slope_11g()
1995 if (phy->phy_version >= 2) in bwi_rf_calc_nrssi_slope_11g()
1996 PHY_FILT_SETBITS(mac, 0x3, 0xff9f, 0x40); in bwi_rf_calc_nrssi_slope_11g()
1999 RF_SETBITS(mac, 0x7a, 0xf); in bwi_rf_calc_nrssi_slope_11g()
2000 PHY_WRITE(mac, 0x15, 0xf330); in bwi_rf_calc_nrssi_slope_11g()
2001 if (phy->phy_rev >= 2) { in bwi_rf_calc_nrssi_slope_11g()
2002 PHY_FILT_SETBITS(mac, 0x812, 0xffcf, 0x20); in bwi_rf_calc_nrssi_slope_11g()
2003 PHY_FILT_SETBITS(mac, 0x811, 0xffcf, 0x20); in bwi_rf_calc_nrssi_slope_11g()
2010 bwi_set_gains(mac, &gains); in bwi_rf_calc_nrssi_slope_11g()
2012 if (rf->rf_rev == 8) { in bwi_rf_calc_nrssi_slope_11g()
2013 RF_WRITE(mac, 0x43, 0x1f); in bwi_rf_calc_nrssi_slope_11g()
2015 RF_FILT_SETBITS(mac, 0x52, 0xff0f, 0x60); in bwi_rf_calc_nrssi_slope_11g()
2016 RF_FILT_SETBITS(mac, 0x43, 0xfff0, 0x9); in bwi_rf_calc_nrssi_slope_11g()
2018 PHY_WRITE(mac, 0x5a, 0x480); in bwi_rf_calc_nrssi_slope_11g()
2019 PHY_WRITE(mac, 0x59, 0x810); in bwi_rf_calc_nrssi_slope_11g()
2020 PHY_WRITE(mac, 0x58, 0xd); in bwi_rf_calc_nrssi_slope_11g()
2023 nrssi[1] = bwi_nrssi_11g(mac); in bwi_rf_calc_nrssi_slope_11g()
2029 rf->rf_nrssi_slope = 0x10000; in bwi_rf_calc_nrssi_slope_11g()
2031 rf->rf_nrssi_slope = 0x400000 / (nrssi[0] - nrssi[1]); in bwi_rf_calc_nrssi_slope_11g()
2032 if (nrssi[0] >= -4) { in bwi_rf_calc_nrssi_slope_11g()
2033 rf->rf_nrssi[0] = nrssi[1]; in bwi_rf_calc_nrssi_slope_11g()
2034 rf->rf_nrssi[1] = nrssi[0]; in bwi_rf_calc_nrssi_slope_11g()
2040 if (phy->phy_rev >= 3) { in bwi_rf_calc_nrssi_slope_11g()
2042 PHY_WRITE(mac, save_phy3_regs[phy3_idx], in bwi_rf_calc_nrssi_slope_11g()
2046 if (phy->phy_rev >= 2) { in bwi_rf_calc_nrssi_slope_11g()
2047 PHY_CLRBITS(mac, 0x812, 0x30); in bwi_rf_calc_nrssi_slope_11g()
2048 PHY_CLRBITS(mac, 0x811, 0x30); in bwi_rf_calc_nrssi_slope_11g()
2052 RF_WRITE(mac, save_rf_regs[i], save_rf[i]); in bwi_rf_calc_nrssi_slope_11g()
2059 PHY_WRITE(mac, save_phy_comm_regs[i], save_phy_comm[i]); in bwi_rf_calc_nrssi_slope_11g()
2061 bwi_rf_work_around(mac, rf->rf_curchan); in bwi_rf_calc_nrssi_slope_11g()
2062 PHY_SETBITS(mac, 0x802, 0x3); in bwi_rf_calc_nrssi_slope_11g()
2063 bwi_set_gains(mac, NULL); in bwi_rf_calc_nrssi_slope_11g()
2064 PHY_SETBITS(mac, 0x429, 0x8000); in bwi_rf_calc_nrssi_slope_11g()
2066 if (phy->phy_rev >= 3) { in bwi_rf_calc_nrssi_slope_11g()
2068 PHY_WRITE(mac, save_phy3_regs[phy3_idx], in bwi_rf_calc_nrssi_slope_11g()
2073 bwi_rf_init_sw_nrssi_table(mac); in bwi_rf_calc_nrssi_slope_11g()
2074 bwi_rf_set_nrssi_thr_11g(mac); in bwi_rf_calc_nrssi_slope_11g()
2082 bwi_rf_init_sw_nrssi_table(struct bwi_mac *mac) in bwi_rf_init_sw_nrssi_table() argument
2084 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_init_sw_nrssi_table()
2087 d = 0x1f - rf->rf_nrssi[0]; in bwi_rf_init_sw_nrssi_table()
2091 val = (((i - d) * rf->rf_nrssi_slope) / 0x10000) + 0x3a; in bwi_rf_init_sw_nrssi_table()
2097 rf->rf_nrssi_table[i] = val; in bwi_rf_init_sw_nrssi_table()
2102 bwi_rf_init_hw_nrssi_table(struct bwi_mac *mac, uint16_t adjust) in bwi_rf_init_hw_nrssi_table() argument
2109 val = bwi_nrssi_read(mac, i); in bwi_rf_init_hw_nrssi_table()
2111 val -= adjust; in bwi_rf_init_hw_nrssi_table()
2112 if (val < -32) in bwi_rf_init_hw_nrssi_table()
2113 val = -32; in bwi_rf_init_hw_nrssi_table()
2117 bwi_nrssi_write(mac, i, val); in bwi_rf_init_hw_nrssi_table()
2122 bwi_rf_set_nrssi_thr_11b(struct bwi_mac *mac) in bwi_rf_set_nrssi_thr_11b() argument
2124 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_set_nrssi_thr_11b()
2127 if (rf->rf_type != BWI_RF_T_BCM2050 || in bwi_rf_set_nrssi_thr_11b()
2128 (mac->mac_sc->sc_card_flags & BWI_CARD_F_SW_NRSSI) == 0) in bwi_rf_set_nrssi_thr_11b()
2134 if (rf->rf_rev >= 6) { in bwi_rf_set_nrssi_thr_11b()
2135 thr = (rf->rf_nrssi[1] - rf->rf_nrssi[0]) * 32; in bwi_rf_set_nrssi_thr_11b()
2136 thr += 20 * (rf->rf_nrssi[0] + 1); in bwi_rf_set_nrssi_thr_11b()
2139 thr = rf->rf_nrssi[1] - 5; in bwi_rf_set_nrssi_thr_11b()
2146 PHY_READ(mac, BWI_PHYR_NRSSI_THR_11B); /* dummy read */ in bwi_rf_set_nrssi_thr_11b()
2147 PHY_WRITE(mac, BWI_PHYR_NRSSI_THR_11B, (((uint16_t)thr) << 8) | 0x1c); in bwi_rf_set_nrssi_thr_11b()
2149 if (rf->rf_rev >= 6) { in bwi_rf_set_nrssi_thr_11b()
2150 PHY_WRITE(mac, 0x87, 0xe0d); in bwi_rf_set_nrssi_thr_11b()
2151 PHY_WRITE(mac, 0x86, 0xc0b); in bwi_rf_set_nrssi_thr_11b()
2152 PHY_WRITE(mac, 0x85, 0xa09); in bwi_rf_set_nrssi_thr_11b()
2153 PHY_WRITE(mac, 0x84, 0x808); in bwi_rf_set_nrssi_thr_11b()
2154 PHY_WRITE(mac, 0x83, 0x808); in bwi_rf_set_nrssi_thr_11b()
2155 PHY_WRITE(mac, 0x82, 0x604); in bwi_rf_set_nrssi_thr_11b()
2156 PHY_WRITE(mac, 0x81, 0x302); in bwi_rf_set_nrssi_thr_11b()
2157 PHY_WRITE(mac, 0x80, 0x100); in bwi_rf_set_nrssi_thr_11b()
2164 val *= (rf->rf_nrssi[1] - rf->rf_nrssi[0]); in _nrssi_threshold()
2165 val += (rf->rf_nrssi[0] << 6); in _nrssi_threshold()
2171 if (val < -31) in _nrssi_threshold()
2172 val = -31; in _nrssi_threshold()
2179 bwi_rf_set_nrssi_thr_11g(struct bwi_mac *mac) in bwi_rf_set_nrssi_thr_11g() argument
2187 if ((mac->mac_phy.phy_flags & BWI_PHY_F_LINKED) == 0 || in bwi_rf_set_nrssi_thr_11g()
2188 (mac->mac_sc->sc_card_flags & BWI_CARD_F_SW_NRSSI) == 0) { in bwi_rf_set_nrssi_thr_11g()
2191 nrssi = bwi_nrssi_read(mac, 0x20); in bwi_rf_set_nrssi_thr_11g()
2193 nrssi -= 64; in bwi_rf_set_nrssi_thr_11g()
2204 thr1 = _nrssi_threshold(&mac->mac_rf, 0x11); in bwi_rf_set_nrssi_thr_11g()
2205 thr2 = _nrssi_threshold(&mac->mac_rf, 0xe); in bwi_rf_set_nrssi_thr_11g()
2213 PHY_FILT_SETBITS(mac, BWI_PHYR_NRSSI_THR_11G, 0xf000, thr); in bwi_rf_set_nrssi_thr_11g()
2220 bwi_rf_clear_tssi(struct bwi_mac *mac) in bwi_rf_clear_tssi() argument
2223 if (mac->mac_phy.phy_mode == IEEE80211_MODE_11A) { in bwi_rf_clear_tssi()
2233 MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, in bwi_rf_clear_tssi()
2238 MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, in bwi_rf_clear_tssi()
2249 rf->rf_flags &= ~BWI_RF_CLEAR_FLAGS; in bwi_rf_clear_state()
2250 bzero(rf->rf_lo, sizeof(rf->rf_lo)); in bwi_rf_clear_state()
2251 bzero(rf->rf_lo_used, sizeof(rf->rf_lo_used)); in bwi_rf_clear_state()
2253 rf->rf_nrssi_slope = 0; in bwi_rf_clear_state()
2254 rf->rf_nrssi[0] = BWI_INVALID_NRSSI; in bwi_rf_clear_state()
2255 rf->rf_nrssi[1] = BWI_INVALID_NRSSI; in bwi_rf_clear_state()
2258 rf->rf_nrssi_table[i] = i; in bwi_rf_clear_state()
2260 rf->rf_lo_gain = 0; in bwi_rf_clear_state()
2261 rf->rf_rx_gain = 0; in bwi_rf_clear_state()
2263 bcopy(rf->rf_txpower_map0, rf->rf_txpower_map, in bwi_rf_clear_state()
2264 sizeof(rf->rf_txpower_map)); in bwi_rf_clear_state()
2265 rf->rf_idle_tssi = rf->rf_idle_tssi0; in bwi_rf_clear_state()
2269 bwi_rf_on_11a(struct bwi_mac *mac) in bwi_rf_on_11a() argument
2275 bwi_rf_on_11bg(struct bwi_mac *mac) in bwi_rf_on_11bg() argument
2277 struct bwi_phy *phy = &mac->mac_phy; in bwi_rf_on_11bg()
2279 PHY_WRITE(mac, 0x15, 0x8000); in bwi_rf_on_11bg()
2280 PHY_WRITE(mac, 0x15, 0xcc00); in bwi_rf_on_11bg()
2281 if (phy->phy_flags & BWI_PHY_F_LINKED) in bwi_rf_on_11bg()
2282 PHY_WRITE(mac, 0x15, 0xc0); in bwi_rf_on_11bg()
2284 PHY_WRITE(mac, 0x15, 0); in bwi_rf_on_11bg()
2286 bwi_rf_set_chan(mac, 6 /* XXX */, 1); in bwi_rf_on_11bg()
2290 bwi_rf_set_ant_mode(struct bwi_mac *mac, int ant_mode) in bwi_rf_set_ant_mode() argument
2292 struct bwi_softc *sc = mac->mac_sc; in bwi_rf_set_ant_mode()
2293 struct bwi_phy *phy = &mac->mac_phy; in bwi_rf_set_ant_mode()
2300 HFLAGS_CLRBITS(mac, BWI_HFLAG_AUTO_ANTDIV); in bwi_rf_set_ant_mode()
2302 if (phy->phy_mode == IEEE80211_MODE_11B) { in bwi_rf_set_ant_mode()
2304 if (mac->mac_rev == 2) in bwi_rf_set_ant_mode()
2309 PHY_FILT_SETBITS(mac, 0x3e2, 0xfe7f, val); in bwi_rf_set_ant_mode()
2313 PHY_FILT_SETBITS(mac, 0x401, 0x7e7f, val); in bwi_rf_set_ant_mode()
2316 PHY_CLRBITS(mac, 0x42b, 0x100); in bwi_rf_set_ant_mode()
2318 if (phy->phy_mode == IEEE80211_MODE_11A) { in bwi_rf_set_ant_mode()
2322 PHY_SETBITS(mac, 0x48c, 0x2000); in bwi_rf_set_ant_mode()
2324 PHY_CLRBITS(mac, 0x48c, 0x2000); in bwi_rf_set_ant_mode()
2326 if (phy->phy_rev >= 2) { in bwi_rf_set_ant_mode()
2327 PHY_SETBITS(mac, 0x461, 0x10); in bwi_rf_set_ant_mode()
2328 PHY_FILT_SETBITS(mac, 0x4ad, 0xff00, 0x15); in bwi_rf_set_ant_mode()
2329 if (phy->phy_rev == 2) { in bwi_rf_set_ant_mode()
2330 PHY_WRITE(mac, 0x427, 0x8); in bwi_rf_set_ant_mode()
2332 PHY_FILT_SETBITS(mac, 0x427, in bwi_rf_set_ant_mode()
2336 if (phy->phy_rev >= 6) in bwi_rf_set_ant_mode()
2337 PHY_WRITE(mac, 0x49b, 0xdc); in bwi_rf_set_ant_mode()
2344 HFLAGS_SETBITS(mac, BWI_HFLAG_AUTO_ANTDIV); in bwi_rf_set_ant_mode()
2347 MOBJ_FILT_SETBITS_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_TX_BEACON, in bwi_rf_set_ant_mode()
2349 MOBJ_FILT_SETBITS_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_TX_ACK, in bwi_rf_set_ant_mode()
2351 MOBJ_FILT_SETBITS_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_TX_PROBE_RESP, in bwi_rf_set_ant_mode()
2355 if (phy->phy_mode == IEEE80211_MODE_11B) in bwi_rf_set_ant_mode()
2359 if (mac->mac_rev < 5) in bwi_rf_set_ant_mode()
2362 mac->mac_rf.rf_ant_mode = ant_mode; in bwi_rf_set_ant_mode()
2366 bwi_rf_get_latest_tssi(struct bwi_mac *mac, int8_t tssi[], uint16_t ofs) in bwi_rf_get_latest_tssi() argument
2373 val = MOBJ_READ_2(mac, BWI_COMM_MOBJ, ofs + i); in bwi_rf_get_latest_tssi()
2386 bwi_rf_tssi2dbm(struct bwi_mac *mac, int8_t tssi, int8_t *txpwr) in bwi_rf_tssi2dbm() argument
2388 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_tssi2dbm()
2391 pwr_idx = rf->rf_idle_tssi + (int)tssi - rf->rf_base_tssi; in bwi_rf_tssi2dbm()
2399 pwr_idx = BWI_TSSI_MAX - 1; in bwi_rf_tssi2dbm()
2402 *txpwr = rf->rf_txpower_map[pwr_idx]; in bwi_rf_tssi2dbm()
2407 bwi_rf_calc_rssi_bcm2050(struct bwi_mac *mac, const struct bwi_rxbuf_hdr *hdr) in bwi_rf_calc_rssi_bcm2050() argument
2412 rssi = hdr->rxh_rssi; in bwi_rf_calc_rssi_bcm2050()
2413 flags1 = le16toh(hdr->rxh_flags1); in bwi_rf_calc_rssi_bcm2050()
2414 flags3 = le16toh(hdr->rxh_flags3); in bwi_rf_calc_rssi_bcm2050()
2418 rssi -= 256; in bwi_rf_calc_rssi_bcm2050()
2422 rssi -= 4; in bwi_rf_calc_rssi_bcm2050()
2426 if (mac->mac_sc->sc_card_flags & BWI_CARD_F_SW_NRSSI) { in bwi_rf_calc_rssi_bcm2050()
2427 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_calc_rssi_bcm2050()
2430 rssi = BWI_NRSSI_TBLSZ - 1; in bwi_rf_calc_rssi_bcm2050()
2432 rssi = ((31 - (int)rf->rf_nrssi_table[rssi]) * -131) / 128; in bwi_rf_calc_rssi_bcm2050()
2433 rssi -= 67; in bwi_rf_calc_rssi_bcm2050()
2435 rssi = ((31 - rssi) * -149) / 128; in bwi_rf_calc_rssi_bcm2050()
2436 rssi -= 68; in bwi_rf_calc_rssi_bcm2050()
2439 if (mac->mac_phy.phy_mode != IEEE80211_MODE_11G) in bwi_rf_calc_rssi_bcm2050()
2445 lna_gain = __SHIFTOUT(le16toh(hdr->rxh_phyinfo), in bwi_rf_calc_rssi_bcm2050()
2447 DPRINTF(mac->mac_sc, BWI_DBG_RF | BWI_DBG_RX, in bwi_rf_calc_rssi_bcm2050()
2449 lna_gain, le16toh(hdr->rxh_phyinfo)); in bwi_rf_calc_rssi_bcm2050()
2477 bwi_rf_calc_rssi_bcm2053(struct bwi_mac *mac, const struct bwi_rxbuf_hdr *hdr) in bwi_rf_calc_rssi_bcm2053() argument
2482 rssi = (((int)hdr->rxh_rssi - 11) * 103) / 64; in bwi_rf_calc_rssi_bcm2053()
2484 flags1 = le16toh(hdr->rxh_flags1); in bwi_rf_calc_rssi_bcm2053()
2486 rssi -= 109; in bwi_rf_calc_rssi_bcm2053()
2488 rssi -= 83; in bwi_rf_calc_rssi_bcm2053()
2493 bwi_rf_calc_rssi_bcm2060(struct bwi_mac *mac, const struct bwi_rxbuf_hdr *hdr) in bwi_rf_calc_rssi_bcm2060() argument
2497 rssi = hdr->rxh_rssi; in bwi_rf_calc_rssi_bcm2060()
2499 rssi -= 256; in bwi_rf_calc_rssi_bcm2060()
2504 bwi_rf_calc_noise_bcm2050(struct bwi_mac *mac) in bwi_rf_calc_noise_bcm2050() argument
2509 val = MOBJ_READ_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_RF_NOISE); in bwi_rf_calc_noise_bcm2050()
2512 if (mac->mac_sc->sc_card_flags & BWI_CARD_F_SW_NRSSI) { in bwi_rf_calc_noise_bcm2050()
2513 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_calc_noise_bcm2050()
2516 noise = BWI_NRSSI_TBLSZ - 1; in bwi_rf_calc_noise_bcm2050()
2518 noise = ((31 - (int)rf->rf_nrssi_table[noise]) * -131) / 128; in bwi_rf_calc_noise_bcm2050()
2519 noise -= 67; in bwi_rf_calc_noise_bcm2050()
2521 noise = ((31 - noise) * -149) / 128; in bwi_rf_calc_noise_bcm2050()
2522 noise -= 68; in bwi_rf_calc_noise_bcm2050()
2528 bwi_rf_calc_noise_bcm2053(struct bwi_mac *mac) in bwi_rf_calc_noise_bcm2053() argument
2533 val = MOBJ_READ_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_RF_NOISE); in bwi_rf_calc_noise_bcm2053()
2536 noise = ((noise - 11) * 103) / 64; in bwi_rf_calc_noise_bcm2053()
2537 noise -= 109; in bwi_rf_calc_noise_bcm2053()
2542 bwi_rf_calc_noise_bcm2060(struct bwi_mac *mac) in bwi_rf_calc_noise_bcm2060() argument
2549 bwi_rf_lo_measure_11b(struct bwi_mac *mac) in bwi_rf_lo_measure_11b() argument
2556 PHY_WRITE(mac, 0x15, 0xafa0); in bwi_rf_lo_measure_11b()
2558 PHY_WRITE(mac, 0x15, 0xefa0); in bwi_rf_lo_measure_11b()
2560 PHY_WRITE(mac, 0x15, 0xffa0); in bwi_rf_lo_measure_11b()
2563 val += PHY_READ(mac, 0x2c); in bwi_rf_lo_measure_11b()
2569 bwi_rf_lo_update_11b(struct bwi_mac *mac) in bwi_rf_lo_update_11b() argument
2571 struct bwi_softc *sc = mac->mac_sc; in bwi_rf_lo_update_11b()
2572 struct bwi_rf *rf = &mac->mac_rf; in bwi_rf_lo_update_11b()
2586 SAVE_PHY_REG(mac, ®s, 15); in bwi_rf_lo_update_11b()
2587 rf52 = RF_READ(mac, 0x52) & 0xfff0; in bwi_rf_lo_update_11b()
2588 if (rf->rf_type == BWI_RF_T_BCM2050) { in bwi_rf_lo_update_11b()
2589 SAVE_PHY_REG(mac, ®s, 0a); in bwi_rf_lo_update_11b()
2590 SAVE_PHY_REG(mac, ®s, 2a); in bwi_rf_lo_update_11b()
2591 SAVE_PHY_REG(mac, ®s, 35); in bwi_rf_lo_update_11b()
2592 SAVE_PHY_REG(mac, ®s, 03); in bwi_rf_lo_update_11b()
2593 SAVE_PHY_REG(mac, ®s, 01); in bwi_rf_lo_update_11b()
2594 SAVE_PHY_REG(mac, ®s, 30); in bwi_rf_lo_update_11b()
2596 SAVE_RF_REG(mac, ®s, 43); in bwi_rf_lo_update_11b()
2597 SAVE_RF_REG(mac, ®s, 7a); in bwi_rf_lo_update_11b()
2601 SAVE_RF_REG(mac, ®s, 52); in bwi_rf_lo_update_11b()
2604 PHY_WRITE(mac, 0x30, 0xff); in bwi_rf_lo_update_11b()
2606 PHY_WRITE(mac, 0x35, regs.phy_35 & 0xff7f); in bwi_rf_lo_update_11b()
2607 RF_WRITE(mac, 0x7a, regs.rf_7a & 0xfff0); in bwi_rf_lo_update_11b()
2610 PHY_WRITE(mac, 0x15, 0xb000); in bwi_rf_lo_update_11b()
2612 if (rf->rf_type == BWI_RF_T_BCM2050) { in bwi_rf_lo_update_11b()
2613 PHY_WRITE(mac, 0x2b, 0x203); in bwi_rf_lo_update_11b()
2614 PHY_WRITE(mac, 0x2a, 0x8a3); in bwi_rf_lo_update_11b()
2616 PHY_WRITE(mac, 0x2b, 0x1402); in bwi_rf_lo_update_11b()
2626 RF_WRITE(mac, 0x52, rf52 | i); in bwi_rf_lo_update_11b()
2627 bwi_rf_lo_measure_11b(mac); /* Ignore return value */ in bwi_rf_lo_update_11b()
2630 RF_WRITE(mac, 0x52, rf52 | i); in bwi_rf_lo_update_11b()
2632 val = bwi_rf_lo_measure_11b(mac) / 10; in bwi_rf_lo_update_11b()
2638 RF_WRITE(mac, 0x52, rf52 | rf_val); in bwi_rf_lo_update_11b()
2646 for (i = -4; i < 5; i += 2) { in bwi_rf_lo_update_11b()
2649 for (j = -4; j < 5; j += 2) { in bwi_rf_lo_update_11b()
2655 PHY_WRITE(mac, 0x2f, phy2f); in bwi_rf_lo_update_11b()
2657 val = bwi_rf_lo_measure_11b(mac) / 10; in bwi_rf_lo_update_11b()
2664 PHY_WRITE(mac, 0x2f, phy_val + 0x101); in bwi_rf_lo_update_11b()
2669 if (rf->rf_type == BWI_RF_T_BCM2050) { in bwi_rf_lo_update_11b()
2670 RESTORE_PHY_REG(mac, ®s, 0a); in bwi_rf_lo_update_11b()
2671 RESTORE_PHY_REG(mac, ®s, 2a); in bwi_rf_lo_update_11b()
2672 RESTORE_PHY_REG(mac, ®s, 35); in bwi_rf_lo_update_11b()
2673 RESTORE_PHY_REG(mac, ®s, 03); in bwi_rf_lo_update_11b()
2674 RESTORE_PHY_REG(mac, ®s, 01); in bwi_rf_lo_update_11b()
2675 RESTORE_PHY_REG(mac, ®s, 30); in bwi_rf_lo_update_11b()
2677 RESTORE_RF_REG(mac, ®s, 43); in bwi_rf_lo_update_11b()
2678 RESTORE_RF_REG(mac, ®s, 7a); in bwi_rf_lo_update_11b()
2680 RF_FILT_SETBITS(mac, 0x52, 0xf, regs.rf_52); in bwi_rf_lo_update_11b()
2684 RESTORE_PHY_REG(mac, ®s, 15); in bwi_rf_lo_update_11b()
2686 bwi_rf_work_around(mac, rf->rf_curchan); in bwi_rf_lo_update_11b()