122347Spst/* $OpenBSD: if_urtwn.c,v 1.16 2011/02/10 17:26:40 jakemsr Exp $ */ 222347Spst 322347Spst/*- 422347Spst * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> 522347Spst * Copyright (c) 2014 Kevin Lo <kevlo@FreeBSD.org> 622347Spst * Copyright (c) 2016 Andriy Voskoboinyk <avos@FreeBSD.org> 722347Spst * 822347Spst * Permission to use, copy, modify, and distribute this software for any 922347Spst * purpose with or without fee is hereby granted, provided that the above 1092914Smarkm * copyright notice and this permission notice appear in all copies. 1122347Spst * 1222347Spst * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1322347Spst * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1422347Spst * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1522347Spst * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1692914Smarkm * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1722347Spst * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1822347Spst * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1922347Spst */ 2022347Spst 2122347Spst#include <sys/cdefs.h> 2222372Spst#include "opt_wlan.h" 2322347Spst 2422347Spst#include <sys/param.h> 2522347Spst#include <sys/lock.h> 2622347Spst#include <sys/mutex.h> 2722347Spst#include <sys/mbuf.h> 2822347Spst#include <sys/kernel.h> 2922347Spst#include <sys/socket.h> 3022347Spst#include <sys/systm.h> 3122347Spst#include <sys/malloc.h> 3222347Spst#include <sys/queue.h> 3322347Spst#include <sys/taskqueue.h> 3422347Spst#include <sys/bus.h> 3522347Spst#include <sys/endian.h> 3622347Spst#include <sys/linker.h> 3722347Spst 3822347Spst#include <net/if.h> 3922347Spst#include <net/ethernet.h> 4022347Spst#include <net/if_media.h> 4122347Spst 4222347Spst#include <net80211/ieee80211_var.h> 4322347Spst#include <net80211/ieee80211_radiotap.h> 4422347Spst 4522347Spst#include <dev/rtwn/if_rtwnreg.h> 4622347Spst#include <dev/rtwn/if_rtwnvar.h> 4722347Spst 4822347Spst#include <dev/rtwn/rtl8192c/r92c.h> 4922347Spst#include <dev/rtwn/rtl8192c/r92c_reg.h> 5022347Spst#include <dev/rtwn/rtl8192c/r92c_var.h> 5122347Spst 5222347Spstvoid 5322347Spstr92c_detach_private(struct rtwn_softc *sc) 5422347Spst{ 5522347Spst struct r92c_softc *rs = sc->sc_priv; 5622347Spst 5722347Spst free(rs, M_RTWN_PRIV); 5822347Spst} 5922347Spst 6022347Spstvoid 6122347Spstr92c_read_chipid_vendor(struct rtwn_softc *sc, uint32_t reg_sys_cfg) 6222347Spst{ 6322347Spst struct r92c_softc *rs = sc->sc_priv; 6422347Spst 6522347Spst if (reg_sys_cfg & R92C_SYS_CFG_TYPE_92C) { 6692914Smarkm rs->chip |= R92C_CHIP_92C; 6722347Spst /* Check if it is a castrated 8192C. */ 6822347Spst if (MS(rtwn_read_4(sc, R92C_HPON_FSM), 6922347Spst R92C_HPON_FSM_CHIP_BONDING_ID) == 7022372Spst R92C_HPON_FSM_CHIP_BONDING_ID_92C_1T2R) 7122372Spst rs->chip |= R92C_CHIP_92C_1T2R; 7222347Spst } 7322347Spst if (reg_sys_cfg & R92C_SYS_CFG_VENDOR_UMC) { 7422347Spst if (MS(reg_sys_cfg, R92C_SYS_CFG_CHIP_VER_RTL) == 0) 7522347Spst rs->chip |= R92C_CHIP_UMC_A_CUT; 7622372Spst } 7722347Spst} 7822347Spst