1 | #include <machine/rtems-bsd-kernel-space.h> |
---|
2 | |
---|
3 | /* $OpenBSD: if_urtwn.c,v 1.16 2011/02/10 17:26:40 jakemsr Exp $ */ |
---|
4 | |
---|
5 | /*- |
---|
6 | * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> |
---|
7 | * Copyright (c) 2014 Kevin Lo <kevlo@FreeBSD.org> |
---|
8 | * Copyright (c) 2015-2016 Andriy Voskoboinyk <avos@FreeBSD.org> |
---|
9 | * |
---|
10 | * Permission to use, copy, modify, and distribute this software for any |
---|
11 | * purpose with or without fee is hereby granted, provided that the above |
---|
12 | * copyright notice and this permission notice appear in all copies. |
---|
13 | * |
---|
14 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
---|
15 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
---|
16 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
---|
17 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
---|
18 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
---|
19 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
---|
20 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
---|
21 | */ |
---|
22 | |
---|
23 | #include <sys/cdefs.h> |
---|
24 | __FBSDID("$FreeBSD$"); |
---|
25 | |
---|
26 | #include <rtems/bsd/local/opt_wlan.h> |
---|
27 | |
---|
28 | #include <rtems/bsd/sys/param.h> |
---|
29 | #include <rtems/bsd/sys/lock.h> |
---|
30 | #include <sys/mutex.h> |
---|
31 | #include <sys/mbuf.h> |
---|
32 | #include <sys/kernel.h> |
---|
33 | #include <sys/socket.h> |
---|
34 | #include <sys/systm.h> |
---|
35 | #include <sys/malloc.h> |
---|
36 | #include <sys/queue.h> |
---|
37 | #include <sys/taskqueue.h> |
---|
38 | #include <sys/bus.h> |
---|
39 | #include <sys/endian.h> |
---|
40 | #include <sys/linker.h> |
---|
41 | |
---|
42 | #include <net/if.h> |
---|
43 | #include <net/ethernet.h> |
---|
44 | #include <net/if_media.h> |
---|
45 | |
---|
46 | #include <net80211/ieee80211_var.h> |
---|
47 | #include <net80211/ieee80211_radiotap.h> |
---|
48 | |
---|
49 | #include <dev/rtwn/if_rtwnreg.h> |
---|
50 | #include <dev/rtwn/if_rtwnvar.h> |
---|
51 | |
---|
52 | #include <dev/rtwn/if_rtwn_debug.h> |
---|
53 | |
---|
54 | #include <dev/rtwn/rtl8192c/r92c_var.h> |
---|
55 | |
---|
56 | #include <dev/rtwn/rtl8188e/r88e.h> |
---|
57 | #include <dev/rtwn/rtl8188e/r88e_priv.h> |
---|
58 | #include <dev/rtwn/rtl8188e/r88e_rom_image.h> |
---|
59 | |
---|
60 | |
---|
61 | void |
---|
62 | r88e_parse_rom(struct rtwn_softc *sc, uint8_t *buf) |
---|
63 | { |
---|
64 | struct r92c_softc *rs = sc->sc_priv; |
---|
65 | struct rtwn_r88e_txpwr *rt = rs->rs_txpwr; |
---|
66 | struct r88e_rom *rom = (struct r88e_rom *)buf; |
---|
67 | int i; |
---|
68 | |
---|
69 | rt->bw20_tx_pwr_diff = RTWN_SIGN4TO8(MS(rom->tx_pwr_diff, HIGH_PART)); |
---|
70 | rt->ofdm_tx_pwr_diff = RTWN_SIGN4TO8(MS(rom->tx_pwr_diff, LOW_PART)); |
---|
71 | for (i = 0; i < nitems(rom->cck_tx_pwr); i++) |
---|
72 | rt->cck_tx_pwr[i] = rom->cck_tx_pwr[i]; |
---|
73 | for (i = 0; i < nitems(rom->ht40_tx_pwr); i++) |
---|
74 | rt->ht40_tx_pwr[i] = rom->ht40_tx_pwr[i]; |
---|
75 | |
---|
76 | rs->crystalcap = RTWN_GET_ROM_VAR(rom->crystalcap, |
---|
77 | R88E_ROM_CRYSTALCAP_DEF); |
---|
78 | rs->regulatory = MS(rom->rf_board_opt, R92C_ROM_RF1_REGULATORY); |
---|
79 | rs->board_type = |
---|
80 | MS(RTWN_GET_ROM_VAR(rom->rf_board_opt, R92C_BOARD_TYPE_DONGLE), |
---|
81 | R92C_ROM_RF1_BOARD_TYPE); |
---|
82 | RTWN_DPRINTF(sc, RTWN_DEBUG_ROM, "%s: regulatory type %d\n", |
---|
83 | __func__,rs->regulatory); |
---|
84 | |
---|
85 | sc->thermal_meter = rom->thermal_meter; |
---|
86 | IEEE80211_ADDR_COPY(sc->sc_ic.ic_macaddr, rom->macaddr); |
---|
87 | } |
---|