mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-18 06:14:27 +00:00
- The DELAY() should not be used in USB drivers.
- The usb_pause_mtx() function takes ticks and not milliseconds as last argument. MFC after: 3 days
This commit is contained in:
parent
5c657683bb
commit
b41381aea9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=266471
|
@ -195,6 +195,7 @@ static void rsu_start_locked(struct ifnet *);
|
||||||
static int rsu_ioctl(struct ifnet *, u_long, caddr_t);
|
static int rsu_ioctl(struct ifnet *, u_long, caddr_t);
|
||||||
static void rsu_stop(struct ifnet *, int);
|
static void rsu_stop(struct ifnet *, int);
|
||||||
static void rsu_stop_locked(struct ifnet *, int);
|
static void rsu_stop_locked(struct ifnet *, int);
|
||||||
|
static void rsu_ms_delay(struct rsu_softc *);
|
||||||
|
|
||||||
static device_method_t rsu_methods[] = {
|
static device_method_t rsu_methods[] = {
|
||||||
DEVMETHOD(device_probe, rsu_match),
|
DEVMETHOD(device_probe, rsu_match),
|
||||||
|
@ -756,11 +757,11 @@ rsu_fw_iocmd(struct rsu_softc *sc, uint32_t iocmd)
|
||||||
int ntries;
|
int ntries;
|
||||||
|
|
||||||
rsu_write_4(sc, R92S_IOCMD_CTRL, iocmd);
|
rsu_write_4(sc, R92S_IOCMD_CTRL, iocmd);
|
||||||
DELAY(100);
|
rsu_ms_delay(sc);
|
||||||
for (ntries = 0; ntries < 50; ntries++) {
|
for (ntries = 0; ntries < 50; ntries++) {
|
||||||
if (rsu_read_4(sc, R92S_IOCMD_CTRL) == 0)
|
if (rsu_read_4(sc, R92S_IOCMD_CTRL) == 0)
|
||||||
return (0);
|
return (0);
|
||||||
DELAY(10);
|
rsu_ms_delay(sc);
|
||||||
}
|
}
|
||||||
return (ETIMEDOUT);
|
return (ETIMEDOUT);
|
||||||
}
|
}
|
||||||
|
@ -780,7 +781,7 @@ rsu_efuse_read_1(struct rsu_softc *sc, uint16_t addr)
|
||||||
reg = rsu_read_4(sc, R92S_EFUSE_CTRL);
|
reg = rsu_read_4(sc, R92S_EFUSE_CTRL);
|
||||||
if (reg & R92S_EFUSE_CTRL_VALID)
|
if (reg & R92S_EFUSE_CTRL_VALID)
|
||||||
return (MS(reg, R92S_EFUSE_CTRL_DATA));
|
return (MS(reg, R92S_EFUSE_CTRL_DATA));
|
||||||
DELAY(5);
|
rsu_ms_delay(sc);
|
||||||
}
|
}
|
||||||
device_printf(sc->sc_dev,
|
device_printf(sc->sc_dev,
|
||||||
"could not read efuse byte at address 0x%x\n", addr);
|
"could not read efuse byte at address 0x%x\n", addr);
|
||||||
|
@ -804,7 +805,7 @@ rsu_read_rom(struct rsu_softc *sc)
|
||||||
/* Turn on 2.5V to prevent eFuse leakage. */
|
/* Turn on 2.5V to prevent eFuse leakage. */
|
||||||
reg = rsu_read_1(sc, R92S_EFUSE_TEST + 3);
|
reg = rsu_read_1(sc, R92S_EFUSE_TEST + 3);
|
||||||
rsu_write_1(sc, R92S_EFUSE_TEST + 3, reg | 0x80);
|
rsu_write_1(sc, R92S_EFUSE_TEST + 3, reg | 0x80);
|
||||||
DELAY(1000);
|
rsu_ms_delay(sc);
|
||||||
rsu_write_1(sc, R92S_EFUSE_TEST + 3, reg & ~0x80);
|
rsu_write_1(sc, R92S_EFUSE_TEST + 3, reg & ~0x80);
|
||||||
|
|
||||||
/* Read full ROM image. */
|
/* Read full ROM image. */
|
||||||
|
@ -1942,7 +1943,7 @@ rsu_power_on_bcut(struct rsu_softc *sc)
|
||||||
}
|
}
|
||||||
rsu_write_1(sc, R92S_SYS_FUNC_EN + 1,
|
rsu_write_1(sc, R92S_SYS_FUNC_EN + 1,
|
||||||
rsu_read_1(sc, R92S_SYS_FUNC_EN + 1) & ~0x8c);
|
rsu_read_1(sc, R92S_SYS_FUNC_EN + 1) & ~0x8c);
|
||||||
DELAY(1000);
|
rsu_ms_delay(sc);
|
||||||
|
|
||||||
rsu_write_1(sc, R92S_SPS0_CTRL + 1, 0x53);
|
rsu_write_1(sc, R92S_SPS0_CTRL + 1, 0x53);
|
||||||
rsu_write_1(sc, R92S_SPS0_CTRL + 0, 0x57);
|
rsu_write_1(sc, R92S_SPS0_CTRL + 0, 0x57);
|
||||||
|
@ -1975,11 +1976,11 @@ rsu_power_on_bcut(struct rsu_softc *sc)
|
||||||
/* Enable AFE PLL macro block. */
|
/* Enable AFE PLL macro block. */
|
||||||
reg = rsu_read_1(sc, R92S_AFE_PLL_CTRL);
|
reg = rsu_read_1(sc, R92S_AFE_PLL_CTRL);
|
||||||
rsu_write_1(sc, R92S_AFE_PLL_CTRL, reg | 0x11);
|
rsu_write_1(sc, R92S_AFE_PLL_CTRL, reg | 0x11);
|
||||||
DELAY(500);
|
rsu_ms_delay(sc);
|
||||||
rsu_write_1(sc, R92S_AFE_PLL_CTRL, reg | 0x51);
|
rsu_write_1(sc, R92S_AFE_PLL_CTRL, reg | 0x51);
|
||||||
DELAY(500);
|
rsu_ms_delay(sc);
|
||||||
rsu_write_1(sc, R92S_AFE_PLL_CTRL, reg | 0x11);
|
rsu_write_1(sc, R92S_AFE_PLL_CTRL, reg | 0x11);
|
||||||
DELAY(500);
|
rsu_ms_delay(sc);
|
||||||
|
|
||||||
/* Attach AFE PLL to MACTOP/BB. */
|
/* Attach AFE PLL to MACTOP/BB. */
|
||||||
rsu_write_1(sc, R92S_SYS_ISO_CTRL,
|
rsu_write_1(sc, R92S_SYS_ISO_CTRL,
|
||||||
|
@ -2026,14 +2027,14 @@ rsu_power_on_bcut(struct rsu_softc *sc)
|
||||||
if ((reg & (R92S_TCR_IMEM_CHK_RPT | R92S_TCR_EMEM_CHK_RPT)) ==
|
if ((reg & (R92S_TCR_IMEM_CHK_RPT | R92S_TCR_EMEM_CHK_RPT)) ==
|
||||||
(R92S_TCR_IMEM_CHK_RPT | R92S_TCR_EMEM_CHK_RPT))
|
(R92S_TCR_IMEM_CHK_RPT | R92S_TCR_EMEM_CHK_RPT))
|
||||||
break;
|
break;
|
||||||
DELAY(5);
|
rsu_ms_delay(sc);
|
||||||
}
|
}
|
||||||
if (ntries == 20) {
|
if (ntries == 20) {
|
||||||
DPRINTF("TxDMA is not ready\n");
|
DPRINTF("TxDMA is not ready\n");
|
||||||
/* Reset TxDMA. */
|
/* Reset TxDMA. */
|
||||||
reg = rsu_read_1(sc, R92S_CR);
|
reg = rsu_read_1(sc, R92S_CR);
|
||||||
rsu_write_1(sc, R92S_CR, reg & ~R92S_CR_TXDMA_EN);
|
rsu_write_1(sc, R92S_CR, reg & ~R92S_CR_TXDMA_EN);
|
||||||
DELAY(2);
|
rsu_ms_delay(sc);
|
||||||
rsu_write_1(sc, R92S_CR, reg | R92S_CR_TXDMA_EN);
|
rsu_write_1(sc, R92S_CR, reg | R92S_CR_TXDMA_EN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2220,7 +2221,7 @@ rsu_load_firmware(struct rsu_softc *sc)
|
||||||
for (ntries = 0; ntries < 100; ntries++) {
|
for (ntries = 0; ntries < 100; ntries++) {
|
||||||
if (rsu_read_2(sc, R92S_TCR) & R92S_TCR_IMEM_RDY)
|
if (rsu_read_2(sc, R92S_TCR) & R92S_TCR_IMEM_RDY)
|
||||||
break;
|
break;
|
||||||
DELAY(1000);
|
rsu_ms_delay(sc);
|
||||||
}
|
}
|
||||||
if (ntries == 100) {
|
if (ntries == 100) {
|
||||||
device_printf(sc->sc_dev,
|
device_printf(sc->sc_dev,
|
||||||
|
@ -2252,7 +2253,7 @@ rsu_load_firmware(struct rsu_softc *sc)
|
||||||
for (ntries = 0; ntries < 100; ntries++) {
|
for (ntries = 0; ntries < 100; ntries++) {
|
||||||
if (rsu_read_2(sc, R92S_TCR) & R92S_TCR_DMEM_CODE_DONE)
|
if (rsu_read_2(sc, R92S_TCR) & R92S_TCR_DMEM_CODE_DONE)
|
||||||
break;
|
break;
|
||||||
DELAY(1000);
|
rsu_ms_delay(sc);
|
||||||
}
|
}
|
||||||
if (ntries == 100) {
|
if (ntries == 100) {
|
||||||
device_printf(sc->sc_dev, "timeout waiting for %s transfer\n",
|
device_printf(sc->sc_dev, "timeout waiting for %s transfer\n",
|
||||||
|
@ -2264,7 +2265,7 @@ rsu_load_firmware(struct rsu_softc *sc)
|
||||||
for (ntries = 0; ntries < 60; ntries++) {
|
for (ntries = 0; ntries < 60; ntries++) {
|
||||||
if (!(rsu_read_2(sc, R92S_TCR) & R92S_TCR_FWRDY))
|
if (!(rsu_read_2(sc, R92S_TCR) & R92S_TCR_FWRDY))
|
||||||
break;
|
break;
|
||||||
DELAY(1000);
|
rsu_ms_delay(sc);
|
||||||
}
|
}
|
||||||
if (ntries == 60) {
|
if (ntries == 60) {
|
||||||
device_printf(sc->sc_dev,
|
device_printf(sc->sc_dev,
|
||||||
|
@ -2385,8 +2386,8 @@ rsu_init_locked(struct rsu_softc *sc)
|
||||||
rsu_write_region_1(sc, R92S_MACID, IF_LLADDR(ifp),
|
rsu_write_region_1(sc, R92S_MACID, IF_LLADDR(ifp),
|
||||||
IEEE80211_ADDR_LEN);
|
IEEE80211_ADDR_LEN);
|
||||||
|
|
||||||
/* NB: it really takes that long for firmware to boot. */
|
/* It really takes 1.5 seconds for the firmware to boot: */
|
||||||
usb_pause_mtx(&sc->sc_mtx, 1500);
|
usb_pause_mtx(&sc->sc_mtx, (3 * hz) / 2);
|
||||||
|
|
||||||
DPRINTF("setting MAC address to %s\n", ether_sprintf(IF_LLADDR(ifp)));
|
DPRINTF("setting MAC address to %s\n", ether_sprintf(IF_LLADDR(ifp)));
|
||||||
error = rsu_fw_cmd(sc, R92S_CMD_SET_MAC_ADDRESS, IF_LLADDR(ifp),
|
error = rsu_fw_cmd(sc, R92S_CMD_SET_MAC_ADDRESS, IF_LLADDR(ifp),
|
||||||
|
@ -2469,3 +2470,8 @@ rsu_stop_locked(struct ifnet *ifp, int disable __unused)
|
||||||
usbd_transfer_stop(sc->sc_xfer[i]);
|
usbd_transfer_stop(sc->sc_xfer[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
rsu_ms_delay(struct rsu_softc *sc)
|
||||||
|
{
|
||||||
|
usb_pause_mtx(&sc->sc_mtx, hz / 1000);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue