svn commit: r335351 - in head/sys/dev/rtwn: rtl8812a rtl8812a/usb rtl8821a/usb
Andriy Voskoboinyk
avos at FreeBSD.org
Tue Jun 19 00:38:30 UTC 2018
Author: avos
Date: Tue Jun 19 00:38:28 2018
New Revision: 335351
URL: https://svnweb.freebsd.org/changeset/base/335351
Log:
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.
Modified:
head/sys/dev/rtwn/rtl8812a/r12a_reg.h
head/sys/dev/rtwn/rtl8812a/usb/r12au.h
head/sys/dev/rtwn/rtl8812a/usb/r12au_init.c
head/sys/dev/rtwn/rtl8821a/usb/r21au.h
head/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c
head/sys/dev/rtwn/rtl8821a/usb/r21au_init.c
Modified: head/sys/dev/rtwn/rtl8812a/r12a_reg.h
==============================================================================
--- head/sys/dev/rtwn/rtl8812a/r12a_reg.h Tue Jun 19 00:27:30 2018 (r335350)
+++ head/sys/dev/rtwn/rtl8812a/r12a_reg.h Tue Jun 19 00:38:28 2018 (r335351)
@@ -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
Modified: head/sys/dev/rtwn/rtl8812a/usb/r12au.h
==============================================================================
--- head/sys/dev/rtwn/rtl8812a/usb/r12au.h Tue Jun 19 00:27:30 2018 (r335350)
+++ head/sys/dev/rtwn/rtl8812a/usb/r12au.h Tue Jun 19 00:38:28 2018 (r335351)
@@ -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 *);
Modified: head/sys/dev/rtwn/rtl8812a/usb/r12au_init.c
==============================================================================
--- head/sys/dev/rtwn/rtl8812a/usb/r12au_init.c Tue Jun 19 00:27:30 2018 (r335350)
+++ head/sys/dev/rtwn/rtl8812a/usb/r12au_init.c Tue Jun 19 00:38:28 2018 (r335351)
@@ -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);
}
Modified: head/sys/dev/rtwn/rtl8821a/usb/r21au.h
==============================================================================
--- head/sys/dev/rtwn/rtl8821a/usb/r21au.h Tue Jun 19 00:27:30 2018 (r335350)
+++ head/sys/dev/rtwn/rtl8821a/usb/r21au.h Tue Jun 19 00:38:28 2018 (r335351)
@@ -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);
Modified: head/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c
==============================================================================
--- head/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c Tue Jun 19 00:27:30 2018 (r335350)
+++ head/sys/dev/rtwn/rtl8821a/usb/r21au_attach.c Tue Jun 19 00:38:28 2018 (r335351)
@@ -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
Modified: head/sys/dev/rtwn/rtl8821a/usb/r21au_init.c
==============================================================================
--- head/sys/dev/rtwn/rtl8821a/usb/r21au_init.c Tue Jun 19 00:27:30 2018 (r335350)
+++ head/sys/dev/rtwn/rtl8821a/usb/r21au_init.c Tue Jun 19 00:38:28 2018 (r335351)
@@ -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);
- }
-}
More information about the svn-src-all
mailing list