Lines Matching +full:0 +full:x0d000000

70 #define DPRINTF(x)	do { if (sc->sc_debug > 0) printf x; } while (0)
71 #define DPRINTFN(n, x) do { if (sc->sc_debug >= (n)) printf x; } while (0)
243 sc->sc_debug = 0; in rt2860_attach()
248 callout_init_mtx(&sc->watchdog_ch, &sc->sc_mtx, 0); in rt2860_attach()
252 for (ntries = 0; ntries < 100; ntries++) { in rt2860_attach()
254 if (tmp != 0 && tmp != 0xffffffff) in rt2860_attach()
265 sc->mac_rev = tmp & 0xffff; in rt2860_attach()
267 if (sc->mac_ver != 0x2860 && in rt2860_attach()
268 (id == 0x0681 || id == 0x0781 || id == 0x1059)) in rt2860_attach()
273 device_printf(sc->sc_dev, "MAC/BBP RT%X (rev 0x%04X), " in rt2860_attach()
281 for (qid = 0; qid < 6; qid++) { in rt2860_attach()
282 if ((error = rt2860_alloc_tx_ring(sc, &sc->txq[qid])) != 0) { in rt2860_attach()
289 if ((error = rt2860_alloc_rx_ring(sc, &sc->rxq)) != 0) { in rt2860_attach()
294 if ((error = rt2860_alloc_tx_pool(sc)) != 0) { in rt2860_attach()
300 sc->mgtqid = (sc->mac_ver == 0x2860 && sc->mac_rev == 0x0100) ? in rt2860_attach()
320 #if 0 in rt2860_attach()
356 "debug", CTLFLAG_RW, &sc->sc_debug, 0, "debug msgs"); in rt2860_attach()
361 return 0; in rt2860_attach()
364 fail2: while (--qid >= 0) in rt2860_attach()
383 for (qid = 0; qid < 6; qid++) in rt2860_detach()
390 return 0; in rt2860_detach()
414 if (sc->sc_ic.ic_nrunning > 0) in rt2860_resume()
468 #if 0 in rt2860_vap_create()
472 /* HW supports up to 255 STAs (0-254) in HostAP and IBSS modes */ in rt2860_vap_create()
497 if (error != 0) in rt2860_dma_map_addr()
502 *(bus_addr_t *)arg = segs[0].ds_addr; in rt2860_dma_map_addr()
512 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 16, 0, in rt2860_alloc_tx_ring()
514 size, 1, size, 0, NULL, NULL, &ring->desc_dmat); in rt2860_alloc_tx_ring()
515 if (error != 0) { in rt2860_alloc_tx_ring()
522 if (error != 0) { in rt2860_alloc_tx_ring()
528 size, rt2860_dma_map_addr, &ring->paddr, 0); in rt2860_alloc_tx_ring()
529 if (error != 0) { in rt2860_alloc_tx_ring()
536 return 0; in rt2860_alloc_tx_ring()
548 for (i = 0; i < RT2860_TX_RING_COUNT; i++) { in rt2860_reset_tx_ring()
568 ring->queued = 0; in rt2860_reset_tx_ring()
569 ring->cur = ring->next = 0; in rt2860_reset_tx_ring()
587 for (i = 0; i < RT2860_TX_RING_COUNT; i++) { in rt2860_free_tx_ring()
619 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, in rt2860_alloc_tx_pool()
621 size, 1, size, 0, NULL, NULL, &sc->txwi_dmat); in rt2860_alloc_tx_pool()
622 if (error != 0) { in rt2860_alloc_tx_pool()
629 if (error != 0) { in rt2860_alloc_tx_pool()
635 sc->txwi_vaddr, size, rt2860_dma_map_addr, &paddr, 0); in rt2860_alloc_tx_pool()
636 if (error != 0) { in rt2860_alloc_tx_pool()
644 for (i = 0; i < RT2860_TX_POOL_COUNT; i++) { in rt2860_alloc_tx_pool()
647 error = bus_dmamap_create(sc->txwi_dmat, 0, &data->map); in rt2860_alloc_tx_pool()
648 if (error != 0) { in rt2860_alloc_tx_pool()
660 return 0; in rt2860_alloc_tx_pool()
694 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 16, 0, in rt2860_alloc_rx_ring()
696 size, 1, size, 0, NULL, NULL, &ring->desc_dmat); in rt2860_alloc_rx_ring()
697 if (error != 0) { in rt2860_alloc_rx_ring()
704 if (error != 0) { in rt2860_alloc_rx_ring()
710 size, rt2860_dma_map_addr, &ring->paddr, 0); in rt2860_alloc_rx_ring()
711 if (error != 0) { in rt2860_alloc_rx_ring()
716 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, in rt2860_alloc_rx_ring()
718 1, MCLBYTES, 0, NULL, NULL, &ring->data_dmat); in rt2860_alloc_rx_ring()
719 if (error != 0) { in rt2860_alloc_rx_ring()
724 for (i = 0; i < RT2860_RX_RING_COUNT; i++) { in rt2860_alloc_rx_ring()
728 error = bus_dmamap_create(ring->data_dmat, 0, &data->map); in rt2860_alloc_rx_ring()
729 if (error != 0) { in rt2860_alloc_rx_ring()
744 &physaddr, 0); in rt2860_alloc_rx_ring()
745 if (error != 0) { in rt2860_alloc_rx_ring()
757 return 0; in rt2860_alloc_rx_ring()
768 for (i = 0; i < RT2860_RX_RING_COUNT; i++) in rt2860_reset_rx_ring()
773 ring->cur = 0; in rt2860_reset_rx_ring()
790 for (i = 0; i < RT2860_RX_RING_COUNT; i++) { in rt2860_free_rx_ring()
840 if (isnew && ni->ni_associd != 0) { in rt2860_newassoc()
858 if (ni->ni_associd != 0) { in rt2860_node_free()
862 RAL_SET_REGION_4(sc, RT2860_WCID_ENTRY(wcid), 0, 2); in rt2860_node_free()
880 return 0; in rt2860_ampdu_rx_start()
920 rt2860_set_gp_timer(sc, 0); in rt2860_newstate()
923 if (error != 0) in rt2860_newstate()
940 if (error != 0) in rt2860_newstate()
967 * Read one 16-byte block into registers EFUSE_DATA[0-3]: in rt3090_efuse_read_2()
971 * DATA3: 3 2 1 0 in rt3090_efuse_read_2()
975 tmp |= (addr & ~0xf) << RT3070_EFSROM_AIN_SHIFT | RT3070_EFSROM_KICK; in rt3090_efuse_read_2()
977 for (ntries = 0; ntries < 500; ntries++) { in rt3090_efuse_read_2()
984 return 0xffff; in rt3090_efuse_read_2()
987 return 0xffff; /* address not found */ in rt3090_efuse_read_2()
990 reg = RT3070_EFUSE_DATA3 - (addr & 0xc); in rt3090_efuse_read_2()
993 return (addr & 2) ? tmp >> 16 : tmp & 0xffff; in rt3090_efuse_read_2()
1008 RT2860_EEPROM_CTL(sc, 0); in rt2860_eeprom_read_2()
1025 n = ((RAL_READ(sc, RT2860_PCI_EECTRL) & 0x30) == 0) ? 5 : 7; in rt2860_eeprom_read_2()
1026 for (; n >= 0; n--) { in rt2860_eeprom_read_2()
1036 val = 0; in rt2860_eeprom_read_2()
1037 for (n = 15; n >= 0; n--) { in rt2860_eeprom_read_2()
1044 RT2860_EEPROM_CTL(sc, 0); in rt2860_eeprom_read_2()
1048 RT2860_EEPROM_CTL(sc, 0); in rt2860_eeprom_read_2()
1089 DPRINTFN(4, ("tx stat 0x%08x\n", stat)); in rt2860_drain_stats_fifo()
1091 wcid = (stat >> RT2860_TXQ_WCID_SHIFT) & 0xff; in rt2860_drain_stats_fifo()
1108 mcs = (stat >> RT2860_TXQ_MCS_SHIFT) & 0x7f; in rt2860_drain_stats_fifo()
1109 pid = (stat >> RT2860_TXQ_PID_SHIFT) & 0xf; in rt2860_drain_stats_fifo()
1113 txs->long_retries = 0; in rt2860_drain_stats_fifo()
1142 ieee80211_tx_complete(data->ni, data->m, 0); in rt2860_tx_intr()
1152 sc->sc_tx_timer = 0; in rt2860_tx_intr()
1164 uint8_t rxchain = 0; in rt2860_maxrssi_chain()
1191 hw = RAL_READ(sc, RT2860_FS_DRX_IDX) & 0xfff; in rt2860_rx_intr()
1215 ieee80211_michael_mic_failure(ic, 0/* XXX */); in rt2860_rx_intr()
1233 &physaddr, 0); in rt2860_rx_intr()
1234 if (__predict_false(error != 0)) { in rt2860_rx_intr()
1240 rt2860_dma_map_addr, &physaddr, 0); in rt2860_rx_intr()
1241 if (__predict_false(error != 0)) { in rt2860_rx_intr()
1263 m->m_pkthdr.len = m->m_len = le16toh(rxwi->len) & 0xfff; in rt2860_rx_intr()
1287 tap->wr_flags = 0; in rt2860_rx_intr()
1297 case 0: tap->wr_rate = 2; break; in rt2860_rx_intr()
1307 case 0: tap->wr_rate = 12; break; in rt2860_rx_intr()
1350 #if 0 in rt2860_tbtt_intr()
1356 if (ic->ic_dtim_count == 0) in rt2860_tbtt_intr()
1365 if (ic->ic_dtim_count == 0) in rt2860_tbtt_intr()
1398 if (__predict_false(r == 0xffffffff)) { in rt2860_intr()
1402 if (r == 0) { in rt2860_intr()
1435 rt2860_tx_intr(sc, 0); in rt2860_intr()
1486 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; in rt2860_tx()
1495 (void) ieee80211_ratectl_rate(ni, NULL, 0); in rt2860_tx()
1502 qos = ((const struct ieee80211_qosframe *)wh)->i_qos[0]; in rt2860_tx()
1504 qos = 0; in rt2860_tx()
1514 txwi->flags = 0; in rt2860_tx()
1516 txwi->xflags = qos ? 0 : RT2860_TX_NSEQ; in rt2860_tx()
1520 txwi->wcid = 0xff; in rt2860_tx()
1536 * 0 means that we don't want feedback in TX_STAT_FIFO. in rt2860_tx()
1538 pid = (mcs + 1) & 0xf; in rt2860_tx()
1569 tap->wt_flags = 0; in rt2860_tx()
1584 &nsegs, 0); in rt2860_tx()
1585 if (__predict_false(error != 0 && error != EFBIG)) { in rt2860_tx()
1591 if (__predict_true(error == 0)) { in rt2860_tx()
1601 if (__predict_false(error != 0)) { in rt2860_tx()
1612 segs, &nsegs, 0); in rt2860_tx()
1613 if (__predict_false(error != 0)) { in rt2860_tx()
1640 seg = &segs[0]; in rt2860_tx()
1654 if (i > 0) { in rt2860_tx()
1659 txd->sdl1 = 0; in rt2860_tx()
1683 return 0; in rt2860_tx()
1763 txwi->flags = 0; in rt2860_tx_raw()
1765 txwi->xflags = params->ibp_pri & 3 ? 0 : RT2860_TX_NSEQ; in rt2860_tx_raw()
1766 txwi->wcid = 0xff; in rt2860_tx_raw()
1782 * 0 means that we don't want feedback in TX_STAT_FIFO. in rt2860_tx_raw()
1784 pid = (mcs + 1) & 0xf; in rt2860_tx_raw()
1793 if ((params->ibp_flags & IEEE80211_BPF_NOACK) == 0) { in rt2860_tx_raw()
1810 tap->wt_flags = 0; in rt2860_tx_raw()
1825 &nsegs, 0); in rt2860_tx_raw()
1826 if (__predict_false(error != 0 && error != EFBIG)) { in rt2860_tx_raw()
1832 if (__predict_true(error == 0)) { in rt2860_tx_raw()
1842 if (__predict_false(error != 0)) { in rt2860_tx_raw()
1853 segs, &nsegs, 0); in rt2860_tx_raw()
1854 if (__predict_false(error != 0)) { in rt2860_tx_raw()
1881 seg = &segs[0]; in rt2860_tx_raw()
1895 if (i > 0) { in rt2860_tx_raw()
1900 txd->sdl1 = 0; in rt2860_tx_raw()
1924 return 0; in rt2860_tx_raw()
1934 if ((sc->sc_flags & RT2860_RUNNING) == 0) { in rt2860_transmit()
1946 return (0); in rt2860_transmit()
1957 if ((sc->sc_flags & RT2860_RUNNING) == 0) in rt2860_start()
1960 while (!SLIST_EMPTY(&sc->data_pool) && sc->qfullmsk == 0 && in rt2860_start()
1963 if (rt2860_tx(sc, m, ni) != 0) { in rt2860_start()
1985 if (sc->sc_tx_timer > 0 && --sc->sc_tx_timer == 0) { in rt2860_watchdog()
1999 int startall = 0; in rt2860_parent()
2002 if (ic->ic_nrunning> 0) { in rt2860_parent()
2025 for (ntries = 0; ntries < 100; ntries++) { in rt2860_mcu_bbp_write()
2040 rt2860_mcu_cmd(sc, RT2860_MCU_CMD_BBP, 0, 0); in rt2860_mcu_bbp_write()
2050 for (ntries = 0; ntries < 100; ntries++) { in rt2860_mcu_bbp_read()
2058 return 0; in rt2860_mcu_bbp_read()
2065 rt2860_mcu_cmd(sc, RT2860_MCU_CMD_BBP, 0, 0); in rt2860_mcu_bbp_read()
2068 for (ntries = 0; ntries < 100; ntries++) { in rt2860_mcu_bbp_read()
2071 return val & 0xff; in rt2860_mcu_bbp_read()
2076 return 0; in rt2860_mcu_bbp_read()
2088 for (ntries = 0; ntries < 100; ntries++) { in rt2860_rf_write()
2100 (val & 0x3fffff) << 2 | (reg & 3); in rt2860_rf_write()
2110 for (ntries = 0; ntries < 100; ntries++) { in rt3090_rf_read()
2117 return 0xff; in rt3090_rf_read()
2122 for (ntries = 0; ntries < 100; ntries++) { in rt3090_rf_read()
2130 return 0xff; in rt3090_rf_read()
2132 return tmp & 0xff; in rt3090_rf_read()
2141 for (ntries = 0; ntries < 10; ntries++) { in rt3090_rf_write()
2165 for (ntries = 0; ntries < 100; ntries++) { in rt2860_mcu_cmd()
2179 return 0; in rt2860_mcu_cmd()
2181 for (ntries = 0; ntries < 200; ntries++) { in rt2860_mcu_cmd()
2184 for (slot = 0; slot < 4; slot++, tmp >>= 8) in rt2860_mcu_cmd()
2185 if ((tmp & 0xff) == cid) in rt2860_mcu_cmd()
2193 RAL_WRITE(sc, RT2860_H2M_MAILBOX_STATUS, 0xffffffff); in rt2860_mcu_cmd()
2194 RAL_WRITE(sc, RT2860_H2M_MAILBOX_CID, 0xffffffff); in rt2860_mcu_cmd()
2199 tmp = (tmp >> (slot * 8)) & 0xff; in rt2860_mcu_cmd()
2200 DPRINTF(("MCU command=0x%02x slot=%d status=0x%02x\n", in rt2860_mcu_cmd()
2203 RAL_WRITE(sc, RT2860_H2M_MAILBOX_STATUS, 0xffffffff); in rt2860_mcu_cmd()
2204 RAL_WRITE(sc, RT2860_H2M_MAILBOX_CID, 0xffffffff); in rt2860_mcu_cmd()
2205 return (tmp == 1) ? 0 : EIO; in rt2860_mcu_cmd()
2220 OFDM(0) << 4 | /* 9-> 6 */ in rt2860_enable_mrr()
2221 OFDM(0)); /* 6-> 6 */ in rt2860_enable_mrr()
2226 CCK(0) << 4 | /* 2-> 1 */ in rt2860_enable_mrr()
2227 CCK(0)); /* 1-> 1 */ in rt2860_enable_mrr()
2250 uint32_t mask = 0; in rt2860_set_basicrates()
2254 for (i = 0; i < rs->rs_nrates; i++) { in rt2860_set_basicrates()
2277 rt2860_set_gp_timer(sc, 0); in rt2860_scan_start()
2299 memset(bands, 0, sizeof(bands)); in rt2860_getradiocaps()
2302 ieee80211_add_channels_default_2ghz(chans, maxchans, nchans, bands, 0); in rt2860_getradiocaps()
2307 rt2860_chan_5ghz, nitems(rt2860_chan_5ghz), bands, 0); in rt2860_getradiocaps()
2327 rt2860_mcu_bbp_write(sc, 62, 0x37 - sc->lna[group]); in rt2860_select_chan_group()
2328 rt2860_mcu_bbp_write(sc, 63, 0x37 - sc->lna[group]); in rt2860_select_chan_group()
2329 rt2860_mcu_bbp_write(sc, 64, 0x37 - sc->lna[group]); in rt2860_select_chan_group()
2330 rt2860_mcu_bbp_write(sc, 86, 0x00); in rt2860_select_chan_group()
2332 if (group == 0) { in rt2860_select_chan_group()
2334 rt2860_mcu_bbp_write(sc, 82, 0x62); in rt2860_select_chan_group()
2335 rt2860_mcu_bbp_write(sc, 75, 0x46); in rt2860_select_chan_group()
2337 rt2860_mcu_bbp_write(sc, 82, 0x84); in rt2860_select_chan_group()
2338 rt2860_mcu_bbp_write(sc, 75, 0x50); in rt2860_select_chan_group()
2342 rt2860_mcu_bbp_write(sc, 82, 0xf2); in rt2860_select_chan_group()
2343 rt2860_mcu_bbp_write(sc, 75, 0x46); in rt2860_select_chan_group()
2345 rt2860_mcu_bbp_write(sc, 82, 0xf2); in rt2860_select_chan_group()
2346 rt2860_mcu_bbp_write(sc, 75, 0x50); in rt2860_select_chan_group()
2352 tmp |= (group == 0) ? RT2860_5G_BAND_SEL_N : RT2860_5G_BAND_SEL_P; in rt2860_select_chan_group()
2359 if (sc->mac_ver == 0x3593 && sc->nrxchains > 2) in rt2860_select_chan_group()
2361 if (group == 0) { /* 2GHz */ in rt2860_select_chan_group()
2365 if (sc->mac_ver == 0x3593 && sc->ntxchains > 2) in rt2860_select_chan_group()
2371 if (sc->mac_ver == 0x3593 && sc->ntxchains > 2) in rt2860_select_chan_group()
2376 if (sc->mac_ver == 0x3593) { in rt2860_select_chan_group()
2379 tmp &= ~0x01010000; in rt2860_select_chan_group()
2380 if (group == 0) in rt2860_select_chan_group()
2381 tmp |= 0x00010000; in rt2860_select_chan_group()
2383 tmp &= ~0x00008080; in rt2860_select_chan_group()
2384 if (group == 0) in rt2860_select_chan_group()
2385 tmp |= 0x00000080; in rt2860_select_chan_group()
2387 tmp = (tmp & ~0x00001000) | 0x00000010; in rt2860_select_chan_group()
2392 if (group == 0) { /* 2GHz band */ in rt2860_select_chan_group()
2393 if (sc->mac_ver >= 0x3071) in rt2860_select_chan_group()
2394 agc = 0x1c + sc->lna[0] * 2; in rt2860_select_chan_group()
2396 agc = 0x2e + sc->lna[0]; in rt2860_select_chan_group()
2398 agc = 0x32 + (sc->lna[group] * 5) / 3; in rt2860_select_chan_group()
2414 for (i = 0; rfprog[i].chan != chan; i++); in rt2860_set_chan()
2428 if (txpow1 >= 0) in rt2860_set_chan()
2432 if (txpow2 >= 0) in rt2860_set_chan()
2471 for (i = 0; rt2860_rf2850[i].chan != chan; i++); in rt3090_set_chan()
2479 rf = (rf & ~0x0f) | rt3090_freqs[i].k; in rt3090_set_chan()
2482 rf = (rf & ~0x03) | rt3090_freqs[i].r; in rt3090_set_chan()
2487 rf = (rf & ~0x1f) | txpow1; in rt3090_set_chan()
2492 rf = (rf & ~0x1f) | txpow2; in rt3090_set_chan()
2496 rf &= ~0xfc; in rt3090_set_chan()
2509 rf = (rf & ~0x7f) | sc->freq; in rt3090_set_chan()
2514 rf = (rf & ~0x3f) | sc->rf24_20mhz; in rt3090_set_chan()
2517 rf = (rf & ~0x3f) | sc->rf24_20mhz; in rt3090_set_chan()
2536 for (i = 0; rt2860_rf2850[i].chan != chan; i++); in rt5390_set_chan()
2543 rt3090_rf_write(sc, 9, rt3090_freqs[i].k & 0x0f); in rt5390_set_chan()
2545 rf = (rf & ~0x03) | (rt3090_freqs[i].r & 0x03); in rt5390_set_chan()
2549 rf = (rf & ~0x3f) | (txpow1 & 0x3f); in rt5390_set_chan()
2550 /* the valid range of the RF R49 is 0x00~0x27 */ in rt5390_set_chan()
2551 if ((rf & 0x3f) > 0x27) in rt5390_set_chan()
2552 rf = (rf & ~0x3f) | 0x27; in rt5390_set_chan()
2554 if (sc->mac_ver == 0x5392) { in rt5390_set_chan()
2556 rf = (rf & ~0x3f) | (txpow2 & 0x3f); in rt5390_set_chan()
2557 /* the valid range of the RF R50 is 0x00~0x27 */ in rt5390_set_chan()
2558 if ((rf & 0x3f) > 0x27) in rt5390_set_chan()
2559 rf = (rf & ~0x3f) | 0x27; in rt5390_set_chan()
2565 if (sc->mac_ver == 0x5392) in rt5390_set_chan()
2576 rf = (rf & ~0x7f) | (sc->freq & 0x7f); in rt5390_set_chan()
2577 rf = MIN(rf, 0x5f); in rt5390_set_chan()
2579 rt2860_mcu_cmd(sc, 0x74, (tmp << 8 ) | rf, 0); in rt5390_set_chan()
2581 if (sc->mac_ver == 0x5390) { in rt5390_set_chan()
2583 rf = 0x73; in rt5390_set_chan()
2585 rf = 0x63; in rt5390_set_chan()
2587 rf = 0x53; in rt5390_set_chan()
2593 rf = 0x0c; in rt5390_set_chan()
2595 rf = 0x0b; in rt5390_set_chan()
2597 rf = 0x0a; in rt5390_set_chan()
2599 rf = 0x09; in rt5390_set_chan()
2601 rf = 0x08; in rt5390_set_chan()
2603 rf = 0x07; in rt5390_set_chan()
2605 rf = 0x06; in rt5390_set_chan()
2610 h20mhz = (sc->rf24_20mhz & 0x20) >> 5; in rt5390_set_chan()
2612 rf = (rf & ~0x06) | (h20mhz << 1) | (h20mhz << 2); in rt5390_set_chan()
2617 rf = (rf & ~0x18) | 0x10; in rt5390_set_chan()
2635 rt3090_rf_write(sc, 30, rf | 0x80); in rt3090_rf_init()
2637 rt3090_rf_write(sc, 30, rf & ~0x80); in rt3090_rf_init()
2640 tmp &= ~0x1f000000; in rt3090_rf_init()
2641 if (sc->patch_dac && sc->mac_rev < 0x0211) in rt3090_rf_init()
2642 tmp |= 0x0d000000; /* 1.35V */ in rt3090_rf_init()
2644 tmp |= 0x01000000; /* 1.2V */ in rt3090_rf_init()
2649 RAL_WRITE(sc, RT3070_GPIO_SWITCH, tmp & ~0x20); in rt3090_rf_init()
2652 for (i = 0; i < nitems(rt3090_def_rf); i++) { in rt3090_rf_init()
2658 rt3090_rf_write(sc, 31, 0x14); in rt3090_rf_init()
2661 rt3090_rf_write(sc, 6, rf | 0x40); in rt3090_rf_init()
2663 if (sc->mac_ver != 0x3593) { in rt3090_rf_init()
2665 sc->rf24_20mhz = 0x1f; /* default value */ in rt3090_rf_init()
2666 rt3090_filter_calib(sc, 0x07, 0x16, &sc->rf24_20mhz); in rt3090_rf_init()
2670 rt2860_mcu_bbp_write(sc, 4, (bbp & ~0x08) | 0x10); in rt3090_rf_init()
2672 rt3090_rf_write(sc, 31, rf | 0x20); in rt3090_rf_init()
2675 sc->rf24_40mhz = 0x2f; /* default value */ in rt3090_rf_init()
2676 rt3090_filter_calib(sc, 0x27, 0x19, &sc->rf24_40mhz); in rt3090_rf_init()
2680 rt2860_mcu_bbp_write(sc, 4, bbp & ~0x18); in rt3090_rf_init()
2682 if (sc->mac_rev < 0x0211) in rt3090_rf_init()
2683 rt3090_rf_write(sc, 27, 0x03); in rt3090_rf_init()
2689 rt3090_set_rx_antenna(sc, 0); in rt3090_rf_init()
2692 if (sc->mac_ver == 0x3593) { in rt3090_rf_init()
2694 bbp |= 0x60; /* turn off DAC1 and DAC2 */ in rt3090_rf_init()
2696 bbp |= 0x40; /* turn off DAC2 */ in rt3090_rf_init()
2698 bbp &= ~0x06; /* turn off ADC1 and ADC2 */ in rt3090_rf_init()
2700 bbp &= ~0x04; /* turn off ADC2 */ in rt3090_rf_init()
2703 bbp |= 0x20; /* turn off DAC1 */ in rt3090_rf_init()
2705 bbp &= ~0x02; /* turn off ADC1 */ in rt3090_rf_init()
2719 if (sc->mac_rev >= 0x0211 && !sc->ext_2ghz_lna) in rt3090_rf_init()
2720 rf |= 0x20; /* fix for long range Rx issue */ in rt3090_rf_init()
2722 rf = (rf & ~0x7) | sc->txmixgain_2ghz; in rt3090_rf_init()
2731 return (0); in rt3090_rf_init()
2747 if (sc->mac_ver == 0x5392) { in rt5390_rf_init()
2748 for (i = 0; i < nitems(rt5392_def_rf); i++) { in rt5390_rf_init()
2753 for (i = 0; i < nitems(rt5390_def_rf); i++) { in rt5390_rf_init()
2759 sc->rf24_20mhz = 0x1f; in rt5390_rf_init()
2760 sc->rf24_40mhz = 0x2f; in rt5390_rf_init()
2762 if (sc->mac_rev < 0x0211) in rt5390_rf_init()
2763 rt3090_rf_write(sc, 27, 0x03); in rt5390_rf_init()
2768 RAL_WRITE(sc, RT2860_TX_SW_CFG1, 0); in rt5390_rf_init()
2769 RAL_WRITE(sc, RT2860_TX_SW_CFG2, 0); in rt5390_rf_init()
2771 if (sc->mac_ver == 0x5390) in rt5390_rf_init()
2772 rt3090_set_rx_antenna(sc, 0); in rt5390_rf_init()
2775 rt2860_mcu_bbp_write(sc, 79, 0x13); in rt5390_rf_init()
2776 rt2860_mcu_bbp_write(sc, 80, 0x05); in rt5390_rf_init()
2777 rt2860_mcu_bbp_write(sc, 81, 0x33); in rt5390_rf_init()
2780 if (sc->mac_rev >= 0x0211) in rt5390_rf_init()
2781 rt2860_mcu_bbp_write(sc, 103, 0xc0); in rt5390_rf_init()
2785 bbp |= 0x20; /* Turn off DAC1. */ in rt5390_rf_init()
2787 bbp &= ~0x02; /* Turn off ADC1. */ in rt5390_rf_init()
2799 rf = (rf & ~0x18) | 0x10; in rt5390_rf_init()
2809 if (sc->mac_ver == 0x3593) { in rt3090_rf_wakeup()
2846 rt3090_rf_write(sc, 7, rf | 0x30); in rt3090_rf_wakeup()
2849 rt3090_rf_write(sc, 9, rf | 0x0e); in rt3090_rf_wakeup()
2857 rf &= ~0x77; in rt3090_rf_wakeup()
2858 if (sc->mac_rev < 0x0211) in rt3090_rf_wakeup()
2859 rf |= 0x03; in rt3090_rf_wakeup()
2862 if (sc->patch_dac && sc->mac_rev < 0x0211) { in rt3090_rf_wakeup()
2864 tmp = (tmp & ~0x1f000000) | 0x0d000000; in rt3090_rf_wakeup()
2878 if (sc->mac_ver == 0x5392) in rt5390_rf_wakeup()
2884 if (sc->mac_ver == 0x5390) in rt5390_rf_wakeup()
2891 rf = (rf & ~0xe0) | 0x20; in rt5390_rf_wakeup()
2895 rt3090_rf_write(sc, 20, rt3090_rf_read(sc, 20) & ~0x77); in rt5390_rf_wakeup()
2898 if (sc->patch_dac && sc->mac_rev < 0x0211) { in rt5390_rf_wakeup()
2900 tmp = (tmp & ~0x1f000000) | 0x0d000000; in rt5390_rf_wakeup()
2915 rf24 = (rf24 & 0xc0) | init; /* initial filter value */ in rt3090_filter_calib()
2923 rt2860_mcu_bbp_write(sc, 24, 0x00); in rt3090_filter_calib()
2924 for (ntries = 0; ntries < 100; ntries++) { in rt3090_filter_calib()
2926 rt2860_mcu_bbp_write(sc, 25, 0x90); in rt3090_filter_calib()
2930 if (bbp55_pb != 0) in rt3090_filter_calib()
2937 rt2860_mcu_bbp_write(sc, 24, 0x06); in rt3090_filter_calib()
2938 for (ntries = 0; ntries < 100; ntries++) { in rt3090_filter_calib()
2940 rt2860_mcu_bbp_write(sc, 25, 0x90); in rt3090_filter_calib()
2961 rt2860_mcu_bbp_write(sc, 24, 0x00); in rt3090_filter_calib()
2967 return (0); in rt3090_filter_calib()
2976 if (sc->mac_rev >= 0x0211) { in rt3090_rf_setup()
2978 rt2860_mcu_bbp_write(sc, 103, 0xc0); in rt3090_rf_setup()
2982 rt2860_mcu_bbp_write(sc, 31, bbp & ~0x03); in rt3090_rf_setup()
2985 RAL_WRITE(sc, RT2860_TX_SW_CFG1, 0); in rt3090_rf_setup()
2986 if (sc->mac_rev < 0x0211) { in rt3090_rf_setup()
2988 sc->patch_dac ? 0x2c : 0x0f); in rt3090_rf_setup()
2990 RAL_WRITE(sc, RT2860_TX_SW_CFG2, 0); in rt3090_rf_setup()
2993 if (sc->mac_ver < 0x5390) { in rt3090_rf_setup()
2994 for (i = 0; i < 10; i++) { in rt3090_rf_setup()
2995 if (sc->rf[i].reg == 0 || sc->rf[i].reg == 0xff) in rt3090_rf_setup()
3006 which | (sc->leds & 0x7f), 0); in rt2860_set_leds()
3022 if (ms == 0) in rt2860_set_gp_timer()
3027 tmp = (tmp & 0xffff) | ms << RT2860_GP_TIMER_SHIFT; in rt2860_set_gp_timer()
3039 bssid[0] | bssid[1] << 8 | bssid[2] << 16 | bssid[3] << 24); in rt2860_set_bssid()
3048 addr[0] | addr[1] << 8 | addr[2] << 16 | addr[3] << 24); in rt2860_set_macaddr()
3050 addr[4] | addr[5] << 8 | 0xff << 16); in rt2860_set_macaddr()
3060 tmp &= ~0xff; in rt2860_updateslot()
3097 if (ic->ic_promisc == 0) in rt2860_update_promisc()
3115 for (aci = 0; aci < WME_NUM_AC; aci++) { in rt2860_updateedca()
3146 return 0; in rt2860_updateedca()
3162 return 0; in rt2860_set_key()
3183 wcid = 0; /* NB: update WCID0 for group keys */ in rt2860_set_key()
3184 base = RT2860_SKEY(0, k->k_id); in rt2860_set_key()
3212 if (val >= 0x03ff00 && (val & 0xf8ff00) == 0x00ff00) in rt2860_set_key()
3213 val += 0x000100; in rt2860_set_key()
3214 iv[0] = val; in rt2860_set_key()
3218 iv[4] = iv[5] = iv[6] = iv[7] = 0; in rt2860_set_key()
3221 iv[0] = k->k_tsc >> 8; in rt2860_set_key()
3222 iv[1] = (iv[0] | 0x20) & 0x7f; in rt2860_set_key()
3225 iv[0] = k->k_tsc; in rt2860_set_key()
3227 iv[2] = 0; in rt2860_set_key()
3241 attr &= ~(0xf << (k->k_id * 4)); in rt2860_set_key()
3247 attr = (attr & ~0xf) | (mode << 1) | RT2860_RX_PKEY_EN; in rt2860_set_key()
3250 return 0; in rt2860_set_key()
3264 attr &= ~(0xf << (k->k_id * 4)); in rt2860_delete_key()
3271 attr &= ~0xf; in rt2860_delete_key()
3296 delta = sc->rssi_2ghz[rxchain] - sc->lna[0]; in rt2860_rssi2dbm()
3310 for (i = 0; i < 8; i++) { in b4inc()
3311 b4 = b32 & 0xf; in b4inc()
3313 if (b4 < 0) in b4inc()
3314 b4 = 0; in b4inc()
3315 else if (b4 > 0xf) in b4inc()
3316 b4 = 0xf; in b4inc()
3353 if (sc->mac_ver >= 0x3071) { in rt2860_read_eeprom()
3355 DPRINTF(("EFUSE_CTRL=0x%08x\n", tmp)); in rt2860_read_eeprom()
3363 DPRINTF(("EEPROM rev=%d, FAE=%d\n", val >> 8, val & 0xff)); in rt2860_read_eeprom()
3368 macaddr[0] = val & 0xff; in rt2860_read_eeprom()
3371 macaddr[2] = val & 0xff; in rt2860_read_eeprom()
3374 macaddr[4] = val & 0xff; in rt2860_read_eeprom()
3380 DPRINTF(("EEPROM region code=0x%04x\n", val)); in rt2860_read_eeprom()
3384 for (i = 0; i < 8; i++) { in rt2860_read_eeprom()
3386 sc->bbp[i].val = val & 0xff; in rt2860_read_eeprom()
3388 DPRINTF(("BBP%d=0x%02x\n", sc->bbp[i].reg, sc->bbp[i].val)); in rt2860_read_eeprom()
3390 if (sc->mac_ver >= 0x3071) { in rt2860_read_eeprom()
3392 for (i = 0; i < 10; i++) { in rt2860_read_eeprom()
3394 sc->rf[i].val = val & 0xff; in rt2860_read_eeprom()
3396 DPRINTF(("RF%d=0x%02x\n", sc->rf[i].reg, in rt2860_read_eeprom()
3403 sc->freq = ((val & 0xff) != 0xff) ? val & 0xff : 0; in rt2860_read_eeprom()
3404 DPRINTF(("EEPROM freq offset %d\n", sc->freq & 0xff)); in rt2860_read_eeprom()
3405 if ((val >> 8) != 0xff) { in rt2860_read_eeprom()
3408 sc->led[0] = rt2860_srom_read(sc, RT2860_EEPROM_LED1); in rt2860_read_eeprom()
3413 sc->leds = 0x01; in rt2860_read_eeprom()
3414 sc->led[0] = 0x5555; in rt2860_read_eeprom()
3415 sc->led[1] = 0x2221; in rt2860_read_eeprom()
3416 sc->led[2] = 0xa9f8; in rt2860_read_eeprom()
3418 DPRINTF(("EEPROM LED mode=0x%02x, LEDs=0x%04x/0x%04x/0x%04x\n", in rt2860_read_eeprom()
3419 sc->leds, sc->led[0], sc->led[1], sc->led[2])); in rt2860_read_eeprom()
3423 if (sc->mac_ver >= 0x5390) in rt2860_read_eeprom()
3426 sc->rf_rev = (val >> 8) & 0xf; in rt2860_read_eeprom()
3427 sc->ntxchains = (val >> 4) & 0xf; in rt2860_read_eeprom()
3428 sc->nrxchains = val & 0xf; in rt2860_read_eeprom()
3429 DPRINTF(("EEPROM RF rev=0x%02x chains=%dT%dR\n", in rt2860_read_eeprom()
3434 DPRINTF(("EEPROM CFG 0x%04x\n", val)); in rt2860_read_eeprom()
3436 if ((val >> 8) != 0xff) in rt2860_read_eeprom()
3438 if ((val & 0xff) != 0xff) { in rt2860_read_eeprom()
3442 sc->calib_2ghz = sc->calib_5ghz = 0; /* XXX (val >> 1) & 1 */ in rt2860_read_eeprom()
3449 if ((val & 0xff) != 0xff) { in rt2860_read_eeprom()
3450 sc->pslevel = val & 0x3; in rt2860_read_eeprom()
3452 if ((val & 0xff80) != 0x9280) in rt2860_read_eeprom()
3459 for (i = 0; i < 14; i += 2) { in rt2860_read_eeprom()
3462 sc->txpow1[i + 0] = (int8_t)(val & 0xff); in rt2860_read_eeprom()
3465 if (sc->mac_ver != 0x5390) { in rt2860_read_eeprom()
3468 sc->txpow2[i + 0] = (int8_t)(val & 0xff); in rt2860_read_eeprom()
3473 for (i = 0; i < 14; i++) { in rt2860_read_eeprom()
3474 if (sc->txpow1[i] < 0 || in rt2860_read_eeprom()
3475 sc->txpow1[i] > ((sc->mac_ver >= 0x5390) ? 39 : 31)) in rt2860_read_eeprom()
3477 if (sc->mac_ver != 0x5390) { in rt2860_read_eeprom()
3478 if (sc->txpow2[i] < 0 || in rt2860_read_eeprom()
3479 sc->txpow2[i] > ((sc->mac_ver == 0x5392) ? 39 : 31)) in rt2860_read_eeprom()
3486 for (i = 0; i < 40; i += 2) { in rt2860_read_eeprom()
3489 sc->txpow1[i + 14] = (int8_t)(val & 0xff); in rt2860_read_eeprom()
3494 sc->txpow2[i + 14] = (int8_t)(val & 0xff); in rt2860_read_eeprom()
3498 for (i = 0; i < 40; i++) { in rt2860_read_eeprom()
3510 delta_2ghz = delta_5ghz = 0; in rt2860_read_eeprom()
3511 if ((val & 0xff) != 0xff && (val & 0x80)) { in rt2860_read_eeprom()
3512 delta_2ghz = val & 0xf; in rt2860_read_eeprom()
3513 if (!(val & 0x40)) /* negative number */ in rt2860_read_eeprom()
3517 if ((val & 0xff) != 0xff && (val & 0x80)) { in rt2860_read_eeprom()
3518 delta_5ghz = val & 0xf; in rt2860_read_eeprom()
3519 if (!(val & 0x40)) /* negative number */ in rt2860_read_eeprom()
3525 for (ridx = 0; ridx < 5; ridx++) { in rt2860_read_eeprom()
3537 DPRINTF(("ridx %d: power 20MHz=0x%08x, 40MHz/2GHz=0x%08x, " in rt2860_read_eeprom()
3538 "40MHz/5GHz=0x%08x\n", ridx, sc->txpow20mhz[ridx], in rt2860_read_eeprom()
3544 sc->tssi_2ghz[0] = val & 0xff; /* [-4] */ in rt2860_read_eeprom()
3547 sc->tssi_2ghz[2] = val & 0xff; /* [-2] */ in rt2860_read_eeprom()
3550 sc->tssi_2ghz[4] = val & 0xff; /* [+0] */ in rt2860_read_eeprom()
3553 sc->tssi_2ghz[6] = val & 0xff; /* [+2] */ in rt2860_read_eeprom()
3556 sc->tssi_2ghz[8] = val & 0xff; /* [+4] */ in rt2860_read_eeprom()
3558 DPRINTF(("TSSI 2GHz: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x " in rt2860_read_eeprom()
3559 "0x%02x 0x%02x step=%d\n", sc->tssi_2ghz[0], sc->tssi_2ghz[1], in rt2860_read_eeprom()
3564 if (sc->tssi_2ghz[4] == 0xff) in rt2860_read_eeprom()
3565 sc->calib_2ghz = 0; in rt2860_read_eeprom()
3568 sc->tssi_5ghz[0] = val & 0xff; /* [-4] */ in rt2860_read_eeprom()
3571 sc->tssi_5ghz[2] = val & 0xff; /* [-2] */ in rt2860_read_eeprom()
3574 sc->tssi_5ghz[4] = val & 0xff; /* [+0] */ in rt2860_read_eeprom()
3577 sc->tssi_5ghz[6] = val & 0xff; /* [+2] */ in rt2860_read_eeprom()
3580 sc->tssi_5ghz[8] = val & 0xff; /* [+4] */ in rt2860_read_eeprom()
3582 DPRINTF(("TSSI 5GHz: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x " in rt2860_read_eeprom()
3583 "0x%02x 0x%02x step=%d\n", sc->tssi_5ghz[0], sc->tssi_5ghz[1], in rt2860_read_eeprom()
3588 if (sc->tssi_5ghz[4] == 0xff) in rt2860_read_eeprom()
3589 sc->calib_5ghz = 0; in rt2860_read_eeprom()
3593 sc->rssi_2ghz[0] = val & 0xff; /* Ant A */ in rt2860_read_eeprom()
3596 if (sc->mac_ver >= 0x3071) { in rt2860_read_eeprom()
3601 if ((val & 0xff) != 0xff) in rt2860_read_eeprom()
3602 sc->txmixgain_2ghz = val & 0x7; in rt2860_read_eeprom()
3605 sc->rssi_2ghz[2] = val & 0xff; /* Ant C */ in rt2860_read_eeprom()
3609 sc->rssi_5ghz[0] = val & 0xff; /* Ant A */ in rt2860_read_eeprom()
3612 sc->rssi_5ghz[2] = val & 0xff; /* Ant C */ in rt2860_read_eeprom()
3616 if (sc->mac_ver >= 0x3071) in rt2860_read_eeprom()
3617 sc->lna[0] = RT3090_DEF_LNA; in rt2860_read_eeprom()
3618 else /* channel group 0 */ in rt2860_read_eeprom()
3619 sc->lna[0] = val & 0xff; in rt2860_read_eeprom()
3623 if (sc->lna[2] == 0 || sc->lna[2] == 0xff) { in rt2860_read_eeprom()
3627 if (sc->lna[3] == 0 || sc->lna[3] == 0xff) { in rt2860_read_eeprom()
3633 for (ant = 0; ant < 3; ant++) { in rt2860_read_eeprom()
3637 sc->rssi_2ghz[ant] = 0; in rt2860_read_eeprom()
3642 sc->rssi_5ghz[ant] = 0; in rt2860_read_eeprom()
3646 return 0; in rt2860_read_eeprom()
3655 for (ntries = 0; ntries < 20; ntries++) { in rt2860_bbp_init()
3656 uint8_t bbp0 = rt2860_mcu_bbp_read(sc, 0); in rt2860_bbp_init()
3657 if (bbp0 != 0 && bbp0 != 0xff) in rt2860_bbp_init()
3667 if (sc->mac_ver >= 0x5390) in rt2860_bbp_init()
3670 for (i = 0; i < nitems(rt2860_def_bbp); i++) { in rt2860_bbp_init()
3677 if (sc->mac_ver == 0x2860 && sc->mac_rev != 0x0101) in rt2860_bbp_init()
3678 rt2860_mcu_bbp_write(sc, 84, 0x19); in rt2860_bbp_init()
3680 if (sc->mac_ver >= 0x3071) { in rt2860_bbp_init()
3681 rt2860_mcu_bbp_write(sc, 79, 0x13); in rt2860_bbp_init()
3682 rt2860_mcu_bbp_write(sc, 80, 0x05); in rt2860_bbp_init()
3683 rt2860_mcu_bbp_write(sc, 81, 0x33); in rt2860_bbp_init()
3684 } else if (sc->mac_ver == 0x2860 && sc->mac_rev == 0x0100) { in rt2860_bbp_init()
3685 rt2860_mcu_bbp_write(sc, 69, 0x16); in rt2860_bbp_init()
3686 rt2860_mcu_bbp_write(sc, 73, 0x12); in rt2860_bbp_init()
3689 return 0; in rt2860_bbp_init()
3708 for (i = 0; i < nitems(rt5390_def_bbp); i++) { in rt5390_bbp_init()
3713 if (sc->mac_ver == 0x5392) { in rt5390_bbp_init()
3714 rt2860_mcu_bbp_write(sc, 84, 0x9a); in rt5390_bbp_init()
3715 rt2860_mcu_bbp_write(sc, 95, 0x9a); in rt5390_bbp_init()
3716 rt2860_mcu_bbp_write(sc, 98, 0x12); in rt5390_bbp_init()
3717 rt2860_mcu_bbp_write(sc, 106, 0x05); in rt5390_bbp_init()
3718 rt2860_mcu_bbp_write(sc, 134, 0xd0); in rt5390_bbp_init()
3719 rt2860_mcu_bbp_write(sc, 135, 0xf6); in rt5390_bbp_init()
3723 rt2860_mcu_bbp_write(sc, 152, bbp | 0x80); in rt5390_bbp_init()
3726 if (sc->mac_ver == 0x5390) in rt5390_bbp_init()
3727 rt2860_mcu_bbp_write(sc, 154, 0); in rt5390_bbp_init()
3740 for (ntries = 0; ntries < 200; ntries++) { in rt2860_txrx_enable()
3742 if ((tmp & (RT2860_TX_DMA_BUSY | RT2860_RX_DMA_BUSY)) == 0) in rt2860_txrx_enable()
3772 return 0; in rt2860_txrx_enable()
3826 RAL_WRITE(sc, RT2860_SYS_CTRL, 0xe1f); in rt2860_init_locked()
3828 RAL_WRITE(sc, RT2860_SYS_CTRL, 0xe00); in rt2860_init_locked()
3830 if ((error = rt2860_load_microcode(sc)) != 0) { in rt2860_init_locked()
3839 for (ridx = 0; ridx < 5; ridx++) { in rt2860_init_locked()
3840 if (sc->txpow20mhz[ridx] == 0xffffffff) in rt2860_init_locked()
3845 for (ntries = 0; ntries < 100; ntries++) { in rt2860_init_locked()
3847 if ((tmp & (RT2860_TX_DMA_BUSY | RT2860_RX_DMA_BUSY)) == 0) in rt2860_init_locked()
3862 RAL_WRITE(sc, RT2860_WPDMA_RST_IDX, 0x1003f); in rt2860_init_locked()
3865 RAL_WRITE(sc, RT2860_SYS_CTRL, 0xe1f); in rt2860_init_locked()
3867 RAL_WRITE(sc, RT2860_SYS_CTRL, 0xe00); in rt2860_init_locked()
3873 RAL_WRITE(sc, RT2860_MAC_SYS_CTRL, 0); in rt2860_init_locked()
3875 for (i = 0; i < nitems(rt2860_def_mac); i++) in rt2860_init_locked()
3877 if (sc->mac_ver >= 0x5390) in rt2860_init_locked()
3878 RAL_WRITE(sc, RT2860_TX_SW_CFG0, 0x00000404); in rt2860_init_locked()
3879 else if (sc->mac_ver >= 0x3071) { in rt2860_init_locked()
3889 tmp = (tmp & ~0xff) | 0x7d; in rt2860_init_locked()
3894 for (ntries = 0; ntries < 100; ntries++) { in rt2860_init_locked()
3907 RAL_WRITE(sc, RT2860_H2M_BBPAGENT, 0); in rt2860_init_locked()
3908 RAL_WRITE(sc, RT2860_H2M_MAILBOX, 0); in rt2860_init_locked()
3910 rt2860_mcu_cmd(sc, RT2860_MCU_CMD_RFRESET, 0, 0); in rt2860_init_locked()
3913 if ((error = rt2860_bbp_init(sc)) != 0) { in rt2860_init_locked()
3919 RAL_SET_REGION_4(sc, RT2860_WCID_ENTRY(0), 0, 512); in rt2860_init_locked()
3921 RAL_SET_REGION_4(sc, RT2860_PKEY(0), 0, 2048); in rt2860_init_locked()
3923 RAL_SET_REGION_4(sc, RT2860_IVEIV(0), 0, 512); in rt2860_init_locked()
3925 RAL_SET_REGION_4(sc, RT2860_WCID_ATTR(0), 0, 256); in rt2860_init_locked()
3927 RAL_SET_REGION_4(sc, RT2860_SKEY(0, 0), 0, 8 * 32); in rt2860_init_locked()
3929 RAL_SET_REGION_4(sc, RT2860_SKEY_MODE_0_7, 0, 4); in rt2860_init_locked()
3932 for (qid = 0; qid < 6; qid++) { in rt2860_init_locked()
3935 RAL_WRITE(sc, RT2860_TX_CTX_IDX(qid), 0); in rt2860_init_locked()
3947 for (ntries = 0; ntries < 100; ntries++) { in rt2860_init_locked()
3949 if ((tmp & (RT2860_TX_DMA_BUSY | RT2860_RX_DMA_BUSY)) == 0) in rt2860_init_locked()
3964 RAL_WRITE(sc, RT2860_DELAY_INT_CFG, 0); in rt2860_init_locked()
3967 for (i = 0; i < 8; i++) { in rt2860_init_locked()
3968 if (sc->bbp[i].reg == 0 || sc->bbp[i].reg == 0xff) in rt2860_init_locked()
3977 sc->mac_ver == 0x5390) in rt2860_init_locked()
3978 rt3090_set_rx_antenna(sc, 0); in rt2860_init_locked()
3981 rt2860_mcu_cmd(sc, RT2860_MCU_CMD_LED1, sc->led[0], 0); in rt2860_init_locked()
3982 rt2860_mcu_cmd(sc, RT2860_MCU_CMD_LED2, sc->led[1], 0); in rt2860_init_locked()
3983 rt2860_mcu_cmd(sc, RT2860_MCU_CMD_LED3, sc->led[2], 0); in rt2860_init_locked()
3985 if (sc->mac_ver >= 0x5390) in rt2860_init_locked()
3987 else if (sc->mac_ver >= 0x3071) { in rt2860_init_locked()
3988 if ((error = rt3090_rf_init(sc)) != 0) { in rt2860_init_locked()
3994 rt2860_mcu_cmd(sc, RT2860_MCU_CMD_SLEEP, 0x02ff, 1); in rt2860_init_locked()
3995 rt2860_mcu_cmd(sc, RT2860_MCU_CMD_WAKEUP, 0, 1); in rt2860_init_locked()
3997 if (sc->mac_ver >= 0x5390) in rt2860_init_locked()
3999 else if (sc->mac_ver >= 0x3071) in rt2860_init_locked()
4015 else if (sc->mac_ver == 0x3593 && sc->ntxchains == 2) in rt2860_init_locked()
4017 else if (sc->mac_ver == 0x3593 && sc->ntxchains == 3) in rt2860_init_locked()
4021 if (sc->mac_ver >= 0x3071) in rt2860_init_locked()
4028 rt2860_mcu_cmd(sc, RT2860_MCU_CMD_RFRESET, 0, 0); in rt2860_init_locked()
4032 tmp &= ~0xffff00; in rt2860_init_locked()
4043 if ((error = rt2860_txrx_enable(sc)) != 0) { in rt2860_init_locked()
4049 RAL_WRITE(sc, RT2860_INT_STATUS, 0xffffffff); in rt2860_init_locked()
4051 RAL_WRITE(sc, RT2860_INT_MASK, 0x3fffc); in rt2860_init_locked()
4054 rt2860_mcu_cmd(sc, RT2860_MCU_CMD_PSLEVEL, sc->pslevel, 0); in rt2860_init_locked()
4078 rt2860_set_leds(sc, 0); /* turn all LEDs off */ in rt2860_stop_locked()
4081 sc->sc_tx_timer = 0; in rt2860_stop_locked()
4085 RAL_WRITE(sc, RT2860_INT_MASK, 0); in rt2860_stop_locked()
4088 rt2860_set_gp_timer(sc, 0); in rt2860_stop_locked()
4098 RAL_WRITE(sc, RT2860_MAC_SYS_CTRL, 0); in rt2860_stop_locked()
4101 sc->qfullmsk = 0; in rt2860_stop_locked()
4102 for (qid = 0; qid < 6; qid++) in rt2860_stop_locked()
4129 RAL_WRITE(sc, RT2860_SYS_CTRL, 0); in rt2860_load_microcode()
4133 RAL_WRITE(sc, RT2860_H2M_BBPAGENT, 0); in rt2860_load_microcode()
4134 RAL_WRITE(sc, RT2860_H2M_MAILBOX, 0); in rt2860_load_microcode()
4138 for (ntries = 0; ntries < 1000; ntries++) { in rt2860_load_microcode()
4148 error = 0; in rt2860_load_microcode()
4178 if (bbp49 < tssi[0]) { /* lower than reference */ in rt2860_calib()
4180 for (d = 0; d > -4 && bbp49 <= tssi[d - 1]; d--); in rt2860_calib()
4181 } else if (bbp49 > tssi[0]) { /* greater than reference */ in rt2860_calib()
4183 for (d = 0; d < +4 && bbp49 >= tssi[d + 1]; d++); in rt2860_calib()
4186 d = 0; in rt2860_calib()
4190 DPRINTF(("BBP49=0x%02x, adjusting Tx power by %d\n", bbp49, d)); in rt2860_calib()
4193 for (ridx = 0; ridx < 5; ridx++) { in rt2860_calib()
4194 if (sc->txpow20mhz[ridx] == 0xffffffff) in rt2860_calib()
4208 if (sc->mac_ver == 0x5390) { in rt3090_set_rx_antenna()
4210 rt2860_mcu_bbp_read(sc, 152) & ~0x80); in rt3090_set_rx_antenna()
4215 RAL_WRITE(sc, RT2860_GPIO_CTRL, (tmp & ~0x0808) | 0x08); in rt3090_set_rx_antenna()
4218 if (sc->mac_ver == 0x5390) { in rt3090_set_rx_antenna()
4220 rt2860_mcu_bbp_read(sc, 152) | 0x80); in rt3090_set_rx_antenna()
4225 RAL_WRITE(sc, RT2860_GPIO_CTRL, tmp & ~0x0808); in rt3090_set_rx_antenna()
4237 if (chan == 0 || chan == IEEE80211_CHAN_ANY) in rt2860_switch_chan()
4240 if (sc->mac_ver >= 0x5390) in rt2860_switch_chan()
4242 else if (sc->mac_ver >= 0x3071) in rt2860_switch_chan()
4249 group = 0; in rt2860_switch_chan()
4258 if (sc->mac_ver < 0x5390) in rt2860_switch_chan()
4275 memset(&txwi, 0, sizeof txwi); in rt2860_setup_beacon()
4276 txwi.wcid = 0xff; in rt2860_setup_beacon()
4288 RAL_WRITE_REGION_1(sc, RT2860_BCN_BASE(0), in rt2860_setup_beacon()
4290 RAL_WRITE_REGION_1(sc, RT2860_BCN_BASE(0) + sizeof txwi, in rt2860_setup_beacon()
4295 return 0; in rt2860_setup_beacon()
4307 tmp &= ~0x1fffff; in rt2860_enable_tsf_sync()