Lines Matching refs:mac

87 static void	bwi_tbl_write_2(struct bwi_mac *mac, uint16_t, uint16_t);
88 static void bwi_tbl_write_4(struct bwi_mac *mac, uint16_t, uint32_t);
136 bwi_phy_write(struct bwi_mac *mac, uint16_t ctrl, uint16_t data)
138 struct bwi_softc *sc = mac->mac_sc;
145 bwi_phy_read(struct bwi_mac *mac, uint16_t ctrl)
147 struct bwi_softc *sc = mac->mac_sc;
154 bwi_phy_attach(struct bwi_mac *mac)
156 struct bwi_softc *sc = mac->mac_sc;
157 struct bwi_phy *phy = &mac->mac_phy;
224 bwi_phy_set_bbp_atten(struct bwi_mac *mac, uint16_t bbp_atten)
226 struct bwi_phy *phy = &mac->mac_phy;
230 CSR_FILT_SETBITS_2(mac->mac_sc, BWI_BBP_ATTEN, ~mask,
237 PHY_FILT_SETBITS(mac, BWI_PHYR_BBP_ATTEN, ~mask,
243 bwi_phy_calibrate(struct bwi_mac *mac)
245 struct bwi_phy *phy = &mac->mac_phy;
248 CSR_READ_4(mac->mac_sc, BWI_MAC_STATUS);
255 bwi_mac_reset(mac, 0);
256 bwi_phy_init_11g(mac);
257 bwi_mac_reset(mac, 1);
265 bwi_tbl_write_2(struct bwi_mac *mac, uint16_t ofs, uint16_t data)
267 struct bwi_phy *phy = &mac->mac_phy;
272 PHY_WRITE(mac, phy->phy_tbl_ctrl, ofs);
273 PHY_WRITE(mac, phy->phy_tbl_data_lo, data);
277 bwi_tbl_write_4(struct bwi_mac *mac, uint16_t ofs, uint32_t data)
279 struct bwi_phy *phy = &mac->mac_phy;
286 PHY_WRITE(mac, phy->phy_tbl_ctrl, ofs);
287 PHY_WRITE(mac, phy->phy_tbl_data_hi, data >> 16);
288 PHY_WRITE(mac, phy->phy_tbl_data_lo, data & 0xffff);
292 bwi_nrssi_write(struct bwi_mac *mac, uint16_t ofs, int16_t data)
294 PHY_WRITE(mac, BWI_PHYR_NRSSI_CTRL, ofs);
295 PHY_WRITE(mac, BWI_PHYR_NRSSI_DATA, (uint16_t)data);
299 bwi_nrssi_read(struct bwi_mac *mac, uint16_t ofs)
301 PHY_WRITE(mac, BWI_PHYR_NRSSI_CTRL, ofs);
302 return (int16_t)PHY_READ(mac, BWI_PHYR_NRSSI_DATA);
306 bwi_phy_init_11a(struct bwi_mac *mac)
312 bwi_phy_init_11g(struct bwi_mac *mac)
314 struct bwi_softc *sc = mac->mac_sc;
315 struct bwi_phy *phy = &mac->mac_phy;
316 struct bwi_rf *rf = &mac->mac_rf;
317 const struct bwi_tpctl *tpctl = &mac->mac_tpctl;
320 bwi_phy_init_11b_rev5(mac);
322 bwi_phy_init_11b_rev6(mac);
325 bwi_phy_config_11g(mac);
328 PHY_WRITE(mac, 0x814, 0);
329 PHY_WRITE(mac, 0x815, 0);
332 PHY_WRITE(mac, 0x811, 0);
333 PHY_WRITE(mac, 0x15, 0xc0);
335 PHY_WRITE(mac, 0x811, 0x400);
336 PHY_WRITE(mac, 0x15, 0xc0);
343 val = PHY_READ(mac, 0x400) & 0xff;
345 PHY_WRITE(mac, 0x4c2, 0x1816);
346 PHY_WRITE(mac, 0x4c3, 0x8006);
348 PHY_FILT_SETBITS(mac, 0x4cc,
356 PHY_WRITE(mac, 0x47e, 0x78);
359 PHY_SETBITS(mac, 0x801, 0x80);
360 PHY_SETBITS(mac, 0x43e, 0x4);
364 bwi_rf_get_gains(mac);
367 bwi_rf_init(mac);
370 bwi_rf_lo_update(mac);
373 RF_WRITE(mac, 0x52,
376 RF_FILT_SETBITS(mac, 0x52, 0xfff0, tpctl->tp_ctrl2);
380 PHY_FILT_SETBITS(mac, 0x36, 0xfff,
385 PHY_WRITE(mac, 0x2e, 0x8075);
387 PHY_WRITE(mac, 0x2e, 0x807f);
390 PHY_WRITE(mac, 0x2f, 0x101);
392 PHY_WRITE(mac, 0x2f, 0x202);
396 bwi_rf_lo_adjust(mac, tpctl);
397 PHY_WRITE(mac, 0x80f, 0x8078);
401 bwi_rf_init_hw_nrssi_table(mac, 0xffff /* XXX */);
402 bwi_rf_set_nrssi_thr(mac);
407 bwi_rf_calc_nrssi_slope(mac);
411 bwi_rf_set_nrssi_thr(mac);
416 PHY_WRITE(mac, 0x805, 0x3230);
418 bwi_mac_init_tpctl_11bg(mac);
421 PHY_CLRBITS(mac, 0x429, 0x4000);
422 PHY_CLRBITS(mac, 0x4c3, 0x8000);
427 bwi_phy_init_11b_rev2(struct bwi_mac *mac)
430 device_printf(mac->mac_sc->sc_dev,
435 bwi_phy_init_11b_rev4(struct bwi_mac *mac)
437 struct bwi_softc *sc = mac->mac_sc;
438 struct bwi_rf *rf = &mac->mac_rf;
444 PHY_WRITE(mac, 0x20, 0x301c);
445 PHY_WRITE(mac, 0x26, 0);
446 PHY_WRITE(mac, 0x30, 0xc6);
447 PHY_WRITE(mac, 0x88, 0x3e00);
450 PHY_WRITE(mac, 0x89 + ofs, val);
457 bwi_rf_set_chan(mac, chan, 0);
460 RF_WRITE(mac, 0x75, 0x80);
461 RF_WRITE(mac, 0x79, 0x81);
464 RF_WRITE(mac, 0x50, 0x20);
465 RF_WRITE(mac, 0x50, 0x23);
468 RF_WRITE(mac, 0x50, 0x20);
469 RF_WRITE(mac, 0x5a, 0x70);
470 RF_WRITE(mac, 0x5b, 0x7b);
471 RF_WRITE(mac, 0x5c, 0xb0);
472 RF_WRITE(mac, 0x7a, 0xf);
473 PHY_WRITE(mac, 0x38, 0x677);
474 bwi_rf_init_bcm2050(mac);
477 PHY_WRITE(mac, 0x14, 0x80);
478 PHY_WRITE(mac, 0x32, 0xca);
480 PHY_WRITE(mac, 0x32, 0xe0);
481 PHY_WRITE(mac, 0x35, 0x7c2);
483 bwi_rf_lo_update(mac);
485 PHY_WRITE(mac, 0x26, 0xcc00);
487 PHY_WRITE(mac, 0x26, 0xce00);
491 PHY_WRITE(mac, 0x2a, 0x88a3);
493 PHY_WRITE(mac, 0x2a, 0x88c2);
495 bwi_mac_set_tpctl_11bg(mac, NULL);
497 bwi_rf_calc_nrssi_slope(mac);
498 bwi_rf_set_nrssi_thr(mac);
500 bwi_mac_init_tpctl_11bg(mac);
504 bwi_phy_init_11b_rev5(struct bwi_mac *mac)
506 struct bwi_softc *sc = mac->mac_sc;
507 struct bwi_rf *rf = &mac->mac_rf;
508 struct bwi_phy *phy = &mac->mac_phy;
512 RF_SETBITS(mac, 0x7a, 0x50);
520 PHY_WRITE(mac, ofs, val);
525 PHY_FILT_SETBITS(mac, 0x35, 0xf0ff, 0x700);
528 PHY_WRITE(mac, 0x38, 0x667);
532 RF_SETBITS(mac, 0x7a, 0x20);
533 RF_SETBITS(mac, 0x51, 0x4);
538 PHY_SETBITS(mac, 0x802, 0x100);
539 PHY_SETBITS(mac, 0x42b, 0x2000);
540 PHY_WRITE(mac, 0x1c, 0x186a);
542 PHY_FILT_SETBITS(mac, 0x13, 0xff, 0x1900);
543 PHY_FILT_SETBITS(mac, 0x35, 0xffc0, 0x64);
544 PHY_FILT_SETBITS(mac, 0x5d, 0xff80, 0xa);
550 PHY_WRITE(mac, 0x26, 0xce00);
551 PHY_WRITE(mac, 0x21, 0x3763);
552 PHY_WRITE(mac, 0x22, 0x1bc3);
553 PHY_WRITE(mac, 0x23, 0x6f9);
554 PHY_WRITE(mac, 0x24, 0x37e);
556 PHY_WRITE(mac, 0x26, 0xcc00);
558 PHY_WRITE(mac, 0x30, 0xc6);
563 PHY_WRITE(mac, 0x20, 0x3e1c);
565 PHY_WRITE(mac, 0x20, 0x301c);
572 bwi_rf_set_chan(mac, 7, 0);
575 RF_WRITE(mac, 0x75, 0x80);
576 RF_WRITE(mac, 0x79, 0x81);
579 RF_WRITE(mac, 0x50, 0x20);
580 RF_WRITE(mac, 0x50, 0x23);
583 RF_WRITE(mac, 0x50, 0x20);
584 RF_WRITE(mac, 0x5a, 0x70);
587 RF_WRITE(mac, 0x5b, 0x7b);
588 RF_WRITE(mac, 0x5c, 0xb0);
589 RF_SETBITS(mac, 0x7a, 0x7);
591 bwi_rf_set_chan(mac, orig_chan, 0);
593 PHY_WRITE(mac, 0x14, 0x80);
594 PHY_WRITE(mac, 0x32, 0xca);
595 PHY_WRITE(mac, 0x2a, 0x88a3);
597 bwi_mac_set_tpctl_11bg(mac, NULL);
600 RF_WRITE(mac, 0x5d, 0xd);
606 bwi_phy_init_11b_rev6(struct bwi_mac *mac)
608 struct bwi_softc *sc = mac->mac_sc;
609 struct bwi_rf *rf = &mac->mac_rf;
610 struct bwi_phy *phy = &mac->mac_phy;
614 PHY_WRITE(mac, 0x3e, 0x817a);
615 RF_SETBITS(mac, 0x7a, 0x58);
618 RF_WRITE(mac, 0x51, 0x37);
619 RF_WRITE(mac, 0x52, 0x70);
620 RF_WRITE(mac, 0x53, 0xb3);
621 RF_WRITE(mac, 0x54, 0x9b);
622 RF_WRITE(mac, 0x5a, 0x88);
623 RF_WRITE(mac, 0x5b, 0x88);
624 RF_WRITE(mac, 0x5d, 0x88);
625 RF_WRITE(mac, 0x5e, 0x88);
626 RF_WRITE(mac, 0x7d, 0x88);
627 HFLAGS_SETBITS(mac, BWI_HFLAG_MAGIC1);
629 RF_WRITE(mac, 0x51, 0);
630 RF_WRITE(mac, 0x52, 0x40);
631 RF_WRITE(mac, 0x53, 0xb7);
632 RF_WRITE(mac, 0x54, 0x98);
633 RF_WRITE(mac, 0x5a, 0x88);
634 RF_WRITE(mac, 0x5b, 0x6b);
635 RF_WRITE(mac, 0x5c, 0xf);
637 RF_WRITE(mac, 0x5d, 0xfa);
638 RF_WRITE(mac, 0x5e, 0xd8);
640 RF_WRITE(mac, 0x5d, 0xf5);
641 RF_WRITE(mac, 0x5e, 0xb8);
643 RF_WRITE(mac, 0x73, 0x3);
644 RF_WRITE(mac, 0x7d, 0xa8);
645 RF_WRITE(mac, 0x7c, 0x1);
646 RF_WRITE(mac, 0x7e, 0x8);
651 PHY_WRITE(mac, ofs, val);
657 PHY_WRITE(mac, ofs, val);
663 PHY_WRITE(mac, ofs, (val & 0x3f3f));
671 RF_SETBITS(mac, 0x7a, 0x20);
672 RF_SETBITS(mac, 0x51, 0x4);
673 PHY_SETBITS(mac, 0x802, 0x100);
674 PHY_SETBITS(mac, 0x42b, 0x2000);
675 PHY_WRITE(mac, 0x5b, 0);
676 PHY_WRITE(mac, 0x5c, 0);
682 bwi_rf_set_chan(mac, 1, 0);
684 bwi_rf_set_chan(mac, 13, 0);
686 RF_WRITE(mac, 0x50, 0x20);
687 RF_WRITE(mac, 0x50, 0x23);
692 RF_SETBITS(mac, 0x7c, 0x2);
693 RF_WRITE(mac, 0x50, 0x20);
696 RF_WRITE(mac, 0x7c, 0x20);
697 RF_WRITE(mac, 0x5a, 0x70);
698 RF_WRITE(mac, 0x5b, 0x7b);
699 RF_WRITE(mac, 0x5c, 0xb0);
702 RF_FILT_SETBITS(mac, 0x7a, 0xf8, 0x7);
704 bwi_rf_set_chan(mac, orig_chan, 0);
706 PHY_WRITE(mac, 0x14, 0x200);
708 PHY_WRITE(mac, 0x2a, 0x88c2);
710 PHY_WRITE(mac, 0x2a, 0x8ac0);
711 PHY_WRITE(mac, 0x38, 0x668);
713 bwi_mac_set_tpctl_11bg(mac, NULL);
716 PHY_FILT_SETBITS(mac, 0x5d, 0xff80, 0x3);
718 RF_WRITE(mac, 0x5d, 0xd);
723 PHY_CLRBITS(mac, 0x61, 0xf000);
725 PHY_FILT_SETBITS(mac, 0x2, 0xffc0, 0x4);
730 PHY_WRITE(mac, 0x16, 0x410);
731 PHY_WRITE(mac, 0x17, 0x820);
732 PHY_WRITE(mac, 0x62, 0x7);
734 bwi_rf_init_bcm2050(mac);
735 bwi_rf_lo_update(mac);
737 bwi_rf_calc_nrssi_slope(mac);
738 bwi_rf_set_nrssi_thr(mac);
740 bwi_mac_init_tpctl_11bg(mac);
747 bwi_phy_config_11g(struct bwi_mac *mac)
749 struct bwi_softc *sc = mac->mac_sc;
750 struct bwi_phy *phy = &mac->mac_phy;
756 PHY_WRITE(mac, 0x406, 0x4f19);
757 PHY_FILT_SETBITS(mac, 0x429, 0xfc3f, 0x340);
758 PHY_WRITE(mac, 0x42c, 0x5a);
759 PHY_WRITE(mac, 0x427, 0x1a);
763 bwi_tbl_write_2(mac, BWI_PHYTBL_FREQ + i,
769 bwi_tbl_write_2(mac, BWI_PHYTBL_NOISE + i,
776 bwi_tbl_write_4(mac, BWI_PHYTBL_ROTOR + i,
780 bwi_nrssi_write(mac, 0xba98, (int16_t)0x7654); /* XXX */
783 PHY_WRITE(mac, 0x4c0, 0x1861);
784 PHY_WRITE(mac, 0x4c1, 0x271);
786 PHY_WRITE(mac, 0x4c0, 0x98);
787 PHY_WRITE(mac, 0x4c1, 0x70);
788 PHY_WRITE(mac, 0x4c9, 0x80);
790 PHY_SETBITS(mac, 0x42b, 0x800);
794 bwi_tbl_write_2(mac, BWI_PHYTBL_RSSI + i, i);
798 bwi_tbl_write_2(mac, BWI_PHYTBL_NOISE + i,
809 } else if (phy->phy_rev >= 7 && (PHY_READ(mac, 0x449) & 0x200)) {
817 bwi_tbl_write_2(mac, BWI_PHYTBL_NOISE_SCALE + i, tbl[i]);
833 bwi_tbl_write_2(mac, BWI_PHYTBL_SIGMA_SQ + i, tbl[i]);
838 bwi_tbl_write_4(mac, BWI_PHYTBL_DELAY + i,
844 bwi_tbl_write_2(mac, BWI_PHYTBL_WRSSI_REV1 + i, 0x20);
846 bwi_phy_config_agc(mac);
853 bwi_tbl_write_2(mac, BWI_PHYTBL_WRSSI + i, 0x820);
855 bwi_phy_config_agc(mac);
857 PHY_READ(mac, 0x400); /* Dummy read */
858 PHY_WRITE(mac, 0x403, 0x1000);
859 bwi_tbl_write_2(mac, 0x3c02, 0xf);
860 bwi_tbl_write_2(mac, 0x3c03, 0x14);
867 bwi_tbl_write_2(mac, wrd_ofs1, 0x2);
868 bwi_tbl_write_2(mac, wrd_ofs2, 0x1);
873 PHY_WRITE(mac, 0x46e, 0x3cf);
880 bwi_phy_config_agc(struct bwi_mac *mac)
882 struct bwi_phy *phy = &mac->mac_phy;
887 bwi_tbl_write_2(mac, ofs, 0xfe);
888 bwi_tbl_write_2(mac, ofs + 1, 0xd);
889 bwi_tbl_write_2(mac, ofs + 2, 0x13);
890 bwi_tbl_write_2(mac, ofs + 3, 0x19);
893 bwi_tbl_write_2(mac, 0x1800, 0x2710);
894 bwi_tbl_write_2(mac, 0x1801, 0x9b83);
895 bwi_tbl_write_2(mac, 0x1802, 0x9b83);
896 bwi_tbl_write_2(mac, 0x1803, 0xf8d);
897 PHY_WRITE(mac, 0x455, 0x4);
900 PHY_FILT_SETBITS(mac, 0x4a5, 0xff, 0x5700);
901 PHY_FILT_SETBITS(mac, 0x41a, 0xff80, 0xf);
902 PHY_FILT_SETBITS(mac, 0x41a, 0xc07f, 0x2b80);
903 PHY_FILT_SETBITS(mac, 0x48c, 0xf0ff, 0x300);
905 RF_SETBITS(mac, 0x7a, 0x8);
907 PHY_FILT_SETBITS(mac, 0x4a0, 0xfff0, 0x8);
908 PHY_FILT_SETBITS(mac, 0x4a1, 0xf0ff, 0x600);
909 PHY_FILT_SETBITS(mac, 0x4a2, 0xf0ff, 0x700);
910 PHY_FILT_SETBITS(mac, 0x4a0, 0xf0ff, 0x100);
913 PHY_FILT_SETBITS(mac, 0x4a2, 0xfff0, 0x7);
915 PHY_FILT_SETBITS(mac, 0x488, 0xff00, 0x1c);
916 PHY_FILT_SETBITS(mac, 0x488, 0xc0ff, 0x200);
917 PHY_FILT_SETBITS(mac, 0x496, 0xff00, 0x1c);
918 PHY_FILT_SETBITS(mac, 0x489, 0xff00, 0x20);
919 PHY_FILT_SETBITS(mac, 0x489, 0xc0ff, 0x200);
920 PHY_FILT_SETBITS(mac, 0x482, 0xff00, 0x2e);
921 PHY_FILT_SETBITS(mac, 0x496, 0xff, 0x1a00);
922 PHY_FILT_SETBITS(mac, 0x481, 0xff00, 0x28);
923 PHY_FILT_SETBITS(mac, 0x481, 0xff, 0x2c00);
926 PHY_WRITE(mac, 0x430, 0x92b);
927 PHY_FILT_SETBITS(mac, 0x41b, 0xffe1, 0x2);
929 PHY_CLRBITS(mac, 0x41b, 0x1e);
930 PHY_WRITE(mac, 0x41f, 0x287a);
931 PHY_FILT_SETBITS(mac, 0x420, 0xfff0, 0x4);
934 PHY_WRITE(mac, 0x422, 0x287a);
935 PHY_FILT_SETBITS(mac, 0x420, 0xfff, 0x3000);
939 PHY_FILT_SETBITS(mac, 0x4a8, 0x8080, 0x7874);
940 PHY_WRITE(mac, 0x48e, 0x1c00);
943 PHY_FILT_SETBITS(mac, 0x4ab, 0xf0ff, 0x600);
944 PHY_WRITE(mac, 0x48b, 0x5e);
945 PHY_FILT_SETBITS(mac, 0x48c, 0xff00, 0x1e);
946 PHY_WRITE(mac, 0x48d, 0x2);
949 bwi_tbl_write_2(mac, ofs + 0x800, 0);
950 bwi_tbl_write_2(mac, ofs + 0x801, 7);
951 bwi_tbl_write_2(mac, ofs + 0x802, 16);
952 bwi_tbl_write_2(mac, ofs + 0x803, 28);
955 PHY_CLRBITS(mac, 0x426, 0x3);
956 PHY_CLRBITS(mac, 0x426, 0x1000);
961 bwi_set_gains(struct bwi_mac *mac, const struct bwi_gains *gains)
963 struct bwi_phy *phy = &mac->mac_phy;
983 bwi_tbl_write_2(mac, tbl_gain_ofs1 + i, tbl_gain);
991 bwi_tbl_write_2(mac, tbl_gain_ofs2 + i, tbl_gain);
1006 PHY_FILT_SETBITS(mac, 0x4a0, 0xbfbf, phy_gain1);
1007 PHY_FILT_SETBITS(mac, 0x4a1, 0xbfbf, phy_gain1);
1008 PHY_FILT_SETBITS(mac, 0x4a2, 0xbfbf, phy_gain2);
1010 bwi_mac_dummy_xmit(mac);