Lines Matching refs:sc
306 rt2860_eeprom_read(struct rt2860_softc *sc, uint8_t addr) in rt2860_eeprom_read() argument
313 RT2860_EEPROM_CTL(sc, 0); in rt2860_eeprom_read()
315 RT2860_EEPROM_CTL(sc, RT2860_S); in rt2860_eeprom_read()
316 RT2860_EEPROM_CTL(sc, RT2860_S | RT2860_C); in rt2860_eeprom_read()
317 RT2860_EEPROM_CTL(sc, RT2860_S); in rt2860_eeprom_read()
320 RT2860_EEPROM_CTL(sc, RT2860_S | RT2860_D); in rt2860_eeprom_read()
321 RT2860_EEPROM_CTL(sc, RT2860_S | RT2860_D | RT2860_C); in rt2860_eeprom_read()
324 RT2860_EEPROM_CTL(sc, RT2860_S | RT2860_D); in rt2860_eeprom_read()
325 RT2860_EEPROM_CTL(sc, RT2860_S | RT2860_D | RT2860_C); in rt2860_eeprom_read()
326 RT2860_EEPROM_CTL(sc, RT2860_S); in rt2860_eeprom_read()
327 RT2860_EEPROM_CTL(sc, RT2860_S | RT2860_C); in rt2860_eeprom_read()
330 n = ((RT2860_READ(sc, RT2860_PCI_EECTRL) & 0x30) == 0) ? 5 : 7; in rt2860_eeprom_read()
332 RT2860_EEPROM_CTL(sc, RT2860_S | in rt2860_eeprom_read()
334 RT2860_EEPROM_CTL(sc, RT2860_S | in rt2860_eeprom_read()
338 RT2860_EEPROM_CTL(sc, RT2860_S); in rt2860_eeprom_read()
343 RT2860_EEPROM_CTL(sc, RT2860_S | RT2860_C); in rt2860_eeprom_read()
344 tmp = RT2860_READ(sc, RT2860_PCI_EECTRL); in rt2860_eeprom_read()
346 RT2860_EEPROM_CTL(sc, RT2860_S); in rt2860_eeprom_read()
349 RT2860_EEPROM_CTL(sc, 0); in rt2860_eeprom_read()
352 RT2860_EEPROM_CTL(sc, RT2860_S); in rt2860_eeprom_read()
353 RT2860_EEPROM_CTL(sc, 0); in rt2860_eeprom_read()
354 RT2860_EEPROM_CTL(sc, RT2860_C); in rt2860_eeprom_read()
381 rt2860_read_eeprom(struct rt2860_softc *sc) in rt2860_read_eeprom() argument
383 struct ieee80211com *ic = &sc->sc_ic; in rt2860_read_eeprom()
389 val = rt2860_eeprom_read(sc, RT2860_EEPROM_VERSION); in rt2860_read_eeprom()
395 val = rt2860_eeprom_read(sc, RT2860_EEPROM_MAC01); in rt2860_read_eeprom()
398 val = rt2860_eeprom_read(sc, RT2860_EEPROM_MAC23); in rt2860_read_eeprom()
401 val = rt2860_eeprom_read(sc, RT2860_EEPROM_MAC45); in rt2860_read_eeprom()
411 val = rt2860_eeprom_read(sc, RT2860_EEPROM_COUNTRY); in rt2860_read_eeprom()
417 val = rt2860_eeprom_read(sc, RT2860_EEPROM_BBP_BASE + i); in rt2860_read_eeprom()
418 sc->bbp[i].val = val & 0xff; in rt2860_read_eeprom()
419 sc->bbp[i].reg = val >> 8; in rt2860_read_eeprom()
422 sc->bbp[i].reg, sc->bbp[i].val); in rt2860_read_eeprom()
426 val = rt2860_eeprom_read(sc, RT2860_EEPROM_FREQ_LEDS); in rt2860_read_eeprom()
427 sc->freq = ((val & 0xff) != 0xff) ? val & 0xff : 0; in rt2860_read_eeprom()
429 "EEPROM freq offset %d\n", sc->freq & 0xff); in rt2860_read_eeprom()
431 if ((sc->leds = val >> 8) != 0xff) { in rt2860_read_eeprom()
433 sc->led[0] = rt2860_eeprom_read(sc, RT2860_EEPROM_LED1); in rt2860_read_eeprom()
434 sc->led[1] = rt2860_eeprom_read(sc, RT2860_EEPROM_LED2); in rt2860_read_eeprom()
435 sc->led[2] = rt2860_eeprom_read(sc, RT2860_EEPROM_LED3); in rt2860_read_eeprom()
438 sc->leds = 0x01; in rt2860_read_eeprom()
439 sc->led[0] = 0x5555; in rt2860_read_eeprom()
440 sc->led[1] = 0x2221; in rt2860_read_eeprom()
441 sc->led[2] = 0xa9f8; in rt2860_read_eeprom()
445 sc->leds, sc->led[0], sc->led[1], sc->led[2]); in rt2860_read_eeprom()
448 val = rt2860_eeprom_read(sc, RT2860_EEPROM_ANTENNA); in rt2860_read_eeprom()
453 sc->rf_rev = RT2860_RF_2820; in rt2860_read_eeprom()
454 sc->ntxchains = 1; in rt2860_read_eeprom()
455 sc->nrxchains = 2; in rt2860_read_eeprom()
457 sc->rf_rev = (val >> 8) & 0xf; in rt2860_read_eeprom()
458 sc->ntxchains = (val >> 4) & 0xf; in rt2860_read_eeprom()
459 sc->nrxchains = val & 0xf; in rt2860_read_eeprom()
463 sc->rf_rev, sc->ntxchains, sc->nrxchains); in rt2860_read_eeprom()
466 val = rt2860_eeprom_read(sc, RT2860_EEPROM_CONFIG); in rt2860_read_eeprom()
470 sc->calib_2ghz = sc->calib_5ghz = 0; /* XXX (val >> 1) & 1 */; in rt2860_read_eeprom()
472 if (sc->sc_flags & RT2860_ADVANCED_PS) { in rt2860_read_eeprom()
474 val = rt2860_eeprom_read(sc, RT2860_EEPROM_PCIE_PSLEVEL); in rt2860_read_eeprom()
476 sc->pslevel = val & 0x3; in rt2860_read_eeprom()
477 val = rt2860_eeprom_read(sc, RT2860_EEPROM_REV); in rt2860_read_eeprom()
479 sc->pslevel = MIN(sc->pslevel, 1); in rt2860_read_eeprom()
483 sc->pslevel); in rt2860_read_eeprom()
488 val = rt2860_eeprom_read(sc, in rt2860_read_eeprom()
490 sc->txpow1[i + 0] = (int8_t)(val & 0xff); in rt2860_read_eeprom()
491 sc->txpow1[i + 1] = (int8_t)(val >> 8); in rt2860_read_eeprom()
493 val = rt2860_eeprom_read(sc, in rt2860_read_eeprom()
495 sc->txpow2[i + 0] = (int8_t)(val & 0xff); in rt2860_read_eeprom()
496 sc->txpow2[i + 1] = (int8_t)(val >> 8); in rt2860_read_eeprom()
500 if (sc->txpow1[i] < 0 || sc->txpow1[i] > 31) in rt2860_read_eeprom()
501 sc->txpow1[i] = 5; in rt2860_read_eeprom()
502 if (sc->txpow2[i] < 0 || sc->txpow2[i] > 31) in rt2860_read_eeprom()
503 sc->txpow2[i] = 5; in rt2860_read_eeprom()
506 rt2860_rf2850[i].chan, sc->txpow1[i], sc->txpow2[i]); in rt2860_read_eeprom()
510 val = rt2860_eeprom_read(sc, in rt2860_read_eeprom()
512 sc->txpow1[i + 14] = (int8_t)(val & 0xff); in rt2860_read_eeprom()
513 sc->txpow1[i + 15] = (int8_t)(val >> 8); in rt2860_read_eeprom()
515 val = rt2860_eeprom_read(sc, in rt2860_read_eeprom()
517 sc->txpow2[i + 14] = (int8_t)(val & 0xff); in rt2860_read_eeprom()
518 sc->txpow2[i + 15] = (int8_t)(val >> 8); in rt2860_read_eeprom()
522 if (sc->txpow1[14 + i] < -7 || sc->txpow1[14 + i] > 15) in rt2860_read_eeprom()
523 sc->txpow1[14 + i] = 5; in rt2860_read_eeprom()
524 if (sc->txpow2[14 + i] < -7 || sc->txpow2[14 + i] > 15) in rt2860_read_eeprom()
525 sc->txpow2[14 + i] = 5; in rt2860_read_eeprom()
528 rt2860_rf2850[14 + i].chan, sc->txpow1[14 + i], in rt2860_read_eeprom()
529 sc->txpow2[14 + i]); in rt2860_read_eeprom()
533 val = rt2860_eeprom_read(sc, RT2860_EEPROM_DELTAPWR); in rt2860_read_eeprom()
553 val = rt2860_eeprom_read(sc, RT2860_EEPROM_RPWR + ridx); in rt2860_read_eeprom()
555 val = rt2860_eeprom_read(sc, RT2860_EEPROM_RPWR + ridx + 1); in rt2860_read_eeprom()
558 sc->txpow20mhz[ridx] = reg; in rt2860_read_eeprom()
559 sc->txpow40mhz_2ghz[ridx] = b4inc(reg, delta_2ghz); in rt2860_read_eeprom()
560 sc->txpow40mhz_5ghz[ridx] = b4inc(reg, delta_5ghz); in rt2860_read_eeprom()
564 "40MHz/5GHz=0x%08x\n", ridx, sc->txpow20mhz[ridx], in rt2860_read_eeprom()
565 sc->txpow40mhz_2ghz[ridx], sc->txpow40mhz_5ghz[ridx]); in rt2860_read_eeprom()
569 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI1_2GHZ); in rt2860_read_eeprom()
570 sc->tssi_2ghz[0] = val & 0xff; /* [-4] */ in rt2860_read_eeprom()
571 sc->tssi_2ghz[1] = val >> 8; /* [-3] */ in rt2860_read_eeprom()
572 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI2_2GHZ); in rt2860_read_eeprom()
573 sc->tssi_2ghz[2] = val & 0xff; /* [-2] */ in rt2860_read_eeprom()
574 sc->tssi_2ghz[3] = val >> 8; /* [-1] */ in rt2860_read_eeprom()
575 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI3_2GHZ); in rt2860_read_eeprom()
576 sc->tssi_2ghz[4] = val & 0xff; /* [+0] */ in rt2860_read_eeprom()
577 sc->tssi_2ghz[5] = val >> 8; /* [+1] */ in rt2860_read_eeprom()
578 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI4_2GHZ); in rt2860_read_eeprom()
579 sc->tssi_2ghz[6] = val & 0xff; /* [+2] */ in rt2860_read_eeprom()
580 sc->tssi_2ghz[7] = val >> 8; /* [+3] */ in rt2860_read_eeprom()
581 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI5_2GHZ); in rt2860_read_eeprom()
582 sc->tssi_2ghz[8] = val & 0xff; /* [+4] */ in rt2860_read_eeprom()
583 sc->step_2ghz = val >> 8; in rt2860_read_eeprom()
586 "0x%02x 0x%02x step=%d\n", sc->tssi_2ghz[0], sc->tssi_2ghz[1], in rt2860_read_eeprom()
587 sc->tssi_2ghz[2], sc->tssi_2ghz[3], sc->tssi_2ghz[4], in rt2860_read_eeprom()
588 sc->tssi_2ghz[5], sc->tssi_2ghz[6], sc->tssi_2ghz[7], in rt2860_read_eeprom()
589 sc->tssi_2ghz[8], sc->step_2ghz); in rt2860_read_eeprom()
591 if (sc->tssi_2ghz[4] == 0xff) in rt2860_read_eeprom()
592 sc->calib_2ghz = 0; in rt2860_read_eeprom()
594 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI1_5GHZ); in rt2860_read_eeprom()
595 sc->tssi_5ghz[0] = val & 0xff; /* [-4] */ in rt2860_read_eeprom()
596 sc->tssi_5ghz[1] = val >> 8; /* [-3] */ in rt2860_read_eeprom()
597 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI2_5GHZ); in rt2860_read_eeprom()
598 sc->tssi_5ghz[2] = val & 0xff; /* [-2] */ in rt2860_read_eeprom()
599 sc->tssi_5ghz[3] = val >> 8; /* [-1] */ in rt2860_read_eeprom()
600 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI3_5GHZ); in rt2860_read_eeprom()
601 sc->tssi_5ghz[4] = val & 0xff; /* [+0] */ in rt2860_read_eeprom()
602 sc->tssi_5ghz[5] = val >> 8; /* [+1] */ in rt2860_read_eeprom()
603 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI4_5GHZ); in rt2860_read_eeprom()
604 sc->tssi_5ghz[6] = val & 0xff; /* [+2] */ in rt2860_read_eeprom()
605 sc->tssi_5ghz[7] = val >> 8; /* [+3] */ in rt2860_read_eeprom()
606 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI5_5GHZ); in rt2860_read_eeprom()
607 sc->tssi_5ghz[8] = val & 0xff; /* [+4] */ in rt2860_read_eeprom()
608 sc->step_5ghz = val >> 8; in rt2860_read_eeprom()
611 "0x%02x 0x%02x step=%d\n", sc->tssi_5ghz[0], sc->tssi_5ghz[1], in rt2860_read_eeprom()
612 sc->tssi_5ghz[2], sc->tssi_5ghz[3], sc->tssi_5ghz[4], in rt2860_read_eeprom()
613 sc->tssi_5ghz[5], sc->tssi_5ghz[6], sc->tssi_5ghz[7], in rt2860_read_eeprom()
614 sc->tssi_5ghz[8], sc->step_5ghz); in rt2860_read_eeprom()
616 if (sc->tssi_5ghz[4] == 0xff) in rt2860_read_eeprom()
617 sc->calib_5ghz = 0; in rt2860_read_eeprom()
620 val = rt2860_eeprom_read(sc, RT2860_EEPROM_RSSI1_2GHZ); in rt2860_read_eeprom()
621 sc->rssi_2ghz[0] = val & 0xff; /* Ant A */ in rt2860_read_eeprom()
622 sc->rssi_2ghz[1] = val >> 8; /* Ant B */ in rt2860_read_eeprom()
623 val = rt2860_eeprom_read(sc, RT2860_EEPROM_RSSI2_2GHZ); in rt2860_read_eeprom()
624 sc->rssi_2ghz[2] = val & 0xff; /* Ant C */ in rt2860_read_eeprom()
625 sc->lna[2] = val >> 8; /* channel group 2 */ in rt2860_read_eeprom()
627 val = rt2860_eeprom_read(sc, RT2860_EEPROM_RSSI1_5GHZ); in rt2860_read_eeprom()
628 sc->rssi_5ghz[0] = val & 0xff; /* Ant A */ in rt2860_read_eeprom()
629 sc->rssi_5ghz[1] = val >> 8; /* Ant B */ in rt2860_read_eeprom()
630 val = rt2860_eeprom_read(sc, RT2860_EEPROM_RSSI2_5GHZ); in rt2860_read_eeprom()
631 sc->rssi_5ghz[2] = val & 0xff; /* Ant C */ in rt2860_read_eeprom()
632 sc->lna[3] = val >> 8; /* channel group 3 */ in rt2860_read_eeprom()
634 val = rt2860_eeprom_read(sc, RT2860_EEPROM_LNA); in rt2860_read_eeprom()
635 sc->lna[0] = val & 0xff; /* channel group 0 */ in rt2860_read_eeprom()
636 sc->lna[1] = val >> 8; /* channel group 1 */ in rt2860_read_eeprom()
639 if (sc->lna[2] == 0 || sc->lna[2] == 0xff) { in rt2860_read_eeprom()
642 sc->lna[2] = sc->lna[1]; in rt2860_read_eeprom()
644 if (sc->lna[3] == 0 || sc->lna[3] == 0xff) { in rt2860_read_eeprom()
647 sc->lna[3] = sc->lna[1]; in rt2860_read_eeprom()
652 if (sc->rssi_2ghz[ant] < -10 || sc->rssi_2ghz[ant] > 10) { in rt2860_read_eeprom()
656 ant + 1, sc->rssi_2ghz[ant]); in rt2860_read_eeprom()
657 sc->rssi_2ghz[ant] = 0; in rt2860_read_eeprom()
659 if (sc->rssi_5ghz[ant] < -10 || sc->rssi_5ghz[ant] > 10) { in rt2860_read_eeprom()
663 ant + 1, sc->rssi_5ghz[ant]); in rt2860_read_eeprom()
664 sc->rssi_5ghz[ant] = 0; in rt2860_read_eeprom()
755 rt2860_alloc_tx_ring(struct rt2860_softc *sc, struct rt2860_tx_ring *ring) in rt2860_alloc_tx_ring() argument
761 err = rt2860_alloc_dma_mem(sc->sc_dev, &rt2860_dma_attr, size, in rt2860_alloc_tx_ring()
786 rt2860_reset_tx_ring(struct rt2860_softc *sc, struct rt2860_tx_ring *ring) in rt2860_reset_tx_ring() argument
798 if (!(sc->sc_flags & RT2860_F_QUIESCE)) in rt2860_reset_tx_ring()
806 SLIST_INSERT_HEAD(&sc->data_pool, data, next); in rt2860_reset_tx_ring()
811 if (!(sc->sc_flags & RT2860_F_QUIESCE)) in rt2860_reset_tx_ring()
820 rt2860_free_tx_ring(struct rt2860_softc *sc, struct rt2860_tx_ring *ring) in rt2860_free_tx_ring() argument
828 rt2860_alloc_rx_ring(struct rt2860_softc *sc, struct rt2860_rx_ring *ring) in rt2860_alloc_rx_ring() argument
836 err = rt2860_alloc_dma_mem(sc->sc_dev, &rt2860_dma_attr, size, in rt2860_alloc_rx_ring()
859 (void) rt2860_alloc_dma_mem(sc->sc_dev, &rt2860_dma_attr, in rt2860_alloc_rx_ring()
860 sc->sc_dmabuf_size, in rt2860_alloc_rx_ring()
866 rxd->sdl0 = LE_16(sc->sc_dmabuf_size); in rt2860_alloc_rx_ring()
881 rt2860_reset_rx_ring(struct rt2860_softc *sc, struct rt2860_rx_ring *ring) in rt2860_reset_rx_ring() argument
895 rt2860_free_rx_ring(struct rt2860_softc *sc, struct rt2860_rx_ring *ring) in rt2860_free_rx_ring() argument
912 rt2860_alloc_tx_pool(struct rt2860_softc *sc) in rt2860_alloc_tx_pool() argument
920 SLIST_INIT(&sc->data_pool); in rt2860_alloc_tx_pool()
922 err = rt2860_alloc_dma_mem(sc->sc_dev, &rt2860_dma_attr, size, in rt2860_alloc_tx_pool()
925 &sc->txpool_dma); in rt2860_alloc_tx_pool()
932 sc->txwi = (struct rt2860_txwi *)sc->txpool_dma.mem_va; in rt2860_alloc_tx_pool()
933 (void) bzero(sc->txwi, size); in rt2860_alloc_tx_pool()
934 RT2860_DMA_SYNC(sc->txpool_dma, DDI_DMA_SYNC_FORDEV); in rt2860_alloc_tx_pool()
937 data = &sc->data[i]; in rt2860_alloc_tx_pool()
939 err = rt2860_alloc_dma_mem(sc->sc_dev, &rt2860_dma_attr, in rt2860_alloc_tx_pool()
940 sc->sc_dmabuf_size, in rt2860_alloc_tx_pool()
950 data->txwi = &sc->txwi[i]; in rt2860_alloc_tx_pool()
951 data->paddr = sc->txpool_dma.cookie.dmac_address + in rt2860_alloc_tx_pool()
954 SLIST_INSERT_HEAD(&sc->data_pool, data, next); in rt2860_alloc_tx_pool()
958 rt2860_free_dma_mem(&sc->txpool_dma); in rt2860_alloc_tx_pool()
964 rt2860_free_tx_pool(struct rt2860_softc *sc) in rt2860_free_tx_pool() argument
969 if (sc->txwi != NULL) { in rt2860_free_tx_pool()
970 rt2860_free_dma_mem(&sc->txpool_dma); in rt2860_free_tx_pool()
974 data = &sc->data[i]; in rt2860_free_tx_pool()
1082 struct rt2860_softc *sc = (struct rt2860_softc *)ic; in rt2860_send() local
1098 mutex_enter(&sc->sc_txlock); in rt2860_send()
1099 if (RT2860_IS_SUSPEND(sc)) { in rt2860_send()
1106 qid = sc->mgtqid; in rt2860_send()
1109 ring = &sc->txq[qid]; in rt2860_send()
1111 if (SLIST_EMPTY(&sc->data_pool) || (ring->queued > 15)) { in rt2860_send()
1112 sc->sc_need_sched = 1; in rt2860_send()
1113 sc->sc_tx_nobuf++; in rt2860_send()
1119 data = SLIST_FIRST(&sc->data_pool); in rt2860_send()
1140 sc->sc_tx_err++; in rt2860_send()
1152 sc->sc_tx_err++; in rt2860_send()
1215 ic->ic_flags) + sc->sifs; in rt2860_send()
1237 SLIST_REMOVE_HEAD(&sc->data_pool, next); in rt2860_send()
1241 (void) ddi_dma_sync(sc->txpool_dma.dma_hdl, in rt2860_send()
1242 _PTRDIFF(txwi, sc->txwi), in rt2860_send()
1256 RT2860_WRITE(sc, RT2860_TX_CTX_IDX(qid), ring->cur); in rt2860_send()
1258 sc->sc_tx_timer = 5; in rt2860_send()
1271 mutex_exit(&sc->sc_txlock); in rt2860_send()
1282 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_next_scan() local
1283 struct ieee80211com *ic = &sc->sc_ic; in rt2860_next_scan()
1290 rt2860_updateslot(struct rt2860_softc *sc) in rt2860_updateslot() argument
1292 struct ieee80211com *ic = &sc->sc_ic; in rt2860_updateslot()
1295 tmp = RT2860_READ(sc, RT2860_BKOFF_SLOT_CFG); in rt2860_updateslot()
1298 RT2860_WRITE(sc, RT2860_BKOFF_SLOT_CFG, tmp); in rt2860_updateslot()
1304 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_iter_func() local
1308 rt2860_amrr_choose(&sc->amrr, ni, &sc->amn[wcid]); in rt2860_iter_func()
1314 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_updatestats() local
1315 struct ieee80211com *ic = &sc->sc_ic; in rt2860_updatestats()
1318 rt2860_iter_func(sc, ic->ic_bss); in rt2860_updatestats()
1322 sc->sc_rssadapt_id = timeout(rt2860_updatestats, (void *)sc, in rt2860_updatestats()
1327 rt2860_enable_mrr(struct rt2860_softc *sc) in rt2860_enable_mrr() argument
1331 RT2860_WRITE(sc, RT2860_LG_FBK_CFG0, in rt2860_enable_mrr()
1341 RT2860_WRITE(sc, RT2860_LG_FBK_CFG1, in rt2860_enable_mrr()
1351 rt2860_set_txpreamble(struct rt2860_softc *sc) in rt2860_set_txpreamble() argument
1355 tmp = RT2860_READ(sc, RT2860_AUTO_RSP_CFG); in rt2860_set_txpreamble()
1357 if (sc->sc_ic.ic_flags & IEEE80211_F_SHPREAMBLE) in rt2860_set_txpreamble()
1359 RT2860_WRITE(sc, RT2860_AUTO_RSP_CFG, tmp); in rt2860_set_txpreamble()
1363 rt2860_set_bssid(struct rt2860_softc *sc, const uint8_t *bssid) in rt2860_set_bssid() argument
1365 RT2860_WRITE(sc, RT2860_MAC_BSSID_DW0, in rt2860_set_bssid()
1367 RT2860_WRITE(sc, RT2860_MAC_BSSID_DW1, in rt2860_set_bssid()
1372 rt2860_set_basicrates(struct rt2860_softc *sc) in rt2860_set_basicrates() argument
1374 struct ieee80211com *ic = &sc->sc_ic; in rt2860_set_basicrates()
1378 RT2860_WRITE(sc, RT2860_LEGACY_BASIC_RATE, 0x003); in rt2860_set_basicrates()
1380 RT2860_WRITE(sc, RT2860_LEGACY_BASIC_RATE, 0x150); in rt2860_set_basicrates()
1382 RT2860_WRITE(sc, RT2860_LEGACY_BASIC_RATE, 0x15f); in rt2860_set_basicrates()
1465 struct rt2860_softc *sc = (struct rt2860_softc *)ic; in rt2860_newassoc() local
1478 rt2860_mem_write1(sc, off++, *fptr++); in rt2860_newassoc()
1480 rt2860_amrr_node_init(&sc->amrr, &sc->amn[wcid]); in rt2860_newassoc()
1499 rt2860_enable_tsf_sync(struct rt2860_softc *sc) in rt2860_enable_tsf_sync() argument
1501 struct ieee80211com *ic = &sc->sc_ic; in rt2860_enable_tsf_sync()
1504 tmp = RT2860_READ(sc, RT2860_BCN_TIME_CFG); in rt2860_enable_tsf_sync()
1517 RT2860_WRITE(sc, RT2860_BCN_TIME_CFG, tmp); in rt2860_enable_tsf_sync()
1523 struct rt2860_softc *sc = (struct rt2860_softc *)ic; in rt2860_newstate() local
1532 RT2860_GLOCK(sc); in rt2860_newstate()
1533 if (sc->sc_scan_id != 0) { in rt2860_newstate()
1534 (void) untimeout(sc->sc_scan_id); in rt2860_newstate()
1535 sc->sc_scan_id = 0; in rt2860_newstate()
1537 if (sc->sc_rssadapt_id != 0) { in rt2860_newstate()
1538 (void) untimeout(sc->sc_rssadapt_id); in rt2860_newstate()
1539 sc->sc_rssadapt_id = 0; in rt2860_newstate()
1543 rt2860_set_leds(sc, RT2860_LED_RADIO); in rt2860_newstate()
1550 tmp = RT2860_READ(sc, RT2860_BCN_TIME_CFG); in rt2860_newstate()
1551 RT2860_WRITE(sc, RT2860_BCN_TIME_CFG, in rt2860_newstate()
1558 rt2860_set_chan(sc, ic->ic_curchan); in rt2860_newstate()
1559 sc->sc_scan_id = timeout(rt2860_next_scan, (void *)sc, in rt2860_newstate()
1565 rt2860_set_chan(sc, ic->ic_curchan); in rt2860_newstate()
1569 rt2860_set_chan(sc, ic->ic_curchan); in rt2860_newstate()
1572 rt2860_updateslot(sc); in rt2860_newstate()
1573 rt2860_enable_mrr(sc); in rt2860_newstate()
1574 rt2860_set_txpreamble(sc); in rt2860_newstate()
1575 rt2860_set_basicrates(sc); in rt2860_newstate()
1576 rt2860_set_bssid(sc, ic->ic_bss->in_bssid); in rt2860_newstate()
1584 rt2860_enable_tsf_sync(sc); in rt2860_newstate()
1585 sc->sc_rssadapt_id = timeout(rt2860_updatestats, in rt2860_newstate()
1586 (void *)sc, drv_usectohz(500 * 1000)); in rt2860_newstate()
1590 rt2860_set_leds(sc, RT2860_LED_RADIO | in rt2860_newstate()
1596 RT2860_GUNLOCK(sc); in rt2860_newstate()
1598 err = sc->sc_newstate(ic, nstate, arg); in rt2860_newstate()
1607 rt2860_maxrssi_chain(struct rt2860_softc *sc, const struct rt2860_rxwi *rxwi) in rt2860_maxrssi_chain() argument
1611 if (sc->nrxchains > 1) in rt2860_maxrssi_chain()
1614 if (sc->nrxchains > 2) in rt2860_maxrssi_chain()
1622 rt2860_drain_stats_fifo(struct rt2860_softc *sc) in rt2860_drain_stats_fifo() argument
1629 while ((stat = RT2860_READ(sc, RT2860_TX_STAT_FIFO)) & RT2860_TXQ_VLD) { in rt2860_drain_stats_fifo()
1639 amn = &sc->amn[wcid]; in rt2860_drain_stats_fifo()
1659 rt2860_tx_intr(struct rt2860_softc *sc, int qid) in rt2860_tx_intr() argument
1661 struct rt2860_tx_ring *ring = &sc->txq[qid]; in rt2860_tx_intr()
1662 struct ieee80211com *ic = &sc->sc_ic; in rt2860_tx_intr()
1665 rt2860_drain_stats_fifo(sc); in rt2860_tx_intr()
1667 mutex_enter(&sc->sc_txlock); in rt2860_tx_intr()
1668 hw = RT2860_READ(sc, RT2860_TX_DTX_IDX(qid)); in rt2860_tx_intr()
1682 SLIST_INSERT_HEAD(&sc->data_pool, data, next); in rt2860_tx_intr()
1696 if (sc->sc_need_sched && in rt2860_tx_intr()
1698 sc->sc_need_sched = 0; in rt2860_tx_intr()
1702 sc->sc_tx_timer = 0; in rt2860_tx_intr()
1703 mutex_exit(&sc->sc_txlock); in rt2860_tx_intr()
1707 rt2860_rx_intr(struct rt2860_softc *sc) in rt2860_rx_intr() argument
1709 struct ieee80211com *ic = &sc->sc_ic; in rt2860_rx_intr()
1716 mutex_enter(&sc->sc_rxlock); in rt2860_rx_intr()
1718 struct rt2860_rx_data *data = &sc->rxq.data[sc->rxq.cur]; in rt2860_rx_intr()
1719 struct rt2860_rxd *rxd = &sc->rxq.rxd[sc->rxq.cur]; in rt2860_rx_intr()
1722 (void) ddi_dma_sync(sc->rxq.rxdesc_dma.dma_hdl, in rt2860_rx_intr()
1723 sc->rxq.cur * sizeof (struct rt2860_rxd), in rt2860_rx_intr()
1737 sc->sc_rx_err++; in rt2860_rx_intr()
1744 sc->sc_rx_err++; in rt2860_rx_intr()
1759 mp0 = allocb(sc->sc_dmabuf_size, BPRI_MED); in rt2860_rx_intr()
1763 sc->sc_rx_nobuf++; in rt2860_rx_intr()
1777 ant = rt2860_maxrssi_chain(sc, rxwi); in rt2860_rx_intr()
1789 (void) ddi_dma_sync(sc->rxq.rxdesc_dma.dma_hdl, in rt2860_rx_intr()
1790 sc->rxq.cur * sizeof (struct rt2860_rxd), in rt2860_rx_intr()
1794 sc->rxq.cur = (sc->rxq.cur + 1) % RT2860_RX_RING_COUNT; in rt2860_rx_intr()
1796 mutex_exit(&sc->sc_rxlock); in rt2860_rx_intr()
1799 RT2860_WRITE(sc, RT2860_RX_CALC_IDX, in rt2860_rx_intr()
1800 (sc->rxq.cur - 1) % RT2860_RX_RING_COUNT); in rt2860_rx_intr()
1806 struct rt2860_softc *sc = (struct rt2860_softc *)data; in rt2860_softintr() local
1812 RT2860_GLOCK(sc); in rt2860_softintr()
1813 if (sc->sc_rx_pend) { in rt2860_softintr()
1814 sc->sc_rx_pend = 0; in rt2860_softintr()
1815 RT2860_GUNLOCK(sc); in rt2860_softintr()
1816 rt2860_rx_intr(sc); in rt2860_softintr()
1819 RT2860_GUNLOCK(sc); in rt2860_softintr()
1827 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_intr() local
1830 RT2860_GLOCK(sc); in rt2860_intr()
1832 if ((!RT2860_IS_RUNNING(sc)) || RT2860_IS_SUSPEND(sc)) { in rt2860_intr()
1837 RT2860_GUNLOCK(sc); in rt2860_intr()
1841 r = RT2860_READ(sc, RT2860_INT_STATUS); in rt2860_intr()
1843 RT2860_GUNLOCK(sc); in rt2860_intr()
1847 RT2860_GUNLOCK(sc); in rt2860_intr()
1852 RT2860_WRITE(sc, RT2860_INT_STATUS, r); in rt2860_intr()
1865 rt2860_drain_stats_fifo(sc); in rt2860_intr()
1871 rt2860_tx_intr(sc, 5); in rt2860_intr()
1877 sc->sc_rx_pend = 1; in rt2860_intr()
1878 ddi_trigger_softintr(sc->sc_softintr_hdl); in rt2860_intr()
1884 rt2860_tx_intr(sc, 4); in rt2860_intr()
1890 rt2860_tx_intr(sc, 3); in rt2860_intr()
1896 rt2860_tx_intr(sc, 2); in rt2860_intr()
1902 rt2860_tx_intr(sc, 1); in rt2860_intr()
1908 rt2860_tx_intr(sc, 0); in rt2860_intr()
1914 struct ieee80211com *ic = &sc->sc_ic; in rt2860_intr()
1916 if ((sc->sc_ic_flags ^ ic->ic_flags) & IEEE80211_F_USEPROT) { in rt2860_intr()
1918 sc->sc_ic_flags = ic->ic_flags; in rt2860_intr()
1926 RT2860_GUNLOCK(sc); in rt2860_intr()
1932 rt2860_set_region_4(struct rt2860_softc *sc, in rt2860_set_region_4() argument
1936 ddi_put32((sc)->sc_io_handle, in rt2860_set_region_4()
1937 (uint32_t *)((uintptr_t)(sc)->sc_io_base + addr), data); in rt2860_set_region_4()
1941 rt2860_load_microcode(struct rt2860_softc *sc) in rt2860_load_microcode() argument
1954 RT2860_WRITE(sc, RT2860_SYS_CTRL, RT2860_HST_PM_SEL); in rt2860_load_microcode()
1959 rt2860_mem_write1(sc, off++, *fptr++); in rt2860_load_microcode()
1962 RT2860_WRITE(sc, RT2860_SYS_CTRL, 0); in rt2860_load_microcode()
1963 RT2860_WRITE(sc, RT2860_SYS_CTRL, RT2860_MCU_RESET); in rt2860_load_microcode()
1965 RT2860_WRITE(sc, RT2860_H2M_BBPAGENT, 0); in rt2860_load_microcode()
1966 RT2860_WRITE(sc, RT2860_H2M_MAILBOX, 0); in rt2860_load_microcode()
1970 if (RT2860_READ(sc, RT2860_SYS_CTRL) & RT2860_MCU_READY) in rt2860_load_microcode()
1984 rt2860_set_macaddr(struct rt2860_softc *sc, const uint8_t *addr) in rt2860_set_macaddr() argument
1986 RT2860_WRITE(sc, RT2860_MAC_ADDR_DW0, in rt2860_set_macaddr()
1988 RT2860_WRITE(sc, RT2860_MAC_ADDR_DW1, in rt2860_set_macaddr()
1996 rt2860_mcu_cmd(struct rt2860_softc *sc, uint8_t cmd, uint16_t arg) in rt2860_mcu_cmd() argument
2001 if (!(RT2860_READ(sc, RT2860_H2M_MAILBOX) & RT2860_H2M_BUSY)) in rt2860_mcu_cmd()
2008 RT2860_WRITE(sc, RT2860_H2M_MAILBOX, in rt2860_mcu_cmd()
2010 RT2860_WRITE(sc, RT2860_HOST_CMD, cmd); in rt2860_mcu_cmd()
2021 rt2860_mcu_bbp_read(struct rt2860_softc *sc, uint8_t reg) in rt2860_mcu_bbp_read() argument
2027 if (!(RT2860_READ(sc, in rt2860_mcu_bbp_read()
2038 RT2860_WRITE(sc, RT2860_H2M_BBPAGENT, RT2860_BBP_RW_PARALLEL | in rt2860_mcu_bbp_read()
2041 (void) rt2860_mcu_cmd(sc, RT2860_MCU_CMD_BBP, 0); in rt2860_mcu_bbp_read()
2045 val = RT2860_READ(sc, RT2860_H2M_BBPAGENT); in rt2860_mcu_bbp_read()
2057 rt2860_mcu_bbp_write(struct rt2860_softc *sc, uint8_t reg, uint8_t val) in rt2860_mcu_bbp_write() argument
2062 if (!(RT2860_READ(sc, in rt2860_mcu_bbp_write()
2073 RT2860_WRITE(sc, RT2860_H2M_BBPAGENT, RT2860_BBP_RW_PARALLEL | in rt2860_mcu_bbp_write()
2076 (void) rt2860_mcu_cmd(sc, RT2860_MCU_CMD_BBP, 0); in rt2860_mcu_bbp_write()
2081 rt2860_bbp_init(struct rt2860_softc *sc) in rt2860_bbp_init() argument
2087 uint8_t bbp0 = rt2860_mcu_bbp_read(sc, 0); in rt2860_bbp_init()
2099 rt2860_mcu_bbp_write(sc, rt2860_def_bbp[i].reg, in rt2860_bbp_init()
2104 if (sc->mac_rev == 0x28600100) { in rt2860_bbp_init()
2105 rt2860_mcu_bbp_write(sc, 69, 0x16); in rt2860_bbp_init()
2106 rt2860_mcu_bbp_write(sc, 73, 0x12); in rt2860_bbp_init()
2113 rt2860_rf_write(struct rt2860_softc *sc, uint8_t reg, uint32_t val) in rt2860_rf_write() argument
2119 if (!(RT2860_READ(sc, RT2860_RF_CSR_CFG0) & RT2860_RF_REG_CTRL)) in rt2860_rf_write()
2132 RT2860_WRITE(sc, RT2860_RF_CSR_CFG0, tmp); in rt2860_rf_write()
2136 rt2860_select_chan_group(struct rt2860_softc *sc, int group) in rt2860_select_chan_group() argument
2140 rt2860_mcu_bbp_write(sc, 62, 0x37 - sc->lna[group]); in rt2860_select_chan_group()
2141 rt2860_mcu_bbp_write(sc, 63, 0x37 - sc->lna[group]); in rt2860_select_chan_group()
2142 rt2860_mcu_bbp_write(sc, 64, 0x37 - sc->lna[group]); in rt2860_select_chan_group()
2143 rt2860_mcu_bbp_write(sc, 82, (group == 0) ? 0x62 : 0xf2); in rt2860_select_chan_group()
2145 tmp = RT2860_READ(sc, RT2860_TX_BAND_CFG); in rt2860_select_chan_group()
2148 RT2860_WRITE(sc, RT2860_TX_BAND_CFG, tmp); in rt2860_select_chan_group()
2154 if (sc->ntxchains > 1) in rt2860_select_chan_group()
2156 if (sc->nrxchains > 1) in rt2860_select_chan_group()
2160 if (sc->ntxchains > 1) in rt2860_select_chan_group()
2162 if (sc->nrxchains > 1) in rt2860_select_chan_group()
2165 RT2860_WRITE(sc, RT2860_TX_PIN_CFG, tmp); in rt2860_select_chan_group()
2167 rt2860_mcu_bbp_write(sc, 66, 0x2e + sc->lna[group]); in rt2860_select_chan_group()
2170 rt2860_set_chan(struct rt2860_softc *sc, struct ieee80211_channel *c) in rt2860_set_chan() argument
2172 struct ieee80211com *ic = &sc->sc_ic; in rt2860_set_chan()
2189 if (sc->ntxchains == 1) in rt2860_set_chan()
2191 if (sc->nrxchains == 1) in rt2860_set_chan()
2193 else if (sc->nrxchains == 2) in rt2860_set_chan()
2197 txpow1 = sc->txpow1[i]; in rt2860_set_chan()
2198 txpow2 = sc->txpow2[i]; in rt2860_set_chan()
2204 r4 = rfprog[i].r4 | sc->freq << 13 | txpow2 << 4; in rt2860_set_chan()
2206 rt2860_rf_write(sc, RAL_RF1, rfprog[i].r1); in rt2860_set_chan()
2207 rt2860_rf_write(sc, RAL_RF2, r2); in rt2860_set_chan()
2208 rt2860_rf_write(sc, RAL_RF3, r3); in rt2860_set_chan()
2209 rt2860_rf_write(sc, RAL_RF4, r4); in rt2860_set_chan()
2213 rt2860_rf_write(sc, RAL_RF1, rfprog[i].r1); in rt2860_set_chan()
2214 rt2860_rf_write(sc, RAL_RF2, r2); in rt2860_set_chan()
2215 rt2860_rf_write(sc, RAL_RF3, r3 | 1); in rt2860_set_chan()
2216 rt2860_rf_write(sc, RAL_RF4, r4); in rt2860_set_chan()
2220 rt2860_rf_write(sc, RAL_RF1, rfprog[i].r1); in rt2860_set_chan()
2221 rt2860_rf_write(sc, RAL_RF2, r2); in rt2860_set_chan()
2222 rt2860_rf_write(sc, RAL_RF3, r3); in rt2860_set_chan()
2223 rt2860_rf_write(sc, RAL_RF4, r4); in rt2860_set_chan()
2226 sc->sifs = IEEE80211_IS_CHAN_5GHZ(c) ? 16 : 10; in rt2860_set_chan()
2239 rt2860_select_chan_group(sc, group); in rt2860_set_chan()
2247 struct rt2860_softc *sc = (struct rt2860_softc *)ic; in rt2860_updateprot() local
2255 RT2860_WRITE(sc, RT2860_CCK_PROT_CFG, tmp); in rt2860_updateprot()
2263 RT2860_WRITE(sc, RT2860_OFDM_PROT_CFG, tmp); in rt2860_updateprot()
2267 rt2860_set_leds(struct rt2860_softc *sc, uint16_t which) in rt2860_set_leds() argument
2269 (void) rt2860_mcu_cmd(sc, RT2860_MCU_CMD_LEDS, in rt2860_set_leds()
2270 which | (sc->leds & 0x7f)); in rt2860_set_leds()
2274 rt2860_init(struct rt2860_softc *sc) in rt2860_init() argument
2282 ic = &sc->sc_ic; in rt2860_init()
2284 rt2860_stop(sc); in rt2860_init()
2285 tmp = RT2860_READ(sc, RT2860_WPDMA_GLO_CFG); in rt2860_init()
2287 RT2860_WRITE(sc, RT2860_WPDMA_GLO_CFG, tmp | RT2860_TX_WB_DDONE); in rt2860_init()
2289 RT2860_WRITE(sc, RT2860_WPDMA_RST_IDX, 0xffffffff); in rt2860_init()
2292 RT2860_WRITE(sc, RT2860_SYS_CTRL, 0xe1f); in rt2860_init()
2293 RT2860_WRITE(sc, RT2860_SYS_CTRL, 0xe00); in rt2860_init()
2295 if (!(sc->sc_flags & RT2860_FWLOADED)) { in rt2860_init()
2296 if ((err = rt2860_load_microcode(sc)) != 0) { in rt2860_init()
2299 rt2860_stop(sc); in rt2860_init()
2302 RT2860_GLOCK(sc); in rt2860_init()
2303 sc->sc_flags |= RT2860_FWLOADED; in rt2860_init()
2304 RT2860_GUNLOCK(sc); in rt2860_init()
2307 rt2860_set_macaddr(sc, ic->ic_macaddr); in rt2860_init()
2311 if (sc->txpow20mhz[ridx] == 0xffffffff) in rt2860_init()
2313 RT2860_WRITE(sc, RT2860_TX_PWR_CFG(ridx), sc->txpow20mhz[ridx]); in rt2860_init()
2317 tmp = RT2860_READ(sc, RT2860_WPDMA_GLO_CFG); in rt2860_init()
2325 rt2860_stop(sc); in rt2860_init()
2329 RT2860_WRITE(sc, RT2860_WPDMA_GLO_CFG, tmp | RT2860_TX_WB_DDONE); in rt2860_init()
2332 RT2860_WRITE(sc, RT2860_WPDMA_RST_IDX, 0x1003f); in rt2860_init()
2335 RT2860_WRITE(sc, RT2860_SYS_CTRL, 0xe1f); in rt2860_init()
2336 RT2860_WRITE(sc, RT2860_SYS_CTRL, 0xe00); in rt2860_init()
2338 RT2860_WRITE(sc, RT2860_MAC_SYS_CTRL, in rt2860_init()
2340 RT2860_WRITE(sc, RT2860_MAC_SYS_CTRL, 0); in rt2860_init()
2343 RT2860_WRITE(sc, rt2860_def_mac[i].reg, rt2860_def_mac[i].val); in rt2860_init()
2347 if (!(RT2860_READ(sc, RT2860_MAC_STATUS_REG) & in rt2860_init()
2355 rt2860_stop(sc); in rt2860_init()
2360 RT2860_WRITE(sc, RT2860_H2M_BBPAGENT, 0); in rt2860_init()
2361 RT2860_WRITE(sc, RT2860_H2M_MAILBOX, 0); in rt2860_init()
2363 if ((err = rt2860_bbp_init(sc)) != 0) { in rt2860_init()
2364 rt2860_stop(sc); in rt2860_init()
2370 RT2860_WRITE(sc, RT2860_TX_BASE_PTR(qid), sc->txq[qid].paddr); in rt2860_init()
2371 RT2860_WRITE(sc, RT2860_TX_MAX_CNT(qid), RT2860_TX_RING_COUNT); in rt2860_init()
2372 RT2860_WRITE(sc, RT2860_TX_CTX_IDX(qid), 0); in rt2860_init()
2376 RT2860_WRITE(sc, RT2860_RX_BASE_PTR, sc->rxq.paddr); in rt2860_init()
2377 RT2860_WRITE(sc, RT2860_RX_MAX_CNT, RT2860_RX_RING_COUNT); in rt2860_init()
2378 RT2860_WRITE(sc, RT2860_RX_CALC_IDX, RT2860_RX_RING_COUNT - 1); in rt2860_init()
2381 RT2860_WRITE(sc, RT2860_MAX_LEN_CFG, 1 << 12 | in rt2860_init()
2382 (sc->sc_dmabuf_size - sizeof (struct rt2860_rxwi) - 2)); in rt2860_init()
2385 tmp = RT2860_READ(sc, RT2860_WPDMA_GLO_CFG); in rt2860_init()
2393 rt2860_stop(sc); in rt2860_init()
2397 RT2860_WRITE(sc, RT2860_WPDMA_GLO_CFG, tmp | RT2860_TX_WB_DDONE); in rt2860_init()
2400 RT2860_WRITE(sc, RT2860_DELAY_INT_CFG, 0); in rt2860_init()
2404 if (sc->bbp[i].reg == 0 || sc->bbp[i].reg == 0xff) in rt2860_init()
2406 rt2860_mcu_bbp_write(sc, sc->bbp[i].reg, sc->bbp[i].val); in rt2860_init()
2410 (void) rt2860_mcu_cmd(sc, RT2860_MCU_CMD_LED1, sc->led[0]); in rt2860_init()
2411 (void) rt2860_mcu_cmd(sc, RT2860_MCU_CMD_LED2, sc->led[1]); in rt2860_init()
2412 (void) rt2860_mcu_cmd(sc, RT2860_MCU_CMD_LED3, sc->led[2]); in rt2860_init()
2415 bbp3 = rt2860_mcu_bbp_read(sc, 3); in rt2860_init()
2417 if (sc->nrxchains == 2) in rt2860_init()
2419 else if (sc->nrxchains == 3) in rt2860_init()
2421 rt2860_mcu_bbp_write(sc, 3, bbp3); in rt2860_init()
2424 bbp1 = rt2860_mcu_bbp_read(sc, 1); in rt2860_init()
2425 if (sc->ntxchains == 1) in rt2860_init()
2427 rt2860_mcu_bbp_write(sc, 1, bbp1); in rt2860_init()
2430 rt2860_set_chan(sc, ic->ic_curchan); in rt2860_init()
2433 (void) rt2860_mcu_cmd(sc, RT2860_MCU_CMD_BOOT, 0); in rt2860_init()
2436 tmp = RT2860_READ(sc, RT2860_TX_RTS_CFG); in rt2860_init()
2441 sc->sc_ic_flags = ic->ic_flags; in rt2860_init()
2445 RT2860_WRITE(sc, RT2860_MAC_SYS_CTRL, RT2860_MAC_TX_EN); in rt2860_init()
2447 tmp = RT2860_READ(sc, RT2860_WPDMA_GLO_CFG); in rt2860_init()
2455 rt2860_stop(sc); in rt2860_init()
2463 RT2860_WRITE(sc, RT2860_WPDMA_GLO_CFG, tmp); in rt2860_init()
2466 rt2860_set_leds(sc, RT2860_LED_RADIO); in rt2860_init()
2478 RT2860_WRITE(sc, RT2860_RX_FILTR_CFG, tmp); in rt2860_init()
2480 RT2860_WRITE(sc, RT2860_MAC_SYS_CTRL, in rt2860_init()
2484 RT2860_WRITE(sc, RT2860_INT_STATUS, 0xffffffff); in rt2860_init()
2486 RT2860_WRITE(sc, RT2860_INT_MASK, 0x3fffc); in rt2860_init()
2488 if (sc->sc_flags & RT2860_ADVANCED_PS) in rt2860_init()
2489 (void) rt2860_mcu_cmd(sc, RT2860_MCU_CMD_PSLEVEL, sc->pslevel); in rt2860_init()
2497 struct rt2860_softc *sc; in rt2860_quiesce() local
2499 sc = ddi_get_soft_state(rt2860_soft_state_p, ddi_get_instance(dip)); in rt2860_quiesce()
2500 if (sc == NULL) in rt2860_quiesce()
2510 sc->sc_flags |= RT2860_F_QUIESCE; in rt2860_quiesce()
2515 rt2860_stop(sc); in rt2860_quiesce()
2520 rt2860_stop(struct rt2860_softc *sc) in rt2860_stop() argument
2526 if (!(sc->sc_flags & RT2860_F_QUIESCE)) in rt2860_stop()
2527 RT2860_GLOCK(sc); in rt2860_stop()
2528 if (sc->sc_flags == RT2860_F_RUNNING) in rt2860_stop()
2529 rt2860_set_leds(sc, 0); /* turn all LEDs off */ in rt2860_stop()
2530 sc->sc_tx_timer = 0; in rt2860_stop()
2532 if (!(sc->sc_flags & RT2860_F_QUIESCE)) in rt2860_stop()
2533 RT2860_GUNLOCK(sc); in rt2860_stop()
2536 rt2860_set_region_4(sc, RT2860_WCID_ENTRY(0), 0, 512); in rt2860_stop()
2538 rt2860_set_region_4(sc, RT2860_PKEY(0), 0, 2048); in rt2860_stop()
2540 rt2860_set_region_4(sc, RT2860_IVEIV(0), 0, 512); in rt2860_stop()
2542 rt2860_set_region_4(sc, RT2860_WCID_ATTR(0), 0, 256); in rt2860_stop()
2544 rt2860_set_region_4(sc, RT2860_SKEY(0, 0), 0, 8 * 32); in rt2860_stop()
2546 rt2860_set_region_4(sc, RT2860_SKEY_MODE_0_7, 0, 4); in rt2860_stop()
2549 RT2860_WRITE(sc, RT2860_INT_MASK, 0); in rt2860_stop()
2552 tmp = RT2860_READ(sc, RT2860_MAC_SYS_CTRL); in rt2860_stop()
2554 RT2860_WRITE(sc, RT2860_MAC_SYS_CTRL, tmp); in rt2860_stop()
2557 RT2860_WRITE(sc, RT2860_MAC_SYS_CTRL, in rt2860_stop()
2559 RT2860_WRITE(sc, RT2860_MAC_SYS_CTRL, 0); in rt2860_stop()
2563 rt2860_reset_tx_ring(sc, &sc->txq[qid]); in rt2860_stop()
2564 rt2860_reset_rx_ring(sc, &sc->rxq); in rt2860_stop()
2567 if (!(sc->sc_flags & RT2860_F_QUIESCE)) in rt2860_stop()
2568 RT2860_GLOCK(sc); in rt2860_stop()
2569 sc->sc_flags &= ~RT2860_UPD_BEACON; in rt2860_stop()
2571 if (!(sc->sc_flags & RT2860_F_QUIESCE)) in rt2860_stop()
2572 RT2860_GUNLOCK(sc); in rt2860_stop()
2578 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_m_start() local
2579 struct ieee80211com *ic = &sc->sc_ic; in rt2860_m_start()
2582 err = rt2860_init(sc); in rt2860_m_start()
2591 RT2860_GLOCK(sc); in rt2860_m_start()
2592 sc->sc_flags |= RT2860_F_RUNNING; in rt2860_m_start()
2593 RT2860_GUNLOCK(sc); in rt2860_m_start()
2597 rt2860_stop(sc); in rt2860_m_start()
2604 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_m_stop() local
2606 (void) rt2860_stop(sc); in rt2860_m_stop()
2608 ieee80211_new_state(&sc->sc_ic, IEEE80211_S_INIT, -1); in rt2860_m_stop()
2610 RT2860_GLOCK(sc); in rt2860_m_stop()
2611 sc->sc_flags &= ~RT2860_F_RUNNING; in rt2860_m_stop()
2612 RT2860_GUNLOCK(sc); in rt2860_m_stop()
2618 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_m_ioctl() local
2619 struct ieee80211com *ic = &sc->sc_ic; in rt2860_m_ioctl()
2623 RT2860_GLOCK(sc); in rt2860_m_ioctl()
2626 if (RT2860_IS_RUNNING(sc)) { in rt2860_m_ioctl()
2627 RT2860_GUNLOCK(sc); in rt2860_m_ioctl()
2628 (void) rt2860_init(sc); in rt2860_m_ioctl()
2631 RT2860_GLOCK(sc); in rt2860_m_ioctl()
2635 RT2860_GUNLOCK(sc); in rt2860_m_ioctl()
2645 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_m_getprop() local
2648 err = ieee80211_getprop(&sc->sc_ic, pr_name, wldp_pr_num, in rt2860_m_getprop()
2658 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_m_propinfo() local
2660 ieee80211_propinfo(&sc->sc_ic, pr_name, wldp_pr_num, prh); in rt2860_m_propinfo()
2667 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_m_setprop() local
2668 ieee80211com_t *ic = &sc->sc_ic; in rt2860_m_setprop()
2673 RT2860_GLOCK(sc); in rt2860_m_setprop()
2676 if (RT2860_IS_RUNNING(sc)) { in rt2860_m_setprop()
2677 RT2860_GUNLOCK(sc); in rt2860_m_setprop()
2678 (void) rt2860_init(sc); in rt2860_m_setprop()
2681 RT2860_GLOCK(sc); in rt2860_m_setprop()
2686 RT2860_GUNLOCK(sc); in rt2860_m_setprop()
2693 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_m_tx() local
2694 struct ieee80211com *ic = &sc->sc_ic; in rt2860_m_tx()
2697 if (RT2860_IS_SUSPEND(sc)) { in rt2860_m_tx()
2751 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_m_stat() local
2752 ieee80211com_t *ic = &sc->sc_ic; in rt2860_m_stat()
2756 RT2860_GLOCK(sc); in rt2860_m_stat()
2764 *val = sc->sc_tx_nobuf; in rt2860_m_stat()
2767 *val = sc->sc_rx_nobuf; in rt2860_m_stat()
2770 *val = sc->sc_rx_err; in rt2860_m_stat()
2786 *val = sc->sc_tx_err; in rt2860_m_stat()
2789 *val = sc->sc_tx_retries; in rt2860_m_stat()
2801 RT2860_GUNLOCK(sc); in rt2860_m_stat()
2804 RT2860_GUNLOCK(sc); in rt2860_m_stat()
2807 RT2860_GUNLOCK(sc); in rt2860_m_stat()
2815 struct rt2860_softc *sc; in rt2860_attach() local
2828 sc = ddi_get_soft_state(rt2860_soft_state_p, in rt2860_attach()
2830 ASSERT(sc != NULL); in rt2860_attach()
2831 RT2860_GLOCK(sc); in rt2860_attach()
2832 sc->sc_flags &= ~RT2860_F_SUSPEND; in rt2860_attach()
2833 RT2860_GUNLOCK(sc); in rt2860_attach()
2834 if (RT2860_IS_RUNNING(sc)) in rt2860_attach()
2835 (void) rt2860_init(sc); in rt2860_attach()
2852 sc = ddi_get_soft_state(rt2860_soft_state_p, instance); in rt2860_attach()
2853 ic = (ieee80211com_t *)&sc->sc_ic; in rt2860_attach()
2854 sc->sc_dev = devinfo; in rt2860_attach()
2857 err = ddi_regs_map_setup(devinfo, 0, &sc->sc_cfg_base, 0, 0, in rt2860_attach()
2858 &rwn_csr_accattr, &sc->sc_cfg_handle); in rt2860_attach()
2865 cachelsz = ddi_get8(sc->sc_cfg_handle, in rt2860_attach()
2866 (uint8_t *)(sc->sc_cfg_base + PCI_CONF_CACHE_LINESZ)); in rt2860_attach()
2869 sc->sc_cachelsz = cachelsz << 2; in rt2860_attach()
2870 sc->sc_dmabuf_size = roundup(IEEE80211_MAX_LEN, sc->sc_cachelsz); in rt2860_attach()
2872 vendor_id = ddi_get16(sc->sc_cfg_handle, in rt2860_attach()
2873 (uint16_t *)((uintptr_t)(sc->sc_cfg_base) + PCI_CONF_VENID)); in rt2860_attach()
2874 device_id = ddi_get16(sc->sc_cfg_handle, in rt2860_attach()
2875 (uint16_t *)((uintptr_t)(sc->sc_cfg_base) + PCI_CONF_DEVID)); in rt2860_attach()
2885 ddi_put16(sc->sc_cfg_handle, in rt2860_attach()
2886 (uint16_t *)((uintptr_t)(sc->sc_cfg_base) + PCI_CONF_COMM), in rt2860_attach()
2888 ddi_put8(sc->sc_cfg_handle, in rt2860_attach()
2889 (uint8_t *)(sc->sc_cfg_base + PCI_CONF_LATENCY_TIMER), 0xa8); in rt2860_attach()
2890 ddi_put8(sc->sc_cfg_handle, in rt2860_attach()
2891 (uint8_t *)(sc->sc_cfg_base + PCI_CONF_ILINE), 0x10); in rt2860_attach()
2895 &sc->sc_io_base, 0, 0, &rwn_csr_accattr, &sc->sc_io_handle); in rt2860_attach()
2904 sc->amrr.amrr_min_success_threshold = 1; in rt2860_attach()
2905 sc->amrr.amrr_max_success_threshold = 15; in rt2860_attach()
2909 sc->mac_rev = RT2860_READ(sc, RT2860_ASIC_VER_ID); in rt2860_attach()
2910 if (sc->mac_rev != 0 && sc->mac_rev != 0xffffffff) in rt2860_attach()
2920 if ((sc->mac_rev >> 16) != 0x2860 && in rt2860_attach()
2924 sc->sc_flags |= RT2860_ADVANCED_PS; in rt2860_attach()
2927 (void) rt2860_read_eeprom(sc); in rt2860_attach()
2930 sc->mac_rev >> 16, sc->mac_rev & 0xffff, in rt2860_attach()
2931 rt2860_get_rf(sc->rf_rev), sc->ntxchains, sc->nrxchains); in rt2860_attach()
2937 if ((err = rt2860_alloc_tx_ring(sc, &sc->txq[qid])) != 0) { in rt2860_attach()
2944 if ((err = rt2860_alloc_rx_ring(sc, &sc->rxq)) != 0) { in rt2860_attach()
2950 if ((err = rt2860_alloc_tx_pool(sc)) != 0) { in rt2860_attach()
2956 mutex_init(&sc->sc_genlock, NULL, MUTEX_DRIVER, NULL); in rt2860_attach()
2957 mutex_init(&sc->sc_txlock, NULL, MUTEX_DRIVER, NULL); in rt2860_attach()
2958 mutex_init(&sc->sc_rxlock, NULL, MUTEX_DRIVER, NULL); in rt2860_attach()
2961 sc->mgtqid = (sc->mac_rev == 0x28600100) ? EDCA_AC_VO : 5; in rt2860_attach()
2963 "mgtqid = %x\n", sc->mgtqid); in rt2860_attach()
3001 sc->sc_newstate = ic->ic_newstate; in rt2860_attach()
3007 &sc->sc_softintr_hdl, NULL, 0, rt2860_softintr, (caddr_t)sc); in rt2860_attach()
3014 err = ddi_get_iblock_cookie(devinfo, 0, &sc->sc_iblock); in rt2860_attach()
3021 err = ddi_add_intr(devinfo, 0, NULL, NULL, rt2860_intr, (caddr_t)sc); in rt2860_attach()
3043 macp->m_driver = sc; in rt2860_attach()
3073 sc->sc_flags &= ~RT2860_F_RUNNING; in rt2860_attach()
3078 ddi_remove_softintr(sc->sc_softintr_hdl); in rt2860_attach()
3080 ddi_remove_intr(devinfo, 0, sc->sc_iblock); in rt2860_attach()
3082 mutex_destroy(&sc->sc_genlock); in rt2860_attach()
3083 mutex_destroy(&sc->sc_txlock); in rt2860_attach()
3084 mutex_destroy(&sc->sc_rxlock); in rt2860_attach()
3086 rt2860_free_tx_pool(sc); in rt2860_attach()
3088 rt2860_free_rx_ring(sc, &sc->rxq); in rt2860_attach()
3091 rt2860_free_tx_ring(sc, &sc->txq[qid]); in rt2860_attach()
3093 ddi_regs_map_free(&sc->sc_io_handle); in rt2860_attach()
3095 ddi_regs_map_free(&sc->sc_cfg_handle); in rt2860_attach()
3103 struct rt2860_softc *sc; in rt2860_detach() local
3106 sc = ddi_get_soft_state(rt2860_soft_state_p, ddi_get_instance(devinfo)); in rt2860_detach()
3112 if (RT2860_IS_RUNNING(sc)) in rt2860_detach()
3113 rt2860_stop(sc); in rt2860_detach()
3114 RT2860_GLOCK(sc); in rt2860_detach()
3115 sc->sc_flags &= ~RT2860_FWLOADED; in rt2860_detach()
3116 sc->sc_flags |= RT2860_F_SUSPEND; in rt2860_detach()
3117 RT2860_GUNLOCK(sc); in rt2860_detach()
3125 if (mac_disable(sc->sc_ic.ic_mach) != 0) in rt2860_detach()
3128 rt2860_stop(sc); in rt2860_detach()
3133 (void) mac_unregister(sc->sc_ic.ic_mach); in rt2860_detach()
3135 ddi_remove_intr(devinfo, 0, sc->sc_iblock); in rt2860_detach()
3136 ddi_remove_softintr(sc->sc_softintr_hdl); in rt2860_detach()
3141 ieee80211_detach(&sc->sc_ic); in rt2860_detach()
3143 rt2860_free_tx_pool(sc); in rt2860_detach()
3144 rt2860_free_rx_ring(sc, &sc->rxq); in rt2860_detach()
3146 rt2860_free_tx_ring(sc, &sc->txq[qid]); in rt2860_detach()
3148 ddi_regs_map_free(&sc->sc_io_handle); in rt2860_detach()
3150 mutex_destroy(&sc->sc_genlock); in rt2860_detach()
3151 mutex_destroy(&sc->sc_txlock); in rt2860_detach()
3152 mutex_destroy(&sc->sc_rxlock); in rt2860_detach()