realtekwifi: Sync with FreeBSD trunk.

This includes changes to support the 8188EE device, as well as a
number of critical bugfixes to 8192EE devices, which should make
the driver much more stable and reliable overall.
This commit is contained in:
Augustin Cavalier 2019-01-10 21:06:35 -05:00
parent 478b2a6ab0
commit a8bfcf3228
174 changed files with 2045 additions and 443 deletions

View File

@ -15,6 +15,8 @@ UseHeaders [ FDirName $(SUBDIR) ] : true ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) dev rtwn ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) dev rtwn pci ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) dev rtwn rtl8188e ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) dev rtwn rtl8188e pci ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) dev rtwn rtl8192c ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) dev rtwn rtl8192c pci ] ;
@ -37,6 +39,23 @@ KernelAddon realtekwifi :
rtwn_pci_rx.c
rtwn_pci_tx.c
# rtl8188e/
r88e_beacon.c
r88e_calib.c
r88e_chan.c
r88e_fw.c
r88e_init.c
r88e_led.c
r88e_rf.c
r88e_rom.c
r88e_rx.c
r88e_tx.c
# rtl8188e/pci/
r88ee_attach.c
r88ee_init.c
r88ee_rx.c
# rtl8192c/
r92c_attach.c
r92c_beacon.c

View File

@ -19,11 +19,12 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn.c 327479 2018-01-02 00:07:28Z adrian $");
__FBSDID("$FreeBSD$");
/*
* Driver for Realtek RTL8188CE-VAU/RTL8188CUS/RTL8188EU/RTL8188RU/RTL8192CU/RTL8812AU/RTL8821AU.
*/
#include "opt_wlan.h"
#include <sys/param.h>
#include <sys/sockio.h>

View File

@ -17,7 +17,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_beacon.c 310867 2016-12-30 22:24:01Z avos $");
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/lock.h>

View File

@ -13,7 +13,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_beacon.h 310867 2016-12-30 22:24:01Z avos $
* $FreeBSD$
*/
#ifndef IF_RTWN_BEACON_H

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_calib.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -13,7 +13,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_calib.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef IF_RTWN_CALIB_H

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_cam.c 309686 2016-12-07 22:16:07Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -13,7 +13,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_cam.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef IF_RTWN_CAM_H

View File

@ -17,12 +17,14 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_debug.h 310867 2016-12-30 22:24:01Z avos $
* $FreeBSD$
*/
#ifndef IF_RTWN_DEBUG_H
#define IF_RTWN_DEBUG_H
#include "opt_rtwn.h"
#ifdef RTWN_DEBUG
enum {
RTWN_DEBUG_XMIT = 0x00000001, /* basic xmit operation */

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_efuse.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -13,7 +13,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_efuse.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef IF_RTWN_EFUSE_H

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_fw.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_fw.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef IF_RTWN_FW_H

View File

@ -13,7 +13,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_nop.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef IF_RTWN_NOP_H

View File

@ -17,7 +17,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_ridx.h 331043 2018-03-16 01:03:10Z avos $
* $FreeBSD$
*/
#ifndef IF_RTWN_RIDX_H

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_rx.c 333813 2018-05-18 20:13:34Z mmacy $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -13,7 +13,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_rx.h 312315 2017-01-17 00:35:23Z avos $
* $FreeBSD$
*/
#ifndef IF_RTWN_RX_H

View File

@ -15,7 +15,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_task.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -13,7 +13,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_task.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef IF_RTWN_TASK_H

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_tx.c 314315 2017-02-26 20:49:35Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -13,7 +13,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwn_tx.h 308575 2016-11-12 17:58:37Z avos $
* $FreeBSD$
*/
#ifndef IF_RTWN_TX_H

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwnreg.h 321735 2017-07-30 23:35:21Z avos $
* $FreeBSD$
*/
#ifndef IF_RTWNREG_H

View File

@ -15,12 +15,14 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/if_rtwnvar.h 320640 2017-07-04 07:07:08Z avos $
* $FreeBSD$
*/
#ifndef IF_RTWNVAR_H
#define IF_RTWNVAR_H
#include "opt_rtwn.h"
#define RTWN_TX_DESC_SIZE 64
#define RTWN_BCN_MAX_SIZE 512

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/pci/rtwn_pci_attach.c 320725 2017-07-06 07:37:33Z avos $");
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/sysctl.h>

View File

@ -13,13 +13,15 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/pci/rtwn_pci_attach.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
void r92ce_attach(struct rtwn_pci_softc *);
void r88ee_attach(struct rtwn_pci_softc *);
enum {
RTWN_CHIP_RTL8192CE,
RTWN_CHIP_RTL8188EE,
RTWN_CHIP_MAX_PCI
};
@ -32,13 +34,15 @@ struct rtwn_pci_ident {
static const struct rtwn_pci_ident rtwn_pci_ident_table[] = {
{ 0x10ec, 0x8176, "Realtek RTL8188CE", RTWN_CHIP_RTL8192CE },
{ 0x10ec, 0x8179, "Realtek RTL8188EE", RTWN_CHIP_RTL8188EE },
{ 0, 0, NULL, RTWN_CHIP_MAX_PCI }
};
typedef void (*chip_pci_attach)(struct rtwn_pci_softc *);
static const chip_pci_attach rtwn_chip_pci_attach[RTWN_CHIP_MAX_PCI] = {
[RTWN_CHIP_RTL8192CE] = r92ce_attach
[RTWN_CHIP_RTL8192CE] = r92ce_attach,
[RTWN_CHIP_RTL8188EE] = r88ee_attach
};
static __inline void

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/pci/rtwn_pci_reg.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/lock.h>

View File

@ -13,7 +13,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/pci/rtwn_pci_reg.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef RTWN_PCI_REG_H

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/pci/rtwn_pci_rx.c 320725 2017-07-06 07:37:33Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -83,12 +83,12 @@ rtwn_pci_setup_rx_desc(struct rtwn_pci_softc *pc,
}
static void
rtwn_pci_rx_frame(struct rtwn_softc *sc, struct rtwn_rx_stat_pci *rx_desc,
int desc_idx)
rtwn_pci_rx_frame(struct rtwn_pci_softc *pc)
{
struct rtwn_pci_softc *pc = RTWN_PCI_SOFTC(sc);
struct rtwn_softc *sc = &pc->pc_sc;
struct rtwn_rx_ring *ring = &pc->rx_ring;
struct rtwn_rx_data *rx_data = &ring->rx_data[desc_idx];
struct rtwn_rx_stat_pci *rx_desc = &ring->desc[ring->cur];
struct rtwn_rx_data *rx_data = &ring->rx_data[ring->cur];
struct ieee80211com *ic = &sc->sc_ic;
struct ieee80211_node *ni;
uint32_t rxdw0;
@ -148,9 +148,6 @@ rtwn_pci_rx_frame(struct rtwn_softc *sc, struct rtwn_rx_stat_pci *rx_desc,
panic("%s: could not load old RX mbuf",
device_get_name(sc->sc_dev));
/* Physical address may have changed. */
rtwn_pci_setup_rx_desc(pc, rx_desc, rx_data->paddr,
MJUMPAGESIZE, desc_idx);
goto fail;
}
@ -165,10 +162,6 @@ rtwn_pci_rx_frame(struct rtwn_softc *sc, struct rtwn_rx_stat_pci *rx_desc,
"%s: Rx frame len %d, infosz %d, shift %d\n",
__func__, pktlen, infosz, shift);
/* Update RX descriptor. */
rtwn_pci_setup_rx_desc(pc, rx_desc, rx_data->paddr, MJUMPAGESIZE,
desc_idx);
/* Send the frame to the 802.11 layer. */
RTWN_UNLOCK(sc);
if (ni != NULL) {
@ -186,6 +179,72 @@ fail:
counter_u64_add(ic->ic_ierrors, 1);
}
static int
rtwn_pci_rx_buf_copy(struct rtwn_pci_softc *pc)
{
struct rtwn_rx_ring *ring = &pc->rx_ring;
struct rtwn_rx_stat_pci *rx_desc = &ring->desc[ring->cur];
struct rtwn_rx_data *rx_data = &ring->rx_data[ring->cur];
uint32_t rxdw0;
int desc_size, pktlen;
/*
* NB: tx_report() / c2h_report() expects to see USB Rx
* descriptor - same as for PCIe, but without rxbufaddr* fields.
*/
desc_size = sizeof(struct rtwn_rx_stat_common);
KASSERT(sizeof(pc->pc_rx_buf) >= desc_size,
("adjust size for PCIe Rx buffer!"));
memcpy(pc->pc_rx_buf, rx_desc, desc_size);
rxdw0 = le32toh(rx_desc->rxdw0);
pktlen = MS(rxdw0, RTWN_RXDW0_PKTLEN);
if (pktlen > sizeof(pc->pc_rx_buf) - desc_size)
{
/* Looks like an ordinary Rx frame. */
return (desc_size);
}
bus_dmamap_sync(ring->data_dmat, rx_data->map, BUS_DMASYNC_POSTREAD);
memcpy(pc->pc_rx_buf + desc_size, mtod(rx_data->m, void *), pktlen);
return (desc_size + pktlen);
}
static void
rtwn_pci_tx_report(struct rtwn_pci_softc *pc, int len)
{
struct rtwn_softc *sc = &pc->pc_sc;
if (sc->sc_ratectl != RTWN_RATECTL_NET80211) {
/* shouldn't happen */
device_printf(sc->sc_dev,
"%s called while ratectl = %d!\n",
__func__, sc->sc_ratectl);
return;
}
RTWN_NT_LOCK(sc);
rtwn_handle_tx_report(sc, pc->pc_rx_buf, len);
RTWN_NT_UNLOCK(sc);
#ifdef IEEE80211_SUPPORT_SUPERG
/*
* NB: this will executed only when 'report' bit is set.
*/
if (sc->sc_tx_n_active > 0 && --sc->sc_tx_n_active <= 1)
rtwn_cmd_sleepable(sc, NULL, 0, rtwn_ff_flush_all);
#endif
}
static void
rtwn_pci_c2h_report(struct rtwn_pci_softc *pc, int len)
{
rtwn_handle_c2h_report(&pc->pc_sc, pc->pc_rx_buf, len);
}
static void
rtwn_pci_tx_done(struct rtwn_softc *sc, int qid)
{
@ -197,7 +256,8 @@ rtwn_pci_tx_done(struct rtwn_softc *sc, int qid)
RTWN_DPRINTF(sc, RTWN_DEBUG_INTR, "%s: qid %d, last %d, cur %d\n",
__func__, qid, ring->last, ring->cur);
bus_dmamap_sync(ring->desc_dmat, ring->desc_map, BUS_DMASYNC_POSTREAD);
bus_dmamap_sync(ring->desc_dmat, ring->desc_map,
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
while(ring->last != ring->cur) {
data = &ring->tx_data[ring->last];
@ -262,21 +322,50 @@ rtwn_pci_rx_done(struct rtwn_softc *sc)
{
struct rtwn_pci_softc *pc = RTWN_PCI_SOFTC(sc);
struct rtwn_rx_ring *ring = &pc->rx_ring;
struct rtwn_rx_stat_pci *rx_desc;
struct rtwn_rx_data *rx_data;
int len;
bus_dmamap_sync(ring->desc_dmat, ring->desc_map, BUS_DMASYNC_POSTREAD);
for (;;) {
struct rtwn_rx_stat_pci *rx_desc = &ring->desc[ring->cur];
rx_desc = &ring->desc[ring->cur];
rx_data = &ring->rx_data[ring->cur];
if (le32toh(rx_desc->rxdw0) & RTWN_RXDW0_OWN)
break;
rtwn_pci_rx_frame(sc, rx_desc, ring->cur);
len = rtwn_pci_rx_buf_copy(pc);
switch (rtwn_classify_intr(sc, pc->pc_rx_buf, len)) {
case RTWN_RX_DATA:
rtwn_pci_rx_frame(pc);
break;
case RTWN_RX_TX_REPORT:
rtwn_pci_tx_report(pc, len);
break;
case RTWN_RX_OTHER:
rtwn_pci_c2h_report(pc, len);
break;
default:
/* NOTREACHED */
KASSERT(0, ("unknown Rx classification code"));
break;
}
/* Update / reset RX descriptor (and set OWN bit). */
rtwn_pci_setup_rx_desc(pc, rx_desc, rx_data->paddr,
MJUMPAGESIZE, ring->cur);
if (!(sc->sc_flags & RTWN_RUNNING))
return;
ring->cur = (ring->cur + 1) % RTWN_PCI_RX_LIST_COUNT;
/* NB: device can reuse current descriptor. */
bus_dmamap_sync(ring->desc_dmat, ring->desc_map,
BUS_DMASYNC_POSTREAD);
if (le32toh(rx_desc->rxdw0) & RTWN_RXDW0_OWN)
ring->cur = (ring->cur + 1) % RTWN_PCI_RX_LIST_COUNT;
}
}
@ -289,7 +378,7 @@ rtwn_pci_intr(void *arg)
RTWN_LOCK(sc);
#ifndef __HAIKU__
status = rtwn_classify_intr(sc, &tx_rings, 0);
status = rtwn_pci_get_intr_status(pc, &tx_rings);
RTWN_DPRINTF(sc, RTWN_DEBUG_INTR, "%s: status %08X, tx_rings %08X\n",
__func__, status, tx_rings);
if (status == 0 && tx_rings == 0)
@ -299,7 +388,7 @@ rtwn_pci_intr(void *arg)
tx_rings = atomic_get(&pc->pc_intr_tx_rings);
#endif
if (status & RTWN_PCI_INTR_RX) {
if (status & (RTWN_PCI_INTR_RX | RTWN_PCI_INTR_TX_REPORT)) {
rtwn_pci_rx_done(sc);
if (!(sc->sc_flags & RTWN_RUNNING))
goto unlock;

View File

@ -13,7 +13,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/pci/rtwn_pci_rx.h 320725 2017-07-06 07:37:33Z avos $
* $FreeBSD$
*/
#ifndef RTWN_PCI_RX_H

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/pci/rtwn_pci_tx.c 308575 2016-11-12 17:58:37Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -174,8 +174,8 @@ rtwn_pci_tx_start_frame(struct rtwn_softc *sc, struct ieee80211_node *ni,
rtwn_dump_tx_desc(sc, txd);
bus_dmamap_sync(ring->desc_dmat, ring->desc_map,
BUS_DMASYNC_POSTWRITE);
bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_POSTWRITE);
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE);
data->m = m;
data->ni = ni;

View File

@ -13,7 +13,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/pci/rtwn_pci_tx.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef RTWN_PCI_TX_H

View File

@ -17,7 +17,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/pci/rtwn_pci_var.h 320725 2017-07-06 07:37:33Z avos $
* $FreeBSD$
*/
#ifndef RTWN_PCI_VAR_H
@ -26,6 +26,9 @@
#define RTWN_PCI_RX_LIST_COUNT 256
#define RTWN_PCI_TX_LIST_COUNT 256
/* sizeof(struct rtwn_rx_stat_common) + R88E_INTR_MSG_LEN */
#define RTWN_PCI_RX_TMP_BUF_SIZE 84
struct rtwn_rx_data {
bus_dmamap_t map;
struct mbuf *m;
@ -95,8 +98,8 @@ enum {
/* Shortcuts */
/* Vendor driver treats RX errors like ROK... */
#define RTWN_PCI_INTR_RX \
(RTWN_PCI_INTR_RX_OVERFLOW | RTWN_PCI_INTR_RX_DESC_UNAVAIL | \
RTWN_PCI_INTR_RX_DONE)
(RTWN_PCI_INTR_RX_ERROR | RTWN_PCI_INTR_RX_OVERFLOW | \
RTWN_PCI_INTR_RX_DESC_UNAVAIL | RTWN_PCI_INTR_RX_DONE)
struct rtwn_pci_softc {
@ -109,6 +112,7 @@ struct rtwn_pci_softc {
void *pc_ih;
bus_size_t pc_mapsize;
uint8_t pc_rx_buf[RTWN_PCI_RX_TMP_BUF_SIZE];
struct rtwn_rx_ring rx_ring;
struct rtwn_tx_ring tx_ring[RTWN_PCI_NTXQUEUES];
@ -122,6 +126,8 @@ struct rtwn_pci_softc {
void *, bus_dma_segment_t *);
void (*pc_copy_tx_desc)(void *, const void *);
void (*pc_enable_intr)(struct rtwn_pci_softc *);
int (*pc_get_intr_status)(struct rtwn_pci_softc *,
int *);
#ifdef __HAIKU__
int32 pc_intr_status;
@ -138,5 +144,7 @@ struct rtwn_pci_softc {
(((_pc)->pc_copy_tx_desc)((_dest), (_src)))
#define rtwn_pci_enable_intr(_pc) \
(((_pc)->pc_enable_intr)((_pc)))
#define rtwn_pci_get_intr_status(_pc, _tx_rings) \
(((_pc)->pc_get_intr_status)((_pc), (_tx_rings)))
#endif /* RTWN_PCI_VAR_H */

View File

@ -0,0 +1,53 @@
/*-
* Copyright (c) 2018 Farhan Khan <khanzf@gmail.com>
*
* 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.
*
* $FreeBSD$
*/
#ifndef RTL8188EE_H
#define RTL8188EE_H
#include <dev/rtwn/rtl8188e/r88e.h>
/*
* Global definitions.
*/
#define R88EE_PUBQ_NPAGES 115
#define R88EE_HPQ_NPAGES 41
#define R88EE_NPQ_NPAGES 1
#define R88EE_LPQ_NPAGES 13
#define R88EE_TX_PAGE_COUNT \
(R88EE_PUBQ_NPAGES + R88EE_HPQ_NPAGES + \
R88EE_NPQ_NPAGES + R88EE_LPQ_NPAGES)
/*
* Function declarations.
*/
/* r88ee_init.c */
void r88ee_init_bb(struct rtwn_softc *);
void r88ee_init_intr(struct rtwn_softc *);
int r88ee_power_on(struct rtwn_softc *);
void r88ee_power_off(struct rtwn_softc *);
/* r88ee_rx.c */
int r88ee_get_intr_status(struct rtwn_pci_softc *, int *);
void r88ee_enable_intr(struct rtwn_pci_softc *);
void r88ee_start_xfers(struct rtwn_softc *);
void r88ee_post_init(struct rtwn_softc *);
#endif /* RTL8188EE_H */

View File

@ -0,0 +1,242 @@
/*-
* Copyright (c) 2018 Farhan Khan <khanzf@gmail.com>
*
* 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>
__FBSDID("$FreeBSD$");
#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 <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.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/pci/rtwn_pci_var.h>
#include <dev/rtwn/rtl8192c/r92c_var.h>
#include <dev/rtwn/rtl8188e/r88e_priv.h>
#include <dev/rtwn/rtl8188e/r88e_rom_image.h> /* for 'macaddr' field */
#include <dev/rtwn/rtl8192c/pci/r92ce.h>
#include <dev/rtwn/rtl8192c/pci/r92ce_tx_desc.h>
#include <dev/rtwn/rtl8188e/pci/r88ee.h>
#include <dev/rtwn/rtl8188e/pci/r88ee_reg.h>
static struct rtwn_r88e_txpwr r88ee_txpwr;
void r88ee_attach(struct rtwn_pci_softc *);
static void
r88ee_set_macaddr(struct rtwn_softc *sc, uint8_t *buf)
{
struct r88e_rom *rom = (struct r88e_rom *)buf;
IEEE80211_ADDR_COPY(sc->sc_ic.ic_macaddr, rom->diff_d0.pci.macaddr);
}
static void
r88ee_postattach(struct rtwn_softc *sc)
{
struct r92c_softc *rs = sc->sc_priv;
struct ieee80211com *ic = &sc->sc_ic;
rs->rs_scan_start = ic->ic_scan_start;
ic->ic_scan_start = r92c_scan_start;
rs->rs_scan_end = ic->ic_scan_end;
ic->ic_scan_end = r92c_scan_end;
}
static void
r88ee_attach_private(struct rtwn_softc *sc)
{
struct r92c_softc *rs;
rs = malloc(sizeof(struct r92c_softc), M_RTWN_PRIV, M_WAITOK | M_ZERO);
rs->rs_txpwr = &r88ee_txpwr;
rs->rs_set_bw20 = r88e_set_bw20;
rs->rs_get_txpower = r88e_get_txpower;
rs->rs_set_gain = r88e_set_gain;
rs->rs_tx_enable_ampdu = r88e_tx_enable_ampdu;
rs->rs_tx_setup_hwseq = r88e_tx_setup_hwseq;
rs->rs_tx_setup_macid = r88e_tx_setup_macid;
rs->rs_set_rom_opts = r88ee_set_macaddr;
rs->rf_read_delay[0] = 1000;
rs->rf_read_delay[1] = 1000;
rs->rf_read_delay[2] = 1000;
sc->sc_priv = rs;
}
static void
r88ee_adj_devcaps(struct rtwn_softc *sc)
{
/* XXX TODO */
}
void
r88ee_attach(struct rtwn_pci_softc *pc)
{
struct rtwn_softc *sc = &pc->pc_sc;
/* PCIe part. */
pc->pc_setup_tx_desc = r92ce_setup_tx_desc;
pc->pc_tx_postsetup = r92ce_tx_postsetup;
pc->pc_copy_tx_desc = r92ce_copy_tx_desc;
pc->pc_enable_intr = r88ee_enable_intr;
pc->pc_get_intr_status = r88ee_get_intr_status;
pc->pc_qmap = 0xe771;
pc->tcr = 0x8200;
/* Common part. */
sc->sc_flags = RTWN_FLAG_EXT_HDR;
sc->sc_start_xfers = r88ee_start_xfers;
sc->sc_set_chan = r92c_set_chan;
sc->sc_fill_tx_desc = r92c_fill_tx_desc;
sc->sc_fill_tx_desc_raw = r92c_fill_tx_desc_raw;
sc->sc_fill_tx_desc_null = r92c_fill_tx_desc_null; /* XXX recheck */
sc->sc_dump_tx_desc = r92ce_dump_tx_desc;
sc->sc_tx_radiotap_flags = r92c_tx_radiotap_flags;
sc->sc_rx_radiotap_flags = r92c_rx_radiotap_flags;
sc->sc_get_rx_stats = r88e_get_rx_stats;
sc->sc_get_rssi_cck = r88e_get_rssi_cck;
sc->sc_get_rssi_ofdm = r88e_get_rssi_ofdm;
sc->sc_classify_intr = r88e_classify_intr;
sc->sc_handle_tx_report = r88e_ratectl_tx_complete;
sc->sc_handle_c2h_report = r88e_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_parse_rom = r88e_parse_rom;
sc->sc_set_led = r88e_set_led;
sc->sc_power_on = r88ee_power_on;
sc->sc_power_off = r88ee_power_off;
#ifndef RTWN_WITHOUT_UCODE
sc->sc_fw_reset = r88e_fw_reset;
sc->sc_fw_download_enable = r88e_fw_download_enable;
#endif
sc->sc_llt_init = r92c_llt_init;
sc->sc_set_page_size = r92c_set_page_size;
sc->sc_lc_calib = r92c_lc_calib;
sc->sc_iq_calib = r88e_iq_calib;
sc->sc_read_chipid_vendor = rtwn_nop_softc_uint32;
sc->sc_adj_devcaps = r88ee_adj_devcaps;
sc->sc_vap_preattach = rtwn_nop_softc_vap;
sc->sc_postattach = r88ee_postattach;
sc->sc_detach_private = r92c_detach_private;
sc->sc_set_media_status = r88e_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 = r92c_set_rssi;
#endif
sc->sc_beacon_init = r92c_beacon_init;
sc->sc_beacon_enable = r88e_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 = rtwn_nop_softc;
sc->sc_init_rx_agg = rtwn_nop_softc;
sc->sc_init_ampdu = r92ce_init_ampdu;
sc->sc_init_intr = r88ee_init_intr;
sc->sc_init_edca = r92ce_init_edca;
sc->sc_init_bb = r88ee_init_bb;
sc->sc_init_rf = r92c_init_rf;
sc->sc_init_antsel = rtwn_nop_softc;
sc->sc_post_init = r88ee_post_init;
sc->sc_init_bcnq1_boundary = rtwn_nop_int_softc;
sc->mac_prog = &rtl8188e_mac[0];
sc->mac_size = nitems(rtl8188e_mac);
sc->bb_prog = &rtl8188e_bb[0];
sc->bb_size = nitems(rtl8188e_bb);
sc->agc_prog = &rtl8188e_agc[0];
sc->agc_size = nitems(rtl8188e_agc);
sc->rf_prog = &rtl8188e_rf[0];
sc->name = "RTL8188EE";
sc->fwname = "rtwn-rtl8188eefw";
sc->fwsig = 0x88e;
sc->page_count = R88EE_TX_PAGE_COUNT;
sc->pktbuf_count = R88E_TXPKTBUF_COUNT;
sc->ackto = 0x40;
sc->npubqpages = R88EE_PUBQ_NPAGES;
sc->nhqpages = R88EE_HPQ_NPAGES;
sc->nnqpages = R88EE_NPQ_NPAGES;
sc->nlqpages = R88EE_LPQ_NPAGES;
sc->page_size = R92C_TX_PAGE_SIZE;
sc->txdesc_len = sizeof(struct r92ce_tx_desc);
sc->efuse_maxlen = R88E_EFUSE_MAX_LEN;
sc->efuse_maplen = R88E_EFUSE_MAP_LEN;
sc->rx_dma_size = R88E_RX_DMA_BUFFER_SIZE;
sc->macid_limit = R88E_MACID_MAX + 1;
sc->cam_entry_limit = R92C_CAM_ENTRY_COUNT;
sc->fwsize_limit = R92C_MAX_FW_SIZE;
sc->temp_delta = R88E_CALIB_THRESHOLD;
sc->bcn_status_reg[0] = R92C_TDECTRL;
/*
* TODO: some additional setup is required
* to maintain few beacons at the same time.
*
* XXX BCNQ1 mechanism is not needed here; move it to the USB module.
*/
sc->bcn_status_reg[1] = R92C_TDECTRL;
sc->rcr = 0;
sc->ntxchains = 1;
sc->nrxchains = 1;
r88ee_attach_private(sc);
}

View File

@ -0,0 +1,287 @@
/*-
* Copyright (c) 2017 Farhan Khan <khanzf@gmail.com>
*
* 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>
__FBSDID("$FreeBSD$");
#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 <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.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/pci/rtwn_pci_var.h>
#include <dev/rtwn/rtl8192c/r92c.h>
#include <dev/rtwn/rtl8188e/pci/r88ee.h>
#include <dev/rtwn/rtl8188e/pci/r88ee_reg.h>
void
r88ee_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 |
R92C_SYS_FUNC_EN_DIO_RF);
rtwn_write_1(sc, R92C_RF_CTRL,
R92C_RF_CTRL_EN | R92C_RF_CTRL_RSTB | R92C_RF_CTRL_SDMRSTB);
rtwn_write_1(sc, R92C_SYS_FUNC_EN, R92C_SYS_FUNC_EN_PPLL |
R92C_SYS_FUNC_EN_PCIEA | R92C_SYS_FUNC_EN_DIO_PCIE |
R92C_SYS_FUNC_EN_BB_GLB_RST | R92C_SYS_FUNC_EN_BBRSTB);
r88e_init_bb_common(sc);
}
void
r88ee_init_intr(struct rtwn_softc *sc)
{
/* Disable interrupts. */
rtwn_write_4(sc, R88E_HIMR, 0x00000000);
rtwn_write_4(sc, R88E_HIMRE, 0x00000000);
}
int
r88ee_power_on(struct rtwn_softc *sc)
{
int ntries;
/* Disable XTAL output for power saving. */
rtwn_setbits_1(sc, R88E_XCK_OUT_CTRL, R88E_XCK_OUT_CTRL_EN, 0);
/* Unlock ISO/CLK/Power control register. */
rtwn_setbits_2(sc, R92C_APS_FSMCO, R92C_APS_FSMCO_APDM_HPDN, 0);
rtwn_write_1(sc, R92C_RSV_CTRL, 0);
/* Wait for power ready bit */
for(ntries = 0; ntries < 5000; ntries++) {
if (rtwn_read_4(sc, R92C_APS_FSMCO) & R92C_APS_FSMCO_SUS_HOST)
break;
rtwn_delay(sc, 10);
}
if (ntries == 5000) {
device_printf(sc->sc_dev,
"timeout waiting for chip power up\n");
return (ETIMEDOUT);
}
/* Reset BB. */
rtwn_setbits_1(sc, R92C_SYS_FUNC_EN,
R92C_SYS_FUNC_EN_BBRSTB | R92C_SYS_FUNC_EN_BB_GLB_RST, 0);
/* schmit trigger */
rtwn_setbits_1(sc, R92C_AFE_XTAL_CTRL + 2, 0, 0x80);
/* Disable HWPDN. */
rtwn_setbits_1_shift(sc, R92C_APS_FSMCO,
R92C_APS_FSMCO_APDM_HPDN, 0, 1);
/* Disable WL suspend. */
rtwn_setbits_1_shift(sc, R92C_APS_FSMCO,
R92C_APS_FSMCO_AFSM_HSUS | R92C_APS_FSMCO_AFSM_PCIE, 0, 1);
/* Auto-enable WLAN */
rtwn_setbits_1_shift(sc, R92C_APS_FSMCO,
0, R92C_APS_FSMCO_APFM_ONMAC, 1);
for (ntries = 0; ntries < 5000; ntries++) {
if (!(rtwn_read_2(sc, R92C_APS_FSMCO) &
R92C_APS_FSMCO_APFM_ONMAC))
break;
rtwn_delay(sc, 10);
}
if (ntries == 5000)
return (ETIMEDOUT);
rtwn_setbits_1(sc, R92C_PCIE_CTRL_REG + 2, 0, 0x04);
/* Enable LDO normal mode. */
rtwn_setbits_1(sc, R92C_LPLDO_CTRL, R92C_LPLDO_CTRL_SLEEP, 0);
rtwn_setbits_1(sc, R92C_APS_FSMCO, 0, R92C_APS_FSMCO_PDN_EN);
rtwn_setbits_1(sc, R92C_PCIE_CTRL_REG + 2, 0, 0x04);
rtwn_setbits_1(sc, R92C_AFE_XTAL_CTRL_EXT + 1, 0, 0x02);
rtwn_setbits_1(sc, R92C_SYS_CLKR, 0, 0x08);
rtwn_setbits_2(sc, R92C_GPIO_MUXCFG, R92C_GPIO_MUXCFG_ENSIC, 0);
/* Enable MAC DMA/WMAC/SCHEDULE/SEC blocks. */
rtwn_write_2(sc, R92C_CR, 0);
rtwn_setbits_2(sc, R92C_CR, 0,
R92C_CR_HCI_TXDMA_EN | R92C_CR_TXDMA_EN |
R92C_CR_HCI_RXDMA_EN | R92C_CR_RXDMA_EN |
R92C_CR_PROTOCOL_EN | R92C_CR_SCHEDULE_EN |
((sc->sc_hwcrypto != RTWN_CRYPTO_SW) ? R92C_CR_ENSEC : 0) |
R92C_CR_CALTMR_EN);
rtwn_write_4(sc, R92C_INT_MIG, 0);
rtwn_write_4(sc, R92C_MCUTST_1, 0);
return (0);
}
void
r88ee_power_off(struct rtwn_softc *sc)
{
uint8_t reg;
int ntries;
/* Disable any kind of TX reports. */
rtwn_setbits_1(sc, R88E_TX_RPT_CTRL,
R88E_TX_RPT1_ENA | R88E_TX_RPT2_ENA, 0);
rtwn_write_1(sc, R92C_PCIE_CTRL_REG + 1, 0xFF);
/* Move card to Low Power State. */
/* Block all Tx queues. */
rtwn_write_1(sc, R92C_TXPAUSE, R92C_TX_QUEUE_ALL);
for (ntries = 0; ntries < 10; ntries++) {
/* Should be zero if no packet is transmitting. */
if (rtwn_read_4(sc, R88E_SCH_TXCMD) == 0)
break;
rtwn_delay(sc, 5000);
}
if (ntries == 10) {
device_printf(sc->sc_dev, "%s: failed to block Tx queues\n",
__func__);
return;
}
/* CCK and OFDM are disabled, and clock are gated. */
rtwn_setbits_1(sc, R92C_SYS_FUNC_EN, R92C_SYS_FUNC_EN_BBRSTB, 0);
rtwn_delay(sc, 1);
/* Reset MAC TRX */
rtwn_write_1(sc, R92C_CR,
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);
/* Disable h/w encryption. */
rtwn_setbits_1_shift(sc, R92C_CR, R92C_CR_ENSEC, 0, 1);
/* Respond TxOK to scheduler */
rtwn_setbits_1(sc, R92C_DUAL_TSF_RST, 0, 0x20);
/* If firmware in ram code, do reset. */
#ifndef RTWN_WITHOUT_UCODE
if (rtwn_read_1(sc, R92C_MCUFWDL) & R92C_MCUFWDL_RDY)
r88e_fw_reset(sc, RTWN_FW_RESET_SHUTDOWN);
#endif
/* Reset MCU ready status. */
rtwn_write_1(sc, R92C_MCUFWDL, 0);
/* Disable 32k. */
rtwn_setbits_1(sc, R88E_32K_CTRL, 0x01, 0);
/* Move card to Disabled state. */
/* Turn off RF. */
rtwn_write_1(sc, R92C_RF_CTRL, 0);
/* LDO Sleep mode. */
rtwn_setbits_1(sc, R92C_LPLDO_CTRL, 0, R92C_LPLDO_CTRL_SLEEP);
/* Turn off MAC by HW state machine */
rtwn_setbits_1_shift(sc, R92C_APS_FSMCO, 0,
R92C_APS_FSMCO_APFM_OFF, 1);
for (ntries = 0; ntries < 10; ntries++) {
/* Wait until it will be disabled. */
if ((rtwn_read_2(sc, R92C_APS_FSMCO) &
R92C_APS_FSMCO_APFM_OFF) == 0)
break;
rtwn_delay(sc, 5000);
}
if (ntries == 10) {
device_printf(sc->sc_dev, "%s: could not turn off MAC\n",
__func__);
return;
}
/* schmit trigger */
rtwn_setbits_1(sc, R92C_AFE_XTAL_CTRL + 2, 0, 0x80);
/* Reset MCU IO Wrapper. */
reg = rtwn_read_1(sc, R92C_RSV_CTRL + 1);
rtwn_write_1(sc, R92C_RSV_CTRL + 1, reg & ~0x08);
rtwn_write_1(sc, R92C_RSV_CTRL + 1, reg | 0x08);
/* marked as 'For Power Consumption' code. */
rtwn_write_1(sc, R92C_GPIO_OUT, rtwn_read_1(sc, R92C_GPIO_IN));
rtwn_write_1(sc, R92C_GPIO_IOSEL, 0xff);
rtwn_write_1(sc, R92C_GPIO_IO_SEL,
rtwn_read_1(sc, R92C_GPIO_IO_SEL) << 4);
rtwn_setbits_1(sc, R92C_GPIO_MOD, 0, 0x0f);
/* Set LNA, TRSW, EX_PA Pin to output mode. */
rtwn_write_4(sc, R88E_BB_PAD_CTRL, 0x00080808);
}
void
r88ee_post_init(struct rtwn_softc *sc)
{
/* Enable per-packet TX report. */
rtwn_setbits_1(sc, R88E_TX_RPT_CTRL, 0, R88E_TX_RPT1_ENA);
/* Disable Tx if MACID is not associated. */
rtwn_write_4(sc, R88E_MACID_NO_LINK, 0xffffffff);
rtwn_write_4(sc, R88E_MACID_NO_LINK + 4, 0xffffffff);
r88e_macid_enable_link(sc, RTWN_MACID_BC, 1);
/* Perform LO and IQ calibrations. */
r88e_iq_calib(sc);
/* Perform LC calibration. */
r92c_lc_calib(sc);
/* Enable Rx DMA */
rtwn_write_1(sc, R92C_PCIE_CTRL_REG + 1, 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;
}

View File

@ -0,0 +1,26 @@
/*-
* Copyright (c) 2018 Farhan Khan <khanzf@gmail.com>
*
* 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.
*
* $FreeBSD$
*/
#ifndef R88EE_REG_H
#define R88EE_REG_H
#include <dev/rtwn/rtl8192c/pci/r92ce_reg.h>
#include <dev/rtwn/rtl8188e/r88e_reg.h>
#endif /* R88EE_REG_H */

View File

@ -0,0 +1,143 @@
/*-
* Copyright (c) 2017 Farhan Khan <khanzf@gmail.com>
*
* 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>
__FBSDID("$FreeBSD$");
#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 <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.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_rtwn_debug.h>
#include <dev/rtwn/pci/rtwn_pci_var.h>
#include <dev/rtwn/rtl8188e/pci/r88ee.h>
#include <dev/rtwn/rtl8188e/pci/r88ee_reg.h>
int
r88ee_get_intr_status(struct rtwn_pci_softc *pc, int *rings)
{
struct rtwn_softc *sc = &pc->pc_sc;
uint32_t status, status_ex;
int ret;
*rings = 0;
status = rtwn_read_4(sc, R88E_HISR);
status_ex = rtwn_read_4(sc, R88E_HISRE);
RTWN_DPRINTF(sc, RTWN_DEBUG_INTR, "%s: HISR %08X, HISRE %08X\n",
__func__, status, status_ex);
if ((status == 0 || status == 0xffffffff) &&
(status_ex == 0 || status_ex == 0xffffffff))
return (0);
/* Disable interrupts */
rtwn_write_4(sc, R88E_HIMR, 0);
rtwn_write_4(sc, R88E_HIMRE, 0);
/* Ack interrupts */
rtwn_write_4(sc, R88E_HISR, status);
rtwn_write_4(sc, R88E_HISRE, status_ex);
if (status & R88E_HIMR_HIGHDOK)
*rings |= (1 << RTWN_PCI_HIGH_QUEUE);
if (status & R88E_HIMR_MGNTDOK)
*rings |= (1 << RTWN_PCI_MGNT_QUEUE);
if (status & R88E_HIMR_BKDOK)
*rings |= (1 << RTWN_PCI_BK_QUEUE);
if (status & R88E_HIMR_BEDOK)
*rings |= (1 << RTWN_PCI_BE_QUEUE);
if (status & R88E_HIMR_VIDOK)
*rings |= (1 << RTWN_PCI_VI_QUEUE);
if (status & R88E_HIMR_VODOK)
*rings |= (1 << RTWN_PCI_VO_QUEUE);
ret = 0;
if (status_ex & R88E_HIMRE_RXERR)
ret |= RTWN_PCI_INTR_RX_ERROR;
if (status_ex & R88E_HIMRE_RXFOVW)
ret |= RTWN_PCI_INTR_RX_OVERFLOW;
if (status & R88E_HIMR_RDU)
ret |= RTWN_PCI_INTR_RX_DESC_UNAVAIL;
if (status & R88E_HIMR_ROK)
ret |= RTWN_PCI_INTR_RX_DONE;
if (status_ex & R88E_HIMRE_TXERR)
ret |= RTWN_PCI_INTR_TX_ERROR;
if (status_ex & R88E_HIMRE_TXFOVW)
ret |= RTWN_PCI_INTR_TX_OVERFLOW;
if (status & R88E_HIMR_TXRPT)
ret |= RTWN_PCI_INTR_TX_REPORT;
if (status & R88E_HIMR_PSTIMEOUT)
ret |= RTWN_PCI_INTR_PS_TIMEOUT;
return (ret);
}
#define R88E_INT_ENABLE (R88E_HIMR_ROK | R88E_HIMR_RDU | R88E_HIMR_VODOK | \
R88E_HIMR_VIDOK | R88E_HIMR_BEDOK | \
R88E_HIMR_BKDOK | R88E_HIMR_MGNTDOK | \
R88E_HIMR_HIGHDOK | R88E_HIMR_TXRPT)
#define R88E_INT_ENABLE_EX (R88E_HIMRE_RXFOVW | R88E_HIMRE_RXERR)
void
r88ee_enable_intr(struct rtwn_pci_softc *pc)
{
struct rtwn_softc *sc = &pc->pc_sc;
/* Enable interrupts */
rtwn_write_4(sc, R88E_HIMR, R88E_INT_ENABLE);
rtwn_write_4(sc, R88E_HIMRE, R88E_INT_ENABLE_EX);
}
void
r88ee_start_xfers(struct rtwn_softc *sc)
{
/* Clear pending interrupts. */
rtwn_write_4(sc, R88E_HISR, 0xffffffff);
rtwn_write_4(sc, R88E_HISRE, 0xffffffff);
/* Enable interrupts. */
rtwn_write_4(sc, R88E_HIMR, R88E_INT_ENABLE);
rtwn_write_4(sc, R88E_HIMRE, R88E_INT_ENABLE_EX);
}
#undef R88E_INT_ENABLE
#undef R88E_INT_ENABLE_EX

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e.h 322949 2017-08-27 12:44:56Z avos $
* $FreeBSD$
*/
#ifndef RTL8188E_H
@ -24,9 +24,7 @@
/*
* Global definitions.
*/
#define R88E_PUBQ_NPAGES 142
#define R88E_TXPKTBUF_COUNT 177
#define R88E_TX_PAGE_COUNT 169
#define R88E_MACID_MAX 63
#define R88E_RX_DMA_BUFFER_SIZE 0x2400
@ -67,9 +65,8 @@ int r88e_set_pwrmode(struct rtwn_softc *, struct ieee80211vap *, int);
#endif
/* r88e_init.c */
void r88e_init_bb(struct rtwn_softc *);
void r88e_init_bb_common(struct rtwn_softc *);
void r88e_init_rf(struct rtwn_softc *);
int r88e_power_on(struct rtwn_softc *);
/* r88e_led.c */
void r88e_set_led(struct rtwn_softc *, int, int);
@ -81,6 +78,7 @@ void r88e_rf_write(struct rtwn_softc *, int, uint8_t, uint32_t);
void r88e_parse_rom(struct rtwn_softc *, uint8_t *);
/* r88e_rx.c */
int r88e_classify_intr(struct rtwn_softc *, void *, int);
void r88e_ratectl_tx_complete(struct rtwn_softc *, uint8_t *, int);
void r88e_handle_c2h_report(struct rtwn_softc *, uint8_t *, int);
int8_t r88e_get_rssi_cck(struct rtwn_softc *, void *);

View File

@ -15,7 +15,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_beacon.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2016 Andriy Voskoboinyk <avos@FreeBSD.org>
* Copyright (c) 2016-2019 Andriy Voskoboinyk <avos@FreeBSD.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -15,7 +15,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_calib.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -42,16 +42,343 @@ __FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_calib.c 307529 2016-1
#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>
/* Registers to save and restore during IQ calibration. */
struct r88e_iq_cal_reg_vals {
uint32_t adda[16];
uint8_t txpause;
uint8_t bcn_ctrl[2];
uint32_t gpio_muxcfg;
uint32_t cck0_afesetting;
uint32_t ofdm0_trxpathena;
uint32_t ofdm0_trmuxpar;
uint32_t fpga0_rfifacesw0;
uint32_t fpga0_rfifacesw1;
uint32_t fpga0_rfifaceoe0;
uint32_t fpga0_rfifaceoe1;
uint32_t config_ant0;
uint32_t config_ant1;
};
static int
r88e_iq_calib_chain(struct rtwn_softc *sc, uint16_t tx[2], uint16_t rx[2])
{
uint32_t status;
/* Set Rx IQ calibration mode table. */
rtwn_bb_write(sc, R92C_FPGA0_IQK, 0);
rtwn_rf_write(sc, 0, R88E_RF_WE_LUT, 0x800a0);
rtwn_rf_write(sc, 0, R92C_RF_RCK_OS, 0x30000);
rtwn_rf_write(sc, 0, R92C_RF_TXPA_G(0), 0xf);
rtwn_rf_write(sc, 0, R92C_RF_TXPA_G(1), 0xf117b);
rtwn_bb_write(sc, R92C_FPGA0_IQK, 0x80800000);
/* IQ calibration settings. */
rtwn_bb_write(sc, R92C_TX_IQK, 0x01007c00);
rtwn_bb_write(sc, R92C_RX_IQK, 0x81004800);
/* IQ calibration settings for chain 0. */
rtwn_bb_write(sc, R92C_TX_IQK_TONE(0), 0x10008c1c);
rtwn_bb_write(sc, R92C_RX_IQK_TONE(0), 0x30008c1c);
rtwn_bb_write(sc, R92C_TX_IQK_PI(0), 0x82160804);
rtwn_bb_write(sc, R92C_RX_IQK_PI(0), 0x28160000);
/* LO calibration settings. */
rtwn_bb_write(sc, R92C_IQK_AGC_RSP, 0x0046a911);
/* We're doing LO and IQ calibration in one shot. */
rtwn_bb_write(sc, R92C_IQK_AGC_PTS, 0xf9000000);
rtwn_bb_write(sc, R92C_IQK_AGC_PTS, 0xf8000000);
/* Give LO and IQ calibrations the time to complete. */
rtwn_delay(sc, 10000);
/* Read IQ calibration status. */
status = rtwn_bb_read(sc, R92C_RX_POWER_IQK_AFTER(0));
if (status & (1 << 28))
return (0); /* Tx failed. */
/* Read Tx IQ calibration results. */
tx[0] = MS(rtwn_bb_read(sc, R92C_TX_POWER_IQK_BEFORE(0)),
R92C_POWER_IQK_RESULT);
tx[1] = MS(rtwn_bb_read(sc, R92C_TX_POWER_IQK_AFTER(0)),
R92C_POWER_IQK_RESULT);
if (tx[0] == 0x142 || tx[1] == 0x042)
return (0); /* Tx failed. */
rtwn_bb_write(sc, R92C_TX_IQK, 0x80007c00 | (tx[0] << 16) | tx[1]);
/* Set Rx IQ calibration mode table. */
rtwn_bb_write(sc, R92C_FPGA0_IQK, 0);
rtwn_rf_write(sc, 0, R88E_RF_WE_LUT, 0x800a0);
rtwn_rf_write(sc, 0, R92C_RF_RCK_OS, 0x30000);
rtwn_rf_write(sc, 0, R92C_RF_TXPA_G(0), 0xf);
rtwn_rf_write(sc, 0, R92C_RF_TXPA_G(1), 0xf7ffa);
rtwn_bb_write(sc, R92C_FPGA0_IQK, 0x80800000);
/* IQ calibration settings. */
rtwn_bb_write(sc, R92C_RX_IQK, 0x01004800);
/* IQ calibration settings for chain 0. */
rtwn_bb_write(sc, R92C_TX_IQK_TONE(0), 0x30008c1c);
rtwn_bb_write(sc, R92C_RX_IQK_TONE(0), 0x10008c1c);
rtwn_bb_write(sc, R92C_TX_IQK_PI(0), 0x82160c05);
rtwn_bb_write(sc, R92C_RX_IQK_PI(0), 0x28160c05);
/* LO calibration settings. */
rtwn_bb_write(sc, R92C_IQK_AGC_RSP, 0x0046a911);
/* We're doing LO and IQ calibration in one shot. */
rtwn_bb_write(sc, R92C_IQK_AGC_PTS, 0xf9000000);
rtwn_bb_write(sc, R92C_IQK_AGC_PTS, 0xf8000000);
/* Give LO and IQ calibrations the time to complete. */
rtwn_delay(sc, 10000);
/* Read IQ calibration status. */
status = rtwn_bb_read(sc, R92C_RX_POWER_IQK_AFTER(0));
if (status & (1 << 27))
return (1); /* Rx failed. */
/* Read Rx IQ calibration results. */
rx[0] = MS(rtwn_bb_read(sc, R92C_RX_POWER_IQK_BEFORE(0)),
R92C_POWER_IQK_RESULT);
rx[1] = MS(status, R92C_POWER_IQK_RESULT);
if (rx[0] == 0x132 || rx[1] == 0x036)
return (1); /* Rx failed. */
return (3); /* Both Tx and Rx succeeded. */
}
static void
r88e_iq_calib_run(struct rtwn_softc *sc, int n, uint16_t tx[2],
uint16_t rx[2], struct r88e_iq_cal_reg_vals *vals)
{
/* Registers to save and restore during IQ calibration. */
static const uint16_t reg_adda[16] = {
0x85c, 0xe6c, 0xe70, 0xe74,
0xe78, 0xe7c, 0xe80, 0xe84,
0xe88, 0xe8c, 0xed0, 0xed4,
0xed8, 0xedc, 0xee0, 0xeec
};
int i;
uint32_t hssi_param1;
if (n == 0) {
for (i = 0; i < nitems(reg_adda); i++)
vals->adda[i] = rtwn_bb_read(sc, reg_adda[i]);
vals->txpause = rtwn_read_1(sc, R92C_TXPAUSE);
vals->bcn_ctrl[0] = rtwn_read_1(sc, R92C_BCN_CTRL(0));
vals->bcn_ctrl[1] = rtwn_read_1(sc, R92C_BCN_CTRL(1));
vals->gpio_muxcfg = rtwn_read_4(sc, R92C_GPIO_MUXCFG);
}
rtwn_bb_write(sc, reg_adda[0], 0x0b1b25a0);
for (i = 1; i < nitems(reg_adda); i++)
rtwn_bb_write(sc, reg_adda[i], 0x0bdb25a0);
hssi_param1 = rtwn_bb_read(sc, R92C_HSSI_PARAM1(0));
if (!(hssi_param1 & R92C_HSSI_PARAM1_PI)) {
rtwn_bb_write(sc, R92C_HSSI_PARAM1(0),
hssi_param1 | R92C_HSSI_PARAM1_PI);
rtwn_bb_write(sc, R92C_HSSI_PARAM1(1),
hssi_param1 | R92C_HSSI_PARAM1_PI);
}
if (n == 0) {
vals->cck0_afesetting = rtwn_bb_read(sc, R92C_CCK0_AFESETTING);
vals->ofdm0_trxpathena =
rtwn_bb_read(sc, R92C_OFDM0_TRXPATHENA);
vals->ofdm0_trmuxpar = rtwn_bb_read(sc, R92C_OFDM0_TRMUXPAR);
vals->fpga0_rfifacesw0 =
rtwn_bb_read(sc, R92C_FPGA0_RFIFACESW(0));
vals->fpga0_rfifacesw1 =
rtwn_bb_read(sc, R92C_FPGA0_RFIFACESW(1));
vals->fpga0_rfifaceoe0 =
rtwn_bb_read(sc, R92C_FPGA0_RFIFACEOE(0));
vals->fpga0_rfifaceoe1 =
rtwn_bb_read(sc, R92C_FPGA0_RFIFACEOE(1));
vals->config_ant0 = rtwn_bb_read(sc, R92C_CONFIG_ANT(0));
vals->config_ant1 = rtwn_bb_read(sc, R92C_CONFIG_ANT(1));
}
rtwn_bb_setbits(sc, R92C_CCK0_AFESETTING, 0, 0x0f000000);
rtwn_bb_write(sc, R92C_OFDM0_TRXPATHENA, 0x03a05600);
rtwn_bb_write(sc, R92C_OFDM0_TRMUXPAR, 0x000800e4);
rtwn_bb_write(sc, R92C_FPGA0_RFIFACESW(1), 0x22204000);
rtwn_bb_setbits(sc, R92C_FPGA0_RFIFACESW(0), 0, 0x04000400);
rtwn_bb_setbits(sc, R92C_FPGA0_RFIFACEOE(0), 0x400, 0);
rtwn_bb_setbits(sc, R92C_FPGA0_RFIFACEOE(1), 0x400, 0);
rtwn_write_1(sc, R92C_TXPAUSE,
R92C_TX_QUEUE_AC | R92C_TX_QUEUE_MGT | R92C_TX_QUEUE_HIGH);
rtwn_write_1(sc, R92C_BCN_CTRL(0),
vals->bcn_ctrl[0] & ~R92C_BCN_CTRL_EN_BCN);
rtwn_write_1(sc, R92C_BCN_CTRL(1),
vals->bcn_ctrl[1] & ~R92C_BCN_CTRL_EN_BCN);
rtwn_write_1(sc, R92C_GPIO_MUXCFG,
vals->gpio_muxcfg & ~R92C_GPIO_MUXCFG_ENBT);
rtwn_bb_write(sc, R92C_CONFIG_ANT(0), 0x0f600000);
rtwn_bb_write(sc, R92C_FPGA0_IQK, 0x80800000);
rtwn_bb_write(sc, R92C_TX_IQK, 0x01007c00);
rtwn_bb_write(sc, R92C_RX_IQK, 0x01004800);
/* Run IQ calibration twice. */
for (i = 0; i < 2; i++) {
int ret;
ret = r88e_iq_calib_chain(sc, tx, rx);
if (ret == 0) {
RTWN_DPRINTF(sc, RTWN_DEBUG_CALIB, "%s: Tx failed.\n",
__func__);
tx[0] = 0xff;
tx[1] = 0xff;
rx[0] = 0xff;
rx[1] = 0xff;
} else if (ret == 1) {
RTWN_DPRINTF(sc, RTWN_DEBUG_CALIB, "%s: Rx failed.\n",
__func__);
rx[0] = 0xff;
rx[1] = 0xff;
} else if (ret == 3) {
RTWN_DPRINTF(sc, RTWN_DEBUG_CALIB, "%s: Both Tx and Rx"
" succeeded.\n", __func__);
}
}
RTWN_DPRINTF(sc, RTWN_DEBUG_CALIB,
"%s: results for run %d: tx[0] 0x%x, tx[1] 0x%x, rx[0] 0x%x, "
"rx[1] 0x%x\n", __func__, n, tx[0], tx[1], rx[0], rx[1]);
rtwn_bb_write(sc, R92C_CCK0_AFESETTING, vals->cck0_afesetting);
rtwn_bb_write(sc, R92C_OFDM0_TRXPATHENA, vals->ofdm0_trxpathena);
rtwn_bb_write(sc, R92C_FPGA0_RFIFACESW(0), vals->fpga0_rfifacesw0);
rtwn_bb_write(sc, R92C_FPGA0_RFIFACESW(1), vals->fpga0_rfifacesw1);
rtwn_bb_write(sc, R92C_OFDM0_TRMUXPAR, vals->ofdm0_trmuxpar);
rtwn_bb_write(sc, R92C_FPGA0_RFIFACEOE(0), vals->fpga0_rfifaceoe0);
rtwn_bb_write(sc, R92C_FPGA0_RFIFACEOE(1), vals->fpga0_rfifaceoe1);
rtwn_bb_write(sc, R92C_CONFIG_ANT(0), vals->config_ant0);
rtwn_bb_write(sc, R92C_CONFIG_ANT(1), vals->config_ant1);
rtwn_bb_write(sc, R92C_FPGA0_IQK, 0);
rtwn_bb_write(sc, R92C_LSSI_PARAM(0), 0x00032ed3);
if (n != 0) {
if (!(hssi_param1 & R92C_HSSI_PARAM1_PI)) {
rtwn_bb_write(sc, R92C_HSSI_PARAM1(0), hssi_param1);
rtwn_bb_write(sc, R92C_HSSI_PARAM1(1), hssi_param1);
}
for (i = 0; i < nitems(reg_adda); i++)
rtwn_bb_write(sc, reg_adda[i], vals->adda[i]);
rtwn_write_1(sc, R92C_TXPAUSE, vals->txpause);
rtwn_write_1(sc, R92C_BCN_CTRL(0), vals->bcn_ctrl[0]);
rtwn_write_1(sc, R92C_BCN_CTRL(1), vals->bcn_ctrl[1]);
rtwn_write_4(sc, R92C_GPIO_MUXCFG, vals->gpio_muxcfg);
}
}
#define RTWN_IQ_CAL_MAX_TOLERANCE 5
static int
r88e_iq_calib_compare_results(struct rtwn_softc *sc, uint16_t tx1[2],
uint16_t rx1[2], uint16_t tx2[2], uint16_t rx2[2])
{
int i, tx_ok, rx_ok;
tx_ok = rx_ok = 0;
for (i = 0; i < 2; i++) {
if (tx1[i] == 0xff || tx2[i] == 0xff ||
rx1[i] == 0xff || rx2[i] == 0xff)
continue;
tx_ok = (abs(tx1[i] - tx2[i]) <= RTWN_IQ_CAL_MAX_TOLERANCE);
rx_ok = (abs(rx1[i] - rx2[i]) <= RTWN_IQ_CAL_MAX_TOLERANCE);
}
return (tx_ok && rx_ok);
}
#undef RTWN_IQ_CAL_MAX_TOLERANCE
static void
r88e_iq_calib_write_results(struct rtwn_softc *sc, uint16_t tx[2],
uint16_t rx[2])
{
uint32_t reg, val, x;
long y, tx_c;
if (tx[0] == 0xff || tx[1] == 0xff)
return;
reg = rtwn_bb_read(sc, R92C_OFDM0_TXIQIMBALANCE(0));
val = ((reg >> 22) & 0x3ff);
x = tx[0];
if (x & 0x00000200)
x |= 0xfffffc00;
reg = (((x * val) >> 8) & 0x3ff);
rtwn_bb_setbits(sc, R92C_OFDM0_TXIQIMBALANCE(0), 0x3ff, reg);
rtwn_bb_setbits(sc, R92C_OFDM0_ECCATHRESHOLD, 0x80000000,
((x * val) & 0x80) << 24);
y = tx[1];
if (y & 0x00000200)
y |= 0xfffffc00;
tx_c = (y * val) >> 8;
rtwn_bb_setbits(sc, R92C_OFDM0_TXAFE(0), 0xf0000000,
(tx_c & 0x3c0) << 22);
rtwn_bb_setbits(sc, R92C_OFDM0_TXIQIMBALANCE(0), 0x003f0000,
(tx_c & 0x3f) << 16);
rtwn_bb_setbits(sc, R92C_OFDM0_ECCATHRESHOLD, 0x20000000,
((y * val) & 0x80) << 22);
if (rx[0] == 0xff || rx[1] == 0xff)
return;
rtwn_bb_setbits(sc, R92C_OFDM0_RXIQIMBALANCE(0), 0x3ff,
rx[0] & 0x3ff);
rtwn_bb_setbits(sc, R92C_OFDM0_RXIQIMBALANCE(0), 0xfc00,
(rx[1] & 0x3f) << 10);
rtwn_bb_setbits(sc, R92C_OFDM0_RXIQEXTANTA, 0xf0000000,
(rx[1] & 0x3c0) << 22);
}
#define RTWN_IQ_CAL_NRUN 3
void
r88e_iq_calib(struct rtwn_softc *sc)
{
/* XXX TODO */
struct r88e_iq_cal_reg_vals vals;
uint16_t tx[RTWN_IQ_CAL_NRUN][2], rx[RTWN_IQ_CAL_NRUN][2];
int n, valid;
KASSERT(sc->ntxchains == 1,
("%s: only 1T1R configuration is supported!\n", __func__));
valid = 0;
for (n = 0; n < RTWN_IQ_CAL_NRUN; n++) {
r88e_iq_calib_run(sc, n, tx[n], rx[n], &vals);
if (n == 0)
continue;
/* Valid results remain stable after consecutive runs. */
valid = r88e_iq_calib_compare_results(sc, tx[n - 1],
rx[n - 1], tx[n], rx[n]);
if (valid)
break;
}
if (valid)
r88e_iq_calib_write_results(sc, tx[n], rx[n]);
}
#undef RTWN_IQ_CAL_NRUN
void
r88e_temp_measure(struct rtwn_softc *sc)

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_chan.c 330750 2018-03-10 23:47:03Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_fw.c 312002 2017-01-13 02:11:16Z kevlo $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -109,7 +109,11 @@ r88e_fw_reset(struct rtwn_softc *sc, int reason)
reg = rtwn_read_2(sc, R92C_SYS_FUNC_EN);
rtwn_write_2(sc, R92C_SYS_FUNC_EN, reg & ~R92C_SYS_FUNC_EN_CPUEN);
rtwn_write_2(sc, R92C_SYS_FUNC_EN, reg | R92C_SYS_FUNC_EN_CPUEN);
if (reason != RTWN_FW_RESET_SHUTDOWN) {
rtwn_write_2(sc, R92C_SYS_FUNC_EN,
reg | R92C_SYS_FUNC_EN_CPUEN);
}
}
void

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_fw_cmd.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef R88E_FW_CMD_H

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_init.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -70,20 +70,8 @@ r88e_crystalcap_write(struct rtwn_softc *sc)
}
void
r88e_init_bb(struct rtwn_softc *sc)
r88e_init_bb_common(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 |
R92C_SYS_FUNC_EN_DIO_RF);
rtwn_write_1(sc, R92C_RF_CTRL,
R92C_RF_CTRL_EN | R92C_RF_CTRL_RSTB | R92C_RF_CTRL_SDMRSTB);
rtwn_write_1(sc, R92C_SYS_FUNC_EN,
R92C_SYS_FUNC_EN_USBA | R92C_SYS_FUNC_EN_USBD |
R92C_SYS_FUNC_EN_BB_GLB_RST | R92C_SYS_FUNC_EN_BBRSTB);
r92c_init_bb_common(sc);
rtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(0), 0x69553422);
@ -93,66 +81,3 @@ r88e_init_bb(struct rtwn_softc *sc)
r88e_crystalcap_write(sc);
}
int
r88e_power_on(struct rtwn_softc *sc)
{
#define RTWN_CHK(res) do { \
if (res != 0) \
return (EIO); \
} while(0)
int ntries;
/* Wait for power ready bit. */
for (ntries = 0; ntries < 5000; ntries++) {
if (rtwn_read_4(sc, R92C_APS_FSMCO) & R92C_APS_FSMCO_SUS_HOST)
break;
rtwn_delay(sc, 10);
}
if (ntries == 5000) {
device_printf(sc->sc_dev,
"timeout waiting for chip power up\n");
return (ETIMEDOUT);
}
/* Reset BB. */
RTWN_CHK(rtwn_setbits_1(sc, R92C_SYS_FUNC_EN,
R92C_SYS_FUNC_EN_BBRSTB | R92C_SYS_FUNC_EN_BB_GLB_RST, 0));
RTWN_CHK(rtwn_setbits_1(sc, R92C_AFE_XTAL_CTRL + 2, 0, 0x80));
/* Disable HWPDN. */
RTWN_CHK(rtwn_setbits_1_shift(sc, R92C_APS_FSMCO,
R92C_APS_FSMCO_APDM_HPDN, 0, 1));
/* Disable WL suspend. */
RTWN_CHK(rtwn_setbits_1_shift(sc, R92C_APS_FSMCO,
R92C_APS_FSMCO_AFSM_HSUS | R92C_APS_FSMCO_AFSM_PCIE, 0, 1));
RTWN_CHK(rtwn_setbits_1_shift(sc, R92C_APS_FSMCO,
0, R92C_APS_FSMCO_APFM_ONMAC, 1));
for (ntries = 0; ntries < 5000; ntries++) {
if (!(rtwn_read_2(sc, R92C_APS_FSMCO) &
R92C_APS_FSMCO_APFM_ONMAC))
break;
rtwn_delay(sc, 10);
}
if (ntries == 5000)
return (ETIMEDOUT);
/* Enable LDO normal mode. */
RTWN_CHK(rtwn_setbits_1(sc, R92C_LPLDO_CTRL,
R92C_LPLDO_CTRL_SLEEP, 0));
/* Enable MAC DMA/WMAC/SCHEDULE/SEC blocks. */
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_TXDMA_EN |
R92C_CR_HCI_RXDMA_EN | R92C_CR_RXDMA_EN |
R92C_CR_PROTOCOL_EN | R92C_CR_SCHEDULE_EN |
((sc->sc_hwcrypto != RTWN_CRYPTO_SW) ? R92C_CR_ENSEC : 0) |
R92C_CR_CALTMR_EN));
return (0);
#undef RTWN_CHK
}

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_led.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_priv.h 320055 2017-06-17 14:39:25Z kevlo $
* $FreeBSD$
*/
#ifndef R88E_PRIV_H
@ -37,7 +37,7 @@ struct rtwn_r88e_txpwr {
/*
* MAC initialization values.
*/
static const struct rtwn_mac_prog rtl8188eu_mac[] = {
static const struct rtwn_mac_prog rtl8188e_mac[] = {
{ 0x026, 0x41 }, { 0x027, 0x35 }, { 0x040, 0x00 }, { 0x428, 0x0a },
{ 0x429, 0x10 }, { 0x430, 0x00 }, { 0x431, 0x01 }, { 0x432, 0x02 },
{ 0x433, 0x04 }, { 0x434, 0x05 }, { 0x435, 0x06 }, { 0x436, 0x07 },
@ -66,7 +66,7 @@ static const struct rtwn_mac_prog rtl8188eu_mac[] = {
/*
* Baseband initialization values.
*/
static const uint16_t rtl8188eu_bb_regs[] = {
static const uint16_t rtl8188e_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,
@ -93,7 +93,7 @@ static const uint16_t rtl8188eu_bb_regs[] = {
0xed8, 0xedc, 0xee0, 0xee8, 0xeec, 0xf14, 0xf4c, 0xf00
};
static const uint32_t rtl8188eu_bb_vals[] = {
static const uint32_t rtl8188e_bb_vals[] = {
0x80040000, 0x00000003, 0x0000fc00, 0x0000000a, 0x10001331,
0x020c3d10, 0x02200385, 0x00000000, 0x01000100, 0x00390204,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
@ -135,17 +135,17 @@ static const uint32_t rtl8188eu_bb_vals[] = {
0x00000000, 0x00000300
};
static const struct rtwn_bb_prog rtl8188eu_bb[] = {
static const struct rtwn_bb_prog rtl8188e_bb[] = {
{
nitems(rtl8188eu_bb_regs),
rtl8188eu_bb_regs,
rtl8188eu_bb_vals,
nitems(rtl8188e_bb_regs),
rtl8188e_bb_regs,
rtl8188e_bb_vals,
{ 0 },
NULL
}
};
static const uint32_t rtl8188eu_agc_vals[] = {
static const uint32_t rtl8188e_agc_vals[] = {
0xfb000001, 0xfb010001, 0xfb020001, 0xfb030001, 0xfb040001,
0xfb050001, 0xfa060001, 0xf9070001, 0xf8080001, 0xf7090001,
0xf60a0001, 0xf50b0001, 0xf40c0001, 0xf30d0001, 0xf20e0001,
@ -174,10 +174,10 @@ static const uint32_t rtl8188eu_agc_vals[] = {
0x407d0001, 0x407e0001, 0x407f0001
};
static const struct rtwn_agc_prog rtl8188eu_agc[] = {
static const struct rtwn_agc_prog rtl8188e_agc[] = {
{
nitems(rtl8188eu_agc_vals),
rtl8188eu_agc_vals,
nitems(rtl8188e_agc_vals),
rtl8188e_agc_vals,
{ 0 },
NULL
}
@ -186,7 +186,7 @@ static const struct rtwn_agc_prog rtl8188eu_agc[] = {
/*
* RF initialization values.
*/
static const uint8_t rtl8188eu_rf_regs[] = {
static const uint8_t rtl8188e_rf_regs[] = {
0x00, 0x08, 0x18, 0x19, 0x1e, 0x1f, 0x2f, 0x3f, 0x42, 0x57,
0x58, 0x67, 0x83, 0xb0, 0xb1, 0xb2, 0xb4, 0xb6, 0xb7, 0xb8,
0xb9, 0xba, 0xbb, 0xbf, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
@ -199,7 +199,7 @@ static const uint8_t rtl8188eu_rf_regs[] = {
0x1f, 0xfe, 0xfe, 0x1e, 0x1f, 0x00
};
static const uint32_t rtl8188eu_rf_vals[] = {
static const uint32_t rtl8188e_rf_vals[] = {
0x30000, 0x84000, 0x00407, 0x00012, 0x80009, 0x00880, 0x1a060,
0x00000, 0x060c0, 0xd0000, 0xbe180, 0x01552, 0x00000, 0xff8fc,
0x54400, 0xccc19, 0x43003, 0x4953e, 0x1c718, 0x060ff, 0x80001,
@ -216,11 +216,11 @@ static const uint32_t rtl8188eu_rf_vals[] = {
0x0c350, 0x0c350, 0x00001, 0x80000, 0x33e60
};
static const struct rtwn_rf_prog rtl8188eu_rf[] = {
static const struct rtwn_rf_prog rtl8188e_rf[] = {
{
nitems(rtl8188eu_rf_regs),
rtl8188eu_rf_regs,
rtl8188eu_rf_vals,
nitems(rtl8188e_rf_regs),
rtl8188e_rf_regs,
rtl8188e_rf_vals,
{ 0 },
NULL
},

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_reg.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef R88E_REG_H
@ -32,6 +32,7 @@
#define R88E_HISR 0x0b4
#define R88E_HIMRE 0x0b8
#define R88E_HISRE 0x0bc
#define R88E_XCK_OUT_CTRL 0x07c
/* MAC General Configuration. */
#define R88E_32K_CTRL 0x194
#define R88E_HMEBOX_EXT(idx) (0x1f0 + (idx) * 4)
@ -45,16 +46,49 @@
/* Bits for R88E_HIMR. */
#define R88E_HIMR_CPWM 0x00000100
#define R88E_HIMR_CPWM2 0x00000200
#define R88E_HIMR_TBDER 0x04000000
#define R88E_HIMR_PSTIMEOUT 0x20000000
#define R88E_HIMR_ROK 0x00000001 /* receive DMA OK */
#define R88E_HIMR_RDU 0x00000002 /* Rx descriptor unavailable */
#define R88E_HIMR_VODOK 0x00000004 /* AC_VO DMA OK */
#define R88E_HIMR_VIDOK 0x00000008 /* AC_VI DMA OK */
#define R88E_HIMR_BEDOK 0x00000010 /* AC_BE DMA OK */
#define R88E_HIMR_BKDOK 0x00000020 /* AC_BK DMA OK */
#define R88E_HIMR_MGNTDOK 0x00000040 /* management queue DMA OK */
#define R88E_HIMR_HIGHDOK 0x00000080 /* high queue DMA OK */
#define R88E_HIMR_CPWM 0x00000100 /* CPU power mode intr 1 */
#define R88E_HIMR_CPWM2 0x00000200 /* CPU power mode intr 2 */
#define R88E_HIMR_C2HCMD 0x00000400 /* C2H command interrupt */
#define R88E_HIMR_HISR 0x00000800 /* (HISR & HIMR) != 0 */
#define R88E_HIMR_ATIMEND 0x00001000 /* ATIM window end interrupt */
#define R88E_HIMR_HSISR 0x00008000 /* (HSIMR & HSISR) != 0 */
#define R88E_HIMR_BCNDERR 0x00010000 /* beacon queue DMA error */
#define R88E_HIMR_BCNINT 0x00100000 /* beacon DMA interrupt 0 */
#define R88E_HIMR_TSF32 0x01000000 /* TSF 32 bit interrupt */
#define R88E_HIMR_TBDOK 0x02000000 /* beacon transmit OK */
#define R88E_HIMR_TBDER 0x04000000 /* beacon transmit error */
#define R88E_HIMR_GTIMER3 0x08000000 /* GTIMER3 interrupt */
#define R88E_HIMR_GTIMER4 0x10000000 /* GTIMER4 interrupt */
#define R88E_HIMR_PSTIMEOUT 0x20000000 /* powersave timeout */
#define R88E_HIMR_TXRPT 0x40000000 /* Tx report interrupt */
/* Bits for R88E_HIMRE.*/
#define R88E_HIMRE_RXFOVW 0x00000100
#define R88E_HIMRE_TXFOVW 0x00000200
#define R88E_HIMRE_RXERR 0x00000400
#define R88E_HIMRE_TXERR 0x00000800
#define R88E_HIMRE_RXFOVW 0x00000100 /* receive FIFO overflow */
#define R88E_HIMRE_TXFOVW 0x00000200 /* transmit FIFO overflow */
#define R88E_HIMRE_RXERR 0x00000400 /* receive error */
#define R88E_HIMRE_TXERR 0x00000800 /* transmit error */
#define R88E_HIMRE_BCNDOK1 0x00004000 /* beacon queue DMA OK (1) */
#define R88E_HIMRE_BCNDOK2 0x00008000 /* beacon queue DMA OK (2) */
#define R88E_HIMRE_BCNDOK3 0x00010000 /* beacon queue DMA OK (3) */
#define R88E_HIMRE_BCNDOK4 0x00020000 /* beacon queue DMA OK (4) */
#define R88E_HIMRE_BCNDOK5 0x00040000 /* beacon queue DMA OK (5) */
#define R88E_HIMRE_BCNDOK6 0x00080000 /* beacon queue DMA OK (6) */
#define R88E_HIMRE_BCNDOK7 0x00100000 /* beacon queue DMA OK (7) */
#define R88E_HIMRE_BCNDMAINT1 0x00200000 /* beacon DMA interrupt 1 */
#define R88E_HIMRE_BCNDMAINT2 0x00400000 /* beacon DMA interrupt 2 */
#define R88E_HIMRE_BCNDMAINT3 0x00800000 /* beacon DMA interrupt 3 */
#define R88E_HIMRE_BCNDMAINT4 0x01000000 /* beacon DMA interrupt 4 */
#define R88E_HIMRE_BCNDMAINT5 0x02000000 /* beacon DMA interrupt 5 */
#define R88E_HIMRE_BCNDMAINT6 0x04000000 /* beacon DMA interrupt 6 */
#define R88E_HIMRE_BCNDMAINT7 0x08000000 /* beacon DMA interrupt 7 */
/* Bits for R88E_TX_RPT_CTRL. */
#define R88E_TX_RPT1_ENA 0x01
@ -79,6 +113,7 @@
* RF (6052) registers.
*/
#define R88E_RF_T_METER 0x42
#define R88E_RF_WE_LUT 0xef
/* Bits for R92C_RF_CHNLBW. */
#define R88E_RF_CHNLBW_BW20 0x00c00
@ -88,4 +123,7 @@
#define R88E_RF_T_METER_VAL_S 10
#define R88E_RF_T_METER_START 0x30000
/* Bits for R88E_XCK_OUT_CTRL. */
#define R88E_XCK_OUT_CTRL_EN 1
#endif /* R88E_REG_H */

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_rf.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_rom.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -81,5 +81,6 @@ r88e_parse_rom(struct rtwn_softc *sc, uint8_t *buf)
__func__,rs->regulatory);
sc->thermal_meter = rom->thermal_meter;
IEEE80211_ADDR_COPY(sc->sc_ic.ic_macaddr, rom->macaddr);
rtwn_r92c_set_rom_opts(sc, buf);
}

View File

@ -13,7 +13,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_rom_defs.h 319649 2017-06-07 09:10:24Z kevlo $
* $FreeBSD$
*/
#ifndef R88E_ROM_DEFS_H

View File

@ -13,7 +13,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_rom_image.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef R88E_ROM_IMAGE_H
@ -44,11 +44,24 @@ struct r88e_rom {
uint8_t reserved4[3];
uint8_t rf_ant_opt;
uint8_t reserved5[6];
uint16_t vid;
uint16_t pid;
uint8_t usb_opt;
uint8_t reserved6[2];
uint8_t macaddr[IEEE80211_ADDR_LEN];
union {
struct {
uint16_t vid;
uint16_t pid;
uint8_t usb_opt;
uint8_t reserved6[2];
uint8_t macaddr[IEEE80211_ADDR_LEN];
} __packed usb;
struct {
uint8_t macaddr[IEEE80211_ADDR_LEN];
uint16_t vid;
uint16_t pid;
uint8_t reserved6[3];
} __packed pci;
} __packed diff_d0;
uint8_t reserved7[2];
uint8_t string[33]; /* "realtek 802.11n NIC" */
uint8_t reserved8[256];

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_rx.c 331043 2018-03-16 01:03:10Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -56,6 +56,25 @@ __FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_rx.c 331043 2018-03-1
#include <dev/rtwn/rtl8188e/r88e_rx_desc.h>
int
r88e_classify_intr(struct rtwn_softc *sc, void *buf, int len)
{
struct r92c_rx_stat *stat = buf;
int report_sel = MS(le32toh(stat->rxdw3), R88E_RXDW3_RPT);
switch (report_sel) {
case R88E_RXDW3_RPT_RX:
return (RTWN_RX_DATA);
case R88E_RXDW3_RPT_TX1: /* per-packet Tx report */
case R88E_RXDW3_RPT_TX2: /* periodical Tx report */
return (RTWN_RX_TX_REPORT);
case R88E_RXDW3_RPT_HIS:
return (RTWN_RX_OTHER);
default: /* shut up the compiler */
return (RTWN_RX_DATA);
}
}
void
r88e_ratectl_tx_complete(struct rtwn_softc *sc, uint8_t *buf, int len)
{

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_rx_desc.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef R88E_RX_DESC_H

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_tx.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/r88e_tx_desc.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef R88E_TX_DESC_H

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/usb/r88eu.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef RTL8188EU_H
@ -24,16 +24,22 @@
#include <dev/rtwn/rtl8188e/r88e.h>
/*
* Global definitions.
*/
#define R88EU_PUBQ_NPAGES 142
#define R88EU_TX_PAGE_COUNT 169
/*
* Function declarations.
*/
/* r88eu_init.c */
void r88eu_init_bb(struct rtwn_softc *);
int r88eu_power_on(struct rtwn_softc *);
void r88eu_power_off(struct rtwn_softc *);
void r88eu_init_intr(struct rtwn_softc *);
void r88eu_init_rx_agg(struct rtwn_softc *);
void r88eu_post_init(struct rtwn_softc *);
/* r88eu_rx.c */
int r88eu_classify_intr(struct rtwn_softc *, void *, int);
#endif /* RTL8188EU_H */

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/usb/r88eu_attach.c 320055 2017-06-17 14:39:25Z kevlo $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -57,6 +57,7 @@ __FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/usb/r88eu_attach.c 320055
#include <dev/rtwn/rtl8192c/usb/r92cu_tx_desc.h>
#include <dev/rtwn/rtl8188e/r88e_priv.h>
#include <dev/rtwn/rtl8188e/r88e_rom_image.h> /* for 'macaddr' field */
#include <dev/rtwn/rtl8188e/usb/r88eu.h>
@ -65,6 +66,14 @@ static struct rtwn_r88e_txpwr r88e_txpwr;
void r88eu_attach(struct rtwn_usb_softc *);
static void
r88eu_set_macaddr(struct rtwn_softc *sc, uint8_t *buf)
{
struct r88e_rom *rom = (struct r88e_rom *)buf;
IEEE80211_ADDR_COPY(sc->sc_ic.ic_macaddr, rom->diff_d0.usb.macaddr);
}
static void
r88e_postattach(struct rtwn_softc *sc)
{
@ -93,7 +102,7 @@ r88eu_attach_private(struct rtwn_softc *sc)
rs->rs_tx_enable_ampdu = r88e_tx_enable_ampdu;
rs->rs_tx_setup_hwseq = r88e_tx_setup_hwseq;
rs->rs_tx_setup_macid = r88e_tx_setup_macid;
rs->rs_set_name = rtwn_nop_softc; /* not used */
rs->rs_set_rom_opts = r88eu_set_macaddr;
rs->rf_read_delay[0] = 10;
rs->rf_read_delay[1] = 100;
@ -130,7 +139,7 @@ r88eu_attach(struct rtwn_usb_softc *uc)
sc->sc_get_rx_stats = r88e_get_rx_stats;
sc->sc_get_rssi_cck = r88e_get_rssi_cck;
sc->sc_get_rssi_ofdm = r88e_get_rssi_ofdm;
sc->sc_classify_intr = r88eu_classify_intr;
sc->sc_classify_intr = r88e_classify_intr;
sc->sc_handle_tx_report = r88e_ratectl_tx_complete;
sc->sc_handle_c2h_report = r88e_handle_c2h_report;
sc->sc_check_frame = rtwn_nop_int_softc_mbuf;
@ -140,7 +149,7 @@ r88eu_attach(struct rtwn_usb_softc *uc)
sc->sc_efuse_postread = rtwn_nop_softc;
sc->sc_parse_rom = r88e_parse_rom;
sc->sc_set_led = r88e_set_led;
sc->sc_power_on = r88e_power_on;
sc->sc_power_on = r88eu_power_on;
sc->sc_power_off = r88eu_power_off;
#ifndef RTWN_WITHOUT_UCODE
sc->sc_fw_reset = r88e_fw_reset;
@ -149,7 +158,7 @@ r88eu_attach(struct rtwn_usb_softc *uc)
sc->sc_llt_init = r92c_llt_init;
sc->sc_set_page_size = r92c_set_page_size;
sc->sc_lc_calib = r92c_lc_calib;
sc->sc_iq_calib = r88e_iq_calib; /* XXX TODO */
sc->sc_iq_calib = r88e_iq_calib;
sc->sc_read_chipid_vendor = rtwn_nop_softc_uint32;
sc->sc_adj_devcaps = r88eu_adj_devcaps;
sc->sc_vap_preattach = rtwn_nop_softc_vap;
@ -172,29 +181,29 @@ r88eu_attach(struct rtwn_usb_softc *uc)
sc->sc_init_ampdu = rtwn_nop_softc;
sc->sc_init_intr = r88eu_init_intr;
sc->sc_init_edca = r92c_init_edca;
sc->sc_init_bb = r88e_init_bb;
sc->sc_init_bb = r88eu_init_bb;
sc->sc_init_rf = r92c_init_rf;
sc->sc_init_antsel = rtwn_nop_softc;
sc->sc_post_init = r88eu_post_init;
sc->sc_init_bcnq1_boundary = rtwn_nop_int_softc;
sc->mac_prog = &rtl8188eu_mac[0];
sc->mac_size = nitems(rtl8188eu_mac);
sc->bb_prog = &rtl8188eu_bb[0];
sc->bb_size = nitems(rtl8188eu_bb);
sc->agc_prog = &rtl8188eu_agc[0];
sc->agc_size = nitems(rtl8188eu_agc);
sc->rf_prog = &rtl8188eu_rf[0];
sc->mac_prog = &rtl8188e_mac[0];
sc->mac_size = nitems(rtl8188e_mac);
sc->bb_prog = &rtl8188e_bb[0];
sc->bb_size = nitems(rtl8188e_bb);
sc->agc_prog = &rtl8188e_agc[0];
sc->agc_size = nitems(rtl8188e_agc);
sc->rf_prog = &rtl8188e_rf[0];
sc->name = "RTL8188EU";
sc->fwname = "rtwn-rtl8188eufw";
sc->fwsig = 0x88e;
sc->page_count = R88E_TX_PAGE_COUNT;
sc->page_count = R88EU_TX_PAGE_COUNT;
sc->pktbuf_count = R88E_TXPKTBUF_COUNT;
sc->ackto = 0x40;
sc->npubqpages = R88E_PUBQ_NPAGES;
sc->npubqpages = R88EU_PUBQ_NPAGES;
sc->page_size = R92C_TX_PAGE_SIZE;
sc->txdesc_len = sizeof(struct r92cu_tx_desc);

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/usb/r88eu_init.c 310305 2016-12-20 01:13:11Z kevlo $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -54,6 +54,87 @@ __FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/usb/r88eu_init.c 310305 20
#include <dev/rtwn/rtl8188e/usb/r88eu_reg.h>
void
r88eu_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 |
R92C_SYS_FUNC_EN_DIO_RF);
rtwn_write_1(sc, R92C_RF_CTRL,
R92C_RF_CTRL_EN | R92C_RF_CTRL_RSTB | R92C_RF_CTRL_SDMRSTB);
rtwn_write_1(sc, R92C_SYS_FUNC_EN,
R92C_SYS_FUNC_EN_USBA | R92C_SYS_FUNC_EN_USBD |
R92C_SYS_FUNC_EN_BB_GLB_RST | R92C_SYS_FUNC_EN_BBRSTB);
r88e_init_bb_common(sc);
}
int
r88eu_power_on(struct rtwn_softc *sc)
{
#define RTWN_CHK(res) do { \
if (res != 0) \
return (EIO); \
} while(0)
int ntries;
/* Wait for power ready bit. */
for (ntries = 0; ntries < 5000; ntries++) {
if (rtwn_read_4(sc, R92C_APS_FSMCO) & R92C_APS_FSMCO_SUS_HOST)
break;
rtwn_delay(sc, 10);
}
if (ntries == 5000) {
device_printf(sc->sc_dev,
"timeout waiting for chip power up\n");
return (ETIMEDOUT);
}
/* Reset BB. */
RTWN_CHK(rtwn_setbits_1(sc, R92C_SYS_FUNC_EN,
R92C_SYS_FUNC_EN_BBRSTB | R92C_SYS_FUNC_EN_BB_GLB_RST, 0));
RTWN_CHK(rtwn_setbits_1(sc, R92C_AFE_XTAL_CTRL + 2, 0, 0x80));
/* Disable HWPDN. */
RTWN_CHK(rtwn_setbits_1_shift(sc, R92C_APS_FSMCO,
R92C_APS_FSMCO_APDM_HPDN, 0, 1));
/* Disable WL suspend. */
RTWN_CHK(rtwn_setbits_1_shift(sc, R92C_APS_FSMCO,
R92C_APS_FSMCO_AFSM_HSUS | R92C_APS_FSMCO_AFSM_PCIE, 0, 1));
RTWN_CHK(rtwn_setbits_1_shift(sc, R92C_APS_FSMCO,
0, R92C_APS_FSMCO_APFM_ONMAC, 1));
for (ntries = 0; ntries < 5000; ntries++) {
if (!(rtwn_read_2(sc, R92C_APS_FSMCO) &
R92C_APS_FSMCO_APFM_ONMAC))
break;
rtwn_delay(sc, 10);
}
if (ntries == 5000)
return (ETIMEDOUT);
/* Enable LDO normal mode. */
RTWN_CHK(rtwn_setbits_1(sc, R92C_LPLDO_CTRL,
R92C_LPLDO_CTRL_SLEEP, 0));
/* Enable MAC DMA/WMAC/SCHEDULE/SEC blocks. */
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_TXDMA_EN |
R92C_CR_HCI_RXDMA_EN | R92C_CR_RXDMA_EN |
R92C_CR_PROTOCOL_EN | R92C_CR_SCHEDULE_EN |
((sc->sc_hwcrypto != RTWN_CRYPTO_SW) ? R92C_CR_ENSEC : 0) |
R92C_CR_CALTMR_EN));
return (0);
#undef RTWN_CHK
}
void
r88eu_power_off(struct rtwn_softc *sc)
{

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/usb/r88eu_reg.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef R88EU_REG_H

View File

@ -1,74 +0,0 @@
/* $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>
*
* 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>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8188e/usb/r88eu_rx.c 307529 2016-10-17 20:38:24Z avos $");
#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_rx_desc.h>
#include <dev/rtwn/rtl8188e/usb/r88eu.h>
int
r88eu_classify_intr(struct rtwn_softc *sc, void *buf, int len)
{
struct r92c_rx_stat *stat = buf;
int report_sel = MS(le32toh(stat->rxdw3), R88E_RXDW3_RPT);
switch (report_sel) {
case R88E_RXDW3_RPT_RX:
return (RTWN_RX_DATA);
case R88E_RXDW3_RPT_TX1: /* per-packet Tx report */
case R88E_RXDW3_RPT_TX2: /* periodical Tx report */
return (RTWN_RX_TX_REPORT);
case R88E_RXDW3_RPT_HIS:
return (RTWN_RX_OTHER);
default: /* shut up the compiler */
return (RTWN_RX_DATA);
}
}

View File

@ -17,7 +17,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/pci/r92ce.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef RTL8192CE_H
@ -60,7 +60,7 @@ void r92ce_post_init(struct rtwn_softc *);
void r92ce_set_led(struct rtwn_softc *, int, int);
/* r92ce_rx.c */
int r92ce_classify_intr(struct rtwn_softc *, void *, int);
int r92ce_get_intr_status(struct rtwn_pci_softc *, int *);
void r92ce_enable_intr(struct rtwn_pci_softc *);
void r92ce_start_xfers(struct rtwn_softc *);

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/pci/r92ce_attach.c 312680 2017-01-24 02:35:38Z kevlo $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -92,7 +92,7 @@ r92ce_postattach(struct rtwn_softc *sc)
}
static void
r92ce_set_name(struct rtwn_softc *sc)
r92ce_set_name(struct rtwn_softc *sc, uint8_t *buf)
{
struct r92c_softc *rs = sc->sc_priv;
@ -117,7 +117,7 @@ r92ce_attach_private(struct rtwn_softc *sc)
rs->rs_tx_enable_ampdu = r92c_tx_enable_ampdu;
rs->rs_tx_setup_hwseq = r92c_tx_setup_hwseq;
rs->rs_tx_setup_macid = r92c_tx_setup_macid;
rs->rs_set_name = r92ce_set_name;
rs->rs_set_rom_opts = r92ce_set_name;
/* XXX TODO: test with net80211 ratectl! */
#ifndef RTWN_WITHOUT_UCODE
@ -155,6 +155,7 @@ r92ce_attach(struct rtwn_pci_softc *pc)
pc->pc_tx_postsetup = r92ce_tx_postsetup;
pc->pc_copy_tx_desc = r92ce_copy_tx_desc;
pc->pc_enable_intr = r92ce_enable_intr;
pc->pc_get_intr_status = r92ce_get_intr_status;
pc->pc_qmap = 0xf771;
pc->tcr =
@ -175,7 +176,7 @@ r92ce_attach(struct rtwn_pci_softc *pc)
sc->sc_get_rx_stats = r92c_get_rx_stats;
sc->sc_get_rssi_cck = r92c_get_rssi_cck;
sc->sc_get_rssi_ofdm = r92c_get_rssi_ofdm;
sc->sc_classify_intr = r92ce_classify_intr;
sc->sc_classify_intr = r92c_classify_intr;
sc->sc_handle_tx_report = rtwn_nop_softc_uint8_int;
sc->sc_handle_c2h_report = rtwn_nop_softc_uint8_int;
sc->sc_check_frame = rtwn_nop_int_softc_mbuf;

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/pci/r92ce_calib.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -75,55 +75,58 @@ r92ce_iq_calib_chain(struct rtwn_softc *sc, int chain, uint16_t tx[2],
uint16_t rx[2])
{
uint32_t status;
int offset = chain * 0x20;
if (chain == 0) { /* IQ calibration for chain 0. */
/* IQ calibration settings for chain 0. */
rtwn_bb_write(sc, 0xe30, 0x10008c1f);
rtwn_bb_write(sc, 0xe34, 0x10008c1f);
rtwn_bb_write(sc, 0xe38, 0x82140102);
rtwn_bb_write(sc, R92C_TX_IQK_TONE(0), 0x10008c1f);
rtwn_bb_write(sc, R92C_RX_IQK_TONE(0), 0x10008c1f);
rtwn_bb_write(sc, R92C_TX_IQK_PI(0), 0x82140102);
if (sc->ntxchains > 1) {
rtwn_bb_write(sc, 0xe3c, 0x28160202); /* 2T */
rtwn_bb_write(sc, R92C_RX_IQK_PI(0), 0x28160202);
/* IQ calibration settings for chain 1. */
rtwn_bb_write(sc, 0xe50, 0x10008c22);
rtwn_bb_write(sc, 0xe54, 0x10008c22);
rtwn_bb_write(sc, 0xe58, 0x82140102);
rtwn_bb_write(sc, 0xe5c, 0x28160202);
rtwn_bb_write(sc, R92C_TX_IQK_TONE(1), 0x10008c22);
rtwn_bb_write(sc, R92C_RX_IQK_TONE(1), 0x10008c22);
rtwn_bb_write(sc, R92C_TX_IQK_PI(1), 0x82140102);
rtwn_bb_write(sc, R92C_RX_IQK_PI(1), 0x28160202);
} else
rtwn_bb_write(sc, 0xe3c, 0x28160502); /* 1T */
rtwn_bb_write(sc, R92C_RX_IQK_PI(0), 0x28160502);
/* LO calibration settings. */
rtwn_bb_write(sc, 0xe4c, 0x001028d1);
rtwn_bb_write(sc, R92C_IQK_AGC_RSP, 0x001028d1);
/* We're doing LO and IQ calibration in one shot. */
rtwn_bb_write(sc, 0xe48, 0xf9000000);
rtwn_bb_write(sc, 0xe48, 0xf8000000);
rtwn_bb_write(sc, R92C_IQK_AGC_PTS, 0xf9000000);
rtwn_bb_write(sc, R92C_IQK_AGC_PTS, 0xf8000000);
} else { /* IQ calibration for chain 1. */
/* We're doing LO and IQ calibration in one shot. */
rtwn_bb_write(sc, 0xe60, 0x00000002);
rtwn_bb_write(sc, 0xe60, 0x00000000);
rtwn_bb_write(sc, R92C_IQK_AGC_CONT, 2);
rtwn_bb_write(sc, R92C_IQK_AGC_CONT, 0);
}
/* Give LO and IQ calibrations the time to complete. */
rtwn_delay(sc, 1000);
/* Read IQ calibration status. */
status = rtwn_bb_read(sc, 0xeac);
status = rtwn_bb_read(sc, R92C_RX_POWER_IQK_AFTER(0));
if (status & (1 << (28 + chain * 3)))
return (0); /* Tx failed. */
/* Read Tx IQ calibration results. */
tx[0] = (rtwn_bb_read(sc, 0xe94 + offset) >> 16) & 0x3ff;
tx[1] = (rtwn_bb_read(sc, 0xe9c + offset) >> 16) & 0x3ff;
tx[0] = MS(rtwn_bb_read(sc, R92C_TX_POWER_IQK_BEFORE(chain)),
R92C_POWER_IQK_RESULT);
tx[1] = MS(rtwn_bb_read(sc, R92C_TX_POWER_IQK_AFTER(chain)),
R92C_POWER_IQK_RESULT);
if (tx[0] == 0x142 || tx[1] == 0x042)
return (0); /* Tx failed. */
if (status & (1 << (27 + chain * 3)))
return (1); /* Rx failed. */
/* Read Rx IQ calibration results. */
rx[0] = (rtwn_bb_read(sc, 0xea4 + offset) >> 16) & 0x3ff;
rx[1] = (rtwn_bb_read(sc, 0xeac + offset) >> 16) & 0x3ff;
rx[0] = MS(rtwn_bb_read(sc, R92C_RX_POWER_IQK_BEFORE(chain)),
R92C_POWER_IQK_RESULT);
rx[1] = MS(rtwn_bb_read(sc, R92C_RX_POWER_IQK_AFTER(chain)),
R92C_POWER_IQK_RESULT);
if (rx[0] == 0x132 || rx[1] == 0x036)
return (1); /* Rx failed. */
@ -200,18 +203,18 @@ r92ce_iq_calib_run(struct rtwn_softc *sc, int n, uint16_t tx[2][2],
if (sc->ntxchains > 1)
rtwn_bb_write(sc, 0x0b6c, 0x00080000);
rtwn_bb_write(sc, 0x0e28, 0x80800000);
rtwn_bb_write(sc, 0x0e40, 0x01007c00);
rtwn_bb_write(sc, 0x0e44, 0x01004800);
rtwn_bb_write(sc, R92C_FPGA0_IQK, 0x80800000);
rtwn_bb_write(sc, R92C_TX_IQK, 0x01007c00);
rtwn_bb_write(sc, R92C_RX_IQK, 0x01004800);
rtwn_bb_write(sc, 0x0b68, 0x00080000);
for (chain = 0; chain < sc->ntxchains; chain++) {
if (chain > 0) {
/* Put chain 0 on standby. */
rtwn_bb_write(sc, 0x0e28, 0x00);
rtwn_bb_write(sc, R92C_FPGA0_IQK, 0);
rtwn_bb_write(sc, R92C_LSSI_PARAM(0), 0x00010000);
rtwn_bb_write(sc, 0x0e28, 0x80800000);
rtwn_bb_write(sc, R92C_FPGA0_IQK, 0x80800000);
/* Enable chain 1. */
for (i = 0; i < nitems(reg_adda); i++)
@ -257,7 +260,7 @@ r92ce_iq_calib_run(struct rtwn_softc *sc, int n, uint16_t tx[2][2],
vals->fpga0_rfifacesw1);
rtwn_bb_write(sc, R92C_OFDM0_TRMUXPAR, vals->ofdm0_trmuxpar);
rtwn_bb_write(sc, 0x0e28, 0x00);
rtwn_bb_write(sc, R92C_FPGA0_IQK, 0);
rtwn_bb_write(sc, R92C_LSSI_PARAM(0), 0x00032ed3);
if (sc->ntxchains > 1)
rtwn_bb_write(sc, R92C_LSSI_PARAM(1), 0x00032ed3);

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/pci/r92ce_fw.c 308380 2016-11-06 17:24:16Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/pci/r92ce_init.c 311347 2017-01-05 02:04:53Z kevlo $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/pci/r92ce_led.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -17,7 +17,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/pci/r92ce_priv.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef R92CE_PRIV_H

View File

@ -17,7 +17,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/pci/r92ce_reg.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef R92CE_REG_H

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/pci/r92ce_rx.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -58,10 +58,10 @@ __FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/pci/r92ce_rx.c 307529 2016
int
r92ce_classify_intr(struct rtwn_softc *sc, void *arg, int len __unused)
r92ce_get_intr_status(struct rtwn_pci_softc *pc, int *rings)
{
struct rtwn_softc *sc = &pc->pc_sc;
uint32_t status;
int *rings = arg;
int ret;
*rings = 0;

View File

@ -17,7 +17,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/pci/r92ce_rx_desc.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef R92CE_RX_DESC_H

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/pci/r92ce_tx.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -17,7 +17,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/pci/r92ce_tx_desc.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef R92CE_TX_DESC_H

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c.h 322950 2017-08-27 13:02:51Z avos $
* $FreeBSD$
*/
#ifndef RTL8192C_H
@ -102,6 +102,7 @@ void r92c_efuse_postread(struct rtwn_softc *);
void r92c_parse_rom(struct rtwn_softc *, uint8_t *);
/* r92c_rx.c */
int r92c_classify_intr(struct rtwn_softc *, void *, int);
int8_t r92c_get_rssi_cck(struct rtwn_softc *, void *);
int8_t r92c_get_rssi_ofdm(struct rtwn_softc *, void *);
uint8_t r92c_rx_radiotap_flags(const void *);

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_attach.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -15,7 +15,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_beacon.c 308389 2016-11-06 23:13:13Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_calib.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -46,16 +46,366 @@ __FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_calib.c 307529 2016-1
#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>
/* Registers to save and restore during IQ calibration. */
struct r92c_iq_cal_reg_vals {
uint32_t adda[16];
uint8_t txpause;
uint8_t bcn_ctrl[2];
uint32_t gpio_muxcfg;
uint32_t cck0_afesetting;
uint32_t ofdm0_trxpathena;
uint32_t ofdm0_trmuxpar;
uint32_t fpga0_rfifacesw0;
uint32_t fpga0_rfifacesw1;
uint32_t fpga0_rfifaceoe0;
uint32_t fpga0_rfifaceoe1;
uint32_t config_ant0;
uint32_t config_ant1;
};
/* XXX TODO: merge */
static int
r92c_iq_calib_chain(struct rtwn_softc *sc, int chain, uint16_t tx[2],
uint16_t rx[2])
{
uint32_t status;
if (chain == 0) { /* IQ calibration for chain 0. */
/* IQ calibration settings for chain 0. */
rtwn_bb_write(sc, R92C_TX_IQK_TONE(0), 0x10008c1f);
rtwn_bb_write(sc, R92C_RX_IQK_TONE(0), 0x10008c1f);
rtwn_bb_write(sc, R92C_TX_IQK_PI(0), 0x82140102);
if (sc->ntxchains > 1) {
rtwn_bb_write(sc, R92C_RX_IQK_PI(0), 0x28160202);
/* IQ calibration settings for chain 1. */
rtwn_bb_write(sc, R92C_TX_IQK_TONE(1), 0x10008c22);
rtwn_bb_write(sc, R92C_RX_IQK_TONE(1), 0x10008c22);
rtwn_bb_write(sc, R92C_TX_IQK_PI(1), 0x82140102);
rtwn_bb_write(sc, R92C_RX_IQK_PI(1), 0x28160202);
} else
rtwn_bb_write(sc, R92C_RX_IQK_PI(0), 0x28160502);
/* LO calibration settings. */
rtwn_bb_write(sc, R92C_IQK_AGC_RSP, 0x001028d1);
/* We're doing LO and IQ calibration in one shot. */
rtwn_bb_write(sc, R92C_IQK_AGC_PTS, 0xf9000000);
rtwn_bb_write(sc, R92C_IQK_AGC_PTS, 0xf8000000);
} else { /* IQ calibration for chain 1. */
/* We're doing LO and IQ calibration in one shot. */
rtwn_bb_write(sc, R92C_IQK_AGC_CONT, 2);
rtwn_bb_write(sc, R92C_IQK_AGC_CONT, 0);
}
/* Give LO and IQ calibrations the time to complete. */
rtwn_delay(sc, 10000);
/* Read IQ calibration status. */
status = rtwn_bb_read(sc, R92C_RX_POWER_IQK_AFTER(0));
if (status & (1 << (28 + chain * 3)))
return (0); /* Tx failed. */
/* Read Tx IQ calibration results. */
tx[0] = MS(rtwn_bb_read(sc, R92C_TX_POWER_IQK_BEFORE(chain)),
R92C_POWER_IQK_RESULT);
tx[1] = MS(rtwn_bb_read(sc, R92C_TX_POWER_IQK_AFTER(chain)),
R92C_POWER_IQK_RESULT);
if (tx[0] == 0x142 || tx[1] == 0x042)
return (0); /* Tx failed. */
if (status & (1 << (27 + chain * 3)))
return (1); /* Rx failed. */
/* Read Rx IQ calibration results. */
rx[0] = MS(rtwn_bb_read(sc, R92C_RX_POWER_IQK_BEFORE(chain)),
R92C_POWER_IQK_RESULT);
rx[1] = MS(rtwn_bb_read(sc, R92C_RX_POWER_IQK_AFTER(chain)),
R92C_POWER_IQK_RESULT);
if (rx[0] == 0x132 || rx[1] == 0x036)
return (1); /* Rx failed. */
return (3); /* Both Tx and Rx succeeded. */
}
static void
r92c_iq_calib_run(struct rtwn_softc *sc, int n, uint16_t tx[2][2],
uint16_t rx[2][2], struct r92c_iq_cal_reg_vals *vals)
{
/* Registers to save and restore during IQ calibration. */
static const uint16_t reg_adda[16] = {
0x85c, 0xe6c, 0xe70, 0xe74,
0xe78, 0xe7c, 0xe80, 0xe84,
0xe88, 0xe8c, 0xed0, 0xed4,
0xed8, 0xedc, 0xee0, 0xeec
};
int i, chain;
uint32_t hssi_param1;
if (n == 0) {
for (i = 0; i < nitems(reg_adda); i++)
vals->adda[i] = rtwn_bb_read(sc, reg_adda[i]);
vals->txpause = rtwn_read_1(sc, R92C_TXPAUSE);
vals->bcn_ctrl[0] = rtwn_read_1(sc, R92C_BCN_CTRL(0));
vals->bcn_ctrl[1] = rtwn_read_1(sc, R92C_BCN_CTRL(1));
vals->gpio_muxcfg = rtwn_read_4(sc, R92C_GPIO_MUXCFG);
}
if (sc->ntxchains == 1) {
rtwn_bb_write(sc, reg_adda[0], 0x0b1b25a0);
for (i = 1; i < nitems(reg_adda); i++)
rtwn_bb_write(sc, reg_adda[i], 0x0bdb25a0);
} else {
for (i = 0; i < nitems(reg_adda); i++)
rtwn_bb_write(sc, reg_adda[i], 0x04db25a4);
}
hssi_param1 = rtwn_bb_read(sc, R92C_HSSI_PARAM1(0));
if (!(hssi_param1 & R92C_HSSI_PARAM1_PI)) {
rtwn_bb_write(sc, R92C_HSSI_PARAM1(0),
hssi_param1 | R92C_HSSI_PARAM1_PI);
rtwn_bb_write(sc, R92C_HSSI_PARAM1(1),
hssi_param1 | R92C_HSSI_PARAM1_PI);
}
if (n == 0) {
vals->cck0_afesetting = rtwn_bb_read(sc, R92C_CCK0_AFESETTING);
vals->ofdm0_trxpathena =
rtwn_bb_read(sc, R92C_OFDM0_TRXPATHENA);
vals->ofdm0_trmuxpar = rtwn_bb_read(sc, R92C_OFDM0_TRMUXPAR);
vals->fpga0_rfifacesw0 =
rtwn_bb_read(sc, R92C_FPGA0_RFIFACESW(0));
vals->fpga0_rfifacesw1 =
rtwn_bb_read(sc, R92C_FPGA0_RFIFACESW(1));
vals->fpga0_rfifaceoe0 =
rtwn_bb_read(sc, R92C_FPGA0_RFIFACEOE(0));
vals->fpga0_rfifaceoe1 =
rtwn_bb_read(sc, R92C_FPGA0_RFIFACEOE(1));
vals->config_ant0 = rtwn_bb_read(sc, R92C_CONFIG_ANT(0));
vals->config_ant1 = rtwn_bb_read(sc, R92C_CONFIG_ANT(1));
}
rtwn_bb_setbits(sc, R92C_CCK0_AFESETTING, 0, 0x0f000000);
rtwn_bb_write(sc, R92C_OFDM0_TRXPATHENA, 0x03a05600);
rtwn_bb_write(sc, R92C_OFDM0_TRMUXPAR, 0x000800e4);
rtwn_bb_write(sc, R92C_FPGA0_RFIFACESW(1), 0x22204000);
rtwn_bb_setbits(sc, R92C_FPGA0_RFIFACESW(0), 0, 0x04000400);
rtwn_bb_setbits(sc, R92C_FPGA0_RFIFACEOE(0), 0x400, 0);
rtwn_bb_setbits(sc, R92C_FPGA0_RFIFACEOE(1), 0x400, 0);
if (sc->ntxchains > 1) {
rtwn_bb_write(sc, R92C_LSSI_PARAM(0), 0x00010000);
rtwn_bb_write(sc, R92C_LSSI_PARAM(1), 0x00010000);
}
rtwn_write_1(sc, R92C_TXPAUSE,
R92C_TX_QUEUE_AC | R92C_TX_QUEUE_MGT | R92C_TX_QUEUE_HIGH);
rtwn_write_1(sc, R92C_BCN_CTRL(0),
vals->bcn_ctrl[0] & ~R92C_BCN_CTRL_EN_BCN);
rtwn_write_1(sc, R92C_BCN_CTRL(1),
vals->bcn_ctrl[1] & ~R92C_BCN_CTRL_EN_BCN);
rtwn_write_1(sc, R92C_GPIO_MUXCFG,
vals->gpio_muxcfg & ~R92C_GPIO_MUXCFG_ENBT);
rtwn_bb_write(sc, R92C_CONFIG_ANT(0), 0x00080000);
if (sc->ntxchains > 1)
rtwn_bb_write(sc, R92C_CONFIG_ANT(1), 0x00080000);
rtwn_bb_write(sc, R92C_FPGA0_IQK, 0x80800000);
rtwn_bb_write(sc, R92C_TX_IQK, 0x01007c00);
rtwn_bb_write(sc, R92C_RX_IQK, 0x01004800);
for (chain = 0; chain < sc->ntxchains; chain++) {
if (chain > 0) {
/* Put chain 0 on standby. */
rtwn_bb_write(sc, R92C_FPGA0_IQK, 0);
rtwn_bb_write(sc, R92C_LSSI_PARAM(0), 0x00010000);
rtwn_bb_write(sc, R92C_FPGA0_IQK, 0x80800000);
/* Enable chain 1. */
for (i = 0; i < nitems(reg_adda); i++)
rtwn_bb_write(sc, reg_adda[i], 0x0b1b25a4);
}
/* Run IQ calibration twice. */
for (i = 0; i < 2; i++) {
int ret;
ret = r92c_iq_calib_chain(sc, chain,
tx[chain], rx[chain]);
if (ret == 0) {
RTWN_DPRINTF(sc, RTWN_DEBUG_CALIB,
"%s: chain %d: Tx failed.\n",
__func__, chain);
tx[chain][0] = 0xff;
tx[chain][1] = 0xff;
rx[chain][0] = 0xff;
rx[chain][1] = 0xff;
} else if (ret == 1) {
RTWN_DPRINTF(sc, RTWN_DEBUG_CALIB,
"%s: chain %d: Rx failed.\n",
__func__, chain);
rx[chain][0] = 0xff;
rx[chain][1] = 0xff;
} else if (ret == 3) {
RTWN_DPRINTF(sc, RTWN_DEBUG_CALIB,
"%s: chain %d: Both Tx and Rx "
"succeeded.\n", __func__, chain);
}
}
RTWN_DPRINTF(sc, RTWN_DEBUG_CALIB,
"%s: results for run %d chain %d: tx[0] 0x%x, "
"tx[1] 0x%x, rx[0] 0x%x, rx[1] 0x%x\n", __func__, n, chain,
tx[chain][0], tx[chain][1], rx[chain][0], rx[chain][1]);
}
rtwn_bb_write(sc, R92C_CCK0_AFESETTING, vals->cck0_afesetting);
rtwn_bb_write(sc, R92C_OFDM0_TRXPATHENA, vals->ofdm0_trxpathena);
rtwn_bb_write(sc, R92C_FPGA0_RFIFACESW(0), vals->fpga0_rfifacesw0);
rtwn_bb_write(sc, R92C_FPGA0_RFIFACESW(1), vals->fpga0_rfifacesw1);
rtwn_bb_write(sc, R92C_OFDM0_TRMUXPAR, vals->ofdm0_trmuxpar);
rtwn_bb_write(sc, R92C_FPGA0_RFIFACEOE(0), vals->fpga0_rfifaceoe0);
rtwn_bb_write(sc, R92C_FPGA0_RFIFACEOE(1), vals->fpga0_rfifaceoe1);
rtwn_bb_write(sc, R92C_CONFIG_ANT(0), vals->config_ant0);
rtwn_bb_write(sc, R92C_CONFIG_ANT(1), vals->config_ant1);
rtwn_bb_write(sc, R92C_FPGA0_IQK, 0);
rtwn_bb_write(sc, R92C_LSSI_PARAM(0), 0x00032ed3);
if (sc->ntxchains > 1)
rtwn_bb_write(sc, R92C_LSSI_PARAM(1), 0x00032ed3);
if (n != 0) {
if (!(hssi_param1 & R92C_HSSI_PARAM1_PI)) {
rtwn_bb_write(sc, R92C_HSSI_PARAM1(0), hssi_param1);
rtwn_bb_write(sc, R92C_HSSI_PARAM1(1), hssi_param1);
}
for (i = 0; i < nitems(reg_adda); i++)
rtwn_bb_write(sc, reg_adda[i], vals->adda[i]);
rtwn_write_1(sc, R92C_TXPAUSE, vals->txpause);
rtwn_write_1(sc, R92C_BCN_CTRL(0), vals->bcn_ctrl[0]);
rtwn_write_1(sc, R92C_BCN_CTRL(1), vals->bcn_ctrl[1]);
rtwn_write_4(sc, R92C_GPIO_MUXCFG, vals->gpio_muxcfg);
rtwn_bb_write(sc, R92C_TX_IQK_TONE(0), 0x01008c00);
rtwn_bb_write(sc, R92C_RX_IQK_TONE(0), 0x01008c00);
}
}
#define RTWN_IQ_CAL_MAX_TOLERANCE 5
static int
r92c_iq_calib_compare_results(struct rtwn_softc *sc, uint16_t tx1[2][2],
uint16_t rx1[2][2], uint16_t tx2[2][2], uint16_t rx2[2][2])
{
int chain, i, tx_ok[2], rx_ok[2];
tx_ok[0] = tx_ok[1] = rx_ok[0] = rx_ok[1] = 0;
for (chain = 0; chain < sc->ntxchains; chain++) {
for (i = 0; i < 2; i++) {
if (tx1[chain][i] == 0xff || tx2[chain][i] == 0xff ||
rx1[chain][i] == 0xff || rx2[chain][i] == 0xff)
continue;
tx_ok[chain] = (abs(tx1[chain][i] - tx2[chain][i]) <=
RTWN_IQ_CAL_MAX_TOLERANCE);
rx_ok[chain] = (abs(rx1[chain][i] - rx2[chain][i]) <=
RTWN_IQ_CAL_MAX_TOLERANCE);
}
}
if (sc->ntxchains > 1)
return (tx_ok[0] && tx_ok[1] && rx_ok[0] && rx_ok[1]);
else
return (tx_ok[0] && rx_ok[0]);
}
#undef RTWN_IQ_CAL_MAX_TOLERANCE
static void
r92c_iq_calib_write_results(struct rtwn_softc *sc, uint16_t tx[2],
uint16_t rx[2], int chain)
{
uint32_t reg, val, x;
long y, tx_c;
if (tx[0] == 0xff || tx[1] == 0xff)
return;
reg = rtwn_bb_read(sc, R92C_OFDM0_TXIQIMBALANCE(chain));
val = ((reg >> 22) & 0x3ff);
x = tx[0];
if (x & 0x00000200)
x |= 0xfffffc00;
reg = (((x * val) >> 8) & 0x3ff);
rtwn_bb_setbits(sc, R92C_OFDM0_TXIQIMBALANCE(chain), 0x3ff, reg);
rtwn_bb_setbits(sc, R92C_OFDM0_ECCATHRESHOLD, 0x80000000,
((x * val) & 0x80) << 24);
y = tx[1];
if (y & 0x00000200)
y |= 0xfffffc00;
tx_c = (y * val) >> 8;
rtwn_bb_setbits(sc, R92C_OFDM0_TXAFE(chain), 0xf0000000,
(tx_c & 0x3c0) << 22);
rtwn_bb_setbits(sc, R92C_OFDM0_TXIQIMBALANCE(chain), 0x003f0000,
(tx_c & 0x3f) << 16);
rtwn_bb_setbits(sc, R92C_OFDM0_ECCATHRESHOLD, 0x20000000,
((y * val) & 0x80) << 22);
if (rx[0] == 0xff || rx[1] == 0xff)
return;
rtwn_bb_setbits(sc, R92C_OFDM0_RXIQIMBALANCE(chain), 0x3ff,
rx[0] & 0x3ff);
rtwn_bb_setbits(sc, R92C_OFDM0_RXIQIMBALANCE(chain), 0xfc00,
(rx[1] & 0x3f) << 10);
if (chain == 0) {
rtwn_bb_setbits(sc, R92C_OFDM0_RXIQEXTANTA, 0xf0000000,
(rx[1] & 0x3c0) << 22);
} else {
rtwn_bb_setbits(sc, R92C_OFDM0_AGCRSSITABLE, 0xf000,
(rx[1] & 0x3c0) << 6);
}
}
#define RTWN_IQ_CAL_NRUN 3
void
r92c_iq_calib(struct rtwn_softc *sc)
{
/* XXX TODO */
struct r92c_iq_cal_reg_vals vals;
uint16_t tx[RTWN_IQ_CAL_NRUN][2][2], rx[RTWN_IQ_CAL_NRUN][2][2];
int n, valid;
valid = 0;
for (n = 0; n < RTWN_IQ_CAL_NRUN; n++) {
r92c_iq_calib_run(sc, n, tx[n], rx[n], &vals);
if (n == 0)
continue;
/* Valid results remain stable after consecutive runs. */
valid = r92c_iq_calib_compare_results(sc, tx[n - 1],
rx[n - 1], tx[n], rx[n]);
if (valid)
break;
}
if (valid) {
r92c_iq_calib_write_results(sc, tx[n][0], rx[n][0], 0);
if (sc->ntxchains > 1)
r92c_iq_calib_write_results(sc, tx[n][1], rx[n][1], 1);
}
}
#undef RTWN_IQ_CAL_NRUN
void
r92c_lc_calib(struct rtwn_softc *sc)

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_chan.c 330750 2018-03-10 23:47:03Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_fw.c 322988 2017-08-28 22:14:16Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_fw_cmd.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef R92C_FW_CMD_H

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_init.c 312680 2017-01-24 02:35:38Z kevlo $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_llt.c 312680 2017-01-24 02:35:38Z kevlo $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_priv.h 322988 2017-08-28 22:14:16Z avos $
* $FreeBSD$
*/
#ifndef R92C_PRIV_H

View File

@ -16,7 +16,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_reg.h 312680 2017-01-24 02:35:38Z kevlo $
* $FreeBSD$
*/
#ifndef R92C_REG_H
@ -66,6 +66,7 @@
#define R92C_HSIMR 0x058
#define R92C_HSISR 0x05c
#define R92C_MULTI_FUNC_CTRL 0x068
#define R92C_AFE_XTAL_CTRL_EXT 0x078
#define R92C_LDO_SWR_CTRL 0x07c
#define R92C_MCUFWDL 0x080
#define R92C_HMEBOX_EXT(idx) (0x088 + (idx) * 2)
@ -347,6 +348,7 @@
/* Bits for R92C_GPIO_MUXCFG. */
#define R92C_GPIO_MUXCFG_ENBT 0x0020
#define R92C_GPIO_MUXCFG_ENSIC 0x1000
/* Bits for R92C_LEDCFG0. */
#define R92C_LEDCFG0_DIS 0x08
@ -691,6 +693,7 @@
#define R92C_FPGA1_TXINFO 0x90c
#define R92C_CCK0_SYSTEM 0xa00
#define R92C_CCK0_AFESETTING 0xa04
#define R92C_CONFIG_ANT(chain) (0xb68 + (chain) * 4)
#define R92C_OFDM0_TRXPATHENA 0xc04
#define R92C_OFDM0_TRMUXPAR 0xc08
#define R92C_OFDM0_RXIQIMBALANCE(chain) (0xc14 + (chain) * 8)
@ -703,6 +706,20 @@
#define R92C_OFDM0_RXIQEXTANTA 0xca0
#define R92C_OFDM0_TXPSEUDONOISEWGT 0xce4
#define R92C_OFDM1_LSTF 0xd00
#define R92C_FPGA0_IQK 0xe28
#define R92C_TX_IQK_TONE(chain) (0xe30 + (chain) * 32)
#define R92C_RX_IQK_TONE(chain) (0xe34 + (chain) * 32)
#define R92C_TX_IQK_PI(chain) (0xe38 + (chain) * 32)
#define R92C_RX_IQK_PI(chain) (0xe3c + (chain) * 32)
#define R92C_TX_IQK 0xe40
#define R92C_RX_IQK 0xe44
#define R92C_IQK_AGC_PTS 0xe48
#define R92C_IQK_AGC_RSP 0xe4c
#define R92C_IQK_AGC_CONT 0xe60
#define R92C_TX_POWER_IQK_BEFORE(chain) (0xe94 + (chain) * 32)
#define R92C_TX_POWER_IQK_AFTER(chain) (0xe9c + (chain) * 32)
#define R92C_RX_POWER_IQK_BEFORE(chain) (0xea4 + (chain) * 32)
#define R92C_RX_POWER_IQK_AFTER(chain) (0xeac + (chain) * 32)
/* Bits for R92C_FPGA[01]_RFMOD. */
#define R92C_RFMOD_40MHZ 0x00000001
@ -828,6 +845,10 @@
#define R92C_OFDM0_AGCCORE1_GAIN_M 0x0000007f
#define R92C_OFDM0_AGCCORE1_GAIN_S 0
/* Bits for R92C_[RT]X_POWER_IQK*. */
#define R92C_POWER_IQK_RESULT_S 16
#define R92C_POWER_IQK_RESULT_M 0x03ff0000
/*
* RF (6052) registers.

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_rf.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_rom.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -96,7 +96,7 @@ r92c_parse_rom(struct rtwn_softc *sc, uint8_t *buf)
__func__, rs->regulatory);
/* Need to be set before postinit() (but after preinit()). */
rtwn_r92c_set_name(sc);
rtwn_r92c_set_rom_opts(sc, buf);
r92c_set_chains(sc);
for (j = 0; j < R92C_GROUP_2G; j++) {

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_rom_defs.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef R92C_ROM_DEFS_H

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_rom_image.h 320055 2017-06-17 14:39:25Z kevlo $
* $FreeBSD$
*/
#ifndef R92C_ROM_IMAGE_H

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_rx.c 331043 2018-03-16 01:03:10Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -52,6 +52,13 @@ __FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_rx.c 331043 2018-03-1
#include <dev/rtwn/rtl8192c/r92c_rx_desc.h>
int
r92c_classify_intr(struct rtwn_softc *sc, void *buf, int len)
{
/* NB: reports are fetched from C2H_MSG register. */
return (RTWN_RX_DATA);
}
int8_t
r92c_get_rssi_cck(struct rtwn_softc *sc, void *physt)
{

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_rx_desc.h 312315 2017-01-17 00:35:23Z avos $
* $FreeBSD$
*/
#ifndef R92C_RX_DESC_H

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_tx.c 322988 2017-08-28 22:14:16Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_tx_desc.h 311948 2017-01-11 23:32:40Z avos $
* $FreeBSD$
*/
#ifndef R92C_TX_DESC_H

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/r92c_var.h 322949 2017-08-27 12:44:56Z avos $
* $FreeBSD$
*/
#ifndef R92C_VAR_H
@ -58,7 +58,7 @@ struct r92c_softc {
void (*rs_tx_enable_ampdu)(void *, int);
void (*rs_tx_setup_hwseq)(void *);
void (*rs_tx_setup_macid)(void *, int);
void (*rs_set_name)(struct rtwn_softc *);
void (*rs_set_rom_opts)(struct rtwn_softc *, uint8_t *);
int rf_read_delay[3];
uint32_t rf_chnlbw[R92C_MAX_CHAINS];
@ -77,7 +77,7 @@ struct r92c_softc {
((R92C_SOFTC(_sc)->rs_tx_setup_hwseq)((_buf)))
#define rtwn_r92c_tx_setup_macid(_sc, _buf, _id) \
((R92C_SOFTC(_sc)->rs_tx_setup_macid)((_buf), (_id)))
#define rtwn_r92c_set_name(_sc) \
((R92C_SOFTC(_sc)->rs_set_name)((_sc)))
#define rtwn_r92c_set_rom_opts(_sc, _buf) \
((R92C_SOFTC(_sc)->rs_set_rom_opts)((_sc), (_buf)))
#endif /* R92C_VAR_H */

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/usb/r92cu.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef RTL8192CU_H
@ -47,7 +47,6 @@ void r92cu_post_init(struct rtwn_softc *);
void r92cu_set_led(struct rtwn_softc *, int, int);
/* r92cu_rx.c */
int r92cu_classify_intr(struct rtwn_softc *, void *, int);
int r92cu_align_rx(int, int);
/* r92cu_tx.c */

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/usb/r92cu_attach.c 312680 2017-01-24 02:35:38Z kevlo $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -94,7 +94,7 @@ r92cu_postattach(struct rtwn_softc *sc)
}
static void
r92cu_set_name(struct rtwn_softc *sc)
r92cu_set_name(struct rtwn_softc *sc, uint8_t *buf)
{
struct r92c_softc *rs = sc->sc_priv;
@ -124,7 +124,7 @@ r92cu_attach_private(struct rtwn_softc *sc)
rs->rs_tx_enable_ampdu = r92c_tx_enable_ampdu;
rs->rs_tx_setup_hwseq = r92c_tx_setup_hwseq;
rs->rs_tx_setup_macid = r92c_tx_setup_macid;
rs->rs_set_name = r92cu_set_name;
rs->rs_set_rom_opts = r92cu_set_name;
#ifndef RTWN_WITHOUT_UCODE
rs->rs_c2h_timeout = hz;
@ -168,7 +168,7 @@ r92cu_attach(struct rtwn_usb_softc *uc)
sc->sc_get_rx_stats = r92c_get_rx_stats;
sc->sc_get_rssi_cck = r92c_get_rssi_cck;
sc->sc_get_rssi_ofdm = r92c_get_rssi_ofdm;
sc->sc_classify_intr = r92cu_classify_intr;
sc->sc_classify_intr = r92c_classify_intr;
sc->sc_handle_tx_report = rtwn_nop_softc_uint8_int;
sc->sc_handle_c2h_report = rtwn_nop_softc_uint8_int;
sc->sc_check_frame = rtwn_nop_int_softc_mbuf;
@ -187,7 +187,7 @@ r92cu_attach(struct rtwn_usb_softc *uc)
sc->sc_llt_init = r92c_llt_init;
sc->sc_set_page_size = r92c_set_page_size;
sc->sc_lc_calib = r92c_lc_calib;
sc->sc_iq_calib = r92c_iq_calib; /* XXX TODO */
sc->sc_iq_calib = r92c_iq_calib;
sc->sc_read_chipid_vendor = r92c_read_chipid_vendor;
sc->sc_adj_devcaps = r92cu_adj_devcaps;
sc->sc_vap_preattach = rtwn_nop_softc_vap;

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/usb/r92cu_init.c 311347 2017-01-05 02:04:53Z kevlo $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/usb/r92cu_led.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/usb/r92cu_priv.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef R92CU_PRIV_H

View File

@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $
* $FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/usb/r92cu_reg.h 307529 2016-10-17 20:38:24Z avos $
* $FreeBSD$
*/
#ifndef R92CU_REG_H

View File

@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/usb/r92cu_rx.c 307529 2016-10-17 20:38:24Z avos $");
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
@ -49,13 +49,6 @@ __FBSDID("$FreeBSD: releng/12.0/sys/dev/rtwn/rtl8192c/usb/r92cu_rx.c 307529 2016
#include <dev/rtwn/rtl8192c/usb/r92cu.h>
int
r92cu_classify_intr(struct rtwn_softc *sc, void *buf, int len)
{
/* NB: reports are fetched from C2H_MSG register. */
return (RTWN_RX_DATA);
}
int
r92cu_align_rx(int totlen, int len)
{

Some files were not shown because too many files have changed in this diff Show More