The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/rtwn/rtl8192c/r92c_rom.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $OpenBSD: if_urtwn.c,v 1.16 2011/02/10 17:26:40 jakemsr Exp $   */
    2 
    3 /*-
    4  * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
    5  * Copyright (c) 2014 Kevin Lo <kevlo@FreeBSD.org>
    6  * Copyright (c) 2015-2016 Andriy Voskoboinyk <avos@FreeBSD.org>
    7  *
    8  * Permission to use, copy, modify, and distribute this software for any
    9  * purpose with or without fee is hereby granted, provided that the above
   10  * copyright notice and this permission notice appear in all copies.
   11  *
   12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
   13  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
   14  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
   15  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   16  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   17  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   18  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   19  */
   20 
   21 #include <sys/cdefs.h>
   22 __FBSDID("$FreeBSD$");
   23 
   24 #include "opt_wlan.h"
   25 
   26 #include <sys/param.h>
   27 #include <sys/lock.h>
   28 #include <sys/mutex.h>
   29 #include <sys/mbuf.h>
   30 #include <sys/kernel.h>
   31 #include <sys/socket.h>
   32 #include <sys/systm.h>
   33 #include <sys/malloc.h>
   34 #include <sys/queue.h>
   35 #include <sys/taskqueue.h>
   36 #include <sys/bus.h>
   37 #include <sys/endian.h>
   38 #include <sys/linker.h>
   39 
   40 #include <net/if.h>
   41 #include <net/ethernet.h>
   42 #include <net/if_media.h>
   43 
   44 #include <net80211/ieee80211_var.h>
   45 #include <net80211/ieee80211_radiotap.h>
   46 
   47 #include <dev/rtwn/if_rtwnreg.h>
   48 #include <dev/rtwn/if_rtwnvar.h>
   49 
   50 #include <dev/rtwn/if_rtwn_debug.h>
   51 #include <dev/rtwn/if_rtwn_efuse.h>
   52 
   53 #include <dev/rtwn/rtl8192c/r92c.h>
   54 #include <dev/rtwn/rtl8192c/r92c_priv.h>
   55 #include <dev/rtwn/rtl8192c/r92c_var.h>
   56 #include <dev/rtwn/rtl8192c/r92c_rom_image.h>
   57 
   58 static void
   59 r92c_set_chains(struct rtwn_softc *sc)
   60 {
   61         struct r92c_softc *rs = sc->sc_priv;
   62 
   63         if (rs->chip & R92C_CHIP_92C) {
   64                 sc->ntxchains = (rs->chip & R92C_CHIP_92C_1T2R) ? 1 : 2;
   65                 sc->nrxchains = 2;
   66         } else {
   67                 sc->ntxchains = 1;
   68                 sc->nrxchains = 1;
   69         }
   70 }
   71 
   72 void
   73 r92c_efuse_postread(struct rtwn_softc *sc)
   74 {
   75         struct r92c_softc *rs = sc->sc_priv;
   76 
   77         /* XXX Weird but this is what the vendor driver does. */
   78         sc->next_rom_addr = 0x1fa;
   79         (void) rtwn_efuse_read_next(sc, &rs->pa_setting);
   80         RTWN_DPRINTF(sc, RTWN_DEBUG_ROM, "%s: PA setting=0x%x\n", __func__,
   81             rs->pa_setting);
   82 }
   83 
   84 void
   85 r92c_parse_rom(struct rtwn_softc *sc, uint8_t *buf)
   86 {
   87         struct r92c_softc *rs = sc->sc_priv;
   88         struct rtwn_r92c_txpwr *rt = rs->rs_txpwr;
   89         struct r92c_rom *rom = (struct r92c_rom *)buf;
   90         int i, j;
   91 
   92         rs->board_type = MS(rom->rf_opt1, R92C_ROM_RF1_BOARD_TYPE);
   93         rs->regulatory = MS(rom->rf_opt1, R92C_ROM_RF1_REGULATORY);
   94         RTWN_DPRINTF(sc, RTWN_DEBUG_ROM, "%s: regulatory type=%d\n",
   95             __func__, rs->regulatory);
   96 
   97         /* Need to be set before postinit() (but after preinit()). */
   98         rtwn_r92c_set_rom_opts(sc, buf);
   99         r92c_set_chains(sc);
  100 
  101         for (j = 0; j < R92C_GROUP_2G; j++) {
  102                 for (i = 0; i < sc->ntxchains; i++) {
  103                         rt->cck_tx_pwr[i][j] = rom->cck_tx_pwr[i][j];
  104                         rt->ht40_1s_tx_pwr[i][j] = rom->ht40_1s_tx_pwr[i][j];
  105                 }
  106 
  107                 rt->ht40_2s_tx_pwr_diff[0][j] =
  108                     MS(rom->ht40_2s_tx_pwr_diff[j], LOW_PART);
  109                 rt->ht20_tx_pwr_diff[0][j] =
  110                     RTWN_SIGN4TO8(MS(rom->ht20_tx_pwr_diff[j],
  111                         LOW_PART));
  112                 rt->ofdm_tx_pwr_diff[0][j] =
  113                     MS(rom->ofdm_tx_pwr_diff[j], LOW_PART);
  114                 rt->ht40_max_pwr[0][j] =
  115                     MS(rom->ht40_max_pwr[j], LOW_PART);
  116                 rt->ht20_max_pwr[0][j] =
  117                     MS(rom->ht20_max_pwr[j], LOW_PART);
  118 
  119                 if (sc->ntxchains > 1) {
  120                         rt->ht40_2s_tx_pwr_diff[1][j] =
  121                             MS(rom->ht40_2s_tx_pwr_diff[j], HIGH_PART);
  122                         rt->ht20_tx_pwr_diff[1][j] =
  123                             RTWN_SIGN4TO8(MS(rom->ht20_tx_pwr_diff[j],
  124                                 HIGH_PART));
  125                         rt->ofdm_tx_pwr_diff[1][j] =
  126                             MS(rom->ofdm_tx_pwr_diff[j], HIGH_PART);
  127                         rt->ht40_max_pwr[1][j] =
  128                             MS(rom->ht40_max_pwr[j], HIGH_PART);
  129                         rt->ht20_max_pwr[1][j] =
  130                             MS(rom->ht20_max_pwr[j], HIGH_PART);
  131                 }
  132         }
  133 
  134         sc->thermal_meter = MS(rom->thermal_meter, R92C_ROM_THERMAL_METER);
  135         if (sc->thermal_meter == R92C_ROM_THERMAL_METER_M)
  136                 sc->thermal_meter = 0xff;
  137         IEEE80211_ADDR_COPY(sc->sc_ic.ic_macaddr, rom->macaddr);
  138 }

Cache object: ba2ad331fe6973d8362efa3270fbe344


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.