summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorKevin Lo <kevlo@cvs.openbsd.org>2019-03-11 06:19:34 +0000
committerKevin Lo <kevlo@cvs.openbsd.org>2019-03-11 06:19:34 +0000
commit93a12c4f186d7599e035fe6339ec2d9878a45888 (patch)
tree98b9f149fcf3d0db1fdc89b95bd0f33a3df6e927 /sys/dev/ic
parentab1f93eea81501536b09296e3cbaaacca9646b5f (diff)
- in rtwn_r88e_fw_reset function, use the correct bit R88E_RSV_CTRL_MCU_RST
to reset/enable MCU - there's no need to enable 1.2V power for rtl8192eu ok jmatthew@
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/r92creg.h22
-rw-r--r--sys/dev/ic/rtwn.c83
-rw-r--r--sys/dev/ic/rtwnvar.h3
3 files changed, 43 insertions, 65 deletions
diff --git a/sys/dev/ic/r92creg.h b/sys/dev/ic/r92creg.h
index 531d449cf52..df8cb6b30ca 100644
--- a/sys/dev/ic/r92creg.h
+++ b/sys/dev/ic/r92creg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: r92creg.h,v 1.23 2018/12/07 01:53:20 kevlo Exp $ */
+/* $OpenBSD: r92creg.h,v 1.24 2019/03/11 06:19:33 kevlo Exp $ */
/*-
* Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -326,15 +326,16 @@
#define R92C_SYS_CLKR_RING_EN 0x00002000
/* Bits for R92C_RSV_CTRL. */
-#define R92C_RSV_CTRL_WLOCK_ALL 0x01
-#define R92C_RSV_CTRL_WLOCK_00 0x02
-#define R92C_RSV_CTRL_WLOCK_04 0x04
-#define R92C_RSV_CTRL_WLOCK_08 0x08
-#define R92C_RSV_CTRL_WLOCK_40 0x10
-#define R92C_RSV_CTRL_R_DIS_PRST_0 0x20
-#define R92C_RSV_CTRL_R_DIS_PRST_1 0x40
-#define R92C_RSV_CTRL_LOCK_ALL_EN 0x80
+#define R92C_RSV_CTRL_WLOCK_ALL 0x0001
+#define R92C_RSV_CTRL_WLOCK_00 0x0002
+#define R92C_RSV_CTRL_WLOCK_04 0x0004
+#define R92C_RSV_CTRL_WLOCK_08 0x0008
+#define R92C_RSV_CTRL_WLOCK_40 0x0010
+#define R92C_RSV_CTRL_R_DIS_PRST_0 0x0020
+#define R92C_RSV_CTRL_R_DIS_PRST_1 0x0040
+#define R92C_RSV_CTRL_LOCK_ALL_EN 0x0080
#define R88E_RSV_CTRL_MIO_EN 0x0100
+#define R88E_RSV_CTRL_MCU_RST 0x0800
/* Bits for R92C_RF_CTRL. */
#define R92C_RF_CTRL_EN 0x01
@@ -544,6 +545,9 @@
#define R92C_TDECTRL_BLK_DESC_NUM_M 0x000000f0
#define R92C_TDECTRL_BLK_DESC_NUM_S 4
+/* Bits for R92C_TXDMA_OFFSET_CHK. */
+#define R92C_TXDMA_OFFSET_CHK_DROP_DATA_EN 0x00000200
+
/* Bits for R92E_AUTO_LLT. */
#define R92E_AUTO_LLT_EN 0x00010000
diff --git a/sys/dev/ic/rtwn.c b/sys/dev/ic/rtwn.c
index fb0e23bb6d0..e11771131c6 100644
--- a/sys/dev/ic/rtwn.c
+++ b/sys/dev/ic/rtwn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtwn.c,v 1.44 2019/01/29 09:35:16 kevlo Exp $ */
+/* $OpenBSD: rtwn.c,v 1.45 2019/03/11 06:19:33 kevlo Exp $ */
/*-
* Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -151,7 +151,6 @@ void rtwn_pa_bias_init(struct rtwn_softc *);
void rtwn_rxfilter_init(struct rtwn_softc *);
void rtwn_edca_init(struct rtwn_softc *);
void rtwn_rate_fallback_init(struct rtwn_softc *);
-void rtwn_usb_aggr_init(struct rtwn_softc *);
void rtwn_write_txpower(struct rtwn_softc *, int, uint16_t[]);
void rtwn_get_txpower(struct rtwn_softc *sc, int,
struct ieee80211_channel *, struct ieee80211_channel *,
@@ -580,10 +579,12 @@ rtwn_efuse_switch_power(struct rtwn_softc *sc)
{
uint16_t reg;
- reg = rtwn_read_2(sc, R92C_SYS_ISO_CTRL);
- if (!(reg & R92C_SYS_ISO_CTRL_PWC_EV12V)) {
- rtwn_write_2(sc, R92C_SYS_ISO_CTRL,
- reg | R92C_SYS_ISO_CTRL_PWC_EV12V);
+ if (!(sc->chip & RTWN_CHIP_92E)) {
+ reg = rtwn_read_2(sc, R92C_SYS_ISO_CTRL);
+ if (!(reg & R92C_SYS_ISO_CTRL_PWC_EV12V)) {
+ rtwn_write_2(sc, R92C_SYS_ISO_CTRL,
+ reg | R92C_SYS_ISO_CTRL_PWC_EV12V);
+ }
}
reg = rtwn_read_2(sc, R92C_SYS_FUNC_EN);
if (!(reg & R92C_SYS_FUNC_EN_ELDR)) {
@@ -1648,14 +1649,28 @@ rtwn_r88e_fw_reset(struct rtwn_softc *sc)
uint16_t reg;
/* Reset MCU IO wrapper. */
- rtwn_write_2(sc, R92C_RSV_CTRL,
- rtwn_read_2(sc, R92C_RSV_CTRL) & ~R88E_RSV_CTRL_MIO_EN);
+ rtwn_write_1(sc, R92C_RSV_CTRL,
+ rtwn_read_1(sc, R92C_RSV_CTRL) & ~R92C_RSV_CTRL_WLOCK_00);
+ if (sc->chip & RTWN_CHIP_88E) {
+ rtwn_write_2(sc, R92C_RSV_CTRL,
+ rtwn_read_2(sc, R92C_RSV_CTRL) & ~R88E_RSV_CTRL_MCU_RST);
+ } else {
+ rtwn_write_2(sc, R92C_RSV_CTRL,
+ rtwn_read_2(sc, R92C_RSV_CTRL) & ~R88E_RSV_CTRL_MIO_EN);
+ }
reg = rtwn_read_2(sc, R92C_SYS_FUNC_EN);
rtwn_write_2(sc, R92C_SYS_FUNC_EN, reg & ~R92C_SYS_FUNC_EN_CPUEN);
/* Enable MCU IO wrapper. */
- rtwn_write_2(sc, R92C_RSV_CTRL,
- rtwn_read_2(sc, R92C_RSV_CTRL) | R88E_RSV_CTRL_MIO_EN);
+ rtwn_write_1(sc, R92C_RSV_CTRL,
+ rtwn_read_1(sc, R92C_RSV_CTRL) & ~R92C_RSV_CTRL_WLOCK_00);
+ if (sc->chip & RTWN_CHIP_88E) {
+ rtwn_write_2(sc, R92C_RSV_CTRL,
+ rtwn_read_2(sc, R92C_RSV_CTRL) | R88E_RSV_CTRL_MCU_RST);
+ } else {
+ rtwn_write_2(sc, R92C_RSV_CTRL,
+ rtwn_read_2(sc, R92C_RSV_CTRL) | R88E_RSV_CTRL_MIO_EN);
+ }
rtwn_write_2(sc, R92C_SYS_FUNC_EN, reg | R92C_SYS_FUNC_EN_CPUEN);
}
@@ -1978,47 +1993,6 @@ rtwn_rate_fallback_init(struct rtwn_softc *sc)
}
void
-rtwn_usb_aggr_init(struct rtwn_softc *sc)
-{
- uint32_t reg;
- int dmasize, dmatiming, ndesc;
-
- if (sc->chip & RTWN_CHIP_92E) {
- dmasize = 0x06;
- dmatiming = 0x20;
- ndesc = 3;
- } else {
- dmasize = 48;
- dmatiming = 4;
- ndesc = (sc->chip & RTWN_CHIP_88E) ? 1 : 6;
- }
-
- /* Tx aggregation setting. */
- if (sc->chip & RTWN_CHIP_92E) {
- rtwn_write_1(sc, R92E_DWBCN1_CTRL, ndesc << 1);
- } else {
- reg = rtwn_read_4(sc, R92C_TDECTRL);
- reg = RW(reg, R92C_TDECTRL_BLK_DESC_NUM, ndesc);
- rtwn_write_4(sc, R92C_TDECTRL, reg);
- }
-
- /* Rx aggregation setting. */
- if (sc->chip & RTWN_CHIP_92E) {
- rtwn_write_1(sc, R92E_RXDMA_PRO,
- (rtwn_read_1(sc, R92E_RXDMA_PRO) & ~0x20) | 0x1e);
- } else {
- rtwn_write_1(sc, R92C_TRXDMA_CTRL,
- rtwn_read_1(sc, R92C_TRXDMA_CTRL) |
- R92C_TRXDMA_CTRL_RXDMA_AGG_EN);
- }
- rtwn_write_1(sc, R92C_RXDMA_AGG_PG_TH, dmasize);
- if (sc->chip & (RTWN_CHIP_92C | RTWN_CHIP_88C))
- rtwn_write_1(sc, R92C_USB_DMA_AGG_TO, dmatiming);
- else
- rtwn_write_1(sc, R92C_RXDMA_AGG_PG_TH + 1, dmatiming);
-}
-
-void
rtwn_write_txpower(struct rtwn_softc *sc, int chain,
uint16_t power[RTWN_POWER_COUNT])
{
@@ -3124,10 +3098,9 @@ rtwn_init(struct ifnet *ifp)
/* Set ACK timeout. */
rtwn_write_1(sc, R92C_ACKTO, 0x40);
- if (sc->chip & RTWN_CHIP_USB) {
- /* Setup USB aggregation. */
- rtwn_usb_aggr_init(sc);
- }
+ /* Setup USB aggregation. */
+ if (sc->chip & RTWN_CHIP_USB)
+ sc->sc_ops.aggr_init(sc->sc_ops.cookie);
/* Initialize beacon parameters. */
rtwn_write_2(sc, R92C_BCN_CTRL,
diff --git a/sys/dev/ic/rtwnvar.h b/sys/dev/ic/rtwnvar.h
index 6386e4c9e07..e7ee10c0fc5 100644
--- a/sys/dev/ic/rtwnvar.h
+++ b/sys/dev/ic/rtwnvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtwnvar.h,v 1.14 2018/12/04 10:47:32 jmatthew Exp $ */
+/* $OpenBSD: rtwnvar.h,v 1.15 2019/03/11 06:19:33 kevlo Exp $ */
/*-
* Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -32,6 +32,7 @@ struct rtwn_ops {
int (*dma_init)(void *);
int (*fw_loadpage)(void *, int, uint8_t *, int);
int (*load_firmware)(void *, u_char **fw, size_t *);
+ void (*aggr_init)(void *);
void (*mac_init)(void *);
void (*bb_init)(void *);
int (*alloc_buffers)(void *);