Lines Matching refs:sc
304 rt2860_eeprom_read(struct rt2860_softc *sc, uint8_t addr) in rt2860_eeprom_read() argument
311 RT2860_EEPROM_CTL(sc, 0); in rt2860_eeprom_read()
313 RT2860_EEPROM_CTL(sc, RT2860_S); in rt2860_eeprom_read()
314 RT2860_EEPROM_CTL(sc, RT2860_S | RT2860_C); in rt2860_eeprom_read()
315 RT2860_EEPROM_CTL(sc, RT2860_S); in rt2860_eeprom_read()
318 RT2860_EEPROM_CTL(sc, RT2860_S | RT2860_D); in rt2860_eeprom_read()
319 RT2860_EEPROM_CTL(sc, RT2860_S | RT2860_D | RT2860_C); in rt2860_eeprom_read()
322 RT2860_EEPROM_CTL(sc, RT2860_S | RT2860_D); in rt2860_eeprom_read()
323 RT2860_EEPROM_CTL(sc, RT2860_S | RT2860_D | RT2860_C); in rt2860_eeprom_read()
324 RT2860_EEPROM_CTL(sc, RT2860_S); in rt2860_eeprom_read()
325 RT2860_EEPROM_CTL(sc, RT2860_S | RT2860_C); in rt2860_eeprom_read()
328 n = ((RT2860_READ(sc, RT2860_PCI_EECTRL) & 0x30) == 0) ? 5 : 7; in rt2860_eeprom_read()
330 RT2860_EEPROM_CTL(sc, RT2860_S | in rt2860_eeprom_read()
332 RT2860_EEPROM_CTL(sc, RT2860_S | in rt2860_eeprom_read()
336 RT2860_EEPROM_CTL(sc, RT2860_S); in rt2860_eeprom_read()
341 RT2860_EEPROM_CTL(sc, RT2860_S | RT2860_C); in rt2860_eeprom_read()
342 tmp = RT2860_READ(sc, RT2860_PCI_EECTRL); in rt2860_eeprom_read()
344 RT2860_EEPROM_CTL(sc, RT2860_S); in rt2860_eeprom_read()
347 RT2860_EEPROM_CTL(sc, 0); in rt2860_eeprom_read()
350 RT2860_EEPROM_CTL(sc, RT2860_S); in rt2860_eeprom_read()
351 RT2860_EEPROM_CTL(sc, 0); in rt2860_eeprom_read()
352 RT2860_EEPROM_CTL(sc, RT2860_C); in rt2860_eeprom_read()
379 rt2860_read_eeprom(struct rt2860_softc *sc) in rt2860_read_eeprom() argument
381 struct ieee80211com *ic = &sc->sc_ic; in rt2860_read_eeprom()
387 val = rt2860_eeprom_read(sc, RT2860_EEPROM_VERSION); in rt2860_read_eeprom()
393 val = rt2860_eeprom_read(sc, RT2860_EEPROM_MAC01); in rt2860_read_eeprom()
396 val = rt2860_eeprom_read(sc, RT2860_EEPROM_MAC23); in rt2860_read_eeprom()
399 val = rt2860_eeprom_read(sc, RT2860_EEPROM_MAC45); in rt2860_read_eeprom()
409 val = rt2860_eeprom_read(sc, RT2860_EEPROM_COUNTRY); in rt2860_read_eeprom()
415 val = rt2860_eeprom_read(sc, RT2860_EEPROM_BBP_BASE + i); in rt2860_read_eeprom()
416 sc->bbp[i].val = val & 0xff; in rt2860_read_eeprom()
417 sc->bbp[i].reg = val >> 8; in rt2860_read_eeprom()
420 sc->bbp[i].reg, sc->bbp[i].val); in rt2860_read_eeprom()
424 val = rt2860_eeprom_read(sc, RT2860_EEPROM_FREQ_LEDS); in rt2860_read_eeprom()
425 sc->freq = ((val & 0xff) != 0xff) ? val & 0xff : 0; in rt2860_read_eeprom()
427 "EEPROM freq offset %d\n", sc->freq & 0xff); in rt2860_read_eeprom()
429 if ((sc->leds = val >> 8) != 0xff) { in rt2860_read_eeprom()
431 sc->led[0] = rt2860_eeprom_read(sc, RT2860_EEPROM_LED1); in rt2860_read_eeprom()
432 sc->led[1] = rt2860_eeprom_read(sc, RT2860_EEPROM_LED2); in rt2860_read_eeprom()
433 sc->led[2] = rt2860_eeprom_read(sc, RT2860_EEPROM_LED3); in rt2860_read_eeprom()
436 sc->leds = 0x01; in rt2860_read_eeprom()
437 sc->led[0] = 0x5555; in rt2860_read_eeprom()
438 sc->led[1] = 0x2221; in rt2860_read_eeprom()
439 sc->led[2] = 0xa9f8; in rt2860_read_eeprom()
443 sc->leds, sc->led[0], sc->led[1], sc->led[2]); in rt2860_read_eeprom()
446 val = rt2860_eeprom_read(sc, RT2860_EEPROM_ANTENNA); in rt2860_read_eeprom()
451 sc->rf_rev = RT2860_RF_2820; in rt2860_read_eeprom()
452 sc->ntxchains = 1; in rt2860_read_eeprom()
453 sc->nrxchains = 2; in rt2860_read_eeprom()
455 sc->rf_rev = (val >> 8) & 0xf; in rt2860_read_eeprom()
456 sc->ntxchains = (val >> 4) & 0xf; in rt2860_read_eeprom()
457 sc->nrxchains = val & 0xf; in rt2860_read_eeprom()
461 sc->rf_rev, sc->ntxchains, sc->nrxchains); in rt2860_read_eeprom()
464 val = rt2860_eeprom_read(sc, RT2860_EEPROM_CONFIG); in rt2860_read_eeprom()
468 sc->calib_2ghz = sc->calib_5ghz = 0; /* XXX (val >> 1) & 1 */; in rt2860_read_eeprom()
470 if (sc->sc_flags & RT2860_ADVANCED_PS) { in rt2860_read_eeprom()
472 val = rt2860_eeprom_read(sc, RT2860_EEPROM_PCIE_PSLEVEL); in rt2860_read_eeprom()
474 sc->pslevel = val & 0x3; in rt2860_read_eeprom()
475 val = rt2860_eeprom_read(sc, RT2860_EEPROM_REV); in rt2860_read_eeprom()
477 sc->pslevel = MIN(sc->pslevel, 1); in rt2860_read_eeprom()
481 sc->pslevel); in rt2860_read_eeprom()
486 val = rt2860_eeprom_read(sc, in rt2860_read_eeprom()
488 sc->txpow1[i + 0] = (int8_t)(val & 0xff); in rt2860_read_eeprom()
489 sc->txpow1[i + 1] = (int8_t)(val >> 8); in rt2860_read_eeprom()
491 val = rt2860_eeprom_read(sc, in rt2860_read_eeprom()
493 sc->txpow2[i + 0] = (int8_t)(val & 0xff); in rt2860_read_eeprom()
494 sc->txpow2[i + 1] = (int8_t)(val >> 8); in rt2860_read_eeprom()
498 if (sc->txpow1[i] < 0 || sc->txpow1[i] > 31) in rt2860_read_eeprom()
499 sc->txpow1[i] = 5; in rt2860_read_eeprom()
500 if (sc->txpow2[i] < 0 || sc->txpow2[i] > 31) in rt2860_read_eeprom()
501 sc->txpow2[i] = 5; in rt2860_read_eeprom()
504 rt2860_rf2850[i].chan, sc->txpow1[i], sc->txpow2[i]); in rt2860_read_eeprom()
508 val = rt2860_eeprom_read(sc, in rt2860_read_eeprom()
510 sc->txpow1[i + 14] = (int8_t)(val & 0xff); in rt2860_read_eeprom()
511 sc->txpow1[i + 15] = (int8_t)(val >> 8); in rt2860_read_eeprom()
513 val = rt2860_eeprom_read(sc, in rt2860_read_eeprom()
515 sc->txpow2[i + 14] = (int8_t)(val & 0xff); in rt2860_read_eeprom()
516 sc->txpow2[i + 15] = (int8_t)(val >> 8); in rt2860_read_eeprom()
520 if (sc->txpow1[14 + i] < -7 || sc->txpow1[14 + i] > 15) in rt2860_read_eeprom()
521 sc->txpow1[14 + i] = 5; in rt2860_read_eeprom()
522 if (sc->txpow2[14 + i] < -7 || sc->txpow2[14 + i] > 15) in rt2860_read_eeprom()
523 sc->txpow2[14 + i] = 5; in rt2860_read_eeprom()
526 rt2860_rf2850[14 + i].chan, sc->txpow1[14 + i], in rt2860_read_eeprom()
527 sc->txpow2[14 + i]); in rt2860_read_eeprom()
531 val = rt2860_eeprom_read(sc, RT2860_EEPROM_DELTAPWR); in rt2860_read_eeprom()
551 val = rt2860_eeprom_read(sc, RT2860_EEPROM_RPWR + ridx); in rt2860_read_eeprom()
553 val = rt2860_eeprom_read(sc, RT2860_EEPROM_RPWR + ridx + 1); in rt2860_read_eeprom()
556 sc->txpow20mhz[ridx] = reg; in rt2860_read_eeprom()
557 sc->txpow40mhz_2ghz[ridx] = b4inc(reg, delta_2ghz); in rt2860_read_eeprom()
558 sc->txpow40mhz_5ghz[ridx] = b4inc(reg, delta_5ghz); in rt2860_read_eeprom()
562 "40MHz/5GHz=0x%08x\n", ridx, sc->txpow20mhz[ridx], in rt2860_read_eeprom()
563 sc->txpow40mhz_2ghz[ridx], sc->txpow40mhz_5ghz[ridx]); in rt2860_read_eeprom()
567 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI1_2GHZ); in rt2860_read_eeprom()
568 sc->tssi_2ghz[0] = val & 0xff; /* [-4] */ in rt2860_read_eeprom()
569 sc->tssi_2ghz[1] = val >> 8; /* [-3] */ in rt2860_read_eeprom()
570 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI2_2GHZ); in rt2860_read_eeprom()
571 sc->tssi_2ghz[2] = val & 0xff; /* [-2] */ in rt2860_read_eeprom()
572 sc->tssi_2ghz[3] = val >> 8; /* [-1] */ in rt2860_read_eeprom()
573 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI3_2GHZ); in rt2860_read_eeprom()
574 sc->tssi_2ghz[4] = val & 0xff; /* [+0] */ in rt2860_read_eeprom()
575 sc->tssi_2ghz[5] = val >> 8; /* [+1] */ in rt2860_read_eeprom()
576 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI4_2GHZ); in rt2860_read_eeprom()
577 sc->tssi_2ghz[6] = val & 0xff; /* [+2] */ in rt2860_read_eeprom()
578 sc->tssi_2ghz[7] = val >> 8; /* [+3] */ in rt2860_read_eeprom()
579 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI5_2GHZ); in rt2860_read_eeprom()
580 sc->tssi_2ghz[8] = val & 0xff; /* [+4] */ in rt2860_read_eeprom()
581 sc->step_2ghz = val >> 8; in rt2860_read_eeprom()
584 "0x%02x 0x%02x step=%d\n", sc->tssi_2ghz[0], sc->tssi_2ghz[1], in rt2860_read_eeprom()
585 sc->tssi_2ghz[2], sc->tssi_2ghz[3], sc->tssi_2ghz[4], in rt2860_read_eeprom()
586 sc->tssi_2ghz[5], sc->tssi_2ghz[6], sc->tssi_2ghz[7], in rt2860_read_eeprom()
587 sc->tssi_2ghz[8], sc->step_2ghz); in rt2860_read_eeprom()
589 if (sc->tssi_2ghz[4] == 0xff) in rt2860_read_eeprom()
590 sc->calib_2ghz = 0; in rt2860_read_eeprom()
592 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI1_5GHZ); in rt2860_read_eeprom()
593 sc->tssi_5ghz[0] = val & 0xff; /* [-4] */ in rt2860_read_eeprom()
594 sc->tssi_5ghz[1] = val >> 8; /* [-3] */ in rt2860_read_eeprom()
595 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI2_5GHZ); in rt2860_read_eeprom()
596 sc->tssi_5ghz[2] = val & 0xff; /* [-2] */ in rt2860_read_eeprom()
597 sc->tssi_5ghz[3] = val >> 8; /* [-1] */ in rt2860_read_eeprom()
598 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI3_5GHZ); in rt2860_read_eeprom()
599 sc->tssi_5ghz[4] = val & 0xff; /* [+0] */ in rt2860_read_eeprom()
600 sc->tssi_5ghz[5] = val >> 8; /* [+1] */ in rt2860_read_eeprom()
601 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI4_5GHZ); in rt2860_read_eeprom()
602 sc->tssi_5ghz[6] = val & 0xff; /* [+2] */ in rt2860_read_eeprom()
603 sc->tssi_5ghz[7] = val >> 8; /* [+3] */ in rt2860_read_eeprom()
604 val = rt2860_eeprom_read(sc, RT2860_EEPROM_TSSI5_5GHZ); in rt2860_read_eeprom()
605 sc->tssi_5ghz[8] = val & 0xff; /* [+4] */ in rt2860_read_eeprom()
606 sc->step_5ghz = val >> 8; in rt2860_read_eeprom()
609 "0x%02x 0x%02x step=%d\n", sc->tssi_5ghz[0], sc->tssi_5ghz[1], in rt2860_read_eeprom()
610 sc->tssi_5ghz[2], sc->tssi_5ghz[3], sc->tssi_5ghz[4], in rt2860_read_eeprom()
611 sc->tssi_5ghz[5], sc->tssi_5ghz[6], sc->tssi_5ghz[7], in rt2860_read_eeprom()
612 sc->tssi_5ghz[8], sc->step_5ghz); in rt2860_read_eeprom()
614 if (sc->tssi_5ghz[4] == 0xff) in rt2860_read_eeprom()
615 sc->calib_5ghz = 0; in rt2860_read_eeprom()
618 val = rt2860_eeprom_read(sc, RT2860_EEPROM_RSSI1_2GHZ); in rt2860_read_eeprom()
619 sc->rssi_2ghz[0] = val & 0xff; /* Ant A */ in rt2860_read_eeprom()
620 sc->rssi_2ghz[1] = val >> 8; /* Ant B */ in rt2860_read_eeprom()
621 val = rt2860_eeprom_read(sc, RT2860_EEPROM_RSSI2_2GHZ); in rt2860_read_eeprom()
622 sc->rssi_2ghz[2] = val & 0xff; /* Ant C */ in rt2860_read_eeprom()
623 sc->lna[2] = val >> 8; /* channel group 2 */ in rt2860_read_eeprom()
625 val = rt2860_eeprom_read(sc, RT2860_EEPROM_RSSI1_5GHZ); in rt2860_read_eeprom()
626 sc->rssi_5ghz[0] = val & 0xff; /* Ant A */ in rt2860_read_eeprom()
627 sc->rssi_5ghz[1] = val >> 8; /* Ant B */ in rt2860_read_eeprom()
628 val = rt2860_eeprom_read(sc, RT2860_EEPROM_RSSI2_5GHZ); in rt2860_read_eeprom()
629 sc->rssi_5ghz[2] = val & 0xff; /* Ant C */ in rt2860_read_eeprom()
630 sc->lna[3] = val >> 8; /* channel group 3 */ in rt2860_read_eeprom()
632 val = rt2860_eeprom_read(sc, RT2860_EEPROM_LNA); in rt2860_read_eeprom()
633 sc->lna[0] = val & 0xff; /* channel group 0 */ in rt2860_read_eeprom()
634 sc->lna[1] = val >> 8; /* channel group 1 */ in rt2860_read_eeprom()
637 if (sc->lna[2] == 0 || sc->lna[2] == 0xff) { in rt2860_read_eeprom()
640 sc->lna[2] = sc->lna[1]; in rt2860_read_eeprom()
642 if (sc->lna[3] == 0 || sc->lna[3] == 0xff) { in rt2860_read_eeprom()
645 sc->lna[3] = sc->lna[1]; in rt2860_read_eeprom()
650 if (sc->rssi_2ghz[ant] < -10 || sc->rssi_2ghz[ant] > 10) { in rt2860_read_eeprom()
654 ant + 1, sc->rssi_2ghz[ant]); in rt2860_read_eeprom()
655 sc->rssi_2ghz[ant] = 0; in rt2860_read_eeprom()
657 if (sc->rssi_5ghz[ant] < -10 || sc->rssi_5ghz[ant] > 10) { in rt2860_read_eeprom()
661 ant + 1, sc->rssi_5ghz[ant]); in rt2860_read_eeprom()
662 sc->rssi_5ghz[ant] = 0; in rt2860_read_eeprom()
753 rt2860_alloc_tx_ring(struct rt2860_softc *sc, struct rt2860_tx_ring *ring) in rt2860_alloc_tx_ring() argument
759 err = rt2860_alloc_dma_mem(sc->sc_dev, &rt2860_dma_attr, size, in rt2860_alloc_tx_ring()
784 rt2860_reset_tx_ring(struct rt2860_softc *sc, struct rt2860_tx_ring *ring) in rt2860_reset_tx_ring() argument
796 if (!(sc->sc_flags & RT2860_F_QUIESCE)) in rt2860_reset_tx_ring()
804 SLIST_INSERT_HEAD(&sc->data_pool, data, next); in rt2860_reset_tx_ring()
809 if (!(sc->sc_flags & RT2860_F_QUIESCE)) in rt2860_reset_tx_ring()
818 rt2860_free_tx_ring(struct rt2860_softc *sc, struct rt2860_tx_ring *ring) in rt2860_free_tx_ring() argument
826 rt2860_alloc_rx_ring(struct rt2860_softc *sc, struct rt2860_rx_ring *ring) in rt2860_alloc_rx_ring() argument
834 err = rt2860_alloc_dma_mem(sc->sc_dev, &rt2860_dma_attr, size, in rt2860_alloc_rx_ring()
857 (void) rt2860_alloc_dma_mem(sc->sc_dev, &rt2860_dma_attr, in rt2860_alloc_rx_ring()
858 sc->sc_dmabuf_size, in rt2860_alloc_rx_ring()
864 rxd->sdl0 = LE_16(sc->sc_dmabuf_size); in rt2860_alloc_rx_ring()
879 rt2860_reset_rx_ring(struct rt2860_softc *sc, struct rt2860_rx_ring *ring) in rt2860_reset_rx_ring() argument
893 rt2860_free_rx_ring(struct rt2860_softc *sc, struct rt2860_rx_ring *ring) in rt2860_free_rx_ring() argument
911 rt2860_alloc_tx_pool(struct rt2860_softc *sc) in rt2860_alloc_tx_pool() argument
919 SLIST_INIT(&sc->data_pool); in rt2860_alloc_tx_pool()
921 err = rt2860_alloc_dma_mem(sc->sc_dev, &rt2860_dma_attr, size, in rt2860_alloc_tx_pool()
924 &sc->txpool_dma); in rt2860_alloc_tx_pool()
931 sc->txwi = (struct rt2860_txwi *)sc->txpool_dma.mem_va; in rt2860_alloc_tx_pool()
932 (void) bzero(sc->txwi, size); in rt2860_alloc_tx_pool()
933 RT2860_DMA_SYNC(sc->txpool_dma, DDI_DMA_SYNC_FORDEV); in rt2860_alloc_tx_pool()
936 data = &sc->data[i]; in rt2860_alloc_tx_pool()
938 err = rt2860_alloc_dma_mem(sc->sc_dev, &rt2860_dma_attr, in rt2860_alloc_tx_pool()
939 sc->sc_dmabuf_size, in rt2860_alloc_tx_pool()
949 data->txwi = &sc->txwi[i]; in rt2860_alloc_tx_pool()
950 data->paddr = sc->txpool_dma.cookie.dmac_address + in rt2860_alloc_tx_pool()
953 SLIST_INSERT_HEAD(&sc->data_pool, data, next); in rt2860_alloc_tx_pool()
957 rt2860_free_dma_mem(&sc->txpool_dma); in rt2860_alloc_tx_pool()
963 rt2860_free_tx_pool(struct rt2860_softc *sc) in rt2860_free_tx_pool() argument
968 if (sc->txwi != NULL) { in rt2860_free_tx_pool()
969 rt2860_free_dma_mem(&sc->txpool_dma); in rt2860_free_tx_pool()
973 data = &sc->data[i]; in rt2860_free_tx_pool()
1081 struct rt2860_softc *sc = (struct rt2860_softc *)ic; in rt2860_send() local
1097 mutex_enter(&sc->sc_txlock); in rt2860_send()
1098 if (RT2860_IS_SUSPEND(sc)) { in rt2860_send()
1105 qid = sc->mgtqid; in rt2860_send()
1108 ring = &sc->txq[qid]; in rt2860_send()
1110 if (SLIST_EMPTY(&sc->data_pool) || (ring->queued > 15)) { in rt2860_send()
1111 sc->sc_need_sched = 1; in rt2860_send()
1112 sc->sc_tx_nobuf++; in rt2860_send()
1118 data = SLIST_FIRST(&sc->data_pool); in rt2860_send()
1139 sc->sc_tx_err++; in rt2860_send()
1151 sc->sc_tx_err++; in rt2860_send()
1214 ic->ic_flags) + sc->sifs; in rt2860_send()
1236 SLIST_REMOVE_HEAD(&sc->data_pool, next); in rt2860_send()
1240 (void) ddi_dma_sync(sc->txpool_dma.dma_hdl, in rt2860_send()
1241 _PTRDIFF(txwi, sc->txwi), in rt2860_send()
1255 RT2860_WRITE(sc, RT2860_TX_CTX_IDX(qid), ring->cur); in rt2860_send()
1257 sc->sc_tx_timer = 5; in rt2860_send()
1270 mutex_exit(&sc->sc_txlock); in rt2860_send()
1281 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_next_scan() local
1282 struct ieee80211com *ic = &sc->sc_ic; in rt2860_next_scan()
1289 rt2860_updateslot(struct rt2860_softc *sc) in rt2860_updateslot() argument
1291 struct ieee80211com *ic = &sc->sc_ic; in rt2860_updateslot()
1294 tmp = RT2860_READ(sc, RT2860_BKOFF_SLOT_CFG); in rt2860_updateslot()
1297 RT2860_WRITE(sc, RT2860_BKOFF_SLOT_CFG, tmp); in rt2860_updateslot()
1303 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_iter_func() local
1307 rt2860_amrr_choose(&sc->amrr, ni, &sc->amn[wcid]); in rt2860_iter_func()
1313 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_updatestats() local
1314 struct ieee80211com *ic = &sc->sc_ic; in rt2860_updatestats()
1317 rt2860_iter_func(sc, ic->ic_bss); in rt2860_updatestats()
1321 sc->sc_rssadapt_id = timeout(rt2860_updatestats, (void *)sc, in rt2860_updatestats()
1326 rt2860_enable_mrr(struct rt2860_softc *sc) in rt2860_enable_mrr() argument
1330 RT2860_WRITE(sc, RT2860_LG_FBK_CFG0, in rt2860_enable_mrr()
1340 RT2860_WRITE(sc, RT2860_LG_FBK_CFG1, in rt2860_enable_mrr()
1350 rt2860_set_txpreamble(struct rt2860_softc *sc) in rt2860_set_txpreamble() argument
1354 tmp = RT2860_READ(sc, RT2860_AUTO_RSP_CFG); in rt2860_set_txpreamble()
1356 if (sc->sc_ic.ic_flags & IEEE80211_F_SHPREAMBLE) in rt2860_set_txpreamble()
1358 RT2860_WRITE(sc, RT2860_AUTO_RSP_CFG, tmp); in rt2860_set_txpreamble()
1362 rt2860_set_bssid(struct rt2860_softc *sc, const uint8_t *bssid) in rt2860_set_bssid() argument
1364 RT2860_WRITE(sc, RT2860_MAC_BSSID_DW0, in rt2860_set_bssid()
1366 RT2860_WRITE(sc, RT2860_MAC_BSSID_DW1, in rt2860_set_bssid()
1371 rt2860_set_basicrates(struct rt2860_softc *sc) in rt2860_set_basicrates() argument
1373 struct ieee80211com *ic = &sc->sc_ic; in rt2860_set_basicrates()
1377 RT2860_WRITE(sc, RT2860_LEGACY_BASIC_RATE, 0x003); in rt2860_set_basicrates()
1379 RT2860_WRITE(sc, RT2860_LEGACY_BASIC_RATE, 0x150); in rt2860_set_basicrates()
1381 RT2860_WRITE(sc, RT2860_LEGACY_BASIC_RATE, 0x15f); in rt2860_set_basicrates()
1464 struct rt2860_softc *sc = (struct rt2860_softc *)ic; in rt2860_newassoc() local
1477 rt2860_mem_write1(sc, off++, *fptr++); in rt2860_newassoc()
1479 rt2860_amrr_node_init(&sc->amrr, &sc->amn[wcid]); in rt2860_newassoc()
1498 rt2860_enable_tsf_sync(struct rt2860_softc *sc) in rt2860_enable_tsf_sync() argument
1500 struct ieee80211com *ic = &sc->sc_ic; in rt2860_enable_tsf_sync()
1503 tmp = RT2860_READ(sc, RT2860_BCN_TIME_CFG); in rt2860_enable_tsf_sync()
1516 RT2860_WRITE(sc, RT2860_BCN_TIME_CFG, tmp); in rt2860_enable_tsf_sync()
1522 struct rt2860_softc *sc = (struct rt2860_softc *)ic; in rt2860_newstate() local
1531 RT2860_GLOCK(sc); in rt2860_newstate()
1532 if (sc->sc_scan_id != 0) { in rt2860_newstate()
1533 (void) untimeout(sc->sc_scan_id); in rt2860_newstate()
1534 sc->sc_scan_id = 0; in rt2860_newstate()
1536 if (sc->sc_rssadapt_id != 0) { in rt2860_newstate()
1537 (void) untimeout(sc->sc_rssadapt_id); in rt2860_newstate()
1538 sc->sc_rssadapt_id = 0; in rt2860_newstate()
1542 rt2860_set_leds(sc, RT2860_LED_RADIO); in rt2860_newstate()
1549 tmp = RT2860_READ(sc, RT2860_BCN_TIME_CFG); in rt2860_newstate()
1550 RT2860_WRITE(sc, RT2860_BCN_TIME_CFG, in rt2860_newstate()
1557 rt2860_set_chan(sc, ic->ic_curchan); in rt2860_newstate()
1558 sc->sc_scan_id = timeout(rt2860_next_scan, (void *)sc, in rt2860_newstate()
1564 rt2860_set_chan(sc, ic->ic_curchan); in rt2860_newstate()
1568 rt2860_set_chan(sc, ic->ic_curchan); in rt2860_newstate()
1571 rt2860_updateslot(sc); in rt2860_newstate()
1572 rt2860_enable_mrr(sc); in rt2860_newstate()
1573 rt2860_set_txpreamble(sc); in rt2860_newstate()
1574 rt2860_set_basicrates(sc); in rt2860_newstate()
1575 rt2860_set_bssid(sc, ic->ic_bss->in_bssid); in rt2860_newstate()
1583 rt2860_enable_tsf_sync(sc); in rt2860_newstate()
1584 sc->sc_rssadapt_id = timeout(rt2860_updatestats, in rt2860_newstate()
1585 (void *)sc, drv_usectohz(500 * 1000)); in rt2860_newstate()
1589 rt2860_set_leds(sc, RT2860_LED_RADIO | in rt2860_newstate()
1595 RT2860_GUNLOCK(sc); in rt2860_newstate()
1597 err = sc->sc_newstate(ic, nstate, arg); in rt2860_newstate()
1606 rt2860_maxrssi_chain(struct rt2860_softc *sc, const struct rt2860_rxwi *rxwi) in rt2860_maxrssi_chain() argument
1610 if (sc->nrxchains > 1) in rt2860_maxrssi_chain()
1613 if (sc->nrxchains > 2) in rt2860_maxrssi_chain()
1621 rt2860_drain_stats_fifo(struct rt2860_softc *sc) in rt2860_drain_stats_fifo() argument
1628 while ((stat = RT2860_READ(sc, RT2860_TX_STAT_FIFO)) & RT2860_TXQ_VLD) { in rt2860_drain_stats_fifo()
1638 amn = &sc->amn[wcid]; in rt2860_drain_stats_fifo()
1658 rt2860_tx_intr(struct rt2860_softc *sc, int qid) in rt2860_tx_intr() argument
1660 struct rt2860_tx_ring *ring = &sc->txq[qid]; in rt2860_tx_intr()
1661 struct ieee80211com *ic = &sc->sc_ic; in rt2860_tx_intr()
1664 rt2860_drain_stats_fifo(sc); in rt2860_tx_intr()
1666 mutex_enter(&sc->sc_txlock); in rt2860_tx_intr()
1667 hw = RT2860_READ(sc, RT2860_TX_DTX_IDX(qid)); in rt2860_tx_intr()
1681 SLIST_INSERT_HEAD(&sc->data_pool, data, next); in rt2860_tx_intr()
1695 if (sc->sc_need_sched && in rt2860_tx_intr()
1697 sc->sc_need_sched = 0; in rt2860_tx_intr()
1701 sc->sc_tx_timer = 0; in rt2860_tx_intr()
1702 mutex_exit(&sc->sc_txlock); in rt2860_tx_intr()
1706 rt2860_rx_intr(struct rt2860_softc *sc) in rt2860_rx_intr() argument
1708 struct ieee80211com *ic = &sc->sc_ic; in rt2860_rx_intr()
1715 mutex_enter(&sc->sc_rxlock); in rt2860_rx_intr()
1717 struct rt2860_rx_data *data = &sc->rxq.data[sc->rxq.cur]; in rt2860_rx_intr()
1718 struct rt2860_rxd *rxd = &sc->rxq.rxd[sc->rxq.cur]; in rt2860_rx_intr()
1721 (void) ddi_dma_sync(sc->rxq.rxdesc_dma.dma_hdl, in rt2860_rx_intr()
1722 sc->rxq.cur * sizeof (struct rt2860_rxd), in rt2860_rx_intr()
1736 sc->sc_rx_err++; in rt2860_rx_intr()
1743 sc->sc_rx_err++; in rt2860_rx_intr()
1758 mp0 = allocb(sc->sc_dmabuf_size, BPRI_MED); in rt2860_rx_intr()
1762 sc->sc_rx_nobuf++; in rt2860_rx_intr()
1776 ant = rt2860_maxrssi_chain(sc, rxwi); in rt2860_rx_intr()
1788 (void) ddi_dma_sync(sc->rxq.rxdesc_dma.dma_hdl, in rt2860_rx_intr()
1789 sc->rxq.cur * sizeof (struct rt2860_rxd), in rt2860_rx_intr()
1793 sc->rxq.cur = (sc->rxq.cur + 1) % RT2860_RX_RING_COUNT; in rt2860_rx_intr()
1795 mutex_exit(&sc->sc_rxlock); in rt2860_rx_intr()
1798 RT2860_WRITE(sc, RT2860_RX_CALC_IDX, in rt2860_rx_intr()
1799 (sc->rxq.cur - 1) % RT2860_RX_RING_COUNT); in rt2860_rx_intr()
1805 struct rt2860_softc *sc = (struct rt2860_softc *)data; in rt2860_softintr() local
1811 RT2860_GLOCK(sc); in rt2860_softintr()
1812 if (sc->sc_rx_pend) { in rt2860_softintr()
1813 sc->sc_rx_pend = 0; in rt2860_softintr()
1814 RT2860_GUNLOCK(sc); in rt2860_softintr()
1815 rt2860_rx_intr(sc); in rt2860_softintr()
1818 RT2860_GUNLOCK(sc); in rt2860_softintr()
1826 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_intr() local
1829 RT2860_GLOCK(sc); in rt2860_intr()
1831 if ((!RT2860_IS_RUNNING(sc)) || RT2860_IS_SUSPEND(sc)) { in rt2860_intr()
1836 RT2860_GUNLOCK(sc); in rt2860_intr()
1840 r = RT2860_READ(sc, RT2860_INT_STATUS); in rt2860_intr()
1842 RT2860_GUNLOCK(sc); in rt2860_intr()
1846 RT2860_GUNLOCK(sc); in rt2860_intr()
1851 RT2860_WRITE(sc, RT2860_INT_STATUS, r); in rt2860_intr()
1864 rt2860_drain_stats_fifo(sc); in rt2860_intr()
1870 rt2860_tx_intr(sc, 5); in rt2860_intr()
1876 sc->sc_rx_pend = 1; in rt2860_intr()
1877 ddi_trigger_softintr(sc->sc_softintr_hdl); in rt2860_intr()
1883 rt2860_tx_intr(sc, 4); in rt2860_intr()
1889 rt2860_tx_intr(sc, 3); in rt2860_intr()
1895 rt2860_tx_intr(sc, 2); in rt2860_intr()
1901 rt2860_tx_intr(sc, 1); in rt2860_intr()
1907 rt2860_tx_intr(sc, 0); in rt2860_intr()
1913 struct ieee80211com *ic = &sc->sc_ic; in rt2860_intr()
1915 if ((sc->sc_ic_flags ^ ic->ic_flags) & IEEE80211_F_USEPROT) { in rt2860_intr()
1917 sc->sc_ic_flags = ic->ic_flags; in rt2860_intr()
1925 RT2860_GUNLOCK(sc); in rt2860_intr()
1931 rt2860_set_region_4(struct rt2860_softc *sc, in rt2860_set_region_4() argument
1935 ddi_put32((sc)->sc_io_handle, in rt2860_set_region_4()
1936 (uint32_t *)((uintptr_t)(sc)->sc_io_base + addr), data); in rt2860_set_region_4()
1940 rt2860_load_microcode(struct rt2860_softc *sc) in rt2860_load_microcode() argument
1953 RT2860_WRITE(sc, RT2860_SYS_CTRL, RT2860_HST_PM_SEL); in rt2860_load_microcode()
1958 rt2860_mem_write1(sc, off++, *fptr++); in rt2860_load_microcode()
1961 RT2860_WRITE(sc, RT2860_SYS_CTRL, 0); in rt2860_load_microcode()
1962 RT2860_WRITE(sc, RT2860_SYS_CTRL, RT2860_MCU_RESET); in rt2860_load_microcode()
1964 RT2860_WRITE(sc, RT2860_H2M_BBPAGENT, 0); in rt2860_load_microcode()
1965 RT2860_WRITE(sc, RT2860_H2M_MAILBOX, 0); in rt2860_load_microcode()
1969 if (RT2860_READ(sc, RT2860_SYS_CTRL) & RT2860_MCU_READY) in rt2860_load_microcode()
1983 rt2860_set_macaddr(struct rt2860_softc *sc, const uint8_t *addr) in rt2860_set_macaddr() argument
1985 RT2860_WRITE(sc, RT2860_MAC_ADDR_DW0, in rt2860_set_macaddr()
1987 RT2860_WRITE(sc, RT2860_MAC_ADDR_DW1, in rt2860_set_macaddr()
1995 rt2860_mcu_cmd(struct rt2860_softc *sc, uint8_t cmd, uint16_t arg) in rt2860_mcu_cmd() argument
2000 if (!(RT2860_READ(sc, RT2860_H2M_MAILBOX) & RT2860_H2M_BUSY)) in rt2860_mcu_cmd()
2007 RT2860_WRITE(sc, RT2860_H2M_MAILBOX, in rt2860_mcu_cmd()
2009 RT2860_WRITE(sc, RT2860_HOST_CMD, cmd); in rt2860_mcu_cmd()
2020 rt2860_mcu_bbp_read(struct rt2860_softc *sc, uint8_t reg) in rt2860_mcu_bbp_read() argument
2026 if (!(RT2860_READ(sc, in rt2860_mcu_bbp_read()
2037 RT2860_WRITE(sc, RT2860_H2M_BBPAGENT, RT2860_BBP_RW_PARALLEL | in rt2860_mcu_bbp_read()
2040 (void) rt2860_mcu_cmd(sc, RT2860_MCU_CMD_BBP, 0); in rt2860_mcu_bbp_read()
2044 val = RT2860_READ(sc, RT2860_H2M_BBPAGENT); in rt2860_mcu_bbp_read()
2056 rt2860_mcu_bbp_write(struct rt2860_softc *sc, uint8_t reg, uint8_t val) in rt2860_mcu_bbp_write() argument
2061 if (!(RT2860_READ(sc, in rt2860_mcu_bbp_write()
2072 RT2860_WRITE(sc, RT2860_H2M_BBPAGENT, RT2860_BBP_RW_PARALLEL | in rt2860_mcu_bbp_write()
2075 (void) rt2860_mcu_cmd(sc, RT2860_MCU_CMD_BBP, 0); in rt2860_mcu_bbp_write()
2080 rt2860_bbp_init(struct rt2860_softc *sc) in rt2860_bbp_init() argument
2086 uint8_t bbp0 = rt2860_mcu_bbp_read(sc, 0); in rt2860_bbp_init()
2098 rt2860_mcu_bbp_write(sc, rt2860_def_bbp[i].reg, in rt2860_bbp_init()
2103 if (sc->mac_rev == 0x28600100) { in rt2860_bbp_init()
2104 rt2860_mcu_bbp_write(sc, 69, 0x16); in rt2860_bbp_init()
2105 rt2860_mcu_bbp_write(sc, 73, 0x12); in rt2860_bbp_init()
2112 rt2860_rf_write(struct rt2860_softc *sc, uint8_t reg, uint32_t val) in rt2860_rf_write() argument
2118 if (!(RT2860_READ(sc, RT2860_RF_CSR_CFG0) & RT2860_RF_REG_CTRL)) in rt2860_rf_write()
2131 RT2860_WRITE(sc, RT2860_RF_CSR_CFG0, tmp); in rt2860_rf_write()
2135 rt2860_select_chan_group(struct rt2860_softc *sc, int group) in rt2860_select_chan_group() argument
2139 rt2860_mcu_bbp_write(sc, 62, 0x37 - sc->lna[group]); in rt2860_select_chan_group()
2140 rt2860_mcu_bbp_write(sc, 63, 0x37 - sc->lna[group]); in rt2860_select_chan_group()
2141 rt2860_mcu_bbp_write(sc, 64, 0x37 - sc->lna[group]); in rt2860_select_chan_group()
2142 rt2860_mcu_bbp_write(sc, 82, (group == 0) ? 0x62 : 0xf2); in rt2860_select_chan_group()
2144 tmp = RT2860_READ(sc, RT2860_TX_BAND_CFG); in rt2860_select_chan_group()
2147 RT2860_WRITE(sc, RT2860_TX_BAND_CFG, tmp); in rt2860_select_chan_group()
2153 if (sc->ntxchains > 1) in rt2860_select_chan_group()
2155 if (sc->nrxchains > 1) in rt2860_select_chan_group()
2159 if (sc->ntxchains > 1) in rt2860_select_chan_group()
2161 if (sc->nrxchains > 1) in rt2860_select_chan_group()
2164 RT2860_WRITE(sc, RT2860_TX_PIN_CFG, tmp); in rt2860_select_chan_group()
2166 rt2860_mcu_bbp_write(sc, 66, 0x2e + sc->lna[group]); in rt2860_select_chan_group()
2169 rt2860_set_chan(struct rt2860_softc *sc, struct ieee80211_channel *c) in rt2860_set_chan() argument
2171 struct ieee80211com *ic = &sc->sc_ic; in rt2860_set_chan()
2188 if (sc->ntxchains == 1) in rt2860_set_chan()
2190 if (sc->nrxchains == 1) in rt2860_set_chan()
2192 else if (sc->nrxchains == 2) in rt2860_set_chan()
2196 txpow1 = sc->txpow1[i]; in rt2860_set_chan()
2197 txpow2 = sc->txpow2[i]; in rt2860_set_chan()
2203 r4 = rfprog[i].r4 | sc->freq << 13 | txpow2 << 4; in rt2860_set_chan()
2205 rt2860_rf_write(sc, RAL_RF1, rfprog[i].r1); in rt2860_set_chan()
2206 rt2860_rf_write(sc, RAL_RF2, r2); in rt2860_set_chan()
2207 rt2860_rf_write(sc, RAL_RF3, r3); in rt2860_set_chan()
2208 rt2860_rf_write(sc, RAL_RF4, r4); in rt2860_set_chan()
2212 rt2860_rf_write(sc, RAL_RF1, rfprog[i].r1); in rt2860_set_chan()
2213 rt2860_rf_write(sc, RAL_RF2, r2); in rt2860_set_chan()
2214 rt2860_rf_write(sc, RAL_RF3, r3 | 1); in rt2860_set_chan()
2215 rt2860_rf_write(sc, RAL_RF4, r4); in rt2860_set_chan()
2219 rt2860_rf_write(sc, RAL_RF1, rfprog[i].r1); in rt2860_set_chan()
2220 rt2860_rf_write(sc, RAL_RF2, r2); in rt2860_set_chan()
2221 rt2860_rf_write(sc, RAL_RF3, r3); in rt2860_set_chan()
2222 rt2860_rf_write(sc, RAL_RF4, r4); in rt2860_set_chan()
2225 sc->sifs = IEEE80211_IS_CHAN_5GHZ(c) ? 16 : 10; in rt2860_set_chan()
2238 rt2860_select_chan_group(sc, group); in rt2860_set_chan()
2246 struct rt2860_softc *sc = (struct rt2860_softc *)ic; in rt2860_updateprot() local
2254 RT2860_WRITE(sc, RT2860_CCK_PROT_CFG, tmp); in rt2860_updateprot()
2262 RT2860_WRITE(sc, RT2860_OFDM_PROT_CFG, tmp); in rt2860_updateprot()
2266 rt2860_set_leds(struct rt2860_softc *sc, uint16_t which) in rt2860_set_leds() argument
2268 (void) rt2860_mcu_cmd(sc, RT2860_MCU_CMD_LEDS, in rt2860_set_leds()
2269 which | (sc->leds & 0x7f)); in rt2860_set_leds()
2273 rt2860_init(struct rt2860_softc *sc) in rt2860_init() argument
2281 ic = &sc->sc_ic; in rt2860_init()
2283 rt2860_stop(sc); in rt2860_init()
2284 tmp = RT2860_READ(sc, RT2860_WPDMA_GLO_CFG); in rt2860_init()
2286 RT2860_WRITE(sc, RT2860_WPDMA_GLO_CFG, tmp | RT2860_TX_WB_DDONE); in rt2860_init()
2288 RT2860_WRITE(sc, RT2860_WPDMA_RST_IDX, 0xffffffff); in rt2860_init()
2291 RT2860_WRITE(sc, RT2860_SYS_CTRL, 0xe1f); in rt2860_init()
2292 RT2860_WRITE(sc, RT2860_SYS_CTRL, 0xe00); in rt2860_init()
2294 if (!(sc->sc_flags & RT2860_FWLOADED)) { in rt2860_init()
2295 if ((err = rt2860_load_microcode(sc)) != 0) { in rt2860_init()
2298 rt2860_stop(sc); in rt2860_init()
2301 RT2860_GLOCK(sc); in rt2860_init()
2302 sc->sc_flags |= RT2860_FWLOADED; in rt2860_init()
2303 RT2860_GUNLOCK(sc); in rt2860_init()
2306 rt2860_set_macaddr(sc, ic->ic_macaddr); in rt2860_init()
2310 if (sc->txpow20mhz[ridx] == 0xffffffff) in rt2860_init()
2312 RT2860_WRITE(sc, RT2860_TX_PWR_CFG(ridx), sc->txpow20mhz[ridx]); in rt2860_init()
2316 tmp = RT2860_READ(sc, RT2860_WPDMA_GLO_CFG); in rt2860_init()
2324 rt2860_stop(sc); in rt2860_init()
2328 RT2860_WRITE(sc, RT2860_WPDMA_GLO_CFG, tmp | RT2860_TX_WB_DDONE); in rt2860_init()
2331 RT2860_WRITE(sc, RT2860_WPDMA_RST_IDX, 0x1003f); in rt2860_init()
2334 RT2860_WRITE(sc, RT2860_SYS_CTRL, 0xe1f); in rt2860_init()
2335 RT2860_WRITE(sc, RT2860_SYS_CTRL, 0xe00); in rt2860_init()
2337 RT2860_WRITE(sc, RT2860_MAC_SYS_CTRL, in rt2860_init()
2339 RT2860_WRITE(sc, RT2860_MAC_SYS_CTRL, 0); in rt2860_init()
2342 RT2860_WRITE(sc, rt2860_def_mac[i].reg, rt2860_def_mac[i].val); in rt2860_init()
2346 if (!(RT2860_READ(sc, RT2860_MAC_STATUS_REG) & in rt2860_init()
2354 rt2860_stop(sc); in rt2860_init()
2359 RT2860_WRITE(sc, RT2860_H2M_BBPAGENT, 0); in rt2860_init()
2360 RT2860_WRITE(sc, RT2860_H2M_MAILBOX, 0); in rt2860_init()
2362 if ((err = rt2860_bbp_init(sc)) != 0) { in rt2860_init()
2363 rt2860_stop(sc); in rt2860_init()
2369 RT2860_WRITE(sc, RT2860_TX_BASE_PTR(qid), sc->txq[qid].paddr); in rt2860_init()
2370 RT2860_WRITE(sc, RT2860_TX_MAX_CNT(qid), RT2860_TX_RING_COUNT); in rt2860_init()
2371 RT2860_WRITE(sc, RT2860_TX_CTX_IDX(qid), 0); in rt2860_init()
2375 RT2860_WRITE(sc, RT2860_RX_BASE_PTR, sc->rxq.paddr); in rt2860_init()
2376 RT2860_WRITE(sc, RT2860_RX_MAX_CNT, RT2860_RX_RING_COUNT); in rt2860_init()
2377 RT2860_WRITE(sc, RT2860_RX_CALC_IDX, RT2860_RX_RING_COUNT - 1); in rt2860_init()
2380 RT2860_WRITE(sc, RT2860_MAX_LEN_CFG, 1 << 12 | in rt2860_init()
2381 (sc->sc_dmabuf_size - sizeof (struct rt2860_rxwi) - 2)); in rt2860_init()
2384 tmp = RT2860_READ(sc, RT2860_WPDMA_GLO_CFG); in rt2860_init()
2392 rt2860_stop(sc); in rt2860_init()
2396 RT2860_WRITE(sc, RT2860_WPDMA_GLO_CFG, tmp | RT2860_TX_WB_DDONE); in rt2860_init()
2399 RT2860_WRITE(sc, RT2860_DELAY_INT_CFG, 0); in rt2860_init()
2403 if (sc->bbp[i].reg == 0 || sc->bbp[i].reg == 0xff) in rt2860_init()
2405 rt2860_mcu_bbp_write(sc, sc->bbp[i].reg, sc->bbp[i].val); in rt2860_init()
2409 (void) rt2860_mcu_cmd(sc, RT2860_MCU_CMD_LED1, sc->led[0]); in rt2860_init()
2410 (void) rt2860_mcu_cmd(sc, RT2860_MCU_CMD_LED2, sc->led[1]); in rt2860_init()
2411 (void) rt2860_mcu_cmd(sc, RT2860_MCU_CMD_LED3, sc->led[2]); in rt2860_init()
2414 bbp3 = rt2860_mcu_bbp_read(sc, 3); in rt2860_init()
2416 if (sc->nrxchains == 2) in rt2860_init()
2418 else if (sc->nrxchains == 3) in rt2860_init()
2420 rt2860_mcu_bbp_write(sc, 3, bbp3); in rt2860_init()
2423 bbp1 = rt2860_mcu_bbp_read(sc, 1); in rt2860_init()
2424 if (sc->ntxchains == 1) in rt2860_init()
2426 rt2860_mcu_bbp_write(sc, 1, bbp1); in rt2860_init()
2429 rt2860_set_chan(sc, ic->ic_curchan); in rt2860_init()
2432 (void) rt2860_mcu_cmd(sc, RT2860_MCU_CMD_BOOT, 0); in rt2860_init()
2435 tmp = RT2860_READ(sc, RT2860_TX_RTS_CFG); in rt2860_init()
2440 sc->sc_ic_flags = ic->ic_flags; in rt2860_init()
2444 RT2860_WRITE(sc, RT2860_MAC_SYS_CTRL, RT2860_MAC_TX_EN); in rt2860_init()
2446 tmp = RT2860_READ(sc, RT2860_WPDMA_GLO_CFG); in rt2860_init()
2454 rt2860_stop(sc); in rt2860_init()
2462 RT2860_WRITE(sc, RT2860_WPDMA_GLO_CFG, tmp); in rt2860_init()
2465 rt2860_set_leds(sc, RT2860_LED_RADIO); in rt2860_init()
2477 RT2860_WRITE(sc, RT2860_RX_FILTR_CFG, tmp); in rt2860_init()
2479 RT2860_WRITE(sc, RT2860_MAC_SYS_CTRL, in rt2860_init()
2483 RT2860_WRITE(sc, RT2860_INT_STATUS, 0xffffffff); in rt2860_init()
2485 RT2860_WRITE(sc, RT2860_INT_MASK, 0x3fffc); in rt2860_init()
2487 if (sc->sc_flags & RT2860_ADVANCED_PS) in rt2860_init()
2488 (void) rt2860_mcu_cmd(sc, RT2860_MCU_CMD_PSLEVEL, sc->pslevel); in rt2860_init()
2496 struct rt2860_softc *sc; in rt2860_quiesce() local
2498 sc = ddi_get_soft_state(rt2860_soft_state_p, ddi_get_instance(dip)); in rt2860_quiesce()
2499 if (sc == NULL) in rt2860_quiesce()
2509 sc->sc_flags |= RT2860_F_QUIESCE; in rt2860_quiesce()
2514 rt2860_stop(sc); in rt2860_quiesce()
2519 rt2860_stop(struct rt2860_softc *sc) in rt2860_stop() argument
2525 if (!(sc->sc_flags & RT2860_F_QUIESCE)) in rt2860_stop()
2526 RT2860_GLOCK(sc); in rt2860_stop()
2527 if (sc->sc_flags == RT2860_F_RUNNING) in rt2860_stop()
2528 rt2860_set_leds(sc, 0); /* turn all LEDs off */ in rt2860_stop()
2529 sc->sc_tx_timer = 0; in rt2860_stop()
2531 if (!(sc->sc_flags & RT2860_F_QUIESCE)) in rt2860_stop()
2532 RT2860_GUNLOCK(sc); in rt2860_stop()
2535 rt2860_set_region_4(sc, RT2860_WCID_ENTRY(0), 0, 512); in rt2860_stop()
2537 rt2860_set_region_4(sc, RT2860_PKEY(0), 0, 2048); in rt2860_stop()
2539 rt2860_set_region_4(sc, RT2860_IVEIV(0), 0, 512); in rt2860_stop()
2541 rt2860_set_region_4(sc, RT2860_WCID_ATTR(0), 0, 256); in rt2860_stop()
2543 rt2860_set_region_4(sc, RT2860_SKEY(0, 0), 0, 8 * 32); in rt2860_stop()
2545 rt2860_set_region_4(sc, RT2860_SKEY_MODE_0_7, 0, 4); in rt2860_stop()
2548 RT2860_WRITE(sc, RT2860_INT_MASK, 0); in rt2860_stop()
2551 tmp = RT2860_READ(sc, RT2860_MAC_SYS_CTRL); in rt2860_stop()
2553 RT2860_WRITE(sc, RT2860_MAC_SYS_CTRL, tmp); in rt2860_stop()
2556 RT2860_WRITE(sc, RT2860_MAC_SYS_CTRL, in rt2860_stop()
2558 RT2860_WRITE(sc, RT2860_MAC_SYS_CTRL, 0); in rt2860_stop()
2562 rt2860_reset_tx_ring(sc, &sc->txq[qid]); in rt2860_stop()
2563 rt2860_reset_rx_ring(sc, &sc->rxq); in rt2860_stop()
2566 if (!(sc->sc_flags & RT2860_F_QUIESCE)) in rt2860_stop()
2567 RT2860_GLOCK(sc); in rt2860_stop()
2568 sc->sc_flags &= ~RT2860_UPD_BEACON; in rt2860_stop()
2570 if (!(sc->sc_flags & RT2860_F_QUIESCE)) in rt2860_stop()
2571 RT2860_GUNLOCK(sc); in rt2860_stop()
2577 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_m_start() local
2578 struct ieee80211com *ic = &sc->sc_ic; in rt2860_m_start()
2581 err = rt2860_init(sc); in rt2860_m_start()
2590 RT2860_GLOCK(sc); in rt2860_m_start()
2591 sc->sc_flags |= RT2860_F_RUNNING; in rt2860_m_start()
2592 RT2860_GUNLOCK(sc); in rt2860_m_start()
2596 rt2860_stop(sc); in rt2860_m_start()
2603 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_m_stop() local
2605 (void) rt2860_stop(sc); in rt2860_m_stop()
2607 ieee80211_new_state(&sc->sc_ic, IEEE80211_S_INIT, -1); in rt2860_m_stop()
2609 RT2860_GLOCK(sc); in rt2860_m_stop()
2610 sc->sc_flags &= ~RT2860_F_RUNNING; in rt2860_m_stop()
2611 RT2860_GUNLOCK(sc); in rt2860_m_stop()
2617 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_m_ioctl() local
2618 struct ieee80211com *ic = &sc->sc_ic; in rt2860_m_ioctl()
2622 RT2860_GLOCK(sc); in rt2860_m_ioctl()
2625 if (RT2860_IS_RUNNING(sc)) { in rt2860_m_ioctl()
2626 RT2860_GUNLOCK(sc); in rt2860_m_ioctl()
2627 (void) rt2860_init(sc); in rt2860_m_ioctl()
2630 RT2860_GLOCK(sc); in rt2860_m_ioctl()
2634 RT2860_GUNLOCK(sc); in rt2860_m_ioctl()
2644 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_m_getprop() local
2647 err = ieee80211_getprop(&sc->sc_ic, pr_name, wldp_pr_num, in rt2860_m_getprop()
2657 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_m_propinfo() local
2659 ieee80211_propinfo(&sc->sc_ic, pr_name, wldp_pr_num, prh); in rt2860_m_propinfo()
2666 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_m_setprop() local
2667 ieee80211com_t *ic = &sc->sc_ic; in rt2860_m_setprop()
2672 RT2860_GLOCK(sc); in rt2860_m_setprop()
2675 if (RT2860_IS_RUNNING(sc)) { in rt2860_m_setprop()
2676 RT2860_GUNLOCK(sc); in rt2860_m_setprop()
2677 (void) rt2860_init(sc); in rt2860_m_setprop()
2680 RT2860_GLOCK(sc); in rt2860_m_setprop()
2685 RT2860_GUNLOCK(sc); in rt2860_m_setprop()
2692 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_m_tx() local
2693 struct ieee80211com *ic = &sc->sc_ic; in rt2860_m_tx()
2696 if (RT2860_IS_SUSPEND(sc)) { in rt2860_m_tx()
2750 struct rt2860_softc *sc = (struct rt2860_softc *)arg; in rt2860_m_stat() local
2751 ieee80211com_t *ic = &sc->sc_ic; in rt2860_m_stat()
2755 RT2860_GLOCK(sc); in rt2860_m_stat()
2763 *val = sc->sc_tx_nobuf; in rt2860_m_stat()
2766 *val = sc->sc_rx_nobuf; in rt2860_m_stat()
2769 *val = sc->sc_rx_err; in rt2860_m_stat()
2785 *val = sc->sc_tx_err; in rt2860_m_stat()
2788 *val = sc->sc_tx_retries; in rt2860_m_stat()
2800 RT2860_GUNLOCK(sc); in rt2860_m_stat()
2803 RT2860_GUNLOCK(sc); in rt2860_m_stat()
2806 RT2860_GUNLOCK(sc); in rt2860_m_stat()
2814 struct rt2860_softc *sc; in rt2860_attach() local
2827 sc = ddi_get_soft_state(rt2860_soft_state_p, in rt2860_attach()
2829 ASSERT(sc != NULL); in rt2860_attach()
2830 RT2860_GLOCK(sc); in rt2860_attach()
2831 sc->sc_flags &= ~RT2860_F_SUSPEND; in rt2860_attach()
2832 RT2860_GUNLOCK(sc); in rt2860_attach()
2833 if (RT2860_IS_RUNNING(sc)) in rt2860_attach()
2834 (void) rt2860_init(sc); in rt2860_attach()
2851 sc = ddi_get_soft_state(rt2860_soft_state_p, instance); in rt2860_attach()
2852 ic = (ieee80211com_t *)&sc->sc_ic; in rt2860_attach()
2853 sc->sc_dev = devinfo; in rt2860_attach()
2856 err = ddi_regs_map_setup(devinfo, 0, &sc->sc_cfg_base, 0, 0, in rt2860_attach()
2857 &rwn_csr_accattr, &sc->sc_cfg_handle); in rt2860_attach()
2864 cachelsz = ddi_get8(sc->sc_cfg_handle, in rt2860_attach()
2865 (uint8_t *)(sc->sc_cfg_base + PCI_CONF_CACHE_LINESZ)); in rt2860_attach()
2868 sc->sc_cachelsz = cachelsz << 2; in rt2860_attach()
2869 sc->sc_dmabuf_size = roundup(IEEE80211_MAX_LEN, sc->sc_cachelsz); in rt2860_attach()
2871 vendor_id = ddi_get16(sc->sc_cfg_handle, in rt2860_attach()
2872 (uint16_t *)((uintptr_t)(sc->sc_cfg_base) + PCI_CONF_VENID)); in rt2860_attach()
2873 device_id = ddi_get16(sc->sc_cfg_handle, in rt2860_attach()
2874 (uint16_t *)((uintptr_t)(sc->sc_cfg_base) + PCI_CONF_DEVID)); in rt2860_attach()
2884 ddi_put16(sc->sc_cfg_handle, in rt2860_attach()
2885 (uint16_t *)((uintptr_t)(sc->sc_cfg_base) + PCI_CONF_COMM), in rt2860_attach()
2887 ddi_put8(sc->sc_cfg_handle, in rt2860_attach()
2888 (uint8_t *)(sc->sc_cfg_base + PCI_CONF_LATENCY_TIMER), 0xa8); in rt2860_attach()
2889 ddi_put8(sc->sc_cfg_handle, in rt2860_attach()
2890 (uint8_t *)(sc->sc_cfg_base + PCI_CONF_ILINE), 0x10); in rt2860_attach()
2894 &sc->sc_io_base, 0, 0, &rwn_csr_accattr, &sc->sc_io_handle); in rt2860_attach()
2903 sc->amrr.amrr_min_success_threshold = 1; in rt2860_attach()
2904 sc->amrr.amrr_max_success_threshold = 15; in rt2860_attach()
2908 sc->mac_rev = RT2860_READ(sc, RT2860_ASIC_VER_ID); in rt2860_attach()
2909 if (sc->mac_rev != 0 && sc->mac_rev != 0xffffffff) in rt2860_attach()
2919 if ((sc->mac_rev >> 16) != 0x2860 && in rt2860_attach()
2923 sc->sc_flags |= RT2860_ADVANCED_PS; in rt2860_attach()
2926 (void) rt2860_read_eeprom(sc); in rt2860_attach()
2929 sc->mac_rev >> 16, sc->mac_rev & 0xffff, in rt2860_attach()
2930 rt2860_get_rf(sc->rf_rev), sc->ntxchains, sc->nrxchains); in rt2860_attach()
2936 if ((err = rt2860_alloc_tx_ring(sc, &sc->txq[qid])) != 0) { in rt2860_attach()
2943 if ((err = rt2860_alloc_rx_ring(sc, &sc->rxq)) != 0) { in rt2860_attach()
2949 if ((err = rt2860_alloc_tx_pool(sc)) != 0) { in rt2860_attach()
2955 mutex_init(&sc->sc_genlock, NULL, MUTEX_DRIVER, NULL); in rt2860_attach()
2956 mutex_init(&sc->sc_txlock, NULL, MUTEX_DRIVER, NULL); in rt2860_attach()
2957 mutex_init(&sc->sc_rxlock, NULL, MUTEX_DRIVER, NULL); in rt2860_attach()
2960 sc->mgtqid = (sc->mac_rev == 0x28600100) ? EDCA_AC_VO : 5; in rt2860_attach()
2962 "mgtqid = %x\n", sc->mgtqid); in rt2860_attach()
3000 sc->sc_newstate = ic->ic_newstate; in rt2860_attach()
3006 &sc->sc_softintr_hdl, NULL, 0, rt2860_softintr, (caddr_t)sc); in rt2860_attach()
3013 err = ddi_get_iblock_cookie(devinfo, 0, &sc->sc_iblock); in rt2860_attach()
3020 err = ddi_add_intr(devinfo, 0, NULL, NULL, rt2860_intr, (caddr_t)sc); in rt2860_attach()
3042 macp->m_driver = sc; in rt2860_attach()
3072 sc->sc_flags &= ~RT2860_F_RUNNING; in rt2860_attach()
3077 ddi_remove_softintr(sc->sc_softintr_hdl); in rt2860_attach()
3079 ddi_remove_intr(devinfo, 0, sc->sc_iblock); in rt2860_attach()
3081 mutex_destroy(&sc->sc_genlock); in rt2860_attach()
3082 mutex_destroy(&sc->sc_txlock); in rt2860_attach()
3083 mutex_destroy(&sc->sc_rxlock); in rt2860_attach()
3085 rt2860_free_tx_pool(sc); in rt2860_attach()
3087 rt2860_free_rx_ring(sc, &sc->rxq); in rt2860_attach()
3090 rt2860_free_tx_ring(sc, &sc->txq[qid]); in rt2860_attach()
3092 ddi_regs_map_free(&sc->sc_io_handle); in rt2860_attach()
3094 ddi_regs_map_free(&sc->sc_cfg_handle); in rt2860_attach()
3102 struct rt2860_softc *sc; in rt2860_detach() local
3105 sc = ddi_get_soft_state(rt2860_soft_state_p, ddi_get_instance(devinfo)); in rt2860_detach()
3111 if (RT2860_IS_RUNNING(sc)) in rt2860_detach()
3112 rt2860_stop(sc); in rt2860_detach()
3113 RT2860_GLOCK(sc); in rt2860_detach()
3114 sc->sc_flags &= ~RT2860_FWLOADED; in rt2860_detach()
3115 sc->sc_flags |= RT2860_F_SUSPEND; in rt2860_detach()
3116 RT2860_GUNLOCK(sc); in rt2860_detach()
3124 if (mac_disable(sc->sc_ic.ic_mach) != 0) in rt2860_detach()
3127 rt2860_stop(sc); in rt2860_detach()
3132 (void) mac_unregister(sc->sc_ic.ic_mach); in rt2860_detach()
3134 ddi_remove_intr(devinfo, 0, sc->sc_iblock); in rt2860_detach()
3135 ddi_remove_softintr(sc->sc_softintr_hdl); in rt2860_detach()
3140 ieee80211_detach(&sc->sc_ic); in rt2860_detach()
3142 rt2860_free_tx_pool(sc); in rt2860_detach()
3143 rt2860_free_rx_ring(sc, &sc->rxq); in rt2860_detach()
3145 rt2860_free_tx_ring(sc, &sc->txq[qid]); in rt2860_detach()
3147 ddi_regs_map_free(&sc->sc_io_handle); in rt2860_detach()
3149 mutex_destroy(&sc->sc_genlock); in rt2860_detach()
3150 mutex_destroy(&sc->sc_txlock); in rt2860_detach()
3151 mutex_destroy(&sc->sc_rxlock); in rt2860_detach()