diff options
author | Andriy Voskoboinyk <avos@FreeBSD.org> | 2018-06-19 00:38:28 +0000 |
---|---|---|
committer | Andriy Voskoboinyk <avos@FreeBSD.org> | 2018-06-19 00:38:28 +0000 |
commit | 02e3fed58c638b7e9cb01c9853d622df2dd6f728 (patch) | |
tree | 292bc5e4e02d729332a3678dcf17b4e016a4d7ea /sys/dev/rtwn | |
parent | ecd4eb0056336e4563495b8eca0855c030d70bbe (diff) | |
download | src-02e3fed58c638b7e9cb01c9853d622df2dd6f728.tar.gz src-02e3fed58c638b7e9cb01c9853d622df2dd6f728.zip |
rtwn(4): decode some bit fields + merge duplicate code.
Add macros for R12A_RXDMA_PRO register (descriptions were seen in the
RTL8822B vendor driver) and merge 2 r21au_init_burstlen() copies.
No functional change intended.
Notes
Notes:
svn path=/head/; revision=335351
Diffstat (limited to 'sys/dev/rtwn')
-rw-r--r-- | sys/dev/rtwn/rtl8812a/r12a_reg.h | 10 | ||||
-rw-r--r-- | sys/dev/rtwn/rtl8812a/usb/r12au.h | 1 | ||||
-rw-r--r-- | sys/dev/rtwn/rtl8812a/usb/r12au_init.c | 33 | ||||
-rw-r--r-- | sys/dev/rtwn/rtl8821a/usb/r21au.h | 1 | ||||
-rw-r--r-- | sys/dev/rtwn/rtl8821a/usb/r21au_attach.c | 2 | ||||
-rw-r--r-- | sys/dev/rtwn/rtl8821a/usb/r21au_init.c | 11 |
6 files changed, 35 insertions, 23 deletions
diff --git a/sys/dev/rtwn/rtl8812a/r12a_reg.h b/sys/dev/rtwn/rtl8812a/r12a_reg.h index 41cc160f9d16..581e7078138d 100644 --- a/sys/dev/rtwn/rtl8812a/r12a_reg.h +++ b/sys/dev/rtwn/rtl8812a/r12a_reg.h @@ -58,6 +58,16 @@ /* Bits for R92C_LEDCFG2. */ #define R12A_LEDCFG2_ENA 0x20 +/* Bits for R12A_RXDMA_PRO. */ +#define R12A_DMA_MODE 0x02 +#define R12A_BURST_CNT_M 0x0c +#define R12A_BURST_CNT_S 2 +#define R12A_BURST_SZ_M 0x30 +#define R12A_BURST_SZ_S 4 +#define R12A_BURST_SZ_USB3 0 +#define R12A_BURST_SZ_USB2 1 +#define R12A_BURST_SZ_USB1 2 + /* Bits for R12A_CCK_CHECK. */ #define R12A_CCK_CHECK_BCN1 0x20 #define R12A_CCK_CHECK_5GHZ 0x80 diff --git a/sys/dev/rtwn/rtl8812a/usb/r12au.h b/sys/dev/rtwn/rtl8812a/usb/r12au.h index 55d132c7c8d9..1ea08a2d94dd 100644 --- a/sys/dev/rtwn/rtl8812a/usb/r12au.h +++ b/sys/dev/rtwn/rtl8812a/usb/r12au.h @@ -37,6 +37,7 @@ */ /* r12au_init.c */ void r12au_init_rx_agg(struct rtwn_softc *); +void r12au_init_burstlen_usb2(struct rtwn_softc *); void r12au_init_burstlen(struct rtwn_softc *); void r12au_init_ampdu_fwhw(struct rtwn_softc *); void r12au_init_ampdu(struct rtwn_softc *); diff --git a/sys/dev/rtwn/rtl8812a/usb/r12au_init.c b/sys/dev/rtwn/rtl8812a/usb/r12au_init.c index 06f9c5d5c201..9a6bc2bb7c8e 100644 --- a/sys/dev/rtwn/rtl8812a/usb/r12au_init.c +++ b/sys/dev/rtwn/rtl8812a/usb/r12au_init.c @@ -72,19 +72,32 @@ r12au_init_rx_agg(struct rtwn_softc *sc) } void +r12au_init_burstlen_usb2(struct rtwn_softc *sc) +{ + const uint8_t dma_count = R12A_DMA_MODE | SM(R12A_BURST_CNT, 3); + + if ((rtwn_read_1(sc, R92C_USB_INFO) & 0x30) == 0) { + /* Set burst packet length to 512 B. */ + rtwn_setbits_1(sc, R12A_RXDMA_PRO, R12A_BURST_SZ_M, + dma_count | SM(R12A_BURST_SZ, R12A_BURST_SZ_USB2)); + } else { + /* Set burst packet length to 64 B. */ + rtwn_setbits_1(sc, R12A_RXDMA_PRO, R12A_BURST_SZ_M, + dma_count | SM(R12A_BURST_SZ, R12A_BURST_SZ_USB1)); + } +} + +void r12au_init_burstlen(struct rtwn_softc *sc) { - if (rtwn_read_1(sc, R92C_TYPE_ID + 3) & 0x80) { - if ((rtwn_read_1(sc, R92C_USB_INFO) & 0x30) == 0) { - /* Set burst packet length to 512 B. */ - rtwn_setbits_1(sc, R12A_RXDMA_PRO, 0x20, 0x1e); - } else { - /* Set burst packet length to 64 B. */ - rtwn_setbits_1(sc, R12A_RXDMA_PRO, 0x10, 0x2e); - } - } else { /* USB 3.0 */ + const uint8_t dma_count = R12A_DMA_MODE | SM(R12A_BURST_CNT, 3); + + if (rtwn_read_1(sc, R92C_TYPE_ID + 3) & 0x80) + r12au_init_burstlen_usb2(sc); + else { /* USB 3.0 */ /* Set burst packet length to 1 KB. */ - rtwn_setbits_1(sc, R12A_RXDMA_PRO, 0x30, 0x0e); + rtwn_setbits_1(sc, R12A_RXDMA_PRO, R12A_BURST_SZ_M, + dma_count | SM(R12A_BURST_SZ, R12A_BURST_SZ_USB3)); rtwn_setbits_1(sc, 0xf008, 0x18, 0); } diff --git a/sys/dev/rtwn/rtl8821a/usb/r21au.h b/sys/dev/rtwn/rtl8821a/usb/r21au.h index 60aa476c7070..a327d2ad7fa6 100644 --- a/sys/dev/rtwn/rtl8821a/usb/r21au.h +++ b/sys/dev/rtwn/rtl8821a/usb/r21au.h @@ -37,7 +37,6 @@ */ /* r21au_init.c */ void r21au_init_tx_agg(struct rtwn_softc *); -void r21au_init_burstlen(struct rtwn_softc *); /* r21au_dfs.c */ void r21au_chan_check(void *, int); diff --git a/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c b/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c index 6c59b0ceef71..89a5bb870f7d 100644 --- a/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c +++ b/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c @@ -135,7 +135,7 @@ r21a_attach_private(struct rtwn_softc *sc) rs->rs_fix_spur = rtwn_nop_softc_chan; rs->rs_set_band_2ghz = r21a_set_band_2ghz; rs->rs_set_band_5ghz = r21a_set_band_5ghz; - rs->rs_init_burstlen = r21au_init_burstlen; + rs->rs_init_burstlen = r12au_init_burstlen_usb2; rs->rs_init_ampdu_fwhw = r21a_init_ampdu_fwhw; rs->rs_crystalcap_write = r21a_crystalcap_write; #ifndef RTWN_WITHOUT_UCODE diff --git a/sys/dev/rtwn/rtl8821a/usb/r21au_init.c b/sys/dev/rtwn/rtl8821a/usb/r21au_init.c index 08af2af318ca..140c291473d9 100644 --- a/sys/dev/rtwn/rtl8821a/usb/r21au_init.c +++ b/sys/dev/rtwn/rtl8821a/usb/r21au_init.c @@ -70,14 +70,3 @@ r21au_init_tx_agg(struct rtwn_softc *sc) rtwn_write_1(sc, R21A_DWBCN1_CTRL, uc->tx_agg_desc_num << 1); } -void -r21au_init_burstlen(struct rtwn_softc *sc) -{ - if ((rtwn_read_1(sc, R92C_USB_INFO) & 0x30) == 0) { - /* Set burst packet length to 512 B. */ - rtwn_setbits_1(sc, R12A_RXDMA_PRO, 0x20, 0x1e); - } else { - /* Set burst packet length to 64 B. */ - rtwn_setbits_1(sc, R12A_RXDMA_PRO, 0x10, 0x2e); - } -} |