Lines Matching +full:d +full:- +full:phy

1 /*-
2 * Copyright (c) 2009-2010 Weongyo Jeong <weongyo@freebsd.org>
143 if (mac->mac_phy.hwpctl == 0 || mac->mac_phy.use_hwpctl == NULL) in bwn_has_hwpctl()
145 return (mac->mac_phy.use_hwpctl(mac)); in bwn_has_hwpctl()
151 struct bwn_softc *sc = mac->mac_sc; in bwn_phy_g_attach()
152 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_g_attach() local
153 struct bwn_phy_g *pg = &phy->phy_g; in bwn_phy_g_attach()
166 "%d\n", (_name), error); \ in bwn_phy_g_attach()
171 BWN_PHY_G_READVAR(sc->sc_dev, int8, BHND_NVAR_PA0ITSSIT, &bg); in bwn_phy_g_attach()
172 BWN_PHY_G_READVAR(sc->sc_dev, int16, BHND_NVAR_PA0B0, &pab0); in bwn_phy_g_attach()
173 BWN_PHY_G_READVAR(sc->sc_dev, int16, BHND_NVAR_PA0B1, &pab1); in bwn_phy_g_attach()
174 BWN_PHY_G_READVAR(sc->sc_dev, int16, BHND_NVAR_PA0B2, &pab2); in bwn_phy_g_attach()
175 BWN_PHY_G_READVAR(sc->sc_dev, int16, BHND_NVAR_PA0MAXPWR, in bwn_phy_g_attach()
176 &pg->pg_pa0maxpwr); in bwn_phy_g_attach()
180 pg->pg_flags = 0; in bwn_phy_g_attach()
181 if (pab0 == 0 || pab1 == 0 || pab2 == 0 || pab0 == -1 || pab1 == -1 || in bwn_phy_g_attach()
182 pab2 == -1) { in bwn_phy_g_attach()
183 pg->pg_idletssi = 52; in bwn_phy_g_attach()
184 pg->pg_tssi2dbm = bwn_phy_g_tssi2dbm_table; in bwn_phy_g_attach()
188 pg->pg_idletssi = (bg == 0 || bg == -1) ? 62 : bg; in bwn_phy_g_attach()
189 pg->pg_tssi2dbm = (uint8_t *)malloc(64, M_DEVBUF, M_NOWAIT | M_ZERO); in bwn_phy_g_attach()
190 if (pg->pg_tssi2dbm == NULL) { in bwn_phy_g_attach()
191 device_printf(sc->sc_dev, "failed to allocate buffer\n"); in bwn_phy_g_attach()
204 device_printf(sc->sc_dev, in bwn_phy_g_attach()
206 free(pg->pg_tssi2dbm, M_DEVBUF); in bwn_phy_g_attach()
209 q = BWN_TSSI2DBM(f * 4096 - BWN_TSSI2DBM(m2 * f, 16) * in bwn_phy_g_attach()
211 delta = abs(q - f); in bwn_phy_g_attach()
216 pg->pg_tssi2dbm[i] = MIN(MAX(BWN_TSSI2DBM(m1 * f, 8192), -127), in bwn_phy_g_attach()
220 pg->pg_flags |= BWN_PHY_G_FLAG_TSSITABLE_ALLOC; in bwn_phy_g_attach()
227 struct bwn_phy_g *pg = &mac->mac_phy.phy_g; in bwn_phy_g_detach()
229 if (pg->pg_flags & BWN_PHY_G_FLAG_TSSITABLE_ALLOC) { in bwn_phy_g_detach()
230 free(pg->pg_tssi2dbm, M_DEVBUF); in bwn_phy_g_detach()
231 pg->pg_tssi2dbm = NULL; in bwn_phy_g_detach()
233 pg->pg_flags = 0; in bwn_phy_g_detach()
239 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_g_init_pre() local
240 struct bwn_phy_g *pg = &phy->phy_g; in bwn_phy_g_init_pre()
245 tssi2dbm = pg->pg_tssi2dbm; in bwn_phy_g_init_pre()
246 idletssi = pg->pg_idletssi; in bwn_phy_g_init_pre()
250 pg->pg_tssi2dbm = tssi2dbm; in bwn_phy_g_init_pre()
251 pg->pg_idletssi = idletssi; in bwn_phy_g_init_pre()
253 memset(pg->pg_minlowsig, 0xff, sizeof(pg->pg_minlowsig)); in bwn_phy_g_init_pre()
255 for (i = 0; i < N(pg->pg_nrssi); i++) in bwn_phy_g_init_pre()
256 pg->pg_nrssi[i] = -1000; in bwn_phy_g_init_pre()
257 for (i = 0; i < N(pg->pg_nrssi_lt); i++) in bwn_phy_g_init_pre()
258 pg->pg_nrssi_lt[i] = i; in bwn_phy_g_init_pre()
259 pg->pg_lofcal = 0xffff; in bwn_phy_g_init_pre()
260 pg->pg_initval = 0xffff; in bwn_phy_g_init_pre()
261 pg->pg_immode = BWN_IMMODE_NONE; in bwn_phy_g_init_pre()
262 pg->pg_ofdmtab_dir = BWN_OFDMTAB_DIR_UNKNOWN; in bwn_phy_g_init_pre()
263 pg->pg_avgtssi = 0xff; in bwn_phy_g_init_pre()
265 pg->pg_loctl.tx_bias = 0xff; in bwn_phy_g_init_pre()
266 TAILQ_INIT(&pg->pg_loctl.calib_list); in bwn_phy_g_init_pre()
272 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_g_prepare_hw() local
273 struct bwn_phy_g *pg = &phy->phy_g; in bwn_phy_g_prepare_hw()
274 struct bwn_softc *sc = mac->mac_sc; in bwn_phy_g_prepare_hw()
275 struct bwn_txpwr_loctl *lo = &pg->pg_loctl; in bwn_phy_g_prepare_hw()
293 KASSERT(phy->type == BWN_PHYTYPE_G, ("%s fail", __func__)); in bwn_phy_g_prepare_hw()
295 if (phy->rf_ver == 0x2050 && phy->rf_rev < 6) in bwn_phy_g_prepare_hw()
296 pg->pg_bbatt.att = 0; in bwn_phy_g_prepare_hw()
298 pg->pg_bbatt.att = 2; in bwn_phy_g_prepare_hw()
301 pg->pg_rfatt.padmix = 0; in bwn_phy_g_prepare_hw()
303 if (sc->sc_board_info.board_vendor == PCI_VENDOR_BROADCOM && in bwn_phy_g_prepare_hw()
304 sc->sc_board_info.board_type == BHND_BOARD_BCM94309G) { in bwn_phy_g_prepare_hw()
305 if (sc->sc_board_info.board_rev < 0x43) { in bwn_phy_g_prepare_hw()
306 pg->pg_rfatt.att = 2; in bwn_phy_g_prepare_hw()
308 } else if (sc->sc_board_info.board_rev < 0x51) { in bwn_phy_g_prepare_hw()
309 pg->pg_rfatt.att = 3; in bwn_phy_g_prepare_hw()
314 if (phy->type == BWN_PHYTYPE_A) { in bwn_phy_g_prepare_hw()
315 pg->pg_rfatt.att = 0x60; in bwn_phy_g_prepare_hw()
319 switch (phy->rf_ver) { in bwn_phy_g_prepare_hw()
321 switch (phy->rf_rev) { in bwn_phy_g_prepare_hw()
323 pg->pg_rfatt.att = 5; in bwn_phy_g_prepare_hw()
326 if (phy->type == BWN_PHYTYPE_G) { in bwn_phy_g_prepare_hw()
327 if (sc->sc_board_info.board_vendor == in bwn_phy_g_prepare_hw()
329 sc->sc_board_info.board_type == in bwn_phy_g_prepare_hw()
331 sc->sc_board_info.board_rev >= 30) in bwn_phy_g_prepare_hw()
332 pg->pg_rfatt.att = 3; in bwn_phy_g_prepare_hw()
333 else if (sc->sc_board_info.board_vendor == in bwn_phy_g_prepare_hw()
335 sc->sc_board_info.board_type == in bwn_phy_g_prepare_hw()
337 pg->pg_rfatt.att = 3; in bwn_phy_g_prepare_hw()
339 pg->pg_rfatt.att = 1; in bwn_phy_g_prepare_hw()
341 if (sc->sc_board_info.board_vendor == in bwn_phy_g_prepare_hw()
343 sc->sc_board_info.board_type == in bwn_phy_g_prepare_hw()
345 sc->sc_board_info.board_rev >= 30) in bwn_phy_g_prepare_hw()
346 pg->pg_rfatt.att = 7; in bwn_phy_g_prepare_hw()
348 pg->pg_rfatt.att = 6; in bwn_phy_g_prepare_hw()
352 if (phy->type == BWN_PHYTYPE_G) { in bwn_phy_g_prepare_hw()
353 if (sc->sc_board_info.board_vendor == in bwn_phy_g_prepare_hw()
355 sc->sc_board_info.board_type == in bwn_phy_g_prepare_hw()
357 sc->sc_board_info.board_rev >= 30) in bwn_phy_g_prepare_hw()
358 pg->pg_rfatt.att = 3; in bwn_phy_g_prepare_hw()
359 else if (sc->sc_board_info.board_vendor == in bwn_phy_g_prepare_hw()
361 sc->sc_board_info.board_type == in bwn_phy_g_prepare_hw()
363 pg->pg_rfatt.att = 5; in bwn_phy_g_prepare_hw()
364 else if (sc->sc_cid.chip_id == in bwn_phy_g_prepare_hw()
366 pg->pg_rfatt.att = 4; in bwn_phy_g_prepare_hw()
368 pg->pg_rfatt.att = 3; in bwn_phy_g_prepare_hw()
370 pg->pg_rfatt.att = 6; in bwn_phy_g_prepare_hw()
373 pg->pg_rfatt.att = 5; in bwn_phy_g_prepare_hw()
377 pg->pg_rfatt.att = 1; in bwn_phy_g_prepare_hw()
381 pg->pg_rfatt.att = 5; in bwn_phy_g_prepare_hw()
384 pg->pg_rfatt.att = 0xa; in bwn_phy_g_prepare_hw()
385 pg->pg_rfatt.padmix = 1; in bwn_phy_g_prepare_hw()
389 pg->pg_rfatt.att = 5; in bwn_phy_g_prepare_hw()
394 switch (phy->rf_rev) { in bwn_phy_g_prepare_hw()
396 pg->pg_rfatt.att = 6; in bwn_phy_g_prepare_hw()
401 pg->pg_rfatt.att = 5; in bwn_phy_g_prepare_hw()
403 pg->pg_txctl = (bwn_phy_g_txctl(mac) << 4); in bwn_phy_g_prepare_hw()
406 lo->rfatt.array = rfatt0; in bwn_phy_g_prepare_hw()
407 lo->rfatt.len = N(rfatt0); in bwn_phy_g_prepare_hw()
408 lo->rfatt.min = 0; in bwn_phy_g_prepare_hw()
409 lo->rfatt.max = 9; in bwn_phy_g_prepare_hw()
412 if (phy->rf_ver == 0x2050 && phy->rf_rev == 8) { in bwn_phy_g_prepare_hw()
413 lo->rfatt.array = rfatt1; in bwn_phy_g_prepare_hw()
414 lo->rfatt.len = N(rfatt1); in bwn_phy_g_prepare_hw()
415 lo->rfatt.min = 0; in bwn_phy_g_prepare_hw()
416 lo->rfatt.max = 14; in bwn_phy_g_prepare_hw()
419 lo->rfatt.array = rfatt2; in bwn_phy_g_prepare_hw()
420 lo->rfatt.len = N(rfatt2); in bwn_phy_g_prepare_hw()
421 lo->rfatt.min = 0; in bwn_phy_g_prepare_hw()
422 lo->rfatt.max = 9; in bwn_phy_g_prepare_hw()
424 lo->bbatt.array = bbatt_0; in bwn_phy_g_prepare_hw()
425 lo->bbatt.len = N(bbatt_0); in bwn_phy_g_prepare_hw()
426 lo->bbatt.min = 0; in bwn_phy_g_prepare_hw()
427 lo->bbatt.max = 8; in bwn_phy_g_prepare_hw()
430 if (phy->rev == 1) { in bwn_phy_g_prepare_hw()
431 phy->gmode = 0; in bwn_phy_g_prepare_hw()
434 phy->gmode = 1; in bwn_phy_g_prepare_hw()
443 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_g_txctl() local
445 if (phy->rf_ver != 0x2050) in bwn_phy_g_txctl()
447 if (phy->rf_rev == 1) in bwn_phy_g_txctl()
449 if (phy->rf_rev < 6) in bwn_phy_g_txctl()
451 if (phy->rf_rev == 8) in bwn_phy_g_txctl()
467 struct bwn_txpwr_loctl *lo = &mac->mac_phy.phy_g.pg_loctl; in bwn_phy_g_exit()
472 TAILQ_FOREACH_SAFE(cal, &lo->calib_list, list, tmp) { in bwn_phy_g_exit()
473 TAILQ_REMOVE(&lo->calib_list, cal, list); in bwn_phy_g_exit()
498 KASSERT(reg != 1, ("%s:%d: fail", __func__, __LINE__)); in bwn_phy_g_rf_read()
507 KASSERT(reg != 1, ("%s:%d: fail", __func__, __LINE__)); in bwn_phy_g_rf_write()
516 return (mac->mac_phy.rev >= 6); in bwn_phy_g_hwpctl()
522 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_g_rf_onoff() local
523 struct bwn_phy_g *pg = &phy->phy_g; in bwn_phy_g_rf_onoff()
528 if (phy->rf_on) in bwn_phy_g_rf_onoff()
533 BWN_PHY_WRITE(mac, 0x15, (phy->gmode ? 0xc0 : 0x0)); in bwn_phy_g_rf_onoff()
534 if (pg->pg_flags & BWN_PHY_G_FLAG_RADIOCTX_VALID) { in bwn_phy_g_rf_onoff()
536 pg->pg_radioctx_over); in bwn_phy_g_rf_onoff()
538 pg->pg_radioctx_overval); in bwn_phy_g_rf_onoff()
539 pg->pg_flags &= ~BWN_PHY_G_FLAG_RADIOCTX_VALID; in bwn_phy_g_rf_onoff()
541 channel = phy->chan; in bwn_phy_g_rf_onoff()
549 pg->pg_radioctx_over = rfover; in bwn_phy_g_rf_onoff()
550 pg->pg_radioctx_overval = rfoverval; in bwn_phy_g_rf_onoff()
551 pg->pg_flags |= BWN_PHY_G_FLAG_RADIOCTX_VALID; in bwn_phy_g_rf_onoff()
577 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_g_set_antenna() local
607 if (phy->rev >= 2) { in bwn_phy_g_set_antenna()
613 if (phy->rev == 2) in bwn_phy_g_set_antenna()
620 if (phy->rev >= 6) in bwn_phy_g_set_antenna()
630 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_g_im() local
631 struct bwn_phy_g *pg = &phy->phy_g; in bwn_phy_g_im()
633 KASSERT(phy->type == BWN_PHYTYPE_G, ("%s: fail", __func__)); in bwn_phy_g_im()
636 if (phy->rev == 0 || !phy->gmode) in bwn_phy_g_im()
639 pg->pg_aci_wlan_automatic = 0; in bwn_phy_g_im()
646 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_g_recalc_txpwr() local
647 struct bwn_phy_g *pg = &phy->phy_g; in bwn_phy_g_recalc_txpwr()
648 struct bwn_softc *sc = mac->mac_sc; in bwn_phy_g_recalc_txpwr()
655 KASSERT(phy->type == BWN_PHYTYPE_G, ("%s: fail", __func__)); in bwn_phy_g_recalc_txpwr()
666 if (pg->pg_avgtssi != 0xff) in bwn_phy_g_recalc_txpwr()
667 tssi = (tssi + pg->pg_avgtssi) / 2; in bwn_phy_g_recalc_txpwr()
668 pg->pg_avgtssi = tssi; in bwn_phy_g_recalc_txpwr()
669 KASSERT(tssi < BWN_TSSI_MAX, ("%s:%d: fail", __func__, __LINE__)); in bwn_phy_g_recalc_txpwr()
671 max = pg->pg_pa0maxpwr; in bwn_phy_g_recalc_txpwr()
672 if (sc->sc_board_info.board_flags & BHND_BFL_PACTRL) in bwn_phy_g_recalc_txpwr()
673 max -= 3; in bwn_phy_g_recalc_txpwr()
675 device_printf(sc->sc_dev, "invalid max TX-power value\n"); in bwn_phy_g_recalc_txpwr()
677 pg->pg_pa0maxpwr = max; in bwn_phy_g_recalc_txpwr()
680 power = MIN(MAX((phy->txpower < 0) ? 0 : (phy->txpower << 2), 0), max) - in bwn_phy_g_recalc_txpwr()
681 (pg->pg_tssi2dbm[MIN(MAX(pg->pg_idletssi - pg->pg_curtssi + in bwn_phy_g_recalc_txpwr()
686 rfatt = -((power + 7) / 8); in bwn_phy_g_recalc_txpwr()
687 bbatt = (-(power / 2)) - (4 * rfatt); in bwn_phy_g_recalc_txpwr()
690 pg->pg_bbatt_delta = bbatt; in bwn_phy_g_recalc_txpwr()
691 pg->pg_rfatt_delta = rfatt; in bwn_phy_g_recalc_txpwr()
698 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_g_set_txpwr() local
699 struct bwn_phy_g *pg = &phy->phy_g; in bwn_phy_g_set_txpwr()
700 struct bwn_softc *sc = mac->mac_sc; in bwn_phy_g_set_txpwr()
708 bbatt = pg->pg_bbatt.att; in bwn_phy_g_set_txpwr()
709 bbatt += pg->pg_bbatt_delta; in bwn_phy_g_set_txpwr()
710 rfatt = pg->pg_rfatt.att; in bwn_phy_g_set_txpwr()
711 rfatt += pg->pg_rfatt_delta; in bwn_phy_g_set_txpwr()
714 txctl = pg->pg_txctl; in bwn_phy_g_set_txpwr()
715 if ((phy->rf_ver == 0x2050) && (phy->rf_rev == 2)) { in bwn_phy_g_set_txpwr()
721 } else if (sc->sc_board_info.board_flags & in bwn_phy_g_set_txpwr()
723 bbatt += 4 * (rfatt - 2); in bwn_phy_g_set_txpwr()
729 rfatt -= 3; in bwn_phy_g_set_txpwr()
732 rfatt -= 2; in bwn_phy_g_set_txpwr()
733 bbatt -= 2; in bwn_phy_g_set_txpwr()
737 pg->pg_txctl = txctl; in bwn_phy_g_set_txpwr()
739 pg->pg_rfatt.att = rfatt; in bwn_phy_g_set_txpwr()
740 pg->pg_bbatt.att = bbatt; in bwn_phy_g_set_txpwr()
746 bwn_phy_g_set_txpwr_sub(mac, &pg->pg_bbatt, &pg->pg_rfatt, in bwn_phy_g_set_txpwr()
747 pg->pg_txctl); in bwn_phy_g_set_txpwr()
757 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_g_task_15s() local
758 struct bwn_phy_g *pg = &phy->phy_g; in bwn_phy_g_task_15s()
759 struct bwn_softc *sc = mac->mac_sc; in bwn_phy_g_task_15s()
760 struct bwn_txpwr_loctl *lo = &pg->pg_loctl; in bwn_phy_g_task_15s()
772 expire = now - BWN_LO_PWRVEC_EXPIRE; in bwn_phy_g_task_15s()
773 if (ieee80211_time_before(lo->pwr_vec_read_time, expire)) { in bwn_phy_g_task_15s()
780 expire = now - BWN_LO_CALIB_EXPIRE; in bwn_phy_g_task_15s()
781 TAILQ_FOREACH_SAFE(cal, &lo->calib_list, list, tmp) { in bwn_phy_g_task_15s()
782 if (!ieee80211_time_before(cal->calib_time, expire)) in bwn_phy_g_task_15s()
784 if (BWN_BBATTCMP(&cal->bbatt, &pg->pg_bbatt) && in bwn_phy_g_task_15s()
785 BWN_RFATTCMP(&cal->rfatt, &pg->pg_rfatt)) { in bwn_phy_g_task_15s()
786 KASSERT(!expired, ("%s:%d: fail", __func__, __LINE__)); in bwn_phy_g_task_15s()
790 DPRINTF(sc, BWN_DEBUG_LO, "expired BB %u RF %u %u I %d Q %d\n", in bwn_phy_g_task_15s()
791 cal->bbatt.att, cal->rfatt.att, cal->rfatt.padmix, in bwn_phy_g_task_15s()
792 cal->ctl.i, cal->ctl.q); in bwn_phy_g_task_15s()
794 TAILQ_REMOVE(&lo->calib_list, cal, list); in bwn_phy_g_task_15s()
797 if (expired || TAILQ_EMPTY(&lo->calib_list)) { in bwn_phy_g_task_15s()
798 cal = bwn_lo_calibset(mac, &pg->pg_bbatt, in bwn_phy_g_task_15s()
799 &pg->pg_rfatt); in bwn_phy_g_task_15s()
801 device_printf(sc->sc_dev, in bwn_phy_g_task_15s()
805 TAILQ_INSERT_TAIL(&lo->calib_list, cal, list); in bwn_phy_g_task_15s()
806 bwn_lo_write(mac, &cal->ctl); in bwn_phy_g_task_15s()
816 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_g_task_60s() local
817 struct bwn_softc *sc = mac->mac_sc; in bwn_phy_g_task_60s()
818 uint8_t old = phy->chan; in bwn_phy_g_task_60s()
820 if (!(sc->sc_board_info.board_flags & BHND_BFL_ADCDIV)) in bwn_phy_g_task_60s()
825 if ((phy->rf_ver == 0x2050) && (phy->rf_rev == 8)) { in bwn_phy_g_task_60s()
842 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_g_init_sub() local
843 struct bwn_phy_g *pg = &phy->phy_g; in bwn_phy_g_init_sub()
844 struct bwn_softc *sc = mac->mac_sc; in bwn_phy_g_init_sub()
847 if (phy->rev == 1) in bwn_phy_g_init_sub()
852 if (phy->rev >= 2 || phy->gmode) in bwn_phy_g_init_sub()
855 if (phy->rev >= 2) { in bwn_phy_g_init_sub()
859 if (phy->rev == 2) { in bwn_phy_g_init_sub()
863 if (phy->rev > 5) { in bwn_phy_g_init_sub()
867 if (phy->gmode || phy->rev >= 2) { in bwn_phy_g_init_sub()
879 if ((phy->rev <= 2 && phy->gmode) || phy->rev >= 2) in bwn_phy_g_init_sub()
881 if (phy->rf_rev == 8) { in bwn_phy_g_init_sub()
885 if (BWN_HAS_LOOPBACK(phy)) in bwn_phy_g_init_sub()
888 if (phy->rf_rev != 8) { in bwn_phy_g_init_sub()
889 if (pg->pg_initval == 0xffff) in bwn_phy_g_init_sub()
890 pg->pg_initval = bwn_rf_init_bcm2050(mac); in bwn_phy_g_init_sub()
892 BWN_RF_WRITE(mac, 0x0078, pg->pg_initval); in bwn_phy_g_init_sub()
895 if (BWN_HAS_TXMAG(phy)) { in bwn_phy_g_init_sub()
898 | pg->pg_loctl.tx_bias | in bwn_phy_g_init_sub()
899 pg->pg_loctl.tx_magn); in bwn_phy_g_init_sub()
901 BWN_RF_SETMASK(mac, 0x52, 0xfff0, pg->pg_loctl.tx_bias); in bwn_phy_g_init_sub()
903 if (phy->rev >= 6) { in bwn_phy_g_init_sub()
905 (pg->pg_loctl.tx_bias << 12)); in bwn_phy_g_init_sub()
907 if (sc->sc_board_info.board_flags & BHND_BFL_PACTRL) in bwn_phy_g_init_sub()
911 if (phy->rev < 2) in bwn_phy_g_init_sub()
915 if (phy->gmode || phy->rev >= 2) { in bwn_phy_g_init_sub()
920 if (!(sc->sc_board_info.board_flags & BHND_BFL_ADCDIV)) { in bwn_phy_g_init_sub()
924 (uint16_t)MIN(MAX(bwn_nrssi_read(mac, i) - 0xffff, in bwn_phy_g_init_sub()
925 -32), 31)); in bwn_phy_g_init_sub()
928 } else if (phy->gmode || phy->rev >= 2) { in bwn_phy_g_init_sub()
929 if (pg->pg_nrssi[0] == -1000) { in bwn_phy_g_init_sub()
930 KASSERT(pg->pg_nrssi[1] == -1000, in bwn_phy_g_init_sub()
931 ("%s:%d: fail", __func__, __LINE__)); in bwn_phy_g_init_sub()
936 if (phy->rf_rev == 8) in bwn_phy_g_init_sub()
939 if ((sc->sc_cid.chip_id == BHND_CHIPID_BCM4306 in bwn_phy_g_init_sub()
940 && sc->sc_cid.chip_pkg == 2) || 0) { in bwn_phy_g_init_sub()
949 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_init_b5() local
950 struct bwn_phy_g *pg = &phy->phy_g; in bwn_phy_init_b5()
951 struct bwn_softc *sc = mac->mac_sc; in bwn_phy_init_b5()
955 if (phy->analog == 1) in bwn_phy_init_b5()
957 if ((sc->sc_board_info.board_vendor != PCI_VENDOR_BROADCOM) && in bwn_phy_init_b5()
958 (sc->sc_board_info.board_type != BHND_BOARD_BU4306)) { in bwn_phy_init_b5()
966 if (phy->rf_ver == 0x2050) in bwn_phy_init_b5()
969 if (phy->gmode || phy->rev >= 2) { in bwn_phy_init_b5()
970 if (phy->rf_ver == 0x2050) { in bwn_phy_init_b5()
986 if (mac->mac_flags & BWN_MAC_FLAG_BADFRAME_PREEMP) in bwn_phy_init_b5()
989 if (phy->analog == 1) { in bwn_phy_init_b5()
1000 if (phy->analog == 1) in bwn_phy_init_b5()
1005 if (phy->analog == 0) in bwn_phy_init_b5()
1008 old_channel = phy->chan; in bwn_phy_init_b5()
1011 if (phy->rf_ver != 0x2050) { in bwn_phy_init_b5()
1019 if (phy->rf_ver == 0x2050) { in bwn_phy_init_b5()
1033 bwn_phy_g_set_txpwr_sub(mac, &pg->pg_bbatt, &pg->pg_rfatt, in bwn_phy_init_b5()
1034 pg->pg_txctl); in bwn_phy_init_b5()
1036 if (phy->rf_ver == 0x2050) in bwn_phy_init_b5()
1045 struct bwn_phy *phy = &mac->mac_phy; in bwn_loopback_calcgain() local
1046 struct bwn_phy_g *pg = &phy->phy_g; in bwn_loopback_calcgain()
1047 struct bwn_softc *sc = mac->mac_sc; in bwn_loopback_calcgain()
1059 if (phy->rev != 1) { in bwn_loopback_calcgain()
1073 backup_bband = pg->pg_bbatt.att; in bwn_loopback_calcgain()
1084 if (phy->rev != 1) { in bwn_loopback_calcgain()
1100 if (phy->rev != 1) { in bwn_loopback_calcgain()
1106 if (phy->rf_rev == 8) in bwn_loopback_calcgain()
1114 if (phy->rev >= 3) in bwn_loopback_calcgain()
1126 if (sc->sc_board_info.board_flags & BHND_BFL_EXTLNA) { in bwn_loopback_calcgain()
1127 if (phy->rev >= 7) { in bwn_loopback_calcgain()
1135 loop_i_max = (phy->rf_rev == 8) ? 15 : 9; in bwn_loopback_calcgain()
1154 for (j = j - 8; j < 16; j++) { in bwn_loopback_calcgain()
1159 trsw_rx -= 3; in bwn_loopback_calcgain()
1167 if (phy->rev != 1) { in bwn_loopback_calcgain()
1194 pg->pg_max_lb_gain = in bwn_loopback_calcgain()
1195 ((loop1_inner_done * 6) - (loop1_outer_done * 4)) - 11; in bwn_loopback_calcgain()
1196 pg->pg_trsw_rx_gain = trsw_rx * 2; in bwn_loopback_calcgain()
1202 struct bwn_phy *phy = &mac->mac_phy; in bwn_rf_init_bcm2050() local
1224 if (phy->type == BWN_PHYTYPE_B) { in bwn_rf_init_bcm2050()
1230 } else if (phy->gmode || phy->rev >= 2) { in bwn_rf_init_bcm2050()
1242 if (BWN_HAS_LOOPBACK(phy)) { in bwn_rf_init_bcm2050()
1245 if (phy->rev >= 3) in bwn_rf_init_bcm2050()
1265 if (phy->analog == 0) in bwn_rf_init_bcm2050()
1268 if (phy->analog >= 2) in bwn_rf_init_bcm2050()
1278 if (phy->type == BWN_PHYTYPE_B) in bwn_rf_init_bcm2050()
1280 if (phy->gmode || phy->rev >= 2) { in bwn_rf_init_bcm2050()
1287 if (phy->gmode || phy->rev >= 2) { in bwn_rf_init_bcm2050()
1294 if (phy->rf_rev == 8) in bwn_rf_init_bcm2050()
1306 if (phy->gmode || phy->rev >= 2) { in bwn_rf_init_bcm2050()
1313 if (phy->gmode || phy->rev >= 2) { in bwn_rf_init_bcm2050()
1320 if (phy->gmode || phy->rev >= 2) { in bwn_rf_init_bcm2050()
1329 if (phy->gmode || phy->rev >= 2) { in bwn_rf_init_bcm2050()
1350 if (phy->gmode || phy->rev >= 2) { in bwn_rf_init_bcm2050()
1357 if (phy->gmode || phy->rev >= 2) { in bwn_rf_init_bcm2050()
1364 if (phy->gmode || phy->rev >= 2) { in bwn_rf_init_bcm2050()
1373 if (phy->gmode || phy->rev >= 2) { in bwn_rf_init_bcm2050()
1394 if (phy->analog != 0) in bwn_rf_init_bcm2050()
1397 bwn_spu_workaround(mac, phy->chan); in bwn_rf_init_bcm2050()
1398 if (phy->type == BWN_PHYTYPE_B) { in bwn_rf_init_bcm2050()
1401 } else if (phy->gmode) { in bwn_rf_init_bcm2050()
1412 if (BWN_HAS_LOOPBACK(phy)) { in bwn_rf_init_bcm2050()
1424 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_init_b6() local
1425 struct bwn_phy_g *pg = &phy->phy_g; in bwn_phy_init_b6()
1426 struct bwn_softc *sc = mac->mac_sc; in bwn_phy_init_b6()
1430 KASSERT(!(phy->rf_rev == 6 || phy->rf_rev == 7), in bwn_phy_init_b6()
1431 ("%s:%d: fail", __func__, __LINE__)); in bwn_phy_init_b6()
1435 if (phy->rf_rev == 4 || phy->rf_rev == 5) { in bwn_phy_init_b6()
1448 if (phy->rf_rev == 8) { in bwn_phy_init_b6()
1456 if (sc->sc_board_info.board_flags & BHND_BFL_ALTIQ) { in bwn_phy_init_b6()
1470 val -= 0x0202; in bwn_phy_init_b6()
1474 val -= 0x0202; in bwn_phy_init_b6()
1480 if (phy->type == BWN_PHYTYPE_G) { in bwn_phy_init_b6()
1489 old_channel = phy->chan; in bwn_phy_init_b6()
1495 if (phy->rf_rev < 6 || phy->rf_rev == 8) { in bwn_phy_init_b6()
1499 if (phy->rf_rev <= 2) { in bwn_phy_init_b6()
1510 if (phy->rf_rev >= 6) in bwn_phy_init_b6()
1515 bwn_phy_g_set_txpwr_sub(mac, &pg->pg_bbatt, &pg->pg_rfatt, in bwn_phy_init_b6()
1516 pg->pg_txctl); in bwn_phy_init_b6()
1517 if (phy->rf_rev <= 5) in bwn_phy_init_b6()
1519 if (phy->rf_rev <= 2) in bwn_phy_init_b6()
1522 if (phy->analog == 4) { in bwn_phy_init_b6()
1527 if (phy->type == BWN_PHYTYPE_B) in bwn_phy_init_b6()
1528 KASSERT(0 == 1, ("%s:%d: fail", __func__, __LINE__)); in bwn_phy_init_b6()
1529 else if (phy->type == BWN_PHYTYPE_G) in bwn_phy_init_b6()
1536 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_init_a() local
1537 struct bwn_softc *sc = mac->mac_sc; in bwn_phy_init_a()
1539 KASSERT(phy->type == BWN_PHYTYPE_A || phy->type == BWN_PHYTYPE_G, in bwn_phy_init_a()
1540 ("%s:%d: fail", __func__, __LINE__)); in bwn_phy_init_a()
1542 if (phy->rev >= 6) { in bwn_phy_init_a()
1543 if (phy->type == BWN_PHYTYPE_A) in bwn_phy_init_a()
1553 if (phy->type == BWN_PHYTYPE_G && in bwn_phy_init_a()
1554 (sc->sc_board_info.board_flags & BHND_BFL_PACTRL)) in bwn_phy_init_a()
1570 struct bwn_phy *phy = &mac->mac_phy; in bwn_wa_agc() local
1572 if (phy->rev == 1) { in bwn_wa_agc()
1599 if (phy->rev == 1) in bwn_wa_agc()
1610 if (phy->rev == 1) { in bwn_wa_agc()
1617 if (phy->rev >= 6) { in bwn_wa_agc()
1625 if (phy->rev == 1) { in bwn_wa_agc()
1640 if (phy->rev >= 6) { in bwn_wa_agc()
1650 struct bwn_phy *phy = &mac->mac_phy; in bwn_wa_grev1() local
1656 KASSERT(phy->type == BWN_PHYTYPE_G, ("%s fail", __func__)); in bwn_wa_grev1()
1659 if (phy->rev == 1) { in bwn_wa_grev1()
1661 } else if (phy->rev == 2) { in bwn_wa_grev1()
1675 /* XXX support PHY-A??? */ in bwn_wa_grev1()
1680 /* XXX support PHY-A??? */ in bwn_wa_grev1()
1681 if (phy->rev == 1) in bwn_wa_grev1()
1694 /* XXX support PHY-A??? */ in bwn_wa_grev1()
1695 if (phy->rev >= 6) { in bwn_wa_grev1()
1708 if (phy->rev == 1) { in bwn_wa_grev1()
1723 struct bwn_phy *phy = &mac->mac_phy; in bwn_wa_grev26789() local
1728 KASSERT(phy->type == BWN_PHYTYPE_G, ("%s fail", __func__)); in bwn_wa_grev26789()
1733 if (phy->rev == 1) in bwn_wa_grev26789()
1735 else if (phy->rev == 2) { in bwn_wa_grev26789()
1749 /* XXX support PHY-A??? */ in bwn_wa_grev26789()
1750 if (phy->rev == 1) in bwn_wa_grev26789()
1759 /* XXX support PHY-A??? */ in bwn_wa_grev26789()
1760 if (phy->rev >= 6) { in bwn_wa_grev26789()
1773 if (phy->rev == 1) { in bwn_wa_grev26789()
1786 if (phy->type == BWN_PHYTYPE_A) in bwn_wa_grev26789()
1803 struct bwn_phy *phy = &mac->mac_phy; in bwn_wa_init() local
1804 struct bwn_softc *sc = mac->mac_sc; in bwn_wa_init()
1806 KASSERT(phy->type == BWN_PHYTYPE_G, ("%s fail", __func__)); in bwn_wa_init()
1808 switch (phy->rev) { in bwn_wa_init()
1820 KASSERT(0 == 1, ("%s:%d: fail", __func__, __LINE__)); in bwn_wa_init()
1823 if (sc->sc_board_info.board_vendor != PCI_VENDOR_BROADCOM || in bwn_wa_init()
1824 sc->sc_board_info.board_type != BHND_BOARD_BU4306 || in bwn_wa_init()
1825 sc->sc_board_info.board_rev != 0x17) { in bwn_wa_init()
1826 if (phy->rev < 2) { in bwn_wa_init()
1834 if ((sc->sc_board_info.board_flags & in bwn_wa_init()
1836 (phy->rev >= 7)) { in bwn_wa_init()
1853 if (sc->sc_board_info.board_flags & BHND_BFL_FEM) { in bwn_wa_init()
1866 struct bwn_phy_g *pg = &mac->mac_phy.phy_g; in bwn_ofdmtab_write_2()
1870 if ((pg->pg_ofdmtab_dir != BWN_OFDMTAB_DIR_WRITE) || in bwn_ofdmtab_write_2()
1871 (addr - 1 != pg->pg_ofdmtab_addr)) { in bwn_ofdmtab_write_2()
1873 pg->pg_ofdmtab_dir = BWN_OFDMTAB_DIR_WRITE; in bwn_ofdmtab_write_2()
1875 pg->pg_ofdmtab_addr = addr; in bwn_ofdmtab_write_2()
1883 struct bwn_phy_g *pg = &mac->mac_phy.phy_g; in bwn_ofdmtab_write_4()
1887 if ((pg->pg_ofdmtab_dir != BWN_OFDMTAB_DIR_WRITE) || in bwn_ofdmtab_write_4()
1888 (addr - 1 != pg->pg_ofdmtab_addr)) { in bwn_ofdmtab_write_4()
1890 pg->pg_ofdmtab_dir = BWN_OFDMTAB_DIR_WRITE; in bwn_ofdmtab_write_4()
1892 pg->pg_ofdmtab_addr = addr; in bwn_ofdmtab_write_4()
1912 KASSERT(mac->mac_phy.type == BWN_PHYTYPE_G, in bwn_lo_write()
1913 ("%s:%d: fail", __func__, __LINE__)); in bwn_lo_write()
1915 value = (uint8_t) (ctl->q); in bwn_lo_write()
1916 value |= ((uint8_t) (ctl->i)) << 8; in bwn_lo_write()
1924 struct bwn_phy *phy = &mac->mac_phy; in bwn_lo_calcfeed() local
1925 struct bwn_softc *sc = mac->mac_sc; in bwn_lo_calcfeed()
1929 if (phy->gmode) { in bwn_lo_calcfeed()
1934 ("%s:%d: fail", __func__, __LINE__)); in bwn_lo_calcfeed()
1936 ("%s:%d: fail", __func__, __LINE__)); in bwn_lo_calcfeed()
1941 if ((sc->sc_board_info.board_flags & BHND_BFL_EXTLNA) && in bwn_lo_calcfeed()
1942 phy->rev > 6) in bwn_lo_calcfeed()
1975 struct bwn_phy *phy = &mac->mac_phy; in bwn_lo_txctl_regtable() local
1978 if (phy->type == BWN_PHYTYPE_B) { in bwn_lo_txctl_regtable()
1980 if (phy->rf_rev <= 5) { in bwn_lo_txctl_regtable()
1988 if (phy->rev >= 2 && phy->rf_rev == 8) { in bwn_lo_txctl_regtable()
2009 struct bwn_phy *phy = &mac->mac_phy; in bwn_lo_measure_txctl_values() local
2010 struct bwn_phy_g *pg = &phy->phy_g; in bwn_lo_measure_txctl_values()
2011 struct bwn_txpwr_loctl *lo = &pg->pg_loctl; in bwn_lo_measure_txctl_values()
2024 if (!BWN_HAS_LOOPBACK(phy)) { in bwn_lo_measure_txctl_values()
2032 lb_gain = pg->pg_max_lb_gain / 2; in bwn_lo_measure_txctl_values()
2035 pga = abs(10 - lb_gain) / 6; in bwn_lo_measure_txctl_values()
2043 if ((phy->rev >= 2) && in bwn_lo_measure_txctl_values()
2044 (phy->rf_ver == 0x2050) && (phy->rf_rev == 8)) in bwn_lo_measure_txctl_values()
2047 if ((10 - lb_gain) < cmp_val) in bwn_lo_measure_txctl_values()
2048 tmp = (10 - lb_gain); in bwn_lo_measure_txctl_values()
2068 if (BWN_HAS_TXMAG(phy)) { in bwn_lo_measure_txctl_values()
2083 lo->tx_bias = tx_bias; in bwn_lo_measure_txctl_values()
2084 lo->tx_magn = tx_magn; in bwn_lo_measure_txctl_values()
2087 if (lo->tx_bias == 0) in bwn_lo_measure_txctl_values()
2092 & 0xff00) | lo->tx_bias | lo-> in bwn_lo_measure_txctl_values()
2096 lo->tx_magn = 0; in bwn_lo_measure_txctl_values()
2097 lo->tx_bias = 0; in bwn_lo_measure_txctl_values()
2101 BWN_GETTIME(lo->txctl_measured_time); in bwn_lo_measure_txctl_values()
2107 struct bwn_phy *phy = &mac->mac_phy; in bwn_lo_get_powervector() local
2108 struct bwn_phy_g *pg = &phy->phy_g; in bwn_lo_get_powervector()
2109 struct bwn_txpwr_loctl *lo = &pg->pg_loctl; in bwn_lo_get_powervector()
2120 lo->power_vector = power_vector; in bwn_lo_get_powervector()
2122 BWN_GETTIME(lo->pwr_vec_read_time); in bwn_lo_get_powervector()
2129 struct bwn_phy *phy = &mac->mac_phy; in bwn_lo_measure_gain_values() local
2130 struct bwn_phy_g *pg = &phy->phy_g; in bwn_lo_measure_gain_values()
2136 if (BWN_HAS_LOOPBACK(phy)) { in bwn_lo_measure_gain_values()
2140 trsw_rx_gain = pg->pg_trsw_rx_gain / 2; in bwn_lo_measure_gain_values()
2142 trsw_rx_gain = max_rx_gain - trsw_rx_gain; in bwn_lo_measure_gain_values()
2147 pg->pg_lna_lod_gain = 0; in bwn_lo_measure_gain_values()
2149 pg->pg_lna_lod_gain = 1; in bwn_lo_measure_gain_values()
2150 trsw_rx_gain -= 8; in bwn_lo_measure_gain_values()
2153 pg->pg_pga_gain = trsw_rx_gain / 3; in bwn_lo_measure_gain_values()
2154 if (pg->pg_pga_gain >= 5) { in bwn_lo_measure_gain_values()
2155 pg->pg_pga_gain -= 5; in bwn_lo_measure_gain_values()
2156 pg->pg_lna_gain = 2; in bwn_lo_measure_gain_values()
2158 pg->pg_lna_gain = 0; in bwn_lo_measure_gain_values()
2160 pg->pg_lna_gain = 0; in bwn_lo_measure_gain_values()
2161 pg->pg_trsw_rx_gain = 0x20; in bwn_lo_measure_gain_values()
2163 pg->pg_lna_lod_gain = 1; in bwn_lo_measure_gain_values()
2164 pg->pg_pga_gain = 2; in bwn_lo_measure_gain_values()
2166 pg->pg_lna_lod_gain = 1; in bwn_lo_measure_gain_values()
2167 pg->pg_pga_gain = 1; in bwn_lo_measure_gain_values()
2169 pg->pg_lna_lod_gain = 1; in bwn_lo_measure_gain_values()
2170 pg->pg_pga_gain = 0; in bwn_lo_measure_gain_values()
2172 pg->pg_lna_lod_gain = 0; in bwn_lo_measure_gain_values()
2173 pg->pg_pga_gain = 0; in bwn_lo_measure_gain_values()
2178 if (pg->pg_lna_lod_gain == 0) in bwn_lo_measure_gain_values()
2188 struct bwn_phy *phy = &mac->mac_phy; in bwn_lo_save() local
2189 struct bwn_phy_g *pg = &phy->phy_g; in bwn_lo_save()
2190 struct bwn_softc *sc = mac->mac_sc; in bwn_lo_save()
2191 struct bwn_txpwr_loctl *lo = &pg->pg_loctl; in bwn_lo_save()
2196 sav->phy_lomask = BWN_PHY_READ(mac, BWN_PHY_LO_MASK); in bwn_lo_save()
2197 sav->phy_extg = BWN_PHY_READ(mac, BWN_PHY_EXTG(0x01)); in bwn_lo_save()
2198 sav->phy_dacctl_hwpctl = BWN_PHY_READ(mac, BWN_PHY_DACCTL); in bwn_lo_save()
2199 sav->phy_cck4 = BWN_PHY_READ(mac, BWN_PHY_CCK(0x14)); in bwn_lo_save()
2200 sav->phy_hpwr_tssictl = BWN_PHY_READ(mac, BWN_PHY_HPWR_TSSICTL); in bwn_lo_save()
2207 if (phy->type == BWN_PHYTYPE_B && in bwn_lo_save()
2208 phy->rf_ver == 0x2050 && phy->rf_rev < 6) { in bwn_lo_save()
2212 if (phy->rev >= 2) { in bwn_lo_save()
2213 sav->phy_analogover = BWN_PHY_READ(mac, BWN_PHY_ANALOGOVER); in bwn_lo_save()
2214 sav->phy_analogoverval = in bwn_lo_save()
2216 sav->phy_rfover = BWN_PHY_READ(mac, BWN_PHY_RFOVER); in bwn_lo_save()
2217 sav->phy_rfoverval = BWN_PHY_READ(mac, BWN_PHY_RFOVERVAL); in bwn_lo_save()
2218 sav->phy_classctl = BWN_PHY_READ(mac, BWN_PHY_CLASSCTL); in bwn_lo_save()
2219 sav->phy_cck3 = BWN_PHY_READ(mac, BWN_PHY_CCK(0x3e)); in bwn_lo_save()
2220 sav->phy_crs0 = BWN_PHY_READ(mac, BWN_PHY_CRS0); in bwn_lo_save()
2226 if (phy->type == BWN_PHYTYPE_G) { in bwn_lo_save()
2227 if ((phy->rev >= 7) && in bwn_lo_save()
2228 (sc->sc_board_info.board_flags & in bwn_lo_save()
2239 sav->reg0 = BWN_READ_2(mac, 0x3f4); in bwn_lo_save()
2240 sav->reg1 = BWN_READ_2(mac, 0x3e2); in bwn_lo_save()
2241 sav->rf0 = BWN_RF_READ(mac, 0x43); in bwn_lo_save()
2242 sav->rf1 = BWN_RF_READ(mac, 0x7a); in bwn_lo_save()
2243 sav->phy_pgactl = BWN_PHY_READ(mac, BWN_PHY_PGACTL); in bwn_lo_save()
2244 sav->phy_cck2 = BWN_PHY_READ(mac, BWN_PHY_CCK(0x2a)); in bwn_lo_save()
2245 sav->phy_syncctl = BWN_PHY_READ(mac, BWN_PHY_SYNCCTL); in bwn_lo_save()
2246 sav->phy_dacctl = BWN_PHY_READ(mac, BWN_PHY_DACCTL); in bwn_lo_save()
2248 if (!BWN_HAS_TXMAG(phy)) { in bwn_lo_save()
2249 sav->rf2 = BWN_RF_READ(mac, 0x52); in bwn_lo_save()
2250 sav->rf2 &= 0x00f0; in bwn_lo_save()
2252 if (phy->type == BWN_PHYTYPE_B) { in bwn_lo_save()
2253 sav->phy_cck0 = BWN_PHY_READ(mac, BWN_PHY_CCK(0x30)); in bwn_lo_save()
2254 sav->phy_cck1 = BWN_PHY_READ(mac, BWN_PHY_CCK(0x06)); in bwn_lo_save()
2265 (phy->type == BWN_PHYTYPE_G) ? BWN_PHY_LO_MASK : BWN_PHY_CCK(0x2e); in bwn_lo_save()
2268 tmp = sav->phy_syncctl; in bwn_lo_save()
2270 tmp = sav->rf1; in bwn_lo_save()
2274 if (phy->type == BWN_PHYTYPE_G || in bwn_lo_save()
2275 (phy->type == BWN_PHYTYPE_B && in bwn_lo_save()
2276 phy->rf_ver == 0x2050 && phy->rf_rev >= 6)) { in bwn_lo_save()
2280 if (phy->rev >= 2) in bwn_lo_save()
2284 if (phy->type == BWN_PHYTYPE_G) in bwn_lo_save()
2288 if (ieee80211_time_before(lo->txctl_measured_time, in bwn_lo_save()
2289 (ts.tv_nsec / 1000000 + ts.tv_sec * 1000) - BWN_LO_TXCTL_EXPIRE)) in bwn_lo_save()
2292 if (phy->type == BWN_PHYTYPE_G && phy->rev >= 3) in bwn_lo_save()
2295 if (phy->type == BWN_PHYTYPE_B) in bwn_lo_save()
2305 struct bwn_phy *phy = &mac->mac_phy; in bwn_lo_restore() local
2306 struct bwn_phy_g *pg = &phy->phy_g; in bwn_lo_restore()
2309 if (phy->rev >= 2) { in bwn_lo_restore()
2311 tmp = (pg->pg_pga_gain << 8); in bwn_lo_restore()
2318 tmp = (pg->pg_pga_gain | 0xefa0); in bwn_lo_restore()
2321 if (phy->type == BWN_PHYTYPE_G) { in bwn_lo_restore()
2322 if (phy->rev >= 3) in bwn_lo_restore()
2326 if (phy->rev >= 2) in bwn_lo_restore()
2331 BWN_WRITE_2(mac, 0x3f4, sav->reg0); in bwn_lo_restore()
2332 BWN_PHY_WRITE(mac, BWN_PHY_PGACTL, sav->phy_pgactl); in bwn_lo_restore()
2333 BWN_PHY_WRITE(mac, BWN_PHY_CCK(0x2a), sav->phy_cck2); in bwn_lo_restore()
2334 BWN_PHY_WRITE(mac, BWN_PHY_SYNCCTL, sav->phy_syncctl); in bwn_lo_restore()
2335 BWN_PHY_WRITE(mac, BWN_PHY_DACCTL, sav->phy_dacctl); in bwn_lo_restore()
2336 BWN_RF_WRITE(mac, 0x43, sav->rf0); in bwn_lo_restore()
2337 BWN_RF_WRITE(mac, 0x7a, sav->rf1); in bwn_lo_restore()
2338 if (!BWN_HAS_TXMAG(phy)) { in bwn_lo_restore()
2339 tmp = sav->rf2; in bwn_lo_restore()
2342 BWN_WRITE_2(mac, 0x3e2, sav->reg1); in bwn_lo_restore()
2343 if (phy->type == BWN_PHYTYPE_B && in bwn_lo_restore()
2344 phy->rf_ver == 0x2050 && phy->rf_rev <= 5) { in bwn_lo_restore()
2345 BWN_PHY_WRITE(mac, BWN_PHY_CCK(0x30), sav->phy_cck0); in bwn_lo_restore()
2346 BWN_PHY_WRITE(mac, BWN_PHY_CCK(0x06), sav->phy_cck1); in bwn_lo_restore()
2348 if (phy->rev >= 2) { in bwn_lo_restore()
2349 BWN_PHY_WRITE(mac, BWN_PHY_ANALOGOVER, sav->phy_analogover); in bwn_lo_restore()
2351 sav->phy_analogoverval); in bwn_lo_restore()
2352 BWN_PHY_WRITE(mac, BWN_PHY_CLASSCTL, sav->phy_classctl); in bwn_lo_restore()
2353 BWN_PHY_WRITE(mac, BWN_PHY_RFOVER, sav->phy_rfover); in bwn_lo_restore()
2354 BWN_PHY_WRITE(mac, BWN_PHY_RFOVERVAL, sav->phy_rfoverval); in bwn_lo_restore()
2355 BWN_PHY_WRITE(mac, BWN_PHY_CCK(0x3e), sav->phy_cck3); in bwn_lo_restore()
2356 BWN_PHY_WRITE(mac, BWN_PHY_CRS0, sav->phy_crs0); in bwn_lo_restore()
2359 tmp = (sav->phy_lomask & 0xbfff); in bwn_lo_restore()
2361 BWN_PHY_WRITE(mac, BWN_PHY_EXTG(0x01), sav->phy_extg); in bwn_lo_restore()
2362 BWN_PHY_WRITE(mac, BWN_PHY_DACCTL, sav->phy_dacctl_hwpctl); in bwn_lo_restore()
2363 BWN_PHY_WRITE(mac, BWN_PHY_CCK(0x14), sav->phy_cck4); in bwn_lo_restore()
2364 BWN_PHY_WRITE(mac, BWN_PHY_HPWR_TSSICTL, sav->phy_hpwr_tssictl); in bwn_lo_restore()
2366 bwn_phy_g_switch_chan(mac, sav->old_channel, 1); in bwn_lo_restore()
2371 struct bwn_loctl *probe, struct bwn_lo_g_sm *d) in bwn_lo_probe_loctl() argument
2373 struct bwn_phy *phy = &mac->mac_phy; in bwn_lo_probe_loctl() local
2374 struct bwn_phy_g *pg = &phy->phy_g; in bwn_lo_probe_loctl()
2376 struct bwn_loctl prev = { -100, -100 }; in bwn_lo_probe_loctl()
2378 { 1, 1,}, { 1, 0,}, { 1, -1,}, { 0, -1,}, in bwn_lo_probe_loctl()
2379 { -1, -1,}, { -1, 0,}, { -1, 1,}, { 0, 1,} in bwn_lo_probe_loctl()
2384 if (d->curstate == 0) { in bwn_lo_probe_loctl()
2387 } else if (d->curstate % 2 == 0) { in bwn_lo_probe_loctl()
2388 begin = d->curstate - 1; in bwn_lo_probe_loctl()
2389 end = d->curstate + 1; in bwn_lo_probe_loctl()
2391 begin = d->curstate - 2; in bwn_lo_probe_loctl()
2392 end = d->curstate + 2; in bwn_lo_probe_loctl()
2397 end -= 8; in bwn_lo_probe_loctl()
2401 d->curstate = i; in bwn_lo_probe_loctl()
2403 KASSERT(i >= 1 && i <= 8, ("%s:%d: fail", __func__, __LINE__)); in bwn_lo_probe_loctl()
2405 test.i += modifiers[i - 1].i * d->multipler; in bwn_lo_probe_loctl()
2406 test.q += modifiers[i - 1].q * d->multipler; in bwn_lo_probe_loctl()
2410 feedth = bwn_lo_calcfeed(mac, pg->pg_lna_gain, in bwn_lo_probe_loctl()
2411 pg->pg_pga_gain, pg->pg_trsw_rx_gain); in bwn_lo_probe_loctl()
2412 if (feedth < d->feedth) { in bwn_lo_probe_loctl()
2416 d->feedth = feedth; in bwn_lo_probe_loctl()
2417 if (d->nmeasure < 2 && !BWN_HAS_LOOPBACK(phy)) in bwn_lo_probe_loctl()
2428 d->curstate = i; in bwn_lo_probe_loctl()
2437 struct bwn_phy *phy = &mac->mac_phy; in bwn_lo_probe_sm() local
2438 struct bwn_phy_g *pg = &phy->phy_g; in bwn_lo_probe_sm()
2439 struct bwn_lo_g_sm d; in bwn_lo_probe_sm() local
2444 d.nmeasure = 0; in bwn_lo_probe_sm()
2445 d.multipler = 1; in bwn_lo_probe_sm()
2446 if (BWN_HAS_LOOPBACK(phy)) in bwn_lo_probe_sm()
2447 d.multipler = 3; in bwn_lo_probe_sm()
2449 memcpy(&d.loctl, loctl, sizeof(struct bwn_loctl)); in bwn_lo_probe_sm()
2450 repeat = (BWN_HAS_LOOPBACK(phy)) ? 4 : 1; in bwn_lo_probe_sm()
2453 bwn_lo_write(mac, &d.loctl); in bwn_lo_probe_sm()
2454 feedth = bwn_lo_calcfeed(mac, pg->pg_lna_gain, in bwn_lo_probe_sm()
2455 pg->pg_pga_gain, pg->pg_trsw_rx_gain); in bwn_lo_probe_sm()
2461 feedth = bwn_lo_calcfeed(mac, pg->pg_lna_gain, in bwn_lo_probe_sm()
2462 pg->pg_pga_gain, pg->pg_trsw_rx_gain); in bwn_lo_probe_sm()
2464 d.feedth = feedth; in bwn_lo_probe_sm()
2465 d.curstate = 0; in bwn_lo_probe_sm()
2467 KASSERT(d.curstate >= 0 && d.curstate <= 8, in bwn_lo_probe_sm()
2468 ("%s:%d: fail", __func__, __LINE__)); in bwn_lo_probe_sm()
2469 memcpy(&probe, &d.loctl, in bwn_lo_probe_sm()
2471 lower = bwn_lo_probe_loctl(mac, &probe, &d); in bwn_lo_probe_sm()
2474 if ((probe.i == d.loctl.i) && (probe.q == d.loctl.q)) in bwn_lo_probe_sm()
2476 memcpy(&d.loctl, &probe, sizeof(struct bwn_loctl)); in bwn_lo_probe_sm()
2477 d.nmeasure++; in bwn_lo_probe_sm()
2478 } while (d.nmeasure < 24); in bwn_lo_probe_sm()
2479 memcpy(loctl, &d.loctl, sizeof(struct bwn_loctl)); in bwn_lo_probe_sm()
2481 if (BWN_HAS_LOOPBACK(phy)) { in bwn_lo_probe_sm()
2482 if (d.feedth > 0x1194) in bwn_lo_probe_sm()
2483 *rxgain -= 6; in bwn_lo_probe_sm()
2484 else if (d.feedth < 0x5dc) in bwn_lo_probe_sm()
2487 if (d.feedth <= 0x5dc) { in bwn_lo_probe_sm()
2488 d.multipler = 1; in bwn_lo_probe_sm()
2491 d.multipler = 2; in bwn_lo_probe_sm()
2493 d.multipler = 1; in bwn_lo_probe_sm()
2495 bwn_lo_measure_gain_values(mac, *rxgain, BWN_HAS_LOOPBACK(phy)); in bwn_lo_probe_sm()
2503 struct bwn_phy *phy = &mac->mac_phy; in bwn_lo_calibset() local
2504 struct bwn_phy_g *pg = &phy->phy_g; in bwn_lo_calibset()
2511 sval.old_channel = phy->chan; in bwn_lo_calibset()
2516 BWN_RF_SETMASK(mac, 0x43, 0xfff0, rfatt->att); in bwn_lo_calibset()
2517 BWN_RF_SETMASK(mac, reg, ~value, (rfatt->padmix ? value :0)); in bwn_lo_calibset()
2519 rxgain = (rfatt->att * 2) + (bbatt->att / 2); in bwn_lo_calibset()
2520 if (rfatt->padmix) in bwn_lo_calibset()
2521 rxgain -= pad; in bwn_lo_calibset()
2522 if (BWN_HAS_LOOPBACK(phy)) in bwn_lo_calibset()
2523 rxgain += pg->pg_max_lb_gain; in bwn_lo_calibset()
2524 bwn_lo_measure_gain_values(mac, rxgain, BWN_HAS_LOOPBACK(phy)); in bwn_lo_calibset()
2525 bwn_phy_g_set_bbatt(mac, bbatt->att); in bwn_lo_calibset()
2533 device_printf(mac->mac_sc->sc_dev, "out of memory\n"); in bwn_lo_calibset()
2536 memcpy(&cal->bbatt, bbatt, sizeof(*bbatt)); in bwn_lo_calibset()
2537 memcpy(&cal->rfatt, rfatt, sizeof(*rfatt)); in bwn_lo_calibset()
2538 memcpy(&cal->ctl, &loctl, sizeof(loctl)); in bwn_lo_calibset()
2540 BWN_GETTIME(cal->calib_time); in bwn_lo_calibset()
2549 struct bwn_txpwr_loctl *lo = &mac->mac_phy.phy_g.pg_loctl; in bwn_lo_get_calib()
2552 TAILQ_FOREACH(c, &lo->calib_list, list) { in bwn_lo_get_calib()
2553 if (!BWN_BBATTCMP(&c->bbatt, bbatt)) in bwn_lo_get_calib()
2555 if (!BWN_RFATTCMP(&c->rfatt, rfatt)) in bwn_lo_get_calib()
2563 TAILQ_INSERT_TAIL(&lo->calib_list, c, list); in bwn_lo_get_calib()
2571 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_g_dc_lookup_init() local
2572 struct bwn_phy_g *pg = &phy->phy_g; in bwn_phy_g_dc_lookup_init()
2573 struct bwn_softc *sc = mac->mac_sc; in bwn_phy_g_dc_lookup_init()
2574 struct bwn_txpwr_loctl *lo = &pg->pg_loctl; in bwn_phy_g_dc_lookup_init()
2582 KASSERT(BWN_DC_LT_SIZE == 32, ("%s:%d: fail", __func__, __LINE__)); in bwn_phy_g_dc_lookup_init()
2583 KASSERT(lo->rfatt.len * lo->bbatt.len <= 64, in bwn_phy_g_dc_lookup_init()
2584 ("%s:%d: fail", __func__, __LINE__)); in bwn_phy_g_dc_lookup_init()
2586 pvector = lo->power_vector; in bwn_phy_g_dc_lookup_init()
2599 bb_offset = i / lo->rfatt.len; in bwn_phy_g_dc_lookup_init()
2600 rf_offset = i % lo->rfatt.len; in bwn_phy_g_dc_lookup_init()
2601 bbatt = &(lo->bbatt.array[bb_offset]); in bwn_phy_g_dc_lookup_init()
2602 rfatt = &(lo->rfatt.array[rf_offset]); in bwn_phy_g_dc_lookup_init()
2606 device_printf(sc->sc_dev, "LO: Could not " in bwn_phy_g_dc_lookup_init()
2610 val = (uint8_t)(cal->ctl.q); in bwn_phy_g_dc_lookup_init()
2611 val |= ((uint8_t)(cal->ctl.i)) << 4; in bwn_phy_g_dc_lookup_init()
2616 lo->dc_lt[idx] = (lo->dc_lt[idx] & 0x00ff) in bwn_phy_g_dc_lookup_init()
2619 lo->dc_lt[idx] = (lo->dc_lt[idx] & 0xff00) in bwn_phy_g_dc_lookup_init()
2625 BWN_PHY_WRITE(mac, 0x3a0 + i, lo->dc_lt[i]); in bwn_phy_g_dc_lookup_init()
2634 if (!rf->padmix) in bwn_lo_fixup_rfatt()
2636 if ((rf->att != 1) && (rf->att != 2) && (rf->att != 3)) in bwn_lo_fixup_rfatt()
2637 rf->att = 4; in bwn_lo_fixup_rfatt()
2643 struct bwn_phy_g *pg = &mac->mac_phy.phy_g; in bwn_lo_g_adjust()
2647 memcpy(&rf, &pg->pg_rfatt, sizeof(rf)); in bwn_lo_g_adjust()
2650 cal = bwn_lo_get_calib(mac, &pg->pg_bbatt, &rf); in bwn_lo_g_adjust()
2653 bwn_lo_write(mac, &cal->ctl); in bwn_lo_g_adjust()
2678 struct bwn_phy *phy = &mac->mac_phy; in bwn_nrssi_threshold() local
2679 struct bwn_phy_g *pg = &phy->phy_g; in bwn_nrssi_threshold()
2680 struct bwn_softc *sc = mac->mac_sc; in bwn_nrssi_threshold()
2685 KASSERT(phy->type == BWN_PHYTYPE_G, ("%s: fail", __func__)); in bwn_nrssi_threshold()
2687 if (phy->gmode && (sc->sc_board_info.board_flags & BHND_BFL_ADCDIV)) { in bwn_nrssi_threshold()
2688 if (!pg->pg_aci_wlan_automatic && pg->pg_aci_enable) { in bwn_nrssi_threshold()
2696 a = a * (pg->pg_nrssi[1] - pg->pg_nrssi[0]); in bwn_nrssi_threshold()
2697 a += (pg->pg_nrssi[0] << 6); in bwn_nrssi_threshold()
2700 a = MIN(MAX(a, -31), 31); in bwn_nrssi_threshold()
2702 b = b * (pg->pg_nrssi[1] - pg->pg_nrssi[0]); in bwn_nrssi_threshold()
2703 b += (pg->pg_nrssi[0] << 6); in bwn_nrssi_threshold()
2709 b = MIN(MAX(b, -31), 31); in bwn_nrssi_threshold()
2720 tmp16 -= 0x40; in bwn_nrssi_threshold()
2738 struct bwn_phy *phy = &mac->mac_phy; in bwn_nrssi_slope_11g() local
2739 struct bwn_phy_g *pg = &phy->phy_g; in bwn_nrssi_slope_11g()
2748 KASSERT(phy->type == BWN_PHYTYPE_G, in bwn_nrssi_slope_11g()
2749 ("%s:%d: fail", __func__, __LINE__)); in bwn_nrssi_slope_11g()
2751 if (phy->rf_rev >= 9) in bwn_nrssi_slope_11g()
2753 if (phy->rf_rev == 8) in bwn_nrssi_slope_11g()
2760 * Save RF/PHY registers for later restoration in bwn_nrssi_slope_11g()
2771 if (phy->rev >= 3) { in bwn_nrssi_slope_11g()
2776 switch (phy->rev) { in bwn_nrssi_slope_11g()
2797 if (phy->rev >= 2) { in bwn_nrssi_slope_11g()
2806 nrssi0 -= 0x0040; in bwn_nrssi_slope_11g()
2812 if (phy->rev >= 2) in bwn_nrssi_slope_11g()
2819 if (phy->rev >= 2) { in bwn_nrssi_slope_11g()
2825 if (phy->rf_rev == 8) { in bwn_nrssi_slope_11g()
2843 nrssi1 -= 0x0040; in bwn_nrssi_slope_11g()
2845 pg->pg_nrssi_slope = 0x00010000; in bwn_nrssi_slope_11g()
2847 pg->pg_nrssi_slope = 0x00400000 / (nrssi0 - nrssi1); in bwn_nrssi_slope_11g()
2848 if (nrssi0 >= -4) { in bwn_nrssi_slope_11g()
2849 pg->pg_nrssi[0] = nrssi1; in bwn_nrssi_slope_11g()
2850 pg->pg_nrssi[1] = nrssi0; in bwn_nrssi_slope_11g()
2854 * Restore saved RF/PHY registers in bwn_nrssi_slope_11g()
2856 if (phy->rev >= 3) { in bwn_nrssi_slope_11g()
2862 if (phy->rev >= 2) { in bwn_nrssi_slope_11g()
2877 bwn_spu_workaround(mac, phy->chan); in bwn_nrssi_slope_11g()
2881 if (phy->rev >= 3) { in bwn_nrssi_slope_11g()
2888 delta = 0x1f - pg->pg_nrssi[0]; in bwn_nrssi_slope_11g()
2890 tmp32 = (((i - delta) * pg->pg_nrssi_slope) / 0x10000) + 0x3a; in bwn_nrssi_slope_11g()
2892 pg->pg_nrssi_lt[i] = tmp32; in bwn_nrssi_slope_11g()
2918 struct bwn_phy *phy = &mac->mac_phy; in bwn_nrssi_offset() local
2936 if (phy->rev >= 6) { in bwn_nrssi_offset()
2955 nrssi -= 0x40; in bwn_nrssi_offset()
2957 for (i = 7; i >= 4; i--) { in bwn_nrssi_offset()
2963 nrssi -= 0x40; in bwn_nrssi_offset()
2971 if (phy->rev != 1) { in bwn_nrssi_offset()
2982 if (phy->rev == 0) in bwn_nrssi_offset()
2986 if (phy->rev != 1) { in bwn_nrssi_offset()
2997 nrssi -= 0x40; in bwn_nrssi_offset()
2998 if (nrssi == -32) { in bwn_nrssi_offset()
3005 nrssi -= 0x40; in bwn_nrssi_offset()
3006 if (nrssi > -31 && saved == 0xffff) in bwn_nrssi_offset()
3017 * Restore saved RF/PHY registers in bwn_nrssi_offset()
3019 if (phy->rev >= 6) { in bwn_nrssi_offset()
3025 if (phy->rev != 1) { in bwn_nrssi_offset()
3033 for (i = SAVE_RF_MAX - 1; i >= 0; --i) in bwn_nrssi_offset()
3039 if (phy->rev >= 6) { in bwn_nrssi_offset()
3055 struct bwn_phy *phy = &mac->mac_phy; in bwn_set_all_gains() local
3061 if (phy->rev <= 1) { in bwn_set_all_gains()
3067 if (phy->rev <= 1) in bwn_set_all_gains()
3075 if (third != -1) { in bwn_set_all_gains()
3087 struct bwn_phy *phy = &mac->mac_phy; in bwn_set_original_gains() local
3092 if (phy->rev <= 1) { in bwn_set_original_gains()
3098 if (phy->rev <= 1) in bwn_set_original_gains()
3109 bwn_ofdmtab_write_2(mac, table, i, i - start); in bwn_set_original_gains()
3120 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_hwpctl_init() local
3121 struct bwn_phy_g *pg = &phy->phy_g; in bwn_phy_hwpctl_init()
3124 struct bwn_softc *sc = mac->mac_sc; in bwn_phy_hwpctl_init()
3127 KASSERT(phy->type == BWN_PHYTYPE_G, in bwn_phy_hwpctl_init()
3128 ("%s:%d: fail", __func__, __LINE__)); in bwn_phy_hwpctl_init()
3130 if ((sc->sc_board_info.board_vendor == PCI_VENDOR_BROADCOM) && in bwn_phy_hwpctl_init()
3131 (sc->sc_board_info.board_type == BHND_BOARD_BU4306)) in bwn_phy_hwpctl_init()
3138 if (!phy->gmode) in bwn_phy_hwpctl_init()
3141 if (pg->pg_curtssi == 0) { in bwn_phy_hwpctl_init()
3142 if (phy->rf_ver == 0x2050 && phy->analog == 0) { in bwn_phy_hwpctl_init()
3145 memcpy(&old_rfatt, &pg->pg_rfatt, sizeof(old_rfatt)); in bwn_phy_hwpctl_init()
3146 memcpy(&old_bbatt, &pg->pg_bbatt, sizeof(old_bbatt)); in bwn_phy_hwpctl_init()
3147 old_txctl = pg->pg_txctl; in bwn_phy_hwpctl_init()
3150 if (phy->rf_rev == 8) { in bwn_phy_hwpctl_init()
3160 pg->pg_curtssi = BWN_PHY_READ(mac, BWN_PHY_TSSI); in bwn_phy_hwpctl_init()
3161 if (phy->rf_ver == 0x2050 && phy->analog == 0) in bwn_phy_hwpctl_init()
3179 struct bwn_phy *phy = &mac->mac_phy; in bwn_hwpctl_early_init() local
3190 if (phy->rf_ver == 0x2050 && phy->rf_rev == 8) { in bwn_hwpctl_early_init()
3210 struct bwn_phy *phy = &mac->mac_phy; in bwn_hwpctl_init_gphy() local
3211 struct bwn_phy_g *pg = &phy->phy_g; in bwn_hwpctl_init_gphy()
3212 struct bwn_txpwr_loctl *lo = &pg->pg_loctl; in bwn_hwpctl_init_gphy()
3223 (pg->pg_idletssi - pg->pg_curtssi)); in bwn_hwpctl_init_gphy()
3225 (pg->pg_idletssi - pg->pg_curtssi)); in bwn_hwpctl_init_gphy()
3228 bwn_ofdmtab_write_2(mac, 0x3c20, i, pg->pg_tssi2dbm[i]); in bwn_hwpctl_init_gphy()
3230 bwn_ofdmtab_write_2(mac, 0x3c00, i - 32, pg->pg_tssi2dbm[i]); in bwn_hwpctl_init_gphy()
3232 value = (uint16_t) pg->pg_tssi2dbm[i]; in bwn_hwpctl_init_gphy()
3233 value |= ((uint16_t) pg->pg_tssi2dbm[i + 1]) << 8; in bwn_hwpctl_init_gphy()
3237 for (rf = 0; rf < lo->rfatt.len; rf++) { in bwn_hwpctl_init_gphy()
3238 for (bb = 0; bb < lo->bbatt.len; bb++) { in bwn_hwpctl_init_gphy()
3241 tmp = lo->bbatt.array[bb].att; in bwn_hwpctl_init_gphy()
3243 if (phy->rf_rev == 8) in bwn_hwpctl_init_gphy()
3247 tmp |= lo->rfatt.array[rf].att; in bwn_hwpctl_init_gphy()
3256 KASSERT(phy->rev >= 6, ("%s:%d: fail", __func__, __LINE__)); in bwn_hwpctl_init_gphy()
3268 struct bwn_softc *sc = mac->mac_sc; in bwn_phy_g_switch_chan()
3279 error = bhnd_nvram_getvar_uint8(sc->sc_dev, BHND_NVAR_CC, &cc); in bwn_phy_g_switch_chan()
3281 device_printf(sc->sc_dev, "error reading country code " in bwn_phy_g_switch_chan()
3282 "from NVRAM, assuming channel 14 unavailable: %d\n", in bwn_phy_g_switch_chan()
3308 ("%s:%d: fail", __func__, __LINE__)); in bwn_phy_g_chan2freq()
3310 return (bwn_phy_g_rf_channels[channel - 1]); in bwn_phy_g_chan2freq()
3317 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_g_set_txpwr_sub() local
3318 struct bwn_phy_g *pg = &phy->phy_g; in bwn_phy_g_set_txpwr_sub()
3319 struct bwn_txpwr_loctl *lo = &pg->pg_loctl; in bwn_phy_g_set_txpwr_sub()
3323 bb = bbatt->att; in bwn_phy_g_set_txpwr_sub()
3324 rf = rfatt->att; in bwn_phy_g_set_txpwr_sub()
3325 tx_bias = lo->tx_bias; in bwn_phy_g_set_txpwr_sub()
3326 tx_magn = lo->tx_magn; in bwn_phy_g_set_txpwr_sub()
3330 pg->pg_txctl = txctl; in bwn_phy_g_set_txpwr_sub()
3331 memmove(&pg->pg_rfatt, rfatt, sizeof(*rfatt)); in bwn_phy_g_set_txpwr_sub()
3332 pg->pg_rfatt.padmix = (txctl & BWN_TXCTL_TXMIX) ? 1 : 0; in bwn_phy_g_set_txpwr_sub()
3333 memmove(&pg->pg_bbatt, bbatt, sizeof(*bbatt)); in bwn_phy_g_set_txpwr_sub()
3336 if (phy->rf_ver == 0x2050 && phy->rf_rev == 8) in bwn_phy_g_set_txpwr_sub()
3342 if (BWN_HAS_TXMAG(phy)) in bwn_phy_g_set_txpwr_sub()
3353 struct bwn_phy *phy = &mac->mac_phy; in bwn_phy_g_set_bbatt() local
3355 if (phy->analog == 0) { in bwn_phy_g_set_bbatt()
3360 if (phy->analog > 1) { in bwn_phy_g_set_bbatt()
3370 struct bwn_phy *phy = &mac->mac_phy; in bwn_rf_2050_rfoverval() local
3371 struct bwn_phy_g *pg = &phy->phy_g; in bwn_rf_2050_rfoverval()
3372 struct bwn_softc *sc = mac->mac_sc; in bwn_rf_2050_rfoverval()
3377 if (phy->gmode == 0) in bwn_rf_2050_rfoverval()
3380 if (BWN_HAS_LOOPBACK(phy)) { in bwn_rf_2050_rfoverval()
3381 max_lb_gain = pg->pg_max_lb_gain; in bwn_rf_2050_rfoverval()
3382 max_lb_gain += (phy->rf_rev == 8) ? 0x3e : 0x26; in bwn_rf_2050_rfoverval()
3385 max_lb_gain -= 0x46; in bwn_rf_2050_rfoverval()
3388 max_lb_gain -= 0x3a; in bwn_rf_2050_rfoverval()
3391 max_lb_gain -= 0x2e; in bwn_rf_2050_rfoverval()
3394 max_lb_gain -= 0x10; in bwn_rf_2050_rfoverval()
3398 max_lb_gain -= (i * 6); in bwn_rf_2050_rfoverval()
3403 if ((phy->rev < 7) || in bwn_rf_2050_rfoverval()
3404 !(sc->sc_board_info.board_flags & BHND_BFL_EXTLNA)) { in bwn_rf_2050_rfoverval()
3419 ("%s:%d: fail", __func__, __LINE__)); in bwn_rf_2050_rfoverval()
3421 KASSERT(0 == 1, ("%s:%d: fail", __func__, __LINE__)); in bwn_rf_2050_rfoverval()
3440 ("%s:%d: fail", __func__, __LINE__)); in bwn_rf_2050_rfoverval()
3442 KASSERT(0 == 1, ("%s:%d: fail", __func__, __LINE__)); in bwn_rf_2050_rfoverval()
3447 if ((phy->rev < 7) || in bwn_rf_2050_rfoverval()
3448 !(sc->sc_board_info.board_flags & BHND_BFL_EXTLNA)) { in bwn_rf_2050_rfoverval()
3463 ("%s:%d: fail", __func__, __LINE__)); in bwn_rf_2050_rfoverval()
3465 KASSERT(0 == 1, ("%s:%d: fail", __func__, __LINE__)); in bwn_rf_2050_rfoverval()
3481 ("%s:%d: fail", __func__, __LINE__)); in bwn_rf_2050_rfoverval()
3483 KASSERT(0 == 1, ("%s:%d: fail", __func__, __LINE__)); in bwn_rf_2050_rfoverval()
3492 if (mac->mac_phy.rf_ver != 0x2050 || mac->mac_phy.rf_rev >= 6) in bwn_spu_workaround()
3504 unsigned int a, b, c, d; in bwn_phy_shm_tssi_read() local
3512 d = (tmp >> 24) & 0xff; in bwn_phy_shm_tssi_read()
3514 c == 0 || c == BWN_TSSI_MAX || d == 0 || d == BWN_TSSI_MAX) in bwn_phy_shm_tssi_read()
3524 d = (d + 32) & 0x3f; in bwn_phy_shm_tssi_read()
3527 avg = (a + b + c + d + 2) / 4; in bwn_phy_shm_tssi_read()
3531 avg = (avg >= 13) ? (avg - 13) : 0; in bwn_phy_shm_tssi_read()
3539 struct bwn_txpwr_loctl *lo = &mac->mac_phy.phy_g.pg_loctl; in bwn_phy_g_setatt()
3544 if (rfatt > lo->rfatt.max && bbatt > lo->bbatt.max - 4) in bwn_phy_g_setatt()
3546 if (rfatt < lo->rfatt.min && bbatt < lo->bbatt.min + 4) in bwn_phy_g_setatt()
3548 if (bbatt > lo->bbatt.max && rfatt > lo->rfatt.max - 1) in bwn_phy_g_setatt()
3550 if (bbatt < lo->bbatt.min && rfatt < lo->rfatt.min + 1) in bwn_phy_g_setatt()
3552 if (bbatt > lo->bbatt.max) { in bwn_phy_g_setatt()
3553 bbatt -= 4; in bwn_phy_g_setatt()
3557 if (bbatt < lo->bbatt.min) { in bwn_phy_g_setatt()
3559 rfatt -= 1; in bwn_phy_g_setatt()
3562 if (rfatt > lo->rfatt.max) { in bwn_phy_g_setatt()
3563 rfatt -= 1; in bwn_phy_g_setatt()
3567 if (rfatt < lo->rfatt.min) { in bwn_phy_g_setatt()
3569 bbatt -= 4; in bwn_phy_g_setatt()
3575 *rfattp = MIN(MAX(rfatt, lo->rfatt.min), lo->rfatt.max); in bwn_phy_g_setatt()
3576 *bbattp = MIN(MAX(bbatt, lo->bbatt.min), lo->bbatt.max); in bwn_phy_g_setatt()
3582 struct bwn_softc *sc = mac->mac_sc; in bwn_phy_lock()
3583 struct ieee80211com *ic = &sc->sc_ic; in bwn_phy_lock()
3585 KASSERT(bhnd_get_hwrev(sc->sc_dev) >= 3, in bwn_phy_lock()
3586 ("%s: unsupported rev %d", __func__, bhnd_get_hwrev(sc->sc_dev))); in bwn_phy_lock()
3588 if (ic->ic_opmode != IEEE80211_M_HOSTAP) in bwn_phy_lock()
3595 struct bwn_softc *sc = mac->mac_sc; in bwn_phy_unlock()
3596 struct ieee80211com *ic = &sc->sc_ic; in bwn_phy_unlock()
3598 KASSERT(bhnd_get_hwrev(sc->sc_dev) >= 3, in bwn_phy_unlock()
3599 ("%s: unsupported rev %d", __func__, bhnd_get_hwrev(sc->sc_dev))); in bwn_phy_unlock()
3601 if (ic->ic_opmode != IEEE80211_M_HOSTAP) in bwn_phy_unlock()