Lines Matching refs:sc

213 rt2560_set_basicrates(struct rt2560_softc *sc)  in rt2560_set_basicrates()  argument
215 struct ieee80211com *ic = &sc->sc_ic; in rt2560_set_basicrates()
220 RAL_WRITE(sc, RT2560_ARSP_PLCP_1, 0x3); in rt2560_set_basicrates()
223 RAL_WRITE(sc, RT2560_ARSP_PLCP_1, 0x150); in rt2560_set_basicrates()
226 RAL_WRITE(sc, RT2560_ARSP_PLCP_1, 0x15f); in rt2560_set_basicrates()
231 rt2560_update_led(struct rt2560_softc *sc, int led1, int led2) in rt2560_update_led() argument
237 RAL_WRITE(sc, RT2560_LEDCSR, tmp); in rt2560_update_led()
241 rt2560_set_bssid(struct rt2560_softc *sc, uint8_t *bssid) in rt2560_set_bssid() argument
246 RAL_WRITE(sc, RT2560_CSR5, tmp); in rt2560_set_bssid()
249 RAL_WRITE(sc, RT2560_CSR6, tmp); in rt2560_set_bssid()
256 rt2560_bbp_write(struct rt2560_softc *sc, uint8_t reg, uint8_t val) in rt2560_bbp_write() argument
262 if (!(RAL_READ(sc, RT2560_BBPCSR) & RT2560_BBP_BUSY)) in rt2560_bbp_write()
272 RAL_WRITE(sc, RT2560_BBPCSR, tmp); in rt2560_bbp_write()
278 rt2560_bbp_read(struct rt2560_softc *sc, uint8_t reg) in rt2560_bbp_read() argument
284 RAL_WRITE(sc, RT2560_BBPCSR, val); in rt2560_bbp_read()
287 val = RAL_READ(sc, RT2560_BBPCSR); in rt2560_bbp_read()
298 rt2560_rf_write(struct rt2560_softc *sc, uint8_t reg, uint32_t val) in rt2560_rf_write() argument
304 if (!(RAL_READ(sc, RT2560_RFCSR) & RT2560_RF_BUSY)) in rt2560_rf_write()
315 RAL_WRITE(sc, RT2560_RFCSR, tmp); in rt2560_rf_write()
318 sc->rf_regs[reg] = val; in rt2560_rf_write()
324 rt2560_set_chan(struct rt2560_softc *sc, struct ieee80211_channel *c) in rt2560_set_chan() argument
326 struct ieee80211com *ic = &sc->sc_ic; in rt2560_set_chan()
335 power = min(sc->txpow[chan - 1], 31); in rt2560_set_chan()
345 switch (sc->rf_rev) { in rt2560_set_chan()
347 rt2560_rf_write(sc, RAL_RF1, 0x00814); in rt2560_set_chan()
348 rt2560_rf_write(sc, RAL_RF2, rt2560_rf2522_r2[chan - 1]); in rt2560_set_chan()
349 rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x00040); in rt2560_set_chan()
353 rt2560_rf_write(sc, RAL_RF1, 0x08804); in rt2560_set_chan()
354 rt2560_rf_write(sc, RAL_RF2, rt2560_rf2523_r2[chan - 1]); in rt2560_set_chan()
355 rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x38044); in rt2560_set_chan()
356 rt2560_rf_write(sc, RAL_RF4, (chan == 14) ? 0x00280 : 0x00286); in rt2560_set_chan()
360 rt2560_rf_write(sc, RAL_RF1, 0x0c808); in rt2560_set_chan()
361 rt2560_rf_write(sc, RAL_RF2, rt2560_rf2524_r2[chan - 1]); in rt2560_set_chan()
362 rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x00040); in rt2560_set_chan()
363 rt2560_rf_write(sc, RAL_RF4, (chan == 14) ? 0x00280 : 0x00286); in rt2560_set_chan()
367 rt2560_rf_write(sc, RAL_RF1, 0x08808); in rt2560_set_chan()
368 rt2560_rf_write(sc, RAL_RF2, rt2560_rf2525_hi_r2[chan - 1]); in rt2560_set_chan()
369 rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x18044); in rt2560_set_chan()
370 rt2560_rf_write(sc, RAL_RF4, (chan == 14) ? 0x00280 : 0x00286); in rt2560_set_chan()
372 rt2560_rf_write(sc, RAL_RF1, 0x08808); in rt2560_set_chan()
373 rt2560_rf_write(sc, RAL_RF2, rt2560_rf2525_r2[chan - 1]); in rt2560_set_chan()
374 rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x18044); in rt2560_set_chan()
375 rt2560_rf_write(sc, RAL_RF4, (chan == 14) ? 0x00280 : 0x00286); in rt2560_set_chan()
379 rt2560_rf_write(sc, RAL_RF1, 0x08808); in rt2560_set_chan()
380 rt2560_rf_write(sc, RAL_RF2, rt2560_rf2525e_r2[chan - 1]); in rt2560_set_chan()
381 rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x18044); in rt2560_set_chan()
382 rt2560_rf_write(sc, RAL_RF4, (chan == 14) ? 0x00286 : 0x00282); in rt2560_set_chan()
386 rt2560_rf_write(sc, RAL_RF2, rt2560_rf2526_hi_r2[chan - 1]); in rt2560_set_chan()
387 rt2560_rf_write(sc, RAL_RF4, (chan & 1) ? 0x00386 : 0x00381); in rt2560_set_chan()
388 rt2560_rf_write(sc, RAL_RF1, 0x08804); in rt2560_set_chan()
390 rt2560_rf_write(sc, RAL_RF2, rt2560_rf2526_r2[chan - 1]); in rt2560_set_chan()
391 rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x18044); in rt2560_set_chan()
392 rt2560_rf_write(sc, RAL_RF4, (chan & 1) ? 0x00386 : 0x00381); in rt2560_set_chan()
400 rt2560_rf_write(sc, RAL_RF1, rt2560_rf5222[i].r1); in rt2560_set_chan()
401 rt2560_rf_write(sc, RAL_RF2, rt2560_rf5222[i].r2); in rt2560_set_chan()
402 rt2560_rf_write(sc, RAL_RF3, power << 7 | 0x00040); in rt2560_set_chan()
403 rt2560_rf_write(sc, RAL_RF4, rt2560_rf5222[i].r4); in rt2560_set_chan()
409 tmp = rt2560_bbp_read(sc, 70); in rt2560_set_chan()
415 rt2560_bbp_write(sc, 70, tmp); in rt2560_set_chan()
418 (void) RAL_READ(sc, RT2560_CNT0); in rt2560_set_chan()
427 rt2560_enable_tsf_sync(struct rt2560_softc *sc) in rt2560_enable_tsf_sync() argument
429 struct ieee80211com *ic = &sc->sc_ic; in rt2560_enable_tsf_sync()
434 RAL_WRITE(sc, RT2560_CSR14, 0); in rt2560_enable_tsf_sync()
437 RAL_WRITE(sc, RT2560_CSR12, tmp); in rt2560_enable_tsf_sync()
439 RAL_WRITE(sc, RT2560_CSR13, 0); in rt2560_enable_tsf_sync()
444 RAL_WRITE(sc, RT2560_BCNOCSR, tmp); in rt2560_enable_tsf_sync()
453 RAL_WRITE(sc, RT2560_CSR14, tmp); in rt2560_enable_tsf_sync()
459 rt2560_update_plcp(struct rt2560_softc *sc) in rt2560_update_plcp() argument
461 struct ieee80211com *ic = &sc->sc_ic; in rt2560_update_plcp()
464 RAL_WRITE(sc, RT2560_PLCP1MCSR, 0x00700400); in rt2560_update_plcp()
468 RAL_WRITE(sc, RT2560_PLCP2MCSR, 0x00380401); in rt2560_update_plcp()
469 RAL_WRITE(sc, RT2560_PLCP5p5MCSR, 0x00150402); in rt2560_update_plcp()
470 RAL_WRITE(sc, RT2560_PLCP11MCSR, 0x000b8403); in rt2560_update_plcp()
473 RAL_WRITE(sc, RT2560_PLCP2MCSR, 0x00380409); in rt2560_update_plcp()
474 RAL_WRITE(sc, RT2560_PLCP5p5MCSR, 0x0015040a); in rt2560_update_plcp()
475 RAL_WRITE(sc, RT2560_PLCP11MCSR, 0x000b840b); in rt2560_update_plcp()
489 struct rt2560_softc *sc = (struct rt2560_softc *)ic; in rt2560_update_slot() local
503 tmp = RAL_READ(sc, RT2560_CSR11); in rt2560_update_slot()
505 RAL_WRITE(sc, RT2560_CSR11, tmp); in rt2560_update_slot()
508 RAL_WRITE(sc, RT2560_CSR18, tmp); in rt2560_update_slot()
511 RAL_WRITE(sc, RT2560_CSR19, tmp); in rt2560_update_slot()
517 ral_dma_region_alloc(struct rt2560_softc *sc, struct dma_region *dr, in ral_dma_region_alloc() argument
520 dev_info_t *dip = sc->sc_dev; in ral_dma_region_alloc()
562 ral_dma_region_free(struct rt2560_softc *sc, struct dma_region *dr) in ral_dma_region_free() argument
570 rt2560_alloc_tx_ring(struct rt2560_softc *sc, struct rt2560_tx_ring *ring, in rt2560_alloc_tx_ring() argument
586 err = ral_dma_region_alloc(sc, &ring->dr_desc, in rt2560_alloc_tx_ring()
593 size = roundup(RAL_TXBUF_SIZE, sc->sc_cachelsz); in rt2560_alloc_tx_ring()
595 err = ral_dma_region_alloc(sc, &ring->dr_txbuf[i], size, in rt2560_alloc_tx_ring()
599 ral_dma_region_free(sc, &ring->dr_txbuf[i]); in rt2560_alloc_tx_ring()
616 ral_dma_region_free(sc, &ring->dr_desc); in rt2560_alloc_tx_ring()
623 rt2560_reset_tx_ring(struct rt2560_softc *sc, struct rt2560_tx_ring *ring) in rt2560_reset_tx_ring() argument
650 rt2560_free_tx_ring(struct rt2560_softc *sc, struct rt2560_tx_ring *ring) in rt2560_free_tx_ring() argument
655 ral_dma_region_free(sc, &ring->dr_desc); in rt2560_free_tx_ring()
664 ral_dma_region_free(sc, &ring->dr_txbuf[i]); in rt2560_free_tx_ring()
672 rt2560_ring_hwsetup(struct rt2560_softc *sc) in rt2560_ring_hwsetup() argument
683 RAL_WRITE(sc, RT2560_TXCSR2, tmp); in rt2560_ring_hwsetup()
684 RAL_WRITE(sc, RT2560_TXCSR3, sc->txq.physaddr); in rt2560_ring_hwsetup()
685 RAL_WRITE(sc, RT2560_TXCSR5, sc->prioq.physaddr); in rt2560_ring_hwsetup()
690 RAL_WRITE(sc, RT2560_RXCSR1, tmp); in rt2560_ring_hwsetup()
691 RAL_WRITE(sc, RT2560_RXCSR2, sc->rxq.physaddr); in rt2560_ring_hwsetup()
695 rt2560_alloc_rx_ring(struct rt2560_softc *sc, struct rt2560_rx_ring *ring, in rt2560_alloc_rx_ring() argument
712 err = ral_dma_region_alloc(sc, &ring->dr_desc, in rt2560_alloc_rx_ring()
719 size = roundup(RAL_RXBUF_SIZE, sc->sc_cachelsz); in rt2560_alloc_rx_ring()
721 err = ral_dma_region_alloc(sc, &ring->dr_rxbuf[i], size, in rt2560_alloc_rx_ring()
725 ral_dma_region_free(sc, &ring->dr_rxbuf[i]); in rt2560_alloc_rx_ring()
747 ral_dma_region_free(sc, &ring->dr_desc); in rt2560_alloc_rx_ring()
754 rt2560_reset_rx_ring(struct rt2560_softc *sc, struct rt2560_rx_ring *ring) in rt2560_reset_rx_ring() argument
772 rt2560_free_rx_ring(struct rt2560_softc *sc, struct rt2560_rx_ring *ring) in rt2560_free_rx_ring() argument
776 ral_dma_region_free(sc, &ring->dr_desc); in rt2560_free_rx_ring()
779 ral_dma_region_free(sc, &ring->dr_rxbuf[i]); in rt2560_free_rx_ring()
813 struct rt2560_softc *sc = arg; in rt2560_next_scan() local
814 struct ieee80211com *ic = &sc->sc_ic; in rt2560_next_scan()
839 struct rt2560_softc *sc = arg; in rt2560_update_rssadapt() local
840 struct ieee80211com *ic = &sc->sc_ic; in rt2560_update_rssadapt()
843 sc->sc_rssadapt_id = timeout(rt2560_update_rssadapt, (void *)sc, in rt2560_update_rssadapt()
850 struct rt2560_softc *sc = arg; in rt2560_statedog() local
851 struct ieee80211com *ic = &sc->sc_ic; in rt2560_statedog()
854 RAL_LOCK(sc); in rt2560_statedog()
856 sc->sc_state_id = 0; in rt2560_statedog()
858 ic->ic_state = sc->sc_ostate; in rt2560_statedog()
860 RAL_UNLOCK(sc); in rt2560_statedog()
869 struct rt2560_softc *sc = (struct rt2560_softc *)ic; in rt2560_newstate() local
874 RAL_LOCK(sc); in rt2560_newstate()
877 sc->sc_ostate = ostate; in rt2560_newstate()
879 if (sc->sc_scan_id != 0) { in rt2560_newstate()
880 (void) untimeout(sc->sc_scan_id); in rt2560_newstate()
881 sc->sc_scan_id = 0; in rt2560_newstate()
884 if (sc->sc_rssadapt_id != 0) { in rt2560_newstate()
885 (void) untimeout(sc->sc_rssadapt_id); in rt2560_newstate()
886 sc->sc_rssadapt_id = 0; in rt2560_newstate()
889 if (sc->sc_state_id != 0) { in rt2560_newstate()
890 (void) untimeout(sc->sc_state_id); in rt2560_newstate()
891 sc->sc_state_id = 0; in rt2560_newstate()
898 RAL_WRITE(sc, RT2560_CSR14, 0); in rt2560_newstate()
900 rt2560_update_led(sc, 0, 0); in rt2560_newstate()
905 rt2560_set_chan(sc, ic->ic_curchan); in rt2560_newstate()
906 sc->sc_scan_id = timeout(rt2560_next_scan, (void *)sc, in rt2560_newstate()
907 drv_usectohz(sc->dwelltime * 1000)); in rt2560_newstate()
911 rt2560_set_chan(sc, ic->ic_curchan); in rt2560_newstate()
915 rt2560_set_chan(sc, ic->ic_curchan); in rt2560_newstate()
918 sc->sc_state_id = timeout(rt2560_statedog, (void *)sc, in rt2560_newstate()
923 rt2560_set_chan(sc, ic->ic_curchan); in rt2560_newstate()
928 rt2560_update_plcp(sc); in rt2560_newstate()
929 rt2560_set_basicrates(sc); in rt2560_newstate()
930 rt2560_set_bssid(sc, ni->in_bssid); in rt2560_newstate()
934 rt2560_update_led(sc, 1, 0); in rt2560_newstate()
936 sc->sc_rssadapt_id = timeout(rt2560_update_rssadapt, in rt2560_newstate()
937 (void *)sc, drv_usectohz(100 * 1000)); in rt2560_newstate()
938 rt2560_enable_tsf_sync(sc); in rt2560_newstate()
943 RAL_UNLOCK(sc); in rt2560_newstate()
945 err = sc->sc_newstate(ic, nstate, arg); in rt2560_newstate()
960 rt2560_eeprom_read(struct rt2560_softc *sc, uint8_t addr) in rt2560_eeprom_read() argument
967 RT2560_EEPROM_CTL(sc, 0); in rt2560_eeprom_read()
969 RT2560_EEPROM_CTL(sc, RT2560_S); in rt2560_eeprom_read()
970 RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_C); in rt2560_eeprom_read()
971 RT2560_EEPROM_CTL(sc, RT2560_S); in rt2560_eeprom_read()
974 RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_D); in rt2560_eeprom_read()
975 RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_D | RT2560_C); in rt2560_eeprom_read()
978 RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_D); in rt2560_eeprom_read()
979 RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_D | RT2560_C); in rt2560_eeprom_read()
980 RT2560_EEPROM_CTL(sc, RT2560_S); in rt2560_eeprom_read()
981 RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_C); in rt2560_eeprom_read()
984 n = (RAL_READ(sc, RT2560_CSR21) & RT2560_93C46) ? 5 : 7; in rt2560_eeprom_read()
986 RT2560_EEPROM_CTL(sc, RT2560_S | in rt2560_eeprom_read()
988 RT2560_EEPROM_CTL(sc, RT2560_S | in rt2560_eeprom_read()
992 RT2560_EEPROM_CTL(sc, RT2560_S); in rt2560_eeprom_read()
997 RT2560_EEPROM_CTL(sc, RT2560_S | RT2560_C); in rt2560_eeprom_read()
998 tmp = RAL_READ(sc, RT2560_CSR21); in rt2560_eeprom_read()
1000 RT2560_EEPROM_CTL(sc, RT2560_S); in rt2560_eeprom_read()
1003 RT2560_EEPROM_CTL(sc, 0); in rt2560_eeprom_read()
1006 RT2560_EEPROM_CTL(sc, RT2560_S); in rt2560_eeprom_read()
1007 RT2560_EEPROM_CTL(sc, 0); in rt2560_eeprom_read()
1008 RT2560_EEPROM_CTL(sc, RT2560_C); in rt2560_eeprom_read()
1014 rt2560_tx_intr(struct rt2560_softc *sc) in rt2560_tx_intr() argument
1016 struct ieee80211com *ic = &sc->sc_ic; in rt2560_tx_intr()
1024 dr = &sc->txq.dr_desc; in rt2560_tx_intr()
1025 count = sc->txq.count; in rt2560_tx_intr()
1030 mutex_enter(&sc->txq.tx_lock); in rt2560_tx_intr()
1033 desc = &sc->txq.desc[sc->txq.next]; in rt2560_tx_intr()
1034 data = &sc->txq.data[sc->txq.next]; in rt2560_tx_intr()
1056 sc->sc_tx_retries++; in rt2560_tx_intr()
1082 ral_debug(RAL_DBG_INTR, "tx done idx=%u\n", sc->txq.next); in rt2560_tx_intr()
1084 sc->txq.queued--; in rt2560_tx_intr()
1085 sc->txq.next = (sc->txq.next + 1) % RT2560_TX_RING_COUNT; in rt2560_tx_intr()
1087 if (sc->sc_need_sched && in rt2560_tx_intr()
1088 sc->txq.queued < (RT2560_TX_RING_COUNT - 32)) { in rt2560_tx_intr()
1089 sc->sc_need_sched = 0; in rt2560_tx_intr()
1097 sc->sc_tx_timer = 0; in rt2560_tx_intr()
1098 mutex_exit(&sc->txq.tx_lock); in rt2560_tx_intr()
1102 rt2560_prio_intr(struct rt2560_softc *sc) in rt2560_prio_intr() argument
1110 dr = &sc->prioq.dr_desc; in rt2560_prio_intr()
1111 count = sc->prioq.count; in rt2560_prio_intr()
1116 mutex_enter(&sc->prioq.tx_lock); in rt2560_prio_intr()
1119 desc = &sc->prioq.desc[sc->prioq.next]; in rt2560_prio_intr()
1120 data = &sc->prioq.data[sc->prioq.next]; in rt2560_prio_intr()
1155 ral_debug(RAL_DBG_INTR, "prio done idx=%u\n", sc->prioq.next); in rt2560_prio_intr()
1157 sc->prioq.queued--; in rt2560_prio_intr()
1158 sc->prioq.next = (sc->prioq.next + 1) % RT2560_PRIO_RING_COUNT; in rt2560_prio_intr()
1164 sc->sc_tx_timer = 0; in rt2560_prio_intr()
1165 mutex_exit(&sc->prioq.tx_lock); in rt2560_prio_intr()
1173 rt2560_rx_intr(struct rt2560_softc *sc) in rt2560_rx_intr() argument
1175 struct ieee80211com *ic = &sc->sc_ic; in rt2560_rx_intr()
1189 dr = &sc->rxq.dr_desc; in rt2560_rx_intr()
1190 count = sc->rxq.count; in rt2560_rx_intr()
1192 mutex_enter(&sc->rxq.rx_lock); in rt2560_rx_intr()
1198 desc = &sc->rxq.desc[sc->rxq.cur]; in rt2560_rx_intr()
1199 data = &sc->rxq.data[sc->rxq.cur]; in rt2560_rx_intr()
1224 sc->sc_rx_err++; in rt2560_rx_intr()
1234 sc->sc_rx_err++; in rt2560_rx_intr()
1241 sc->sc_rx_nobuf++; in rt2560_rx_intr()
1245 dr_bf = &sc->rxq.dr_rxbuf[sc->rxq.cur]; in rt2560_rx_intr()
1266 ral_debug(RAL_DBG_RX, "rx done idx=%u\n", sc->rxq.cur); in rt2560_rx_intr()
1268 sc->rxq.cur = (sc->rxq.cur + 1) % RT2560_RX_RING_COUNT; in rt2560_rx_intr()
1270 mutex_exit(&sc->rxq.rx_lock); in rt2560_rx_intr()
1280 struct rt2560_softc *sc = (struct rt2560_softc *)data; in ral_softint_handler() local
1286 RAL_LOCK(sc); in ral_softint_handler()
1287 if (sc->sc_rx_pend) { in ral_softint_handler()
1288 sc->sc_rx_pend = 0; in ral_softint_handler()
1289 RAL_UNLOCK(sc); in ral_softint_handler()
1290 rt2560_rx_intr(sc); in ral_softint_handler()
1293 RAL_UNLOCK(sc); in ral_softint_handler()
1383 rt2560_setup_tx_desc(struct rt2560_softc *sc, struct rt2560_tx_desc *desc, in rt2560_setup_tx_desc() argument
1386 struct ieee80211com *ic = &sc->sc_ic; in rt2560_setup_tx_desc()
1430 struct rt2560_softc *sc = (struct rt2560_softc *)ic; in rt2560_mgmt_send() local
1447 mutex_enter(&sc->prioq.tx_lock); in rt2560_mgmt_send()
1449 if (!RAL_IS_RUNNING(sc)) { in rt2560_mgmt_send()
1454 if (sc->prioq.queued >= RT2560_PRIO_RING_COUNT) { in rt2560_mgmt_send()
1456 sc->sc_tx_nobuf++; in rt2560_mgmt_send()
1479 sc->sc_tx_err++; in rt2560_mgmt_send()
1488 sc->sc_tx_err++; in rt2560_mgmt_send()
1495 desc = &sc->prioq.desc[sc->prioq.cur]; in rt2560_mgmt_send()
1496 data = &sc->prioq.data[sc->prioq.cur]; in rt2560_mgmt_send()
1522 rt2560_setup_tx_desc(sc, desc, flags, pktlen, rate, 0); in rt2560_mgmt_send()
1524 idx = sc->prioq.cur; in rt2560_mgmt_send()
1526 dr = &sc->prioq.dr_txbuf[idx]; in rt2560_mgmt_send()
1529 dr = &sc->prioq.dr_desc; in rt2560_mgmt_send()
1534 pktlen, sc->prioq.cur, rate); in rt2560_mgmt_send()
1537 sc->prioq.queued++; /* IF > RT2560_PRIO_RING_COUNT? FULL */ in rt2560_mgmt_send()
1538 sc->prioq.cur = (sc->prioq.cur + 1) % RT2560_PRIO_RING_COUNT; in rt2560_mgmt_send()
1539 RAL_WRITE(sc, RT2560_TXCSR0, RT2560_KICK_PRIO); in rt2560_mgmt_send()
1541 sc->sc_tx_timer = 5; in rt2560_mgmt_send()
1552 mutex_exit(&sc->prioq.tx_lock); in rt2560_mgmt_send()
1560 struct rt2560_softc *sc = (struct rt2560_softc *)ic; in rt2560_send() local
1579 mutex_enter(&sc->txq.tx_lock); in rt2560_send()
1581 if (sc->txq.queued >= RT2560_TX_RING_COUNT - 1) { in rt2560_send()
1584 sc->sc_need_sched = 1; in rt2560_send()
1585 sc->sc_tx_nobuf++; in rt2560_send()
1609 sc->sc_tx_err++; in rt2560_send()
1618 sc->sc_tx_err++; in rt2560_send()
1632 data = &sc->txq.data[sc->txq.cur]; in rt2560_send()
1633 desc = &sc->txq.desc[sc->txq.cur]; in rt2560_send()
1676 rt2560_setup_tx_desc(sc, desc, flags, pktlen, rate, 0); in rt2560_send()
1678 idx = sc->txq.cur; in rt2560_send()
1680 dr = &sc->txq.dr_txbuf[idx]; in rt2560_send()
1683 dr = &sc->txq.dr_desc; in rt2560_send()
1688 pktlen, sc->txq.cur, rate); in rt2560_send()
1691 sc->txq.queued++; in rt2560_send()
1692 sc->txq.cur = (sc->txq.cur + 1) % RT2560_TX_RING_COUNT; in rt2560_send()
1693 RAL_WRITE(sc, RT2560_TXCSR0, RT2560_KICK_TX); in rt2560_send()
1695 sc->sc_tx_timer = 5; in rt2560_send()
1706 mutex_exit(&sc->txq.tx_lock); in rt2560_send()
1713 struct rt2560_softc *sc = (struct rt2560_softc *)arg; in rt2560_m_tx() local
1714 struct ieee80211com *ic = &sc->sc_ic; in rt2560_m_tx()
1717 if (!RAL_IS_RUNNING(sc)) { in rt2560_m_tx()
1747 rt2560_set_macaddr(struct rt2560_softc *sc, uint8_t *addr) in rt2560_set_macaddr() argument
1752 RAL_WRITE(sc, RT2560_CSR3, tmp); in rt2560_set_macaddr()
1755 RAL_WRITE(sc, RT2560_CSR4, tmp); in rt2560_set_macaddr()
1762 rt2560_get_macaddr(struct rt2560_softc *sc, uint8_t *addr) in rt2560_get_macaddr() argument
1766 tmp = RAL_READ(sc, RT2560_CSR3); in rt2560_get_macaddr()
1772 tmp = RAL_READ(sc, RT2560_CSR4); in rt2560_get_macaddr()
1778 rt2560_update_promisc(struct rt2560_softc *sc) in rt2560_update_promisc() argument
1782 tmp = RAL_READ(sc, RT2560_RXCSR0); in rt2560_update_promisc()
1784 if (!(sc->sc_rcr & RAL_RCR_PROMISC)) in rt2560_update_promisc()
1787 RAL_WRITE(sc, RT2560_RXCSR0, tmp); in rt2560_update_promisc()
1789 (sc->sc_rcr & RAL_RCR_PROMISC) ? "entering" : "leaving"); in rt2560_update_promisc()
1808 rt2560_read_eeprom(struct rt2560_softc *sc) in rt2560_read_eeprom() argument
1813 val = rt2560_eeprom_read(sc, RT2560_EEPROM_CONFIG0); in rt2560_read_eeprom()
1814 sc->rf_rev = (val >> 11) & 0x7; in rt2560_read_eeprom()
1815 sc->hw_radio = (val >> 10) & 0x1; in rt2560_read_eeprom()
1816 sc->led_mode = (val >> 6) & 0x7; in rt2560_read_eeprom()
1817 sc->rx_ant = (val >> 4) & 0x3; in rt2560_read_eeprom()
1818 sc->tx_ant = (val >> 2) & 0x3; in rt2560_read_eeprom()
1819 sc->nb_ant = val & 0x3; in rt2560_read_eeprom()
1823 val = rt2560_eeprom_read(sc, RT2560_EEPROM_BBP_BASE + i); in rt2560_read_eeprom()
1824 sc->bbp_prom[i].reg = val >> 8; in rt2560_read_eeprom()
1825 sc->bbp_prom[i].val = val & 0xff; in rt2560_read_eeprom()
1830 val = rt2560_eeprom_read(sc, RT2560_EEPROM_TXPOWER + i); in rt2560_read_eeprom()
1831 sc->txpow[i * 2] = val >> 8; in rt2560_read_eeprom()
1832 sc->txpow[i * 2 + 1] = val & 0xff; in rt2560_read_eeprom()
1837 rt2560_bbp_init(struct rt2560_softc *sc) in rt2560_bbp_init() argument
1844 if (rt2560_bbp_read(sc, RT2560_BBP_VERSION) != 0) in rt2560_bbp_init()
1854 rt2560_bbp_write(sc, rt2560_def_bbp[i].reg, in rt2560_bbp_init()
1863 rt2560_set_txantenna(struct rt2560_softc *sc, int antenna) in rt2560_set_txantenna() argument
1868 tx = rt2560_bbp_read(sc, RT2560_BBP_TX) & ~RT2560_BBP_ANTMASK; in rt2560_set_txantenna()
1877 if (sc->rf_rev == RT2560_RF_2525E || sc->rf_rev == RT2560_RF_2526 || in rt2560_set_txantenna()
1878 sc->rf_rev == RT2560_RF_5222) in rt2560_set_txantenna()
1881 rt2560_bbp_write(sc, RT2560_BBP_TX, tx); in rt2560_set_txantenna()
1884 tmp = RAL_READ(sc, RT2560_BBPCSR1) & ~0x00070007; in rt2560_set_txantenna()
1886 RAL_WRITE(sc, RT2560_BBPCSR1, tmp); in rt2560_set_txantenna()
1890 rt2560_set_rxantenna(struct rt2560_softc *sc, int antenna) in rt2560_set_rxantenna() argument
1894 rx = rt2560_bbp_read(sc, RT2560_BBP_RX) & ~RT2560_BBP_ANTMASK; in rt2560_set_rxantenna()
1903 if (sc->rf_rev == RT2560_RF_2525E || sc->rf_rev == RT2560_RF_2526) in rt2560_set_rxantenna()
1906 rt2560_bbp_write(sc, RT2560_BBP_RX, rx); in rt2560_set_rxantenna()
1910 rt2560_stop(struct rt2560_softc *sc) in rt2560_stop() argument
1912 struct ieee80211com *ic = &sc->sc_ic; in rt2560_stop()
1917 RAL_LOCK(sc); in rt2560_stop()
1918 sc->sc_tx_timer = 0; in rt2560_stop()
1921 RAL_WRITE(sc, RT2560_TXCSR0, RT2560_ABORT_TX); in rt2560_stop()
1924 RAL_WRITE(sc, RT2560_RXCSR0, RT2560_DISABLE_RX); in rt2560_stop()
1927 RAL_WRITE(sc, RT2560_CSR1, RT2560_RESET_ASIC); in rt2560_stop()
1928 RAL_WRITE(sc, RT2560_CSR1, 0); in rt2560_stop()
1931 RAL_WRITE(sc, RT2560_CSR8, 0xffffffff); in rt2560_stop()
1934 rt2560_reset_tx_ring(sc, &sc->txq); in rt2560_stop()
1935 rt2560_reset_tx_ring(sc, &sc->prioq); in rt2560_stop()
1936 rt2560_reset_rx_ring(sc, &sc->rxq); in rt2560_stop()
1937 RAL_UNLOCK(sc); in rt2560_stop()
1941 rt2560_init(struct rt2560_softc *sc) in rt2560_init() argument
1945 struct ieee80211com *ic = &sc->sc_ic; in rt2560_init()
1949 rt2560_stop(sc); in rt2560_init()
1951 RAL_LOCK(sc); in rt2560_init()
1953 rt2560_ring_hwsetup(sc); in rt2560_init()
1957 RAL_WRITE(sc, rt2560_def_mac[i].reg, rt2560_def_mac[i].val); in rt2560_init()
1959 rt2560_set_macaddr(sc, ic->ic_macaddr); in rt2560_init()
1962 RAL_WRITE(sc, RT2560_ARSP_PLCP_1, 0x153); in rt2560_init()
1964 rt2560_set_txantenna(sc, sc->tx_ant); in rt2560_init()
1965 rt2560_set_rxantenna(sc, sc->rx_ant); in rt2560_init()
1967 rt2560_update_plcp(sc); in rt2560_init()
1968 rt2560_update_led(sc, 0, 0); in rt2560_init()
1970 RAL_WRITE(sc, RT2560_CSR1, RT2560_RESET_ASIC); in rt2560_init()
1971 RAL_WRITE(sc, RT2560_CSR1, RT2560_HOST_READY); in rt2560_init()
1973 if (rt2560_bbp_init(sc) != 0) { in rt2560_init()
1974 RAL_UNLOCK(sc); in rt2560_init()
1975 rt2560_stop(sc); in rt2560_init()
1980 rt2560_set_chan(sc, ic->ic_curchan); in rt2560_init()
1988 if (!(sc->sc_rcr & RAL_RCR_PROMISC)) in rt2560_init()
1992 RAL_WRITE(sc, RT2560_RXCSR0, tmp); in rt2560_init()
1995 (void) RAL_READ(sc, RT2560_CNT0); in rt2560_init()
1996 (void) RAL_READ(sc, RT2560_CNT4); in rt2560_init()
1999 RAL_WRITE(sc, RT2560_CSR7, 0xffffffff); in rt2560_init()
2001 RAL_WRITE(sc, RT2560_CSR8, RT2560_INTR_MASK); in rt2560_init()
2003 RAL_UNLOCK(sc); in rt2560_init()
2011 struct rt2560_softc *sc = arg; in rt2560_watchdog() local
2012 struct ieee80211com *ic = &sc->sc_ic; in rt2560_watchdog()
2015 RAL_LOCK(sc); in rt2560_watchdog()
2018 if (!RAL_IS_RUNNING(sc)) { in rt2560_watchdog()
2019 RAL_UNLOCK(sc); in rt2560_watchdog()
2023 if (sc->sc_tx_timer > 0) { in rt2560_watchdog()
2024 if (--sc->sc_tx_timer == 0) { in rt2560_watchdog()
2026 RAL_UNLOCK(sc); in rt2560_watchdog()
2027 (void) rt2560_init(sc); in rt2560_watchdog()
2036 RAL_UNLOCK(sc); in rt2560_watchdog()
2047 struct rt2560_softc *sc = (struct rt2560_softc *)arg; in rt2560_m_start() local
2053 err = rt2560_init(sc); in rt2560_m_start()
2058 sc->sc_flags |= RAL_FLAG_RUNNING; /* RUNNING */ in rt2560_m_start()
2062 rt2560_stop(sc); in rt2560_m_start()
2069 struct rt2560_softc *sc = (struct rt2560_softc *)arg; in rt2560_m_stop() local
2071 (void) rt2560_stop(sc); in rt2560_m_stop()
2072 sc->sc_flags &= ~RAL_FLAG_RUNNING; /* STOP */ in rt2560_m_stop()
2078 struct rt2560_softc *sc = (struct rt2560_softc *)arg; in rt2560_m_unicst() local
2079 struct ieee80211com *ic = &sc->sc_ic; in rt2560_m_unicst()
2085 (void) rt2560_set_macaddr(sc, (uint8_t *)macaddr); in rt2560_m_unicst()
2086 (void) rt2560_init(sc); in rt2560_m_unicst()
2101 struct rt2560_softc *sc = (struct rt2560_softc *)arg; in rt2560_m_promisc() local
2104 sc->sc_rcr |= RAL_RCR_PROMISC; in rt2560_m_promisc()
2105 sc->sc_rcr |= RAL_RCR_MULTI; in rt2560_m_promisc()
2107 sc->sc_rcr &= ~RAL_RCR_PROMISC; in rt2560_m_promisc()
2108 sc->sc_rcr &= ~RAL_RCR_PROMISC; in rt2560_m_promisc()
2111 rt2560_update_promisc(sc); in rt2560_m_promisc()
2122 struct rt2560_softc *sc = arg; in rt2560_m_setprop() local
2123 struct ieee80211com *ic = &sc->sc_ic; in rt2560_m_setprop()
2128 RAL_LOCK(sc); in rt2560_m_setprop()
2130 if (RAL_IS_RUNNING(sc)) { in rt2560_m_setprop()
2131 RAL_UNLOCK(sc); in rt2560_m_setprop()
2132 (void) rt2560_init(sc); in rt2560_m_setprop()
2134 RAL_LOCK(sc); in rt2560_m_setprop()
2138 RAL_UNLOCK(sc); in rt2560_m_setprop()
2147 struct rt2560_softc *sc = arg; in rt2560_m_getprop() local
2150 err = ieee80211_getprop(&sc->sc_ic, pr_name, wldp_pr_num, in rt2560_m_getprop()
2160 struct rt2560_softc *sc = arg; in rt2560_m_propinfo() local
2162 ieee80211_propinfo(&sc->sc_ic, pr_name, wldp_pr_num, prh); in rt2560_m_propinfo()
2168 struct rt2560_softc *sc = (struct rt2560_softc *)arg; in rt2560_m_ioctl() local
2169 struct ieee80211com *ic = &sc->sc_ic; in rt2560_m_ioctl()
2173 RAL_LOCK(sc); in rt2560_m_ioctl()
2175 if (RAL_IS_RUNNING(sc)) { in rt2560_m_ioctl()
2176 RAL_UNLOCK(sc); in rt2560_m_ioctl()
2177 (void) rt2560_init(sc); in rt2560_m_ioctl()
2179 RAL_LOCK(sc); in rt2560_m_ioctl()
2182 RAL_UNLOCK(sc); in rt2560_m_ioctl()
2188 struct rt2560_softc *sc = (struct rt2560_softc *)arg; in rt2560_m_stat() local
2189 ieee80211com_t *ic = &sc->sc_ic; in rt2560_m_stat()
2193 RAL_LOCK(sc); in rt2560_m_stat()
2201 *val = sc->sc_tx_nobuf; in rt2560_m_stat()
2204 *val = sc->sc_rx_nobuf; in rt2560_m_stat()
2207 *val = sc->sc_rx_err; in rt2560_m_stat()
2223 *val = sc->sc_tx_err; in rt2560_m_stat()
2226 *val = sc->sc_tx_retries; in rt2560_m_stat()
2238 RAL_UNLOCK(sc); in rt2560_m_stat()
2241 RAL_UNLOCK(sc); in rt2560_m_stat()
2244 RAL_UNLOCK(sc); in rt2560_m_stat()
2253 struct rt2560_softc *sc = (struct rt2560_softc *)arg; in rt2560_intr() local
2256 RAL_LOCK(sc); in rt2560_intr()
2258 if (!RAL_IS_RUNNING(sc)) { in rt2560_intr()
2263 RAL_UNLOCK(sc); in rt2560_intr()
2267 r = RAL_READ(sc, RT2560_CSR7); in rt2560_intr()
2268 RAL_WRITE(sc, RT2560_CSR7, r); in rt2560_intr()
2271 RAL_UNLOCK(sc); in rt2560_intr()
2276 RAL_UNLOCK(sc); in rt2560_intr()
2281 RAL_WRITE(sc, RT2560_CSR8, 0xffffffff); in rt2560_intr()
2284 RAL_UNLOCK(sc); in rt2560_intr()
2285 rt2560_tx_intr(sc); in rt2560_intr()
2286 RAL_LOCK(sc); in rt2560_intr()
2290 RAL_UNLOCK(sc); in rt2560_intr()
2291 rt2560_prio_intr(sc); in rt2560_intr()
2292 RAL_LOCK(sc); in rt2560_intr()
2296 sc->sc_rx_pend = 1; in rt2560_intr()
2297 ddi_trigger_softintr(sc->sc_softint_id); in rt2560_intr()
2301 RAL_WRITE(sc, RT2560_CSR8, RT2560_INTR_MASK); in rt2560_intr()
2302 RAL_UNLOCK(sc); in rt2560_intr()
2320 struct rt2560_softc *sc; in rt2560_quiesce() local
2322 sc = ddi_get_soft_state(ral_soft_state_p, ddi_get_instance(devinfo)); in rt2560_quiesce()
2323 if (sc == NULL) in rt2560_quiesce()
2327 RAL_WRITE(sc, RT2560_TXCSR0, RT2560_ABORT_TX); in rt2560_quiesce()
2330 RAL_WRITE(sc, RT2560_RXCSR0, RT2560_DISABLE_RX); in rt2560_quiesce()
2333 RAL_WRITE(sc, RT2560_CSR1, RT2560_RESET_ASIC); in rt2560_quiesce()
2334 RAL_WRITE(sc, RT2560_CSR1, 0); in rt2560_quiesce()
2337 RAL_WRITE(sc, RT2560_CSR8, 0xffffffff); in rt2560_quiesce()
2345 struct rt2560_softc *sc; in rt2560_attach() local
2363 sc = ddi_get_soft_state(ral_soft_state_p, in rt2560_attach()
2365 sc->sc_flags &= ~RAL_FLAG_SUSPENDING; in rt2560_attach()
2366 if (RAL_IS_INITED(sc)) in rt2560_attach()
2367 (void) rt2560_init(sc); in rt2560_attach()
2381 sc = ddi_get_soft_state(ral_soft_state_p, instance); in rt2560_attach()
2382 ic = (ieee80211com_t *)&sc->sc_ic; in rt2560_attach()
2383 sc->sc_dev = devinfo; in rt2560_attach()
2397 sc->sc_cachelsz = cachelsz << 2; in rt2560_attach()
2422 &sc->sc_rbase, 0, 0, &ral_csr_accattr, &sc->sc_ioh); in rt2560_attach()
2435 sc->asic_rev = RAL_READ(sc, RT2560_CSR0); in rt2560_attach()
2438 rt2560_get_macaddr(sc, ic->ic_macaddr); in rt2560_attach()
2441 rt2560_read_eeprom(sc); in rt2560_attach()
2444 sc->asic_rev, rt2560_get_rf(sc->rf_rev)); in rt2560_attach()
2449 err = rt2560_alloc_tx_ring(sc, &sc->txq, RT2560_TX_RING_COUNT); in rt2560_attach()
2454 err = rt2560_alloc_tx_ring(sc, &sc->prioq, RT2560_PRIO_RING_COUNT); in rt2560_attach()
2459 err = rt2560_alloc_rx_ring(sc, &sc->rxq, RT2560_RX_RING_COUNT); in rt2560_attach()
2465 mutex_init(&sc->sc_genlock, NULL, MUTEX_DRIVER, NULL); in rt2560_attach()
2466 mutex_init(&sc->txq.tx_lock, NULL, MUTEX_DRIVER, NULL); in rt2560_attach()
2467 mutex_init(&sc->prioq.tx_lock, NULL, MUTEX_DRIVER, NULL); in rt2560_attach()
2468 mutex_init(&sc->rxq.rx_lock, NULL, MUTEX_DRIVER, NULL); in rt2560_attach()
2490 if (sc->rf_rev == RT2560_RF_5222) { in rt2560_attach()
2535 sc->sc_newstate = ic->ic_newstate; in rt2560_attach()
2541 sc->sc_rcr = 0; in rt2560_attach()
2542 sc->sc_rx_pend = 0; in rt2560_attach()
2543 sc->dwelltime = 300; in rt2560_attach()
2544 sc->sc_flags &= ~RAL_FLAG_RUNNING; in rt2560_attach()
2547 &sc->sc_softint_id, NULL, 0, ral_softint_handler, (caddr_t)sc); in rt2560_attach()
2554 err = ddi_get_iblock_cookie(devinfo, 0, &sc->sc_iblock); in rt2560_attach()
2561 err = ddi_add_intr(devinfo, 0, NULL, NULL, rt2560_intr, (caddr_t)sc); in rt2560_attach()
2583 macp->m_driver = sc; in rt2560_attach()
2618 ddi_remove_intr(devinfo, 0, sc->sc_iblock); in rt2560_attach()
2620 ddi_remove_softintr(sc->sc_softint_id); in rt2560_attach()
2622 mutex_destroy(&sc->sc_genlock); in rt2560_attach()
2623 mutex_destroy(&sc->txq.tx_lock); in rt2560_attach()
2624 mutex_destroy(&sc->prioq.tx_lock); in rt2560_attach()
2625 mutex_destroy(&sc->rxq.rx_lock); in rt2560_attach()
2627 rt2560_free_rx_ring(sc, &sc->rxq); in rt2560_attach()
2629 rt2560_free_tx_ring(sc, &sc->prioq); in rt2560_attach()
2631 rt2560_free_tx_ring(sc, &sc->txq); in rt2560_attach()
2633 ddi_regs_map_free(&sc->sc_ioh); in rt2560_attach()
2643 struct rt2560_softc *sc; in rt2560_detach() local
2645 sc = ddi_get_soft_state(ral_soft_state_p, ddi_get_instance(devinfo)); in rt2560_detach()
2646 ASSERT(sc != NULL); in rt2560_detach()
2652 if (RAL_IS_INITED(sc)) in rt2560_detach()
2653 (void) rt2560_stop(sc); in rt2560_detach()
2654 sc->sc_flags |= RAL_FLAG_SUSPENDING; in rt2560_detach()
2660 if (mac_disable(sc->sc_ic.ic_mach) != 0) in rt2560_detach()
2663 rt2560_stop(sc); in rt2560_detach()
2668 (void) mac_unregister(sc->sc_ic.ic_mach); in rt2560_detach()
2670 ddi_remove_intr(devinfo, 0, sc->sc_iblock); in rt2560_detach()
2671 ddi_remove_softintr(sc->sc_softint_id); in rt2560_detach()
2676 ieee80211_detach(&sc->sc_ic); in rt2560_detach()
2678 rt2560_free_tx_ring(sc, &sc->txq); in rt2560_detach()
2679 rt2560_free_tx_ring(sc, &sc->prioq); in rt2560_detach()
2680 rt2560_free_rx_ring(sc, &sc->rxq); in rt2560_detach()
2682 ddi_regs_map_free(&sc->sc_ioh); in rt2560_detach()
2684 mutex_destroy(&sc->sc_genlock); in rt2560_detach()
2685 mutex_destroy(&sc->txq.tx_lock); in rt2560_detach()
2686 mutex_destroy(&sc->prioq.tx_lock); in rt2560_detach()
2687 mutex_destroy(&sc->rxq.rx_lock); in rt2560_detach()