git: c6c22ebb38e7 - main - urtw(4): Adjust all pause calls to use milliseconds instead of ticks.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 09 Jun 2022 13:19:04 UTC
The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=c6c22ebb38e7371191e2f8c411b81011ecbe096a commit c6c22ebb38e7371191e2f8c411b81011ecbe096a Author: Hans Petter Selasky <hselasky@FreeBSD.org> AuthorDate: 2022-06-09 13:11:29 +0000 Commit: Hans Petter Selasky <hselasky@FreeBSD.org> CommitDate: 2022-06-09 13:18:02 +0000 urtw(4): Adjust all pause calls to use milliseconds instead of ticks. MFC after: 1 week Sponsored by: NVIDIA Networking --- sys/dev/usb/wlan/if_urtw.c | 116 ++++++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 55 deletions(-) diff --git a/sys/dev/usb/wlan/if_urtw.c b/sys/dev/usb/wlan/if_urtw.c index 2ade18480b6f..2e4bb876eb3e 100644 --- a/sys/dev/usb/wlan/if_urtw.c +++ b/sys/dev/usb/wlan/if_urtw.c @@ -1282,6 +1282,12 @@ fail: return (error); } +static void +urtw_pause_ms(struct urtw_softc *sc, int delay) +{ + usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(delay)); +} + static usb_error_t urtw_8187b_cmd_reset(struct urtw_softc *sc) { @@ -1295,7 +1301,7 @@ urtw_8187b_cmd_reset(struct urtw_softc *sc) urtw_write8_m(sc, URTW_CMD, data8); for (i = 0; i < 20; i++) { - usb_pause_mtx(&sc->sc_mtx, 2); + urtw_pause_ms(sc, 2); urtw_read8_m(sc, URTW_CMD, &data8); if (!(data8 & URTW_CMD_RST)) break; @@ -1326,7 +1332,7 @@ urtw_do_request(struct urtw_softc *sc, DPRINTF(sc, URTW_DEBUG_INIT, "Control request failed, %s (retrying)\n", usbd_errstr(err)); - usb_pause_mtx(&sc->sc_mtx, hz / 100); + urtw_pause_ms(sc, 10); } return (err); } @@ -1634,7 +1640,7 @@ urtw_set_channel(struct ieee80211com *ic) error = sc->sc_rf_set_chan(sc, ieee80211_chan2ieee(ic, ic->ic_curchan)); if (error != 0) goto fail; - usb_pause_mtx(&sc->sc_mtx, 10); + urtw_pause_ms(sc, 10); urtw_write32_m(sc, URTW_TX_CONF, orig); urtw_write16_m(sc, URTW_ATIM_WND, 2); @@ -2509,20 +2515,20 @@ urtw_8225_rf_init(struct urtw_softc *sc) error = urtw_8185_rf_pins_enable(sc); if (error) goto fail; - usb_pause_mtx(&sc->sc_mtx, 1000); + urtw_pause_ms(sc, 1000); for (i = 0; i < nitems(urtw_8225_rf_part1); i++) { urtw_8225_write(sc, urtw_8225_rf_part1[i].reg, urtw_8225_rf_part1[i].val); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); } - usb_pause_mtx(&sc->sc_mtx, 100); + urtw_pause_ms(sc, 100); urtw_8225_write(sc, URTW_8225_ADDR_2_MAGIC, URTW_8225_ADDR_2_DATA_MAGIC1); - usb_pause_mtx(&sc->sc_mtx, 200); + urtw_pause_ms(sc, 200); urtw_8225_write(sc, URTW_8225_ADDR_2_MAGIC, URTW_8225_ADDR_2_DATA_MAGIC2); - usb_pause_mtx(&sc->sc_mtx, 200); + urtw_pause_ms(sc, 200); urtw_8225_write(sc, URTW_8225_ADDR_0_MAGIC, URTW_8225_ADDR_0_DATA_MAGIC3); @@ -2538,15 +2544,15 @@ urtw_8225_rf_init(struct urtw_softc *sc) for (i = 0; i < 128; i++) { urtw_8187_write_phy_ofdm(sc, 0xb, urtw_8225_agc[i]); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); urtw_8187_write_phy_ofdm(sc, 0xa, (uint8_t)i + 0x80); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); } for (i = 0; i < nitems(urtw_8225_rf_part2); i++) { urtw_8187_write_phy_ofdm(sc, urtw_8225_rf_part2[i].reg, urtw_8225_rf_part2[i].val); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); } error = urtw_8225_setgain(sc, 4); @@ -2556,7 +2562,7 @@ urtw_8225_rf_init(struct urtw_softc *sc) for (i = 0; i < nitems(urtw_8225_rf_part3); i++) { urtw_8187_write_phy_cck(sc, urtw_8225_rf_part3[i].reg, urtw_8225_rf_part3[i].val); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); } urtw_write8_m(sc, URTW_TESTR, 0x0d); @@ -2566,9 +2572,9 @@ urtw_8225_rf_init(struct urtw_softc *sc) goto fail; urtw_8187_write_phy_cck(sc, 0x10, 0x9b); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); urtw_8187_write_phy_ofdm(sc, 0x26, 0x90); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); /* TX ant A, 0x0 for B */ error = urtw_8185_tx_antenna(sc, 0x3); @@ -2597,7 +2603,7 @@ urtw_8185_tx_antenna(struct urtw_softc *sc, uint8_t ant) usb_error_t error; urtw_write8_m(sc, URTW_TX_ANTENNA, ant); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); fail: return (error); } @@ -2629,7 +2635,7 @@ urtw_8187_write_phy(struct urtw_softc *sc, uint8_t addr, uint32_t data) urtw_write8_m(sc, URTW_PHY_MAGIC3, ((phyw & 0x00ff0000) >> 16)); urtw_write8_m(sc, URTW_PHY_MAGIC2, ((phyw & 0x0000ff00) >> 8)); urtw_write8_m(sc, URTW_PHY_MAGIC1, ((phyw & 0x000000ff))); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); fail: return (error); } @@ -2669,7 +2675,7 @@ urtw_8225_usb_init(struct urtw_softc *sc) urtw_write16_m(sc, URTW_RF_PINS_SELECT, 0x80); urtw_write16_m(sc, URTW_RF_PINS_ENABLE, 0x80); - usb_pause_mtx(&sc->sc_mtx, 500); + urtw_pause_ms(sc, 500); fail: return (error); } @@ -2702,7 +2708,7 @@ urtw_8225_write_c(struct urtw_softc *sc, uint8_t addr, uint16_t data) DELAY(10); urtw_write16_m(sc, URTW_RF_PINS_OUTPUT, d80 | URTW_BB_HOST_BANG_EN); urtw_write16_m(sc, URTW_RF_PINS_SELECT, d84); - usb_pause_mtx(&sc->sc_mtx, 2); + urtw_pause_ms(sc, 2); fail: return (error); } @@ -2740,7 +2746,7 @@ urtw_8225_rf_set_chan(struct urtw_softc *sc, int chan) if (error) goto fail; urtw_8225_write(sc, URTW_8225_ADDR_7_MAGIC, urtw_8225_channel[chan]); - usb_pause_mtx(&sc->sc_mtx, 10); + urtw_pause_ms(sc, 10); fail: return (error); } @@ -2798,7 +2804,7 @@ urtw_8225_set_txpwrlvl(struct urtw_softc *sc, int chan) urtw_8187_write_phy_cck(sc, 0x44 + i, cck_pwltable[idx * 8 + i]); } - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); /* OFDM power setting */ ofdm_pwrlvl = (ofdm_pwrlvl > (ofdm_pwrlvl_max - ofdm_pwrlvl_min)) ? @@ -2819,7 +2825,7 @@ urtw_8225_set_txpwrlvl(struct urtw_softc *sc, int chan) urtw_8225_tx_gain_cck_ofdm[set] >> 1); urtw_8187_write_phy_ofdm(sc, 0x5, urtw_8225_txpwr_ofdm[idx]); urtw_8187_write_phy_ofdm(sc, 0x7, urtw_8225_txpwr_ofdm[idx]); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); fail: return (error); } @@ -2891,13 +2897,13 @@ urtw_8225v2_rf_init(struct urtw_softc *sc) if (error) goto fail; - usb_pause_mtx(&sc->sc_mtx, 500); + urtw_pause_ms(sc, 500); for (i = 0; i < nitems(urtw_8225v2_rf_part1); i++) { urtw_8225_write(sc, urtw_8225v2_rf_part1[i].reg, urtw_8225v2_rf_part1[i].val); } - usb_pause_mtx(&sc->sc_mtx, 50); + urtw_pause_ms(sc, 50); urtw_8225_write(sc, URTW_8225_ADDR_0_MAGIC, URTW_8225_ADDR_0_DATA_MAGIC1); @@ -2916,10 +2922,10 @@ urtw_8225v2_rf_init(struct urtw_softc *sc) URTW_8225_ADDR_0_MAGIC, URTW_8225_ADDR_0_DATA_MAGIC2); urtw_8225_write(sc, URTW_8225_ADDR_2_MAGIC, URTW_8225_ADDR_2_DATA_MAGIC1); - usb_pause_mtx(&sc->sc_mtx, 100); + urtw_pause_ms(sc, 100); urtw_8225_write(sc, URTW_8225_ADDR_2_MAGIC, URTW_8225_ADDR_2_DATA_MAGIC2); - usb_pause_mtx(&sc->sc_mtx, 100); + urtw_pause_ms(sc, 100); error = urtw_8225_read(sc, URTW_8225_ADDR_6_MAGIC, &data32); if (error != 0) @@ -2929,17 +2935,17 @@ urtw_8225v2_rf_init(struct urtw_softc *sc) if (!(data32 & URTW_8225_ADDR_6_DATA_MAGIC2)) { urtw_8225_write(sc, URTW_8225_ADDR_2_MAGIC, URTW_8225_ADDR_2_DATA_MAGIC1); - usb_pause_mtx(&sc->sc_mtx, 100); + urtw_pause_ms(sc, 100); urtw_8225_write(sc, URTW_8225_ADDR_2_MAGIC, URTW_8225_ADDR_2_DATA_MAGIC2); - usb_pause_mtx(&sc->sc_mtx, 50); + urtw_pause_ms(sc, 50); error = urtw_8225_read(sc, URTW_8225_ADDR_6_MAGIC, &data32); if (error != 0) goto fail; if (!(data32 & URTW_8225_ADDR_6_DATA_MAGIC2)) device_printf(sc->sc_dev, "RF calibration failed\n"); } - usb_pause_mtx(&sc->sc_mtx, 100); + urtw_pause_ms(sc, 100); urtw_8225_write(sc, URTW_8225_ADDR_0_MAGIC, URTW_8225_ADDR_0_DATA_MAGIC6); @@ -2992,7 +2998,7 @@ urtw_8225v2_rf_set_chan(struct urtw_softc *sc, int chan) goto fail; urtw_8225_write(sc, URTW_8225_ADDR_7_MAGIC, urtw_8225_channel[chan]); - usb_pause_mtx(&sc->sc_mtx, 10); + urtw_pause_ms(sc, 10); fail: return (error); } @@ -3109,7 +3115,7 @@ urtw_8225v2_set_txpwrlvl(struct urtw_softc *sc, int chan) urtw_write8_m(sc, URTW_TX_GAIN_CCK, urtw_8225v2_tx_gain_cck_ofdm[cck_pwrlvl]); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); /* OFDM power setting */ ofdm_pwrlvl = (ofdm_pwrlvl > (ofdm_pwrlvl_max - ofdm_pwrlvl_min)) ? @@ -3129,7 +3135,7 @@ urtw_8225v2_set_txpwrlvl(struct urtw_softc *sc, int chan) urtw_write8_m(sc, URTW_TX_GAIN_OFDM, urtw_8225v2_tx_gain_cck_ofdm[ofdm_pwrlvl]); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); fail: return (error); } @@ -3143,13 +3149,13 @@ urtw_8225v2_setgain(struct urtw_softc *sc, int16_t gain) /* XXX for A? */ gainp = urtw_8225v2_gain_bg; urtw_8187_write_phy_ofdm(sc, 0x0d, gainp[gain * 3]); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); urtw_8187_write_phy_ofdm(sc, 0x1b, gainp[gain * 3 + 1]); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); urtw_8187_write_phy_ofdm(sc, 0x1d, gainp[gain * 3 + 2]); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); urtw_8187_write_phy_ofdm(sc, 0x21, 0x17); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); fail: return (error); } @@ -3165,7 +3171,7 @@ urtw_8225_isv2(struct urtw_softc *sc, int *ret) urtw_write16_m(sc, URTW_RF_PINS_OUTPUT, URTW_RF_PINS_MAGIC5); urtw_write16_m(sc, URTW_RF_PINS_SELECT, URTW_RF_PINS_MAGIC5); urtw_write16_m(sc, URTW_RF_PINS_ENABLE, URTW_RF_PINS_MAGIC5); - usb_pause_mtx(&sc->sc_mtx, 500); + urtw_pause_ms(sc, 500); urtw_8225_write(sc, URTW_8225_ADDR_0_MAGIC, URTW_8225_ADDR_0_DATA_MAGIC1); @@ -3287,36 +3293,36 @@ urtw_8225v2b_rf_init(struct urtw_softc *sc) urtw_write16_m(sc, URTW_RF_PINS_OUTPUT, 0x0480); urtw_write16_m(sc, URTW_RF_PINS_SELECT, 0x2488); urtw_write16_m(sc, URTW_RF_PINS_ENABLE, 0x1fff); - usb_pause_mtx(&sc->sc_mtx, 1100); + urtw_pause_ms(sc, 1100); for (i = 0; i < nitems(urtw_8225v2b_rf_part0); i++) { urtw_8225_write(sc, urtw_8225v2b_rf_part0[i].reg, urtw_8225v2b_rf_part0[i].val); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); } urtw_8225_write(sc, 0x00, 0x01b7); for (i = 0; i < 95; i++) { urtw_8225_write(sc, URTW_8225_ADDR_1_MAGIC, (uint8_t)(i + 1)); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); urtw_8225_write(sc, URTW_8225_ADDR_2_MAGIC, urtw_8225v2b_rxgain[i]); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); } urtw_8225_write(sc, URTW_8225_ADDR_3_MAGIC, 0x080); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); urtw_8225_write(sc, URTW_8225_ADDR_5_MAGIC, 0x004); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); urtw_8225_write(sc, URTW_8225_ADDR_0_MAGIC, 0x0b7); - usb_pause_mtx(&sc->sc_mtx, 1); - usb_pause_mtx(&sc->sc_mtx, 3000); + urtw_pause_ms(sc, 1); + urtw_pause_ms(sc, 3000); urtw_8225_write(sc, URTW_8225_ADDR_2_MAGIC, 0xc4d); - usb_pause_mtx(&sc->sc_mtx, 2000); + urtw_pause_ms(sc, 2000); urtw_8225_write(sc, URTW_8225_ADDR_2_MAGIC, 0x44d); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); urtw_8225_write(sc, URTW_8225_ADDR_0_MAGIC, 0x2bf); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); urtw_write8_m(sc, URTW_TX_GAIN_CCK, 0x03); urtw_write8_m(sc, URTW_TX_GAIN_OFDM, 0x07); @@ -3362,7 +3368,7 @@ urtw_8225v2b_rf_set_chan(struct urtw_softc *sc, int chan) goto fail; urtw_8225_write(sc, URTW_8225_ADDR_7_MAGIC, urtw_8225_channel[chan]); - usb_pause_mtx(&sc->sc_mtx, 10); + urtw_pause_ms(sc, 10); fail: return (error); } @@ -3398,7 +3404,7 @@ urtw_8225v2b_set_txpwrlvl(struct urtw_softc *sc, int chan) urtw_write8_m(sc, URTW_TX_GAIN_CCK, urtw_8225v2_tx_gain_cck_ofdm[cck_pwrlvl] << 1); - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); /* OFDM power setting */ ofdm_pwrlvl = (ofdm_pwrlvl > 15) ? @@ -3430,7 +3436,7 @@ urtw_8225v2b_set_txpwrlvl(struct urtw_softc *sc, int chan) urtw_8187_write_phy_ofdm(sc, 0x89, 0x50); } } - usb_pause_mtx(&sc->sc_mtx, 1); + urtw_pause_ms(sc, 1); fail: return (error); } @@ -3547,7 +3553,7 @@ urtw_reset(struct urtw_softc *sc) error = urtw_intr_disable(sc); if (error) goto fail; - usb_pause_mtx(&sc->sc_mtx, 100); + urtw_pause_ms(sc, 100); error = urtw_write8e(sc, 0x18, 0x10); if (error != 0) @@ -3558,12 +3564,12 @@ urtw_reset(struct urtw_softc *sc) error = urtw_write8e(sc, 0x18, 0x00); if (error != 0) goto fail; - usb_pause_mtx(&sc->sc_mtx, 100); + urtw_pause_ms(sc, 100); urtw_read8_m(sc, URTW_CMD, &data); data = (data & 0x2) | URTW_CMD_RST; urtw_write8_m(sc, URTW_CMD, data); - usb_pause_mtx(&sc->sc_mtx, 100); + urtw_pause_ms(sc, 100); urtw_read8_m(sc, URTW_CMD, &data); if (data & URTW_CMD_RST) { @@ -3574,7 +3580,7 @@ urtw_reset(struct urtw_softc *sc) error = urtw_set_mode(sc, URTW_EPROM_CMD_LOAD); if (error) goto fail; - usb_pause_mtx(&sc->sc_mtx, 100); + urtw_pause_ms(sc, 100); error = urtw_8180_set_anaparam(sc, URTW_8225_ANAPARAM_ON); if (error) @@ -3654,7 +3660,7 @@ urtw_led_mode0(struct urtw_softc *sc, int mode) break; case URTW_LED_POWER_ON_BLINK: urtw_led_on(sc, URTW_LED_GPIO); - usb_pause_mtx(&sc->sc_mtx, 100); + urtw_pause_ms(sc, 100); urtw_led_off(sc, URTW_LED_GPIO); break; default: