aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/rtwn/rtl8188f/r88f.h2
-rw-r--r--sys/dev/rtwn/rtl8188f/r88f_chan.c6
-rw-r--r--sys/dev/rtwn/rtl8188f/r88f_init.c2
-rw-r--r--sys/dev/rtwn/rtl8188f/usb/r88fu.h1
-rw-r--r--sys/dev/rtwn/rtl8188f/usb/r88fu_init.c2
-rw-r--r--sys/dev/rtwn/rtl8192c/r92c_init.c1
-rw-r--r--sys/dev/rtwn/rtl8192e/usb/r92eu_attach.c1
-rw-r--r--sys/dev/rtwn/rtl8192f/r92f.h71
-rw-r--r--sys/dev/rtwn/rtl8192f/r92f_beacon.c47
-rw-r--r--sys/dev/rtwn/rtl8192f/r92f_calib.c1087
-rw-r--r--sys/dev/rtwn/rtl8192f/r92f_chan.c332
-rw-r--r--sys/dev/rtwn/rtl8192f/r92f_fw.c100
-rw-r--r--sys/dev/rtwn/rtl8192f/r92f_init.c114
-rw-r--r--sys/dev/rtwn/rtl8192f/r92f_led.c79
-rw-r--r--sys/dev/rtwn/rtl8192f/r92f_priv.h320
-rw-r--r--sys/dev/rtwn/rtl8192f/r92f_reg.h90
-rw-r--r--sys/dev/rtwn/rtl8192f/r92f_rom.c134
-rw-r--r--sys/dev/rtwn/rtl8192f/r92f_rom_defs.h15
-rw-r--r--sys/dev/rtwn/rtl8192f/r92f_rom_image.h47
-rw-r--r--sys/dev/rtwn/rtl8192f/r92f_rx.c171
-rw-r--r--sys/dev/rtwn/rtl8192f/r92f_rx_desc.h48
-rw-r--r--sys/dev/rtwn/rtl8192f/r92f_tx.c107
-rw-r--r--sys/dev/rtwn/rtl8192f/r92f_var.h29
-rw-r--r--sys/dev/rtwn/rtl8192f/usb/r92fu.h31
-rw-r--r--sys/dev/rtwn/rtl8192f/usb/r92fu_attach.c232
-rw-r--r--sys/dev/rtwn/rtl8192f/usb/r92fu_init.c544
-rw-r--r--sys/dev/rtwn/rtl8192f/usb/r92fu_reg.h16
-rw-r--r--sys/dev/rtwn/rtl8192f/usb/r92fu_tx.c53
-rw-r--r--sys/dev/rtwn/usb/rtwn_usb_attach.h11
-rw-r--r--sys/dev/usb/usbdevs3
30 files changed, 3689 insertions, 7 deletions
diff --git a/sys/dev/rtwn/rtl8188f/r88f.h b/sys/dev/rtwn/rtl8188f/r88f.h
index b3160c208aa2..05308c7815cf 100644
--- a/sys/dev/rtwn/rtl8188f/r88f.h
+++ b/sys/dev/rtwn/rtl8188f/r88f.h
@@ -40,6 +40,7 @@ int r88f_set_page_size(struct rtwn_softc *);
void r88f_init_ampdu(struct rtwn_softc *);
int r88f_llt_init(struct rtwn_softc *);
void r88f_init_rf(struct rtwn_softc *);
+int r88f_read_efuse_1(struct rtwn_softc *, uint16_t, uint8_t *);
/* r88f_calib.c */
void r88f_lc_calib(struct rtwn_softc *);
@@ -49,6 +50,7 @@ void r88f_iq_calib(struct rtwn_softc *);
void r88f_set_chan(struct rtwn_softc *, struct ieee80211_channel *);
void r88f_get_txpower(struct rtwn_softc *, int, struct ieee80211_channel *,
uint8_t[RTWN_RIDX_COUNT]);
+int r88f_chan2group(int);
/* r88f_fw.c */
void r88f_fw_reset(struct rtwn_softc *, int);
diff --git a/sys/dev/rtwn/rtl8188f/r88f_chan.c b/sys/dev/rtwn/rtl8188f/r88f_chan.c
index e9ec8f89c126..11bca227cf4b 100644
--- a/sys/dev/rtwn/rtl8188f/r88f_chan.c
+++ b/sys/dev/rtwn/rtl8188f/r88f_chan.c
@@ -47,8 +47,8 @@
#include <dev/rtwn/rtl8188f/r88f.h>
#include <dev/rtwn/rtl8188f/r88f_reg.h>
-static int
-rtwn_chan2group(int chan)
+int
+r88f_chan2group(int chan)
{
int group;
@@ -79,7 +79,7 @@ r88f_get_txpower(struct rtwn_softc *sc, int chain,
/* Determine channel group. */
chan = rtwn_chan2centieee(c); /* XXX center freq! */
- group = rtwn_chan2group(chan);
+ group = r88f_chan2group(chan);
memset(power, 0, R88F_RTWN_POWER_COUNT * sizeof(power[0]));
diff --git a/sys/dev/rtwn/rtl8188f/r88f_init.c b/sys/dev/rtwn/rtl8188f/r88f_init.c
index 6d7464b9d5e4..9032532a7025 100644
--- a/sys/dev/rtwn/rtl8188f/r88f_init.c
+++ b/sys/dev/rtwn/rtl8188f/r88f_init.c
@@ -90,7 +90,7 @@ r88f_init_ampdu(struct rtwn_softc *sc)
R92C_RSV_CTRL_R_DIS_PRST_0 | R92C_RSV_CTRL_R_DIS_PRST_1);
}
-static int
+int
r88f_read_efuse_1(struct rtwn_softc *sc, uint16_t offset, uint8_t *data)
{
int i;
diff --git a/sys/dev/rtwn/rtl8188f/usb/r88fu.h b/sys/dev/rtwn/rtl8188f/usb/r88fu.h
index b79c64dedf48..8e0e2894e03e 100644
--- a/sys/dev/rtwn/rtl8188f/usb/r88fu.h
+++ b/sys/dev/rtwn/rtl8188f/usb/r88fu.h
@@ -20,5 +20,6 @@ void r88fu_init_rx_agg(struct rtwn_softc *);
void r88fu_init_tx_agg(struct rtwn_softc *);
void r88fu_init_bb(struct rtwn_softc *);
void r88fu_post_init(struct rtwn_softc *);
+int r88fu_flush_fifo(struct rtwn_softc *);
#endif /* RTL8188FU_H */
diff --git a/sys/dev/rtwn/rtl8188f/usb/r88fu_init.c b/sys/dev/rtwn/rtl8188f/usb/r88fu_init.c
index 66bbf79a9342..86815c7049e4 100644
--- a/sys/dev/rtwn/rtl8188f/usb/r88fu_init.c
+++ b/sys/dev/rtwn/rtl8188f/usb/r88fu_init.c
@@ -151,7 +151,7 @@ r88fu_power_on(struct rtwn_softc *sc)
#define R88F_RXPKT_NUM_RW_RELEASE_ENABLE 0x00040000
#define R88F_RXPKT_NUM_RXDMA_IDLE 0x00020000
-static int
+int
r88fu_flush_fifo(struct rtwn_softc *sc)
{
uint32_t reg;
diff --git a/sys/dev/rtwn/rtl8192c/r92c_init.c b/sys/dev/rtwn/rtl8192c/r92c_init.c
index 8697c526ec06..1e8c41fd82cf 100644
--- a/sys/dev/rtwn/rtl8192c/r92c_init.c
+++ b/sys/dev/rtwn/rtl8192c/r92c_init.c
@@ -210,7 +210,6 @@ r92c_init_rf_chain(struct rtwn_softc *sc,
RTWN_DPRINTF(sc, RTWN_DEBUG_RESET,
"RF: reg 0x%02x, val 0x%05x\n",
prog->reg[j], prog->val[j]);
-
/*
* These are fake RF registers offsets that
* indicate a delay is required.
diff --git a/sys/dev/rtwn/rtl8192e/usb/r92eu_attach.c b/sys/dev/rtwn/rtl8192e/usb/r92eu_attach.c
index c850d29664b5..a8a589a0c287 100644
--- a/sys/dev/rtwn/rtl8192e/usb/r92eu_attach.c
+++ b/sys/dev/rtwn/rtl8192e/usb/r92eu_attach.c
@@ -43,7 +43,6 @@
#include <dev/rtwn/if_rtwnreg.h>
#include <dev/rtwn/if_rtwnvar.h>
-
#include <dev/rtwn/if_rtwn_fw.h>
#include <dev/rtwn/if_rtwn_nop.h>
diff --git a/sys/dev/rtwn/rtl8192f/r92f.h b/sys/dev/rtwn/rtl8192f/r92f.h
new file mode 100644
index 000000000000..68510dc05648
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/r92f.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef RTL8192F_H
+#define RTL8192F_H
+
+#include <dev/rtwn/if_rtwn_ridx.h>
+
+/*
+ * Global Definitions.
+ */
+#define R92F_HQ_NPAGES 8
+#define R92F_LQ_NPAGES 8
+#define R92F_NQ_NPAGES 8
+#define R92F_PUBQ_NPAGES 0xde
+#define R92F_CAM_ENTRY_COUNT 64
+#define R92F_TXPKTBUF_COUNT 177
+#define R92F_TX_PAGE_COUNT 247
+#define R92F_RX_DMA_BUFFER_SIZE 0x3f40
+#define R92F_MAX_FW_SIZE 31136
+#define R92F_RTWN_POWER_COUNT 28
+#define R92F_FW_START_ADDR 0x4000
+#define R92F_MACID_MAX 127
+
+/*
+ * Function declarations.
+ */
+
+/* r92f_beacon.c */
+void r92f_beacon_init(struct rtwn_softc *, void *, int);
+
+/* r92f_calib.c */
+void r92f_lc_calib(struct rtwn_softc *);
+void r92f_iq_calib(struct rtwn_softc *);
+
+/* r92f_chan.c */
+int r92f_set_tx_power(struct rtwn_softc *, struct ieee80211vap *);
+void r92f_set_chan(struct rtwn_softc *, struct ieee80211_channel *);
+
+/* r92f_init.c */
+void r92f_init_bb(struct rtwn_softc *);
+
+/* r92f_rom.c */
+void r92f_parse_rom(struct rtwn_softc *, uint8_t *);
+
+/* r92f_rx.c */
+int8_t r92f_get_rssi_cck(struct rtwn_softc *, void *);
+int8_t r92f_get_rssi_ofdm(struct rtwn_softc *, void *);
+void r92f_get_rx_stats(struct rtwn_softc *, struct ieee80211_rx_stats *,
+ const void *, const void *);
+
+/* r92f_tx.c */
+void r92f_tx_setup_macid(void *, int);
+void r92f_fill_tx_desc(struct rtwn_softc *, struct ieee80211_node *,
+ struct mbuf *, void *, uint8_t, bool, int);
+void r92f_fill_tx_desc_raw(struct rtwn_softc *, struct ieee80211_node *,
+ struct mbuf *, void *, const struct ieee80211_bpf_params *);
+void r92f_fill_tx_desc_null(struct rtwn_softc *, void *, int, int, int);
+
+/* r92f_fw.c */
+void r92f_fw_reset(struct rtwn_softc *, int);
+void r92f_fw_download_enable(struct rtwn_softc *, int);
+int r92f_fw_write_finish(struct rtwn_softc *);
+
+/* r92f_led.c */
+void r92f_set_led(struct rtwn_softc *, int, int);
+
+#endif /* RTL8192F_H */
diff --git a/sys/dev/rtwn/rtl8192f/r92f_beacon.c b/sys/dev/rtwn/rtl8192f/r92f_beacon.c
new file mode 100644
index 000000000000..6baed771e425
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/r92f_beacon.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/cdefs.h>
+#include "opt_wlan.h"
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/mbuf.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
+#include <sys/taskqueue.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/linker.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_media.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
+
+#include <dev/rtwn/if_rtwnreg.h>
+#include <dev/rtwn/if_rtwnvar.h>
+
+#include <dev/rtwn/rtl8812a/r12a.h>
+#include <dev/rtwn/rtl8812a/r12a_tx_desc.h>
+
+#include <dev/rtwn/rtl8192f/r92f.h>
+
+void
+r92f_beacon_init(struct rtwn_softc *sc, void *buf, int id)
+{
+ struct r12a_tx_desc *txd = (struct r12a_tx_desc *)buf;
+
+ r12a_beacon_init(sc, buf, id);
+
+ txd->flags0 &= ~(R12A_FLAGS0_LSG | R12A_FLAGS0_FSG);
+}
diff --git a/sys/dev/rtwn/rtl8192f/r92f_calib.c b/sys/dev/rtwn/rtl8192f/r92f_calib.c
new file mode 100644
index 000000000000..a680fd4d96c8
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/r92f_calib.c
@@ -0,0 +1,1087 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/cdefs.h>
+#include "opt_wlan.h"
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/mbuf.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
+#include <sys/taskqueue.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/linker.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_media.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
+
+#include <dev/rtwn/if_rtwnreg.h>
+#include <dev/rtwn/if_rtwnvar.h>
+
+#include <dev/rtwn/if_rtwn_debug.h>
+
+#include <dev/rtwn/rtl8188e/r88e.h>
+#include <dev/rtwn/rtl8188e/r88e_reg.h>
+
+#include <dev/rtwn/rtl8188f/r88f.h>
+#include <dev/rtwn/rtl8188f/r88f_reg.h>
+
+#include <dev/rtwn/rtl8192c/r92c_reg.h>
+
+#include <dev/rtwn/rtl8192f/r92f.h>
+#include <dev/rtwn/rtl8192f/r92f_reg.h>
+#include <dev/rtwn/rtl8192f/r92f_var.h>
+
+#define LC_BACKUP_M 0xc0000000
+#define LC_BACKUP_S 30
+
+void
+r92f_lc_calib(struct rtwn_softc *sc)
+{
+ uint32_t backup;
+ uint32_t reg;
+
+ /*
+ * Init GPIO settings for 8192f
+ */
+ rtwn_setbits_1(sc, R92C_GPIO_MUXCFG, R92C_GPIO_MUXCFG_ENBT, 0);
+
+ /* Aries's NarrowBand */
+ reg = rtwn_bb_read(sc, R92C_OFDM0_TXPSEUDONOISEWGT);
+ backup = MS(reg, LC_BACKUP);
+
+ reg = RW(reg, LC_BACKUP, 0);
+ rtwn_bb_write(sc, R92C_OFDM0_TXPSEUDONOISEWGT, reg);
+
+ r88f_lc_calib(sc);
+
+ /* Aries's NarrowBand */
+ reg = rtwn_bb_read(sc, R92C_OFDM0_TXPSEUDONOISEWGT);
+ reg = RW(reg, LC_BACKUP, backup);
+ rtwn_bb_write(sc, R92C_OFDM0_TXPSEUDONOISEWGT, reg);
+
+ /* reset OFDM state */
+ rtwn_bb_setbits(sc, R92C_FPGA0_RFMOD, R92C_RFMOD_OFDM_EN, 0);
+ rtwn_bb_setbits(sc, R92C_FPGA0_RFMOD, 0, R92C_RFMOD_OFDM_EN);
+}
+
+#define PATH_A 0
+#define PATH_B 1
+
+#define R92F_IQK_MAX_PATHS 2
+#define R92F_IQK_MAX_TOLERANCE 5
+#define R92F_IQK_POLL_MAX 21
+#define R92F_IQK_POLL_STEP 5
+#define R92F_IQK_MAX_RETRIES 2
+#define R92F_RXIQB_EXT 0xca8
+
+#define R92F_ADDA_REGS 2
+#define R92F_MAC_REGS 4
+#define R92F_BB_REGS 9
+
+struct r92f_iqk_regs_vals {
+ uint32_t adda_regs[R92F_ADDA_REGS];
+ uint32_t mac_regs[R92F_MAC_REGS];
+ uint32_t bb_regs[R92F_BB_REGS];
+ uint32_t hssi_param1;
+};
+
+struct r92f_iqk_result {
+ int32_t before;
+ int32_t after;
+};
+
+static const uint32_t iqk_adda_regs[R92F_ADDA_REGS] = {
+ R92F_ANAPWR1, R88F_RX_WAIT_CCA
+};
+static const uint32_t iqk_mac_regs[R92F_MAC_REGS] = {
+ R92C_TXPAUSE, R92C_BCN_CTRL(0),
+ R92C_BCN_CTRL(1), R92C_GPIO_MUXCFG
+};
+static const uint32_t iqk_bb_regs[R92F_BB_REGS] = {
+ R92C_OFDM0_TRXPATHENA, R92C_OFDM0_TRMUXPAR,
+ R88F_FPGA0_XCD_RF_SW_CTRL, R92C_CONFIG_ANT(0), R92C_CONFIG_ANT(1),
+ R92F_DPDT_CTRL, R92F_RFE_CTRL_ANT_SRC(0),
+ R92F_RFE_CTRL_ANT_SRC(2), R92C_CCK0_AFESETTING
+};
+
+static void
+r92f_iqk_save_regs(struct rtwn_softc *sc, struct r92f_iqk_regs_vals *backup)
+{
+ int i;
+
+ for (i = 0; i < R92F_ADDA_REGS; i++)
+ backup->adda_regs[i] = rtwn_bb_read(sc, iqk_adda_regs[i]);
+
+ for (i = 0; i < R92F_MAC_REGS - 1; i++)
+ backup->mac_regs[i] = rtwn_read_1(sc, iqk_mac_regs[i]);
+
+ backup->mac_regs[i] = rtwn_bb_read(sc, iqk_mac_regs[i]);
+
+ for (i = 0; i < R92F_BB_REGS; i++)
+ backup->bb_regs[i] = rtwn_bb_read(sc, iqk_bb_regs[i]);
+}
+
+static void
+r92f_iqk_restore_regs(struct rtwn_softc *sc, struct r92f_iqk_regs_vals *backup)
+{
+ int i;
+
+ for (i = 0; i < R92F_ADDA_REGS; i++)
+ rtwn_bb_write(sc, iqk_adda_regs[i], backup->adda_regs[i]);
+
+ for (i = 0; i < R92F_MAC_REGS - 1; i++)
+ rtwn_write_1(sc, iqk_mac_regs[i], backup->mac_regs[i]);
+
+ rtwn_bb_write(sc, iqk_mac_regs[i], backup->mac_regs[i]);
+
+ for (i = 0; i < R92F_BB_REGS; i++)
+ rtwn_bb_write(sc, iqk_bb_regs[i], backup->bb_regs[i]);
+}
+
+static void
+r92f_iqk_setup_bb(struct rtwn_softc *sc, uint32_t hssi_param1)
+{
+ rtwn_bb_write(sc, R88F_FPGA0_ANALOG4, 0xccf000c0);
+ rtwn_bb_write(sc, R92F_ANAPWR1, 0x44ffbb44);
+ rtwn_bb_write(sc, R88F_RX_WAIT_CCA, 0x00400040);
+ rtwn_bb_write(sc, R92C_OFDM0_TRXPATHENA, 0x6f005403);
+ rtwn_bb_write(sc, R92C_OFDM0_TRMUXPAR, 0x000804e4);
+ rtwn_bb_write(sc, R88F_FPGA0_XCD_RF_SW_CTRL, 0x04203400);
+ rtwn_bb_write(sc, R92C_HSSI_PARAM1(0), hssi_param1);
+}
+
+/* One shot, path A LOK & IQK */
+static void
+r92f_iqk_one_shot(struct rtwn_softc *sc)
+{
+ rtwn_bb_write(sc, R92C_IQK_AGC_PTS, 0xfa005800);
+ rtwn_bb_write(sc, R92C_IQK_AGC_PTS, 0xf8005800);
+}
+
+static void
+r92f_iqk_poll(struct rtwn_softc *sc, uint32_t reg)
+{
+ int ktime;
+
+ ktime = 0;
+
+ while (rtwn_bb_read(sc, reg) == 0 && ktime < R92F_IQK_POLL_MAX) {
+ rtwn_delay(sc, R92F_IQK_POLL_STEP * 1000);
+ ktime += R92F_IQK_POLL_STEP;
+ }
+}
+
+
+static bool
+r92f_iq_calib_compare_results(struct rtwn_softc *sc, int result[][8],
+ int c1, int c2)
+{
+ uint32_t i, j, diff, simubitmap, bound;
+ int candidate[2] = {-1, -1}; /* for path A and path B */
+ int tmp1, tmp2;
+ bool retval = true;
+
+ if (sc->ntxchains > 1)
+ bound = 8;
+ else
+ bound = 4;
+
+ simubitmap = 0;
+
+ for (i = 0; i < bound; i++) {
+ if (i & 1) {
+ if ((result[c1][i] & 0x00000200))
+ tmp1 = result[c1][i] | 0xfffffc00;
+ else
+ tmp1 = result[c1][i];
+
+ if ((result[c2][i]& 0x00000200))
+ tmp2 = result[c2][i] | 0xfffffc00;
+ else
+ tmp2 = result[c2][i];
+ } else {
+ tmp1 = result[c1][i];
+ tmp2 = result[c2][i];
+ }
+
+ diff = (tmp1 > tmp2) ? (tmp1 - tmp2) : (tmp2 - tmp1);
+
+ if (diff > R92F_IQK_MAX_TOLERANCE) {
+ if ((i == 2 || i == 6) && !simubitmap) {
+ if (result[c1][i] + result[c1][i + 1] == 0)
+ candidate[(i / 4)] = c2;
+ else if (result[c2][i] + result[c2][i + 1] == 0)
+ candidate[(i / 4)] = c1;
+ else
+ simubitmap = simubitmap | (1 << i);
+ } else {
+ simubitmap = simubitmap | (1 << i);
+ }
+ }
+ }
+
+ if (simubitmap == 0) {
+ for (i = 0; i < (bound / 4); i++) {
+ if (candidate[i] >= 0) {
+ for (j = i * 4; j < (i + 1) * 4 - 2; j++)
+ result[3][j] = result[candidate[i]][j];
+ retval = false;
+ }
+ }
+ return retval;
+ } else {
+ if (!(simubitmap & 0x03)) {
+ /* path A TX OK */
+ for (i = 0; i < 2; i++)
+ result[3][i] = result[c1][i];
+ }
+
+ if (!(simubitmap & 0x0c)) {
+ /* path A RX OK */
+ for (i = 2; i < 4; i++)
+ result[3][i] = result[c1][i];
+ }
+
+ if (!(simubitmap & 0x30) && sc->ntxchains > 1) {
+ /* path B TX OK */
+ for (i = 4; i < 6; i++)
+ result[3][i] = result[c1][i];
+ }
+
+ if (!(simubitmap & 0xc0) && sc->ntxchains > 1) {
+ /* path B RX OK */
+ for (i = 6; i < 8; i++)
+ result[3][i] = result[c1][i];
+ }
+ }
+
+ return false;
+}
+
+static void
+r92f_fill_iqk_matrix_a(struct rtwn_softc *sc, bool path_ok, int result[][8],
+ int candidate, bool tx_only)
+{
+ uint32_t oldval, x, tx0_a, result_reg;
+ int y, tx0_c;
+ uint32_t reg;
+
+ if (!path_ok)
+ return;
+
+ reg = rtwn_bb_read(sc, R92C_OFDM0_TXIQIMBALANCE(0));
+ oldval = reg >> 22;
+
+ x = result[candidate][0];
+ if ((x & 0x00000200) != 0)
+ x = x | 0xfffffc00;
+ tx0_a = (x * oldval) >> 8;
+
+ reg = rtwn_bb_read(sc, R92C_OFDM0_TXIQIMBALANCE(0));
+ reg &= ~0x3ff;
+ reg |= tx0_a;
+ rtwn_bb_write(sc, R92C_OFDM0_TXIQIMBALANCE(0), reg);
+
+ reg = rtwn_bb_read(sc, R92C_OFDM0_ECCATHRESHOLD);
+ reg &= ~0x80000000;
+ if ((x * oldval >> 7) & 0x1)
+ reg |= 0x80000000;
+ rtwn_bb_write(sc, R92C_OFDM0_ECCATHRESHOLD, reg);
+
+ y = result[candidate][1];
+ if ((y & 0x00000200) != 0)
+ y |= 0xfffffc00;
+ tx0_c = (y * oldval) >> 8;
+
+ rtwn_bb_setbits(sc, R92C_OFDM0_TXAFE(0), 0xf0000000,
+ ((tx0_c & 0x3c0) >> 6) << 28);
+
+ rtwn_bb_setbits(sc, R92C_OFDM0_TXIQIMBALANCE(0), 0x003f0000,
+ ((tx0_c & 0x3f) << 16));
+
+ reg = rtwn_bb_read(sc, R92C_OFDM0_ECCATHRESHOLD);
+ reg &= ~0x20000000;
+ if ((y * oldval >> 7) & 0x1)
+ reg |= 0x20000000;
+ rtwn_bb_write(sc, R92C_OFDM0_ECCATHRESHOLD, reg);
+
+ if (tx_only) {
+ RTWN_DPRINTF(sc, RTWN_DEBUG_CALIB, "%s: only TX\n", __func__);
+ return;
+ }
+
+ result_reg = result[candidate][2];
+ rtwn_bb_setbits(sc, R92C_OFDM0_RXIQIMBALANCE(0), 0x3ff,
+ result_reg & 0x3ff);
+
+ result_reg = result[candidate][3] & 0x3f;
+ rtwn_bb_setbits(sc, R92C_OFDM0_RXIQIMBALANCE(0), 0xfc00,
+ (result_reg << 10) & 0xfc00);
+
+ result_reg = (result[candidate][3] >> 6) & 0xf;
+ rtwn_bb_setbits(sc, R92C_OFDM0_RXIQEXTANTA, 0xf0000000,
+ result_reg << 28);
+}
+
+static void
+r92f_fill_iqk_matrix_b(struct rtwn_softc *sc, bool path_ok, int result[][8],
+ int candidate, bool tx_only)
+{
+ uint32_t oldval, x, tx1_a, result_reg;
+ int y, tx1_c;
+ uint32_t reg;
+
+ if (!path_ok)
+ return;
+
+ reg = rtwn_bb_read(sc, R92C_OFDM0_TXIQIMBALANCE(1));
+ oldval = reg >> 22;
+
+ x = result[candidate][4];
+ if ((x & 0x00000200) != 0)
+ x = x | 0xfffffc00;
+ tx1_a = (x * oldval) >> 8;
+
+ rtwn_bb_setbits(sc, R92C_OFDM0_TXIQIMBALANCE(1), 0x3ff, tx1_a);
+
+ reg = rtwn_bb_read(sc, R92C_OFDM0_ECCATHRESHOLD);
+ reg &= ~0x8000000;
+ if ((x * oldval >> 7) & 0x1)
+ reg |= 0x8000000;
+ rtwn_bb_write(sc, R92C_OFDM0_ECCATHRESHOLD, reg);
+
+ y = result[candidate][5];
+ if ((y & 0x00000200) != 0)
+ y |= 0xfffffc00;
+ tx1_c = (y * oldval) >> 8;
+
+ rtwn_bb_setbits(sc, R92C_OFDM0_TXAFE(1), 0xf0000000,
+ ((tx1_c & 0x3c0) >> 6) << 28);
+
+ rtwn_bb_setbits(sc, R92C_OFDM0_TXIQIMBALANCE(1), 0x003f0000,
+ (tx1_c & 0x3f) << 16);
+
+ reg = rtwn_bb_read(sc, R92C_OFDM0_ECCATHRESHOLD);
+ reg &= ~0x2000000;
+ if ((y * oldval >> 7) & 0x1)
+ reg |= 0x2000000;
+ rtwn_bb_write(sc, R92C_OFDM0_ECCATHRESHOLD, reg);
+
+ if (tx_only) {
+ RTWN_DPRINTF(sc, RTWN_DEBUG_CALIB, "%s: only TX\n", __func__);
+ return;
+ }
+
+ result_reg = result[candidate][6];
+ rtwn_bb_setbits(sc, R92C_OFDM0_RXIQIMBALANCE(1), 0x3ff,
+ result_reg & 0x3ff);
+
+ result_reg = result[candidate][7] & 0x3f;
+ rtwn_bb_setbits(sc, R92C_OFDM0_RXIQIMBALANCE(1), 0xfc00,
+ (result_reg << 10) & 0xfc00);
+
+ result_reg = (result[candidate][7] >> 6) & 0xf;
+ rtwn_bb_setbits(sc, R92F_RXIQB_EXT, 0x000000f0, result_reg << 4);
+}
+
+static int
+r92f_iqk_tx_path_a(struct rtwn_softc *sc)
+{
+ struct r92f_softc *rs = sc->sc_priv;
+ struct r92f_iqk_result tx_result;
+ struct r92f_iqk_result rx_result;
+ uint32_t rf_0x58_i, rf_0x58_q, reg;
+ uint8_t rfe = rs->rfe;
+ int result = 0;
+ int i;
+
+ /* Leave IQK mode */
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0);
+
+ r92f_iqk_setup_bb(sc, 0x01000100);
+
+ rtwn_rf_setbits(sc, 0, R88F_RF_GAIN_CCA, 0x10, 0x10);
+ rtwn_rf_setbits(sc, 0, R88F_RF_GAIN_CCA, 0x800, 0x800);
+
+ if (rfe == 7 || rfe == 8 || rfe == 9 || rfe == 12)
+ reg = 0x30;
+ else
+ reg = 0xe9;
+
+ rtwn_rf_setbits(sc, 0, R88F_RF_PAD_TXG, 0x003ff, reg);
+
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0x80800000);
+
+ /* path-A IQK setting */
+ rtwn_bb_write(sc, R92C_TX_IQK_TONE(0), 0x18008c1c);
+ rtwn_bb_write(sc, R92C_RX_IQK_TONE(0), 0x38008c1c);
+ rtwn_bb_write(sc, R92C_TX_IQK_TONE(1), 0x38008c1c);
+ rtwn_bb_write(sc, R92C_RX_IQK_TONE(1), 0x38008c1c);
+
+ rtwn_bb_write(sc, R92C_TX_IQK_PI(0), 0x8214000f);
+ rtwn_bb_write(sc, R92C_RX_IQK_PI(0), 0x28140000);
+
+ rtwn_bb_write(sc, R92C_TX_IQK, 0x01007c00);
+ rtwn_bb_write(sc, R92C_RX_IQK, 0x01004800);
+
+ /* LO calibration setting */
+ rtwn_bb_write(sc, R92C_IQK_AGC_RSP, 0x00e62911);
+
+ r92f_iqk_one_shot(sc);
+ rtwn_delay(sc, 15000); /* wait 15ms */
+
+ r92f_iqk_poll(sc, R92F_IQK_RPT_TXA);
+
+ /* Check failed */
+ rx_result.after = rtwn_bb_read(sc, R92C_RX_POWER_IQK_AFTER(0));
+ tx_result.before = rtwn_bb_read(sc, R92C_TX_POWER_IQK_BEFORE(0));
+ tx_result.after = rtwn_bb_read(sc, R92C_TX_POWER_IQK_AFTER(0));
+
+ /* reload 0xdf and CCK_IND off */
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0);
+
+ rtwn_rf_setbits(sc, 0, R88E_RF_WE_LUT, 0x10, 0x10);
+
+ reg = rtwn_rf_read(sc, 0, R92F_RF_TXMOD);
+ rf_0x58_i = (reg & 0x000fc000) >> 14;
+ rf_0x58_q = (reg & 0x003f0) >> 4;
+
+ for (i = 0; i < 8; i++) {
+ rtwn_rf_setbits(sc, 0, R92C_RF_TXPA_G(2), 0x1c000, i << 14);
+ rtwn_rf_setbits(sc, 0, R92C_RF_TXPA_G(2), 0x00fc0, rf_0x58_i << 6);
+ rtwn_rf_setbits(sc, 0, R92C_RF_TXPA_G(2), 0x0003f, rf_0x58_q);
+ }
+
+ rtwn_rf_setbits(sc, 0, R92C_RF_AC, 0x4000, 0);
+ rtwn_rf_setbits(sc, 0, R88E_RF_WE_LUT, 0x10, 0);
+ rtwn_rf_setbits(sc, 0, R88F_RF_GAIN_CCA, 0x00810, 0);
+
+ if (!(rx_result.after & 0x10000000) &&
+ ((tx_result.before & 0x03ff0000) != 0x01420000) &&
+ ((tx_result.after & 0x03ff0000) != 0x00420000))
+ result |= 0x01;
+
+ return (result);
+}
+
+static int
+r92f_iqk_tx_rx_path_a(struct rtwn_softc *sc)
+{
+ struct r92f_iqk_result rx_result;
+ struct r92f_iqk_result tx_result;
+ int result = 0;
+ uint32_t reg;
+
+ /* Leave IQK mode */
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0);
+
+ /* PA/PAD control by 0x56, and set = 0x0 */
+ rtwn_rf_setbits(sc, 0, R88F_RF_GAIN_CCA, 0x2, 0x2);
+ rtwn_rf_write(sc, 0, R92F_RF_GAIN_P1, 0);
+ rtwn_rf_setbits(sc, 0, R88F_RF_GAIN_CCA, 0x800, 0x800);
+ rtwn_rf_setbits(sc, 0, R88F_RF_PAD_TXG, 0x003ff, 0x27);
+
+ /* Enter IQK mode */
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0x80800000);
+
+ /* path-A IQK setting */
+ rtwn_bb_write(sc, R92C_TX_IQK_TONE(0), 0x18008c1c);
+ rtwn_bb_write(sc, R92C_RX_IQK_TONE(0), 0x38008c1c);
+ rtwn_bb_write(sc, R92C_TX_IQK_TONE(1), 0x38008c1c);
+ rtwn_bb_write(sc, R92C_RX_IQK_TONE(1), 0x38008c1c);
+
+ rtwn_bb_write(sc, R92C_TX_IQK_PI(0), 0x82160027);
+ rtwn_bb_write(sc, R92C_RX_IQK_PI(0), 0x28160000);
+
+ /* Tx IQK setting */
+ rtwn_bb_write(sc, R92C_TX_IQK, 0x01007c00);
+ rtwn_bb_write(sc, R92C_RX_IQK, 0x01004800);
+
+ /* LO calibration setting */
+ rtwn_bb_write(sc, R92C_IQK_AGC_RSP, 0x0086a911);
+
+ r92f_iqk_one_shot(sc);
+ rtwn_delay(sc, 15000); /* wait 15ms */
+
+ r92f_iqk_poll(sc, R92F_IQK_RPT_TXA);
+
+ /* Check failed */
+ rx_result.after = rtwn_bb_read(sc, R92C_RX_POWER_IQK_AFTER(0));
+ tx_result.before = rtwn_bb_read(sc, R92C_TX_POWER_IQK_BEFORE(0));
+ tx_result.after = rtwn_bb_read(sc, R92C_TX_POWER_IQK_AFTER(0));
+
+ if (!(rx_result.after & 0x10000000) &&
+ ((tx_result.before & 0x03ff0000) != 0x01420000) &&
+ ((tx_result.after & 0x03ff0000) != 0x00420000)) {
+ result |= 0x01;
+ } else { /* If TX not OK, ignore RX */
+ /* PA/PAD controlled by 0x0 */
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0);
+ rtwn_rf_setbits(sc, 0, R88F_RF_GAIN_CCA, 0x800, 0);
+
+ return (result);
+ }
+
+ reg = 0x80007c00 | (tx_result.before & 0x3ff0000) | ((tx_result.after & 0x3ff0000) >> 16);
+ rtwn_bb_write(sc, R92C_TX_IQK, reg);
+
+ /* Modify RX IQK mode table */
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0);
+
+ /* PA/PAD control by 0x56, and set = 0x0 */
+ rtwn_rf_setbits(sc, 0, R88F_RF_GAIN_CCA, 0x2, 0x2);
+ rtwn_rf_write(sc, 0, R92F_RF_GAIN_P1, 0);
+ rtwn_rf_setbits(sc, 0, R88F_RF_GAIN_CCA, 0x800, 0x800);
+ rtwn_rf_setbits(sc, 0, R88F_RF_PAD_TXG, 0x003ff, 0x1e0);
+
+ r92f_iqk_setup_bb(sc, 0x01000100);
+
+ /* Enter IQK mode */
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0x80800000);
+
+ /* path-A IQK setting */
+ rtwn_bb_write(sc, R92C_TX_IQK_TONE(0), 0x38008c1c);
+ rtwn_bb_write(sc, R92C_RX_IQK_TONE(0), 0x18008c1c);
+ rtwn_bb_write(sc, R92C_TX_IQK_TONE(1), 0x38008c1c);
+ rtwn_bb_write(sc, R92C_RX_IQK_TONE(1), 0x38008c1c);
+
+ rtwn_bb_write(sc, R92C_TX_IQK_PI(0), 0x82170000);
+ rtwn_bb_write(sc, R92C_RX_IQK_PI(0), 0x28170000);
+
+ /* RX IQK setting */
+ rtwn_bb_write(sc, R92C_RX_IQK, 0x01004800);
+
+ /* LO calibration setting */
+ rtwn_bb_write(sc, R92C_IQK_AGC_RSP, 0x0046a8d1);
+
+ r92f_iqk_one_shot(sc);
+ rtwn_delay(sc, 15000);
+
+ r92f_iqk_poll(sc, R92F_IQK_RPT_RXA);
+
+ /* Check failed */
+ rx_result.after = rtwn_bb_read(sc, R92C_RX_POWER_IQK_AFTER(0));
+ rx_result.before = rtwn_bb_read(sc, R92C_RX_POWER_IQK_BEFORE(0));
+
+ /* Leave IQK mode */
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0);
+
+ rtwn_rf_setbits(sc, 0, R88F_RF_GAIN_CCA, 0x800, 0);
+ rtwn_rf_write(sc, 0, R92F_RF_GAIN_P1, 0x02000);
+
+ if (!(rx_result.after & 0x8000000) &&
+ ((rx_result.before & 0x03ff0000) != 0x01320000) &&
+ ((rx_result.after & 0x03ff0000) != 0x00360000))
+ result |= 0x02;
+
+ return (result);
+}
+
+static int
+r92f_iqk_tx_path_b(struct rtwn_softc *sc)
+{
+ struct r92f_softc *rs = sc->sc_priv;
+ struct r92f_iqk_result tx_result;
+ struct r92f_iqk_result rx_result;
+ uint32_t rf_0x58_i, rf_0x58_q;
+ uint32_t reg;
+ uint8_t rfe = rs->rfe;
+ int result = 0;
+ int i;
+
+ /* PA/PAD controlled by 0x0 */
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0);
+
+ r92f_iqk_setup_bb(sc, 0x01000000);
+
+ rtwn_rf_setbits(sc, 1, R88F_RF_GAIN_CCA, 0x10, 0x10);
+ rtwn_rf_setbits(sc, 1, R88F_RF_GAIN_CCA, 0x800, 0x800);
+
+ if (rfe == 7 || rfe == 8 || rfe == 9 || rfe == 12)
+ rtwn_rf_setbits(sc, 1, R88F_RF_PAD_TXG, 0x003ff, 0x30);
+
+ else
+ rtwn_rf_setbits(sc, 1, R88F_RF_PAD_TXG, 0x00fff, 0xe9);
+
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0x80800000);
+
+ /* Path B IQK setting */
+ rtwn_bb_write(sc, R92C_TX_IQK_TONE(0), 0x38008c1c);
+ rtwn_bb_write(sc, R92C_RX_IQK_TONE(0), 0x38008c1c);
+ rtwn_bb_write(sc, R92C_TX_IQK_TONE(1), 0x18008c1c);
+ rtwn_bb_write(sc, R92C_RX_IQK_TONE(1), 0x38008c1c);
+
+ rtwn_bb_write(sc, R92C_TX_IQK_PI(1), 0x8214000F);
+ rtwn_bb_write(sc, R92C_RX_IQK_PI(1), 0x28140000);
+
+ rtwn_bb_write(sc, R92C_TX_IQK, 0x01007c00);
+ rtwn_bb_write(sc, R92C_RX_IQK, 0x01004800);
+
+ /* LO calibration setting */
+ rtwn_bb_write(sc, R92C_IQK_AGC_RSP, 0x00e62911);
+
+ r92f_iqk_one_shot(sc);
+ rtwn_delay(sc, 15000);
+
+ r92f_iqk_poll(sc, R92F_IQK_RPT_TXB);
+
+ /* Check failed */
+ rx_result.after = rtwn_bb_read(sc, R92C_RX_POWER_IQK_AFTER(0));
+ tx_result.before = rtwn_bb_read(sc, R92C_TX_POWER_IQK_BEFORE(1));
+ tx_result.after = rtwn_bb_read(sc, R92C_TX_POWER_IQK_AFTER(1));
+
+ /* reload 0xdf and CCK_IND off */
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0);
+
+ rtwn_rf_setbits(sc, 1, R88E_RF_WE_LUT, 0x10, 0x10);
+
+ reg = rtwn_rf_read(sc, 1, R92F_RF_TXMOD);
+ rf_0x58_i = (reg & 0xfc000) >> 14;
+ rf_0x58_q = (reg & 0x003f0) >> 4;
+
+ for (i = 0; i < 8; i++) {
+ rtwn_rf_setbits(sc, 1, R92C_RF_TXPA_G(2), 0x1c000, i << 14);
+ rtwn_rf_setbits(sc, 1, R92C_RF_TXPA_G(2), 0x00fc0, rf_0x58_i << 6);
+ rtwn_rf_setbits(sc, 1, R92C_RF_TXPA_G(2), 0x0003f, rf_0x58_q);
+ }
+
+ rtwn_rf_setbits(sc, 1, R92C_RF_AC, 0x4000, 0);
+ rtwn_rf_setbits(sc, 1, R88E_RF_WE_LUT, 0x10, 0);
+ rtwn_rf_setbits(sc, 1, R88F_RF_GAIN_CCA, 0x00810, 0);
+
+ if (!(rx_result.after & 0x80000000) &&
+ ((tx_result.before & 0x03ff0000) != 0x01420000) &&
+ ((tx_result.after & 0x03ff0000) != 0x00420000))
+ result |= 0x01;
+ else
+ RTWN_DPRINTF(sc, RTWN_DEBUG_CALIB, "%s: Path B IQK failed!\n",
+ __func__);
+
+ return (result);
+}
+
+static int
+r92f_iqk_tx_rx_path_b(struct rtwn_softc *sc)
+{
+ struct r92f_iqk_result rx_result_a;
+ struct r92f_iqk_result tx_result_b;
+ uint32_t reg_eac, reg_ec4, reg_ecc;
+ uint32_t reg;
+ int result = 0;
+
+ /* Leave IQK mode */
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0);
+
+ rtwn_rf_setbits(sc, 1, R88F_RF_GAIN_CCA, 0x2, 0x2);
+ rtwn_rf_write(sc, 1, R92F_RF_GAIN_P1, 0);
+ rtwn_rf_setbits(sc, 1, R88F_RF_GAIN_CCA, 0x800, 0x800);
+ rtwn_rf_setbits(sc, 1, R88F_RF_PAD_TXG, 0x003ff, 0x67);
+
+ r92f_iqk_setup_bb(sc, 0x01000000);
+
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0x80800000);
+
+ /* path-B IQK setting */
+ rtwn_bb_write(sc, R92C_TX_IQK_TONE(0), 0x38008c1c);
+ rtwn_bb_write(sc, R92C_RX_IQK_TONE(0), 0x38008c1c);
+ rtwn_bb_write(sc, R92C_TX_IQK_TONE(1), 0x18008c1c);
+ rtwn_bb_write(sc, R92C_RX_IQK_TONE(1), 0x38008c1c);
+
+ rtwn_bb_write(sc, R92C_TX_IQK_PI(1), 0x82160027);
+ rtwn_bb_write(sc, R92C_RX_IQK_PI(1), 0x28160000);
+
+ /* LO calibration setting */
+ rtwn_bb_write(sc, R92C_IQK_AGC_RSP, 0x0086a911);
+
+ r92f_iqk_one_shot(sc);
+ rtwn_delay(sc, 15000);
+
+ r92f_iqk_poll(sc, R92F_IQK_RPT_TXB);
+
+ /* Check failed */
+ rx_result_a.after = rtwn_bb_read(sc, R92C_RX_POWER_IQK_AFTER(0));
+ tx_result_b.before = rtwn_bb_read(sc, R92C_TX_POWER_IQK_BEFORE(1));
+ tx_result_b.after = rtwn_bb_read(sc, R92C_TX_POWER_IQK_AFTER(1));
+
+ if (!(rx_result_a.after & 0x80000000) &&
+ ((tx_result_b.before & 0x03ff0000) != 0x01420000) &&
+ ((tx_result_b.after & 0x03ff0000) != 0x00420000)) {
+ result |= 0x01;
+ } else {
+ /* PA/PAD controlled by 0x0 */
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0);
+
+ rtwn_rf_setbits(sc, 1, R88F_RF_GAIN_CCA, 0x800, 0);
+ return (result);
+ }
+
+ reg = 0x80007c00 | (tx_result_b.before & 0x03ff0000) | ((tx_result_b.after >> 16) & 0x03ff);
+ rtwn_bb_write(sc, R92C_TX_IQK, reg);
+
+ /* Modify RX IQK mode table */
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0);
+
+ rtwn_rf_setbits(sc, 1, R88F_RF_GAIN_CCA, 0x2, 0x2);
+ rtwn_rf_write(sc, 1, R92F_RF_GAIN_P1, 0);
+ rtwn_rf_setbits(sc, 1, R88F_RF_GAIN_CCA, 0x800, 0x800);
+ rtwn_rf_setbits(sc, 1, R88F_RF_PAD_TXG, 0x003ff, 0x1e0);
+
+ r92f_iqk_setup_bb(sc, 0x01000000);
+
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0x80800000);
+
+ /* Path B IQK setting */
+ rtwn_bb_write(sc, R92C_TX_IQK_TONE(0), 0x38008c1c);
+ rtwn_bb_write(sc, R92C_RX_IQK_TONE(0), 0x38008c1c);
+ rtwn_bb_write(sc, R92C_TX_IQK_TONE(1), 0x38008c1c);
+ rtwn_bb_write(sc, R92C_RX_IQK_TONE(1), 0x18008c1c);
+
+ rtwn_bb_write(sc, R92C_TX_IQK_PI(1), 0x82170000);
+ rtwn_bb_write(sc, R92C_RX_IQK_PI(1), 0x28170000);
+
+ /* IQK setting */
+ rtwn_bb_write(sc, R92C_RX_IQK, 0x01004800);
+
+ /* LO calibration setting */
+ rtwn_bb_write(sc, R92C_IQK_AGC_RSP, 0x0046a911);
+
+ r92f_iqk_one_shot(sc);
+ rtwn_delay(sc, 15000);
+
+ r92f_iqk_poll(sc, R92F_IQK_RPT_RXB);
+
+ reg_eac = rtwn_bb_read(sc, R92C_RX_POWER_IQK_AFTER(0));
+ reg_ec4 = rtwn_bb_read(sc, R92C_RX_POWER_IQK_BEFORE(1));
+ reg_ecc = rtwn_bb_read(sc, R92C_RX_POWER_IQK_AFTER(1));
+
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0);
+ rtwn_bb_write(sc, R92C_HSSI_PARAM1(0), 0x01000100);
+
+ rtwn_rf_setbits(sc, 1, R88F_RF_GAIN_CCA, 0x800, 0);
+ rtwn_rf_setbits(sc, 1, R88F_RF_GAIN_CCA, 0x2, 0);
+ rtwn_rf_write(sc, 1, R92F_RF_GAIN_P1, 0x02000);
+
+ if (!(reg_eac & 0x40000000) &&
+ ((reg_ec4 & 0x03ff0000) != 0x01320000) &&
+ ((reg_ecc & 0x03ff0000) != 0x00360000))
+ result |= 0x02;
+ else
+ RTWN_DPRINTF(sc, RTWN_DEBUG_CALIB, "%s: Path B RX IQK failed!\n",
+ __func__);
+
+ return (result);
+}
+
+static void
+r92f_iq_calib_run(struct rtwn_softc *sc, struct r92f_iqk_regs_vals *backup,
+ int result[][8], int t)
+{
+ struct r92f_softc *rs = sc->sc_priv;
+ uint32_t rx_initial_gain_a, rx_initial_gain_b;
+ uint32_t reg;
+ int path_a_ok, path_b_ok, i;
+ uint8_t rfe = rs->rfe;
+
+ /*
+ * Note: IQ calibration must be performed after loading
+ * PHY_REG.txt , and radio_a, radio_b.txt
+ */
+
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0);
+
+ rx_initial_gain_a = rtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(0));
+ rx_initial_gain_b = rtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(1));
+
+ if (t == 0) {
+ /* Save ADDA parameters, turn Path A ADDA on */
+ r92f_iqk_save_regs(sc, backup);
+ }
+
+ rtwn_bb_setbits(sc, R92C_FPGA0_RFPARAM(1), 0, 0x80000000);
+
+ /* MAC settings */
+ rtwn_write_1(sc, R92C_TXPAUSE, 0xff);
+ rtwn_setbits_1(sc, R92C_GPIO_MUXCFG, R92C_GPIO_MUXCFG_ENBT, 0);
+
+ if (rfe == 7 || rfe == 8 || rfe == 9 || rfe == 12) {
+ /* path A */
+ rtwn_bb_setbits(sc, R92F_RFE_CTRL_ANT_SRC(0), 0xf, 0x7);
+ rtwn_bb_setbits(sc, R92F_DPDT_CTRL, 0x1, 0x0);
+
+ rtwn_bb_setbits(sc, R92F_RFE_CTRL_ANT_SRC(0), 0xf00, 0x700);
+ rtwn_bb_setbits(sc, R92F_DPDT_CTRL, 0x4, 0x0);
+
+ rtwn_bb_setbits(sc, R92F_RFE_CTRL_ANT_SRC(0), 0xF000, 0x7000);
+ rtwn_bb_setbits(sc, R92F_DPDT_CTRL, 0x8, 0x0);
+
+ /* path B */
+ rtwn_bb_setbits(sc, R92F_RFE_CTRL_ANT_SRC(2), 0xf0, 0x70);
+ rtwn_bb_setbits(sc, R92F_DPDT_CTRL, 0x20000, 0x0);
+
+ rtwn_bb_setbits(sc, R92F_RFE_CTRL_ANT_SRC(2), 0xf0000, 0x70000);
+ rtwn_bb_setbits(sc, R92F_DPDT_CTRL, 0x100000, 0x0);
+
+ rtwn_bb_setbits(sc, R92F_RFE_CTRL_ANT_SRC(3), 0xf000, 0x7000);
+ rtwn_bb_setbits(sc, R92F_DPDT_CTRL, 0x8000000, 0x0);
+ }
+
+ if (sc->nrxchains > 1) {
+ /* path B standby */
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0x000000);
+ rtwn_rf_write(sc, 1, R92C_RF_AC, 0x10000);
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0x80800000);
+ }
+
+ for (i = 0; i < R92F_IQK_MAX_RETRIES; i++) {
+ path_a_ok = r92f_iqk_tx_path_a(sc);
+
+ if (path_a_ok == 0x01) {
+ reg = rtwn_bb_read(sc, R92C_TX_POWER_IQK_BEFORE(0));
+ result[t][0] = (reg >> 16) & 0x3ff;
+
+ reg = rtwn_bb_read(sc, R92C_TX_POWER_IQK_AFTER(0));
+ result[t][1] = (reg >> 16) & 0x3ff;
+ break;
+ } else {
+ result[t][0] = 0x100;
+ result[t][1] = 0x0;
+ }
+ }
+
+ for (i = 0; i < R92F_IQK_MAX_RETRIES; i++) {
+ path_a_ok = r92f_iqk_tx_rx_path_a(sc);
+
+ if (path_a_ok == 0x03) {
+ reg = rtwn_bb_read(sc, R92C_RX_POWER_IQK_BEFORE(0));
+ result[t][2] = (reg >> 16) & 0x3ff;
+
+ reg = rtwn_bb_read(sc, R92C_RX_POWER_IQK_AFTER(0));
+ result[t][3] = (reg >> 16) & 0x3ff;
+ break;
+ } else {
+ result[t][2] = 0x100;
+ result[t][3] = 0x0;
+ }
+ }
+
+ if (!path_a_ok)
+ RTWN_DPRINTF(sc, RTWN_DEBUG_CALIB, "%s: Path A IQK failed!\n",
+ __func__);
+
+ for (i = 0; i < R92F_IQK_MAX_RETRIES; i++) {
+ path_b_ok = r92f_iqk_tx_path_b(sc);
+
+ if (path_b_ok == 0x01) {
+ reg = rtwn_bb_read(sc, R92C_TX_POWER_IQK_BEFORE(1));
+ result[t][4] = (reg >> 16) & 0x3ff;
+
+ reg = rtwn_bb_read(sc, R92C_TX_POWER_IQK_AFTER(1));
+ result[t][5] = (reg >> 16) & 0x3ff;
+ break;
+ } else {
+ result[t][4] = 0x100;
+ result[t][5] = 0x0;
+ }
+ }
+
+ if (sc->nrxchains > 1) {
+ for (i = 0; i < R92F_IQK_MAX_RETRIES; i++) {
+ path_b_ok = r92f_iqk_tx_rx_path_b(sc);
+
+ if (path_b_ok == 0x03) {
+ reg = rtwn_bb_read(sc, R92C_RX_POWER_IQK_BEFORE(1));
+ result[t][6] = (reg >> 16) & 0x3ff;
+
+ reg = rtwn_bb_read(sc, R92C_RX_POWER_IQK_AFTER(1));
+ result[t][7] = (reg >> 16) & 0x3ff;
+ break;
+ } else {
+ result[t][6] = 0x100;
+ result[t][7] = 0x0;
+ }
+ }
+
+ if (!path_b_ok)
+ RTWN_DPRINTF(sc, RTWN_DEBUG_CALIB, "%s: Path B IQK failed!\n",
+ __func__);
+ }
+
+ /* Back to BB mode, load original value */
+ rtwn_bb_setbits(sc, R92C_FPGA0_IQK, 0xffffff00, 0);
+
+ rtwn_bb_write(sc, R88F_FPGA0_ANALOG4, 0xcc0000c0);
+ rtwn_bb_write(sc, R92F_ANAPWR1, 0x44bbbb44);
+ rtwn_bb_write(sc, R88F_RX_WAIT_CCA, 0x80408040);
+ rtwn_bb_write(sc, R92C_OFDM0_TRXPATHENA, 0x6f005433);
+ rtwn_bb_write(sc, R92C_OFDM0_TRMUXPAR, 0x000004e4);
+ rtwn_bb_write(sc, R88F_FPGA0_XCD_RF_SW_CTRL, 0x04003400);
+ rtwn_bb_write(sc, R92C_HSSI_PARAM1(0), 0x01000100);
+
+ /* Reload ADDA power saving parameters, MAC parameters and BB parameters */
+ r92f_iqk_restore_regs(sc, backup);
+
+ rtwn_bb_setbits(sc, R92C_FPGA0_RFPARAM(1), 0x80000000, 0);
+
+ /* Restore RX initial gain */
+ rtwn_bb_setbits(sc, R92C_OFDM0_AGCCORE1(0), 0xff, 0x50);
+ rtwn_bb_setbits(sc, R92C_OFDM0_AGCCORE1(0), 0xff,
+ rx_initial_gain_a & 0xff);
+ if (sc->nrxchains > 1) {
+ rtwn_bb_setbits(sc, R92C_OFDM0_AGCCORE1(1), 0xff, 0x50);
+ rtwn_bb_setbits(sc, R92C_OFDM0_AGCCORE1(1), 0xff,
+ rx_initial_gain_b & 0xff);
+ }
+}
+
+void
+r92f_iq_calib(struct rtwn_softc *sc)
+{
+ struct r92f_softc *rs = sc->sc_priv;
+ struct r92f_iqk_regs_vals backup_regs;
+ int32_t reg_e94, reg_e9c, reg_ea4, reg_eac;
+ int32_t reg_eb4, reg_ebc, reg_ec4, reg_ecc;
+ uint32_t path_a_0xdf, path_a_0x35;
+ uint32_t path_b_0xdf, path_b_0x35;
+ bool path_a_ok, path_b_ok;
+ uint8_t rfe = rs->rfe;
+ uint32_t rfe_path_select;
+ int result[4][8]; /* last is final result */
+ int i, candidate;
+ int32_t reg_tmp = 0;
+ bool match;
+
+ rfe_path_select = rtwn_bb_read(sc, R92F_RFE_PATH_SELECT);
+
+ path_a_0xdf = rtwn_rf_read(sc, 0, R88F_RF_GAIN_CCA);
+ path_a_0x35 = rtwn_rf_read(sc, 0, R92F_RF_GAIN_P1);
+ path_b_0xdf = rtwn_rf_read(sc, 1, R88F_RF_GAIN_CCA);
+ path_b_0x35 = rtwn_rf_read(sc, 1, R92F_RF_GAIN_P1);
+
+ memset(result, 0, sizeof(result));
+ candidate = -1;
+
+ path_a_ok = false;
+ path_b_ok = false;
+
+ for (i = 0; i < 3; i++) {
+ r92f_iq_calib_run(sc, &backup_regs, result, i);
+
+ if (i == 1) {
+ if (r92f_iq_calib_compare_results(sc, result, 0, 1)) {
+ candidate = 0;
+ break;
+ }
+ }
+
+ if (i == 2) {
+ if (r92f_iq_calib_compare_results(sc, result, 0, 2)) {
+ candidate = 0;
+ break;
+ }
+
+ match = r92f_iq_calib_compare_results(sc, result, 1, 2);
+ if (match) {
+ candidate = 1;
+ } else {
+ for (i = 0; i < 8; i++)
+ reg_tmp += result[3][i];
+ if (reg_tmp)
+ candidate = 3;
+ else
+ candidate = -1;
+ }
+ }
+ }
+
+ if (candidate >= 0) {
+ reg_e94 = result[candidate][0];
+ reg_e9c = result[candidate][1];
+ reg_ea4 = result[candidate][2];
+ reg_eac = result[candidate][3];
+ reg_eb4 = result[candidate][4];
+ reg_ebc = result[candidate][5];
+ reg_ec4 = result[candidate][6];
+ reg_ecc = result[candidate][7];
+
+ RTWN_DPRINTF(sc, RTWN_DEBUG_CALIB,
+ "%s: candidate is %x\n", __func__, candidate);
+ RTWN_DPRINTF(sc, RTWN_DEBUG_CALIB,
+ "%s: e94=%x e9c=%x ea4=%x eac=%x eb4=%x ebc=%x ec4=%x ecc=%x\n",
+ __func__, reg_e94, reg_e9c, reg_ea4, reg_eac,
+ reg_eb4, reg_ebc, reg_ec4, reg_ecc);
+
+ path_a_ok = true;
+ path_b_ok = true;
+ }
+
+ rtwn_bb_setbits(sc, R92C_TX_IQK_TONE(0), 0x3ff00000, 0x10000000);
+ rtwn_bb_setbits(sc, R92F_NP_ANTA, 0x3ff, 0);
+ rtwn_bb_setbits(sc, R92C_TX_IQK_TONE(1), 0x3ff00000, 0x10000000);
+ rtwn_bb_setbits(sc, R92F_TAP_UPD_97F, 0x3ff, 0);
+
+ if (candidate >= 0) {
+ if (reg_e94)
+ r92f_fill_iqk_matrix_a(sc, path_a_ok, result,
+ candidate, reg_ea4 == 0);
+
+ if (reg_eb4)
+ r92f_fill_iqk_matrix_b(sc, path_b_ok, result,
+ candidate, reg_ec4 == 0);
+ }
+
+ rtwn_rf_write(sc, 0, R88F_RF_GAIN_CCA, path_a_0xdf);
+ rtwn_rf_write(sc, 0, R92F_RF_GAIN_P1, path_a_0x35);
+ rtwn_rf_write(sc, 1, R88F_RF_GAIN_CCA, path_b_0xdf);
+ rtwn_rf_write(sc, 1, R92F_RF_GAIN_P1, path_b_0x35);
+
+ if (rfe == 7 || rfe == 8 || rfe == 9 || rfe == 12) {
+ rtwn_bb_setbits(sc, R92F_SW_GPIO_SHARE_CTRL(1), 0, 0x70000);
+ rtwn_bb_setbits(sc, R92C_LEDCFG0, 0x6c00000, 0);
+ rtwn_bb_setbits(sc, R88E_BB_PAD_CTRL, 0, 0x30000000);
+ rtwn_bb_setbits(sc, R92F_SW_GPIO_SHARE_CTRL(0), 0x600010, 0);
+
+ /*
+ * Originally:
+ * odm_set_bb_reg(dm, R_0x944, BIT(11) | 0x1F, 0x3F);
+ *
+ * It clears bit 11 and sets bits 0..4. The mask doesn't cover
+ * bit 5 so it's not modified. Is that what it's supposed to
+ * accomplish?
+ */
+ rtwn_bb_setbits(sc, R92F_RFE_BUFFER, 0x81f, 0x1f);
+
+ if (rfe == 7) {
+ rtwn_bb_setbits(sc, R92F_RFE_CTRL_ANT_SRC(0), 0xfffff, 0x23200);
+ rtwn_bb_setbits(sc, R92F_RFE_CTRL_ANT_SRC(2), 0xfffff, 0x23200);
+ rtwn_bb_setbits(sc, R92F_RFE_CTRL_ANT_SRC(1), 0xf000, 0x3000);
+ rtwn_bb_setbits(sc, R92F_RFE_CTRL_ANT_SRC(3), 0xf000, 0x3000);
+
+ } else {
+ rtwn_bb_setbits(sc, R92F_RFE_CTRL_ANT_SRC(0), 0xfffff, 0x22200);
+ rtwn_bb_setbits(sc, R92F_RFE_CTRL_ANT_SRC(2), 0xfffff, 0x22200);
+ rtwn_bb_setbits(sc, R92F_RFE_CTRL_ANT_SRC(1), 0xf000, 0x2000);
+ rtwn_bb_setbits(sc, R92F_RFE_CTRL_ANT_SRC(3), 0xf000, 0x2000);
+ }
+
+ rtwn_bb_setbits(sc, R92F_RFE_OPT62, 0x4, 0);
+
+ if (rfe == 7)
+ rtwn_bb_write(sc, R92F_RFE_OPT, 0x03000003);
+
+ rtwn_bb_write(sc, R92F_RFE_PATH_SELECT, rfe_path_select);
+ }
+}
diff --git a/sys/dev/rtwn/rtl8192f/r92f_chan.c b/sys/dev/rtwn/rtl8192f/r92f_chan.c
new file mode 100644
index 000000000000..a8c0d857126c
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/r92f_chan.c
@@ -0,0 +1,332 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/cdefs.h>
+#include "opt_wlan.h"
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/mbuf.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
+#include <sys/taskqueue.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/linker.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_media.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
+
+#include <dev/rtwn/if_rtwnreg.h>
+#include <dev/rtwn/if_rtwnvar.h>
+
+#include <dev/rtwn/if_rtwn_ridx.h>
+
+#include <dev/rtwn/rtl8188e/r88e.h>
+#include <dev/rtwn/rtl8188e/r88e_priv.h>
+#include <dev/rtwn/rtl8188e/r88e_reg.h>
+
+#include <dev/rtwn/rtl8192c/r92c.h>
+#include <dev/rtwn/rtl8192c/r92c_var.h>
+
+#include <dev/rtwn/rtl8723b/r23b_reg.h>
+
+#include <dev/rtwn/rtl8812a/r12a.h>
+#include <dev/rtwn/rtl8812a/r12a_reg.h>
+
+#include <dev/rtwn/rtl8188f/r88f.h>
+#include <dev/rtwn/rtl8188f/r88f_reg.h>
+
+#include <dev/rtwn/rtl8192f/r92f.h>
+#include <dev/rtwn/rtl8192f/r92f_reg.h>
+#include <dev/rtwn/rtl8192f/r92f_var.h>
+
+static int
+r92f_chan2cckgroup(int chan)
+{
+ if (chan == 14)
+ return (5);
+ else
+ return (r88f_chan2group(chan));
+}
+
+static void
+r92f_get_txpower(struct rtwn_softc *sc, int chain, struct ieee80211_channel *c,
+ uint8_t power[RTWN_RIDX_COUNT])
+{
+ const struct ieee80211com *ic = &sc->sc_ic;
+ struct r92f_softc *rs = sc->sc_priv;
+ int i, ridx, group, cck_group, max_mcs, chan;
+
+ /* Determine channel group. */
+ chan = rtwn_chan2centieee(c);
+ group = r88f_chan2group(chan);
+ cck_group = r92f_chan2cckgroup(chan);
+ if (group == -1 || cck_group == -1) { /* shouldn't happen */
+ device_printf(sc->sc_dev, "%s: incorrect channel\n", __func__);
+ return;
+ }
+
+ max_mcs = RTWN_RIDX_HT_MCS(sc->ntxchains * 8 - 1);
+
+ for (ridx = RTWN_RIDX_CCK1; ridx <= RTWN_RIDX_CCK11; ridx++) {
+ power[ridx] = rs->cck_tx_pwr[chain][cck_group];
+ if (power[ridx] > ic->ic_txpowlimit)
+ power[ridx] = ic->ic_txpowlimit;
+ }
+ for (ridx = RTWN_RIDX_OFDM6; ridx <= max_mcs; ridx++) {
+ power[ridx] = rs->ht40_tx_pwr_2g[chain][group];
+ if (power[ridx] > ic->ic_txpowlimit)
+ power[ridx] = ic->ic_txpowlimit;
+ }
+
+ for (ridx = RTWN_RIDX_OFDM6; ridx <= RTWN_RIDX_OFDM54; ridx++) {
+ /* Ensure we don't underflow if the power delta is -ve */
+ int8_t pwr;
+
+ pwr = power[ridx] + rs->ofdm_tx_pwr_diff_2g[chain][0];
+ if (pwr < 0)
+ pwr = 0;
+
+ power[ridx] = pwr;
+ }
+
+ for (i = 0; i < sc->ntxchains; i++) {
+ uint8_t min_mcs;
+ int8_t pwr_diff, pwr;
+
+ if (IEEE80211_IS_CHAN_HT40(c))
+ pwr_diff = rs->bw40_tx_pwr_diff_2g[chain][i];
+ else
+ pwr_diff = rs->bw20_tx_pwr_diff_2g[chain][i];
+
+ min_mcs = RTWN_RIDX_HT_MCS(i * 8);
+ for (ridx = min_mcs; ridx <= min_mcs; ridx++) {
+ /* Ensure we don't underflow */
+ pwr = power[ridx] + pwr_diff;
+ if (pwr < 0)
+ pwr = 0;
+ power[ridx] = pwr;
+ }
+ }
+
+ /* Apply max limit. */
+ for (ridx = RTWN_RIDX_CCK1; ridx <= max_mcs; ridx++) {
+ if (power[ridx] > R92C_MAX_TX_PWR)
+ power[ridx] = R92C_MAX_TX_PWR;
+ }
+
+}
+
+static void
+r92f_set_txpower(struct rtwn_softc *sc, struct ieee80211_channel *c)
+{
+ uint8_t power[RTWN_RIDX_COUNT];
+ int i;
+
+ for (i = 0; i < sc->ntxchains; i++) {
+ memset(power, 0, sizeof(power));
+ /* Compute per-rate Tx power values. */
+ r92f_get_txpower(sc, i, c, power);
+ /* Optionally print out the power table */
+ r92c_dump_txpower(sc, i, power);
+ /* Write per-rate Tx power values to hardware. */
+ r92c_write_txpower(sc, i, power);
+ }
+}
+
+int
+r92f_set_tx_power(struct rtwn_softc *sc, struct ieee80211vap *vap)
+{
+
+ if (vap->iv_bss == NULL)
+ return (EINVAL);
+ if (vap->iv_bss->ni_chan == IEEE80211_CHAN_ANYC)
+ return (EINVAL);
+
+ r92f_set_txpower(sc, vap->iv_bss->ni_chan);
+ return (0);
+}
+
+
+static void
+r92f_config_kfree(struct rtwn_softc *sc, uint8_t chan)
+{
+ struct r92f_softc *rs = sc->sc_priv;
+
+ const uint8_t *bb_gain = rs->bb_gain;
+ uint8_t bb_gain_path_mask[2] = { 0x0f, 0xf0 };
+ uint8_t bb_gain_path_shift[2] = { 0, 4 };
+ int rfpath; /* RF_A or RF_B */
+ uint8_t bb_gain_for_path;
+ uint8_t channel_idx = 0;
+
+ if (bb_gain[1] == 0xff)
+ return;
+
+ if (chan >= 1 && chan <= 3)
+ channel_idx = 0;
+ if (chan >= 4 && chan <= 9)
+ channel_idx = 1;
+ if (chan >= 10 && chan <= 14)
+ channel_idx = 2;
+
+ for (rfpath = 0; rfpath < 2; rfpath++) {
+ /* power_trim based on 55[19:14] */
+ rtwn_rf_setbits(sc, rfpath, R88F_RF_UNKNOWN_55, 0x20, 0x20);
+
+ /* enable 55[14] for 0.5db step */
+ rtwn_rf_setbits(sc, rfpath, R92F_RF_GAIN_CTRL, 0x40000,
+ 0x40000);
+
+ /* enter power_trim debug mode */
+ rtwn_rf_setbits(sc, rfpath, R88F_RF_GAIN_CCA, 0x80, 0x80);
+
+ /* write enable */
+ rtwn_rf_setbits(sc, rfpath, R88E_RF_WE_LUT, 0x80, 0x80);
+
+
+ bb_gain_for_path = (bb_gain[channel_idx] &
+ bb_gain_path_mask[rfpath]) >> bb_gain_path_shift[rfpath];
+
+ rtwn_rf_setbits(sc, rfpath, R92C_RF_TXPA_G(2), 0x70000,
+ (channel_idx * 2) << 16);
+ rtwn_rf_setbits(sc, rfpath, R92C_RF_TXPA_G(2), 0x3f,
+ bb_gain_for_path);
+
+ rtwn_rf_setbits(sc, rfpath, R92C_RF_TXPA_G(2), 0x70000,
+ (channel_idx * 2 + 1) << 16);
+
+ rtwn_rf_setbits(sc, rfpath, R92C_RF_TXPA_G(2), 0x3f,
+ bb_gain_for_path);
+
+ /* leave power_trim debug mode */
+ rtwn_rf_setbits(sc, rfpath, R88F_RF_GAIN_CCA, 0x80, 0);
+
+ /* write disable */
+ rtwn_rf_setbits(sc, rfpath, R88E_RF_WE_LUT, 0x80, 0);
+ }
+}
+
+static void
+r92f_revise_cck_tx_psf(struct rtwn_softc *sc, uint8_t channel)
+{
+ if (channel == 13) {
+ /* Special value for channel 13 */
+ rtwn_bb_write(sc, R92F_CCK0_TX_FILTER1, 0xf8fe0001);
+ /* Normal values */
+ rtwn_bb_write(sc, R92F_CCK0_TX_FILTER2, 0x64b80c1c);
+ rtwn_write_2(sc, R92F_CCK0_DEBUG_PORT, 0x8810);
+ rtwn_bb_write(sc, R92F_CCK0_TX_FILTER3, 0x01235667);
+ } else if (channel == 14) {
+ /* Normal value */
+ rtwn_bb_write(sc, R92F_CCK0_TX_FILTER1, 0xe82c0001);
+ /* Special values for channel 14 */
+ rtwn_bb_write(sc, R92F_CCK0_TX_FILTER2, 0x0000b81c);
+ rtwn_write_2(sc, R92F_CCK0_DEBUG_PORT, 0x0000);
+ rtwn_bb_write(sc, R92F_CCK0_TX_FILTER3, 0x00003667);
+ } else {
+ /* Restore normal values from the phy init table */
+ rtwn_bb_write(sc, R92F_CCK0_TX_FILTER1, 0xe82c0001);
+ rtwn_bb_write(sc, R92F_CCK0_TX_FILTER2, 0x64b80c1c);
+ rtwn_write_2(sc, R92F_CCK0_DEBUG_PORT, 0x8810);
+ rtwn_bb_write(sc, R92F_CCK0_TX_FILTER3, 0x01235667);
+ }
+}
+
+void
+r92f_set_chan(struct rtwn_softc *sc, struct ieee80211_channel *c)
+{
+ bool ht40 = IEEE80211_IS_CHAN_HT40(c);
+ uint8_t chan, subchan = 0;
+ bool sec_ch_above = 0;
+ uint32_t reg;
+
+ /* unit: 256us. 256ms */
+ rtwn_write_2(sc, R92F_PKT_VO_VI_LIFE_TIME, 0x0400);
+ /* unit: 256us. 256ms */
+ rtwn_write_2(sc, R92F_PKT_BE_BK_LIFE_TIME, 0x0400);
+
+ r92f_set_txpower(sc, c);
+
+ chan = rtwn_chan2centieee(c);
+
+ if(IEEE80211_IS_CHAN_HT40U(c)) {
+ sec_ch_above = 1;
+ subchan = 2;
+ } else if(IEEE80211_IS_CHAN_HT40D(c)) {
+ sec_ch_above = 0;
+ subchan = 1;
+ }
+
+ r92f_revise_cck_tx_psf(sc, chan);
+
+ /* Set channel */
+ reg = rtwn_rf_read(sc, 0, R92C_RF_CHNLBW);
+ reg &= ~(0x60000); /* select the 2.4G band(?) */
+ reg = (reg & ~0xff) | (chan & 0xff);
+ rtwn_rf_write(sc, 0, R92C_RF_CHNLBW, reg);
+ if (sc->nrxchains > 1)
+ rtwn_rf_write(sc, 1, R92C_RF_CHNLBW, reg);
+
+ r92f_config_kfree(sc, chan);
+
+ rtwn_write_1(sc, R92F_DATA_SUBCHANNEL, subchan);
+
+ /* small BW */
+ rtwn_bb_setbits(sc, R92C_OFDM0_TXPSEUDONOISEWGT, 0xC0000000, 0);
+
+ rtwn_bb_setbits(sc, R92C_FPGA0_RFMOD, R92C_RFMOD_40MHZ, ht40);
+
+ rtwn_bb_setbits(sc, R92C_FPGA1_RFMOD, R92C_RFMOD_40MHZ, ht40);
+
+ /* ADC clock = 160M */
+ rtwn_bb_setbits(sc, R92C_FPGA0_RFMOD, 0x700, 0x400);
+
+ /* DAC clock = 80M */
+ rtwn_bb_setbits(sc, R92C_FPGA0_RFMOD, 0x3000, 0x2000);
+
+ /* ADC buffer clk */
+ rtwn_bb_setbits(sc, R92F_ANTDIV_PARA1, 0xc000000, 0x8000000);
+
+ if (ht40)
+ /* Set Control channel to upper or lower. */
+ rtwn_bb_setbits(sc, R92C_CCK0_SYSTEM, R92C_CCK0_SYSTEM_CCK_SIDEBAND,
+ (!sec_ch_above) << 4);
+
+ /* Enable CCK */
+ rtwn_bb_setbits(sc, R92C_FPGA0_RFMOD, 0, R92F_FPGA0_RFMOD_CCK);
+
+ /* RF TRX_BW */
+ reg = rtwn_rf_read(sc, 0, R92C_RF_CHNLBW);
+ reg &= ~R92F_RF_CHNLBW_BW_MASK;
+ if (ht40)
+ reg |= R88F_RF_CHNLBW_BW40;
+ else
+ reg |= R88F_RF_CHNLBW_BW20;
+ rtwn_rf_write(sc, 0, R92C_RF_CHNLBW, reg);
+ if (sc->nrxchains > 1)
+ rtwn_rf_write(sc, 1, R92C_RF_CHNLBW, reg);
+
+ /* Modify RX DFIR parameters */
+ rtwn_bb_setbits(sc, R92F_TAP_UPD_97F, 0x300000, 0x200000);
+
+ rtwn_bb_setbits(sc, R92F_DOWNSAM_FACTOR, 0x30000000, 0x20000000);
+
+ if (ht40)
+ reg = 0x3;
+ else
+ reg = 0x1a3;
+ rtwn_bb_setbits(sc, R92F_RX_DFIR_MOD_97F, 0x1ff, reg);
+}
diff --git a/sys/dev/rtwn/rtl8192f/r92f_fw.c b/sys/dev/rtwn/rtl8192f/r92f_fw.c
new file mode 100644
index 000000000000..586c6dcd6758
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/r92f_fw.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/cdefs.h>
+#include "opt_wlan.h"
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/mbuf.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
+#include <sys/taskqueue.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/linker.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_media.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
+
+#include <dev/rtwn/if_rtwnreg.h>
+#include <dev/rtwn/if_rtwnvar.h>
+
+#include <dev/rtwn/rtl8192c/r92c.h>
+#include <dev/rtwn/rtl8192c/r92c_reg.h>
+
+#include <dev/rtwn/rtl8188f/r88f.h>
+
+#include <dev/rtwn/rtl8192f/r92f.h>
+
+
+#ifndef RTWN_WITHOUT_UCODE
+static void
+r92f_fw_reset_8051(struct rtwn_softc *sc)
+{
+ rtwn_setbits_1(sc, R92C_RSV_CTRL, 0x2, 0);
+
+ rtwn_setbits_1(sc, R92C_RSV_CTRL + 1, 0x1, 0);
+
+ rtwn_setbits_2(sc, R92C_SYS_FUNC_EN, R92C_SYS_FUNC_EN_CPUEN, 0);
+
+ rtwn_setbits_1(sc, R92C_RSV_CTRL, 0x2, 0);
+
+ rtwn_setbits_1(sc, R92C_RSV_CTRL + 1, 0, 0x1);
+
+ rtwn_setbits_2(sc, R92C_SYS_FUNC_EN, 0, R92C_SYS_FUNC_EN_CPUEN);
+}
+
+void
+r92f_fw_reset(struct rtwn_softc *sc, int reason)
+{
+ switch (reason) {
+ case RTWN_FW_RESET_SHUTDOWN:
+ r92c_fw_reset(sc, RTWN_FW_RESET_SHUTDOWN);
+ break;
+ case RTWN_FW_RESET_CHECKSUM:
+ /* FALLTHROUGH */
+ case RTWN_FW_RESET_DOWNLOAD:
+ r92f_fw_reset_8051(sc);
+ break;
+ }
+}
+
+void
+r92f_fw_download_enable(struct rtwn_softc *sc, int enable)
+{
+ if (enable) {
+ /* 8051 enable. */
+ rtwn_setbits_1_shift(sc, R92C_SYS_FUNC_EN, 0,
+ R92C_SYS_FUNC_EN_CPUEN, 1);
+ /* MCU firmware download enable. */
+ rtwn_setbits_1(sc, R92C_MCUFWDL, 0, R92C_MCUFWDL_EN);
+ /* 8051 reset. */
+ rtwn_setbits_1_shift(sc, R92C_MCUFWDL, R92C_MCUFWDL_ROM_DLEN,
+ 0, 2);
+
+ rtwn_delay(sc, 100000); /* 100ms */
+ } else {
+ /* MCU download disable. */
+ rtwn_setbits_1(sc, R92C_MCUFWDL, R92C_MCUFWDL_EN, 0);
+ }
+}
+
+int
+r92f_fw_write_finish(struct rtwn_softc *sc)
+{
+ return (rtwn_write_1(sc, R92C_HMETFR, 0x0f));
+}
+
+#endif
diff --git a/sys/dev/rtwn/rtl8192f/r92f_init.c b/sys/dev/rtwn/rtl8192f/r92f_init.c
new file mode 100644
index 000000000000..1b85841da954
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/r92f_init.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/cdefs.h>
+#include "opt_wlan.h"
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/mbuf.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
+#include <sys/taskqueue.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/linker.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_media.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
+
+#include <dev/rtwn/if_rtwnreg.h>
+#include <dev/rtwn/if_rtwnvar.h>
+
+#include <dev/rtwn/if_rtwn_debug.h>
+
+#include <dev/rtwn/rtl8192c/r92c.h>
+#include <dev/rtwn/rtl8192c/r92c_reg.h>
+
+#include <dev/rtwn/rtl8192e/r92e_reg.h>
+
+#include <dev/rtwn/rtl8192f/r92f.h>
+#include <dev/rtwn/rtl8192f/r92f_var.h>
+
+#define R92F_XTAL1_M 0x0000007e
+#define R92F_XTAL1_S 1
+#define R92F_XTAL0_M 0x7e000000
+#define R92F_XTAL0_S 25
+
+static void
+r92f_set_crystal_cap(struct rtwn_softc *sc)
+{
+ struct r92f_softc *rs = sc->sc_priv;
+ uint8_t cap;
+ uint32_t xtal0, xtal1;
+
+ cap = rs->crystalcap & 0x3f;
+
+ xtal0 = rtwn_read_4(sc, R92C_AFE_XTAL_CTRL);
+ xtal1 = rtwn_read_4(sc, R92C_AFE_PLL_CTRL);
+
+ RTWN_DPRINTF(sc, RTWN_DEBUG_USB,
+ "%s: Adjusting crystal cap from 0x%x (actually 0x%x 0x%x) to 0x%x\n",
+ __func__,
+ rs->crystalcap,
+ MS(xtal1, R92F_XTAL1),
+ MS(xtal0, R92F_XTAL0),
+ cap);
+
+ xtal0 = RW(xtal0, R92F_XTAL0, cap);
+ xtal1 = RW(xtal1, R92F_XTAL1, cap);
+ rtwn_write_4(sc, R92C_AFE_PLL_CTRL, xtal1);
+ rtwn_write_4(sc, R92C_AFE_XTAL_CTRL, xtal0);
+}
+
+static void
+r92f_init_bb_common(struct rtwn_softc *sc)
+{
+ struct r92f_softc *rs = sc->sc_priv;
+
+ r92c_init_bb_common(sc);
+
+ rs->cck_new_agc = (rtwn_bb_read(sc, 0xa9c) & (1u << 17)) != 0;
+
+ /* these values are taken out from rtl8192fu_agc_vals as they write
+ to 0xc50 instead of 0xc78 */
+ rtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(0), 0x00e48024);
+ rtwn_delay(sc, 1);
+ rtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(0), 0x00e48020);
+ rtwn_delay(sc, 1);
+
+ r92f_set_crystal_cap(sc);
+}
+
+void
+r92f_init_bb(struct rtwn_softc *sc)
+{
+ /* Enable BB and RF */
+ rtwn_setbits_2(sc, R92C_SYS_FUNC_EN, 0,
+ R92C_SYS_FUNC_EN_BBRSTB | R92C_SYS_FUNC_EN_BB_GLB_RST);
+
+ rtwn_write_1(sc, R92C_RF_CTRL, R92C_RF_CTRL_EN | R92C_RF_CTRL_RSTB |
+ R92C_RF_CTRL_SDMRSTB);
+
+ /* To Fix MAC loopback mode fail. */
+ rtwn_write_1(sc, R92C_LDOHCI12_CTRL, 0xf);
+ rtwn_write_1(sc, R92E_LDOV12_CTRL + 1, 0xe9);
+
+ rtwn_delay(sc, 10);
+
+ r92f_init_bb_common(sc);
+ /* Enable TX/RX for path A and B */
+ rtwn_bb_setbits(sc, R92C_OFDM0_TRXPATHENA, 0xff, 0x33);
+ rtwn_write_1(sc, R92C_TXPAUSE, 0x00);
+}
diff --git a/sys/dev/rtwn/rtl8192f/r92f_led.c b/sys/dev/rtwn/rtl8192f/r92f_led.c
new file mode 100644
index 000000000000..900b3c6104e4
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/r92f_led.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/cdefs.h>
+#include "opt_wlan.h"
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/mbuf.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
+#include <sys/taskqueue.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/linker.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_media.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
+
+#include <dev/rtwn/if_rtwnvar.h>
+#include <dev/rtwn/if_rtwnreg.h>
+
+#include <dev/rtwn/rtl8192c/r92c_reg.h>
+#include <dev/rtwn/rtl8192c/r92c_reg.h>
+
+#include <dev/rtwn/rtl8192f/r92f.h>
+#include <dev/rtwn/rtl8192f/r92f_reg.h>
+
+void
+r92f_set_led(struct rtwn_softc *sc, int led, int on)
+{
+ uint32_t ledcfg;
+
+ /* Values obtained by observing the USB traffic from the Windows driver. */
+ rtwn_bb_write(sc, R92F_SW_GPIO_SHARE_CTRL(0), 0x20080);
+ rtwn_bb_write(sc, R92F_SW_GPIO_SHARE_CTRL(1), 0x1b0000);
+
+ ledcfg = rtwn_read_4(sc, R92C_LEDCFG0);
+
+ /* Comfast CF-826F uses LED1. Asus USB-N13 C1 uses LED0. Set both. */
+ ledcfg = RW(ledcfg, R92F_LEDCFG0_LED2EN, R92F_LED_GPIO_ENABLE);
+ ledcfg = RW(ledcfg, R92F_LEDCFG0_LED0_IO_MODE, R92F_LED_IO_MODE_OUTPUT);
+ ledcfg = RW(ledcfg, R92F_LEDCFG0_LED1_IO_MODE, R92F_LED_IO_MODE_OUTPUT);
+
+ if (led == RTWN_LED_LINK) {
+ if (!on) {
+ ledcfg = RW(ledcfg, R92F_LEDCFG0_LED0CM, R92F_LED_MODE_SW_CTRL);
+ ledcfg = RW(ledcfg, R92F_LEDCFG0_LED0SV, R92F_LED_SW_OFF);
+ ledcfg = RW(ledcfg, R92F_LEDCFG0_LED1CM, R92F_LED_MODE_SW_CTRL);
+ ledcfg = RW(ledcfg, R92F_LEDCFG0_LED1SV, R92F_LED_SW_OFF);
+ } else {
+ ledcfg = RW(ledcfg, R92F_LEDCFG0_LED0CM, R92F_LED_MODE_SW_CTRL);
+ ledcfg = RW(ledcfg, R92F_LEDCFG0_LED0SV, R92F_LED_SW_ON);
+ ledcfg = RW(ledcfg, R92F_LEDCFG0_LED1CM, R92F_LED_MODE_SW_CTRL);
+ ledcfg = RW(ledcfg, R92F_LEDCFG0_LED1SV, R92F_LED_SW_ON);
+ }
+ rtwn_write_4(sc, R92C_LEDCFG0, ledcfg);
+ sc->ledlink = on; /* Save LED state. */
+ }
+
+ /* XXX: hw traffic controlled led blinking? */
+ /*
+ * ledcfg = RW(ledcfg, LEDCFG0_LED0CM, R92F_LED_MODE_TX_OR_RX_EVENTS);
+ * ledcfg = RW(ledcfg, LEDCFG0_LED0SV, R92F_LED_SW_OFF);
+ * ledcfg = RW(ledcfg, LEDCFG0_LED1CM, R92F_LED_MODE_TX_OR_RX_EVENTS);
+ * ledcfg = RW(ledcfg, LEDCFG0_LED1SV, R92F_LED_SW_OFF);
+ */
+}
diff --git a/sys/dev/rtwn/rtl8192f/r92f_priv.h b/sys/dev/rtwn/rtl8192f/r92f_priv.h
new file mode 100644
index 000000000000..694aa702fa5f
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/r92f_priv.h
@@ -0,0 +1,320 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef R92F_PRIV_H
+#define R92F_PRIV_H
+
+#include <dev/rtwn/rtl8188f/r88f_rom_defs.h>
+
+/*
+ * MAC initialization values.
+ */
+static const struct rtwn_mac_prog rtl8192fu_mac[] = {
+ { 0x420, 0x00 }, { 0x422, 0x78 }, { 0x428, 0x0a }, { 0x429, 0x10 },
+ { 0x430, 0x00 }, { 0x431, 0x00 }, { 0x432, 0x00 }, { 0x433, 0x01 },
+ { 0x434, 0x04 }, { 0x435, 0x05 }, { 0x436, 0x07 }, { 0x437, 0x08 },
+ { 0x43c, 0x04 }, { 0x43d, 0x05 }, { 0x43e, 0x07 }, { 0x43f, 0x08 },
+ { 0x440, 0x5d }, { 0x441, 0x01 }, { 0x442, 0x00 }, { 0x444, 0x10 },
+ { 0x445, 0xf0 }, { 0x446, 0x0e }, { 0x447, 0x1f }, { 0x448, 0x00 },
+ { 0x449, 0x00 }, { 0x44a, 0x00 }, { 0x44b, 0x00 }, { 0x44c, 0x10 },
+ { 0x44d, 0xf0 }, { 0x44e, 0x0e }, { 0x44f, 0x00 }, { 0x450, 0x00 },
+ { 0x451, 0x00 }, { 0x452, 0x00 }, { 0x453, 0x00 }, { 0x480, 0x20 },
+ { 0x49c, 0x30 }, { 0x49d, 0xf0 }, { 0x49e, 0x03 }, { 0x49f, 0x3e },
+ { 0x4a0, 0x00 }, { 0x4a1, 0x00 }, { 0x4a2, 0x00 }, { 0x4a3, 0x00 },
+ { 0x4a4, 0x15 }, { 0x4a5, 0xf0 }, { 0x4a6, 0x01 }, { 0x4a7, 0x0e },
+ { 0x4a8, 0xe0 }, { 0x4a9, 0x00 }, { 0x4aa, 0x00 }, { 0x4ab, 0x00 },
+ { 0x2448, 0x06}, { 0x244a, 0x06}, { 0x244c, 0x06}, { 0x244e, 0x06},
+ { 0x4c7, 0x80 }, { 0x4c8, 0xff }, { 0x4c9, 0x08 }, { 0x4ca, 0x3c },
+ { 0x4cb, 0x3c }, { 0x4cc, 0xff }, { 0x4cd, 0xff }, { 0x4ce, 0x01 },
+ { 0x500, 0x26 }, { 0x501, 0xa2 }, { 0x502, 0x2f }, { 0x503, 0x00 },
+ { 0x504, 0x28 }, { 0x505, 0xa3 }, { 0x506, 0x5e }, { 0x507, 0x00 },
+ { 0x508, 0x2b }, { 0x509, 0xa4 }, { 0x50a, 0x5e }, { 0x50b, 0x00 },
+ { 0x50c, 0x4f }, { 0x50d, 0xa4 }, { 0x50e, 0x00 }, { 0x50f, 0x00 },
+ { 0x512, 0x1c }, { 0x514, 0x0a }, { 0x516, 0x0a }, { 0x521, 0x2f },
+ { 0x525, 0x0f }, { 0x550, 0x10 }, { 0x551, 0x10 }, { 0x559, 0x02 },
+ { 0x55c, 0x50 }, { 0x55d, 0xff }, { 0x605, 0x30 }, { 0x608, 0x0e },
+ { 0x609, 0x2a }, { 0x60c, 0x18 }, { 0x620, 0xff }, { 0x621, 0xff },
+ { 0x622, 0xff }, { 0x623, 0xff }, { 0x624, 0xff }, { 0x625, 0xff },
+ { 0x626, 0xff }, { 0x627, 0xff }, { 0x638, 0x50 }, { 0x63c, 0x0a },
+ { 0x63d, 0x0a }, { 0x63e, 0x0e }, { 0x63f, 0x0e }, { 0x640, 0x40 },
+ { 0x642, 0x40 }, { 0x643, 0x00 }, { 0x652, 0xc8 }, { 0x66e, 0x05 },
+ { 0x6a0, 0xff }, { 0x6a1, 0xff }, { 0x6a2, 0xff }, { 0x6a3, 0xff },
+ { 0x6a4, 0xff }, { 0x6a5, 0xff }, { 0x6de, 0x84 }, { 0x700, 0x21 },
+ { 0x701, 0x43 }, { 0x702, 0x65 }, { 0x703, 0x87 }, { 0x708, 0x21 },
+ { 0x709, 0x43 }, { 0x70a, 0x65 }, { 0x70b, 0x87 }, { 0x718, 0x40 },
+ { 0x7c0, 0x38 }, { 0x7c2, 0x0f }, { 0x7c3, 0xc0 }, { 0x073, 0x04 },
+ { 0x7c4, 0x77 }, { 0x024, 0xc7 }, { 0x7ec, 0xff }, { 0x7ed, 0xff },
+ { 0x7ee, 0xff }, { 0x7ef, 0xff },
+};
+
+/*
+ * Baseband initialization values.
+ */
+static const uint16_t rtl8192fu_bb_regs[] = {
+ 0x800, 0x804, 0x808, 0x80c, 0x810, 0x814, 0x818, 0x81c, 0x820,
+ 0x824, 0x828, 0x82c, 0x830, 0x834, 0x838, 0x83c, 0x840, 0x844,
+ 0x848, 0x84c, 0x850, 0x854, 0x858, 0x85c, 0x860, 0x864, 0x868,
+ 0x86c, 0x870, 0x874, 0x878, 0x87c, 0x880, 0x884, 0x888, 0x88c,
+ 0x890, 0x894, 0x898, 0x89c, 0x900, 0x904, 0x908, 0x90c, 0x910,
+ 0x914, 0x918, 0x91c, 0x920, 0x924, 0x928, 0x92c, 0x930, 0x934,
+ 0x938, 0x93c, 0x940, 0x944, 0x948, 0x94c, 0x950, 0x954, 0x958,
+ 0x95c, 0x960, 0x964, 0x968, 0x96c, 0x970, 0x974, 0x978, 0x97c,
+ 0x980, 0x984, 0x988, 0x98c, 0x990, 0x994, 0x998, 0x99c, 0x9a0,
+ 0x9a4, 0x9a8, 0x9ac, 0xa00, 0xa04, 0xa08, 0xa0c, 0xa10, 0xa14,
+ 0xa18, 0xa1c, 0xa20, 0xa24, 0xa28, 0xa2c, 0xa70, 0xa74, 0xa78,
+ 0xa7c, 0xa80, 0xa84, 0xa88, 0xa8c, 0xa90, 0xa94, 0xa98, 0xa9c,
+ 0xaa0, 0xaa4, 0xaa8, 0xaac, 0xab0, 0xab4, 0xab8, 0xabc, 0xac0,
+ 0xac4, 0xac8, 0xacc, 0xad0, 0xad4, 0xad8, 0xadc, 0xae0, 0xb2c,
+ 0xc00, 0xc04, 0xc08, 0xc0c, 0xc10, 0xc14, 0xc18, 0xc1c, 0xc20,
+ 0xc24, 0xc28, 0xc2c, 0xc30, 0xc34, 0xc38, 0xc3c, 0xc40, 0xc44,
+ 0xc48, 0xc4c, 0xc50, 0xc54, 0xc58, 0xc5c, 0xc60, 0xc64, 0xc68,
+ 0xc6c, 0xc70, 0xc74, 0xc78, 0xc7c, 0xc80, 0xc84, 0xc88, 0xc8c,
+ 0xc90, 0xc94, 0xc98, 0xc9c, 0xca0, 0xca4, 0xca8, 0xcac, 0xcb0,
+ 0xcb4, 0xcb8, 0xcbc, 0xcc0, 0xcc4, 0xcc8, 0xccc, 0xcd0, 0xcd4,
+ 0xcd8, 0xcdc, 0xce0, 0xce4, 0xce8, 0xcec, 0xd00, 0xd04, 0xd08,
+ 0xd0c, 0xd10, 0xd14, 0xd18, 0xd1c, 0xd20, 0xd24, 0xd28, 0xd2c,
+ 0xd30, 0xd34, 0xd38, 0xd3c, 0xd50, 0xd54, 0xd58, 0xd5c, 0xd60,
+ 0xd64, 0xd68, 0xd7c, 0xd80, 0xd84, 0xd88, 0xd8c, 0xd90, 0xd94,
+ 0xd98, 0xd9c, 0xe00, 0xe04, 0xe08, 0xe10, 0xe14, 0xe18, 0xe1c,
+ 0xe20, 0xe24, 0xe28, 0xe2c, 0xe30, 0xe34, 0xe38, 0xe3c, 0xe40,
+ 0xe44, 0xe48, 0xe4c, 0xe50, 0xe54, 0xe58, 0xe5c, 0xe60, 0xe64,
+ 0xe68, 0xe6c, 0xe70, 0xe74, 0xe78, 0xe7c, 0xe80, 0xe84, 0xe88,
+ 0xe8c, 0xed0, 0xed4, 0xed8, 0xedc, 0xee0, 0xee4, 0xee8, 0xeec,
+ 0xef0, 0xef4, 0xef8, 0xf00, 0xf04, 0xf08, 0xf0c, 0xf10, 0xf14,
+ 0xf18, 0xf1c, 0xf20, 0xf24, 0xf28, 0xf2c, 0xf30, 0xf34, 0xf38,
+ 0xf3c, 0xf40, 0xf44, 0xf48, 0xf4c, 0xf50,
+};
+
+static const uint32_t rtl8192fu_bb_vals[] = {
+ 0x80006c00, 0x00004001, 0x0000fc00, 0x00000000, 0x20200322,
+ 0x020c3910, 0x00000385, 0x07000000, 0x01000100, 0x00390204,
+ 0x01000100, 0x00390204, 0x25252525, 0x25252525, 0x25252525,
+ 0x25252525, 0x00010000, 0x00010000, 0x25252525, 0x25252525,
+ 0x00031fe0, 0x00000000, 0x569a569a, 0x00400040, 0x66f60000,
+ 0x061f0000, 0x25252525, 0x25252525, 0x00000300, 0x04003400,
+ 0x08080808, 0x004f0201, 0xd8001402, 0xc0000120, 0x00000000,
+ 0xcc0000c0, 0x00000000, 0xfffffffe, 0x40302010, 0x00706050,
+ 0x00000000, 0x00000023, 0x00000f00, 0x81121313, 0x024c0000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x88000000, 0x00000245, 0x00024588,
+ 0x00000000, 0x000007ff, 0x3f3f0000, 0x000001a3, 0x20200008,
+ 0x00338a98, 0x00000000, 0xcbcad87a, 0x06eb5735, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000,
+ 0x00000000, 0x10030000, 0x00000000, 0x02800280, 0x020a5704,
+ 0x1461c826, 0x0001469e, 0x008858d1, 0x400086c9, 0x44444242,
+ 0x00000000, 0x00000000, 0x00000000, 0xc0000000, 0x00d047c8,
+ 0xc1ff0008, 0x88838300, 0x2e20100f, 0x9500bb78, 0x11144028,
+ 0x00881117, 0x89140f00, 0xe82c0001, 0x64b80c1c, 0x00158810,
+ 0x10bb8000, 0x00008000, 0x80800100, 0x000089f0, 0x225b0606,
+ 0x20803210, 0x00200200, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00460000, 0x00000000, 0x00020014,
+ 0xba0a0008, 0x01235667, 0x00000000, 0x00201402, 0x0000001c,
+ 0x0000f7ff, 0xd4c0a742, 0x00000000, 0x00000f08, 0x00000f07,
+ 0xa1052a10, 0x0d9d8452, 0x9e024024, 0x0023c001, 0x00000391,
+ 0x00000000, 0x00000080, 0x6f005433, 0x000004e4, 0x6c6c6c6c,
+ 0x22000000, 0x40000100, 0x22000000, 0x40000100, 0x00000000,
+ 0x40000100, 0x00000000, 0x40000100, 0x0401e809, 0x30000020,
+ 0x23808080, 0x00002f44, 0x1cf8403f, 0x000100c7, 0xec060106,
+ 0x007f037f, 0x00e48020, 0x04008017, 0x00000020, 0x00708492,
+ 0x09280200, 0x5014838b, 0x47c006c7, 0x00000035, 0x00001007,
+ 0x02815269, 0x0fe07f1f, 0x00b91612, 0x40000100, 0x32000000,
+ 0x40000100, 0xa0240000, 0x400e161e, 0x00000f00, 0x400e161e,
+ 0x0000bdc8, 0x00000000, 0x098300a0, 0x00006b00, 0x87f45b1a,
+ 0x0000002d, 0x00000000, 0x00000000, 0x28100200, 0x0010a3d0,
+ 0x00000f7d, 0x00000000, 0x00000000, 0x593659ad, 0xb7545121,
+ 0x64b22427, 0x00766932, 0x40201000, 0x00000000, 0x40e04407,
+ 0x2e572000, 0x000d8780, 0x40020403, 0x0002907f, 0x20010201,
+ 0x06288888, 0x8888367b, 0x7d806db3, 0x0000007f, 0x567600b8,
+ 0x0000018b, 0xd513ff7d, 0xcc979975, 0x04928000, 0x40608000,
+ 0x88dda000, 0x00026ee2, 0x67270001, 0x20500000, 0x16161616,
+ 0x71f20064, 0x4653da60, 0x3e718a3c, 0x00000183, 0x00000000,
+ 0x50000000, 0x31310400, 0xf5b50000, 0x00000000, 0x00000000,
+ 0x44bbbb44, 0x44bb44ff, 0x06033688, 0x25252525, 0x25252525,
+ 0x25252525, 0x25252525, 0x25252525, 0x25252525, 0x25252525,
+ 0x00000000, 0x00200000, 0x00000000, 0x00000000, 0x01007c00,
+ 0x01004800, 0x10008c0f, 0x3c008c0f, 0x01007c00, 0x00000000,
+ 0x00000000, 0x00000000, 0x01007c00, 0x01004800, 0x10008c0f,
+ 0x3c008c0f, 0x02100000, 0xbbbbbbbb, 0x40404040, 0x80408040,
+ 0x80408040, 0x40404040, 0x00400040, 0x40404040, 0x00ff0000,
+ 0x80408040, 0x40404040, 0x80408040, 0x80408040, 0x80408040,
+ 0x80408040, 0xc040c040, 0xc040c040, 0x00400040, 0xd8001402,
+ 0xc0000120, 0x02000b09, 0x00000001, 0x00000000, 0x00000300,
+ 0x00000002, 0x00007d0c, 0x0000a907, 0x00005807, 0x00000003,
+ 0x07d003e8, 0x8000001f, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00030055, 0x0000003a,
+ 0x00000002, 0x00000000, 0x00000000, 0x0b000000, 0x00000000,
+};
+
+static const struct rtwn_bb_prog rtl8192fu_bb[] = {
+ {
+ nitems(rtl8192fu_bb_regs),
+ rtl8192fu_bb_regs,
+ rtl8192fu_bb_vals,
+ { 0 },
+ NULL
+ }
+};
+
+static const uint32_t rtl8192fu_agc_vals[] = {
+ 0x0fa0001f, 0x0fa0011f, 0x0fa0021f, 0x0fa0031f, 0x0fa0041f,
+ 0x0fa0051f, 0x0f90061f, 0x0f80071f, 0x0f70081f, 0x0f60091f,
+ 0x0f500a1f, 0x0f400b1f, 0x0f300c1f, 0x0f200d1f, 0x0f100e1f,
+ 0x0f000f1f, 0x0ef0101f, 0x0ee0111f, 0x0ed0121f, 0x0ec0131f,
+ 0x0eb0141f, 0x0ea0151f, 0x0e90161f, 0x0e80171f, 0x0e70181f,
+ 0x0e60191f, 0x0e501a1f, 0x0e401b1f, 0x0e301c1f, 0x0c701d1f,
+ 0x0c601e1f, 0x0c501f1f, 0x0c40201f, 0x0c30211f, 0x0a60221f,
+ 0x0a50231f, 0x0a40241f, 0x0a30251f, 0x0860261f, 0x0850271f,
+ 0x0840281f, 0x0830291f, 0x06702a1f, 0x06602b1f, 0x06502c1f,
+ 0x06402d1f, 0x06302e1f, 0x04602f1f, 0x0450301f, 0x0440311f,
+ 0x0430321f, 0x0260331f, 0x0250341f, 0x0240351f, 0x0230361f,
+ 0x0050371f, 0x0040381f, 0x0030391f, 0x00203a1f, 0x00103b1f,
+ 0x00003c1f, 0x00003d1f, 0x00003e1f, 0x00003f1f, 0x0fa0401f,
+ 0x0fa0411f, 0x0fa0421f, 0x0fa0431f, 0x0f90441f, 0x0f80451f,
+ 0x0f70461f, 0x0f60471f, 0x0f50481f, 0x0f40491f, 0x0f304a1f,
+ 0x0f204b1f, 0x0f104c1f, 0x0f004d1f, 0x0ef04e1f, 0x0ee04f1f,
+ 0x0ed0501f, 0x0ec0511f, 0x0eb0521f, 0x0ea0531f, 0x0e90541f,
+ 0x0e80551f, 0x0e70561f, 0x0e60571f, 0x0e50581f, 0x0e40591f,
+ 0x0e305a1f, 0x0e205b1f, 0x0e105c1f, 0x0c505d1f, 0x0c405e1f,
+ 0x0c305f1f, 0x0c20601f, 0x0c10611f, 0x0a40621f, 0x0a30631f,
+ 0x0a20641f, 0x0a10651f, 0x0840661f, 0x0830671f, 0x0820681f,
+ 0x0810691f, 0x06506a1f, 0x06406b1f, 0x06306c1f, 0x06206d1f,
+ 0x06106e1f, 0x04406f1f, 0x0430701f, 0x0420711f, 0x0410721f,
+ 0x0240731f, 0x0230741f, 0x0220751f, 0x0210761f, 0x0030771f,
+ 0x0020781f, 0x0010791f, 0x00007a1f, 0x00007b1f, 0x00007c1f,
+ 0x00007d1f, 0x00007e1f, 0x00007f1f, 0x0fa0801f, 0x0fa0811f,
+ 0x0fa0821f, 0x0fa0831f, 0x0fa0841f, 0x0fa0851f, 0x0f90861f,
+ 0x0f80871f, 0x0f70881f, 0x0f60891f, 0x0f508a1f, 0x0f408b1f,
+ 0x0f308c1f, 0x0f208d1f, 0x0f108e1f, 0x0b908f1f, 0x0b80901f,
+ 0x0b70911f, 0x0b60921f, 0x0b50931f, 0x0b40941f, 0x0b30951f,
+ 0x0b20961f, 0x0b10971f, 0x0b00981f, 0x0af0991f, 0x0ae09a1f,
+ 0x0ad09b1f, 0x0ac09c1f, 0x0ab09d1f, 0x0aa09e1f, 0x0a909f1f,
+ 0x0a80a01f, 0x0a70a11f, 0x0a60a21f, 0x0a50a31f, 0x0a40a41f,
+ 0x0a30a51f, 0x0a20a61f, 0x0a10a71f, 0x0a00a81f, 0x0830a91f,
+ 0x0820aa1f, 0x0810ab1f, 0x0800ac1f, 0x0640ad1f, 0x0630ae1f,
+ 0x0620af1f, 0x0610b01f, 0x0600b11f, 0x0430b21f, 0x0420b31f,
+ 0x0410b41f, 0x0400b51f, 0x0230b61f, 0x0220b71f, 0x0210b81f,
+ 0x0200b91f, 0x0000ba1f, 0x0000bb1f, 0x0000bc1f, 0x0000bd1f,
+ 0x0000be1f, 0x0000bf1f, /* 0x00e48024, 0x00e48020, these values are written to 0xc50 rather than 0xc78 */
+};
+
+static const struct rtwn_agc_prog rtl8192fu_agc[] = {
+ {
+ nitems(rtl8192fu_agc_vals),
+ rtl8192fu_agc_vals,
+ { 0 },
+ NULL
+ }
+};
+
+/*
+ * RF initialization values.
+ */
+static const uint8_t rtl8192fu_rf0_regs[] = {
+ 0x00, 0x18, 0x81, 0x82, 0x84, 0x86, 0x87, 0x88, 0x8e, 0x8f,
+ 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x5a, 0x5b,
+ 0x5c, 0x65, 0x6e, 0xf5, 0xef, 0x33, 0x33, 0x33, 0xef, 0xdf,
+ 0x35, 0xf0, 0xef, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0x33, 0x33, 0x33, 0xef, 0xef, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0x33, 0x33, 0x33, 0xef, 0xef, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0x33, 0xef, 0xef, 0x33, 0x33, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0x33, 0xef, 0x84, 0xef, 0x30, 0x31, 0x32, 0xef,
+ 0x84, 0xef, 0x30, 0x31, 0x32, 0xef, 0x84, 0xef, 0x30, 0x31,
+ 0x32, 0xef, 0x1b, 0xef, 0x33, 0x33, 0x33, 0x33, 0xef, 0xdf,
+ 0xb0, 0xb3, 0xb7, 0xb8, 0xc9, 0xdf, 0xb1, 0xb2, 0xb4, 0xb5,
+ 0xb6, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xca, 0xfe,
+ 0x18, 0xfe, 0xfe, 0xfe, 0x00,
+}, rtl8192fu_rf1_regs[] = {
+ 0x00, 0x81, 0x82, 0x84, 0x86, 0x87, 0x88, 0x8e, 0x8f, 0x51,
+ 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x5a, 0x5b, 0x5c,
+ 0x65, 0x6e, 0xf5, 0xef, 0x33, 0x33, 0x33, 0xef, 0xdf, 0x35,
+ 0xf0, 0xef, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0x33, 0x33, 0xef, 0xef, 0x33, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0x33, 0x33, 0xef, 0xef, 0x33, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0xef, 0xef, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+ 0x33, 0x33, 0xef, 0x84, 0xef, 0x30, 0x31, 0x32, 0xef, 0x84,
+ 0xef, 0x30, 0x31, 0x32, 0xef, 0x84, 0xef, 0x30, 0x31, 0x32,
+ 0xef, 0x1b, 0xef, 0x33, 0x33, 0x33, 0x33, 0xef, 0x00,
+
+};
+
+static const uint32_t rtl8192fu_rf0_vals[] = {
+ 0x30000, 0x0fc07, 0x0fc00, 0x003c0, 0x00005, 0xa33a5, 0x00000,
+ 0x58010, 0x64540, 0x282d8, 0x02c06, 0x7a007, 0x10061, 0x60018,
+ 0x82020, 0x08cc6, 0x2cc00, 0x00000, 0x50000, 0x00006, 0x00015,
+ 0x20000, 0x38319, 0x43180, 0x00002, 0x00301, 0x1032a, 0x2032a,
+ 0x00000, 0x00002, 0x00000, 0x08008, 0x00800, 0x0040e, 0x04845,
+ 0x08848, 0x0c84b, 0x1088a, 0x14c50, 0x18c8e, 0x1cccd, 0x20cd0,
+ 0x24cd3, 0x28cd6, 0x4002b, 0x4402e, 0x48846, 0x4c849, 0x50888,
+ 0x54cc6, 0x58cc9, 0x5cccc, 0x60ccf, 0x64cd2, 0x68cd5, 0x00000,
+ 0x00400, 0x01c23, 0x05c23, 0x09d23, 0x0dd23, 0x11fa3, 0x15fa3,
+ 0x19fab, 0x1dfab, 0x00000, 0x00200, 0x00030, 0x04030, 0x08030,
+ 0x0c030, 0x10030, 0x14030, 0x18030, 0x1c030, 0x20030, 0x24030,
+ 0x28030, 0x2c030, 0x30030, 0x34030, 0x38030, 0x3c030, 0x00000,
+ 0x00100, 0x44001, 0x48001, 0x4c001, 0x50001, 0x54001, 0x58001,
+ 0x5c001, 0x60001, 0x64001, 0x68001, 0x6c001, 0x70001, 0x74001,
+ 0x78001, 0x04000, 0x08000, 0x0c000, 0x10000, 0x14000, 0x18001,
+ 0x1c002, 0x20002, 0x24002, 0x28002, 0x2c002, 0x30002, 0x34002,
+ 0x38002, 0x00000, 0x00000, 0x80010, 0x20000, 0x0006f, 0x01ff7,
+ 0x00000, 0x00000, 0x80000, 0x30000, 0x0006f, 0xf1df3, 0x00000,
+ 0x00000, 0x80000, 0x38000, 0x0006f, 0xf1ff2, 0x00000, 0x746ce,
+ 0x20000, 0x30000, 0x38000, 0x70000, 0x78000, 0x00000, 0x08000,
+ 0xffbcb, 0x06000, 0x18df0, 0x38ff0, 0x00600, 0x00000, 0x33b8f,
+ 0x33762, 0x141f0, 0x14080, 0x12425, 0xc0008, 0x40005, 0x02c01,
+ 0x0000b, 0x81e2f, 0x5c28f, 0x000a0, 0x02000, 0x00000, 0x08c07,
+ 0x00000, 0x00000, 0x00000, 0x31dd5,
+}, rtl8192fu_rf1_vals[] = {
+ 0x30000, 0x0fc00, 0x003c0, 0x00005, 0xa33a5, 0x00000, 0x58010,
+ 0x64540, 0x282d8, 0x02c06, 0x7a007, 0x10061, 0x60018, 0x82020,
+ 0x08cc6, 0x2cc00, 0x00000, 0x50000, 0x00006, 0x00015, 0x20000,
+ 0x38319, 0x43180, 0x00002, 0x00301, 0x1032a, 0x2032a, 0x00000,
+ 0x00002, 0x00000, 0x08008, 0x00800, 0x0040e, 0x04845, 0x08848,
+ 0x0c84b, 0x1088a, 0x14cc8, 0x18ccb, 0x1ccce, 0x20cd1, 0x24cd4,
+ 0x28cd7, 0x4002b, 0x4402e, 0x48846, 0x4c849, 0x50888, 0x54cc6,
+ 0x58cc9, 0x5cccc, 0x60ccf, 0x64cd2, 0x68cd5, 0x00000, 0x00400,
+ 0x01d23, 0x05d23, 0x09fa3, 0x0dfa3, 0x11d2b, 0x15d2b, 0x19fab,
+ 0x1dfab, 0x00000, 0x00200, 0x00030, 0x04030, 0x08030, 0x0c030,
+ 0x10030, 0x14030, 0x18030, 0x1c030, 0x20030, 0x24030, 0x28030,
+ 0x2c030, 0x30030, 0x34030, 0x38030, 0x3c030, 0x00000, 0x00100,
+ 0x44000, 0x48000, 0x4c000, 0x50000, 0x54000, 0x58000, 0x5c000,
+ 0x60000, 0x64000, 0x68000, 0x6c000, 0x70000, 0x74000, 0x78000,
+ 0x04000, 0x08000, 0x0c000, 0x10000, 0x14000, 0x18000, 0x1c001,
+ 0x20001, 0x24001, 0x28001, 0x2c001, 0x30001, 0x34001, 0x38001,
+ 0x00000, 0x00000, 0x80010, 0x20000, 0x0006f, 0x01ff7, 0x00000,
+ 0x00000, 0x80000, 0x30000, 0x0006f, 0xf1df3, 0x00000, 0x00000,
+ 0x80000, 0x38000, 0x0006f, 0xf1ff2, 0x00000, 0x746ce, 0x20000,
+ 0x30000, 0x38000, 0x70000, 0x78000, 0x00000, 0x31dd5,
+};
+
+static const struct rtwn_rf_prog rtl8192fu_rf[] = {
+ /* RF chain 0. */
+ {
+ nitems(rtl8192fu_rf0_regs),
+ rtl8192fu_rf0_regs,
+ rtl8192fu_rf0_vals,
+ { 0 },
+ NULL
+ },
+ { 0, NULL, NULL, { 0 }, NULL },
+ /* RF chain 1. */
+ {
+ nitems(rtl8192fu_rf1_regs),
+ rtl8192fu_rf1_regs,
+ rtl8192fu_rf1_vals,
+ { 0 },
+ NULL
+ },
+ { 0, NULL, NULL, { 0 }, NULL },
+};
+
+#endif /* R92F_PRIV_H */
diff --git a/sys/dev/rtwn/rtl8192f/r92f_reg.h b/sys/dev/rtwn/rtl8192f/r92f_reg.h
new file mode 100644
index 000000000000..2af34f350470
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/r92f_reg.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef R92F_REG_H
+#define R92F_REG_H
+
+#define R92F_RFE_OPT 0x0920
+#define R92F_DPDT_CTRL 0x092c
+#define R92F_RFE_CTRL_ANT_SRC(idx) (0x0930 + (idx * 4))
+#define R92F_RFE_PATH_SELECT 0x0940
+#define R92F_RFE_BUFFER 0x0944
+#define R92F_RFE_OPT62 0x0968
+#define R92F_ANAPWR1 0x0d94
+#define R92F_NP_ANTA 0x0e20
+#define R92F_TAP_UPD_97F 0x0e24
+#define R92F_IQK_RPT_TXA 0x0e98
+#define R92F_IQK_RPT_RXA 0x0ea8
+#define R92F_IQK_RPT_TXB 0x0eb8
+#define R92F_IQK_RPT_RXB 0x0ec8
+#define R92F_RF_GAIN_P1 0x35
+#define R92F_RF_TXMOD 0x58
+#define R92F_PKT_VO_VI_LIFE_TIME 0x04c0
+#define R92F_PKT_BE_BK_LIFE_TIME 0x04c2
+
+#define R92F_DATA_SUBCHANNEL 0x0483
+#define R92F_RX_DFIR_MOD_97F 0x0948
+#define R92F_CCK0_TX_FILTER1 0x0a20
+#define R92F_CCK0_TX_FILTER2 0x0a24
+#define R92F_CCK0_DEBUG_PORT 0x0a28
+#define R92F_CCK0_TX_FILTER3 0x0aac
+#define R92F_DOWNSAM_FACTOR 0x0c10
+#define R92F_ANTDIV_PARA1 0x0ca4
+#define R92F_TAP_UPD_97F 0x0e24
+
+#define R92F_RF_CHNLBW_BW_MASK 0x00000c00
+#define R92F_RF_GAIN_CTRL 0xf5
+
+#define R92F_SW_GPIO_SHARE_CTRL(idx) (0x1038 + (idx * 4))
+#define R92F_LED_GPIO_ENABLE 0x1
+
+#define R92F_AFE_MISC_WL_XTAL_CTRL 0x40
+#define R92F_GPIO_INTM_EDGE_TRIG_IRQ 0x200
+
+#define R92F_GPIO_IO_SEL_2 0x0062
+#define R92F_GPIO_IO_SEL_2_GPIO09_IRQ 0x200
+#define R92F_GPIO_IO_SEL_2_GPIO09_INPUT 0x002
+
+/* Enable GPIO[9] as WiFi RF HW powerdown source */
+#define R92F_MULTI_WIFI_HW_ROF_EN 0x8
+
+#define R92F_RSVD_1 0x0097
+#define R92F_RSVD_4 0x00dc
+
+#define R92F_GPIO_A0 0x1050
+#define R92F_GPIO_B0 0x105b
+
+#define R92F_LED_MODE_SW_CTRL 0x0
+
+#define R92F_LEDCFG0_LED2EN_M 0x00200000
+#define R92F_LEDCFG0_LED2EN_S 21
+
+#define R92F_LEDCFG0_LED0_IO_MODE_M 0x80
+#define R92F_LEDCFG0_LED0_IO_MODE_S 7
+
+#define R92F_LEDCFG0_LED1_IO_MODE_M 0x8000
+#define R92F_LEDCFG0_LED1_IO_MODE_S 15
+
+#define R92F_LEDCFG0_LED0CM_M 0x7
+#define R92F_LEDCFG0_LED0CM_S 0
+
+#define R92F_LEDCFG0_LED1CM_M 0x700
+#define R92F_LEDCFG0_LED1CM_S 8
+
+#define R92F_LEDCFG0_LED0SV_M 0x8
+#define R92F_LEDCFG0_LED0SV_S 3
+
+#define R92F_LEDCFG0_LED1SV_M 0x800
+#define R92F_LEDCFG0_LED1SV_S 11
+
+#define R92F_LED_SW_OFF 0x0
+#define R92F_LED_SW_ON 0x1
+
+#define R92F_LED_MODE_TX_OR_RX_EVENTS 0x3
+#define R92F_LED_IO_MODE_OUTPUT 0x0
+#define R92F_FPGA0_RFMOD_CCK 0x1000000
+
+#endif /* R92F_REG_H */
diff --git a/sys/dev/rtwn/rtl8192f/r92f_rom.c b/sys/dev/rtwn/rtl8192f/r92f_rom.c
new file mode 100644
index 000000000000..57b0c0aec4e9
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/r92f_rom.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/cdefs.h>
+#include "opt_wlan.h"
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/mbuf.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
+#include <sys/taskqueue.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/linker.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_media.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
+
+#include <dev/rtwn/if_rtwnreg.h>
+#include <dev/rtwn/if_rtwnvar.h>
+
+#include <dev/rtwn/if_rtwn_debug.h>
+
+#include <dev/rtwn/rtl8192c/r92c_var.h>
+#include <dev/rtwn/rtl8192c/r92c_reg.h>
+
+#include <dev/rtwn/rtl8192e/r92e_rom_image.h>
+
+#include <dev/rtwn/rtl8192f/r92f.h>
+#include <dev/rtwn/rtl8192f/r92f_priv.h>
+#include <dev/rtwn/rtl8192f/r92f_var.h>
+#include <dev/rtwn/rtl8192f/r92f_rom_image.h>
+
+void
+r92f_parse_rom(struct rtwn_softc *sc, uint8_t *buf)
+{
+ struct r92f_softc *rs = sc->sc_priv;
+ struct r92f_rom *rom = (struct r92f_rom *)buf;
+ uint8_t pwr_diff;
+ int i, j, k;
+
+ rs->bb_gain[0] = buf[0x1ec];
+ rs->bb_gain[1] = buf[0x1ee];
+ rs->bb_gain[2] = buf[0x1ea];
+
+ if (rs->bb_gain[1] != 0xff) {
+ if (rs->bb_gain[0] == 0xff) {
+ rs->bb_gain[0] = rs->bb_gain[1];
+ }
+ if (rs->bb_gain[2] == 0xff) {
+ rs->bb_gain[2] = rs->bb_gain[1];
+ }
+ }
+
+ RTWN_DPRINTF(sc, RTWN_DEBUG_ROM,
+ "%s: bb_gain ch1-3=%02x ch4-9=%02x ch10-14=%02x\n", __func__,
+ rs->bb_gain[0], rs->bb_gain[1], rs->bb_gain[2]);
+
+ sc->thermal_meter = rom->thermal_meter;
+
+ for (i = 0; i < sc->ntxchains; i++) {
+ struct r92e_tx_pwr_2g *pwr_2g = &rom->tx_pwr[i].pwr_2g;
+ struct r92e_tx_pwr_diff_2g *pwr_diff_2g =
+ &rom->tx_pwr[i].pwr_diff_2g;
+
+ for (j = 0; j < R92E_GROUP_2G - 1; j++) {
+ rs->cck_tx_pwr[i][j] =
+ RTWN_GET_ROM_VAR(pwr_2g->cck[j],
+ R92E_DEF_TX_PWR_2G);
+ rs->ht40_tx_pwr_2g[i][j] =
+ RTWN_GET_ROM_VAR(pwr_2g->ht40[j],
+ R92E_DEF_TX_PWR_2G);
+ }
+ rs->cck_tx_pwr[i][j] = RTWN_GET_ROM_VAR(pwr_2g->cck[j],
+ R92E_DEF_TX_PWR_2G);
+
+ rs->cck_tx_pwr_diff_2g[i][0] = 0;
+ rs->ofdm_tx_pwr_diff_2g[i][0] = RTWN_SIGN4TO8(
+ MS(pwr_diff_2g->ht20_ofdm, LOW_PART));
+ rs->bw20_tx_pwr_diff_2g[i][0] = RTWN_SIGN4TO8(
+ MS(pwr_diff_2g->ht20_ofdm, HIGH_PART));
+ rs->bw40_tx_pwr_diff_2g[i][0] = 0;
+
+ for (j = 1, k = 0; k < nitems(pwr_diff_2g->diff123); j++, k++) {
+ pwr_diff = RTWN_GET_ROM_VAR(
+ pwr_diff_2g->diff123[k].ofdm_cck,
+ R92E_DEF_TX_PWR_DIFF);
+ if (pwr_diff != R92E_DEF_TX_PWR_DIFF) {
+ rs->cck_tx_pwr_diff_2g[i][j] = RTWN_SIGN4TO8(
+ MS(pwr_diff_2g->diff123[k].ofdm_cck,
+ LOW_PART));
+ rs->ofdm_tx_pwr_diff_2g[i][j] = RTWN_SIGN4TO8(
+ MS(pwr_diff_2g->diff123[k].ofdm_cck,
+ HIGH_PART));
+ } else {
+ rs->cck_tx_pwr_diff_2g[i][j] =
+ rs->ofdm_tx_pwr_diff_2g[i][j] = pwr_diff;
+ }
+ pwr_diff = RTWN_GET_ROM_VAR(
+ pwr_diff_2g->diff123[k].ht40_ht20,
+ R92E_DEF_TX_PWR_DIFF);
+ if (pwr_diff != R92E_DEF_TX_PWR_DIFF) {
+ rs->bw20_tx_pwr_diff_2g[i][j] = RTWN_SIGN4TO8(
+ MS(pwr_diff_2g->diff123[k].ht40_ht20,
+ LOW_PART));
+ rs->bw40_tx_pwr_diff_2g[i][j] = RTWN_SIGN4TO8(
+ MS(pwr_diff_2g->diff123[k].ht40_ht20,
+ HIGH_PART));
+ } else {
+ rs->bw20_tx_pwr_diff_2g[i][j] =
+ rs->bw40_tx_pwr_diff_2g[i][j] = pwr_diff;
+ }
+ }
+ }
+
+ rs->crystalcap = (rom->crystalcap == 0xff) ?
+ R92E_ROM_CRYSTALCAP_DEF : (rom->crystalcap & 0x3f);
+ rs->rfe = rom->rfe_opt & 0x1f;
+
+ /* Read MAC address. */
+ IEEE80211_ADDR_COPY(sc->sc_ic.ic_macaddr, rom->macaddr);
+}
diff --git a/sys/dev/rtwn/rtl8192f/r92f_rom_defs.h b/sys/dev/rtwn/rtl8192f/r92f_rom_defs.h
new file mode 100644
index 000000000000..17e59133ea2b
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/r92f_rom_defs.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef R92F_ROM_DEFS_H
+#define R92F_ROM_DEFS_H
+
+#include <dev/rtwn/rtl8192e/r92e_rom_image.h>
+
+#define R92F_MAX_RF_PATH 2
+#define R92F_EFUSE_MAP_LEN 512
+
+#endif /* R92F_ROM_DEFS_H */
diff --git a/sys/dev/rtwn/rtl8192f/r92f_rom_image.h b/sys/dev/rtwn/rtl8192f/r92f_rom_image.h
new file mode 100644
index 000000000000..83f75b204eea
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/r92f_rom_image.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef R92F_ROM_IMAGE_H
+#define R92F_ROM_IMAGE_H
+
+#include <dev/rtwn/rtl8192f/r92f_rom_defs.h>
+
+struct r92f_rom {
+ uint8_t reserved1[16];
+ struct r92e_tx_pwr tx_pwr[R92F_MAX_RF_PATH];
+ uint8_t reserved2[84];
+ uint8_t channel_plan;
+ uint8_t crystalcap;
+ uint8_t thermal_meter;
+ uint8_t iqk_lck;
+ uint8_t pa_type;
+ uint8_t lna_type_2g;
+ uint8_t reserved3;
+ uint8_t lna_type_5g;
+ uint8_t reserved4;
+ uint8_t rf_board_opt;
+ uint8_t rf_feature_option;
+ uint8_t rf_bt_opt;
+ uint8_t version;
+ uint8_t customer_id;
+ uint8_t reserved5[3];
+ uint8_t rf_ant_opt;
+ uint8_t rfe_opt;
+ uint8_t country_code;
+ uint8_t reserved6[52];
+ uint8_t vid[2];
+ uint8_t pid[2];
+ uint8_t usb_optional_function;
+ uint8_t reserved7[2];
+ uint8_t macaddr[IEEE80211_ADDR_LEN];
+ uint8_t device_info[80];
+ uint8_t reserved8[163];
+} __packed;
+
+_Static_assert(sizeof(struct r92f_rom) == R92F_EFUSE_MAP_LEN,
+ "R92F_EFUSE_MAP_LEN must be equal to sizeof(struct r92f_rom)!");
+
+#endif /* R92F_ROM_IMAGE_H */
diff --git a/sys/dev/rtwn/rtl8192f/r92f_rx.c b/sys/dev/rtwn/rtl8192f/r92f_rx.c
new file mode 100644
index 000000000000..158ce59022aa
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/r92f_rx.c
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/cdefs.h>
+#include "opt_wlan.h"
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/mbuf.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
+#include <sys/taskqueue.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/linker.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_media.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
+#include <net80211/ieee80211_ratectl.h>
+
+#include <dev/rtwn/if_rtwnreg.h>
+#include <dev/rtwn/if_rtwnvar.h>
+
+#include <dev/rtwn/if_rtwn_debug.h>
+#include <dev/rtwn/if_rtwn_ridx.h>
+
+#include <dev/rtwn/rtl8192c/r92c_rx_desc.h>
+
+#include <dev/rtwn/rtl8192f/r92f.h>
+#include <dev/rtwn/rtl8192f/r92f_reg.h>
+#include <dev/rtwn/rtl8192f/r92f_rx_desc.h>
+#include <dev/rtwn/rtl8192f/r92f_var.h>
+
+#include <dev/rtwn/rtl8812a/r12a_rx_desc.h>
+
+int8_t
+r92f_get_rssi_cck(struct rtwn_softc *sc, void *physt)
+{
+ struct r92f_rx_phystat *phy = (struct r92f_rx_phystat *)physt;
+ struct r92f_softc *rs = sc->sc_priv;
+ uint32_t rxdw0, rxdw3;
+ uint8_t vga_idx, lna_idx;
+ int8_t rx_pwr_all;
+
+ rxdw0 = le32toh(phy->rxdw0);
+ rxdw3 = le32toh(phy->rxdw3);
+
+ if (rs->cck_new_agc)
+ return ((int8_t)(MS(rxdw0, R92F_RXDW0_PWDB0) - 110));
+
+ lna_idx = (MS(rxdw3, R92F_RXDW3_LNA_H) << 3) | MS(rxdw3, R92F_RXDW3_LNA_L);
+ vga_idx = MS(rxdw3, R92F_RXDW3_VGA);
+
+ switch (lna_idx) {
+ case 7:
+ rx_pwr_all = -44 - (2 * vga_idx);
+ break;
+ case 5:
+ rx_pwr_all = -28 - (2 * vga_idx);
+ break;
+ case 3:
+ rx_pwr_all = -10 - (2 * vga_idx);
+ break;
+ case 0:
+ rx_pwr_all = 14 - (2 * vga_idx);
+ break;
+ default:
+ rx_pwr_all = 0;
+ break;
+ }
+
+ return (rx_pwr_all);
+}
+
+int8_t
+r92f_get_rssi_ofdm(struct rtwn_softc *sc, void *physt)
+{
+ struct r92f_rx_phystat *phy = (struct r92f_rx_phystat *)physt;
+ uint32_t rxdw0, rxdw1;
+ uint8_t pagenum, pwdb_max;
+ int rx_path;
+ uint8_t pwdb[4];
+
+ rxdw0 = le32toh(phy->rxdw0);
+ rxdw1 = le32toh(phy->rxdw1);
+
+ pagenum = MS(rxdw0, R92F_RXDW0_PAGE_NUM);
+
+ if (pagenum == 0)
+ return (MS(rxdw0, R92F_RXDW0_PWDB0) - 110);
+
+ if (pagenum > 2)
+ return (0);
+
+ pwdb[0] = MS(rxdw0, R92F_RXDW0_PWDB0);
+ pwdb[1] = MS(rxdw0, R92F_RXDW0_PWDB1);
+ pwdb[2] = MS(rxdw0, R92F_RXDW0_PWDB2);
+ pwdb[3] = MS(rxdw1, R92F_RXDW1_PWDB3);
+
+ pwdb_max = 0;
+
+ for (rx_path = 0; rx_path < sc->nrxchains; rx_path++)
+ pwdb_max = pwdb_max > pwdb[rx_path] ? pwdb_max : pwdb[rx_path];
+
+ return ((uint8_t)(pwdb_max - 110));
+}
+
+void
+r92f_get_rx_stats(struct rtwn_softc *sc, struct ieee80211_rx_stats *rxs,
+ const void *desc, const void *physt_ptr)
+{
+ const struct r92c_rx_stat *stat = desc;
+ uint32_t rxdw0, rxdw1, rxdw3, rxdw4;
+ uint8_t rate;
+
+ rxdw0 = le32toh(stat->rxdw0);
+ rxdw1 = le32toh(stat->rxdw1);
+ rxdw3 = le32toh(stat->rxdw3);
+ rxdw4 = le32toh(stat->rxdw4);
+
+ rate = MS(rxdw3, R92F_RXDW3_MCS);
+
+ if (rxdw1 & R92C_RXDW1_AMPDU) {
+ if (rxdw0 & R92C_RXDW0_PHYST)
+ rxs->c_pktflags |= IEEE80211_RX_F_AMPDU;
+ else
+ rxs->c_pktflags |= IEEE80211_RX_F_AMPDU_MORE;
+ }
+
+ if ((rxdw4 & R92F_RXDW4_SPLCP) && RTWN_RATE_IS_HT(rate))
+ rxs->c_pktflags |= IEEE80211_RX_F_SHORTGI;
+
+ if (MS(rxdw4, R92F_RXDW4_BW) != 0)
+ rxs->c_width = IEEE80211_RX_FW_40MHZ;
+ else
+ rxs->c_width = IEEE80211_RX_FW_20MHZ;
+
+ if (RTWN_RATE_IS_CCK(rate))
+ rxs->c_phytype = IEEE80211_RX_FP_11B;
+ else if (RTWN_RATE_IS_OFDM(rate))
+ rxs->c_phytype = IEEE80211_RX_FP_11G;
+ else
+ rxs->c_phytype = IEEE80211_RX_FP_11NG;
+
+ /* Map HW rate index to 802.11 rate. */
+ if (RTWN_RATE_IS_CCK(rate) || RTWN_RATE_IS_OFDM(rate)) {
+ rxs->c_rate = ridx2rate[rate];
+ if (RTWN_RATE_IS_CCK(rate))
+ rxs->c_pktflags |= IEEE80211_RX_F_CCK;
+ else
+ rxs->c_pktflags |= IEEE80211_RX_F_OFDM;
+ } else if (RTWN_RATE_IS_HT(rate)) {
+ rxs->c_rate = IEEE80211_RATE_MCS | RTWN_RIDX_TO_MCS(rate);
+ rxs->c_pktflags |= IEEE80211_RX_F_HT;
+ } else {
+ /* Reserved/unsupported rate. */
+ rxs->c_rate = 0;
+ }
+}
+
diff --git a/sys/dev/rtwn/rtl8192f/r92f_rx_desc.h b/sys/dev/rtwn/rtl8192f/r92f_rx_desc.h
new file mode 100644
index 000000000000..5b0d3c26cc43
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/r92f_rx_desc.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef R92F_RX_DESC_H
+#define R92F_RX_DESC_H
+
+#define R92F_RXDW0_PAGE_NUM_M 0x000000ff
+#define R92F_RXDW0_PAGE_NUM_S 0
+
+#define R92F_RXDW0_PWDB0_M 0x0000ff00
+#define R92F_RXDW0_PWDB0_S 8
+
+#define R92F_RXDW0_PWDB1_M 0x00ff0000
+#define R92F_RXDW0_PWDB1_S 16
+
+#define R92F_RXDW0_PWDB2_M 0xff000000
+#define R92F_RXDW0_PWDB2_S 24
+
+#define R92F_RXDW1_PWDB3_M 0x000000ff
+#define R92F_RXDW1_PWDB3_S 0
+
+#define R92F_RXDW3_VGA_M 0x00001f00
+#define R92F_RXDW3_VGA_S 8
+
+#define R92F_RXDW3_LNA_L_M 0x0000e000
+#define R92F_RXDW3_LNA_L_S 13
+#define R92F_RXDW3_LNA_H_M 0x00800000
+#define R92F_RXDW3_LNA_H_S 23
+#define R92F_RXDW4_SPLCP 0x00000001
+#define R92F_RXDW4_BW_M 0x00000030
+#define R92F_RXDW4_BW_S 4
+#define R92F_RXDW3_MCS_M 0x0000007f
+#define R92F_RXDW3_MCS_S 0
+
+struct r92f_rx_phystat {
+ uint32_t rxdw0;
+ uint32_t rxdw1;
+ uint32_t rxdw2;
+ uint32_t rxdw3;
+ uint32_t rxdw4;
+ uint32_t rxdw5;
+ uint32_t rxdw6;
+} __packed;
+
+#endif // !R92F_RX_DESC_H
diff --git a/sys/dev/rtwn/rtl8192f/r92f_tx.c b/sys/dev/rtwn/rtl8192f/r92f_tx.c
new file mode 100644
index 000000000000..085bdee4272f
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/r92f_tx.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/cdefs.h>
+#include "opt_wlan.h"
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/mbuf.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
+#include <sys/taskqueue.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/linker.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_media.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
+#include <net80211/ieee80211_vht.h>
+
+#include <dev/rtwn/if_rtwnreg.h>
+#include <dev/rtwn/if_rtwnvar.h>
+
+#include <dev/rtwn/if_rtwn_ridx.h>
+
+#include <dev/rtwn/rtl8812a/r12a.h>
+#include <dev/rtwn/rtl8812a/r12a_tx_desc.h>
+
+#include <dev/rtwn/rtl8192f/r92f.h>
+
+#define R92F_TXDW1_MACID_M 0x0000007f
+#define R92F_TXDW1_MACID_S 0
+
+void
+r92f_tx_setup_macid(void *buf, int id)
+{
+ struct r12a_tx_desc *txd = buf;
+
+ txd->txdw1 &= htole32(~R92F_TXDW1_MACID_M);
+ txd->txdw1 |= htole32(SM(R92F_TXDW1_MACID, id));
+}
+#define R92F_TXDW5_PATH_A_EN 0x01000000
+#define R92F_TXDW5_PATH_B_EN 0x02000000
+
+void
+r92f_fill_tx_desc(struct rtwn_softc *sc, struct ieee80211_node *ni,
+ struct mbuf *m, void *buf, uint8_t ridx, bool force_rate, int maxretry)
+{
+ struct r12a_tx_desc *txd = buf;
+ struct rtwn_node *un = RTWN_NODE(ni);
+ int macid;
+
+ macid = un->id;
+
+ r12a_fill_tx_desc(sc, ni, m, buf, ridx, force_rate, maxretry);
+
+ /* Vendor does this for some reason */
+ txd->txdw5 |= htole32(R92F_TXDW5_PATH_A_EN
+ | ((sc->ntxchains > 1) ? R92F_TXDW5_PATH_B_EN : 0));
+
+ if (macid == RTWN_MACID_UNDEFINED)
+ macid = 0;
+
+ if (IEEE80211_IS_MULTICAST(mtod(m, struct ieee80211_frame *)->i_addr1))
+ macid = RTWN_MACID_BC;
+
+ txd->flags0 &= ~(R12A_FLAGS0_LSG | R12A_FLAGS0_FSG);
+ txd->txdw1 &= htole32(~R92F_TXDW1_MACID_M);
+ txd->txdw1 |= htole32(SM(R92F_TXDW1_MACID, macid));
+}
+
+void
+r92f_fill_tx_desc_raw(struct rtwn_softc *sc, struct ieee80211_node *ni,
+ struct mbuf *m, void *buf, const struct ieee80211_bpf_params *params)
+{
+ struct r12a_tx_desc *txd;
+
+ txd = (struct r12a_tx_desc *)buf;
+
+ r12a_fill_tx_desc_raw(sc, ni, m, buf, params);
+
+ txd->flags0 &= ~(R12A_FLAGS0_LSG | R12A_FLAGS0_FSG);
+}
+
+void
+r92f_fill_tx_desc_null(struct rtwn_softc *sc, void *buf, int is11b, int qos,
+ int id)
+{
+ struct r12a_tx_desc *txd;
+
+ txd = (struct r12a_tx_desc *)buf;
+
+ r12a_fill_tx_desc_null(sc, buf, is11b, qos, id);
+
+ txd->flags0 &= ~(R12A_FLAGS0_LSG | R12A_FLAGS0_FSG);
+}
diff --git a/sys/dev/rtwn/rtl8192f/r92f_var.h b/sys/dev/rtwn/rtl8192f/r92f_var.h
new file mode 100644
index 000000000000..71c649cf04f4
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/r92f_var.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef R92F_VAR_H
+#define R92F_VAR_H
+
+#include <dev/rtwn/rtl8192c/r92c_var.h>
+#include <dev/rtwn/rtl8192f/r92f_rom_defs.h>
+
+struct r92f_softc {
+ struct r92c_softc super;
+ int8_t cck_tx_pwr[R92F_MAX_RF_PATH][R92E_GROUP_2G];
+ int8_t ht40_tx_pwr_2g[R92F_MAX_RF_PATH][R92E_GROUP_2G];
+ int8_t cck_tx_pwr_diff_2g[R92F_MAX_RF_PATH] [R92E_MAX_TX_COUNT];
+ int8_t ofdm_tx_pwr_diff_2g[R92F_MAX_RF_PATH][R92E_MAX_TX_COUNT];
+ int8_t bw20_tx_pwr_diff_2g[R92F_MAX_RF_PATH][R92E_MAX_TX_COUNT];
+ int8_t bw40_tx_pwr_diff_2g[R92F_MAX_RF_PATH][R92E_MAX_TX_COUNT];
+
+ uint8_t bb_gain[3]; /* efuse 0x1ea/0x1ec/0x1ee */
+ uint8_t regulatory;
+ uint8_t crystalcap;
+ uint8_t rfe;
+ bool cck_new_agc;
+};
+
+#endif /* R92F_VAR_H */
diff --git a/sys/dev/rtwn/rtl8192f/usb/r92fu.h b/sys/dev/rtwn/rtl8192f/usb/r92fu.h
new file mode 100644
index 000000000000..4527a0700408
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/usb/r92fu.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef RTL8192FU_H
+#define RTL8192FU_H
+
+#define R92F_EFUSE_MAP_LEN 512
+
+#include <dev/rtwn/rtl8192f/r92f.h>
+
+/*
+ * Function declarations
+ */
+
+/* r92fu_init.c */
+int r92fu_power_on(struct rtwn_softc *);
+void r92fu_power_off(struct rtwn_softc *);
+int r92fu_set_qmap(struct rtwn_softc *);
+void r92fu_init_rx_agg(struct rtwn_softc *);
+void r92fu_init_tx_agg(struct rtwn_softc *);
+void r92fu_init_ampdu(struct rtwn_softc *);
+void r92fu_post_init(struct rtwn_softc *);
+void r92fu_init_antsel(struct rtwn_softc *);
+
+/* r92fu_tx.c */
+void r92fu_tx_checksum(struct rtwn_tx_desc_common *);
+
+#endif /* RTL8192FU_H */
diff --git a/sys/dev/rtwn/rtl8192f/usb/r92fu_attach.c b/sys/dev/rtwn/rtl8192f/usb/r92fu_attach.c
new file mode 100644
index 000000000000..b1efadea8af7
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/usb/r92fu_attach.c
@@ -0,0 +1,232 @@
+/* $OpenBSD: if_urtwn.c,v 1.16 2011/02/10 17:26:40 jakemsr Exp $ */
+
+/*-
+ * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
+ * Copyright (c) 2014 Kevin Lo <kevlo@FreeBSD.org>
+ * Copyright (c) 2015-2016 Andriy Voskoboinyk <avos@FreeBSD.org>
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/cdefs.h>
+#include "opt_wlan.h"
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/mbuf.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
+#include <sys/taskqueue.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/linker.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_media.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
+
+#include <dev/rtwn/if_rtwnreg.h>
+#include <dev/rtwn/if_rtwnvar.h>
+#include <dev/rtwn/if_rtwn_nop.h>
+
+#include <dev/rtwn/usb/rtwn_usb_var.h>
+
+#include <dev/rtwn/rtl8188e/r88e_rom_image.h> /* for 'macaddr' field */
+#include <dev/rtwn/rtl8188e/usb/r88eu.h>
+
+#include <dev/rtwn/rtl8192c/r92c_reg.h>
+#include <dev/rtwn/rtl8192c/usb/r92cu.h>
+
+#include <dev/rtwn/rtl8192e/r92e.h>
+
+#include <dev/rtwn/rtl8723b/r23b.h>
+
+#include <dev/rtwn/rtl8812a/r12a.h>
+#include <dev/rtwn/rtl8812a/r12a_reg.h>
+#include <dev/rtwn/rtl8812a/usb/r12au.h>
+#include <dev/rtwn/rtl8812a/usb/r12au_tx_desc.h>
+
+#include <dev/rtwn/rtl8188f/r88f.h>
+
+#include <dev/rtwn/rtl8192f/r92f.h>
+#include <dev/rtwn/rtl8192f/r92f_priv.h>
+#include <dev/rtwn/rtl8192f/r92f_var.h>
+#include <dev/rtwn/rtl8192f/usb/r92fu.h>
+
+void r92fu_attach(struct rtwn_usb_softc *);
+
+static void
+r92fu_attach_private(struct rtwn_softc *sc)
+{
+ struct r92f_softc *rs;
+
+ rs = malloc(sizeof(struct r92f_softc), M_RTWN_PRIV, M_WAITOK | M_ZERO);
+
+ rs->super.rs_tx_setup_macid = r92f_tx_setup_macid;
+
+ rs->super.rf_read_delay[0] = 10;
+ rs->super.rf_read_delay[1] = 100;
+ rs->super.rf_read_delay[2] = 10;
+
+ sc->sc_priv = rs;
+}
+
+static void
+r92fu_enable_mac_txrx(struct rtwn_softc *sc)
+{
+ rtwn_setbits_2(sc, R92C_AFE_XTAL_CTRL_EXT, 0, 0x8010);
+ rtwn_setbits_4(sc, R92C_TXDMA_OFFSET_CHK, 0,
+ R92C_TXDMA_OFFSET_DROP_DATA_EN);
+ rtwn_setbits_2(sc, R92C_CR, 0, R92C_CR_MACTXEN | R92C_CR_MACRXEN);
+ rtwn_write_1(sc, R12A_EARLY_MODE_CONTROL, 0);
+}
+
+static void
+r92fu_set_tx_desc_own(struct rtwn_tx_desc_common *txd)
+{
+ /* Noop. */
+}
+
+void
+r92fu_attach(struct rtwn_usb_softc *uc)
+{
+ struct rtwn_softc *sc = &uc->uc_sc;
+
+ /* USB part. */
+ uc->uc_align_rx = r12au_align_rx;
+ uc->uc_set_tx_desc_own = r92fu_set_tx_desc_own;
+ uc->uc_tx_checksum = r92fu_tx_checksum;
+ uc->tx_agg_desc_num = 6;
+
+ /* Common part. */
+ sc->sc_flags = RTWN_FLAG_EXT_HDR;
+
+ sc->sc_set_chan = r92f_set_chan;
+ sc->sc_fill_tx_desc = r92f_fill_tx_desc;
+ sc->sc_fill_tx_desc_raw = r92f_fill_tx_desc_raw;
+ sc->sc_fill_tx_desc_null = r92f_fill_tx_desc_null;
+ sc->sc_dump_tx_desc = r12au_dump_tx_desc;
+ sc->sc_tx_radiotap_flags = r12a_tx_radiotap_flags;
+ sc->sc_rx_radiotap_flags = r12a_rx_radiotap_flags;
+ sc->sc_get_rx_stats = r92f_get_rx_stats;
+ sc->sc_get_rssi_cck = r92f_get_rssi_cck;
+ sc->sc_get_rssi_ofdm = r92f_get_rssi_ofdm;
+ sc->sc_classify_intr = r12au_classify_intr;
+ sc->sc_handle_tx_report = r12a_ratectl_tx_complete;
+ sc->sc_handle_tx_report2 = rtwn_nop_softc_uint8_int;
+ sc->sc_handle_c2h_report = r92e_handle_c2h_report;
+ sc->sc_check_frame = rtwn_nop_int_softc_mbuf;
+ sc->sc_rf_read = r92c_rf_read;
+ sc->sc_rf_write = r88e_rf_write;
+ sc->sc_check_condition = r92c_check_condition;
+ sc->sc_efuse_postread = rtwn_nop_softc;
+ sc->sc_efuse_preread = r88f_efuse_preread;
+ sc->sc_parse_rom = r92f_parse_rom;
+ sc->sc_set_led = r92f_set_led;
+ sc->sc_power_on = r92fu_power_on;
+ sc->sc_power_off = r92fu_power_off;
+#ifndef RTWN_WITHOUT_UCODE
+ sc->sc_fw_reset = r92f_fw_reset;
+ sc->sc_fw_download_enable = r92f_fw_download_enable;
+ sc->sc_fw_write_finish = r92f_fw_write_finish;
+#endif
+ sc->sc_llt_init = r92e_llt_init;
+ sc->sc_enable_mac_txrx = r92fu_enable_mac_txrx;
+ sc->sc_set_page_size = r88f_set_page_size;
+ sc->sc_lc_calib = r92f_lc_calib;
+ sc->sc_iq_calib = r92f_iq_calib;
+ sc->sc_read_chipid_vendor = rtwn_nop_softc_uint32;
+ sc->sc_adj_devcaps = rtwn_nop_softc;
+ sc->sc_vap_preattach = rtwn_nop_softc_vap;
+ sc->sc_postattach = rtwn_nop_softc; /* XXX TODO? */
+ sc->sc_detach_private = r92c_detach_private;
+ sc->sc_set_media_status = r12a_set_media_status;
+#ifndef RTWN_WITHOUT_UCODE
+ sc->sc_set_rsvd_page = r88e_set_rsvd_page;
+ sc->sc_set_pwrmode = r88e_set_pwrmode;
+ sc->sc_set_rssi = rtwn_nop_softc; /* XXX TODO? */
+#endif
+ sc->sc_beacon_init = r92f_beacon_init;
+ sc->sc_beacon_enable = r92c_beacon_enable;
+ sc->sc_sta_beacon_enable = r92c_sta_beacon_enable;
+ sc->sc_beacon_set_rate = rtwn_nop_void_int;
+ sc->sc_beacon_select = rtwn_nop_softc_int;
+ sc->sc_temp_measure = r88e_temp_measure;
+ sc->sc_temp_read = r88e_temp_read;
+ sc->sc_init_tx_agg = r92fu_init_tx_agg;
+ sc->sc_init_rx_agg = r92fu_init_rx_agg;
+ sc->sc_init_beacon_timer = rtwn_nop_softc;
+ sc->sc_init_ampdu = r92fu_init_ampdu;
+ sc->sc_init_intr = rtwn_nop_softc;
+ sc->sc_init_edca = r92c_init_edca;
+ sc->sc_init_bb = r92f_init_bb;
+ sc->sc_init_rf = r92c_init_rf;
+ sc->sc_init_antsel = r92fu_init_antsel;
+ sc->sc_post_init = r92fu_post_init;
+ sc->sc_set_qmap = r92fu_set_qmap;
+ sc->sc_init_bcnq1_boundary = rtwn_nop_int_softc;
+ sc->sc_set_tx_power = r92f_set_tx_power;
+
+ sc->mac_prog = &rtl8192fu_mac[0];
+ sc->mac_size = nitems(rtl8192fu_mac);
+ sc->bb_prog = &rtl8192fu_bb[0];
+ sc->bb_size = nitems(rtl8192fu_bb);
+ sc->agc_prog = &rtl8192fu_agc[0];
+ sc->agc_size = nitems(rtl8192fu_agc);
+ sc->rf_prog = &rtl8192fu_rf[0];
+
+ sc->name = "RTL8192FU";
+ sc->fwname = "rtwn-rtl8192fufw";
+ sc->fwsig = 0x92f;
+ sc->fw_start_addr = R92F_FW_START_ADDR;
+
+ sc->ackto = 0x40;
+ sc->npubqpages = R92F_PUBQ_NPAGES;
+ sc->nhqpages = R92F_HQ_NPAGES;
+ sc->nlqpages = R92F_LQ_NPAGES;
+ sc->nnqpages = R92F_NQ_NPAGES;
+ sc->page_size = R92C_TX_PAGE_SIZE;
+
+ sc->page_count = R92F_TX_PAGE_COUNT;
+ sc->pktbuf_count = R92F_TXPKTBUF_COUNT;
+
+ sc->txdesc_len = sizeof(struct r12au_tx_desc);
+ sc->efuse_maxlen = R92F_EFUSE_MAP_LEN;
+ sc->efuse_maplen = R92F_EFUSE_MAP_LEN;
+ sc->rx_dma_size = R92F_RX_DMA_BUFFER_SIZE;
+
+ sc->macid_limit = R92F_MACID_MAX + 1;
+ sc->macid_rpt2_max_num = 2;
+ sc->cam_entry_limit = R92F_CAM_ENTRY_COUNT;
+ sc->fwsize_limit = R92F_MAX_FW_SIZE;
+ sc->temp_delta = R88E_CALIB_THRESHOLD;
+
+ sc->bcn_status_reg[0] = R92C_TDECTRL;
+ sc->bcn_status_reg[1] = R92C_TDECTRL;
+ sc->rcr = 0;
+
+ sc->sc_ht40 = 1;
+
+ sc->ntxchains = 2;
+ sc->nrxchains = 2;
+
+ r92fu_attach_private(sc);
+}
diff --git a/sys/dev/rtwn/rtl8192f/usb/r92fu_init.c b/sys/dev/rtwn/rtl8192f/usb/r92fu_init.c
new file mode 100644
index 000000000000..6674aa1f95d6
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/usb/r92fu_init.c
@@ -0,0 +1,544 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/cdefs.h>
+#include "opt_wlan.h"
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/mbuf.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
+#include <sys/taskqueue.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/linker.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_media.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+
+#include <dev/rtwn/if_rtwnreg.h>
+#include <dev/rtwn/if_rtwnvar.h>
+#include <dev/rtwn/usb/rtwn_usb_var.h>
+#include <dev/rtwn/if_rtwn_debug.h>
+
+#include <dev/rtwn/rtl8188e/r88e.h>
+#include <dev/rtwn/rtl8188e/r88e_reg.h>
+#include <dev/rtwn/rtl8188e/usb/r88eu.h>
+#include <dev/rtwn/rtl8188e/usb/r88eu_reg.h>
+
+#include <dev/rtwn/rtl8192c/r92c.h>
+#include <dev/rtwn/rtl8192c/r92c_var.h>
+#include <dev/rtwn/rtl8192c/usb/r92cu.h>
+#include <dev/rtwn/rtl8192e/r92e_reg.h>
+
+#include <dev/rtwn/rtl8188f/usb/r88fu.h>
+
+#include <dev/rtwn/rtl8192f/r92f.h>
+#include <dev/rtwn/rtl8192f/usb/r92fu.h>
+#include <dev/rtwn/rtl8192f/r92f_reg.h>
+#include <dev/rtwn/rtl8192f/usb/r92fu_reg.h>
+
+static int
+r92fu_disabled_to_emu(struct rtwn_softc *sc)
+{
+#define RTWN_CHK(res) do { \
+ if (res != 0) \
+ return (EIO); \
+} while(0)
+
+ RTWN_CHK(rtwn_setbits_2(sc, R92C_APS_FSMCO,
+ R92C_APS_FSMCO_APDM_HPDN | R92C_APS_FSMCO_AFSM_HSUS, 0));
+
+ RTWN_CHK(rtwn_bb_setbits(sc, R92C_GPIO_INTM, 0x10000, 0));
+
+ RTWN_CHK(rtwn_setbits_2(sc, R92C_APS_FSMCO,
+ R92C_APS_FSMCO_AFSM_PCIE | R92C_APS_FSMCO_AFSM_HSUS, 0));
+
+ return (0);
+#undef RTWN_CHK
+}
+
+#define R92F_MAX_REG_POLL 500
+
+static int
+r92fu_emu_to_active(struct rtwn_softc *sc)
+{
+#define RTWN_CHK(res) do { \
+ if (res != 0) \
+ return (EIO); \
+} while(0)
+ uint32_t reg;
+ int count;
+
+ /* enable LDOA12 MACRO block for all interface */
+ RTWN_CHK(rtwn_setbits_1(sc, R92C_LDOA15_CTRL, 0, R92C_LDOA15_CTRL_EN));
+
+ /* disable BT_GPS_SEL pins */
+ RTWN_CHK(rtwn_bb_setbits(sc, R88E_BB_PAD_CTRL, 0x10000000, 0));
+
+ rtwn_delay(sc, 1000);
+
+ /* release analog Ips to digital */
+ RTWN_CHK(rtwn_setbits_1(sc, R92C_SYS_ISO_CTRL,
+ R92C_SYS_ISO_CTRL_IP2MAC, 0));
+
+ RTWN_CHK(rtwn_setbits_2(sc, R92C_APS_FSMCO, R92C_APS_FSMCO_AFSM_PCIE |
+ R92C_APS_FSMCO_AFSM_HSUS | R92C_APS_FSMCO_APFM_RSM, 0));
+
+ /* wait till 0x04[17] = 1 power ready */
+ for (count = R92F_MAX_REG_POLL; count; count--) {
+ reg = rtwn_bb_read(sc, R92C_APS_FSMCO);
+ if (reg & 0x20000)
+ break;
+
+ rtwn_delay(sc, 10);
+ }
+
+ /* setting retval to (EBUSY = 16) */
+ if (!count)
+ return (-16);
+
+ RTWN_CHK(rtwn_bb_setbits(sc, R92C_APS_FSMCO, 0,
+ R92C_APS_FSMCO_RDY_MACON));
+
+ for (count = R92F_MAX_REG_POLL; count; count--) {
+ reg = rtwn_bb_read(sc, R92C_APS_FSMCO);
+ if ((reg & (R92C_APS_FSMCO_APFM_ONMAC | R92C_APS_FSMCO_APFM_OFF)) == 0)
+ break;
+
+ rtwn_delay(sc, 10);
+ }
+
+ if (!count)
+ return (-16);
+
+ /* SWR OCP enable */
+ RTWN_CHK(rtwn_bb_setbits(sc, R92C_AFE_MISC, 0, 0x40000));
+
+ RTWN_CHK(rtwn_setbits_2(sc, R92C_APS_FSMCO,
+ R92C_APS_FSMCO_APDM_HPDN, 0));
+
+ RTWN_CHK(rtwn_setbits_2(sc, R92C_APS_FSMCO,
+ R92C_APS_FSMCO_AFSM_PCIE | R92C_APS_FSMCO_AFSM_HSUS, 0));
+
+ /* 0x7c[31]=1, LDO has max output capability */
+ RTWN_CHK(rtwn_bb_setbits(sc, R92C_LDO_SWR_CTRL, 0, 0x80000000));
+
+ RTWN_CHK(rtwn_setbits_2(sc, R92C_APS_FSMCO, 0,
+ R92C_APS_FSMCO_APFM_ONMAC));
+
+ for (count = R92F_MAX_REG_POLL; count; count--) {
+ reg = rtwn_bb_read(sc, R92C_APS_FSMCO);
+ if ((reg & R92C_APS_FSMCO_APFM_ONMAC) == 0)
+ break;
+
+ rtwn_delay(sc, 10);
+ }
+
+ if (!count)
+ return (-16);
+
+ /* Enable WL control XTAL setting */
+ RTWN_CHK(rtwn_setbits_1(sc, R92C_AFE_MISC, 0,
+ R92F_AFE_MISC_WL_XTAL_CTRL));
+
+ /* Enable falling edge triggering interrupt */
+ RTWN_CHK(rtwn_setbits_2(sc, R92C_GPIO_INTM, 0,
+ R92F_GPIO_INTM_EDGE_TRIG_IRQ));
+
+
+ /* Enable GPIO9 data mode */
+ RTWN_CHK(rtwn_setbits_2(sc, R92F_GPIO_IO_SEL_2,
+ R92F_GPIO_IO_SEL_2_GPIO09_IRQ, 0));
+
+ /* Enable GPIO9 input mode */
+ RTWN_CHK(rtwn_setbits_2(sc, R92F_GPIO_IO_SEL_2,
+ R92F_GPIO_IO_SEL_2_GPIO09_INPUT, 0));
+
+ /* Enable HSISR GPIO[C:0] interrupt */
+ RTWN_CHK(rtwn_setbits_1(sc, R92C_HSIMR, 0, 0x01));
+
+
+ /* RF HW ON/OFF Enable */
+ RTWN_CHK(rtwn_setbits_1(sc, R92C_MULTI_FUNC_CTRL,
+ R92F_MULTI_WIFI_HW_ROF_EN, 0));
+
+ /* Register Lock Disable */
+ RTWN_CHK(rtwn_setbits_1(sc, R92C_RSV_CTRL, 0, 0x80));
+
+ /* For GPIO9 internal pull high setting */
+ RTWN_CHK(rtwn_setbits_2(sc, R92C_MULTI_FUNC_CTRL, 0, 0x4000));
+
+ /* reset RF path S1 */
+ RTWN_CHK(rtwn_write_1(sc, R92C_RF_CTRL, 0));
+
+ /* reset RF path S0 */
+ RTWN_CHK(rtwn_write_1(sc, R92C_AFE_XTAL_CTRL_EXT + 3, 0));
+
+ /* enable RF path S1 */
+ RTWN_CHK(rtwn_write_1(sc, R92C_RF_CTRL, R92C_RF_CTRL_SDMRSTB | R92C_RF_CTRL_RSTB | R92C_RF_CTRL_EN));
+
+ /* enable RF path S0 */
+ RTWN_CHK(rtwn_write_1(sc, R92C_AFE_XTAL_CTRL_EXT + 3, R92C_RF_CTRL_SDMRSTB | R92C_RF_CTRL_RSTB | R92C_RF_CTRL_EN));
+
+ /* AFE_Ctrl */
+ RTWN_CHK(rtwn_setbits_1(sc, R92F_RSVD_1, 0, 0x20));
+
+ /* AFE_Ctrl */
+ RTWN_CHK(rtwn_write_1(sc, R92F_RSVD_4, 0xcc));
+
+ /* AFE_Ctrl 0x24[4:3]=00 for xtal gmn */
+ RTWN_CHK(rtwn_setbits_1(sc, R92C_AFE_XTAL_CTRL, 0x18, 0));
+
+ /* GPIO_A[31:0] Pull down software register */
+ RTWN_CHK(rtwn_bb_write(sc, R92F_GPIO_A0, 0xffffffff));
+
+ /* GPIO_B[7:0] Pull down software register */
+ RTWN_CHK(rtwn_write_1(sc, R92F_GPIO_B0, 0xff));
+
+ /* Register Lock Enable */
+ RTWN_CHK(rtwn_setbits_1(sc, R92C_RSV_CTRL, 0x80, 0));
+
+ return (0);
+#undef RTWN_CHK
+}
+
+static int
+r92fu_active_to_emu(struct rtwn_softc *sc)
+{
+#define RTWN_CHK(res) do { \
+ if (res != 0) \
+ return (EIO); \
+} while(0)
+ uint32_t reg;
+ int count;
+
+ /* Reset BB, RF enter Power Down mode */
+ RTWN_CHK(rtwn_setbits_1(sc, R92C_SYS_FUNC_EN,
+ R92C_SYS_FUNC_EN_BBRSTB, 0));
+
+ /* Enable rising edge triggering interrupt */
+ RTWN_CHK(rtwn_setbits_2(sc, R92C_GPIO_INTM, 0x200, 0));
+
+ /* release WLON reset */
+ RTWN_CHK(rtwn_setbits_4(sc, R92C_APS_FSMCO, 0,
+ R92C_APS_FSMCO_RDY_MACON));
+
+ /* turn off MAC by HW state machine */
+ RTWN_CHK(rtwn_setbits_2(sc, R92C_APS_FSMCO, 0, R92C_APS_FSMCO_APFM_OFF));
+
+ for (count = R92F_MAX_REG_POLL; count; count--) {
+ reg = rtwn_bb_read(sc, R92C_APS_FSMCO);
+ if ((reg & R92C_APS_FSMCO_APFM_OFF) == 0)
+ break;
+
+ rtwn_delay(sc, 10);
+ }
+
+ if (!count)
+ return (-16);
+
+ /* analog Ips to digital, 1:isolation */
+ RTWN_CHK(rtwn_setbits_1(sc, R92C_SYS_ISO_CTRL, 0,
+ R92C_SYS_ISO_CTRL_IP2MAC));
+
+ /* disable LDOA12 MACRO block */
+ RTWN_CHK(rtwn_setbits_1(sc, R92C_LDOA15_CTRL, R92C_LDOA15_CTRL_EN, 0));
+
+ return (0);
+#undef RTWN_CHK
+}
+
+static int
+r92fu_active_to_lps(struct rtwn_softc *sc)
+{
+#define RTWN_CHK(res) do { \
+ if (res != 0) \
+ return (EIO); \
+} while(0)
+
+ uint16_t reg16;
+ uint32_t reg;
+ int retry;
+
+ /* Tx Pause */
+ RTWN_CHK(rtwn_write_1(sc, R92C_TXPAUSE, 0xff));
+
+ retry = 100;
+
+ /* Poll 32 bit wide R92C_SCH_TX_CMD for 0 to ensure no TX is pending. */
+ do {
+ reg = rtwn_bb_read(sc, R88E_SCH_TXCMD);
+ if (!reg)
+ break;
+
+ rtwn_delay(sc, 10);
+ } while (retry--);
+
+ if (!retry) {
+ device_printf(sc->sc_dev,
+ "%s: Failed to flush TX queue\n", __func__);
+ return (-16);
+ }
+
+ /* Disable CCK and OFDM, clock gated */
+ RTWN_CHK(rtwn_setbits_1(sc, R92C_SYS_FUNC_EN,
+ R92C_SYS_FUNC_EN_BBRSTB, 0));
+
+ rtwn_delay(sc, 2);
+
+ /* Whole BB is reset */
+ RTWN_CHK(rtwn_setbits_1(sc, R92C_SYS_FUNC_EN,
+ R92C_SYS_FUNC_EN_BB_GLB_RST, 0));
+
+ /* Reset MAC TRX */
+ reg16 = rtwn_read_2(sc, R92C_CR);
+ reg16 &= 0xff00;
+ reg16 |= R92C_CR_HCI_RXDMA_EN | R92C_CR_HCI_TXDMA_EN;
+ reg16 &= ~R92C_CR_ENSEC;
+ RTWN_CHK(rtwn_write_2(sc, R92C_CR, reg16));
+
+ /* Respond TxOK to scheduler */
+ RTWN_CHK(rtwn_setbits_1(sc, R92C_DUAL_TSF_RST, 0,
+ R92C_DUAL_TSF_RST_TXOK));
+
+ return (0);
+
+#undef RTWN_CHK
+}
+
+static int
+r92fu_emu_to_disabled(struct rtwn_softc *sc)
+{
+#define RTWN_CHK(res) do { \
+ if (res != 0) \
+ return (EIO); \
+} while(0)
+ /* SOP option to disable BG/MB */
+ RTWN_CHK(rtwn_write_1(sc, R92C_APS_FSMCO + 3, 0x20));
+
+ /* 0x04[12:11] = 2b'01 enable WL suspend */
+ RTWN_CHK(rtwn_setbits_2(sc, R92C_APS_FSMCO, R92C_APS_FSMCO_AFSM_PCIE,
+ R92C_APS_FSMCO_AFSM_HSUS));
+
+ /* enable GPIO9 as EXT WAKEUP */
+ RTWN_CHK(rtwn_bb_setbits(sc, R92C_GPIO_INTM, 0, 0x10000));
+
+ return (0);
+
+#undef RTWN_CHK
+}
+
+int
+r92fu_power_on(struct rtwn_softc *sc)
+{
+#define RTWN_CHK(res) do { \
+ if (res != 0) \
+ return (EIO); \
+} while(0)
+
+ RTWN_CHK(rtwn_write_1(sc, R92F_USB_ACCESS_TIMEOUT, 0x80));
+
+ RTWN_CHK(r92fu_disabled_to_emu(sc));
+
+ RTWN_CHK(r92fu_emu_to_active(sc));
+
+ RTWN_CHK(rtwn_write_2(sc, R92C_CR, 0));
+
+ RTWN_CHK(rtwn_setbits_2(sc, R92C_CR, 0,
+ R92C_CR_HCI_TXDMA_EN | R92C_CR_HCI_RXDMA_EN |
+ R92C_CR_TXDMA_EN | R92C_CR_RXDMA_EN |
+ R92C_CR_PROTOCOL_EN | R92C_CR_SCHEDULE_EN |
+ R92C_CR_ENSEC | R92C_CR_CALTMR_EN));
+
+ return (0);
+#undef RTWN_CHK
+}
+
+void
+r92fu_power_off(struct rtwn_softc *sc)
+{
+ int error;
+ r88fu_flush_fifo(sc);
+
+ /* Stop Tx Report Timer. 0x4EC[Bit1]=b'0 */
+ error = rtwn_setbits_1(sc, R88E_TX_RPT_CTRL, 0x2, 0);
+ if (error == ENXIO) /* hardware gone */
+ return;
+
+ /* Stop rx */
+ rtwn_write_1(sc, R92C_CR, 0x00);
+
+ r92fu_active_to_lps(sc);
+
+
+#ifndef RTWN_WITHOUT_UCODE
+ /* Reset Firmware if running in RAM */
+ if (rtwn_read_1(sc, R92C_MCUFWDL) & R92C_MCUFWDL_RAM_DL_SEL)
+ r92c_fw_reset(sc, RTWN_FW_RESET_SHUTDOWN);
+#endif
+
+
+ /* Reset MCU */
+ rtwn_setbits_2(sc, R92C_SYS_FUNC_EN, R92C_SYS_FUNC_EN_CPUEN, 0);
+
+ /* Reset MCU ready status */
+ rtwn_write_1(sc, R92C_MCUFWDL, 0x00);
+
+ if (r92fu_active_to_emu(sc) != 0)
+ RTWN_DPRINTF(sc, RTWN_DEBUG_RESET,
+ "%s: failed to enter EMU state\n", __func__);
+ r92fu_emu_to_disabled(sc);
+}
+
+int
+r92fu_set_qmap(struct rtwn_softc *sc)
+{
+ struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc);
+ uint32_t qmap, reg;
+
+ switch (uc->ntx) {
+ case 1:
+ qmap = R92F_USB_TRXDMA_CTRL_QMAP_HQ;
+ break;
+ case 2:
+ qmap = R92F_USB_TRXDMA_CTRL_QMAP_HQ_NQ;
+ break;
+ default:
+ qmap = R92F_USB_TRXDMA_CTRL_QMAP_3EP;
+ break;
+ }
+
+ reg = rtwn_read_4(sc, R92C_TRXDMA_CTRL);
+ reg &= 0x7;
+ reg |= qmap;
+ return (rtwn_write_4(sc, R92C_TRXDMA_CTRL, reg));
+}
+
+void
+r92fu_init_ampdu(struct rtwn_softc *sc)
+{
+ struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc);
+ uint8_t val;
+
+ val = rtwn_read_1(sc, R12A_RXDMA_PRO);
+ val = RW(val, R12A_BURST_SZ,
+ usbd_get_speed(uc->uc_udev) == USB_SPEED_HIGH ?
+ R12A_BURST_SZ_USB2 : R12A_BURST_SZ_USB1);
+ val |= R12A_DMA_MODE | SM(R12A_BURST_CNT, 3);
+ rtwn_write_1(sc, R12A_RXDMA_PRO, val);
+
+ /* Enable single packet AMPDU. */
+ rtwn_setbits_1(sc, R12A_HT_SINGLE_AMPDU, 0,
+ R12A_HT_SINGLE_AMPDU_PKT_ENA);
+
+ rtwn_write_2(sc, R92C_MAX_AGGR_NUM, 0x1f1f);
+ rtwn_write_1(sc, R12A_AMPDU_MAX_TIME, 0x5e);
+ rtwn_write_4(sc, R12A_AMPDU_MAX_LENGTH, UINT32_MAX);
+
+ /*
+ * The vendor driver says this is for
+ * "VHT packet length 11K", but this chip
+ * doesn't support VHT rates...
+ */
+ rtwn_write_1(sc, R92C_RX_PKT_LIMIT, 0x18);
+
+ rtwn_write_1(sc, R92C_PIFS, 0);
+ rtwn_write_1(sc, R92C_FWHW_TXQ_CTRL, R92C_FWHW_TXQ_CTRL_AMPDU_RTY_NEW);
+ rtwn_write_4(sc, R92C_FAST_EDCA_CTRL, 0x03086666);
+
+ rtwn_write_1(sc, R92C_USTIME_TSF, 0x50);
+ rtwn_write_1(sc, R92C_USTIME_EDCA, 0x50);
+
+ /* Do not reset MAC. */
+ rtwn_setbits_1(sc, R92C_RSV_CTRL, 0, 0x60);
+}
+
+void
+r92fu_init_tx_agg(struct rtwn_softc *sc)
+{
+ uint8_t usb_tx_agg_desc_num = 6;
+
+ /* TX aggregation */
+ rtwn_setbits_4(sc, R92C_TDECTRL, 0xf << 4, usb_tx_agg_desc_num << 4);
+ rtwn_write_1(sc, R92E_DWBCN1_CTRL, usb_tx_agg_desc_num << 1);
+}
+
+void
+r92fu_init_rx_agg(struct rtwn_softc *sc)
+{
+ uint32_t agg_rx;
+ uint8_t agg_ctrl;
+
+ /* RX aggregation */
+ agg_ctrl = rtwn_read_1(sc, R92C_TRXDMA_CTRL);
+ agg_ctrl &= ~R92C_TRXDMA_CTRL_RXDMA_AGG_EN;
+
+ agg_rx = rtwn_read_4(sc, R92C_RXDMA_AGG_PG_TH);
+ agg_rx &= ~R92F_RXDMA_USB_AGG_EN;
+ agg_rx &= ~0xff0f; /* reset agg size and timeout */
+
+ rtwn_write_1(sc, R92C_TRXDMA_CTRL, agg_ctrl);
+ rtwn_write_4(sc, R92C_RXDMA_AGG_PG_TH, agg_rx);
+}
+
+void
+r92fu_init_antsel(struct rtwn_softc *sc)
+{
+ rtwn_setbits_1(sc, R92C_LEDCFG2, 0, 0x80);
+}
+
+void
+r92fu_post_init(struct rtwn_softc *sc)
+{
+ uint8_t reg8;
+
+ rtwn_setbits_1(sc, R88E_TX_RPT_CTRL, 0, R88E_TX_RPT2_ENA);
+ /* Set MAX RPT MACID */
+ rtwn_write_1(sc, R88E_TX_RPT_CTRL + 1, R88E_TX_RPT2_ENA);
+ /* TX report Timer. Unit: 32us */
+ rtwn_write_2(sc, R88E_TX_RPT_TIME, 0xcdf0);
+ /* tmp ps ? */
+ reg8 = rtwn_read_1(sc, 0xa3);
+ reg8 &= 0xf8;
+ rtwn_write_1(sc, 0xa3, reg8);
+
+ rtwn_write_1(sc, R12A_EARLY_MODE_CONTROL, 0);
+
+ /* RFSW control: TRSW/TRSWB/ANTSW/ANTSWB/PAPE */
+ rtwn_write_4(sc, R92C_FPGA0_RFIFACESW(0), 0x7000760);
+
+ /* Perform LC calibration. */
+ r92f_lc_calib(sc);
+ /* Perform LO and IQ calibrations. */
+ r92f_iq_calib(sc);
+
+ /*
+ * This should enable thermal meter
+ */
+ rtwn_rf_setbits(sc, 0, R88E_RF_T_METER, 0, 0x37cf8);
+
+ rtwn_write_1(sc, R92C_USB_HRPWM, 0);
+
+ if (sc->sc_ratectl_sysctl == RTWN_RATECTL_FW) {
+ /* No support (yet?) for f/w rate adaptation. */
+ sc->sc_ratectl = RTWN_RATECTL_NET80211;
+ } else
+ sc->sc_ratectl = sc->sc_ratectl_sysctl;
+
+}
diff --git a/sys/dev/rtwn/rtl8192f/usb/r92fu_reg.h b/sys/dev/rtwn/rtl8192f/usb/r92fu_reg.h
new file mode 100644
index 000000000000..9290f667a75e
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/usb/r92fu_reg.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef R92FU_REG_H
+#define R92FU_REG_H
+
+#define R92F_USB_TRXDMA_CTRL_QMAP_HQ 0x1b6db0
+#define R92F_USB_TRXDMA_CTRL_QMAP_HQ_NQ 0x1b49b0
+#define R92F_USB_TRXDMA_CTRL_QMAP_3EP 0x1b2530
+#define R92F_RXDMA_USB_AGG_EN 0x80000000
+#define R92F_USB_ACCESS_TIMEOUT 0xfe4c
+
+#endif // !R92FU_REG_H
diff --git a/sys/dev/rtwn/rtl8192f/usb/r92fu_tx.c b/sys/dev/rtwn/rtl8192f/usb/r92fu_tx.c
new file mode 100644
index 000000000000..882a80a9cc80
--- /dev/null
+++ b/sys/dev/rtwn/rtl8192f/usb/r92fu_tx.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2026 Mir Saheb Ali <mirsahebali@pm.me>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/cdefs.h>
+#include "opt_wlan.h"
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/mbuf.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
+#include <sys/taskqueue.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/linker.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_media.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+
+#include <dev/rtwn/if_rtwnvar.h>
+#include <dev/rtwn/if_rtwn_debug.h>
+
+#include <dev/rtwn/if_rtwnreg.h>
+
+#include <dev/rtwn/usb/rtwn_usb_tx.h>
+#include <dev/rtwn/usb/rtwn_usb_reg.h>
+
+#include <dev/rtwn/rtl8192f/usb/r92fu.h>
+
+void
+r92fu_tx_checksum(struct rtwn_tx_desc_common *txd)
+{
+ txd->txdw7.usb_checksum = 0;
+ txd->txdw7.usb_checksum = rtwn_usb_calc_tx_checksum(txd);
+ /*
+ * Avoids zero checksum make tx hang
+ */
+ txd->txdw7.usb_checksum = ~(txd->txdw7.usb_checksum);
+}
diff --git a/sys/dev/rtwn/usb/rtwn_usb_attach.h b/sys/dev/rtwn/usb/rtwn_usb_attach.h
index 89445c54dc36..f0b22b5c3dd9 100644
--- a/sys/dev/rtwn/usb/rtwn_usb_attach.h
+++ b/sys/dev/rtwn/usb/rtwn_usb_attach.h
@@ -20,6 +20,7 @@
void r92cu_attach(struct rtwn_usb_softc *);
void r92eu_attach(struct rtwn_usb_softc *);
+void r92fu_attach(struct rtwn_usb_softc *);
void r88eu_attach(struct rtwn_usb_softc *);
void r88fu_attach(struct rtwn_usb_softc *);
void r23bu_attach(struct rtwn_usb_softc *);
@@ -29,6 +30,7 @@ void r21au_attach(struct rtwn_usb_softc *);
enum {
RTWN_CHIP_RTL8192CU,
RTWN_CHIP_RTL8192EU,
+ RTWN_CHIP_RTL8192FU,
RTWN_CHIP_RTL8188EU,
RTWN_CHIP_RTL8188FU,
RTWN_CHIP_RTL8723BU,
@@ -118,6 +120,14 @@ static const STRUCT_USB_HOST_ID rtwn_devs[] = {
RTWN_RTL8192EU_DEV(TPLINK, WN823NV2),
#undef RTWN_RTL8192EU_DEV
+ /* RTL8192FU */
+#define RTWN_RTL8192FU_DEV(v,p) \
+ { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, \
+ RTWN_USB_DEVINFO(RTWN_CHIP_RTL8192FU, 0)) }
+ RTWN_RTL8192FU_DEV(DLINK, RTL8192FU),
+ RTWN_RTL8192FU_DEV(REALTEK, RTL8192FU),
+#undef RTWN_RTL8192FU_DEV
+
/* RTL8188EU */
#define RTWN_RTL8188EU_DEV(v,p) \
{ USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, \
@@ -204,6 +214,7 @@ typedef void (*chip_usb_attach)(struct rtwn_usb_softc *);
static const chip_usb_attach rtwn_chip_usb_attach[RTWN_CHIP_MAX_USB] = {
[RTWN_CHIP_RTL8192CU] = r92cu_attach,
[RTWN_CHIP_RTL8192EU] = r92eu_attach,
+ [RTWN_CHIP_RTL8192FU] = r92fu_attach,
[RTWN_CHIP_RTL8188EU] = r88eu_attach,
[RTWN_CHIP_RTL8188FU] = r88fu_attach,
[RTWN_CHIP_RTL8723BU] = r23bu_attach,
diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs
index 3caa18826f39..d344f4986d27 100644
--- a/sys/dev/usb/usbdevs
+++ b/sys/dev/usb/usbdevs
@@ -1788,6 +1788,7 @@ product DLINK RTL8192CU_1 0x3307 RTL8192CU
product DLINK RTL8188CU 0x3308 RTL8188CU
product DLINK RTL8192CU_2 0x3309 RTL8192CU
product DLINK RTL8192CU_3 0x330a RTL8192CU
+product DLINK RTL8192FU 0x3328 RTL8192FU
product DLINK DWA131B 0x330d DWA-131 rev B
product DLINK DWA125D1 0x330f DWA-125 rev D1
product DLINK DWA123D1 0x3310 DWA-123 rev D1
@@ -4169,6 +4170,8 @@ product REALTEK RTL8187 0x8187 RTL8187 Wireless Adapter
product REALTEK RTL8187B_0 0x8189 RTL8187B Wireless Adapter
product REALTEK RTL8188CUS 0x818a RTL8188CUS
product REALTEK RTL8192EU 0x818b RTL8192EU
+product REALTEK RTL8192FU 0xf192 RTL8192FU
+product REALTEK RTL8192FU_2 0x318b RTL8192FU
product REALTEK RTL8188CU_3 0x8191 RTL8188CU
product REALTEK RTL8196EU 0x8196 RTL8196EU
product REALTEK RTL8187B_1 0x8197 RTL8187B Wireless Adapter