Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src-draft/trunk]: src/sys/dev/usb Reduce gratious changes to -current, espec...
details: https://anonhg.NetBSD.org/src-all/rev/fd50efcbee37
branches: trunk
changeset: 377053:fd50efcbee37
user: Martin Husemann <martin%NetBSD.org@localhost>
date: Sat Jan 15 20:30:15 2022 +0100
description:
Reduce gratious changes to -current, especially sync delays
diffstat:
sys/dev/usb/if_urtwn.c | 89 ++++++++++++++++++-------------------------------
1 files changed, 33 insertions(+), 56 deletions(-)
diffs (truncated from 338 to 300 lines):
diff -r 8fb58977c718 -r fd50efcbee37 sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c Tue Dec 14 21:21:08 2021 +0100
+++ b/sys/dev/usb/if_urtwn.c Sat Jan 15 20:30:15 2022 +0100
@@ -247,7 +247,6 @@ static int urtwn_write_region_1(struct u
static void urtwn_write_1(struct urtwn_softc *, uint16_t, uint8_t);
static void urtwn_write_2(struct urtwn_softc *, uint16_t, uint16_t);
static void urtwn_write_4(struct urtwn_softc *, uint16_t, uint32_t);
-static void urtwn_bb_write(struct urtwn_softc *, uint16_t, uint32_t);
static int urtwn_write_region(struct urtwn_softc *, uint16_t, uint8_t *,
int);
static int urtwn_read_region_1(struct urtwn_softc *, uint16_t, uint8_t *,
@@ -334,6 +333,7 @@ static void urtwn_set_channel(struct iee
static void urtwn_update_mcast(struct ieee80211com *);
/* Aliases. */
+#define urtwn_bb_write urtwn_write_4
#define urtwn_bb_read urtwn_read_4
#define urtwn_lookup(d,v,p) ((const struct urtwn_dev *)usb_lookup(d,v,p))
@@ -749,13 +749,6 @@ urtwn_wait_async(struct urtwn_softc *sc)
tsleep(&sc->cmdq, 0, "endtask", 0);
}
-static void
-urtwn_bb_write(struct urtwn_softc *sc, uint16_t addr, uint32_t val)
-{
- urtwn_write_4(sc, addr, val);
- DELAY(1);
-}
-
static int
urtwn_write_region_1(struct urtwn_softc *sc, uint16_t addr, uint8_t *buf,
int len)
@@ -775,7 +768,6 @@ urtwn_write_region_1(struct urtwn_softc
DPRINTFN(DBG_REG, ("%s: %s: error=%d: addr=%#x, len=%d\n",
device_xname(sc->sc_uw.uw_dev), __func__, error, addr, len));
}
- DELAY(1);
return error;
}
@@ -847,7 +839,6 @@ urtwn_read_region_1(struct urtwn_softc *
DPRINTFN(DBG_REG, ("%s: %s: error=%d: addr=%#x, len=%d\n",
device_xname(sc->sc_uw.uw_dev), __func__, error, addr, len));
}
- DELAY(1);
return error;
}
@@ -965,7 +956,6 @@ urtwn_r92c_rf_write(struct urtwn_softc *
urtwn_bb_write(sc, R92C_LSSI_PARAM(chain),
SM(R92C_LSSI_PARAM_ADDR, addr) | SM(R92C_LSSI_PARAM_DATA, val));
- urtwn_delay_ms(sc, 1);
}
static void
@@ -975,7 +965,6 @@ urtwn_r88e_rf_write(struct urtwn_softc *
urtwn_bb_write(sc, R92C_LSSI_PARAM(chain),
SM(R88E_LSSI_PARAM_ADDR, addr) | SM(R92C_LSSI_PARAM_DATA, val));
- urtwn_delay_ms(sc, 1);
}
static void
@@ -985,7 +974,6 @@ urtwn_r92e_rf_write(struct urtwn_softc *
urtwn_bb_write(sc, R92C_LSSI_PARAM(chain),
SM(R88E_LSSI_PARAM_ADDR, addr) | SM(R92C_LSSI_PARAM_DATA, val));
- urtwn_delay_ms(sc, 1);
}
static uint32_t
@@ -1282,7 +1270,6 @@ urtwn_read_rom(struct urtwn_softc *sc)
sc->board_type, sc->regulatory));
IEEE80211_ADDR_COPY(ic->ic_macaddr, rom->macaddr);
-
sc->sc_rf_write = urtwn_r92c_rf_write;
sc->sc_power_on = urtwn_r92c_power_on;
sc->sc_dma_init = urtwn_r92c_dma_init;
@@ -1589,7 +1576,6 @@ urtwn_set_led(struct urtwn_softc *sc, in
}
sc->ledlink = on; /* Save LED state. */
}
- urtwn_delay_ms(sc, 1);
}
static void
@@ -3143,11 +3129,10 @@ urtwn_r92e_power_on(struct urtwn_softc *
R92C_APS_FSMCO_PDN_EN |
R92C_APS_FSMCO_PFM_ALDN);
- if (urtwn_read_4(sc, R92E_SYS_CFG1_8192E) & R92E_SPSLDO_SEL){
+ if (urtwn_read_4(sc, R92E_SYS_CFG1_8192E) & R92E_SPSLDO_SEL) {
/* LDO. */
urtwn_write_1(sc, R92E_LDO_SWR_CTRL, 0xc3);
- }
- else {
+ } else {
urtwn_write_2(sc, R92C_SYS_SWR_CTRL2, urtwn_read_2(sc,
R92C_SYS_SWR_CTRL2) & 0xffff);
urtwn_write_1(sc, R92E_LDO_SWR_CTRL, 0x83);
@@ -3156,37 +3141,37 @@ urtwn_r92e_power_on(struct urtwn_softc *
for (ntries = 0; ntries < 2; ntries++) {
urtwn_write_1(sc, R92C_AFE_PLL_CTRL,
urtwn_read_1(sc, R92C_AFE_PLL_CTRL));
- urtwn_write_2(sc, R92C_AFE_CTRL4, urtwn_read_2(sc,
- R92C_AFE_CTRL4));
+ urtwn_write_2(sc, R92C_AFE_CTRL4,
+ urtwn_read_2(sc, R92C_AFE_CTRL4));
}
/* Reset BB. */
urtwn_write_1(sc, R92C_SYS_FUNC_EN,
- urtwn_read_1(sc, R92C_SYS_FUNC_EN) & ~(R92C_SYS_FUNC_EN_BBRSTB |
- R92C_SYS_FUNC_EN_BB_GLB_RST));
+ urtwn_read_1(sc, R92C_SYS_FUNC_EN) & ~(R92C_SYS_FUNC_EN_BBRSTB |
+ R92C_SYS_FUNC_EN_BB_GLB_RST));
urtwn_write_1(sc, R92C_AFE_XTAL_CTRL + 2, urtwn_read_1(sc,
R92C_AFE_XTAL_CTRL + 2) | 0x80);
/* Disable HWPDN. */
- urtwn_write_2(sc, R92C_APS_FSMCO, urtwn_read_2(sc,
- R92C_APS_FSMCO) & ~R92C_APS_FSMCO_APDM_HPDN);
+ urtwn_write_2(sc, R92C_APS_FSMCO,
+ urtwn_read_2(sc, R92C_APS_FSMCO) & ~R92C_APS_FSMCO_APDM_HPDN);
/* Disable WL suspend. */
- urtwn_write_2(sc, R92C_APS_FSMCO, urtwn_read_2(sc,
- R92C_APS_FSMCO) & ~(R92C_APS_FSMCO_AFSM_PCIE |
- R92C_APS_FSMCO_AFSM_HSUS));
-
- urtwn_write_4(sc, R92C_APS_FSMCO, urtwn_read_4(sc,
- R92C_APS_FSMCO) | R92C_APS_FSMCO_RDY_MACON);
- urtwn_write_2(sc, R92C_APS_FSMCO, urtwn_read_2(sc,
- R92C_APS_FSMCO) | R92C_APS_FSMCO_APFM_ONMAC);
+ urtwn_write_2(sc, R92C_APS_FSMCO,
+ urtwn_read_2(sc, R92C_APS_FSMCO) & ~(R92C_APS_FSMCO_AFSM_PCIE |
+ R92C_APS_FSMCO_AFSM_HSUS));
+
+ urtwn_write_4(sc, R92C_APS_FSMCO,
+ urtwn_read_4(sc, R92C_APS_FSMCO) | R92C_APS_FSMCO_RDY_MACON);
+ urtwn_write_2(sc, R92C_APS_FSMCO,
+ urtwn_read_2(sc, R92C_APS_FSMCO) | R92C_APS_FSMCO_APFM_ONMAC);
for (ntries = 0; ntries < 10000; ntries++) {
val = urtwn_read_2(sc, R92C_APS_FSMCO) &
- R92C_APS_FSMCO_APFM_ONMAC;
+ R92C_APS_FSMCO_APFM_ONMAC;
if (val == 0x0)
break;
- DELAY(10);
+ DELAY(260);
}
if (ntries == 10000) {
aprint_error_dev(sc->sc_uw.uw_dev,
@@ -3201,6 +3186,10 @@ urtwn_r92e_power_on(struct urtwn_softc *
R92C_CR_SCHEDULE_EN | R92C_CR_ENSEC;
urtwn_write_2(sc, R92C_CR, reg);
+ urtwn_write_1(sc, 0xfe10, 0x19);
+
+ urtwn_delay_ms(sc, 1);
+
return 0;
}
@@ -3344,7 +3333,6 @@ urtwn_fw_reset(struct urtwn_softc *sc)
/* Force 8051 reset. */
urtwn_write_2(sc, R92C_SYS_FUNC_EN,
urtwn_read_2(sc, R92C_SYS_FUNC_EN) & ~R92C_SYS_FUNC_EN_CPUEN);
- urtwn_delay_ms(sc, 10);
}
static void
@@ -3359,24 +3347,24 @@ urtwn_r88e_fw_reset(struct urtwn_softc *
if (ISSET(sc->chip, URTWN_CHIP_92EU)) {
reg = urtwn_read_2(sc, R92C_RSV_CTRL) & ~R92E_RSV_MIO_EN;
urtwn_write_2(sc,R92C_RSV_CTRL, reg);
+ DELAY(50);
}
- DELAY(200);
reg = urtwn_read_2(sc, R92C_SYS_FUNC_EN);
urtwn_write_2(sc, R92C_SYS_FUNC_EN, reg & ~R92C_SYS_FUNC_EN_CPUEN);
DELAY(50);
urtwn_write_2(sc, R92C_SYS_FUNC_EN, reg | R92C_SYS_FUNC_EN_CPUEN);
- DELAY(200);
+ DELAY(50);
if (ISSET(sc->chip, URTWN_CHIP_92EU)) {
reg = urtwn_read_2(sc, R92C_RSV_CTRL) | R92E_RSV_MIO_EN;
urtwn_write_2(sc,R92C_RSV_CTRL, reg);
+ DELAY(50);
}
+
/* Init firmware commands ring. */
sc->fwcur = 0;
- urtwn_delay_ms(sc, 10);
-
}
static int
@@ -3496,7 +3484,7 @@ urtwn_load_firmware(struct urtwn_softc *
/* Reset the FWDL checksum. */
urtwn_write_1(sc, R92C_MCUFWDL,
- urtwn_read_1(sc, R92C_MCUFWDL) | R92C_MCUFWDL_CHKSUM_RPT);
+ urtwn_read_1(sc, R92C_MCUFWDL) | R92C_MCUFWDL_CHKSUM_RPT);
DELAY(50);
/* download firmware */
@@ -3537,8 +3525,6 @@ urtwn_load_firmware(struct urtwn_softc *
if (ISSET(sc->chip, URTWN_CHIP_88E) ||
ISSET(sc->chip, URTWN_CHIP_92EU))
urtwn_r88e_fw_reset(sc);
- else
- urtwn_fw_reset(sc);
for (ntries = 0; ntries < 6000; ntries++) {
if (urtwn_read_4(sc, R92C_MCUFWDL) & R92C_MCUFWDL_WINTINI_RDY)
break;
@@ -3550,7 +3536,7 @@ urtwn_load_firmware(struct urtwn_softc *
error = ETIMEDOUT;
goto fail;
}
- urtwn_delay_ms(sc, 10);
+
fail:
firmware_free(fw, fwlen);
return error;
@@ -3812,6 +3798,7 @@ urtwn_bb_init(struct urtwn_softc *sc)
break;
}
urtwn_bb_write(sc, prog->regs[i], prog->vals[i]);
+ DELAY(1);
}
if (sc->chip & URTWN_CHIP_92C_1T2R) {
@@ -3856,12 +3843,15 @@ urtwn_bb_init(struct urtwn_softc *sc)
/* Write AGC values. */
for (i = 0; i < prog->agccount; i++) {
urtwn_bb_write(sc, R92C_OFDM0_AGCRSSITABLE, prog->agcvals[i]);
+ DELAY(1);
}
if (ISSET(sc->chip, URTWN_CHIP_88E) ||
ISSET(sc->chip, URTWN_CHIP_92EU)) {
urtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(0), 0x69553422);
+ DELAY(1);
urtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(0), 0x69553420);
+ DELAY(1);
}
if (ISSET(sc->chip, URTWN_CHIP_92EU)) {
@@ -3873,7 +3863,6 @@ urtwn_bb_init(struct urtwn_softc *sc)
urtwn_bb_write(sc, R92C_AFE_CTRL3,
RW(reg, R92C_AFE_XTAL_CTRL_ADDR,
crystalcap | crystalcap << 6));
- urtwn_delay_ms(sc, 1);
urtwn_write_4(sc, R92C_AFE_XTAL_CTRL, 0xf81fb);
} else if (ISSET(sc->chip, URTWN_CHIP_88E)) {
crystalcap = sc->r88e_rom[0xb9];
@@ -3890,7 +3879,6 @@ urtwn_bb_init(struct urtwn_softc *sc)
SET(sc->sc_uw.uw_flags, URTWN_FLAG_CCK_HIPWR);
}
}
- urtwn_delay_ms(sc, 1);
}
static void __noinline
@@ -3965,7 +3953,6 @@ urtwn_rf_init(struct urtwn_softc *sc)
/* Restore RF_ENV control type. */
reg = urtwn_bb_read(sc, R92C_FPGA0_RFIFACESW(idx)) & ~mask;
urtwn_bb_write(sc, R92C_FPGA0_RFIFACESW(idx), reg | saved);
- urtwn_delay_ms(sc, 1);
}
if ((sc->chip & (URTWN_CHIP_UMC_A_CUT | URTWN_CHIP_92C)) ==
@@ -4399,7 +4386,6 @@ urtwn_set_chan(struct urtwn_softc *sc, s
for (i = 0; i < sc->nrxchains; i++) {
urtwn_rf_write(sc, i, R92C_RF_CHNLBW,
RW(sc->rf_chnlbw[i], R92C_RF_CHNLBW_CHNL, chan));
- urtwn_delay_ms(sc, 1);
}
if (ht40m) {
@@ -4462,7 +4448,6 @@ urtwn_set_chan(struct urtwn_softc *sc, s
ISSET(sc->chip, URTWN_CHIP_92EU) ?
R88E_RF_CHNLBW_BW20 : R92C_RF_CHNLBW_BW20));
}
- urtwn_delay_ms(sc, 1);
}
static void __noinline
@@ -4522,11 +4507,9 @@ urtwn_iq_calib(struct urtwn_softc *sc, b
urtwn_bb_write(sc, R92C_HSSI_PARAM1(0),
urtwn_bb_read(sc, R92C_HSSI_PARAM1(0))|
R92C_HSSI_PARAM1_PI);
Home |
Main Index |
Thread Index |
Old Index