From 5c95ab023ccf7f035c50fde27b1276e44aaa7b69 Mon Sep 17 00:00:00 2001 From: Kevin Lo Date: Wed, 8 Jun 2016 02:37:23 +0000 Subject: [PATCH] - Replace the magic numbers with something more readable. - Reset DMA indexes after disabling DMA. --- sys/dev/ral/rt2860.c | 19 +++++++++++++++---- sys/dev/ral/rt2860reg.h | 11 ++++++++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/sys/dev/ral/rt2860.c b/sys/dev/ral/rt2860.c index 79989fcb3621..1b15a0f62efc 100644 --- a/sys/dev/ral/rt2860.c +++ b/sys/dev/ral/rt2860.c @@ -900,7 +900,7 @@ rt2860_ampdu_rx_stop(struct ieee80211com *ic, struct ieee80211_node *ni, } #endif -int +static int rt2860_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) { struct rt2860_vap *rvp = RT2860_VAP(vap); @@ -3824,9 +3824,16 @@ rt2860_init_locked(struct rt2860_softc *sc) /* disable DMA */ tmp = RAL_READ(sc, RT2860_WPDMA_GLO_CFG); - tmp &= 0xff0; + tmp &= ~(RT2860_RX_DMA_BUSY | RT2860_RX_DMA_EN | RT2860_TX_DMA_BUSY | + RT2860_TX_DMA_EN); + tmp |= RT2860_TX_WB_DDONE; RAL_WRITE(sc, RT2860_WPDMA_GLO_CFG, tmp); + /* reset DMA indexes */ + RAL_WRITE(sc, RT2860_WPDMA_RST_IDX, RT2860_RST_DRX_IDX0 | + RT2860_RST_DTX_IDX5 | RT2860_RST_DTX_IDX4 | RT2860_RST_DTX_IDX3 | + RT2860_RST_DTX_IDX2 | RT2860_RST_DTX_IDX1 | RT2860_RST_DTX_IDX0); + /* PBF hardware reset */ RAL_WRITE(sc, RT2860_SYS_CTRL, 0xe1f); RAL_BARRIER_WRITE(sc); @@ -3858,7 +3865,9 @@ rt2860_init_locked(struct rt2860_softc *sc) rt2860_stop_locked(sc); return; } - tmp &= 0xff0; + tmp &= ~(RT2860_RX_DMA_BUSY | RT2860_RX_DMA_EN | RT2860_TX_DMA_BUSY | + RT2860_TX_DMA_EN); + tmp |= RT2860_TX_WB_DDONE; RAL_WRITE(sc, RT2860_WPDMA_GLO_CFG, tmp); /* reset Rx ring and all 6 Tx rings */ @@ -3958,7 +3967,9 @@ rt2860_init_locked(struct rt2860_softc *sc) rt2860_stop_locked(sc); return; } - tmp &= 0xff0; + tmp &= ~(RT2860_RX_DMA_BUSY | RT2860_RX_DMA_EN | RT2860_TX_DMA_BUSY | + RT2860_TX_DMA_EN); + tmp |= RT2860_TX_WB_DDONE; RAL_WRITE(sc, RT2860_WPDMA_GLO_CFG, tmp); /* disable interrupts mitigation */ diff --git a/sys/dev/ral/rt2860reg.h b/sys/dev/ral/rt2860reg.h index 5bd7dbbfa7ff..f79874e23994 100644 --- a/sys/dev/ral/rt2860reg.h +++ b/sys/dev/ral/rt2860reg.h @@ -257,6 +257,15 @@ #define RT2860_TX_DMA_BUSY (1 << 1) #define RT2860_TX_DMA_EN (1 << 0) +/* flags for register WPDMA_RST_IDX */ +#define RT2860_RST_DRX_IDX0 (1 << 16) +#define RT2860_RST_DTX_IDX5 (1 << 5) +#define RT2860_RST_DTX_IDX4 (1 << 4) +#define RT2860_RST_DTX_IDX3 (1 << 3) +#define RT2860_RST_DTX_IDX2 (1 << 2) +#define RT2860_RST_DTX_IDX1 (1 << 1) +#define RT2860_RST_DTX_IDX0 (1 << 0) + /* possible flags for register DELAY_INT_CFG */ #define RT2860_TXDLY_INT_EN (1U << 31) #define RT2860_TXMAX_PINT_SHIFT 24 @@ -1233,7 +1242,7 @@ static const struct rt2860_rate { { 20, 0xba }, \ { 21, 0xdb }, \ { 24, 0x16 }, \ - { 25, 0x01 }, \ + { 25, 0x03 }, \ { 29, 0x1f } #define RT5390_DEF_RF \