Bug Summary

File:dev/ic/rtw.c
Warning:line 744, column 3
Value stored to 'method' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd7.4 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name rtw.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -relaxed-aliasing -ffp-contract=on -fno-rounding-math -mconstructor-aliases -ffreestanding -mcmodel=kernel -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -target-feature -sse2 -target-feature -sse -target-feature -3dnow -target-feature -mmx -target-feature +save-args -target-feature +retpoline-external-thunk -disable-red-zone -no-implicit-float -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -nostdsysteminc -nobuiltininc -resource-dir /usr/local/llvm16/lib/clang/16 -I /usr/src/sys -I /usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -I /usr/src/sys/arch -I /usr/src/sys/dev/pci/drm/include -I /usr/src/sys/dev/pci/drm/include/uapi -I /usr/src/sys/dev/pci/drm/amd/include/asic_reg -I /usr/src/sys/dev/pci/drm/amd/include -I /usr/src/sys/dev/pci/drm/amd/amdgpu -I /usr/src/sys/dev/pci/drm/amd/display -I /usr/src/sys/dev/pci/drm/amd/display/include -I /usr/src/sys/dev/pci/drm/amd/display/dc -I /usr/src/sys/dev/pci/drm/amd/display/amdgpu_dm -I /usr/src/sys/dev/pci/drm/amd/pm/inc -I /usr/src/sys/dev/pci/drm/amd/pm/legacy-dpm -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/inc -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu11 -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu12 -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu13 -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/inc -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/hwmgr -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/smumgr -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/inc -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/inc/pmfw_if -I /usr/src/sys/dev/pci/drm/amd/display/dc/inc -I /usr/src/sys/dev/pci/drm/amd/display/dc/inc/hw -I /usr/src/sys/dev/pci/drm/amd/display/dc/clk_mgr -I /usr/src/sys/dev/pci/drm/amd/display/modules/inc -I /usr/src/sys/dev/pci/drm/amd/display/modules/hdcp -I /usr/src/sys/dev/pci/drm/amd/display/dmub/inc -I /usr/src/sys/dev/pci/drm/i915 -D DDB -D DIAGNOSTIC -D KTRACE -D ACCOUNTING -D KMEMSTATS -D PTRACE -D POOL_DEBUG -D CRYPTO -D SYSVMSG -D SYSVSEM -D SYSVSHM -D UVM_SWAP_ENCRYPT -D FFS -D FFS2 -D FFS_SOFTUPDATES -D UFS_DIRHASH -D QUOTA -D EXT2FS -D MFS -D NFSCLIENT -D NFSSERVER -D CD9660 -D UDF -D MSDOSFS -D FIFO -D FUSE -D SOCKET_SPLICE -D TCP_ECN -D TCP_SIGNATURE -D INET6 -D IPSEC -D PPP_BSDCOMP -D PPP_DEFLATE -D PIPEX -D MROUTING -D MPLS -D BOOT_CONFIG -D USER_PCICONF -D APERTURE -D MTRR -D NTFS -D SUSPEND -D HIBERNATE -D PCIVERBOSE -D USBVERBOSE -D WSDISPLAY_COMPAT_USL -D WSDISPLAY_COMPAT_RAWKBD -D WSDISPLAY_DEFAULTSCREENS=6 -D X86EMU -D ONEWIREVERBOSE -D MULTIPROCESSOR -D MAXUSERS=80 -D _KERNEL -O2 -Wno-pointer-sign -Wno-address-of-packed-member -Wno-constant-conversion -Wno-unused-but-set-variable -Wno-gnu-folding-constant -fdebug-compilation-dir=/usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fcf-protection=branch -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -o /home/ben/Projects/scan/2024-01-11-110808-61670-1 -x c /usr/src/sys/dev/ic/rtw.c
1/* $OpenBSD: rtw.c,v 1.103 2022/04/21 21:03:02 stsp Exp $ */
2/* $NetBSD: rtw.c,v 1.29 2004/12/27 19:49:16 dyoung Exp $ */
3
4/*-
5 * Copyright (c) 2004, 2005 David Young. All rights reserved.
6 *
7 * Programmed for NetBSD by David Young.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of David Young may not be used to endorse or promote
18 * products derived from this software without specific prior
19 * written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY David Young ``AS IS'' AND ANY
22 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David
25 * Young BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32 * OF SUCH DAMAGE.
33 */
34/*
35 * Device driver for the Realtek RTL8180 802.11 MAC/BBP.
36 */
37
38#include "bpfilter.h"
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/mbuf.h>
43#include <sys/malloc.h>
44#include <sys/kernel.h>
45#include <sys/ioctl.h>
46#include <sys/socket.h>
47#include <sys/time.h>
48#include <sys/endian.h>
49
50#include <machine/bus.h>
51#include <machine/intr.h> /* splnet */
52
53#include <net/if.h>
54#include <net/if_media.h>
55
56#if NBPFILTER1 > 0
57#include <net/bpf.h>
58#endif
59
60#include <netinet/in.h>
61#include <netinet/if_ether.h>
62
63#include <net80211/ieee80211_var.h>
64#include <net80211/ieee80211_radiotap.h>
65
66#include <dev/ic/rtwreg.h>
67#include <dev/ic/rtwvar.h>
68#include <dev/ic/max2820reg.h>
69#include <dev/ic/sa2400reg.h>
70#include <dev/ic/si4136reg.h>
71#include <dev/ic/rtl8225reg.h>
72#include <dev/ic/smc93cx6var.h>
73
74int rtw_rfprog_fallback = 0;
75int rtw_do_chip_reset = 0;
76int rtw_dwelltime = 200; /* milliseconds per channel */
77int rtw_macbangbits_timeout = 100;
78
79#ifdef RTW_DEBUG
80int rtw_debug = 0;
81int rtw_rxbufs_limit = RTW_RXQLEN64;
82#endif /* RTW_DEBUG */
83
84void rtw_start(struct ifnet *);
85void rtw_txdesc_blk_init_all(struct rtw_txdesc_blk *);
86void rtw_txsoft_blk_init_all(struct rtw_txsoft_blk *);
87void rtw_txdesc_blk_init(struct rtw_txdesc_blk *);
88void rtw_txdescs_sync(struct rtw_txdesc_blk *, u_int, u_int, int);
89void rtw_txring_fixup(struct rtw_softc *);
90void rtw_rxbufs_release(bus_dma_tag_t, struct rtw_rxsoft *);
91void rtw_rxdesc_init(struct rtw_rxdesc_blk *, struct rtw_rxsoft *, int, int);
92void rtw_rxring_fixup(struct rtw_softc *);
93void rtw_io_enable(struct rtw_regs *, u_int8_t, int);
94void rtw_intr_rx(struct rtw_softc *, u_int16_t);
95#ifndef IEEE80211_STA_ONLY
96void rtw_intr_beacon(struct rtw_softc *, u_int16_t);
97void rtw_intr_atim(struct rtw_softc *);
98#endif
99void rtw_transmit_config(struct rtw_softc *);
100void rtw_pktfilt_load(struct rtw_softc *);
101void rtw_start(struct ifnet *);
102void rtw_watchdog(struct ifnet *);
103void rtw_next_scan(void *);
104#ifndef IEEE80211_STA_ONLY
105void rtw_recv_mgmt(struct ieee80211com *, struct mbuf *,
106 struct ieee80211_node *, struct ieee80211_rxinfo *, int);
107#endif
108struct ieee80211_node *rtw_node_alloc(struct ieee80211com *);
109void rtw_node_free(struct ieee80211com *, struct ieee80211_node *);
110void rtw_media_status(struct ifnet *, struct ifmediareq *);
111void rtw_txsoft_blk_cleanup_all(struct rtw_softc *);
112void rtw_txdesc_blk_setup(struct rtw_txdesc_blk *, struct rtw_txdesc *,
113 u_int, bus_addr_t, bus_addr_t);
114void rtw_txdesc_blk_setup_all(struct rtw_softc *);
115void rtw_intr_tx(struct rtw_softc *, u_int16_t);
116void rtw_intr_ioerror(struct rtw_softc *, u_int16_t);
117void rtw_intr_timeout(struct rtw_softc *);
118void rtw_stop(struct ifnet *, int);
119void rtw_maxim_pwrstate(struct rtw_regs *, enum rtw_pwrstate, int, int);
120void rtw_philips_pwrstate(struct rtw_regs *, enum rtw_pwrstate, int, int);
121void rtw_rtl_pwrstate(struct rtw_regs *, enum rtw_pwrstate, int, int);
122void rtw_pwrstate0(struct rtw_softc *, enum rtw_pwrstate, int, int);
123void rtw_join_bss(struct rtw_softc *, u_int8_t *, u_int16_t);
124void rtw_set_access1(struct rtw_regs *, enum rtw_access);
125int rtw_srom_parse(struct rtw_softc *);
126int rtw_srom_read(struct rtw_regs *, u_int32_t, struct rtw_srom *,
127 const char *);
128void rtw_set_rfprog(struct rtw_regs *, int, const char *);
129u_int8_t rtw_chan2txpower(struct rtw_srom *, struct ieee80211com *,
130 struct ieee80211_channel *);
131int rtw_txsoft_blk_init(struct rtw_txsoft_blk *);
132int rtw_rxsoft_init_all(bus_dma_tag_t, struct rtw_rxsoft *,
133 int *, const char *);
134void rtw_txsoft_release(bus_dma_tag_t, struct ieee80211com *,
135 struct rtw_txsoft *);
136void rtw_txsofts_release(bus_dma_tag_t, struct ieee80211com *,
137 struct rtw_txsoft_blk *);
138void rtw_hwring_setup(struct rtw_softc *);
139int rtw_swring_setup(struct rtw_softc *);
140void rtw_txdescs_reset(struct rtw_softc *);
141void rtw_rfmd_pwrstate(struct rtw_regs *, enum rtw_pwrstate, int, int);
142int rtw_pwrstate(struct rtw_softc *, enum rtw_pwrstate);
143int rtw_tune(struct rtw_softc *);
144void rtw_set_nettype(struct rtw_softc *, enum ieee80211_opmode);
145int rtw_compute_duration1(int, int, uint32_t, int, struct rtw_duration *);
146int rtw_compute_duration(struct ieee80211_frame *, int, uint32_t, int,
147 int, struct rtw_duration *, struct rtw_duration *, int *, int);
148int rtw_init(struct ifnet *);
149int rtw_ioctl(struct ifnet *, u_long, caddr_t);
150int rtw_seg_too_short(bus_dmamap_t);
151struct mbuf *rtw_dmamap_load_txbuf(bus_dma_tag_t, bus_dmamap_t, struct mbuf *,
152 u_int, short *, const char *);
153int rtw_newstate(struct ieee80211com *, enum ieee80211_state, int);
154int rtw_media_change(struct ifnet *);
155int rtw_txsoft_blk_setup_all(struct rtw_softc *);
156int rtw_rf_attach(struct rtw_softc *, int);
157u_int8_t rtw_check_phydelay(struct rtw_regs *, u_int32_t);
158int rtw_chip_reset1(struct rtw_regs *, const char *);
159int rtw_chip_reset(struct rtw_regs *, const char *);
160int rtw_recall_eeprom(struct rtw_regs *, const char *);
161int rtw_reset(struct rtw_softc *);
162void rtw_reset_oactive(struct rtw_softc *);
163int rtw_txdesc_dmamaps_create(bus_dma_tag_t, struct rtw_txsoft *, u_int);
164int rtw_rxdesc_dmamaps_create(bus_dma_tag_t, struct rtw_rxsoft *, u_int);
165void rtw_rxdesc_dmamaps_destroy(bus_dma_tag_t, struct rtw_rxsoft *, u_int);
166void rtw_txdesc_dmamaps_destroy(bus_dma_tag_t, struct rtw_txsoft *, u_int);
167void rtw_identify_country(struct rtw_regs *, enum rtw_locale *);
168int rtw_identify_sta(struct rtw_regs *, u_int8_t (*)[], const char *);
169void rtw_rxdescs_sync(struct rtw_rxdesc_blk *, int, int, int);
170int rtw_rxsoft_alloc(bus_dma_tag_t, struct rtw_rxsoft *);
171void rtw_collect_txpkt(struct rtw_softc *, struct rtw_txdesc_blk *,
172 struct rtw_txsoft *, int);
173void rtw_collect_txring(struct rtw_softc *, struct rtw_txsoft_blk *,
174 struct rtw_txdesc_blk *, int);
175void rtw_suspend_ticks(struct rtw_softc *);
176void rtw_resume_ticks(struct rtw_softc *);
177void rtw_enable_interrupts(struct rtw_softc *);
178int rtw_dequeue(struct ifnet *, struct rtw_txsoft_blk **,
179 struct rtw_txdesc_blk **, struct mbuf **,
180 struct ieee80211_node **);
181int rtw_txsoft_blk_setup(struct rtw_txsoft_blk *, u_int);
182void rtw_rxdesc_init_all(struct rtw_rxdesc_blk *, struct rtw_rxsoft *,
183 int);
184int rtw_txring_choose(struct rtw_softc *, struct rtw_txsoft_blk **,
185 struct rtw_txdesc_blk **, int);
186u_int rtw_txring_next(struct rtw_regs *, struct rtw_txdesc_blk *);
187struct mbuf *rtw_80211_dequeue(struct rtw_softc *, struct mbuf_queue *, int,
188 struct rtw_txsoft_blk **, struct rtw_txdesc_blk **,
189 struct ieee80211_node **);
190uint64_t rtw_tsf_extend(struct rtw_regs *, u_int32_t);
191#ifndef IEEE80211_STA_ONLY
192void rtw_ibss_merge(struct rtw_softc *, struct ieee80211_node *,
193 u_int32_t);
194#endif
195void rtw_idle(struct rtw_regs *);
196void rtw_led_attach(struct rtw_led_state *, void *);
197void rtw_led_init(struct rtw_regs *);
198void rtw_led_slowblink(void *);
199void rtw_led_fastblink(void *);
200void rtw_led_set(struct rtw_led_state *, struct rtw_regs *, u_int);
201void rtw_led_newstate(struct rtw_softc *, enum ieee80211_state);
202
203int rtw_phy_init(struct rtw_softc *);
204int rtw_bbp_preinit(struct rtw_regs *, u_int, int, u_int);
205int rtw_bbp_init(struct rtw_regs *, struct rtw_bbpset *, int,
206 int, u_int8_t, u_int);
207void rtw_verify_syna(u_int, u_int32_t);
208int rtw_sa2400_pwrstate(struct rtw_softc *, enum rtw_pwrstate);
209int rtw_sa2400_txpower(struct rtw_softc *, u_int8_t);
210int rtw_sa2400_tune(struct rtw_softc *, u_int);
211int rtw_sa2400_vcocal_start(struct rtw_softc *, int);
212int rtw_sa2400_vco_calibration(struct rtw_softc *);
213int rtw_sa2400_filter_calibration(struct rtw_softc *);
214int rtw_sa2400_dc_calibration(struct rtw_softc *);
215int rtw_sa2400_calibrate(struct rtw_softc *, u_int);
216int rtw_sa2400_init(struct rtw_softc *, u_int, u_int8_t,
217 enum rtw_pwrstate);
218int rtw_max2820_pwrstate(struct rtw_softc *, enum rtw_pwrstate);
219int rtw_max2820_init(struct rtw_softc *, u_int, u_int8_t,
220 enum rtw_pwrstate);
221int rtw_max2820_txpower(struct rtw_softc *, u_int8_t);
222int rtw_max2820_tune(struct rtw_softc *, u_int);
223int rtw_rtl8225_pwrstate(struct rtw_softc *, enum rtw_pwrstate);
224int rtw_rtl8225_init(struct rtw_softc *, u_int, u_int8_t,
225 enum rtw_pwrstate);
226int rtw_rtl8225_txpower(struct rtw_softc *, u_int8_t);
227int rtw_rtl8225_tune(struct rtw_softc *, u_int);
228int rtw_rtl8255_pwrstate(struct rtw_softc *, enum rtw_pwrstate);
229int rtw_rtl8255_init(struct rtw_softc *, u_int, u_int8_t,
230 enum rtw_pwrstate);
231int rtw_rtl8255_txpower(struct rtw_softc *, u_int8_t);
232int rtw_rtl8255_tune(struct rtw_softc *, u_int);
233int rtw_grf5101_pwrstate(struct rtw_softc *, enum rtw_pwrstate);
234int rtw_grf5101_init(struct rtw_softc *, u_int, u_int8_t,
235 enum rtw_pwrstate);
236int rtw_grf5101_txpower(struct rtw_softc *, u_int8_t);
237int rtw_grf5101_tune(struct rtw_softc *, u_int);
238int rtw_rf_hostwrite(struct rtw_softc *, u_int, u_int32_t);
239int rtw_rf_macwrite(struct rtw_softc *, u_int, u_int32_t);
240int rtw_bbp_write(struct rtw_regs *, u_int, u_int);
241u_int32_t rtw_grf5101_host_crypt(u_int, u_int32_t);
242u_int32_t rtw_maxim_swizzle(u_int, uint32_t);
243u_int32_t rtw_grf5101_mac_crypt(u_int, u_int32_t);
244void rtw_rf_hostbangbits(struct rtw_regs *, u_int32_t, int, u_int);
245void rtw_rf_rtl8225_hostbangbits(struct rtw_regs *, u_int32_t, int, u_int);
246int rtw_rf_macbangbits(struct rtw_regs *, u_int32_t);
247
248u_int8_t rtw_read8(void *, u_int32_t);
249u_int16_t rtw_read16(void *, u_int32_t);
250u_int32_t rtw_read32(void *, u_int32_t);
251void rtw_write8(void *, u_int32_t, u_int8_t);
252void rtw_write16(void *, u_int32_t, u_int16_t);
253void rtw_write32(void *, u_int32_t, u_int32_t);
254void rtw_barrier(void *, u_int32_t, u_int32_t, int);
255
256#ifdef RTW_DEBUG
257void rtw_print_txdesc(struct rtw_softc *, const char *,
258 struct rtw_txsoft *, struct rtw_txdesc_blk *, int);
259const char *rtw_access_string(enum rtw_access);
260void rtw_dump_rings(struct rtw_softc *);
261void rtw_print_txdesc(struct rtw_softc *, const char *,
262 struct rtw_txsoft *, struct rtw_txdesc_blk *, int);
263#endif
264
265struct cfdriver rtw_cd = {
266 NULL((void *)0), "rtw", DV_IFNET
267};
268
269void
270rtw_continuous_tx_enable(struct rtw_softc *sc, int enable)
271{
272 struct rtw_regs *regs = &sc->sc_regs;
273
274 u_int32_t tcr;
275 tcr = RTW_READ(regs, RTW_TCR)((*(regs)->r_read32)(regs, 0x40));
276 tcr &= ~RTW_TCR_LBK_MASK0x60000;
277 if (enable)
278 tcr |= RTW_TCR_LBK_CONT((3) << ((((u_long)((((((0x60000)) - 1) & ((0x60000
))) ^ ((0x60000)))) >> (16)) != 0) ? 16 + ((((u_long)((
(((((0x60000) >> 16)) - 1) & (((0x60000) >> 16
))) ^ (((0x60000) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0x60000) >> 16) >> 8)) - 1) &
((((0x60000) >> 16) >> 8))) ^ ((((0x60000) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0x60000) >> 16) >> 8) >> 4)) - 1) &
(((((0x60000) >> 16) >> 8) >> 4))) ^ (((((
0x60000) >> 16) >> 8) >> 4)))) >> (2)
) != 0) ? 2 + ((((u_long)((((((((((0x60000) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x60000) >>
16) >> 8) >> 4) >> 2))) ^ ((((((0x60000) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x60000) >> 16) >>
8) >> 4))) - 1) & ((((((0x60000) >> 16) >>
8) >> 4)))) ^ ((((((0x60000) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
) >> 16) >> 8))) - 1) & (((((0x60000) >>
16) >> 8)))) ^ (((((0x60000) >> 16) >> 8))
))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x60000) >>
16) >> 8)) >> 2)) - 1) & ((((((0x60000) >>
16) >> 8)) >> 2))) ^ ((((((0x60000) >> 16)
>> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x60000) >> 16) >> 8)))) - 1)
& ((((((0x60000) >> 16) >> 8))))) ^ ((((((0x60000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x60000) >> 16))) - 1) & (((
(0x60000) >> 16)))) ^ ((((0x60000) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x60000) >> 16)) >>
4)) - 1) & (((((0x60000) >> 16)) >> 4))) ^ (
((((0x60000) >> 16)) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x60000) >> 16)) >> 4
) >> 2)) - 1) & ((((((0x60000) >> 16)) >>
4) >> 2))) ^ ((((((0x60000) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000
) >> 16)) >> 4))) - 1) & ((((((0x60000) >>
16)) >> 4)))) ^ ((((((0x60000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
) >> 16)))) - 1) & (((((0x60000) >> 16))))) ^
(((((0x60000) >> 16)))))) >> (2)) != 0) ? 2 + ((
((u_long)((((((((((0x60000) >> 16))) >> 2)) - 1) &
((((((0x60000) >> 16))) >> 2))) ^ ((((((0x60000)
>> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x60000) >> 16))))) - 1) & ((
((((0x60000) >> 16)))))) ^ ((((((0x60000) >> 16))
))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x60000
))) - 1) & (((0x60000)))) ^ (((0x60000))))) >> (8))
!= 0) ? 8 + ((((u_long)((((((((0x60000)) >> 8)) - 1) &
((((0x60000)) >> 8))) ^ ((((0x60000)) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x60000)) >> 8) >>
4)) - 1) & (((((0x60000)) >> 8) >> 4))) ^ ((
(((0x60000)) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x60000)) >> 8) >> 4) >>
2)) - 1) & ((((((0x60000)) >> 8) >> 4) >>
2))) ^ ((((((0x60000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000
)) >> 8) >> 4))) - 1) & ((((((0x60000)) >>
8) >> 4)))) ^ ((((((0x60000)) >> 8) >> 4))
))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
)) >> 8))) - 1) & (((((0x60000)) >> 8)))) ^ (
((((0x60000)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x60000)) >> 8)) >> 2)) - 1) & (((
(((0x60000)) >> 8)) >> 2))) ^ ((((((0x60000)) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x60000)) >> 8)))) - 1) & ((((((0x60000)
) >> 8))))) ^ ((((((0x60000)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x60000)))) - 1) &
((((0x60000))))) ^ ((((0x60000)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x60000))) >> 4)) - 1) & (((
((0x60000))) >> 4))) ^ (((((0x60000))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x60000))) >> 4)
>> 2)) - 1) & ((((((0x60000))) >> 4) >>
2))) ^ ((((((0x60000))) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000))) >>
4))) - 1) & ((((((0x60000))) >> 4)))) ^ ((((((0x60000
))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x60000))))) - 1) & (((((0x60000)))))) ^ (((((0x60000
))))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x60000
)))) >> 2)) - 1) & ((((((0x60000)))) >> 2))) ^
((((((0x60000)))) >> 2)))) >> (1)) != 0) ? 1 : 0
) : ((((u_long)((((((((((0x60000)))))) - 1) & ((((((0x60000
))))))) ^ ((((((0x60000)))))))) >> (1)) != 0) ? 1 : 0))
))))
;
279 else
280 tcr |= RTW_TCR_LBK_NORMAL((0) << ((((u_long)((((((0x60000)) - 1) & ((0x60000
))) ^ ((0x60000)))) >> (16)) != 0) ? 16 + ((((u_long)((
(((((0x60000) >> 16)) - 1) & (((0x60000) >> 16
))) ^ (((0x60000) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0x60000) >> 16) >> 8)) - 1) &
((((0x60000) >> 16) >> 8))) ^ ((((0x60000) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0x60000) >> 16) >> 8) >> 4)) - 1) &
(((((0x60000) >> 16) >> 8) >> 4))) ^ (((((
0x60000) >> 16) >> 8) >> 4)))) >> (2)
) != 0) ? 2 + ((((u_long)((((((((((0x60000) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x60000) >>
16) >> 8) >> 4) >> 2))) ^ ((((((0x60000) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x60000) >> 16) >>
8) >> 4))) - 1) & ((((((0x60000) >> 16) >>
8) >> 4)))) ^ ((((((0x60000) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
) >> 16) >> 8))) - 1) & (((((0x60000) >>
16) >> 8)))) ^ (((((0x60000) >> 16) >> 8))
))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x60000) >>
16) >> 8)) >> 2)) - 1) & ((((((0x60000) >>
16) >> 8)) >> 2))) ^ ((((((0x60000) >> 16)
>> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x60000) >> 16) >> 8)))) - 1)
& ((((((0x60000) >> 16) >> 8))))) ^ ((((((0x60000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x60000) >> 16))) - 1) & (((
(0x60000) >> 16)))) ^ ((((0x60000) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x60000) >> 16)) >>
4)) - 1) & (((((0x60000) >> 16)) >> 4))) ^ (
((((0x60000) >> 16)) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x60000) >> 16)) >> 4
) >> 2)) - 1) & ((((((0x60000) >> 16)) >>
4) >> 2))) ^ ((((((0x60000) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000
) >> 16)) >> 4))) - 1) & ((((((0x60000) >>
16)) >> 4)))) ^ ((((((0x60000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
) >> 16)))) - 1) & (((((0x60000) >> 16))))) ^
(((((0x60000) >> 16)))))) >> (2)) != 0) ? 2 + ((
((u_long)((((((((((0x60000) >> 16))) >> 2)) - 1) &
((((((0x60000) >> 16))) >> 2))) ^ ((((((0x60000)
>> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x60000) >> 16))))) - 1) & ((
((((0x60000) >> 16)))))) ^ ((((((0x60000) >> 16))
))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x60000
))) - 1) & (((0x60000)))) ^ (((0x60000))))) >> (8))
!= 0) ? 8 + ((((u_long)((((((((0x60000)) >> 8)) - 1) &
((((0x60000)) >> 8))) ^ ((((0x60000)) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x60000)) >> 8) >>
4)) - 1) & (((((0x60000)) >> 8) >> 4))) ^ ((
(((0x60000)) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x60000)) >> 8) >> 4) >>
2)) - 1) & ((((((0x60000)) >> 8) >> 4) >>
2))) ^ ((((((0x60000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000
)) >> 8) >> 4))) - 1) & ((((((0x60000)) >>
8) >> 4)))) ^ ((((((0x60000)) >> 8) >> 4))
))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
)) >> 8))) - 1) & (((((0x60000)) >> 8)))) ^ (
((((0x60000)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x60000)) >> 8)) >> 2)) - 1) & (((
(((0x60000)) >> 8)) >> 2))) ^ ((((((0x60000)) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x60000)) >> 8)))) - 1) & ((((((0x60000)
) >> 8))))) ^ ((((((0x60000)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x60000)))) - 1) &
((((0x60000))))) ^ ((((0x60000)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x60000))) >> 4)) - 1) & (((
((0x60000))) >> 4))) ^ (((((0x60000))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x60000))) >> 4)
>> 2)) - 1) & ((((((0x60000))) >> 4) >>
2))) ^ ((((((0x60000))) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000))) >>
4))) - 1) & ((((((0x60000))) >> 4)))) ^ ((((((0x60000
))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x60000))))) - 1) & (((((0x60000)))))) ^ (((((0x60000
))))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x60000
)))) >> 2)) - 1) & ((((((0x60000)))) >> 2))) ^
((((((0x60000)))) >> 2)))) >> (1)) != 0) ? 1 : 0
) : ((((u_long)((((((((((0x60000)))))) - 1) & ((((((0x60000
))))))) ^ ((((((0x60000)))))))) >> (1)) != 0) ? 1 : 0))
))))
;
281 RTW_WRITE(regs, RTW_TCR, tcr)((*(regs)->r_write32)(regs, 0x40, tcr));
282 RTW_SYNC(regs, RTW_TCR, RTW_TCR)((*(regs)->r_barrier)(regs, 0x40, 0x40, (0x01|0x02)));
283 rtw_set_access(regs, RTW_ACCESS_ANAPARM);
284 rtw_txdac_enable(sc, !enable);
285 rtw_set_access(regs, RTW_ACCESS_ANAPARM);/* XXX Voodoo from Linux. */
286 rtw_set_access(regs, RTW_ACCESS_NONE);
287}
288
289#ifdef RTW_DEBUG
290const char *
291rtw_access_string(enum rtw_access access)
292{
293 switch (access) {
294 case RTW_ACCESS_NONE:
295 return "none";
296 case RTW_ACCESS_CONFIG:
297 return "config";
298 case RTW_ACCESS_ANAPARM:
299 return "anaparm";
300 default:
301 return "unknown";
302 }
303}
304#endif
305
306void
307rtw_set_access1(struct rtw_regs *regs, enum rtw_access naccess)
308{
309 KASSERT(naccess >= RTW_ACCESS_NONE && naccess <= RTW_ACCESS_ANAPARM)((naccess >= RTW_ACCESS_NONE && naccess <= RTW_ACCESS_ANAPARM
) ? (void)0 : __assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c"
, 309, "naccess >= RTW_ACCESS_NONE && naccess <= RTW_ACCESS_ANAPARM"
))
;
310 KASSERT(regs->r_access >= RTW_ACCESS_NONE &&((regs->r_access >= RTW_ACCESS_NONE && regs->
r_access <= RTW_ACCESS_ANAPARM) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 311, "regs->r_access >= RTW_ACCESS_NONE && regs->r_access <= RTW_ACCESS_ANAPARM"
))
311 regs->r_access <= RTW_ACCESS_ANAPARM)((regs->r_access >= RTW_ACCESS_NONE && regs->
r_access <= RTW_ACCESS_ANAPARM) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 311, "regs->r_access >= RTW_ACCESS_NONE && regs->r_access <= RTW_ACCESS_ANAPARM"
))
;
312
313 if (naccess == regs->r_access)
314 return;
315
316 switch (naccess) {
317 case RTW_ACCESS_NONE:
318 switch (regs->r_access) {
319 case RTW_ACCESS_ANAPARM:
320 rtw_anaparm_enable(regs, 0);
321 /*FALLTHROUGH*/
322 case RTW_ACCESS_CONFIG:
323 rtw_config0123_enable(regs, 0);
324 /*FALLTHROUGH*/
325 case RTW_ACCESS_NONE:
326 break;
327 }
328 break;
329 case RTW_ACCESS_CONFIG:
330 switch (regs->r_access) {
331 case RTW_ACCESS_NONE:
332 rtw_config0123_enable(regs, 1);
333 /*FALLTHROUGH*/
334 case RTW_ACCESS_CONFIG:
335 break;
336 case RTW_ACCESS_ANAPARM:
337 rtw_anaparm_enable(regs, 0);
338 break;
339 }
340 break;
341 case RTW_ACCESS_ANAPARM:
342 switch (regs->r_access) {
343 case RTW_ACCESS_NONE:
344 rtw_config0123_enable(regs, 1);
345 /*FALLTHROUGH*/
346 case RTW_ACCESS_CONFIG:
347 rtw_anaparm_enable(regs, 1);
348 /*FALLTHROUGH*/
349 case RTW_ACCESS_ANAPARM:
350 break;
351 }
352 break;
353 }
354}
355
356void
357rtw_set_access(struct rtw_regs *regs, enum rtw_access access)
358{
359 rtw_set_access1(regs, access);
360 RTW_DPRINTF(RTW_DEBUG_ACCESS,
361 ("%s: access %s -> %s\n",__func__,
362 rtw_access_string(regs->r_access),
363 rtw_access_string(access)));
364 regs->r_access = access;
365}
366
367/*
368 * Enable registers, switch register banks.
369 */
370void
371rtw_config0123_enable(struct rtw_regs *regs, int enable)
372{
373 u_int8_t ecr;
374 ecr = RTW_READ8(regs, RTW_9346CR)((*(regs)->r_read8)(regs, 0x50));
375 ecr &= ~(RTW_9346CR_EEM_MASK0xc0 | RTW_9346CR_EECS(1<<3) | RTW_9346CR_EESK(1<<2));
376 if (enable)
377 ecr |= RTW_9346CR_EEM_CONFIG((3) << ((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ (
(0xc0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc0)
>> 16)) - 1) & (((0xc0) >> 16))) ^ (((0xc0) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >>
16) >> 8)) - 1) & ((((0xc0) >> 16) >> 8
))) ^ ((((0xc0) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0) >> 16) >> 8) >>
4)) - 1) & (((((0xc0) >> 16) >> 8) >> 4
))) ^ (((((0xc0) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc0) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc0) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4))) - 1) & ((((((0xc0) >> 16) >>
8) >> 4)))) ^ ((((((0xc0) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0
) >> 16) >> 8))) - 1) & (((((0xc0) >> 16
) >> 8)))) ^ (((((0xc0) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
378 else {
379 RTW_WBW(regs, RTW_9346CR, MAX(RTW_CONFIG0, RTW_CONFIG3))((*(regs)->r_barrier)(regs, 0x50, (((0x51)>(0x59))?(0x51
):(0x59)), 0x02))
;
380 ecr |= RTW_9346CR_EEM_NORMAL((0) << ((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ (
(0xc0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc0)
>> 16)) - 1) & (((0xc0) >> 16))) ^ (((0xc0) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >>
16) >> 8)) - 1) & ((((0xc0) >> 16) >> 8
))) ^ ((((0xc0) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0) >> 16) >> 8) >>
4)) - 1) & (((((0xc0) >> 16) >> 8) >> 4
))) ^ (((((0xc0) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc0) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc0) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4))) - 1) & ((((((0xc0) >> 16) >>
8) >> 4)))) ^ ((((((0xc0) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0
) >> 16) >> 8))) - 1) & (((((0xc0) >> 16
) >> 8)))) ^ (((((0xc0) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
381 }
382 RTW_WRITE8(regs, RTW_9346CR, ecr)((*(regs)->r_write8)(regs, 0x50, ecr));
383 RTW_SYNC(regs, RTW_9346CR, RTW_9346CR)((*(regs)->r_barrier)(regs, 0x50, 0x50, (0x01|0x02)));
384}
385
386/* requires rtw_config0123_enable(, 1) */
387void
388rtw_anaparm_enable(struct rtw_regs *regs, int enable)
389{
390 u_int8_t cfg3;
391
392 cfg3 = RTW_READ8(regs, RTW_CONFIG3)((*(regs)->r_read8)(regs, 0x59));
393 cfg3 |= RTW_CONFIG3_CLKRUNEN(1<<2);
394 if (enable)
395 cfg3 |= RTW_CONFIG3_PARMEN(1<<6);
396 else
397 cfg3 &= ~RTW_CONFIG3_PARMEN(1<<6);
398 RTW_WRITE8(regs, RTW_CONFIG3, cfg3)((*(regs)->r_write8)(regs, 0x59, cfg3));
399 RTW_SYNC(regs, RTW_CONFIG3, RTW_CONFIG3)((*(regs)->r_barrier)(regs, 0x59, 0x59, (0x01|0x02)));
400}
401
402/* requires rtw_anaparm_enable(, 1) */
403void
404rtw_txdac_enable(struct rtw_softc *sc, int enable)
405{
406 u_int32_t anaparm;
407 struct rtw_regs *regs = &sc->sc_regs;
408
409 anaparm = RTW_READ(regs, RTW_ANAPARM_0)((*(regs)->r_read32)(regs, 0x54));
410 if (enable)
411 anaparm &= ~RTW_ANAPARM_TXDACOFF(1<<27);
412 else
413 anaparm |= RTW_ANAPARM_TXDACOFF(1<<27);
414 RTW_WRITE(regs, RTW_ANAPARM_0, anaparm)((*(regs)->r_write32)(regs, 0x54, anaparm));
415 RTW_SYNC(regs, RTW_ANAPARM_0, RTW_ANAPARM_0)((*(regs)->r_barrier)(regs, 0x54, 0x54, (0x01|0x02)));
416}
417
418int
419rtw_chip_reset1(struct rtw_regs *regs, const char *dvname)
420{
421 u_int8_t cr;
422 int i;
423
424 RTW_WRITE8(regs, RTW_CR, RTW_CR_RST)((*(regs)->r_write8)(regs, 0x37, (1<<4)));
425
426 RTW_WBR(regs, RTW_CR, RTW_CR)((*(regs)->r_barrier)(regs, 0x37, 0x37, 0x02));
427
428 for (i = 0; i < 1000; i++) {
429 if ((cr = RTW_READ8(regs, RTW_CR)((*(regs)->r_read8)(regs, 0x37)) & RTW_CR_RST(1<<4)) == 0) {
430 RTW_DPRINTF(RTW_DEBUG_RESET,
431 ("%s: reset in %dus\n", dvname, i));
432 return 0;
433 }
434 RTW_RBR(regs, RTW_CR, RTW_CR)((*(regs)->r_barrier)(regs, 0x37, 0x37, 0x01));
435 DELAY(10)(*delay_func)(10); /* 10us */
436 }
437
438 printf("\n%s: reset failed\n", dvname);
439 return ETIMEDOUT60;
440}
441
442int
443rtw_chip_reset(struct rtw_regs *regs, const char *dvname)
444{
445 uint32_t tcr;
446
447 /* from Linux driver */
448 tcr = RTW_TCR_CWMIN(1<<31) | RTW_TCR_MXDMA_2048((7) << ((((u_long)((((((0xe00000)) - 1) & ((0xe00000
))) ^ ((0xe00000)))) >> (16)) != 0) ? 16 + ((((u_long)(
((((((0xe00000) >> 16)) - 1) & (((0xe00000) >>
16))) ^ (((0xe00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0xe00000) >> 16) >> 8)) - 1
) & ((((0xe00000) >> 16) >> 8))) ^ ((((0xe00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xe00000) >> 16) >> 8) >> 4)) - 1
) & (((((0xe00000) >> 16) >> 8) >> 4)))
^ (((((0xe00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xe00000) >> 16)
>> 8) >> 4) >> 2)) - 1) & ((((((0xe00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xe00000) >> 16) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xe00000
) >> 16) >> 8) >> 4)))) ^ ((((((0xe00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xe00000) >> 16) >> 8))) -
1) & (((((0xe00000) >> 16) >> 8)))) ^ (((((0xe00000
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xe00000) >> 16) >> 8)) >>
2)) - 1) & ((((((0xe00000) >> 16) >> 8)) >>
2))) ^ ((((((0xe00000) >> 16) >> 8)) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000
) >> 16) >> 8)))) - 1) & ((((((0xe00000) >>
16) >> 8))))) ^ ((((((0xe00000) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xe00000
) >> 16))) - 1) & ((((0xe00000) >> 16)))) ^ (
(((0xe00000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xe00000) >> 16)) >> 4)) - 1) & (((
((0xe00000) >> 16)) >> 4))) ^ (((((0xe00000) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xe00000) >> 16)) >> 4) >> 2)) - 1) &
((((((0xe00000) >> 16)) >> 4) >> 2))) ^ ((
((((0xe00000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000) >>
16)) >> 4))) - 1) & ((((((0xe00000) >> 16)) >>
4)))) ^ ((((((0xe00000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe00000) >>
16)))) - 1) & (((((0xe00000) >> 16))))) ^ (((((0xe00000
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0xe00000) >> 16))) >> 2)) - 1) & ((((((
0xe00000) >> 16))) >> 2))) ^ ((((((0xe00000) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xe00000) >> 16))))) - 1) & ((((((0xe00000
) >> 16)))))) ^ ((((((0xe00000) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xe00000))) - 1) &
(((0xe00000)))) ^ (((0xe00000))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0xe00000)) >> 8)) - 1) & ((((0xe00000
)) >> 8))) ^ ((((0xe00000)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xe00000)) >> 8) >>
4)) - 1) & (((((0xe00000)) >> 8) >> 4))) ^ (
((((0xe00000)) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xe00000)) >> 8) >> 4
) >> 2)) - 1) & ((((((0xe00000)) >> 8) >>
4) >> 2))) ^ ((((((0xe00000)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000
)) >> 8) >> 4))) - 1) & ((((((0xe00000)) >>
8) >> 4)))) ^ ((((((0xe00000)) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe00000
)) >> 8))) - 1) & (((((0xe00000)) >> 8)))) ^ (
((((0xe00000)) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xe00000)) >> 8)) >> 2)) - 1) &
((((((0xe00000)) >> 8)) >> 2))) ^ ((((((0xe00000
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xe00000)) >> 8)))) - 1) & ((
((((0xe00000)) >> 8))))) ^ ((((((0xe00000)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xe00000
)))) - 1) & ((((0xe00000))))) ^ ((((0xe00000)))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xe00000))) >> 4)
) - 1) & (((((0xe00000))) >> 4))) ^ (((((0xe00000))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xe00000))) >> 4) >> 2)) - 1) & ((((((0xe00000
))) >> 4) >> 2))) ^ ((((((0xe00000))) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0xe00000))) >> 4))) - 1) & ((((((0xe00000)))
>> 4)))) ^ ((((((0xe00000))) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe00000))))) - 1) &
(((((0xe00000)))))) ^ (((((0xe00000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0xe00000)))) >> 2)) - 1) &
((((((0xe00000)))) >> 2))) ^ ((((((0xe00000)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000
)))))) - 1) & ((((((0xe00000))))))) ^ ((((((0xe00000)))))
))) >> (1)) != 0) ? 1 : 0))))))
|
449 LSHIFT(7, RTW_TCR_SRL_MASK)((7) << ((((u_long)((((((0xff00)) - 1) & ((0xff00))
) ^ ((0xff00)))) >> (16)) != 0) ? 16 + ((((u_long)(((((
((0xff00) >> 16)) - 1) & (((0xff00) >> 16))) ^
(((0xff00) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xff00) >> 16) >> 8)) - 1) & ((((0xff00
) >> 16) >> 8))) ^ ((((0xff00) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff00) >>
16) >> 8) >> 4)) - 1) & (((((0xff00) >>
16) >> 8) >> 4))) ^ (((((0xff00) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff00) >> 16) >> 8) >> 4) >> 2)
) - 1) & ((((((0xff00) >> 16) >> 8) >> 4
) >> 2))) ^ ((((((0xff00) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xff00) >> 16) >> 8) >> 4))) - 1)
& ((((((0xff00) >> 16) >> 8) >> 4)))) ^
((((((0xff00) >> 16) >> 8) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00) >> 16
) >> 8))) - 1) & (((((0xff00) >> 16) >>
8)))) ^ (((((0xff00) >> 16) >> 8))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0xff00) >> 16) >>
8)) >> 2)) - 1) & ((((((0xff00) >> 16) >>
8)) >> 2))) ^ ((((((0xff00) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
) >> 16) >> 8)))) - 1) & ((((((0xff00) >>
16) >> 8))))) ^ ((((((0xff00) >> 16) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff00
) >> 16))) - 1) & ((((0xff00) >> 16)))) ^ (((
(0xff00) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xff00) >> 16)) >> 4)) - 1) & (((((
0xff00) >> 16)) >> 4))) ^ (((((0xff00) >> 16
)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((
((((0xff00) >> 16)) >> 4) >> 2)) - 1) &
((((((0xff00) >> 16)) >> 4) >> 2))) ^ ((((
((0xff00) >> 16)) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00) >> 16
)) >> 4))) - 1) & ((((((0xff00) >> 16)) >>
4)))) ^ ((((((0xff00) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00) >> 16
)))) - 1) & (((((0xff00) >> 16))))) ^ (((((0xff00) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00
) >> 16))) >> 2)) - 1) & ((((((0xff00) >>
16))) >> 2))) ^ ((((((0xff00) >> 16))) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
) >> 16))))) - 1) & ((((((0xff00) >> 16))))))
^ ((((((0xff00) >> 16))))))) >> (1)) != 0) ? 1 :
0)))) : ((((u_long)(((((((0xff00))) - 1) & (((0xff00))))
^ (((0xff00))))) >> (8)) != 0) ? 8 + ((((u_long)((((((
((0xff00)) >> 8)) - 1) & ((((0xff00)) >> 8)))
^ ((((0xff00)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0xff00)) >> 8) >> 4)) - 1) & (
((((0xff00)) >> 8) >> 4))) ^ (((((0xff00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff00)) >> 8) >> 4) >> 2)) - 1) &
((((((0xff00)) >> 8) >> 4) >> 2))) ^ (((((
(0xff00)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8) >>
4))) - 1) & ((((((0xff00)) >> 8) >> 4)))) ^ (
(((((0xff00)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xff00)) >> 8))) - 1) &
(((((0xff00)) >> 8)))) ^ (((((0xff00)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00)) >>
8)) >> 2)) - 1) & ((((((0xff00)) >> 8)) >>
2))) ^ ((((((0xff00)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8
)))) - 1) & ((((((0xff00)) >> 8))))) ^ ((((((0xff00
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00)))) - 1) & ((((0xff00))))) ^ ((((0xff00))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff00))) >>
4)) - 1) & (((((0xff00))) >> 4))) ^ (((((0xff00)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xff00))) >> 4) >> 2)) - 1) & ((((((0xff00)
)) >> 4) >> 2))) ^ ((((((0xff00))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
))) >> 4))) - 1) & ((((((0xff00))) >> 4)))) ^
((((((0xff00))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff00))))) - 1) & (((((0xff00)))
))) ^ (((((0xff00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00)))) >> 2)) - 1) & ((((((0xff00)))
) >> 2))) ^ ((((((0xff00)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)))))) - 1) &
((((((0xff00))))))) ^ ((((((0xff00)))))))) >> (1)) != 0
) ? 1 : 0))))))
| LSHIFT(7, RTW_TCR_LRL_MASK)((7) << ((((u_long)((((((0xff)) - 1) & ((0xff))) ^ (
(0xff)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xff)
>> 16)) - 1) & (((0xff) >> 16))) ^ (((0xff) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xff) >>
16) >> 8)) - 1) & ((((0xff) >> 16) >> 8
))) ^ ((((0xff) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xff) >> 16) >> 8) >>
4)) - 1) & (((((0xff) >> 16) >> 8) >> 4
))) ^ (((((0xff) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xff) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xff) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16) >>
8) >> 4))) - 1) & ((((((0xff) >> 16) >>
8) >> 4)))) ^ ((((((0xff) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff
) >> 16) >> 8))) - 1) & (((((0xff) >> 16
) >> 8)))) ^ (((((0xff) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >> 16) >>
8)) >> 2)) - 1) & ((((((0xff) >> 16) >>
8)) >> 2))) ^ ((((((0xff) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
) >> 16) >> 8)))) - 1) & ((((((0xff) >>
16) >> 8))))) ^ ((((((0xff) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff)
>> 16))) - 1) & ((((0xff) >> 16)))) ^ ((((0xff
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xff) >> 16)) >> 4)) - 1) & (((((0xff) >>
16)) >> 4))) ^ (((((0xff) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >>
16)) >> 4) >> 2)) - 1) & ((((((0xff) >>
16)) >> 4) >> 2))) ^ ((((((0xff) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xff) >> 16)) >> 4))) - 1) & ((((((
0xff) >> 16)) >> 4)))) ^ ((((((0xff) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xff) >> 16)))) - 1) & (((((0xff) >>
16))))) ^ (((((0xff) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xff) >> 16))) >> 2)) -
1) & ((((((0xff) >> 16))) >> 2))) ^ ((((((0xff
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xff) >> 16))))) - 1) & (((((
(0xff) >> 16)))))) ^ ((((((0xff) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xff))) - 1) &
(((0xff)))) ^ (((0xff))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xff)) >> 8)) - 1) & ((((0xff)) >> 8
))) ^ ((((0xff)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xff)) >> 8) >> 4)) - 1) & (
((((0xff)) >> 8) >> 4))) ^ (((((0xff)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xff)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xff)) >> 8) >> 4) >> 2))) ^ ((((((0xff)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xff)) >> 8) >> 4)
)) - 1) & ((((((0xff)) >> 8) >> 4)))) ^ (((((
(0xff)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xff)) >> 8))) - 1) & ((
(((0xff)) >> 8)))) ^ (((((0xff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff)) >> 8)) >>
2)) - 1) & ((((((0xff)) >> 8)) >> 2))) ^ (((
(((0xff)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xff)) >> 8)))) - 1) &
((((((0xff)) >> 8))))) ^ ((((((0xff)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff))))
- 1) & ((((0xff))))) ^ ((((0xff)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xff))) >> 4)) - 1) & (
((((0xff))) >> 4))) ^ (((((0xff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff))) >> 4) >>
2)) - 1) & ((((((0xff))) >> 4) >> 2))) ^ (((
(((0xff))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xff))) >> 4))) - 1) &
((((((0xff))) >> 4)))) ^ ((((((0xff))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff))))
) - 1) & (((((0xff)))))) ^ (((((0xff))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xff)))) >> 2)) - 1) &
((((((0xff)))) >> 2))) ^ ((((((0xff)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff))))
)) - 1) & ((((((0xff))))))) ^ ((((((0xff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
450
451 RTW_WRITE(regs, RTW_TCR, tcr)((*(regs)->r_write32)(regs, 0x40, tcr));
452
453 RTW_WBW(regs, RTW_CR, RTW_TCR)((*(regs)->r_barrier)(regs, 0x37, 0x40, 0x02));
454
455 return rtw_chip_reset1(regs, dvname);
456}
457
458int
459rtw_recall_eeprom(struct rtw_regs *regs, const char *dvname)
460{
461 int i;
462 u_int8_t ecr;
463
464 ecr = RTW_READ8(regs, RTW_9346CR)((*(regs)->r_read8)(regs, 0x50));
465 ecr = (ecr & ~RTW_9346CR_EEM_MASK0xc0) | RTW_9346CR_EEM_AUTOLOAD((1) << ((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ (
(0xc0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc0)
>> 16)) - 1) & (((0xc0) >> 16))) ^ (((0xc0) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >>
16) >> 8)) - 1) & ((((0xc0) >> 16) >> 8
))) ^ ((((0xc0) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0) >> 16) >> 8) >>
4)) - 1) & (((((0xc0) >> 16) >> 8) >> 4
))) ^ (((((0xc0) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc0) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc0) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4))) - 1) & ((((((0xc0) >> 16) >>
8) >> 4)))) ^ ((((((0xc0) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0
) >> 16) >> 8))) - 1) & (((((0xc0) >> 16
) >> 8)))) ^ (((((0xc0) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
466 RTW_WRITE8(regs, RTW_9346CR, ecr)((*(regs)->r_write8)(regs, 0x50, ecr));
467
468 RTW_WBR(regs, RTW_9346CR, RTW_9346CR)((*(regs)->r_barrier)(regs, 0x50, 0x50, 0x02));
469
470 /* wait 10ms for completion */
471 for (i = 0; i < 50; i++) {
472 ecr = RTW_READ8(regs, RTW_9346CR)((*(regs)->r_read8)(regs, 0x50));
473 if ((ecr & RTW_9346CR_EEM_MASK0xc0) == RTW_9346CR_EEM_NORMAL((0) << ((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ (
(0xc0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc0)
>> 16)) - 1) & (((0xc0) >> 16))) ^ (((0xc0) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >>
16) >> 8)) - 1) & ((((0xc0) >> 16) >> 8
))) ^ ((((0xc0) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0) >> 16) >> 8) >>
4)) - 1) & (((((0xc0) >> 16) >> 8) >> 4
))) ^ (((((0xc0) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc0) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc0) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4))) - 1) & ((((((0xc0) >> 16) >>
8) >> 4)))) ^ ((((((0xc0) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0
) >> 16) >> 8))) - 1) & (((((0xc0) >> 16
) >> 8)))) ^ (((((0xc0) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))
) {
474 RTW_DPRINTF(RTW_DEBUG_RESET,
475 ("%s: recall EEPROM in %dus\n", dvname, i * 200));
476 return (0);
477 }
478 RTW_RBR(regs, RTW_9346CR, RTW_9346CR)((*(regs)->r_barrier)(regs, 0x50, 0x50, 0x01));
479 DELAY(200)(*delay_func)(200);
480 }
481
482 printf("\n%s: could not recall EEPROM in %dus\n", dvname, i * 200);
483
484 return (ETIMEDOUT60);
485}
486
487int
488rtw_reset(struct rtw_softc *sc)
489{
490 int rc;
491 uint8_t config1;
492
493 if ((rc = rtw_chip_reset(&sc->sc_regs, sc->sc_dev.dv_xname)) != 0)
494 return rc;
495
496 if ((rc = rtw_recall_eeprom(&sc->sc_regs, sc->sc_dev.dv_xname)) != 0)
497 ;
498
499 config1 = RTW_READ8(&sc->sc_regs, RTW_CONFIG1)((*(&sc->sc_regs)->r_read8)(&sc->sc_regs, 0x52
))
;
500 RTW_WRITE8(&sc->sc_regs, RTW_CONFIG1, config1 & ~RTW_CONFIG1_PMEN)((*(&sc->sc_regs)->r_write8)(&sc->sc_regs, 0x52
, config1 & ~(1<<0)))
;
501 /* TBD turn off maximum power saving? */
502
503 return 0;
504}
505
506int
507rtw_txdesc_dmamaps_create(bus_dma_tag_t dmat, struct rtw_txsoft *descs,
508 u_int ndescs)
509{
510 int i, rc = 0;
511 for (i = 0; i < ndescs; i++) {
512 rc = bus_dmamap_create(dmat, MCLBYTES, RTW_MAXPKTSEGS, MCLBYTES,(*(dmat)->_dmamap_create)((dmat), ((1 << 11)), (64),
((1 << 11)), (0), (0), (&descs[i].ts_dmamap))
513 0, 0, &descs[i].ts_dmamap)(*(dmat)->_dmamap_create)((dmat), ((1 << 11)), (64),
((1 << 11)), (0), (0), (&descs[i].ts_dmamap))
;
514 if (rc != 0)
515 break;
516 }
517 return rc;
518}
519
520int
521rtw_rxdesc_dmamaps_create(bus_dma_tag_t dmat, struct rtw_rxsoft *descs,
522 u_int ndescs)
523{
524 int i, rc = 0;
525 for (i = 0; i < ndescs; i++) {
526 rc = bus_dmamap_create(dmat, MCLBYTES, 1, MCLBYTES, 0, 0,(*(dmat)->_dmamap_create)((dmat), ((1 << 11)), (1), (
(1 << 11)), (0), (0), (&descs[i].rs_dmamap))
527 &descs[i].rs_dmamap)(*(dmat)->_dmamap_create)((dmat), ((1 << 11)), (1), (
(1 << 11)), (0), (0), (&descs[i].rs_dmamap))
;
528 if (rc != 0)
529 break;
530 }
531 return rc;
532}
533
534void
535rtw_rxdesc_dmamaps_destroy(bus_dma_tag_t dmat, struct rtw_rxsoft *descs,
536 u_int ndescs)
537{
538 int i;
539 for (i = 0; i < ndescs; i++) {
540 if (descs[i].rs_dmamap != NULL((void *)0))
541 bus_dmamap_destroy(dmat, descs[i].rs_dmamap)(*(dmat)->_dmamap_destroy)((dmat), (descs[i].rs_dmamap));
542 }
543}
544
545void
546rtw_txdesc_dmamaps_destroy(bus_dma_tag_t dmat, struct rtw_txsoft *descs,
547 u_int ndescs)
548{
549 int i;
550 for (i = 0; i < ndescs; i++) {
551 if (descs[i].ts_dmamap != NULL((void *)0))
552 bus_dmamap_destroy(dmat, descs[i].ts_dmamap)(*(dmat)->_dmamap_destroy)((dmat), (descs[i].ts_dmamap));
553 }
554}
555
556int
557rtw_srom_parse(struct rtw_softc *sc)
558{
559 int i;
560 struct rtw_srom *sr = &sc->sc_srom;
561 u_int32_t *flags = &sc->sc_flags;
562 u_int8_t *cs_threshold = &sc->sc_csthr;
563 int *rfchipid = &sc->sc_rfchipid;
564 u_int32_t *rcr = &sc->sc_rcr;
565 enum rtw_locale *locale = &sc->sc_locale;
566 u_int16_t version;
567 u_int8_t mac[IEEE80211_ADDR_LEN6];
568
569 *flags &= ~(RTW_F_DIGPHY0x00000002|RTW_F_DFLANTB0x00000004|RTW_F_ANTDIV0x00000010);
570 *rcr &= ~(RTW_RCR_ENCS1(1<<29) | RTW_RCR_ENCS2(1<<30));
571
572 version = RTW_SR_GET16(sr, RTW_SR_VERSION)(((((sr))->sr_content[((0x3c))/2] >> ((((0x3c)) % 2 ==
0) ? 0 : 8)) & 0xff) | (((((sr))->sr_content[((0x3c) +
1)/2] >> ((((0x3c) + 1) % 2 == 0) ? 0 : 8)) & 0xff
) << 8))
;
573 RTW_DPRINTF(RTW_DEBUG_ATTACH,
574 ("%s: SROM %d.%d\n", sc->sc_dev.dv_xname, version >> 8,
575 version & 0xff));
576
577 if (version <= 0x0101) {
578 printf(" is not understood, limping along with defaults ");
579 *flags |= (RTW_F_DIGPHY0x00000002|RTW_F_ANTDIV0x00000010);
580 *cs_threshold = RTW_SR_ENERGYDETTHR_DEFAULT0x0c;
581 *rcr |= RTW_RCR_ENCS1(1<<29);
582 *rfchipid = RTW_RFCHIPID_PHILIPS0x03;
583 return 0;
584 }
585
586 for (i = 0; i < IEEE80211_ADDR_LEN6; i++)
587 mac[i] = RTW_SR_GET(sr, RTW_SR_MAC + i)(((sr)->sr_content[(0x0e + i)/2] >> (((0x0e + i) % 2
== 0) ? 0 : 8)) & 0xff)
;
588
589 RTW_DPRINTF(RTW_DEBUG_ATTACH,
590 ("%s: EEPROM MAC %s\n", sc->sc_dev.dv_xname, ether_sprintf(mac)));
591
592 *cs_threshold = RTW_SR_GET(sr, RTW_SR_ENERGYDETTHR)(((sr)->sr_content[(0x2f)/2] >> (((0x2f) % 2 == 0) ?
0 : 8)) & 0xff)
;
593
594 if ((RTW_SR_GET(sr, RTW_SR_CONFIG2)(((sr)->sr_content[(0x18)/2] >> (((0x18) % 2 == 0) ?
0 : 8)) & 0xff)
& RTW8180_CONFIG2_ANT(1<<6)) != 0)
595 *flags |= RTW_F_ANTDIV0x00000010;
596
597 /* Note well: the sense of the RTW_SR_RFPARM_DIGPHY bit seems
598 * to be reversed.
599 */
600 if ((RTW_SR_GET(sr, RTW_SR_RFPARM)(((sr)->sr_content[(0x32)/2] >> (((0x32) % 2 == 0) ?
0 : 8)) & 0xff)
& RTW_SR_RFPARM_DIGPHY(1<<0)) == 0)
601 *flags |= RTW_F_DIGPHY0x00000002;
602 if ((RTW_SR_GET(sr, RTW_SR_RFPARM)(((sr)->sr_content[(0x32)/2] >> (((0x32) % 2 == 0) ?
0 : 8)) & 0xff)
& RTW_SR_RFPARM_DFLANTB(1<<1)) != 0)
603 *flags |= RTW_F_DFLANTB0x00000004;
604
605 *rcr |= LSHIFT(MASK_AND_RSHIFT(RTW_SR_GET(sr, RTW_SR_RFPARM),((((((((sr)->sr_content[(0x32)/2] >> (((0x32) % 2 ==
0) ? 0 : 8)) & 0xff)) & (0xc)) >> ((((u_long)(
(((((0xc)) - 1) & ((0xc))) ^ ((0xc)))) >> (16)) != 0
) ? 16 + ((((u_long)(((((((0xc) >> 16)) - 1) & (((0xc
) >> 16))) ^ (((0xc) >> 16)))) >> (8)) != 0
) ? 8 + ((((u_long)((((((((0xc) >> 16) >> 8)) - 1
) & ((((0xc) >> 16) >> 8))) ^ ((((0xc) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0xc) >> 16) >> 8) >> 4)) - 1) & ((
(((0xc) >> 16) >> 8) >> 4))) ^ (((((0xc) >>
16) >> 8) >> 4)))) >> (2)) != 0) ? 2 + (((
(u_long)((((((((((0xc) >> 16) >> 8) >> 4) >>
2)) - 1) & ((((((0xc) >> 16) >> 8) >> 4
) >> 2))) ^ ((((((0xc) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc) >> 16) >> 8) >> 4))) - 1) &
((((((0xc) >> 16) >> 8) >> 4)))) ^ ((((((0xc
) >> 16) >> 8) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)(((((((((0xc) >> 16) >> 8
))) - 1) & (((((0xc) >> 16) >> 8)))) ^ (((((0xc
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xc) >> 16) >> 8)) >> 2)) -
1) & ((((((0xc) >> 16) >> 8)) >> 2))) ^
((((((0xc) >> 16) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16)
>> 8)))) - 1) & ((((((0xc) >> 16) >> 8
))))) ^ ((((((0xc) >> 16) >> 8)))))) >> (1)
) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc) >> 16))) -
1) & ((((0xc) >> 16)))) ^ ((((0xc) >> 16))))
) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xc) >>
16)) >> 4)) - 1) & (((((0xc) >> 16)) >>
4))) ^ (((((0xc) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xc) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xc) >> 16)) >> 4)
>> 2))) ^ ((((((0xc) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16)) >> 4))) - 1) & ((((((0xc) >> 16
)) >> 4)))) ^ ((((((0xc) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc) >> 16)
))) - 1) & (((((0xc) >> 16))))) ^ (((((0xc) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc)
>> 16))) >> 2)) - 1) & ((((((0xc) >> 16
))) >> 2))) ^ ((((((0xc) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16)
)))) - 1) & ((((((0xc) >> 16)))))) ^ ((((((0xc) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xc))) - 1) & (((0xc)))) ^ (((0xc))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xc)) >> 8)) - 1) & ((
((0xc)) >> 8))) ^ ((((0xc)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xc)) >> 8) >> 4
)) - 1) & (((((0xc)) >> 8) >> 4))) ^ (((((0xc
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xc)) >> 8) >> 4) >> 2)) - 1) &
((((((0xc)) >> 8) >> 4) >> 2))) ^ ((((((0xc
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xc)) >> 8) >> 4
))) - 1) & ((((((0xc)) >> 8) >> 4)))) ^ (((((
(0xc)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xc)) >> 8))) - 1) & (((((
0xc)) >> 8)))) ^ (((((0xc)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xc)) >> 8)) >>
2)) - 1) & ((((((0xc)) >> 8)) >> 2))) ^ ((((
((0xc)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)) >> 8)))) - 1) & ((
((((0xc)) >> 8))))) ^ ((((((0xc)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc)))) - 1) &
((((0xc))))) ^ ((((0xc)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xc))) >> 4)) - 1) & (((((0xc))) >>
4))) ^ (((((0xc))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xc))) >> 4) >> 2)) - 1) &
((((((0xc))) >> 4) >> 2))) ^ ((((((0xc))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc))) >> 4))) - 1) & ((((((0xc))) >>
4)))) ^ ((((((0xc))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xc))))) - 1) & (((((0xc))))
)) ^ (((((0xc))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xc)))) >> 2)) - 1) & ((((((0xc)))) >>
2))) ^ ((((((0xc)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)))))) - 1) & ((((((0xc))))
))) ^ ((((((0xc)))))))) >> (1)) != 0) ? 1 : 0))))))) <<
((((u_long)(((((((1<<29))) - 1) & (((1<<29))
)) ^ (((1<<29))))) >> (16)) != 0) ? 16 + ((((u_long
)((((((((1<<29)) >> 16)) - 1) & ((((1<<
29)) >> 16))) ^ ((((1<<29)) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)(((((((((1<<29)) >> 16
) >> 8)) - 1) & (((((1<<29)) >> 16) >>
8))) ^ (((((1<<29)) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)((((((((((1<<29)) >>
16) >> 8) >> 4)) - 1) & ((((((1<<29)) >>
16) >> 8) >> 4))) ^ ((((((1<<29)) >>
16) >> 8) >> 4)))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((1<<29)) >> 16) >> 8) >>
4) >> 2)) - 1) & (((((((1<<29)) >> 16)
>> 8) >> 4) >> 2))) ^ (((((((1<<29))
>> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((1<<29)) >>
16) >> 8) >> 4))) - 1) & (((((((1<<29)
) >> 16) >> 8) >> 4)))) ^ (((((((1<<29
)) >> 16) >> 8) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)((((((((((1<<29)) >> 16)
>> 8))) - 1) & ((((((1<<29)) >> 16) >>
8)))) ^ ((((((1<<29)) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((1<<29)) >>
16) >> 8)) >> 2)) - 1) & (((((((1<<29)
) >> 16) >> 8)) >> 2))) ^ (((((((1<<29
)) >> 16) >> 8)) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)(((((((((((1<<29)) >> 16)
>> 8)))) - 1) & (((((((1<<29)) >> 16) >>
8))))) ^ (((((((1<<29)) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((1<<29)) >>
16))) - 1) & (((((1<<29)) >> 16)))) ^ (((((1
<<29)) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)((((((((((1<<29)) >> 16)) >> 4)) - 1) &
((((((1<<29)) >> 16)) >> 4))) ^ ((((((1<<
29)) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)(((((((((((1<<29)) >> 16)) >> 4) >>
2)) - 1) & (((((((1<<29)) >> 16)) >> 4
) >> 2))) ^ (((((((1<<29)) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
(((((((((((1<<29)) >> 16)) >> 4))) - 1) &
(((((((1<<29)) >> 16)) >> 4)))) ^ (((((((1
<<29)) >> 16)) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)((((((((((1<<29)) >> 16)
))) - 1) & ((((((1<<29)) >> 16))))) ^ ((((((1
<<29)) >> 16)))))) >> (2)) != 0) ? 2 + ((((
u_long)(((((((((((1<<29)) >> 16))) >> 2)) -
1) & (((((((1<<29)) >> 16))) >> 2))) ^
(((((((1<<29)) >> 16))) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((1<<29)) >>
16))))) - 1) & (((((((1<<29)) >> 16)))))) ^ (
((((((1<<29)) >> 16))))))) >> (1)) != 0) ? 1
: 0)))) : ((((u_long)((((((((1<<29)))) - 1) & ((((
1<<29))))) ^ ((((1<<29)))))) >> (8)) != 0) ?
8 + ((((u_long)(((((((((1<<29))) >> 8)) - 1) &
(((((1<<29))) >> 8))) ^ (((((1<<29))) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)((((((((((1<<
29))) >> 8) >> 4)) - 1) & ((((((1<<29))
) >> 8) >> 4))) ^ ((((((1<<29))) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
((((1<<29))) >> 8) >> 4) >> 2)) - 1) &
(((((((1<<29))) >> 8) >> 4) >> 2))) ^
(((((((1<<29))) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((1<<
29))) >> 8) >> 4))) - 1) & (((((((1<<29
))) >> 8) >> 4)))) ^ (((((((1<<29))) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)((((((((((1<<29))) >> 8))) - 1) & ((((((1<<
29))) >> 8)))) ^ ((((((1<<29))) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((1<<29))) >>
8)) >> 2)) - 1) & (((((((1<<29))) >> 8
)) >> 2))) ^ (((((((1<<29))) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((1
<<29))) >> 8)))) - 1) & (((((((1<<29)))
>> 8))))) ^ (((((((1<<29))) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((1<<29)))))
- 1) & (((((1<<29)))))) ^ (((((1<<29))))))) >>
(4)) != 0) ? 4 + ((((u_long)((((((((((1<<29)))) >>
4)) - 1) & ((((((1<<29)))) >> 4))) ^ ((((((1
<<29)))) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((1<<29)))) >> 4) >> 2)) - 1) &
(((((((1<<29)))) >> 4) >> 2))) ^ (((((((1<<
29)))) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0
) : ((((u_long)(((((((((((1<<29)))) >> 4))) - 1) &
(((((((1<<29)))) >> 4)))) ^ (((((((1<<29))
)) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)((((((((((1<<29)))))) - 1) & ((((((1<<29))))
))) ^ ((((((1<<29)))))))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((1<<29))))) >> 2)) - 1) & (
((((((1<<29))))) >> 2))) ^ (((((((1<<29))))
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
(((((((((1<<29))))))) - 1) & (((((((1<<29))))
)))) ^ (((((((1<<29))))))))) >> (1)) != 0) ? 1 : 0
))))))
606 RTW_SR_RFPARM_CS_MASK), RTW_RCR_ENCS1)((((((((sr)->sr_content[(0x32)/2] >> (((0x32) % 2 ==
0) ? 0 : 8)) & 0xff)) & (0xc)) >> ((((u_long)(
(((((0xc)) - 1) & ((0xc))) ^ ((0xc)))) >> (16)) != 0
) ? 16 + ((((u_long)(((((((0xc) >> 16)) - 1) & (((0xc
) >> 16))) ^ (((0xc) >> 16)))) >> (8)) != 0
) ? 8 + ((((u_long)((((((((0xc) >> 16) >> 8)) - 1
) & ((((0xc) >> 16) >> 8))) ^ ((((0xc) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0xc) >> 16) >> 8) >> 4)) - 1) & ((
(((0xc) >> 16) >> 8) >> 4))) ^ (((((0xc) >>
16) >> 8) >> 4)))) >> (2)) != 0) ? 2 + (((
(u_long)((((((((((0xc) >> 16) >> 8) >> 4) >>
2)) - 1) & ((((((0xc) >> 16) >> 8) >> 4
) >> 2))) ^ ((((((0xc) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc) >> 16) >> 8) >> 4))) - 1) &
((((((0xc) >> 16) >> 8) >> 4)))) ^ ((((((0xc
) >> 16) >> 8) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)(((((((((0xc) >> 16) >> 8
))) - 1) & (((((0xc) >> 16) >> 8)))) ^ (((((0xc
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xc) >> 16) >> 8)) >> 2)) -
1) & ((((((0xc) >> 16) >> 8)) >> 2))) ^
((((((0xc) >> 16) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16)
>> 8)))) - 1) & ((((((0xc) >> 16) >> 8
))))) ^ ((((((0xc) >> 16) >> 8)))))) >> (1)
) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc) >> 16))) -
1) & ((((0xc) >> 16)))) ^ ((((0xc) >> 16))))
) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xc) >>
16)) >> 4)) - 1) & (((((0xc) >> 16)) >>
4))) ^ (((((0xc) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xc) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xc) >> 16)) >> 4)
>> 2))) ^ ((((((0xc) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16)) >> 4))) - 1) & ((((((0xc) >> 16
)) >> 4)))) ^ ((((((0xc) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc) >> 16)
))) - 1) & (((((0xc) >> 16))))) ^ (((((0xc) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc)
>> 16))) >> 2)) - 1) & ((((((0xc) >> 16
))) >> 2))) ^ ((((((0xc) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16)
)))) - 1) & ((((((0xc) >> 16)))))) ^ ((((((0xc) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xc))) - 1) & (((0xc)))) ^ (((0xc))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xc)) >> 8)) - 1) & ((
((0xc)) >> 8))) ^ ((((0xc)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xc)) >> 8) >> 4
)) - 1) & (((((0xc)) >> 8) >> 4))) ^ (((((0xc
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xc)) >> 8) >> 4) >> 2)) - 1) &
((((((0xc)) >> 8) >> 4) >> 2))) ^ ((((((0xc
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xc)) >> 8) >> 4
))) - 1) & ((((((0xc)) >> 8) >> 4)))) ^ (((((
(0xc)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xc)) >> 8))) - 1) & (((((
0xc)) >> 8)))) ^ (((((0xc)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xc)) >> 8)) >>
2)) - 1) & ((((((0xc)) >> 8)) >> 2))) ^ ((((
((0xc)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)) >> 8)))) - 1) & ((
((((0xc)) >> 8))))) ^ ((((((0xc)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc)))) - 1) &
((((0xc))))) ^ ((((0xc)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xc))) >> 4)) - 1) & (((((0xc))) >>
4))) ^ (((((0xc))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xc))) >> 4) >> 2)) - 1) &
((((((0xc))) >> 4) >> 2))) ^ ((((((0xc))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc))) >> 4))) - 1) & ((((((0xc))) >>
4)))) ^ ((((((0xc))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xc))))) - 1) & (((((0xc))))
)) ^ (((((0xc))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xc)))) >> 2)) - 1) & ((((((0xc)))) >>
2))) ^ ((((((0xc)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)))))) - 1) & ((((((0xc))))
))) ^ ((((((0xc)))))))) >> (1)) != 0) ? 1 : 0))))))) <<
((((u_long)(((((((1<<29))) - 1) & (((1<<29))
)) ^ (((1<<29))))) >> (16)) != 0) ? 16 + ((((u_long
)((((((((1<<29)) >> 16)) - 1) & ((((1<<
29)) >> 16))) ^ ((((1<<29)) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)(((((((((1<<29)) >> 16
) >> 8)) - 1) & (((((1<<29)) >> 16) >>
8))) ^ (((((1<<29)) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)((((((((((1<<29)) >>
16) >> 8) >> 4)) - 1) & ((((((1<<29)) >>
16) >> 8) >> 4))) ^ ((((((1<<29)) >>
16) >> 8) >> 4)))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((1<<29)) >> 16) >> 8) >>
4) >> 2)) - 1) & (((((((1<<29)) >> 16)
>> 8) >> 4) >> 2))) ^ (((((((1<<29))
>> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((1<<29)) >>
16) >> 8) >> 4))) - 1) & (((((((1<<29)
) >> 16) >> 8) >> 4)))) ^ (((((((1<<29
)) >> 16) >> 8) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)((((((((((1<<29)) >> 16)
>> 8))) - 1) & ((((((1<<29)) >> 16) >>
8)))) ^ ((((((1<<29)) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((1<<29)) >>
16) >> 8)) >> 2)) - 1) & (((((((1<<29)
) >> 16) >> 8)) >> 2))) ^ (((((((1<<29
)) >> 16) >> 8)) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)(((((((((((1<<29)) >> 16)
>> 8)))) - 1) & (((((((1<<29)) >> 16) >>
8))))) ^ (((((((1<<29)) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((1<<29)) >>
16))) - 1) & (((((1<<29)) >> 16)))) ^ (((((1
<<29)) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)((((((((((1<<29)) >> 16)) >> 4)) - 1) &
((((((1<<29)) >> 16)) >> 4))) ^ ((((((1<<
29)) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)(((((((((((1<<29)) >> 16)) >> 4) >>
2)) - 1) & (((((((1<<29)) >> 16)) >> 4
) >> 2))) ^ (((((((1<<29)) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
(((((((((((1<<29)) >> 16)) >> 4))) - 1) &
(((((((1<<29)) >> 16)) >> 4)))) ^ (((((((1
<<29)) >> 16)) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)((((((((((1<<29)) >> 16)
))) - 1) & ((((((1<<29)) >> 16))))) ^ ((((((1
<<29)) >> 16)))))) >> (2)) != 0) ? 2 + ((((
u_long)(((((((((((1<<29)) >> 16))) >> 2)) -
1) & (((((((1<<29)) >> 16))) >> 2))) ^
(((((((1<<29)) >> 16))) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((1<<29)) >>
16))))) - 1) & (((((((1<<29)) >> 16)))))) ^ (
((((((1<<29)) >> 16))))))) >> (1)) != 0) ? 1
: 0)))) : ((((u_long)((((((((1<<29)))) - 1) & ((((
1<<29))))) ^ ((((1<<29)))))) >> (8)) != 0) ?
8 + ((((u_long)(((((((((1<<29))) >> 8)) - 1) &
(((((1<<29))) >> 8))) ^ (((((1<<29))) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)((((((((((1<<
29))) >> 8) >> 4)) - 1) & ((((((1<<29))
) >> 8) >> 4))) ^ ((((((1<<29))) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
((((1<<29))) >> 8) >> 4) >> 2)) - 1) &
(((((((1<<29))) >> 8) >> 4) >> 2))) ^
(((((((1<<29))) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((1<<
29))) >> 8) >> 4))) - 1) & (((((((1<<29
))) >> 8) >> 4)))) ^ (((((((1<<29))) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)((((((((((1<<29))) >> 8))) - 1) & ((((((1<<
29))) >> 8)))) ^ ((((((1<<29))) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((1<<29))) >>
8)) >> 2)) - 1) & (((((((1<<29))) >> 8
)) >> 2))) ^ (((((((1<<29))) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((1
<<29))) >> 8)))) - 1) & (((((((1<<29)))
>> 8))))) ^ (((((((1<<29))) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((1<<29)))))
- 1) & (((((1<<29)))))) ^ (((((1<<29))))))) >>
(4)) != 0) ? 4 + ((((u_long)((((((((((1<<29)))) >>
4)) - 1) & ((((((1<<29)))) >> 4))) ^ ((((((1
<<29)))) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((1<<29)))) >> 4) >> 2)) - 1) &
(((((((1<<29)))) >> 4) >> 2))) ^ (((((((1<<
29)))) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0
) : ((((u_long)(((((((((((1<<29)))) >> 4))) - 1) &
(((((((1<<29)))) >> 4)))) ^ (((((((1<<29))
)) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)((((((((((1<<29)))))) - 1) & ((((((1<<29))))
))) ^ ((((((1<<29)))))))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((1<<29))))) >> 2)) - 1) & (
((((((1<<29))))) >> 2))) ^ (((((((1<<29))))
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
(((((((((1<<29))))))) - 1) & (((((((1<<29))))
)))) ^ (((((((1<<29))))))))) >> (1)) != 0) ? 1 : 0
))))))
;
607
608 *rfchipid = RTW_SR_GET(sr, RTW_SR_RFCHIPID)(((sr)->sr_content[(0x0c)/2] >> (((0x0c) % 2 == 0) ?
0 : 8)) & 0xff)
;
609
610 if (sc->sc_flags & RTW_F_RTL81850x00000008) {
611 *locale = RTW_LOCALE_UNKNOWN;
612 return (0);
613 }
614
615 switch (RTW_SR_GET(sr, RTW_SR_CONFIG0)(((sr)->sr_content[(0x14)/2] >> (((0x14) % 2 == 0) ?
0 : 8)) & 0xff)
& RTW8180_CONFIG0_GL_MASK0x3) {
616 case RTW8180_CONFIG0_GL_USA((3) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
:
617 *locale = RTW_LOCALE_USA;
618 break;
619 case RTW8180_CONFIG0_GL_EUROPE((2) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
:
620 *locale = RTW_LOCALE_EUROPE;
621 break;
622 case RTW8180_CONFIG0_GL_JAPAN((1) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
:
623 case RTW8180_CONFIG0_GL_JAPAN2((0) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
:
624 *locale = RTW_LOCALE_JAPAN;
625 break;
626 default:
627 *locale = RTW_LOCALE_UNKNOWN;
628 break;
629 }
630 return 0;
631}
632
633/* Returns -1 on failure. */
634int
635rtw_srom_read(struct rtw_regs *regs, u_int32_t flags, struct rtw_srom *sr,
636 const char *dvname)
637{
638 int rc;
639 struct seeprom_descriptor sd;
640 u_int8_t ecr;
641
642 bzero(&sd, sizeof(sd))__builtin_bzero((&sd), (sizeof(sd)));
643
644 ecr = RTW_READ8(regs, RTW_9346CR)((*(regs)->r_read8)(regs, 0x50));
645
646 if ((flags & RTW_F_9356SROM0x00000020) != 0) {
647 RTW_DPRINTF(RTW_DEBUG_ATTACH, ("%s: 93c56 SROM\n", dvname));
648 sr->sr_size = 256;
649 sd.sd_chip = C56_66;
650 } else {
651 RTW_DPRINTF(RTW_DEBUG_ATTACH, ("%s: 93c46 SROM\n", dvname));
652 sr->sr_size = 128;
653 sd.sd_chip = C46;
654 }
655
656 ecr &= ~(RTW_9346CR_EEDI(1<<1) | RTW_9346CR_EEDO(1<<0) | RTW_9346CR_EESK(1<<2) |
657 RTW_9346CR_EEM_MASK0xc0 | RTW_9346CR_EECS(1<<3));
658 ecr |= RTW_9346CR_EEM_PROGRAM((2) << ((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ (
(0xc0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc0)
>> 16)) - 1) & (((0xc0) >> 16))) ^ (((0xc0) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >>
16) >> 8)) - 1) & ((((0xc0) >> 16) >> 8
))) ^ ((((0xc0) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0) >> 16) >> 8) >>
4)) - 1) & (((((0xc0) >> 16) >> 8) >> 4
))) ^ (((((0xc0) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc0) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc0) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4))) - 1) & ((((((0xc0) >> 16) >>
8) >> 4)))) ^ ((((((0xc0) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0
) >> 16) >> 8))) - 1) & (((((0xc0) >> 16
) >> 8)))) ^ (((((0xc0) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
659
660 RTW_WRITE8(regs, RTW_9346CR, ecr)((*(regs)->r_write8)(regs, 0x50, ecr));
661
662 sr->sr_content = malloc(sr->sr_size, M_DEVBUF2, M_NOWAIT0x0002 | M_ZERO0x0008);
663
664 if (sr->sr_content == NULL((void *)0)) {
665 printf("%s: unable to allocate SROM buffer\n", dvname);
666 return ENOMEM12;
667 }
668
669 /* RTL8180 has a single 8-bit register for controlling the
670 * 93cx6 SROM. There is no "ready" bit. The RTL8180
671 * input/output sense is the reverse of read_seeprom's.
672 */
673 sd.sd_tag = regs->r_bt;
674 sd.sd_bsh = regs->r_bh;
675 sd.sd_regsize = 1;
676 sd.sd_control_offset = RTW_9346CR0x50;
677 sd.sd_status_offset = RTW_9346CR0x50;
678 sd.sd_dataout_offset = RTW_9346CR0x50;
679 sd.sd_CK = RTW_9346CR_EESK(1<<2);
680 sd.sd_CS = RTW_9346CR_EECS(1<<3);
681 sd.sd_DI = RTW_9346CR_EEDO(1<<0);
682 sd.sd_DO = RTW_9346CR_EEDI(1<<1);
683 /* make read_seeprom enter EEPROM read/write mode */
684 sd.sd_MS = ecr;
685 sd.sd_RDY = 0;
686
687 /* TBD bus barriers */
688 if (!read_seeprom(&sd, sr->sr_content, 0, sr->sr_size/2)) {
689 printf("\n%s: could not read SROM\n", dvname);
690 free(sr->sr_content, M_DEVBUF2, 0);
691 sr->sr_content = NULL((void *)0);
692 return -1; /* XXX */
693 }
694
695 /* end EEPROM read/write mode */
696 RTW_WRITE8(regs, RTW_9346CR,((*(regs)->r_write8)(regs, 0x50, (ecr & ~0xc0) | ((0) <<
((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ ((0xc0)))) >>
(16)) != 0) ? 16 + ((((u_long)(((((((0xc0) >> 16)) - 1
) & (((0xc0) >> 16))) ^ (((0xc0) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >> 16) >>
8)) - 1) & ((((0xc0) >> 16) >> 8))) ^ ((((0xc0
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xc0) >> 16) >> 8) >> 4)) - 1) &
(((((0xc0) >> 16) >> 8) >> 4))) ^ (((((0xc0
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xc0) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xc0) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16) >> 8) >>
4))) - 1) & ((((((0xc0) >> 16) >> 8) >>
4)))) ^ ((((((0xc0) >> 16) >> 8) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0) >>
16) >> 8))) - 1) & (((((0xc0) >> 16) >>
8)))) ^ (((((0xc0) >> 16) >> 8))))) >> (2)
) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))))
697 (ecr & ~RTW_9346CR_EEM_MASK) | RTW_9346CR_EEM_NORMAL)((*(regs)->r_write8)(regs, 0x50, (ecr & ~0xc0) | ((0) <<
((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ ((0xc0)))) >>
(16)) != 0) ? 16 + ((((u_long)(((((((0xc0) >> 16)) - 1
) & (((0xc0) >> 16))) ^ (((0xc0) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >> 16) >>
8)) - 1) & ((((0xc0) >> 16) >> 8))) ^ ((((0xc0
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xc0) >> 16) >> 8) >> 4)) - 1) &
(((((0xc0) >> 16) >> 8) >> 4))) ^ (((((0xc0
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xc0) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xc0) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16) >> 8) >>
4))) - 1) & ((((((0xc0) >> 16) >> 8) >>
4)))) ^ ((((((0xc0) >> 16) >> 8) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0) >>
16) >> 8))) - 1) & (((((0xc0) >> 16) >>
8)))) ^ (((((0xc0) >> 16) >> 8))))) >> (2)
) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))))
;
698 RTW_WBRW(regs, RTW_9346CR, RTW_9346CR)((*(regs)->r_barrier)(regs, 0x50, 0x50, 0x02 | 0x02));
699
700 if ((rc = rtw_recall_eeprom(regs, dvname)) != 0)
701 return rc;
702
703#ifdef RTW_DEBUG
704 {
705 int i;
706 RTW_DPRINTF(RTW_DEBUG_ATTACH,
707 ("\n%s: serial ROM:\n\t", dvname));
708 for (i = 0; i < sr->sr_size/2; i++) {
709 if (((i % 8) == 0) && (i != 0))
710 RTW_DPRINTF(RTW_DEBUG_ATTACH, ("\n\t"));
711 RTW_DPRINTF(RTW_DEBUG_ATTACH,
712 (" %04x", sr->sr_content[i]));
713 }
714 RTW_DPRINTF(RTW_DEBUG_ATTACH, ("\n"));
715 }
716#endif /* RTW_DEBUG */
717 return 0;
718}
719
720void
721rtw_set_rfprog(struct rtw_regs *regs, int rfchipid,
722 const char *dvname)
723{
724 u_int8_t cfg4;
725 const char *method;
726
727 cfg4 = RTW_READ8(regs, RTW_CONFIG4)((*(regs)->r_read8)(regs, 0x5A)) & ~RTW_CONFIG4_RFTYPE_MASK0x3;
728
729 switch (rfchipid) {
730 default:
731 cfg4 |= LSHIFT(rtw_rfprog_fallback, RTW_CONFIG4_RFTYPE_MASK)((rtw_rfprog_fallback) << ((((u_long)((((((0x3)) - 1) &
((0x3))) ^ ((0x3)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x3) >> 16)) - 1) & (((0x3) >> 16))) ^
(((0x3) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x3) >> 16) >> 8)) - 1) & ((((0x3) >>
16) >> 8))) ^ ((((0x3) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >> 16) >>
8) >> 4)) - 1) & (((((0x3) >> 16) >> 8
) >> 4))) ^ (((((0x3) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0x3
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x3) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
>> 8) >> 4))) - 1) & ((((((0x3) >> 16)
>> 8) >> 4)))) ^ ((((((0x3) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x3) >> 16) >> 8))) - 1) & (((((0x3
) >> 16) >> 8)))) ^ (((((0x3) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >>
16) >> 8)) >> 2)) - 1) & ((((((0x3) >>
16) >> 8)) >> 2))) ^ ((((((0x3) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x3) >> 16) >> 8)))) - 1) & ((((((
0x3) >> 16) >> 8))))) ^ ((((((0x3) >> 16) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
0x3) >> 16))) - 1) & ((((0x3) >> 16)))) ^ (((
(0x3) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(
((((((((0x3) >> 16)) >> 4)) - 1) & (((((0x3) >>
16)) >> 4))) ^ (((((0x3) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >>
4) >> 2)) - 1) & ((((((0x3) >> 16)) >>
4) >> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
;
732 method = "fallback";
733 break;
734 case RTW_RFCHIPID_INTERSIL0x01:
735 cfg4 |= RTW_CONFIG4_RFTYPE_INTERSIL((1) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
;
736 method = "Intersil";
737 break;
738 case RTW_RFCHIPID_PHILIPS0x03:
739 cfg4 |= RTW_CONFIG4_RFTYPE_PHILIPS((3) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
;
740 method = "Philips";
741 break;
742 case RTW_RFCHIPID_RFMD29480x02:
743 cfg4 |= RTW_CONFIG4_RFTYPE_RFMD((2) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
;
744 method = "RFMD";
Value stored to 'method' is never read
745 break;
746 }
747
748 RTW_WRITE8(regs, RTW_CONFIG4, cfg4)((*(regs)->r_write8)(regs, 0x5A, cfg4));
749
750 RTW_WBR(regs, RTW_CONFIG4, RTW_CONFIG4)((*(regs)->r_barrier)(regs, 0x5A, 0x5A, 0x02));
751
752 RTW_DPRINTF(RTW_DEBUG_INIT,
753 ("%s: %s RF programming method, %#02x\n", dvname, method,
754 RTW_READ8(regs, RTW_CONFIG4)));
755}
756
757void
758rtw_identify_country(struct rtw_regs *regs, enum rtw_locale *locale)
759{
760 u_int8_t cfg0 = RTW_READ8(regs, RTW_CONFIG0)((*(regs)->r_read8)(regs, 0x51));
761
762 switch (cfg0 & RTW8180_CONFIG0_GL_MASK0x3) {
763 case RTW8180_CONFIG0_GL_USA((3) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
:
764 *locale = RTW_LOCALE_USA;
765 break;
766 case RTW8180_CONFIG0_GL_JAPAN((1) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
:
767 case RTW8180_CONFIG0_GL_JAPAN2((0) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
:
768 *locale = RTW_LOCALE_JAPAN;
769 break;
770 case RTW8180_CONFIG0_GL_EUROPE((2) << ((((u_long)((((((0x3)) - 1) & ((0x3))) ^ ((
0x3)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3) >>
16)) - 1) & (((0x3) >> 16))) ^ (((0x3) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3) >>
16) >> 8)) - 1) & ((((0x3) >> 16) >> 8
))) ^ ((((0x3) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3) >> 16) >> 8) >>
4)) - 1) & (((((0x3) >> 16) >> 8) >> 4
))) ^ (((((0x3) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16) >> 8
) >> 4))) - 1) & ((((((0x3) >> 16) >> 8
) >> 4)))) ^ ((((((0x3) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3
) >> 16) >> 8))) - 1) & (((((0x3) >> 16
) >> 8)))) ^ (((((0x3) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3) >> 16) >>
8)) >> 2))) ^ ((((((0x3) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16) >> 8)))) - 1) & ((((((0x3) >> 16
) >> 8))))) ^ ((((((0x3) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16)
)) - 1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))
:
771 *locale = RTW_LOCALE_EUROPE;
772 break;
773 default:
774 *locale = RTW_LOCALE_UNKNOWN;
775 break;
776 }
777}
778
779int
780rtw_identify_sta(struct rtw_regs *regs, u_int8_t (*addr)[IEEE80211_ADDR_LEN6],
781 const char *dvname)
782{
783 static const u_int8_t empty_macaddr[IEEE80211_ADDR_LEN6] = {
784 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
785 };
786 u_int32_t idr0 = RTW_READ(regs, RTW_IDR0)((*(regs)->r_read32)(regs, 0x00)),
787 idr1 = RTW_READ(regs, RTW_IDR1)((*(regs)->r_read32)(regs, 0x04));
788
789 (*addr)[0] = MASK_AND_RSHIFT(idr0, 0xff)(((idr0) & (0xff)) >> ((((u_long)((((((0xff)) - 1) &
((0xff))) ^ ((0xff)))) >> (16)) != 0) ? 16 + ((((u_long
)(((((((0xff) >> 16)) - 1) & (((0xff) >> 16))
) ^ (((0xff) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xff) >> 16) >> 8)) - 1) & ((((0xff)
>> 16) >> 8))) ^ ((((0xff) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >>
16) >> 8) >> 4)) - 1) & (((((0xff) >> 16
) >> 8) >> 4))) ^ (((((0xff) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff) >> 16) >> 8) >> 4) >> 2)) -
1) & ((((((0xff) >> 16) >> 8) >> 4) >>
2))) ^ ((((((0xff) >> 16) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
) >> 16) >> 8) >> 4))) - 1) & ((((((0xff
) >> 16) >> 8) >> 4)))) ^ ((((((0xff) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff) >> 16) >> 8))) - 1)
& (((((0xff) >> 16) >> 8)))) ^ (((((0xff) >>
16) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xff) >> 16) >> 8)) >> 2)) - 1) &
((((((0xff) >> 16) >> 8)) >> 2))) ^ ((((((
0xff) >> 16) >> 8)) >> 2)))) >> (1)) !=
0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16) >>
8)))) - 1) & ((((((0xff) >> 16) >> 8))))) ^ (
(((((0xff) >> 16) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0xff) >> 16))) - 1) &
((((0xff) >> 16)))) ^ ((((0xff) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >> 16)) >>
4)) - 1) & (((((0xff) >> 16)) >> 4))) ^ ((((
(0xff) >> 16)) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)((((((((((0xff) >> 16)) >> 4) >>
2)) - 1) & ((((((0xff) >> 16)) >> 4) >>
2))) ^ ((((((0xff) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16
)) >> 4))) - 1) & ((((((0xff) >> 16)) >>
4)))) ^ ((((((0xff) >> 16)) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff) >> 16))
)) - 1) & (((((0xff) >> 16))))) ^ (((((0xff) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff
) >> 16))) >> 2)) - 1) & ((((((0xff) >>
16))) >> 2))) ^ ((((((0xff) >> 16))) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff)
>> 16))))) - 1) & ((((((0xff) >> 16)))))) ^ (
(((((0xff) >> 16))))))) >> (1)) != 0) ? 1 : 0))))
: ((((u_long)(((((((0xff))) - 1) & (((0xff)))) ^ (((0xff
))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xff)) >>
8)) - 1) & ((((0xff)) >> 8))) ^ ((((0xff)) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff)) >>
8) >> 4)) - 1) & (((((0xff)) >> 8) >> 4
))) ^ (((((0xff)) >> 8) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xff)) >> 8) >> 4)
>> 2)) - 1) & ((((((0xff)) >> 8) >> 4)
>> 2))) ^ ((((((0xff)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
)) >> 8) >> 4))) - 1) & ((((((0xff)) >>
8) >> 4)))) ^ ((((((0xff)) >> 8) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff)) >>
8))) - 1) & (((((0xff)) >> 8)))) ^ (((((0xff)) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff))
>> 8)) >> 2)) - 1) & ((((((0xff)) >> 8
)) >> 2))) ^ ((((((0xff)) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff)) >> 8
)))) - 1) & ((((((0xff)) >> 8))))) ^ ((((((0xff)) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
0xff)))) - 1) & ((((0xff))))) ^ ((((0xff)))))) >> (
4)) != 0) ? 4 + ((((u_long)(((((((((0xff))) >> 4)) - 1)
& (((((0xff))) >> 4))) ^ (((((0xff))) >> 4))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff))) >>
4) >> 2)) - 1) & ((((((0xff))) >> 4) >>
2))) ^ ((((((0xff))) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff))) >> 4)))
- 1) & ((((((0xff))) >> 4)))) ^ ((((((0xff))) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff
))))) - 1) & (((((0xff)))))) ^ (((((0xff))))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0xff)))) >> 2)) - 1
) & ((((((0xff)))) >> 2))) ^ ((((((0xff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
)))))) - 1) & ((((((0xff))))))) ^ ((((((0xff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
790 (*addr)[1] = MASK_AND_RSHIFT(idr0, 0xff00)(((idr0) & (0xff00)) >> ((((u_long)((((((0xff00)) -
1) & ((0xff00))) ^ ((0xff00)))) >> (16)) != 0) ? 16
+ ((((u_long)(((((((0xff00) >> 16)) - 1) & (((0xff00
) >> 16))) ^ (((0xff00) >> 16)))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xff00) >> 16) >> 8)
) - 1) & ((((0xff00) >> 16) >> 8))) ^ ((((0xff00
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xff00) >> 16) >> 8) >> 4)) - 1) &
(((((0xff00) >> 16) >> 8) >> 4))) ^ (((((0xff00
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xff00) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xff00) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xff00) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xff00) >> 16) >> 8) >>
4))) - 1) & ((((((0xff00) >> 16) >> 8) >>
4)))) ^ ((((((0xff00) >> 16) >> 8) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00
) >> 16) >> 8))) - 1) & (((((0xff00) >>
16) >> 8)))) ^ (((((0xff00) >> 16) >> 8)))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00) >>
16) >> 8)) >> 2)) - 1) & ((((((0xff00) >>
16) >> 8)) >> 2))) ^ ((((((0xff00) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff00) >> 16) >> 8)))) - 1) & (((
(((0xff00) >> 16) >> 8))))) ^ ((((((0xff00) >>
16) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00) >> 16))) - 1) & ((((0xff00) >>
16)))) ^ ((((0xff00) >> 16))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xff00) >> 16)) >> 4)) - 1
) & (((((0xff00) >> 16)) >> 4))) ^ (((((0xff00
) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xff00) >> 16)) >> 4) >> 2
)) - 1) & ((((((0xff00) >> 16)) >> 4) >>
2))) ^ ((((((0xff00) >> 16)) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)
>> 16)) >> 4))) - 1) & ((((((0xff00) >>
16)) >> 4)))) ^ ((((((0xff00) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00
) >> 16)))) - 1) & (((((0xff00) >> 16))))) ^ (
((((0xff00) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00) >> 16))) >> 2)) - 1) & (((
(((0xff00) >> 16))) >> 2))) ^ ((((((0xff00) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff00) >> 16))))) - 1) & ((((((0xff00) >>
16)))))) ^ ((((((0xff00) >> 16))))))) >> (1)) !=
0) ? 1 : 0)))) : ((((u_long)(((((((0xff00))) - 1) & (((0xff00
)))) ^ (((0xff00))))) >> (8)) != 0) ? 8 + ((((u_long)((
((((((0xff00)) >> 8)) - 1) & ((((0xff00)) >> 8
))) ^ ((((0xff00)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xff00)) >> 8) >> 4)) - 1) &
(((((0xff00)) >> 8) >> 4))) ^ (((((0xff00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff00)) >> 8) >> 4) >> 2)) - 1) &
((((((0xff00)) >> 8) >> 4) >> 2))) ^ (((((
(0xff00)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8) >>
4))) - 1) & ((((((0xff00)) >> 8) >> 4)))) ^ (
(((((0xff00)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xff00)) >> 8))) - 1) &
(((((0xff00)) >> 8)))) ^ (((((0xff00)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00)) >>
8)) >> 2)) - 1) & ((((((0xff00)) >> 8)) >>
2))) ^ ((((((0xff00)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8
)))) - 1) & ((((((0xff00)) >> 8))))) ^ ((((((0xff00
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00)))) - 1) & ((((0xff00))))) ^ ((((0xff00))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff00))) >>
4)) - 1) & (((((0xff00))) >> 4))) ^ (((((0xff00)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xff00))) >> 4) >> 2)) - 1) & ((((((0xff00)
)) >> 4) >> 2))) ^ ((((((0xff00))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
))) >> 4))) - 1) & ((((((0xff00))) >> 4)))) ^
((((((0xff00))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff00))))) - 1) & (((((0xff00)))
))) ^ (((((0xff00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00)))) >> 2)) - 1) & ((((((0xff00)))
) >> 2))) ^ ((((((0xff00)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)))))) - 1) &
((((((0xff00))))))) ^ ((((((0xff00)))))))) >> (1)) != 0
) ? 1 : 0))))))
;
791 (*addr)[2] = MASK_AND_RSHIFT(idr0, 0xff0000)(((idr0) & (0xff0000)) >> ((((u_long)((((((0xff0000
)) - 1) & ((0xff0000))) ^ ((0xff0000)))) >> (16)) !=
0) ? 16 + ((((u_long)(((((((0xff0000) >> 16)) - 1) &
(((0xff0000) >> 16))) ^ (((0xff0000) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)((((((((0xff0000) >> 16) >>
8)) - 1) & ((((0xff0000) >> 16) >> 8))) ^ ((
((0xff0000) >> 16) >> 8)))) >> (4)) != 0) ?
4 + ((((u_long)(((((((((0xff0000) >> 16) >> 8) >>
4)) - 1) & (((((0xff0000) >> 16) >> 8) >>
4))) ^ (((((0xff0000) >> 16) >> 8) >> 4)))
) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff0000) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0xff0000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xff0000) >> 16) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xff0000
) >> 16) >> 8) >> 4)))) ^ ((((((0xff0000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff0000) >> 16) >> 8))) -
1) & (((((0xff0000) >> 16) >> 8)))) ^ (((((0xff0000
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xff0000) >> 16) >> 8)) >>
2)) - 1) & ((((((0xff0000) >> 16) >> 8)) >>
2))) ^ ((((((0xff0000) >> 16) >> 8)) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0000
) >> 16) >> 8)))) - 1) & ((((((0xff0000) >>
16) >> 8))))) ^ ((((((0xff0000) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff0000
) >> 16))) - 1) & ((((0xff0000) >> 16)))) ^ (
(((0xff0000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xff0000) >> 16)) >> 4)) - 1) & (((
((0xff0000) >> 16)) >> 4))) ^ (((((0xff0000) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xff0000) >> 16)) >> 4) >> 2)) - 1) &
((((((0xff0000) >> 16)) >> 4) >> 2))) ^ ((
((((0xff0000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0000) >>
16)) >> 4))) - 1) & ((((((0xff0000) >> 16)) >>
4)))) ^ ((((((0xff0000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff0000) >>
16)))) - 1) & (((((0xff0000) >> 16))))) ^ (((((0xff0000
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0xff0000) >> 16))) >> 2)) - 1) & ((((((
0xff0000) >> 16))) >> 2))) ^ ((((((0xff0000) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff0000) >> 16))))) - 1) & ((((((0xff0000
) >> 16)))))) ^ ((((((0xff0000) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xff0000))) - 1) &
(((0xff0000)))) ^ (((0xff0000))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0xff0000)) >> 8)) - 1) & ((((0xff0000
)) >> 8))) ^ ((((0xff0000)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xff0000)) >> 8) >>
4)) - 1) & (((((0xff0000)) >> 8) >> 4))) ^ (
((((0xff0000)) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xff0000)) >> 8) >> 4
) >> 2)) - 1) & ((((((0xff0000)) >> 8) >>
4) >> 2))) ^ ((((((0xff0000)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0000
)) >> 8) >> 4))) - 1) & ((((((0xff0000)) >>
8) >> 4)))) ^ ((((((0xff0000)) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff0000
)) >> 8))) - 1) & (((((0xff0000)) >> 8)))) ^ (
((((0xff0000)) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xff0000)) >> 8)) >> 2)) - 1) &
((((((0xff0000)) >> 8)) >> 2))) ^ ((((((0xff0000
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xff0000)) >> 8)))) - 1) & ((
((((0xff0000)) >> 8))))) ^ ((((((0xff0000)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff0000
)))) - 1) & ((((0xff0000))))) ^ ((((0xff0000)))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xff0000))) >> 4)
) - 1) & (((((0xff0000))) >> 4))) ^ (((((0xff0000))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xff0000))) >> 4) >> 2)) - 1) & ((((((0xff0000
))) >> 4) >> 2))) ^ ((((((0xff0000))) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0xff0000))) >> 4))) - 1) & ((((((0xff0000)))
>> 4)))) ^ ((((((0xff0000))) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff0000))))) - 1) &
(((((0xff0000)))))) ^ (((((0xff0000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0xff0000)))) >> 2)) - 1) &
((((((0xff0000)))) >> 2))) ^ ((((((0xff0000)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0000
)))))) - 1) & ((((((0xff0000))))))) ^ ((((((0xff0000)))))
))) >> (1)) != 0) ? 1 : 0))))))
;
792 (*addr)[3] = MASK_AND_RSHIFT(idr0, 0xff000000)(((idr0) & (0xff000000)) >> ((((u_long)((((((0xff000000
)) - 1) & ((0xff000000))) ^ ((0xff000000)))) >> (16
)) != 0) ? 16 + ((((u_long)(((((((0xff000000) >> 16)) -
1) & (((0xff000000) >> 16))) ^ (((0xff000000) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xff000000
) >> 16) >> 8)) - 1) & ((((0xff000000) >>
16) >> 8))) ^ ((((0xff000000) >> 16) >> 8)
))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff000000)
>> 16) >> 8) >> 4)) - 1) & (((((0xff000000
) >> 16) >> 8) >> 4))) ^ (((((0xff000000) >>
16) >> 8) >> 4)))) >> (2)) != 0) ? 2 + (((
(u_long)((((((((((0xff000000) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xff000000) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xff000000) >> 16
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xff000000) >> 16) >>
8) >> 4))) - 1) & ((((((0xff000000) >> 16) >>
8) >> 4)))) ^ ((((((0xff000000) >> 16) >> 8
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xff000000) >> 16) >> 8))) - 1) & ((
(((0xff000000) >> 16) >> 8)))) ^ (((((0xff000000)
>> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff000000) >> 16) >> 8)) >> 2))
- 1) & ((((((0xff000000) >> 16) >> 8)) >>
2))) ^ ((((((0xff000000) >> 16) >> 8)) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff000000
) >> 16) >> 8)))) - 1) & ((((((0xff000000) >>
16) >> 8))))) ^ ((((((0xff000000) >> 16) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
0xff000000) >> 16))) - 1) & ((((0xff000000) >>
16)))) ^ ((((0xff000000) >> 16))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xff000000) >> 16)) >>
4)) - 1) & (((((0xff000000) >> 16)) >> 4))) ^
(((((0xff000000) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xff000000) >> 16)) >>
4) >> 2)) - 1) & ((((((0xff000000) >> 16)) >>
4) >> 2))) ^ ((((((0xff000000) >> 16)) >> 4
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
((((((((0xff000000) >> 16)) >> 4))) - 1) & ((
((((0xff000000) >> 16)) >> 4)))) ^ ((((((0xff000000
) >> 16)) >> 4))))) >> (1)) != 0) ? 1 : 0))
: ((((u_long)(((((((((0xff000000) >> 16)))) - 1) &
(((((0xff000000) >> 16))))) ^ (((((0xff000000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff000000
) >> 16))) >> 2)) - 1) & ((((((0xff000000) >>
16))) >> 2))) ^ ((((((0xff000000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff000000
) >> 16))))) - 1) & ((((((0xff000000) >> 16))
)))) ^ ((((((0xff000000) >> 16))))))) >> (1)) != 0
) ? 1 : 0)))) : ((((u_long)(((((((0xff000000))) - 1) & ((
(0xff000000)))) ^ (((0xff000000))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0xff000000)) >> 8)) - 1) & ((((
0xff000000)) >> 8))) ^ ((((0xff000000)) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xff000000)) >> 8
) >> 4)) - 1) & (((((0xff000000)) >> 8) >>
4))) ^ (((((0xff000000)) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff000000)) >> 8
) >> 4) >> 2)) - 1) & ((((((0xff000000)) >>
8) >> 4) >> 2))) ^ ((((((0xff000000)) >> 8
) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0xff000000)) >> 8) >> 4))) - 1
) & ((((((0xff000000)) >> 8) >> 4)))) ^ (((((
(0xff000000)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xff000000)) >> 8))) -
1) & (((((0xff000000)) >> 8)))) ^ (((((0xff000000)
) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((
((((0xff000000)) >> 8)) >> 2)) - 1) & ((((((0xff000000
)) >> 8)) >> 2))) ^ ((((((0xff000000)) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0xff000000)) >> 8)))) - 1) & ((((((0xff000000
)) >> 8))))) ^ ((((((0xff000000)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff000000)))) - 1
) & ((((0xff000000))))) ^ ((((0xff000000)))))) >> (
4)) != 0) ? 4 + ((((u_long)(((((((((0xff000000))) >> 4)
) - 1) & (((((0xff000000))) >> 4))) ^ (((((0xff000000
))) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff000000))) >> 4) >> 2)) - 1) & ((((((
0xff000000))) >> 4) >> 2))) ^ ((((((0xff000000)))
>> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((
((u_long)((((((((((0xff000000))) >> 4))) - 1) & (((
(((0xff000000))) >> 4)))) ^ ((((((0xff000000))) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff000000
))))) - 1) & (((((0xff000000)))))) ^ (((((0xff000000)))))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff000000)
))) >> 2)) - 1) & ((((((0xff000000)))) >> 2))
) ^ ((((((0xff000000)))) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xff000000)))))) - 1) & ((
((((0xff000000))))))) ^ ((((((0xff000000)))))))) >> (1)
) != 0) ? 1 : 0))))))
;
793
794 (*addr)[4] = MASK_AND_RSHIFT(idr1, 0xff)(((idr1) & (0xff)) >> ((((u_long)((((((0xff)) - 1) &
((0xff))) ^ ((0xff)))) >> (16)) != 0) ? 16 + ((((u_long
)(((((((0xff) >> 16)) - 1) & (((0xff) >> 16))
) ^ (((0xff) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xff) >> 16) >> 8)) - 1) & ((((0xff)
>> 16) >> 8))) ^ ((((0xff) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >>
16) >> 8) >> 4)) - 1) & (((((0xff) >> 16
) >> 8) >> 4))) ^ (((((0xff) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff) >> 16) >> 8) >> 4) >> 2)) -
1) & ((((((0xff) >> 16) >> 8) >> 4) >>
2))) ^ ((((((0xff) >> 16) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
) >> 16) >> 8) >> 4))) - 1) & ((((((0xff
) >> 16) >> 8) >> 4)))) ^ ((((((0xff) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff) >> 16) >> 8))) - 1)
& (((((0xff) >> 16) >> 8)))) ^ (((((0xff) >>
16) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xff) >> 16) >> 8)) >> 2)) - 1) &
((((((0xff) >> 16) >> 8)) >> 2))) ^ ((((((
0xff) >> 16) >> 8)) >> 2)))) >> (1)) !=
0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16) >>
8)))) - 1) & ((((((0xff) >> 16) >> 8))))) ^ (
(((((0xff) >> 16) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0xff) >> 16))) - 1) &
((((0xff) >> 16)))) ^ ((((0xff) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >> 16)) >>
4)) - 1) & (((((0xff) >> 16)) >> 4))) ^ ((((
(0xff) >> 16)) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)((((((((((0xff) >> 16)) >> 4) >>
2)) - 1) & ((((((0xff) >> 16)) >> 4) >>
2))) ^ ((((((0xff) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16
)) >> 4))) - 1) & ((((((0xff) >> 16)) >>
4)))) ^ ((((((0xff) >> 16)) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff) >> 16))
)) - 1) & (((((0xff) >> 16))))) ^ (((((0xff) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff
) >> 16))) >> 2)) - 1) & ((((((0xff) >>
16))) >> 2))) ^ ((((((0xff) >> 16))) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff)
>> 16))))) - 1) & ((((((0xff) >> 16)))))) ^ (
(((((0xff) >> 16))))))) >> (1)) != 0) ? 1 : 0))))
: ((((u_long)(((((((0xff))) - 1) & (((0xff)))) ^ (((0xff
))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xff)) >>
8)) - 1) & ((((0xff)) >> 8))) ^ ((((0xff)) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff)) >>
8) >> 4)) - 1) & (((((0xff)) >> 8) >> 4
))) ^ (((((0xff)) >> 8) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xff)) >> 8) >> 4)
>> 2)) - 1) & ((((((0xff)) >> 8) >> 4)
>> 2))) ^ ((((((0xff)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
)) >> 8) >> 4))) - 1) & ((((((0xff)) >>
8) >> 4)))) ^ ((((((0xff)) >> 8) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff)) >>
8))) - 1) & (((((0xff)) >> 8)))) ^ (((((0xff)) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff))
>> 8)) >> 2)) - 1) & ((((((0xff)) >> 8
)) >> 2))) ^ ((((((0xff)) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff)) >> 8
)))) - 1) & ((((((0xff)) >> 8))))) ^ ((((((0xff)) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
0xff)))) - 1) & ((((0xff))))) ^ ((((0xff)))))) >> (
4)) != 0) ? 4 + ((((u_long)(((((((((0xff))) >> 4)) - 1)
& (((((0xff))) >> 4))) ^ (((((0xff))) >> 4))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff))) >>
4) >> 2)) - 1) & ((((((0xff))) >> 4) >>
2))) ^ ((((((0xff))) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff))) >> 4)))
- 1) & ((((((0xff))) >> 4)))) ^ ((((((0xff))) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff
))))) - 1) & (((((0xff)))))) ^ (((((0xff))))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0xff)))) >> 2)) - 1
) & ((((((0xff)))) >> 2))) ^ ((((((0xff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
)))))) - 1) & ((((((0xff))))))) ^ ((((((0xff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
795 (*addr)[5] = MASK_AND_RSHIFT(idr1, 0xff00)(((idr1) & (0xff00)) >> ((((u_long)((((((0xff00)) -
1) & ((0xff00))) ^ ((0xff00)))) >> (16)) != 0) ? 16
+ ((((u_long)(((((((0xff00) >> 16)) - 1) & (((0xff00
) >> 16))) ^ (((0xff00) >> 16)))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xff00) >> 16) >> 8)
) - 1) & ((((0xff00) >> 16) >> 8))) ^ ((((0xff00
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xff00) >> 16) >> 8) >> 4)) - 1) &
(((((0xff00) >> 16) >> 8) >> 4))) ^ (((((0xff00
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xff00) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xff00) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xff00) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xff00) >> 16) >> 8) >>
4))) - 1) & ((((((0xff00) >> 16) >> 8) >>
4)))) ^ ((((((0xff00) >> 16) >> 8) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00
) >> 16) >> 8))) - 1) & (((((0xff00) >>
16) >> 8)))) ^ (((((0xff00) >> 16) >> 8)))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00) >>
16) >> 8)) >> 2)) - 1) & ((((((0xff00) >>
16) >> 8)) >> 2))) ^ ((((((0xff00) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff00) >> 16) >> 8)))) - 1) & (((
(((0xff00) >> 16) >> 8))))) ^ ((((((0xff00) >>
16) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00) >> 16))) - 1) & ((((0xff00) >>
16)))) ^ ((((0xff00) >> 16))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xff00) >> 16)) >> 4)) - 1
) & (((((0xff00) >> 16)) >> 4))) ^ (((((0xff00
) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xff00) >> 16)) >> 4) >> 2
)) - 1) & ((((((0xff00) >> 16)) >> 4) >>
2))) ^ ((((((0xff00) >> 16)) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)
>> 16)) >> 4))) - 1) & ((((((0xff00) >>
16)) >> 4)))) ^ ((((((0xff00) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00
) >> 16)))) - 1) & (((((0xff00) >> 16))))) ^ (
((((0xff00) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00) >> 16))) >> 2)) - 1) & (((
(((0xff00) >> 16))) >> 2))) ^ ((((((0xff00) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff00) >> 16))))) - 1) & ((((((0xff00) >>
16)))))) ^ ((((((0xff00) >> 16))))))) >> (1)) !=
0) ? 1 : 0)))) : ((((u_long)(((((((0xff00))) - 1) & (((0xff00
)))) ^ (((0xff00))))) >> (8)) != 0) ? 8 + ((((u_long)((
((((((0xff00)) >> 8)) - 1) & ((((0xff00)) >> 8
))) ^ ((((0xff00)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xff00)) >> 8) >> 4)) - 1) &
(((((0xff00)) >> 8) >> 4))) ^ (((((0xff00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff00)) >> 8) >> 4) >> 2)) - 1) &
((((((0xff00)) >> 8) >> 4) >> 2))) ^ (((((
(0xff00)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8) >>
4))) - 1) & ((((((0xff00)) >> 8) >> 4)))) ^ (
(((((0xff00)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xff00)) >> 8))) - 1) &
(((((0xff00)) >> 8)))) ^ (((((0xff00)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00)) >>
8)) >> 2)) - 1) & ((((((0xff00)) >> 8)) >>
2))) ^ ((((((0xff00)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8
)))) - 1) & ((((((0xff00)) >> 8))))) ^ ((((((0xff00
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00)))) - 1) & ((((0xff00))))) ^ ((((0xff00))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff00))) >>
4)) - 1) & (((((0xff00))) >> 4))) ^ (((((0xff00)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xff00))) >> 4) >> 2)) - 1) & ((((((0xff00)
)) >> 4) >> 2))) ^ ((((((0xff00))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
))) >> 4))) - 1) & ((((((0xff00))) >> 4)))) ^
((((((0xff00))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff00))))) - 1) & (((((0xff00)))
))) ^ (((((0xff00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00)))) >> 2)) - 1) & ((((((0xff00)))
) >> 2))) ^ ((((((0xff00)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)))))) - 1) &
((((((0xff00))))))) ^ ((((((0xff00)))))))) >> (1)) != 0
) ? 1 : 0))))))
;
796
797 if (IEEE80211_ADDR_EQ(addr, empty_macaddr)(__builtin_memcmp((addr), (empty_macaddr), (6)) == 0)) {
798 printf("\n%s: could not get mac address, attach failed\n",
799 dvname);
800 return ENXIO6;
801 }
802
803 printf("address %s\n", ether_sprintf(*addr));
804
805 return 0;
806}
807
808u_int8_t
809rtw_chan2txpower(struct rtw_srom *sr, struct ieee80211com *ic,
810 struct ieee80211_channel *chan)
811{
812 u_int idx = RTW_SR_TXPOWER10x20 + ieee80211_chan2ieee(ic, chan) - 1;
813 KASSERT2(idx >= RTW_SR_TXPOWER1 && idx <= RTW_SR_TXPOWER14,do { if (!(idx >= 0x20 && idx <= 0x2d)) panic (
"%s: channel %d out of range", __func__, idx - 0x20 + 1) ; } while
(0)
814 ("%s: channel %d out of range", __func__,do { if (!(idx >= 0x20 && idx <= 0x2d)) panic (
"%s: channel %d out of range", __func__, idx - 0x20 + 1) ; } while
(0)
815 idx - RTW_SR_TXPOWER1 + 1))do { if (!(idx >= 0x20 && idx <= 0x2d)) panic (
"%s: channel %d out of range", __func__, idx - 0x20 + 1) ; } while
(0)
;
816 return RTW_SR_GET(sr, idx)(((sr)->sr_content[(idx)/2] >> (((idx) % 2 == 0) ? 0
: 8)) & 0xff)
;
817}
818
819void
820rtw_txdesc_blk_init_all(struct rtw_txdesc_blk *tdb)
821{
822 int pri;
823 /* nfree: the number of free descriptors in each ring.
824 * The beacon ring is a special case: I do not let the
825 * driver use all of the descriptors on the beacon ring.
826 * The reasons are two-fold:
827 *
828 * (1) A BEACON descriptor's OWN bit is (apparently) not
829 * updated, so the driver cannot easily know if the descriptor
830 * belongs to it, or if it is racing the NIC. If the NIC
831 * does not OWN every descriptor, then the driver can safely
832 * update the descriptors when RTW_TBDA points at tdb_next.
833 *
834 * (2) I hope that the NIC will process more than one BEACON
835 * descriptor in a single beacon interval, since that will
836 * enable multiple-BSS support. Since the NIC does not
837 * clear the OWN bit, there is no natural place for it to
838 * stop processing BEACON descriptors. Maybe it will *not*
839 * stop processing them! I do not want to chance the NIC
840 * looping around and around a saturated beacon ring, so
841 * I will leave one descriptor unOWNed at all times.
842 */
843 u_int nfree[RTW_NTXPRI4] =
844 {RTW_NTXDESCLO64, RTW_NTXDESCMD64, RTW_NTXDESCHI64,
845 RTW_NTXDESCBCN8 - 1};
846
847 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
848 tdb[pri].tdb_nfree = nfree[pri];
849 tdb[pri].tdb_next = 0;
850 }
851}
852
853int
854rtw_txsoft_blk_init(struct rtw_txsoft_blk *tsb)
855{
856 int i;
857 struct rtw_txsoft *ts;
858
859 SIMPLEQ_INIT(&tsb->tsb_dirtyq)do { (&tsb->tsb_dirtyq)->sqh_first = ((void *)0); (
&tsb->tsb_dirtyq)->sqh_last = &(&tsb->tsb_dirtyq
)->sqh_first; } while (0)
;
860 SIMPLEQ_INIT(&tsb->tsb_freeq)do { (&tsb->tsb_freeq)->sqh_first = ((void *)0); (&
tsb->tsb_freeq)->sqh_last = &(&tsb->tsb_freeq
)->sqh_first; } while (0)
;
861 for (i = 0; i < tsb->tsb_ndesc; i++) {
862 ts = &tsb->tsb_desc[i];
863 ts->ts_mbuf = NULL((void *)0);
864 SIMPLEQ_INSERT_TAIL(&tsb->tsb_freeq, ts, ts_q)do { (ts)->ts_q.sqe_next = ((void *)0); *(&tsb->tsb_freeq
)->sqh_last = (ts); (&tsb->tsb_freeq)->sqh_last =
&(ts)->ts_q.sqe_next; } while (0)
;
865 }
866 tsb->tsb_tx_timer = 0;
867 return 0;
868}
869
870void
871rtw_txsoft_blk_init_all(struct rtw_txsoft_blk *tsb)
872{
873 int pri;
874 for (pri = 0; pri < RTW_NTXPRI4; pri++)
875 rtw_txsoft_blk_init(&tsb[pri]);
876}
877
878void
879rtw_rxdescs_sync(struct rtw_rxdesc_blk *rdb, int desc0, int nsync, int ops)
880{
881 KASSERT(nsync <= rdb->rdb_ndesc)((nsync <= rdb->rdb_ndesc) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 881, "nsync <= rdb->rdb_ndesc"
))
;
882 /* sync to end of ring */
883 if (desc0 + nsync > rdb->rdb_ndesc) {
884 bus_dmamap_sync(rdb->rdb_dmat, rdb->rdb_dmamap,(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[desc0])), (sizeof(struct rtw_rxdesc) * (rdb->rdb_ndesc - desc0
)), (ops))
885 offsetof(struct rtw_descs, hd_rx[desc0]),(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[desc0])), (sizeof(struct rtw_rxdesc) * (rdb->rdb_ndesc - desc0
)), (ops))
886 sizeof(struct rtw_rxdesc) * (rdb->rdb_ndesc - desc0), ops)(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[desc0])), (sizeof(struct rtw_rxdesc) * (rdb->rdb_ndesc - desc0
)), (ops))
;
887 nsync -= (rdb->rdb_ndesc - desc0);
888 desc0 = 0;
889 }
890
891 KASSERT(desc0 < rdb->rdb_ndesc)((desc0 < rdb->rdb_ndesc) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 891, "desc0 < rdb->rdb_ndesc"
))
;
892 KASSERT(nsync <= rdb->rdb_ndesc)((nsync <= rdb->rdb_ndesc) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 892, "nsync <= rdb->rdb_ndesc"
))
;
893 KASSERT(desc0 + nsync <= rdb->rdb_ndesc)((desc0 + nsync <= rdb->rdb_ndesc) ? (void)0 : __assert
("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 893, "desc0 + nsync <= rdb->rdb_ndesc"
))
;
894
895 /* sync what remains */
896 bus_dmamap_sync(rdb->rdb_dmat, rdb->rdb_dmamap,(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[desc0])), (sizeof(struct rtw_rxdesc) * nsync), (ops))
897 offsetof(struct rtw_descs, hd_rx[desc0]),(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[desc0])), (sizeof(struct rtw_rxdesc) * nsync), (ops))
898 sizeof(struct rtw_rxdesc) * nsync, ops)(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[desc0])), (sizeof(struct rtw_rxdesc) * nsync), (ops))
;
899}
900
901void
902rtw_txdescs_sync(struct rtw_txdesc_blk *tdb, u_int desc0, u_int nsync, int ops)
903{
904 /* sync to end of ring */
905 if (desc0 + nsync > tdb->tdb_ndesc) {
906 bus_dmamap_sync(tdb->tdb_dmat, tdb->tdb_dmamap,(*(tdb->tdb_dmat)->_dmamap_sync)((tdb->tdb_dmat), (tdb
->tdb_dmamap), (tdb->tdb_ofs + sizeof(struct rtw_txdesc
) * desc0), (sizeof(struct rtw_txdesc) * (tdb->tdb_ndesc -
desc0)), (ops))
907 tdb->tdb_ofs + sizeof(struct rtw_txdesc) * desc0,(*(tdb->tdb_dmat)->_dmamap_sync)((tdb->tdb_dmat), (tdb
->tdb_dmamap), (tdb->tdb_ofs + sizeof(struct rtw_txdesc
) * desc0), (sizeof(struct rtw_txdesc) * (tdb->tdb_ndesc -
desc0)), (ops))
908 sizeof(struct rtw_txdesc) * (tdb->tdb_ndesc - desc0),(*(tdb->tdb_dmat)->_dmamap_sync)((tdb->tdb_dmat), (tdb
->tdb_dmamap), (tdb->tdb_ofs + sizeof(struct rtw_txdesc
) * desc0), (sizeof(struct rtw_txdesc) * (tdb->tdb_ndesc -
desc0)), (ops))
909 ops)(*(tdb->tdb_dmat)->_dmamap_sync)((tdb->tdb_dmat), (tdb
->tdb_dmamap), (tdb->tdb_ofs + sizeof(struct rtw_txdesc
) * desc0), (sizeof(struct rtw_txdesc) * (tdb->tdb_ndesc -
desc0)), (ops))
;
910 nsync -= (tdb->tdb_ndesc - desc0);
911 desc0 = 0;
912 }
913
914 /* sync what remains */
915 bus_dmamap_sync(tdb->tdb_dmat, tdb->tdb_dmamap,(*(tdb->tdb_dmat)->_dmamap_sync)((tdb->tdb_dmat), (tdb
->tdb_dmamap), (tdb->tdb_ofs + sizeof(struct rtw_txdesc
) * desc0), (sizeof(struct rtw_txdesc) * nsync), (ops))
916 tdb->tdb_ofs + sizeof(struct rtw_txdesc) * desc0,(*(tdb->tdb_dmat)->_dmamap_sync)((tdb->tdb_dmat), (tdb
->tdb_dmamap), (tdb->tdb_ofs + sizeof(struct rtw_txdesc
) * desc0), (sizeof(struct rtw_txdesc) * nsync), (ops))
917 sizeof(struct rtw_txdesc) * nsync, ops)(*(tdb->tdb_dmat)->_dmamap_sync)((tdb->tdb_dmat), (tdb
->tdb_dmamap), (tdb->tdb_ofs + sizeof(struct rtw_txdesc
) * desc0), (sizeof(struct rtw_txdesc) * nsync), (ops))
;
918}
919
920void
921rtw_rxbufs_release(bus_dma_tag_t dmat, struct rtw_rxsoft *desc)
922{
923 int i;
924 struct rtw_rxsoft *rs;
925
926 for (i = 0; i < RTW_RXQLEN64; i++) {
927 rs = &desc[i];
928 if (rs->rs_mbuf == NULL((void *)0))
929 continue;
930 bus_dmamap_sync(dmat, rs->rs_dmamap, 0,(*(dmat)->_dmamap_sync)((dmat), (rs->rs_dmamap), (0), (
rs->rs_dmamap->dm_mapsize), (0x02))
931 rs->rs_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD)(*(dmat)->_dmamap_sync)((dmat), (rs->rs_dmamap), (0), (
rs->rs_dmamap->dm_mapsize), (0x02))
;
932 bus_dmamap_unload(dmat, rs->rs_dmamap)(*(dmat)->_dmamap_unload)((dmat), (rs->rs_dmamap));
933 m_freem(rs->rs_mbuf);
934 rs->rs_mbuf = NULL((void *)0);
935 }
936}
937
938int
939rtw_rxsoft_alloc(bus_dma_tag_t dmat, struct rtw_rxsoft *rs)
940{
941 int rc;
942 struct mbuf *m;
943
944 MGETHDR(m, M_DONTWAIT, MT_DATA)m = m_gethdr((0x0002), (1));
945 if (m == NULL((void *)0))
946 return ENOBUFS55;
947
948 MCLGET(m, M_DONTWAIT)(void) m_clget((m), (0x0002), (1 << 11));
949 if ((m->m_flagsm_hdr.mh_flags & M_EXT0x0001) == 0) {
950 m_freem(m);
951 return ENOBUFS55;
952 }
953
954 m->m_pkthdrM_dat.MH.MH_pkthdr.len = m->m_lenm_hdr.mh_len = m->m_extM_dat.MH.MH_dat.MH_ext.ext_size;
955
956 if (rs->rs_mbuf != NULL((void *)0))
957 bus_dmamap_unload(dmat, rs->rs_dmamap)(*(dmat)->_dmamap_unload)((dmat), (rs->rs_dmamap));
958
959 rs->rs_mbuf = NULL((void *)0);
960
961 rc = bus_dmamap_load_mbuf(dmat, rs->rs_dmamap, m, BUS_DMA_NOWAIT)(*(dmat)->_dmamap_load_mbuf)((dmat), (rs->rs_dmamap), (
m), (0x0001))
;
962 if (rc != 0) {
963 m_freem(m);
964 return -1;
965 }
966
967 rs->rs_mbuf = m;
968
969 return 0;
970}
971
972int
973rtw_rxsoft_init_all(bus_dma_tag_t dmat, struct rtw_rxsoft *desc,
974 int *ndesc, const char *dvname)
975{
976 int i, rc = 0;
977 struct rtw_rxsoft *rs;
978
979 for (i = 0; i < RTW_RXQLEN64; i++) {
980 rs = &desc[i];
981 /* we're in rtw_init, so there should be no mbufs allocated */
982 KASSERT(rs->rs_mbuf == NULL)((rs->rs_mbuf == ((void *)0)) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 982, "rs->rs_mbuf == NULL")
)
;
983#ifdef RTW_DEBUG
984 if (i == rtw_rxbufs_limit) {
985 printf("%s: TEST hit %d-buffer limit\n", dvname, i);
986 rc = ENOBUFS55;
987 break;
988 }
989#endif /* RTW_DEBUG */
990 if ((rc = rtw_rxsoft_alloc(dmat, rs)) != 0) {
991 printf("%s: rtw_rxsoft_alloc failed, %d buffers, "
992 "rc %d\n", dvname, i, rc);
993 break;
994 }
995 }
996 *ndesc = i;
997 return rc;
998}
999
1000void
1001rtw_rxdesc_init(struct rtw_rxdesc_blk *rdb, struct rtw_rxsoft *rs,
1002 int idx, int kick)
1003{
1004 int is_last = (idx == rdb->rdb_ndesc - 1);
1005 uint32_t ctl, octl, obuf;
1006 struct rtw_rxdesc *rd = &rdb->rdb_desc[idx];
1007
1008 obuf = rd->rd_buf;
1009 rd->rd_buf = htole32(rs->rs_dmamap->dm_segs[0].ds_addr)((__uint32_t)(rs->rs_dmamap->dm_segs[0].ds_addr));
1010
1011 ctl = LSHIFT(rs->rs_mbuf->m_len, RTW_RXCTL_LENGTH_MASK)((rs->rs_mbuf->m_hdr.mh_len) << ((((u_long)((((((
0xfff)) - 1) & ((0xfff))) ^ ((0xfff)))) >> (16)) !=
0) ? 16 + ((((u_long)(((((((0xfff) >> 16)) - 1) & (
((0xfff) >> 16))) ^ (((0xfff) >> 16)))) >> (
8)) != 0) ? 8 + ((((u_long)((((((((0xfff) >> 16) >>
8)) - 1) & ((((0xfff) >> 16) >> 8))) ^ ((((0xfff
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xfff) >> 16) >> 8) >> 4)) - 1) &
(((((0xfff) >> 16) >> 8) >> 4))) ^ (((((0xfff
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xfff) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xfff) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xfff) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xfff) >> 16) >> 8) >>
4))) - 1) & ((((((0xfff) >> 16) >> 8) >>
4)))) ^ ((((((0xfff) >> 16) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfff) >>
16) >> 8))) - 1) & (((((0xfff) >> 16) >>
8)))) ^ (((((0xfff) >> 16) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xfff) >> 16) >>
8)) >> 2)) - 1) & ((((((0xfff) >> 16) >>
8)) >> 2))) ^ ((((((0xfff) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfff
) >> 16) >> 8)))) - 1) & ((((((0xfff) >>
16) >> 8))))) ^ ((((((0xfff) >> 16) >> 8))
)))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xfff
) >> 16))) - 1) & ((((0xfff) >> 16)))) ^ ((((
0xfff) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0xfff) >> 16)) >> 4)) - 1) & (((((0xfff
) >> 16)) >> 4))) ^ (((((0xfff) >> 16)) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xfff) >>
16)) >> 4) >> 2)) - 1) & ((((((0xfff) >>
16)) >> 4) >> 2))) ^ ((((((0xfff) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xfff) >> 16)) >> 4))) - 1) & (((((
(0xfff) >> 16)) >> 4)))) ^ ((((((0xfff) >> 16
)) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xfff) >> 16)))) - 1) & (((((0xfff) >>
16))))) ^ (((((0xfff) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xfff) >> 16))) >> 2)) -
1) & ((((((0xfff) >> 16))) >> 2))) ^ ((((((0xfff
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xfff) >> 16))))) - 1) & ((((
((0xfff) >> 16)))))) ^ ((((((0xfff) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xfff))) - 1) &
(((0xfff)))) ^ (((0xfff))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xfff)) >> 8)) - 1) & ((((0xfff)) >>
8))) ^ ((((0xfff)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xfff)) >> 8) >> 4)) - 1) &
(((((0xfff)) >> 8) >> 4))) ^ (((((0xfff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xfff)) >> 8) >> 4) >> 2)) - 1) & (
(((((0xfff)) >> 8) >> 4) >> 2))) ^ ((((((0xfff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xfff)) >> 8) >>
4))) - 1) & ((((((0xfff)) >> 8) >> 4)))) ^ (
(((((0xfff)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0xfff)) >> 8))) - 1) &
(((((0xfff)) >> 8)))) ^ (((((0xfff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff)) >> 8)) >>
2)) - 1) & ((((((0xfff)) >> 8)) >> 2))) ^ ((
((((0xfff)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xfff)) >> 8)))) - 1) &
((((((0xfff)) >> 8))))) ^ ((((((0xfff)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xfff)
))) - 1) & ((((0xfff))))) ^ ((((0xfff)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0xfff))) >> 4)) - 1) &
(((((0xfff))) >> 4))) ^ (((((0xfff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff))) >> 4) >>
2)) - 1) & ((((((0xfff))) >> 4) >> 2))) ^ ((
((((0xfff))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xfff))) >> 4))) - 1) &
((((((0xfff))) >> 4)))) ^ ((((((0xfff))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfff)
)))) - 1) & (((((0xfff)))))) ^ (((((0xfff))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff)))) >> 2))
- 1) & ((((((0xfff)))) >> 2))) ^ ((((((0xfff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfff
)))))) - 1) & ((((((0xfff))))))) ^ ((((((0xfff)))))))) >>
(1)) != 0) ? 1 : 0))))))
|
1012 RTW_RXCTL_OWN(1<<31) | RTW_RXCTL_FS(1<<29) | RTW_RXCTL_LS(1<<28);
1013
1014 if (is_last)
1015 ctl |= RTW_RXCTL_EOR(1<<30);
1016
1017 octl = rd->rd_ctl;
1018 rd->rd_ctl = htole32(ctl)((__uint32_t)(ctl));
1019
1020 RTW_DPRINTF(kick ? (RTW_DEBUG_RECV_DESC | RTW_DEBUG_IO_KICK)
1021 : RTW_DEBUG_RECV_DESC,
1022 ("%s: rd %p buf %08x -> %08x ctl %08x -> %08x\n", __func__, rd,
1023 letoh32(obuf), letoh32(rd->rd_buf), letoh32(octl),
1024 letoh32(rd->rd_ctl)));
1025
1026 /* sync the mbuf */
1027 bus_dmamap_sync(rdb->rdb_dmat, rs->rs_dmamap, 0,(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rs
->rs_dmamap), (0), (rs->rs_dmamap->dm_mapsize), (0x01
))
1028 rs->rs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD)(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rs
->rs_dmamap), (0), (rs->rs_dmamap->dm_mapsize), (0x01
))
;
1029
1030 /* sync the descriptor */
1031 bus_dmamap_sync(rdb->rdb_dmat, rdb->rdb_dmamap,(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[idx])), (sizeof(struct rtw_rxdesc)), (0x01|0x04))
1032 RTW_DESC_OFFSET(hd_rx, idx), sizeof(struct rtw_rxdesc),(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[idx])), (sizeof(struct rtw_rxdesc)), (0x01|0x04))
1033 BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)(*(rdb->rdb_dmat)->_dmamap_sync)((rdb->rdb_dmat), (rdb
->rdb_dmamap), (__builtin_offsetof(struct rtw_descs, hd_rx
[idx])), (sizeof(struct rtw_rxdesc)), (0x01|0x04))
;
1034}
1035
1036void
1037rtw_rxdesc_init_all(struct rtw_rxdesc_blk *rdb, struct rtw_rxsoft *ctl,
1038 int kick)
1039{
1040 int i;
1041 struct rtw_rxsoft *rs;
1042
1043 for (i = 0; i < rdb->rdb_ndesc; i++) {
1044 rs = &ctl[i];
1045 rtw_rxdesc_init(rdb, rs, i, kick);
1046 }
1047}
1048
1049void
1050rtw_io_enable(struct rtw_regs *regs, u_int8_t flags, int enable)
1051{
1052 u_int8_t cr;
1053
1054 RTW_DPRINTF(RTW_DEBUG_IOSTATE, ("%s: %s 0x%02x\n", __func__,
1055 enable ? "enable" : "disable", flags));
1056
1057 cr = RTW_READ8(regs, RTW_CR)((*(regs)->r_read8)(regs, 0x37));
1058
1059 /* XXX reference source does not enable MULRW */
1060#if 0
1061 /* enable PCI Read/Write Multiple */
1062 cr |= RTW_CR_MULRW(1<<0);
1063#endif
1064
1065 RTW_RBW(regs, RTW_CR, RTW_CR)((*(regs)->r_barrier)(regs, 0x37, 0x37, 0x01)); /* XXX paranoia? */
1066 if (enable)
1067 cr |= flags;
1068 else
1069 cr &= ~flags;
1070 RTW_WRITE8(regs, RTW_CR, cr)((*(regs)->r_write8)(regs, 0x37, cr));
1071 RTW_SYNC(regs, RTW_CR, RTW_CR)((*(regs)->r_barrier)(regs, 0x37, 0x37, (0x01|0x02)));
1072}
1073
1074void
1075rtw_intr_rx(struct rtw_softc *sc, u_int16_t isr)
1076{
1077#define IS_BEACON(__fc0) \
1078 ((__fc0 & (IEEE80211_FC0_TYPE_MASK0x0c | IEEE80211_FC0_SUBTYPE_MASK0xf0)) ==\
1079 (IEEE80211_FC0_TYPE_MGT0x00 | IEEE80211_FC0_SUBTYPE_BEACON0x80))
1080
1081 static const int ratetbl[4] = {2, 4, 11, 22}; /* convert rates:
1082 * hardware -> net80211
1083 */
1084 struct mbuf_list ml = MBUF_LIST_INITIALIZER(){ ((void *)0), ((void *)0), 0 };
1085 u_int next, nproc = 0;
1086 int hwrate, len, rate, rssi, sq;
1087 u_int32_t hrssi, hstat, htsfth, htsftl;
1088 struct rtw_rxdesc *rd;
1089 struct rtw_rxsoft *rs;
1090 struct rtw_rxdesc_blk *rdb;
1091 struct mbuf *m;
1092 struct ieee80211_rxinfo rxi;
1093 struct ieee80211_node *ni;
1094 struct ieee80211_frame *wh;
1095
1096 rdb = &sc->sc_rxdesc_blk;
1097
1098 KASSERT(rdb->rdb_next < rdb->rdb_ndesc)((rdb->rdb_next < rdb->rdb_ndesc) ? (void)0 : __assert
("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 1098, "rdb->rdb_next < rdb->rdb_ndesc"
))
;
1099
1100 for (next = rdb->rdb_next; ; next = (next + 1) % rdb->rdb_ndesc) {
1101 rtw_rxdescs_sync(rdb, next, 1,
1102 BUS_DMASYNC_POSTREAD0x02|BUS_DMASYNC_POSTWRITE0x08);
1103 rd = &rdb->rdb_desc[next];
1104 rs = &sc->sc_rxsoft[next];
1105
1106 hstat = letoh32(rd->rd_stat)((__uint32_t)(rd->rd_ctl));
1107 hrssi = letoh32(rd->rd_rssi)((__uint32_t)(rd->rd_rsvd0));
1108 htsfth = letoh32(rd->rd_tsfth)((__uint32_t)(rd->rd_rsvd1));
1109 htsftl = letoh32(rd->rd_tsftl)((__uint32_t)(rd->rd_buf));
1110
1111 RTW_DPRINTF(RTW_DEBUG_RECV_DESC,
1112 ("%s: rxdesc[%d] hstat %08x hrssi %08x htsft %08x%08x\n",
1113 __func__, next, hstat, hrssi, htsfth, htsftl));
1114
1115 ++nproc;
1116
1117 /* still belongs to NIC */
1118 if ((hstat & RTW_RXSTAT_OWN(1<<31)) != 0) {
1119 if (nproc > 1)
1120 break;
1121
1122 /* sometimes the NIC skips to the 0th descriptor */
1123 rtw_rxdescs_sync(rdb, 0, 1,
1124 BUS_DMASYNC_POSTREAD0x02|BUS_DMASYNC_POSTWRITE0x08);
1125 rd = &rdb->rdb_desc[0];
1126 if ((rd->rd_statrd_ctl & htole32(RTW_RXSTAT_OWN)((__uint32_t)((1<<31)))) != 0)
1127 break;
1128 RTW_DPRINTF(RTW_DEBUG_BUGS,
1129 ("%s: NIC skipped from rxdesc[%u] to rxdesc[0]\n",
1130 sc->sc_dev.dv_xname, next));
1131 next = rdb->rdb_ndesc - 1;
1132 continue;
1133 }
1134
1135#ifdef RTW_DEBUG
1136#define PRINTSTAT(flag) do { \
1137 if ((hstat & flag) != 0) { \
1138 printf("%s" #flag, delim); \
1139 delim = ","; \
1140 } \
1141} while (0)
1142 if ((rtw_debug & RTW_DEBUG_RECV_DESC) != 0) {
1143 const char *delim = "<";
1144 printf("%s: ", sc->sc_dev.dv_xname);
1145 if ((hstat & RTW_RXSTAT_DEBUG((1<<25)|(1<<18)| (1<<17)|(1<<16)| (1
<<14)|(1<<13)| (1<<12))
) != 0) {
1146 printf("status %08x", hstat);
1147 PRINTSTAT(RTW_RXSTAT_SPLCP(1<<25));
1148 PRINTSTAT(RTW_RXSTAT_MAR(1<<18));
1149 PRINTSTAT(RTW_RXSTAT_PAR(1<<17));
1150 PRINTSTAT(RTW_RXSTAT_BAR(1<<16));
1151 PRINTSTAT(RTW_RXSTAT_PWRMGT(1<<14));
1152 PRINTSTAT(RTW_RXSTAT_CRC32(1<<13));
1153 PRINTSTAT(RTW_RXSTAT_ICV(1<<12));
1154 printf(">, ");
1155 }
1156 }
1157#undef PRINTSTAT
1158#endif /* RTW_DEBUG */
1159
1160 if ((hstat & RTW_RXSTAT_IOERROR((1<<27)|(1<<26))) != 0) {
1161 printf("%s: DMA error/FIFO overflow %08x, "
1162 "rx descriptor %d\n", sc->sc_dev.dv_xname,
1163 hstat & RTW_RXSTAT_IOERROR((1<<27)|(1<<26)), next);
1164 sc->sc_ifsc_ic.ic_ac.ac_if.if_ierrorsif_data.ifi_ierrors++;
1165 goto next;
1166 }
1167
1168 len = MASK_AND_RSHIFT(hstat, RTW_RXSTAT_LENGTH_MASK)(((hstat) & (0xfff)) >> ((((u_long)((((((0xfff)) - 1
) & ((0xfff))) ^ ((0xfff)))) >> (16)) != 0) ? 16 + (
(((u_long)(((((((0xfff) >> 16)) - 1) & (((0xfff) >>
16))) ^ (((0xfff) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0xfff) >> 16) >> 8)) - 1) &
((((0xfff) >> 16) >> 8))) ^ ((((0xfff) >> 16
) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((
((0xfff) >> 16) >> 8) >> 4)) - 1) & (((
((0xfff) >> 16) >> 8) >> 4))) ^ (((((0xfff)
>> 16) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xfff) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xfff) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xfff) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xfff) >> 16) >> 8) >>
4))) - 1) & ((((((0xfff) >> 16) >> 8) >>
4)))) ^ ((((((0xfff) >> 16) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfff) >>
16) >> 8))) - 1) & (((((0xfff) >> 16) >>
8)))) ^ (((((0xfff) >> 16) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xfff) >> 16) >>
8)) >> 2)) - 1) & ((((((0xfff) >> 16) >>
8)) >> 2))) ^ ((((((0xfff) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfff
) >> 16) >> 8)))) - 1) & ((((((0xfff) >>
16) >> 8))))) ^ ((((((0xfff) >> 16) >> 8))
)))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xfff
) >> 16))) - 1) & ((((0xfff) >> 16)))) ^ ((((
0xfff) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0xfff) >> 16)) >> 4)) - 1) & (((((0xfff
) >> 16)) >> 4))) ^ (((((0xfff) >> 16)) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xfff) >>
16)) >> 4) >> 2)) - 1) & ((((((0xfff) >>
16)) >> 4) >> 2))) ^ ((((((0xfff) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xfff) >> 16)) >> 4))) - 1) & (((((
(0xfff) >> 16)) >> 4)))) ^ ((((((0xfff) >> 16
)) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xfff) >> 16)))) - 1) & (((((0xfff) >>
16))))) ^ (((((0xfff) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xfff) >> 16))) >> 2)) -
1) & ((((((0xfff) >> 16))) >> 2))) ^ ((((((0xfff
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xfff) >> 16))))) - 1) & ((((
((0xfff) >> 16)))))) ^ ((((((0xfff) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xfff))) - 1) &
(((0xfff)))) ^ (((0xfff))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xfff)) >> 8)) - 1) & ((((0xfff)) >>
8))) ^ ((((0xfff)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xfff)) >> 8) >> 4)) - 1) &
(((((0xfff)) >> 8) >> 4))) ^ (((((0xfff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xfff)) >> 8) >> 4) >> 2)) - 1) & (
(((((0xfff)) >> 8) >> 4) >> 2))) ^ ((((((0xfff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xfff)) >> 8) >>
4))) - 1) & ((((((0xfff)) >> 8) >> 4)))) ^ (
(((((0xfff)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0xfff)) >> 8))) - 1) &
(((((0xfff)) >> 8)))) ^ (((((0xfff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff)) >> 8)) >>
2)) - 1) & ((((((0xfff)) >> 8)) >> 2))) ^ ((
((((0xfff)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xfff)) >> 8)))) - 1) &
((((((0xfff)) >> 8))))) ^ ((((((0xfff)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xfff)
))) - 1) & ((((0xfff))))) ^ ((((0xfff)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0xfff))) >> 4)) - 1) &
(((((0xfff))) >> 4))) ^ (((((0xfff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff))) >> 4) >>
2)) - 1) & ((((((0xfff))) >> 4) >> 2))) ^ ((
((((0xfff))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xfff))) >> 4))) - 1) &
((((((0xfff))) >> 4)))) ^ ((((((0xfff))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfff)
)))) - 1) & (((((0xfff)))))) ^ (((((0xfff))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff)))) >> 2))
- 1) & ((((((0xfff)))) >> 2))) ^ ((((((0xfff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfff
)))))) - 1) & ((((((0xfff))))))) ^ ((((((0xfff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
1169 if (len < IEEE80211_MIN_LEN(sizeof(struct ieee80211_frame_min) + 4)) {
1170 sc->sc_ic.ic_stats.is_rx_tooshort++;
1171 goto next;
1172 }
1173
1174 /* CRC is included with the packet; trim it off. */
1175 len -= IEEE80211_CRC_LEN4;
1176
1177 hwrate = MASK_AND_RSHIFT(hstat, RTW_RXSTAT_RATE_MASK)(((hstat) & (0xf00000)) >> ((((u_long)((((((0xf00000
)) - 1) & ((0xf00000))) ^ ((0xf00000)))) >> (16)) !=
0) ? 16 + ((((u_long)(((((((0xf00000) >> 16)) - 1) &
(((0xf00000) >> 16))) ^ (((0xf00000) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)((((((((0xf00000) >> 16) >>
8)) - 1) & ((((0xf00000) >> 16) >> 8))) ^ ((
((0xf00000) >> 16) >> 8)))) >> (4)) != 0) ?
4 + ((((u_long)(((((((((0xf00000) >> 16) >> 8) >>
4)) - 1) & (((((0xf00000) >> 16) >> 8) >>
4))) ^ (((((0xf00000) >> 16) >> 8) >> 4)))
) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf00000) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0xf00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xf00000) >> 16) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xf00000
) >> 16) >> 8) >> 4)))) ^ ((((((0xf00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xf00000) >> 16) >> 8))) -
1) & (((((0xf00000) >> 16) >> 8)))) ^ (((((0xf00000
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xf00000) >> 16) >> 8)) >>
2)) - 1) & ((((((0xf00000) >> 16) >> 8)) >>
2))) ^ ((((((0xf00000) >> 16) >> 8)) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000
) >> 16) >> 8)))) - 1) & ((((((0xf00000) >>
16) >> 8))))) ^ ((((((0xf00000) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf00000
) >> 16))) - 1) & ((((0xf00000) >> 16)))) ^ (
(((0xf00000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf00000) >> 16)) >> 4)) - 1) & (((
((0xf00000) >> 16)) >> 4))) ^ (((((0xf00000) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf00000) >> 16)) >> 4) >> 2)) - 1) &
((((((0xf00000) >> 16)) >> 4) >> 2))) ^ ((
((((0xf00000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000) >>
16)) >> 4))) - 1) & ((((((0xf00000) >> 16)) >>
4)))) ^ ((((((0xf00000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf00000) >>
16)))) - 1) & (((((0xf00000) >> 16))))) ^ (((((0xf00000
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0xf00000) >> 16))) >> 2)) - 1) & ((((((
0xf00000) >> 16))) >> 2))) ^ ((((((0xf00000) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xf00000) >> 16))))) - 1) & ((((((0xf00000
) >> 16)))))) ^ ((((((0xf00000) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xf00000))) - 1) &
(((0xf00000)))) ^ (((0xf00000))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0xf00000)) >> 8)) - 1) & ((((0xf00000
)) >> 8))) ^ ((((0xf00000)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xf00000)) >> 8) >>
4)) - 1) & (((((0xf00000)) >> 8) >> 4))) ^ (
((((0xf00000)) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xf00000)) >> 8) >> 4
) >> 2)) - 1) & ((((((0xf00000)) >> 8) >>
4) >> 2))) ^ ((((((0xf00000)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000
)) >> 8) >> 4))) - 1) & ((((((0xf00000)) >>
8) >> 4)))) ^ ((((((0xf00000)) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf00000
)) >> 8))) - 1) & (((((0xf00000)) >> 8)))) ^ (
((((0xf00000)) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xf00000)) >> 8)) >> 2)) - 1) &
((((((0xf00000)) >> 8)) >> 2))) ^ ((((((0xf00000
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xf00000)) >> 8)))) - 1) & ((
((((0xf00000)) >> 8))))) ^ ((((((0xf00000)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf00000
)))) - 1) & ((((0xf00000))))) ^ ((((0xf00000)))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xf00000))) >> 4)
) - 1) & (((((0xf00000))) >> 4))) ^ (((((0xf00000))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xf00000))) >> 4) >> 2)) - 1) & ((((((0xf00000
))) >> 4) >> 2))) ^ ((((((0xf00000))) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0xf00000))) >> 4))) - 1) & ((((((0xf00000)))
>> 4)))) ^ ((((((0xf00000))) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf00000))))) - 1) &
(((((0xf00000)))))) ^ (((((0xf00000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0xf00000)))) >> 2)) - 1) &
((((((0xf00000)))) >> 2))) ^ ((((((0xf00000)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000
)))))) - 1) & ((((((0xf00000))))))) ^ ((((((0xf00000)))))
))) >> (1)) != 0) ? 1 : 0))))))
;
1178 if (hwrate >= sizeof(ratetbl) / sizeof(ratetbl[0])) {
1179 printf("%s: unknown rate #%d\n", sc->sc_dev.dv_xname,
1180 MASK_AND_RSHIFT(hstat, RTW_RXSTAT_RATE_MASK)(((hstat) & (0xf00000)) >> ((((u_long)((((((0xf00000
)) - 1) & ((0xf00000))) ^ ((0xf00000)))) >> (16)) !=
0) ? 16 + ((((u_long)(((((((0xf00000) >> 16)) - 1) &
(((0xf00000) >> 16))) ^ (((0xf00000) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)((((((((0xf00000) >> 16) >>
8)) - 1) & ((((0xf00000) >> 16) >> 8))) ^ ((
((0xf00000) >> 16) >> 8)))) >> (4)) != 0) ?
4 + ((((u_long)(((((((((0xf00000) >> 16) >> 8) >>
4)) - 1) & (((((0xf00000) >> 16) >> 8) >>
4))) ^ (((((0xf00000) >> 16) >> 8) >> 4)))
) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf00000) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0xf00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xf00000) >> 16) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xf00000
) >> 16) >> 8) >> 4)))) ^ ((((((0xf00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xf00000) >> 16) >> 8))) -
1) & (((((0xf00000) >> 16) >> 8)))) ^ (((((0xf00000
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xf00000) >> 16) >> 8)) >>
2)) - 1) & ((((((0xf00000) >> 16) >> 8)) >>
2))) ^ ((((((0xf00000) >> 16) >> 8)) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000
) >> 16) >> 8)))) - 1) & ((((((0xf00000) >>
16) >> 8))))) ^ ((((((0xf00000) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf00000
) >> 16))) - 1) & ((((0xf00000) >> 16)))) ^ (
(((0xf00000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf00000) >> 16)) >> 4)) - 1) & (((
((0xf00000) >> 16)) >> 4))) ^ (((((0xf00000) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf00000) >> 16)) >> 4) >> 2)) - 1) &
((((((0xf00000) >> 16)) >> 4) >> 2))) ^ ((
((((0xf00000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000) >>
16)) >> 4))) - 1) & ((((((0xf00000) >> 16)) >>
4)))) ^ ((((((0xf00000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf00000) >>
16)))) - 1) & (((((0xf00000) >> 16))))) ^ (((((0xf00000
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0xf00000) >> 16))) >> 2)) - 1) & ((((((
0xf00000) >> 16))) >> 2))) ^ ((((((0xf00000) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xf00000) >> 16))))) - 1) & ((((((0xf00000
) >> 16)))))) ^ ((((((0xf00000) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xf00000))) - 1) &
(((0xf00000)))) ^ (((0xf00000))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0xf00000)) >> 8)) - 1) & ((((0xf00000
)) >> 8))) ^ ((((0xf00000)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xf00000)) >> 8) >>
4)) - 1) & (((((0xf00000)) >> 8) >> 4))) ^ (
((((0xf00000)) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xf00000)) >> 8) >> 4
) >> 2)) - 1) & ((((((0xf00000)) >> 8) >>
4) >> 2))) ^ ((((((0xf00000)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000
)) >> 8) >> 4))) - 1) & ((((((0xf00000)) >>
8) >> 4)))) ^ ((((((0xf00000)) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf00000
)) >> 8))) - 1) & (((((0xf00000)) >> 8)))) ^ (
((((0xf00000)) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xf00000)) >> 8)) >> 2)) - 1) &
((((((0xf00000)) >> 8)) >> 2))) ^ ((((((0xf00000
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xf00000)) >> 8)))) - 1) & ((
((((0xf00000)) >> 8))))) ^ ((((((0xf00000)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf00000
)))) - 1) & ((((0xf00000))))) ^ ((((0xf00000)))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xf00000))) >> 4)
) - 1) & (((((0xf00000))) >> 4))) ^ (((((0xf00000))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xf00000))) >> 4) >> 2)) - 1) & ((((((0xf00000
))) >> 4) >> 2))) ^ ((((((0xf00000))) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0xf00000))) >> 4))) - 1) & ((((((0xf00000)))
>> 4)))) ^ ((((((0xf00000))) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf00000))))) - 1) &
(((((0xf00000)))))) ^ (((((0xf00000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0xf00000)))) >> 2)) - 1) &
((((((0xf00000)))) >> 2))) ^ ((((((0xf00000)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00000
)))))) - 1) & ((((((0xf00000))))))) ^ ((((((0xf00000)))))
))) >> (1)) != 0) ? 1 : 0))))))
);
1181 sc->sc_ifsc_ic.ic_ac.ac_if.if_ierrorsif_data.ifi_ierrors++;
1182 goto next;
1183 }
1184 rate = ratetbl[hwrate];
1185
1186#ifdef RTW_DEBUG
1187 RTW_DPRINTF(RTW_DEBUG_RECV_DESC,
1188 ("rate %d.%d Mb/s, time %08x%08x\n", (rate * 5) / 10,
1189 (rate * 5) % 10, htsfth, htsftl));
1190#endif /* RTW_DEBUG */
1191
1192 if ((hstat & RTW_RXSTAT_RES(1<<15)) != 0 &&
1193 sc->sc_ic.ic_opmode != IEEE80211_M_MONITOR)
1194 goto next;
1195
1196 /* if bad flags, skip descriptor */
1197 if ((hstat & RTW_RXSTAT_ONESEG((1<<29)|(1<<28))) != RTW_RXSTAT_ONESEG((1<<29)|(1<<28))) {
1198 printf("%s: too many rx segments\n",
1199 sc->sc_dev.dv_xname);
1200 goto next;
1201 }
1202
1203 bus_dmamap_sync(sc->sc_dmat, rs->rs_dmamap, 0,(*(sc->sc_dmat)->_dmamap_sync)((sc->sc_dmat), (rs->
rs_dmamap), (0), (rs->rs_dmamap->dm_mapsize), (0x02))
1204 rs->rs_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD)(*(sc->sc_dmat)->_dmamap_sync)((sc->sc_dmat), (rs->
rs_dmamap), (0), (rs->rs_dmamap->dm_mapsize), (0x02))
;
1205
1206 m = rs->rs_mbuf;
1207
1208 /* if temporarily out of memory, re-use mbuf */
1209 switch (rtw_rxsoft_alloc(sc->sc_dmat, rs)) {
1210 case 0:
1211 break;
1212 case ENOBUFS55:
1213 printf("%s: rtw_rxsoft_alloc(, %d) failed, "
1214 "dropping this packet\n", sc->sc_dev.dv_xname,
1215 next);
1216 goto next;
1217 default:
1218 /* XXX shorten rx ring, instead? */
1219 panic("%s: could not load DMA map",
1220 sc->sc_dev.dv_xname);
1221 }
1222
1223 if (sc->sc_rfchipid == RTW_RFCHIPID_PHILIPS0x03)
1224 rssi = MASK_AND_RSHIFT(hrssi, RTW_RXRSSI_RSSI)(((hrssi) & (0xff00)) >> ((((u_long)((((((0xff00)) -
1) & ((0xff00))) ^ ((0xff00)))) >> (16)) != 0) ? 16
+ ((((u_long)(((((((0xff00) >> 16)) - 1) & (((0xff00
) >> 16))) ^ (((0xff00) >> 16)))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xff00) >> 16) >> 8)
) - 1) & ((((0xff00) >> 16) >> 8))) ^ ((((0xff00
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xff00) >> 16) >> 8) >> 4)) - 1) &
(((((0xff00) >> 16) >> 8) >> 4))) ^ (((((0xff00
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xff00) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xff00) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xff00) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xff00) >> 16) >> 8) >>
4))) - 1) & ((((((0xff00) >> 16) >> 8) >>
4)))) ^ ((((((0xff00) >> 16) >> 8) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00
) >> 16) >> 8))) - 1) & (((((0xff00) >>
16) >> 8)))) ^ (((((0xff00) >> 16) >> 8)))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00) >>
16) >> 8)) >> 2)) - 1) & ((((((0xff00) >>
16) >> 8)) >> 2))) ^ ((((((0xff00) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff00) >> 16) >> 8)))) - 1) & (((
(((0xff00) >> 16) >> 8))))) ^ ((((((0xff00) >>
16) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00) >> 16))) - 1) & ((((0xff00) >>
16)))) ^ ((((0xff00) >> 16))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xff00) >> 16)) >> 4)) - 1
) & (((((0xff00) >> 16)) >> 4))) ^ (((((0xff00
) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xff00) >> 16)) >> 4) >> 2
)) - 1) & ((((((0xff00) >> 16)) >> 4) >>
2))) ^ ((((((0xff00) >> 16)) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)
>> 16)) >> 4))) - 1) & ((((((0xff00) >>
16)) >> 4)))) ^ ((((((0xff00) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00
) >> 16)))) - 1) & (((((0xff00) >> 16))))) ^ (
((((0xff00) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00) >> 16))) >> 2)) - 1) & (((
(((0xff00) >> 16))) >> 2))) ^ ((((((0xff00) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff00) >> 16))))) - 1) & ((((((0xff00) >>
16)))))) ^ ((((((0xff00) >> 16))))))) >> (1)) !=
0) ? 1 : 0)))) : ((((u_long)(((((((0xff00))) - 1) & (((0xff00
)))) ^ (((0xff00))))) >> (8)) != 0) ? 8 + ((((u_long)((
((((((0xff00)) >> 8)) - 1) & ((((0xff00)) >> 8
))) ^ ((((0xff00)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xff00)) >> 8) >> 4)) - 1) &
(((((0xff00)) >> 8) >> 4))) ^ (((((0xff00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff00)) >> 8) >> 4) >> 2)) - 1) &
((((((0xff00)) >> 8) >> 4) >> 2))) ^ (((((
(0xff00)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8) >>
4))) - 1) & ((((((0xff00)) >> 8) >> 4)))) ^ (
(((((0xff00)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xff00)) >> 8))) - 1) &
(((((0xff00)) >> 8)))) ^ (((((0xff00)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00)) >>
8)) >> 2)) - 1) & ((((((0xff00)) >> 8)) >>
2))) ^ ((((((0xff00)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8
)))) - 1) & ((((((0xff00)) >> 8))))) ^ ((((((0xff00
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00)))) - 1) & ((((0xff00))))) ^ ((((0xff00))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff00))) >>
4)) - 1) & (((((0xff00))) >> 4))) ^ (((((0xff00)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xff00))) >> 4) >> 2)) - 1) & ((((((0xff00)
)) >> 4) >> 2))) ^ ((((((0xff00))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
))) >> 4))) - 1) & ((((((0xff00))) >> 4)))) ^
((((((0xff00))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff00))))) - 1) & (((((0xff00)))
))) ^ (((((0xff00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00)))) >> 2)) - 1) & ((((((0xff00)))
) >> 2))) ^ ((((((0xff00)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)))))) - 1) &
((((((0xff00))))))) ^ ((((((0xff00)))))))) >> (1)) != 0
) ? 1 : 0))))))
;
1225 else {
1226 rssi = MASK_AND_RSHIFT(hrssi, RTW_RXRSSI_IMR_RSSI)(((hrssi) & (0xfe00)) >> ((((u_long)((((((0xfe00)) -
1) & ((0xfe00))) ^ ((0xfe00)))) >> (16)) != 0) ? 16
+ ((((u_long)(((((((0xfe00) >> 16)) - 1) & (((0xfe00
) >> 16))) ^ (((0xfe00) >> 16)))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xfe00) >> 16) >> 8)
) - 1) & ((((0xfe00) >> 16) >> 8))) ^ ((((0xfe00
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xfe00) >> 16) >> 8) >> 4)) - 1) &
(((((0xfe00) >> 16) >> 8) >> 4))) ^ (((((0xfe00
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xfe00) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xfe00) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xfe00) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xfe00) >> 16) >> 8) >>
4))) - 1) & ((((((0xfe00) >> 16) >> 8) >>
4)))) ^ ((((((0xfe00) >> 16) >> 8) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfe00
) >> 16) >> 8))) - 1) & (((((0xfe00) >>
16) >> 8)))) ^ (((((0xfe00) >> 16) >> 8)))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xfe00) >>
16) >> 8)) >> 2)) - 1) & ((((((0xfe00) >>
16) >> 8)) >> 2))) ^ ((((((0xfe00) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xfe00) >> 16) >> 8)))) - 1) & (((
(((0xfe00) >> 16) >> 8))))) ^ ((((((0xfe00) >>
16) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xfe00) >> 16))) - 1) & ((((0xfe00) >>
16)))) ^ ((((0xfe00) >> 16))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xfe00) >> 16)) >> 4)) - 1
) & (((((0xfe00) >> 16)) >> 4))) ^ (((((0xfe00
) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xfe00) >> 16)) >> 4) >> 2
)) - 1) & ((((((0xfe00) >> 16)) >> 4) >>
2))) ^ ((((((0xfe00) >> 16)) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfe00)
>> 16)) >> 4))) - 1) & ((((((0xfe00) >>
16)) >> 4)))) ^ ((((((0xfe00) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfe00
) >> 16)))) - 1) & (((((0xfe00) >> 16))))) ^ (
((((0xfe00) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xfe00) >> 16))) >> 2)) - 1) & (((
(((0xfe00) >> 16))) >> 2))) ^ ((((((0xfe00) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xfe00) >> 16))))) - 1) & ((((((0xfe00) >>
16)))))) ^ ((((((0xfe00) >> 16))))))) >> (1)) !=
0) ? 1 : 0)))) : ((((u_long)(((((((0xfe00))) - 1) & (((0xfe00
)))) ^ (((0xfe00))))) >> (8)) != 0) ? 8 + ((((u_long)((
((((((0xfe00)) >> 8)) - 1) & ((((0xfe00)) >> 8
))) ^ ((((0xfe00)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xfe00)) >> 8) >> 4)) - 1) &
(((((0xfe00)) >> 8) >> 4))) ^ (((((0xfe00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xfe00)) >> 8) >> 4) >> 2)) - 1) &
((((((0xfe00)) >> 8) >> 4) >> 2))) ^ (((((
(0xfe00)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfe00)) >> 8) >>
4))) - 1) & ((((((0xfe00)) >> 8) >> 4)))) ^ (
(((((0xfe00)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xfe00)) >> 8))) - 1) &
(((((0xfe00)) >> 8)))) ^ (((((0xfe00)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xfe00)) >>
8)) >> 2)) - 1) & ((((((0xfe00)) >> 8)) >>
2))) ^ ((((((0xfe00)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfe00)) >> 8
)))) - 1) & ((((((0xfe00)) >> 8))))) ^ ((((((0xfe00
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xfe00)))) - 1) & ((((0xfe00))))) ^ ((((0xfe00))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xfe00))) >>
4)) - 1) & (((((0xfe00))) >> 4))) ^ (((((0xfe00)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xfe00))) >> 4) >> 2)) - 1) & ((((((0xfe00)
)) >> 4) >> 2))) ^ ((((((0xfe00))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfe00
))) >> 4))) - 1) & ((((((0xfe00))) >> 4)))) ^
((((((0xfe00))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xfe00))))) - 1) & (((((0xfe00)))
))) ^ (((((0xfe00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xfe00)))) >> 2)) - 1) & ((((((0xfe00)))
) >> 2))) ^ ((((((0xfe00)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfe00)))))) - 1) &
((((((0xfe00))))))) ^ ((((((0xfe00)))))))) >> (1)) != 0
) ? 1 : 0))))))
;
1227 /* TBD find out each front-end's LNA gain in the
1228 * front-end's units
1229 */
1230 if ((hrssi & RTW_RXRSSI_IMR_LNA(1<<8)) == 0)
1231 rssi |= 0x80;
1232 }
1233
1234 sq = MASK_AND_RSHIFT(hrssi, RTW_RXRSSI_SQ)(((hrssi) & (0xff)) >> ((((u_long)((((((0xff)) - 1)
& ((0xff))) ^ ((0xff)))) >> (16)) != 0) ? 16 + (((
(u_long)(((((((0xff) >> 16)) - 1) & (((0xff) >>
16))) ^ (((0xff) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0xff) >> 16) >> 8)) - 1) & (
(((0xff) >> 16) >> 8))) ^ ((((0xff) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >>
16) >> 8) >> 4)) - 1) & (((((0xff) >> 16
) >> 8) >> 4))) ^ (((((0xff) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff) >> 16) >> 8) >> 4) >> 2)) -
1) & ((((((0xff) >> 16) >> 8) >> 4) >>
2))) ^ ((((((0xff) >> 16) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
) >> 16) >> 8) >> 4))) - 1) & ((((((0xff
) >> 16) >> 8) >> 4)))) ^ ((((((0xff) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff) >> 16) >> 8))) - 1)
& (((((0xff) >> 16) >> 8)))) ^ (((((0xff) >>
16) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xff) >> 16) >> 8)) >> 2)) - 1) &
((((((0xff) >> 16) >> 8)) >> 2))) ^ ((((((
0xff) >> 16) >> 8)) >> 2)))) >> (1)) !=
0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16) >>
8)))) - 1) & ((((((0xff) >> 16) >> 8))))) ^ (
(((((0xff) >> 16) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0xff) >> 16))) - 1) &
((((0xff) >> 16)))) ^ ((((0xff) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >> 16)) >>
4)) - 1) & (((((0xff) >> 16)) >> 4))) ^ ((((
(0xff) >> 16)) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)((((((((((0xff) >> 16)) >> 4) >>
2)) - 1) & ((((((0xff) >> 16)) >> 4) >>
2))) ^ ((((((0xff) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16
)) >> 4))) - 1) & ((((((0xff) >> 16)) >>
4)))) ^ ((((((0xff) >> 16)) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff) >> 16))
)) - 1) & (((((0xff) >> 16))))) ^ (((((0xff) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff
) >> 16))) >> 2)) - 1) & ((((((0xff) >>
16))) >> 2))) ^ ((((((0xff) >> 16))) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff)
>> 16))))) - 1) & ((((((0xff) >> 16)))))) ^ (
(((((0xff) >> 16))))))) >> (1)) != 0) ? 1 : 0))))
: ((((u_long)(((((((0xff))) - 1) & (((0xff)))) ^ (((0xff
))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xff)) >>
8)) - 1) & ((((0xff)) >> 8))) ^ ((((0xff)) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff)) >>
8) >> 4)) - 1) & (((((0xff)) >> 8) >> 4
))) ^ (((((0xff)) >> 8) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xff)) >> 8) >> 4)
>> 2)) - 1) & ((((((0xff)) >> 8) >> 4)
>> 2))) ^ ((((((0xff)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
)) >> 8) >> 4))) - 1) & ((((((0xff)) >>
8) >> 4)))) ^ ((((((0xff)) >> 8) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff)) >>
8))) - 1) & (((((0xff)) >> 8)))) ^ (((((0xff)) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff))
>> 8)) >> 2)) - 1) & ((((((0xff)) >> 8
)) >> 2))) ^ ((((((0xff)) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff)) >> 8
)))) - 1) & ((((((0xff)) >> 8))))) ^ ((((((0xff)) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
0xff)))) - 1) & ((((0xff))))) ^ ((((0xff)))))) >> (
4)) != 0) ? 4 + ((((u_long)(((((((((0xff))) >> 4)) - 1)
& (((((0xff))) >> 4))) ^ (((((0xff))) >> 4))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff))) >>
4) >> 2)) - 1) & ((((((0xff))) >> 4) >>
2))) ^ ((((((0xff))) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff))) >> 4)))
- 1) & ((((((0xff))) >> 4)))) ^ ((((((0xff))) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff
))))) - 1) & (((((0xff)))))) ^ (((((0xff))))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0xff)))) >> 2)) - 1
) & ((((((0xff)))) >> 2))) ^ ((((((0xff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
)))))) - 1) & ((((((0xff))))))) ^ ((((((0xff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
1235
1236 /*
1237 * Note well: now we cannot recycle the rs_mbuf unless
1238 * we restore its original length.
1239 */
1240 m->m_pkthdrM_dat.MH.MH_pkthdr.len = m->m_lenm_hdr.mh_len = len;
1241
1242 wh = mtod(m, struct ieee80211_frame *)((struct ieee80211_frame *)((m)->m_hdr.mh_data));
1243
1244 if (!IS_BEACON(wh->i_fc[0]))
1245 sc->sc_led_state.ls_event |= RTW_LED_S_RX0x1;
1246 /* TBD use _MAR, _BAR, _PAR flags as hints to _find_rxnode? */
1247 ni = ieee80211_find_rxnode(&sc->sc_ic, wh);
1248
1249 sc->sc_tsfth = htsfth;
1250
1251#ifdef RTW_DEBUG
1252 if ((sc->sc_ifsc_ic.ic_ac.ac_if.if_flags & (IFF_DEBUG0x4|IFF_LINK20x4000)) ==
1253 (IFF_DEBUG0x4|IFF_LINK20x4000)) {
1254 ieee80211_dump_pkt(mtod(m, uint8_t *)((uint8_t *)((m)->m_hdr.mh_data)), m->m_pkthdrM_dat.MH.MH_pkthdr.len,
1255 rate, rssi);
1256 }
1257#endif /* RTW_DEBUG */
1258
1259#if NBPFILTER1 > 0
1260 if (sc->sc_radiobpf != NULL((void *)0)) {
1261 struct mbuf mb;
1262 struct ieee80211com *ic = &sc->sc_ic;
1263 struct rtw_rx_radiotap_header *rr = &sc->sc_rxtapsc_rxtapu.tap;
1264
1265 rr->rr_tsft =
1266 htole64(((uint64_t)htsfth << 32) | htsftl)((__uint64_t)(((uint64_t)htsfth << 32) | htsftl));
1267
1268 rr->rr_flags = 0;
1269 if ((hstat & RTW_RXSTAT_SPLCP(1<<25)) != 0)
1270 rr->rr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE0x02;
1271
1272 rr->rr_rate = rate;
1273 rr->rr_chan_freq =
1274 htole16(ic->ic_bss->ni_chan->ic_freq)((__uint16_t)(ic->ic_bss->ni_chan->ic_freq));
1275 rr->rr_chan_flags =
1276 htole16(ic->ic_bss->ni_chan->ic_flags)((__uint16_t)(ic->ic_bss->ni_chan->ic_flags));
1277 rr->rr_antsignal = rssi;
1278 rr->rr_barker_lock = htole16(sq)((__uint16_t)(sq));
1279
1280 mb.m_datam_hdr.mh_data = (caddr_t)rr;
1281 mb.m_lenm_hdr.mh_len = sizeof(sc->sc_rxtapu);
1282 mb.m_nextm_hdr.mh_next = m;
1283 mb.m_nextpktm_hdr.mh_nextpkt = NULL((void *)0);
1284 mb.m_typem_hdr.mh_type = 0;
1285 mb.m_flagsm_hdr.mh_flags = 0;
1286 bpf_mtap(sc->sc_radiobpf, &mb, BPF_DIRECTION_IN(1 << 0));
1287 }
1288#endif /* NBPFILTER > 0 */
1289
1290 memset(&rxi, 0, sizeof(rxi))__builtin_memset((&rxi), (0), (sizeof(rxi)));
1291 rxi.rxi_rssi = rssi;
1292 rxi.rxi_tstamp = htsftl;
1293 ieee80211_inputm(&sc->sc_ifsc_ic.ic_ac.ac_if, m, ni, &rxi, &ml);
1294 ieee80211_release_node(&sc->sc_ic, ni);
1295next:
1296 rtw_rxdesc_init(rdb, rs, next, 0);
1297 }
1298 if_input(&sc->sc_ifsc_ic.ic_ac.ac_if, &ml);
1299 rdb->rdb_next = next;
1300
1301 KASSERT(rdb->rdb_next < rdb->rdb_ndesc)((rdb->rdb_next < rdb->rdb_ndesc) ? (void)0 : __assert
("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 1301, "rdb->rdb_next < rdb->rdb_ndesc"
))
;
1302
1303 return;
1304#undef IS_BEACON
1305}
1306
1307void
1308rtw_txsoft_release(bus_dma_tag_t dmat, struct ieee80211com *ic,
1309 struct rtw_txsoft *ts)
1310{
1311 struct mbuf *m;
1312 struct ieee80211_node *ni;
1313
1314 m = ts->ts_mbuf;
1315 ni = ts->ts_ni;
1316 KASSERT(m != NULL)((m != ((void *)0)) ? (void)0 : __assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c"
, 1316, "m != NULL"))
;
1317 KASSERT(ni != NULL)((ni != ((void *)0)) ? (void)0 : __assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c"
, 1317, "ni != NULL"))
;
1318 ts->ts_mbuf = NULL((void *)0);
1319 ts->ts_ni = NULL((void *)0);
1320
1321 bus_dmamap_sync(dmat, ts->ts_dmamap, 0, ts->ts_dmamap->dm_mapsize,(*(dmat)->_dmamap_sync)((dmat), (ts->ts_dmamap), (0), (
ts->ts_dmamap->dm_mapsize), (0x08))
1322 BUS_DMASYNC_POSTWRITE)(*(dmat)->_dmamap_sync)((dmat), (ts->ts_dmamap), (0), (
ts->ts_dmamap->dm_mapsize), (0x08))
;
1323 bus_dmamap_unload(dmat, ts->ts_dmamap)(*(dmat)->_dmamap_unload)((dmat), (ts->ts_dmamap));
1324 m_freem(m);
1325 ieee80211_release_node(ic, ni);
1326}
1327
1328void
1329rtw_txsofts_release(bus_dma_tag_t dmat, struct ieee80211com *ic,
1330 struct rtw_txsoft_blk *tsb)
1331{
1332 struct rtw_txsoft *ts;
1333
1334 while ((ts = SIMPLEQ_FIRST(&tsb->tsb_dirtyq)((&tsb->tsb_dirtyq)->sqh_first)) != NULL((void *)0)) {
1335 rtw_txsoft_release(dmat, ic, ts);
1336 SIMPLEQ_REMOVE_HEAD(&tsb->tsb_dirtyq, ts_q)do { if (((&tsb->tsb_dirtyq)->sqh_first = (&tsb
->tsb_dirtyq)->sqh_first->ts_q.sqe_next) == ((void *
)0)) (&tsb->tsb_dirtyq)->sqh_last = &(&tsb->
tsb_dirtyq)->sqh_first; } while (0)
;
1337 SIMPLEQ_INSERT_TAIL(&tsb->tsb_freeq, ts, ts_q)do { (ts)->ts_q.sqe_next = ((void *)0); *(&tsb->tsb_freeq
)->sqh_last = (ts); (&tsb->tsb_freeq)->sqh_last =
&(ts)->ts_q.sqe_next; } while (0)
;
1338 }
1339 tsb->tsb_tx_timer = 0;
1340}
1341
1342void
1343rtw_collect_txpkt(struct rtw_softc *sc, struct rtw_txdesc_blk *tdb,
1344 struct rtw_txsoft *ts, int ndesc)
1345{
1346 uint32_t hstat;
1347 int data_retry, rts_retry;
1348 struct rtw_txdesc *tdn;
1349 const char *condstring;
1350
1351 rtw_txsoft_release(sc->sc_dmat, &sc->sc_ic, ts);
1352
1353 tdb->tdb_nfree += ndesc;
1354
1355 tdn = &tdb->tdb_desc[ts->ts_last];
1356
1357 hstat = letoh32(tdn->td_stat)((__uint32_t)(tdn->td_ctl0));
1358 rts_retry = MASK_AND_RSHIFT(hstat, RTW_TXSTAT_RTSRETRY_MASK)(((hstat) & (0x7f00)) >> ((((u_long)((((((0x7f00)) -
1) & ((0x7f00))) ^ ((0x7f00)))) >> (16)) != 0) ? 16
+ ((((u_long)(((((((0x7f00) >> 16)) - 1) & (((0x7f00
) >> 16))) ^ (((0x7f00) >> 16)))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x7f00) >> 16) >> 8)
) - 1) & ((((0x7f00) >> 16) >> 8))) ^ ((((0x7f00
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00) >> 16) >> 8) >> 4)) - 1) &
(((((0x7f00) >> 16) >> 8) >> 4))) ^ (((((0x7f00
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0x7f00) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0x7f00) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x7f00) >> 16) >> 8) >>
4))) - 1) & ((((((0x7f00) >> 16) >> 8) >>
4)))) ^ ((((((0x7f00) >> 16) >> 8) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00
) >> 16) >> 8))) - 1) & (((((0x7f00) >>
16) >> 8)))) ^ (((((0x7f00) >> 16) >> 8)))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00) >>
16) >> 8)) >> 2)) - 1) & ((((((0x7f00) >>
16) >> 8)) >> 2))) ^ ((((((0x7f00) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x7f00) >> 16) >> 8)))) - 1) & (((
(((0x7f00) >> 16) >> 8))))) ^ ((((((0x7f00) >>
16) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00) >> 16))) - 1) & ((((0x7f00) >>
16)))) ^ ((((0x7f00) >> 16))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00) >> 16)) >> 4)) - 1
) & (((((0x7f00) >> 16)) >> 4))) ^ (((((0x7f00
) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0x7f00) >> 16)) >> 4) >> 2
)) - 1) & ((((((0x7f00) >> 16)) >> 4) >>
2))) ^ ((((((0x7f00) >> 16)) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00)
>> 16)) >> 4))) - 1) & ((((((0x7f00) >>
16)) >> 4)))) ^ ((((((0x7f00) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00
) >> 16)))) - 1) & (((((0x7f00) >> 16))))) ^ (
((((0x7f00) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00) >> 16))) >> 2)) - 1) & (((
(((0x7f00) >> 16))) >> 2))) ^ ((((((0x7f00) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x7f00) >> 16))))) - 1) & ((((((0x7f00) >>
16)))))) ^ ((((((0x7f00) >> 16))))))) >> (1)) !=
0) ? 1 : 0)))) : ((((u_long)(((((((0x7f00))) - 1) & (((0x7f00
)))) ^ (((0x7f00))))) >> (8)) != 0) ? 8 + ((((u_long)((
((((((0x7f00)) >> 8)) - 1) & ((((0x7f00)) >> 8
))) ^ ((((0x7f00)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0x7f00)) >> 8) >> 4)) - 1) &
(((((0x7f00)) >> 8) >> 4))) ^ (((((0x7f00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00)) >> 8) >> 4) >> 2)) - 1) &
((((((0x7f00)) >> 8) >> 4) >> 2))) ^ (((((
(0x7f00)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00)) >> 8) >>
4))) - 1) & ((((((0x7f00)) >> 8) >> 4)))) ^ (
(((((0x7f00)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00)) >> 8))) - 1) &
(((((0x7f00)) >> 8)))) ^ (((((0x7f00)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00)) >>
8)) >> 2)) - 1) & ((((((0x7f00)) >> 8)) >>
2))) ^ ((((((0x7f00)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00)) >> 8
)))) - 1) & ((((((0x7f00)) >> 8))))) ^ ((((((0x7f00
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00)))) - 1) & ((((0x7f00))))) ^ ((((0x7f00))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00))) >>
4)) - 1) & (((((0x7f00))) >> 4))) ^ (((((0x7f00)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0x7f00))) >> 4) >> 2)) - 1) & ((((((0x7f00)
)) >> 4) >> 2))) ^ ((((((0x7f00))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00
))) >> 4))) - 1) & ((((((0x7f00))) >> 4)))) ^
((((((0x7f00))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00))))) - 1) & (((((0x7f00)))
))) ^ (((((0x7f00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00)))) >> 2)) - 1) & ((((((0x7f00)))
) >> 2))) ^ ((((((0x7f00)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00)))))) - 1) &
((((((0x7f00))))))) ^ ((((((0x7f00)))))))) >> (1)) != 0
) ? 1 : 0))))))
;
1359 data_retry = MASK_AND_RSHIFT(hstat, RTW_TXSTAT_DRC_MASK)(((hstat) & (0xff)) >> ((((u_long)((((((0xff)) - 1)
& ((0xff))) ^ ((0xff)))) >> (16)) != 0) ? 16 + (((
(u_long)(((((((0xff) >> 16)) - 1) & (((0xff) >>
16))) ^ (((0xff) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0xff) >> 16) >> 8)) - 1) & (
(((0xff) >> 16) >> 8))) ^ ((((0xff) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >>
16) >> 8) >> 4)) - 1) & (((((0xff) >> 16
) >> 8) >> 4))) ^ (((((0xff) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff) >> 16) >> 8) >> 4) >> 2)) -
1) & ((((((0xff) >> 16) >> 8) >> 4) >>
2))) ^ ((((((0xff) >> 16) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
) >> 16) >> 8) >> 4))) - 1) & ((((((0xff
) >> 16) >> 8) >> 4)))) ^ ((((((0xff) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff) >> 16) >> 8))) - 1)
& (((((0xff) >> 16) >> 8)))) ^ (((((0xff) >>
16) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xff) >> 16) >> 8)) >> 2)) - 1) &
((((((0xff) >> 16) >> 8)) >> 2))) ^ ((((((
0xff) >> 16) >> 8)) >> 2)))) >> (1)) !=
0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16) >>
8)))) - 1) & ((((((0xff) >> 16) >> 8))))) ^ (
(((((0xff) >> 16) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0xff) >> 16))) - 1) &
((((0xff) >> 16)))) ^ ((((0xff) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >> 16)) >>
4)) - 1) & (((((0xff) >> 16)) >> 4))) ^ ((((
(0xff) >> 16)) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)((((((((((0xff) >> 16)) >> 4) >>
2)) - 1) & ((((((0xff) >> 16)) >> 4) >>
2))) ^ ((((((0xff) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16
)) >> 4))) - 1) & ((((((0xff) >> 16)) >>
4)))) ^ ((((((0xff) >> 16)) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff) >> 16))
)) - 1) & (((((0xff) >> 16))))) ^ (((((0xff) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff
) >> 16))) >> 2)) - 1) & ((((((0xff) >>
16))) >> 2))) ^ ((((((0xff) >> 16))) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff)
>> 16))))) - 1) & ((((((0xff) >> 16)))))) ^ (
(((((0xff) >> 16))))))) >> (1)) != 0) ? 1 : 0))))
: ((((u_long)(((((((0xff))) - 1) & (((0xff)))) ^ (((0xff
))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xff)) >>
8)) - 1) & ((((0xff)) >> 8))) ^ ((((0xff)) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff)) >>
8) >> 4)) - 1) & (((((0xff)) >> 8) >> 4
))) ^ (((((0xff)) >> 8) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xff)) >> 8) >> 4)
>> 2)) - 1) & ((((((0xff)) >> 8) >> 4)
>> 2))) ^ ((((((0xff)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
)) >> 8) >> 4))) - 1) & ((((((0xff)) >>
8) >> 4)))) ^ ((((((0xff)) >> 8) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff)) >>
8))) - 1) & (((((0xff)) >> 8)))) ^ (((((0xff)) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff))
>> 8)) >> 2)) - 1) & ((((((0xff)) >> 8
)) >> 2))) ^ ((((((0xff)) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff)) >> 8
)))) - 1) & ((((((0xff)) >> 8))))) ^ ((((((0xff)) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
0xff)))) - 1) & ((((0xff))))) ^ ((((0xff)))))) >> (
4)) != 0) ? 4 + ((((u_long)(((((((((0xff))) >> 4)) - 1)
& (((((0xff))) >> 4))) ^ (((((0xff))) >> 4))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff))) >>
4) >> 2)) - 1) & ((((((0xff))) >> 4) >>
2))) ^ ((((((0xff))) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff))) >> 4)))
- 1) & ((((((0xff))) >> 4)))) ^ ((((((0xff))) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff
))))) - 1) & (((((0xff)))))) ^ (((((0xff))))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0xff)))) >> 2)) - 1
) & ((((((0xff)))) >> 2))) ^ ((((((0xff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
)))))) - 1) & ((((((0xff))))))) ^ ((((((0xff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
1360
1361 sc->sc_ifsc_ic.ic_ac.ac_if.if_collisionsif_data.ifi_collisions += rts_retry + data_retry;
1362
1363 if ((hstat & RTW_TXSTAT_TOK(1<<15)) != 0)
1364 condstring = "ok";
1365 else {
1366 sc->sc_ifsc_ic.ic_ac.ac_if.if_oerrorsif_data.ifi_oerrors++;
1367 condstring = "error";
1368 }
1369
1370 DPRINTF(sc, RTW_DEBUG_XMIT_DESC,
1371 ("%s: ts %p txdesc[%d, %d] %s tries rts %u data %u\n",
1372 sc->sc_dev.dv_xname, ts, ts->ts_first, ts->ts_last,
1373 condstring, rts_retry, data_retry));
1374}
1375
1376void
1377rtw_reset_oactive(struct rtw_softc *sc)
1378{
1379 int oactive;
1380 int pri;
1381 struct rtw_txsoft_blk *tsb;
1382 struct rtw_txdesc_blk *tdb;
1383 oactive = ifq_is_oactive(&sc->sc_ifsc_ic.ic_ac.ac_if.if_snd);
1384 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
1385 tsb = &sc->sc_txsoft_blk[pri];
1386 tdb = &sc->sc_txdesc_blk[pri];
1387 if (!SIMPLEQ_EMPTY(&tsb->tsb_freeq)(((&tsb->tsb_freeq)->sqh_first) == ((void *)0)) && tdb->tdb_nfree > 0)
1388 ifq_set_oactive(&sc->sc_ifsc_ic.ic_ac.ac_if.if_snd);
1389 }
1390 if (oactive != ifq_is_oactive(&sc->sc_ifsc_ic.ic_ac.ac_if.if_snd)) {
1391 DPRINTF(sc, RTW_DEBUG_OACTIVE,
1392 ("%s: reset OACTIVE\n", __func__));
1393 }
1394}
1395
1396/* Collect transmitted packets. */
1397void
1398rtw_collect_txring(struct rtw_softc *sc, struct rtw_txsoft_blk *tsb,
1399 struct rtw_txdesc_blk *tdb, int force)
1400{
1401 int ndesc;
1402 struct rtw_txsoft *ts;
1403
1404 while ((ts = SIMPLEQ_FIRST(&tsb->tsb_dirtyq)((&tsb->tsb_dirtyq)->sqh_first)) != NULL((void *)0)) {
1405 ndesc = 1 + ts->ts_last - ts->ts_first;
1406 if (ts->ts_last < ts->ts_first)
1407 ndesc += tdb->tdb_ndesc;
1408
1409 KASSERT(ndesc > 0)((ndesc > 0) ? (void)0 : __assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c"
, 1409, "ndesc > 0"))
;
1410
1411 rtw_txdescs_sync(tdb, ts->ts_first, ndesc,
1412 BUS_DMASYNC_POSTREAD0x02|BUS_DMASYNC_POSTWRITE0x08);
1413
1414 if (force) {
1415 int i;
1416 for (i = ts->ts_first; ; i = RTW_NEXT_IDX(tdb, i)(((i) + 1) % (tdb)->tdb_ndesc)) {
1417 tdb->tdb_desc[i].td_stattd_ctl0 &=
1418 ~htole32(RTW_TXSTAT_OWN)((__uint32_t)((1<<31)));
1419 if (i == ts->ts_last)
1420 break;
1421 }
1422 rtw_txdescs_sync(tdb, ts->ts_first, ndesc,
1423 BUS_DMASYNC_PREREAD0x01|BUS_DMASYNC_PREWRITE0x04);
1424 } else if ((tdb->tdb_desc[ts->ts_last].td_stattd_ctl0 &
1425 htole32(RTW_TXSTAT_OWN)((__uint32_t)((1<<31)))) != 0)
1426 break;
1427
1428 rtw_collect_txpkt(sc, tdb, ts, ndesc);
1429 SIMPLEQ_REMOVE_HEAD(&tsb->tsb_dirtyq, ts_q)do { if (((&tsb->tsb_dirtyq)->sqh_first = (&tsb
->tsb_dirtyq)->sqh_first->ts_q.sqe_next) == ((void *
)0)) (&tsb->tsb_dirtyq)->sqh_last = &(&tsb->
tsb_dirtyq)->sqh_first; } while (0)
;
1430 SIMPLEQ_INSERT_TAIL(&tsb->tsb_freeq, ts, ts_q)do { (ts)->ts_q.sqe_next = ((void *)0); *(&tsb->tsb_freeq
)->sqh_last = (ts); (&tsb->tsb_freeq)->sqh_last =
&(ts)->ts_q.sqe_next; } while (0)
;
1431 }
1432 /* no more pending transmissions, cancel watchdog */
1433 if (ts == NULL((void *)0))
1434 tsb->tsb_tx_timer = 0;
1435 rtw_reset_oactive(sc);
1436}
1437
1438void
1439rtw_intr_tx(struct rtw_softc *sc, u_int16_t isr)
1440{
1441 int pri;
1442 struct rtw_txsoft_blk *tsb;
1443 struct rtw_txdesc_blk *tdb;
1444
1445 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
1446 tsb = &sc->sc_txsoft_blk[pri];
1447 tdb = &sc->sc_txdesc_blk[pri];
1448
1449 rtw_collect_txring(sc, tsb, tdb, 0);
1450
1451 }
1452
1453 if ((isr & RTW_INTR_TX((1<<3)|(1<<2)|(1<<9)| (1<<8)|(1<<
7)|(1<<6)| (1<<11)|(1<<10))
) != 0)
1454 rtw_start(&sc->sc_ifsc_ic.ic_ac.ac_if);
1455}
1456
1457#ifndef IEEE80211_STA_ONLY
1458void
1459rtw_intr_beacon(struct rtw_softc *sc, u_int16_t isr)
1460{
1461 u_int next;
1462 uint32_t tsfth, tsftl;
1463 struct ieee80211com *ic;
1464 struct rtw_txdesc_blk *tdb = &sc->sc_txdesc_blk[RTW_TXPRIBCN3];
1465 struct rtw_txsoft_blk *tsb = &sc->sc_txsoft_blk[RTW_TXPRIBCN3];
1466 struct mbuf *m;
1467
1468 tsfth = RTW_READ(&sc->sc_regs, RTW_TSFTRH)((*(&sc->sc_regs)->r_read32)(&sc->sc_regs, 0x1c
))
;
1469 tsftl = RTW_READ(&sc->sc_regs, RTW_TSFTRL)((*(&sc->sc_regs)->r_read32)(&sc->sc_regs, 0x18
))
;
1470
1471 if ((isr & (RTW_INTR_TBDOK(1<<10)|RTW_INTR_TBDER(1<<11))) != 0) {
1472 next = rtw_txring_next(&sc->sc_regs, tdb);
1473 RTW_DPRINTF(RTW_DEBUG_BEACON,
1474 ("%s: beacon ring %sprocessed, isr = %#04hx"
1475 ", next %u expected %u, %llu\n", __func__,
1476 (next == tdb->tdb_next) ? "" : "un", isr, next,
1477 tdb->tdb_next, (uint64_t)tsfth << 32 | tsftl));
1478 if ((RTW_READ8(&sc->sc_regs, RTW_TPPOLL)((*(&sc->sc_regs)->r_read8)(&sc->sc_regs, 0xd9
))
& RTW_TPPOLL_BQ(1<<7)) == 0){
1479 rtw_collect_txring(sc, tsb, tdb, 1);
1480 tdb->tdb_next = 0;
1481 }
1482 }
1483 /* Start beacon transmission. */
1484
1485 if ((isr & RTW_INTR_BCNINT(1<<13)) != 0 &&
1486 sc->sc_ic.ic_state == IEEE80211_S_RUN &&
1487 SIMPLEQ_EMPTY(&tsb->tsb_dirtyq)(((&tsb->tsb_dirtyq)->sqh_first) == ((void *)0))) {
1488 RTW_DPRINTF(RTW_DEBUG_BEACON,
1489 ("%s: beacon prep. time, isr = %#04hx"
1490 ", %16llu\n", __func__, isr,
1491 (uint64_t)tsfth << 32 | tsftl));
1492 ic = &sc->sc_ic;
1493 if ((m = ieee80211_beacon_alloc(ic, ic->ic_bss)) != NULL((void *)0)) {
1494 RTW_DPRINTF(RTW_DEBUG_BEACON,
1495 ("%s: m %p len %u\n", __func__, m, m->m_len));
1496 }
1497
1498 if (m == NULL((void *)0)) {
1499 printf("%s: could not allocate beacon\n",
1500 sc->sc_dev.dv_xname);
1501 return;
1502 }
1503 m->m_pkthdrM_dat.MH.MH_pkthdr.ph_cookie = ieee80211_ref_node(ic->ic_bss);
1504 mq_enqueue(&sc->sc_beaconq, m);
1505 rtw_start(&sc->sc_ifsc_ic.ic_ac.ac_if);
1506 }
1507}
1508
1509void
1510rtw_intr_atim(struct rtw_softc *sc)
1511{
1512 /* TBD */
1513 return;
1514}
1515#endif /* IEEE80211_STA_ONLY */
1516
1517#ifdef RTW_DEBUG
1518void
1519rtw_dump_rings(struct rtw_softc *sc)
1520{
1521 struct rtw_txdesc_blk *tdb;
1522 struct rtw_rxdesc *rd;
1523 struct rtw_rxdesc_blk *rdb;
1524 int desc, pri;
1525
1526 if ((rtw_debug & RTW_DEBUG_IO_KICK) == 0)
1527 return;
1528
1529 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
1530 tdb = &sc->sc_txdesc_blk[pri];
1531 printf("%s: txpri %d ndesc %d nfree %d\n", __func__, pri,
1532 tdb->tdb_ndesc, tdb->tdb_nfree);
1533 for (desc = 0; desc < tdb->tdb_ndesc; desc++)
1534 rtw_print_txdesc(sc, ".", NULL((void *)0), tdb, desc);
1535 }
1536
1537 rdb = &sc->sc_rxdesc_blk;
1538
1539 for (desc = 0; desc < RTW_RXQLEN64; desc++) {
1540 rd = &rdb->rdb_desc[desc];
1541 printf("%s: %sctl %08x rsvd0/rssi %08x buf/tsftl %08x "
1542 "rsvd1/tsfth %08x\n", __func__,
1543 (desc >= rdb->rdb_ndesc) ? "UNUSED " : "",
1544 letoh32(rd->rd_ctl)((__uint32_t)(rd->rd_ctl)), letoh32(rd->rd_rssi)((__uint32_t)(rd->rd_rsvd0)),
1545 letoh32(rd->rd_buf)((__uint32_t)(rd->rd_buf)), letoh32(rd->rd_tsfth)((__uint32_t)(rd->rd_rsvd1)));
1546 }
1547}
1548#endif /* RTW_DEBUG */
1549
1550void
1551rtw_hwring_setup(struct rtw_softc *sc)
1552{
1553 int pri;
1554 struct rtw_regs *regs = &sc->sc_regs;
1555 struct rtw_txdesc_blk *tdb;
1556
1557 sc->sc_txdesc_blk[RTW_TXPRILO0].tdb_basereg = RTW_TLPDA0x20;
1558 sc->sc_txdesc_blk[RTW_TXPRILO0].tdb_base = RTW_RING_BASE(sc, hd_txlo)((sc)->sc_desc_dmamap->dm_segs[0].ds_addr + __builtin_offsetof
(struct rtw_descs, hd_txlo[0]))
;
1559 sc->sc_txdesc_blk[RTW_TXPRIMD1].tdb_basereg = RTW_TNPDA0x24;
1560 sc->sc_txdesc_blk[RTW_TXPRIMD1].tdb_base = RTW_RING_BASE(sc, hd_txmd)((sc)->sc_desc_dmamap->dm_segs[0].ds_addr + __builtin_offsetof
(struct rtw_descs, hd_txmd[0]))
;
1561 sc->sc_txdesc_blk[RTW_TXPRIHI2].tdb_basereg = RTW_THPDA0x28;
1562 sc->sc_txdesc_blk[RTW_TXPRIHI2].tdb_base = RTW_RING_BASE(sc, hd_txhi)((sc)->sc_desc_dmamap->dm_segs[0].ds_addr + __builtin_offsetof
(struct rtw_descs, hd_txhi[0]))
;
1563 sc->sc_txdesc_blk[RTW_TXPRIBCN3].tdb_basereg = RTW_TBDA0x4c;
1564 sc->sc_txdesc_blk[RTW_TXPRIBCN3].tdb_base = RTW_RING_BASE(sc, hd_bcn)((sc)->sc_desc_dmamap->dm_segs[0].ds_addr + __builtin_offsetof
(struct rtw_descs, hd_bcn[0]))
;
1565
1566 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
1567 tdb = &sc->sc_txdesc_blk[pri];
1568 RTW_WRITE(regs, tdb->tdb_basereg, tdb->tdb_base)((*(regs)->r_write32)(regs, tdb->tdb_basereg, tdb->tdb_base
))
;
1569 RTW_DPRINTF(RTW_DEBUG_XMIT_DESC,
1570 ("%s: reg[tdb->tdb_basereg] <- %lx\n", __func__,
1571 (u_int *)tdb->tdb_base));
1572 }
1573
1574 RTW_WRITE(regs, RTW_RDSAR, RTW_RING_BASE(sc, hd_rx))((*(regs)->r_write32)(regs, 0xe4, ((sc)->sc_desc_dmamap
->dm_segs[0].ds_addr + __builtin_offsetof(struct rtw_descs
, hd_rx[0]))))
;
1575
1576 RTW_DPRINTF(RTW_DEBUG_RECV_DESC,
1577 ("%s: reg[RDSAR] <- %lx\n", __func__,
1578 (u_int *)RTW_RING_BASE(sc, hd_rx)));
1579
1580 RTW_SYNC(regs, RTW_TLPDA, RTW_RDSAR)((*(regs)->r_barrier)(regs, 0x20, 0xe4, (0x01|0x02)));
1581}
1582
1583int
1584rtw_swring_setup(struct rtw_softc *sc)
1585{
1586 int rc, pri;
1587 struct rtw_rxdesc_blk *rdb;
1588 struct rtw_txdesc_blk *tdb;
1589
1590 rtw_txdesc_blk_init_all(&sc->sc_txdesc_blk[0]);
1591
1592 rtw_txsoft_blk_init_all(&sc->sc_txsoft_blk[0]);
1593
1594 rdb = &sc->sc_rxdesc_blk;
1595 if ((rc = rtw_rxsoft_init_all(sc->sc_dmat, sc->sc_rxsoft,
1596 &rdb->rdb_ndesc, sc->sc_dev.dv_xname)) != 0 &&
1597 rdb->rdb_ndesc == 0) {
1598 printf("%s: could not allocate rx buffers\n",
1599 sc->sc_dev.dv_xname);
1600 return rc;
1601 }
1602
1603 rdb = &sc->sc_rxdesc_blk;
1604 rtw_rxdescs_sync(rdb, 0, rdb->rdb_ndesc,
1605 BUS_DMASYNC_POSTREAD0x02|BUS_DMASYNC_POSTWRITE0x08);
1606 rtw_rxdesc_init_all(rdb, sc->sc_rxsoft, 1);
1607 rdb->rdb_next = 0;
1608
1609 tdb = &sc->sc_txdesc_blk[0];
1610 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
1611 rtw_txdescs_sync(&tdb[pri], 0, tdb[pri].tdb_ndesc,
1612 BUS_DMASYNC_PREREAD0x01|BUS_DMASYNC_PREWRITE0x04);
1613 }
1614 return 0;
1615}
1616
1617void
1618rtw_txdesc_blk_init(struct rtw_txdesc_blk *tdb)
1619{
1620 int i;
1621
1622 bzero(tdb->tdb_desc, sizeof(tdb->tdb_desc[0]) * tdb->tdb_ndesc)__builtin_bzero((tdb->tdb_desc), (sizeof(tdb->tdb_desc[
0]) * tdb->tdb_ndesc))
;
1623 for (i = 0; i < tdb->tdb_ndesc; i++)
1624 tdb->tdb_desc[i].td_next = htole32(RTW_NEXT_DESC(tdb, i))((__uint32_t)(((tdb)->tdb_physbase + sizeof(struct rtw_txdesc
) * ((((i)) + 1) % ((tdb))->tdb_ndesc))))
;
1625}
1626
1627u_int
1628rtw_txring_next(struct rtw_regs *regs, struct rtw_txdesc_blk *tdb)
1629{
1630 return (letoh32(RTW_READ(regs, tdb->tdb_basereg))((__uint32_t)(((*(regs)->r_read32)(regs, tdb->tdb_basereg
))))
- tdb->tdb_base) /
1631 sizeof(struct rtw_txdesc);
1632}
1633
1634void
1635rtw_txring_fixup(struct rtw_softc *sc)
1636{
1637 int pri;
1638 u_int next;
1639 struct rtw_txdesc_blk *tdb;
1640 struct rtw_regs *regs = &sc->sc_regs;
1641
1642 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
1643 tdb = &sc->sc_txdesc_blk[pri];
1644 next = rtw_txring_next(regs, tdb);
1645 if (tdb->tdb_next == next)
1646 continue;
1647 RTW_DPRINTF(RTW_DEBUG_BUGS,
1648 ("%s: tx-ring %d expected next %u, read %u\n", __func__,
1649 pri, tdb->tdb_next, next));
1650 tdb->tdb_next = MIN(next, tdb->tdb_ndesc - 1)(((next)<(tdb->tdb_ndesc - 1))?(next):(tdb->tdb_ndesc
- 1))
;
1651 }
1652}
1653
1654void
1655rtw_rxring_fixup(struct rtw_softc *sc)
1656{
1657 u_int next;
1658 uint32_t rdsar;
1659 struct rtw_rxdesc_blk *rdb;
1660
1661 rdsar = letoh32(RTW_READ(&sc->sc_regs, RTW_RDSAR))((__uint32_t)(((*(&sc->sc_regs)->r_read32)(&sc->
sc_regs, 0xe4))))
;
1662 next = (rdsar - RTW_RING_BASE(sc, hd_rx)((sc)->sc_desc_dmamap->dm_segs[0].ds_addr + __builtin_offsetof
(struct rtw_descs, hd_rx[0]))
) / sizeof(struct rtw_rxdesc);
1663
1664 rdb = &sc->sc_rxdesc_blk;
1665 if (rdb->rdb_next != next) {
1666 RTW_DPRINTF(RTW_DEBUG_BUGS,
1667 ("%s: rx-ring expected next %u, read %u\n", __func__,
1668 rdb->rdb_next, next));
1669 rdb->rdb_next = MIN(next, rdb->rdb_ndesc - 1)(((next)<(rdb->rdb_ndesc - 1))?(next):(rdb->rdb_ndesc
- 1))
;
1670 }
1671}
1672
1673void
1674rtw_txdescs_reset(struct rtw_softc *sc)
1675{
1676 int pri;
1677
1678 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
1679 rtw_collect_txring(sc, &sc->sc_txsoft_blk[pri],
1680 &sc->sc_txdesc_blk[pri], 1);
1681 }
1682}
1683
1684void
1685rtw_intr_ioerror(struct rtw_softc *sc, u_int16_t isr)
1686{
1687 uint8_t cr = 0;
1688 int xmtr = 0, rcvr = 0;
1689 struct rtw_regs *regs = &sc->sc_regs;
1690
1691 if ((isr & RTW_INTR_TXFOVW(1<<15)) != 0) {
1692 RTW_DPRINTF(RTW_DEBUG_BUGS,
1693 ("%s: tx fifo underflow\n", sc->sc_dev.dv_xname));
1694 rcvr = xmtr = 1;
1695 cr |= RTW_CR_TE(1<<2) | RTW_CR_RE(1<<3);
1696 }
1697
1698 if ((isr & (RTW_INTR_RDU(1<<4)|RTW_INTR_RXFOVW(1<<5))) != 0) {
1699 cr |= RTW_CR_RE(1<<3);
1700 rcvr = 1;
1701 }
1702
1703 RTW_DPRINTF(RTW_DEBUG_BUGS, ("%s: restarting xmit/recv, isr %hx"
1704 "\n", sc->sc_dev.dv_xname, isr));
1705
1706#ifdef RTW_DEBUG
1707 rtw_dump_rings(sc);
1708#endif /* RTW_DEBUG */
1709
1710 rtw_io_enable(regs, cr, 0);
1711
1712 /* Collect rx'd packets. Refresh rx buffers. */
1713 if (rcvr)
1714 rtw_intr_rx(sc, 0);
1715 /* Collect tx'd packets. XXX let's hope this stops the transmit
1716 * timeouts.
1717 */
1718 if (xmtr)
1719 rtw_txdescs_reset(sc);
1720
1721 RTW_WRITE16(regs, RTW_IMR, 0)((*(regs)->r_write16)(regs, 0x3c, 0));
1722 RTW_SYNC(regs, RTW_IMR, RTW_IMR)((*(regs)->r_barrier)(regs, 0x3c, 0x3c, (0x01|0x02)));
1723
1724 if (rtw_do_chip_reset) {
1725 rtw_chip_reset1(regs, sc->sc_dev.dv_xname);
1726 }
1727
1728 rtw_rxdesc_init_all(&sc->sc_rxdesc_blk, &sc->sc_rxsoft[0], 1);
1729
1730#ifdef RTW_DEBUG
1731 rtw_dump_rings(sc);
1732#endif /* RTW_DEBUG */
1733
1734 RTW_WRITE16(regs, RTW_IMR, sc->sc_inten)((*(regs)->r_write16)(regs, 0x3c, sc->sc_inten));
1735 RTW_SYNC(regs, RTW_IMR, RTW_IMR)((*(regs)->r_barrier)(regs, 0x3c, 0x3c, (0x01|0x02)));
1736 if (rcvr)
1737 rtw_rxring_fixup(sc);
1738 rtw_io_enable(regs, cr, 1);
1739 if (xmtr)
1740 rtw_txring_fixup(sc);
1741}
1742
1743void
1744rtw_suspend_ticks(struct rtw_softc *sc)
1745{
1746 RTW_DPRINTF(RTW_DEBUG_TIMEOUT,
1747 ("%s: suspending ticks\n", sc->sc_dev.dv_xname));
1748 sc->sc_do_tick = 0;
1749}
1750
1751void
1752rtw_resume_ticks(struct rtw_softc *sc)
1753{
1754 u_int32_t tsftrl0, tsftrl1, next_tick;
1755
1756 tsftrl0 = RTW_READ(&sc->sc_regs, RTW_TSFTRL)((*(&sc->sc_regs)->r_read32)(&sc->sc_regs, 0x18
))
;
1757
1758 tsftrl1 = RTW_READ(&sc->sc_regs, RTW_TSFTRL)((*(&sc->sc_regs)->r_read32)(&sc->sc_regs, 0x18
))
;
1759 next_tick = tsftrl1 + 1000000;
1760 RTW_WRITE(&sc->sc_regs, RTW_TINT, next_tick)((*(&sc->sc_regs)->r_write32)(&sc->sc_regs, 0x48
, next_tick))
;
1761
1762 sc->sc_do_tick = 1;
1763
1764 RTW_DPRINTF(RTW_DEBUG_TIMEOUT,
1765 ("%s: resume ticks delta %#08x now %#08x next %#08x\n",
1766 sc->sc_dev.dv_xname, tsftrl1 - tsftrl0, tsftrl1, next_tick));
1767}
1768
1769void
1770rtw_intr_timeout(struct rtw_softc *sc)
1771{
1772 RTW_DPRINTF(RTW_DEBUG_TIMEOUT, ("%s: timeout\n", sc->sc_dev.dv_xname));
1773 if (sc->sc_do_tick)
1774 rtw_resume_ticks(sc);
1775 return;
1776}
1777
1778int
1779rtw_intr(void *arg)
1780{
1781 int i;
1782 struct rtw_softc *sc = arg;
1783 struct rtw_regs *regs = &sc->sc_regs;
1784 u_int16_t isr;
1785
1786 /*
1787 * If the interface isn't running, the interrupt couldn't
1788 * possibly have come from us.
1789 */
1790 if ((sc->sc_flags & RTW_F_ENABLED0x00000001) == 0 ||
1791 (sc->sc_ifsc_ic.ic_ac.ac_if.if_flags & IFF_RUNNING0x40) == 0 ||
1792 (sc->sc_dev.dv_flags & DVF_ACTIVE0x0001) == 0) {
1793 RTW_DPRINTF(RTW_DEBUG_INTR, ("%s: stray interrupt\n",
1794 sc->sc_dev.dv_xname));
1795 return (0);
1796 }
1797
1798 for (i = 0; i < 10; i++) {
1799 isr = RTW_READ16(regs, RTW_ISR)((*(regs)->r_read16)(regs, 0x3e));
1800
1801 RTW_WRITE16(regs, RTW_ISR, isr)((*(regs)->r_write16)(regs, 0x3e, isr));
1802 RTW_WBR(regs, RTW_ISR, RTW_ISR)((*(regs)->r_barrier)(regs, 0x3e, 0x3e, 0x02));
1803
1804 if (sc->sc_intr_ack != NULL((void *)0))
1805 (*sc->sc_intr_ack)(regs);
1806
1807 if (isr == 0)
1808 break;
1809
1810#ifdef RTW_DEBUG
1811#define PRINTINTR(flag) do { \
1812 if ((isr & flag) != 0) { \
1813 printf("%s" #flag, delim); \
1814 delim = ","; \
1815 } \
1816} while (0)
1817
1818 if ((rtw_debug & RTW_DEBUG_INTR) != 0 && isr != 0) {
1819 const char *delim = "<";
1820
1821 printf("%s: reg[ISR] = %x", sc->sc_dev.dv_xname, isr);
1822
1823 PRINTINTR(RTW_INTR_TXFOVW(1<<15));
1824 PRINTINTR(RTW_INTR_TIMEOUT(1<<14));
1825 PRINTINTR(RTW_INTR_BCNINT(1<<13));
1826 PRINTINTR(RTW_INTR_ATIMINT(1<<12));
1827 PRINTINTR(RTW_INTR_TBDER(1<<11));
1828 PRINTINTR(RTW_INTR_TBDOK(1<<10));
1829 PRINTINTR(RTW_INTR_THPDER(1<<9));
1830 PRINTINTR(RTW_INTR_THPDOK(1<<8));
1831 PRINTINTR(RTW_INTR_TNPDER(1<<7));
1832 PRINTINTR(RTW_INTR_TNPDOK(1<<6));
1833 PRINTINTR(RTW_INTR_RXFOVW(1<<5));
1834 PRINTINTR(RTW_INTR_RDU(1<<4));
1835 PRINTINTR(RTW_INTR_TLPDER(1<<3));
1836 PRINTINTR(RTW_INTR_TLPDOK(1<<2));
1837 PRINTINTR(RTW_INTR_RER(1<<1));
1838 PRINTINTR(RTW_INTR_ROK(1<<0));
1839
1840 printf(">\n");
1841 }
1842#undef PRINTINTR
1843#endif /* RTW_DEBUG */
1844
1845 if ((isr & RTW_INTR_RX((1<<1)|(1<<0))) != 0)
1846 rtw_intr_rx(sc, isr & RTW_INTR_RX((1<<1)|(1<<0)));
1847 if ((isr & RTW_INTR_TX((1<<3)|(1<<2)|(1<<9)| (1<<8)|(1<<
7)|(1<<6)| (1<<11)|(1<<10))
) != 0)
1848 rtw_intr_tx(sc, isr & RTW_INTR_TX((1<<3)|(1<<2)|(1<<9)| (1<<8)|(1<<
7)|(1<<6)| (1<<11)|(1<<10))
);
1849#ifndef IEEE80211_STA_ONLY
1850 if ((isr & RTW_INTR_BEACON((1<<13)|(1<<11)|(1<<10))) != 0)
1851 rtw_intr_beacon(sc, isr & RTW_INTR_BEACON((1<<13)|(1<<11)|(1<<10)));
1852 if ((isr & RTW_INTR_ATIMINT(1<<12)) != 0)
1853 rtw_intr_atim(sc);
1854#endif
1855 if ((isr & RTW_INTR_IOERROR((1<<15)|(1<<5)|(1<<4))) != 0)
1856 rtw_intr_ioerror(sc, isr & RTW_INTR_IOERROR((1<<15)|(1<<5)|(1<<4)));
1857 if ((isr & RTW_INTR_TIMEOUT(1<<14)) != 0)
1858 rtw_intr_timeout(sc);
1859 }
1860
1861 return 1;
1862}
1863
1864/* Must be called at splnet. */
1865void
1866rtw_stop(struct ifnet *ifp, int disable)
1867{
1868 int pri;
1869 struct rtw_softc *sc = (struct rtw_softc *)ifp->if_softc;
1870 struct ieee80211com *ic = &sc->sc_ic;
1871 struct rtw_regs *regs = &sc->sc_regs;
1872
1873 if ((sc->sc_flags & RTW_F_ENABLED0x00000001) == 0)
1874 return;
1875
1876 rtw_suspend_ticks(sc);
1877
1878 ieee80211_new_state(ic, IEEE80211_S_INIT, -1)(((ic)->ic_newstate)((ic), (IEEE80211_S_INIT), (-1)));
1879
1880 if ((sc->sc_flags & RTW_F_INVALID0x00000080) == 0) {
1881 /* Disable interrupts. */
1882 RTW_WRITE16(regs, RTW_IMR, 0)((*(regs)->r_write16)(regs, 0x3c, 0));
1883
1884 RTW_WBW(regs, RTW_TPPOLL, RTW_IMR)((*(regs)->r_barrier)(regs, 0xd9, 0x3c, 0x02));
1885
1886 /* Stop the transmit and receive processes. First stop DMA,
1887 * then disable receiver and transmitter.
1888 */
1889 RTW_WRITE8(regs, RTW_TPPOLL, RTW_TPPOLL_SALL)((*(regs)->r_write8)(regs, 0xd9, ((1<<3) | (1<<
2) | (1<<1) | (1<<0))))
;
1890
1891 RTW_SYNC(regs, RTW_TPPOLL, RTW_IMR)((*(regs)->r_barrier)(regs, 0xd9, 0x3c, (0x01|0x02)));
1892
1893 rtw_io_enable(&sc->sc_regs, RTW_CR_RE(1<<3)|RTW_CR_TE(1<<2), 0);
1894 }
1895
1896 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
1897 rtw_txsofts_release(sc->sc_dmat, &sc->sc_ic,
1898 &sc->sc_txsoft_blk[pri]);
1899 }
1900
1901 rtw_rxbufs_release(sc->sc_dmat, &sc->sc_rxsoft[0]);
1902
1903 if (disable)
1904 rtw_disable(sc);
1905
1906 /* Mark the interface as not running. Cancel the watchdog timer. */
1907 ifp->if_flags &= ~IFF_RUNNING0x40;
1908 ifq_clr_oactive(&ifp->if_snd);
1909 ifp->if_timer = 0;
1910
1911 return;
1912}
1913
1914#ifdef RTW_DEBUG
1915const char *
1916rtw_pwrstate_string(enum rtw_pwrstate power)
1917{
1918 switch (power) {
1919 case RTW_ON:
1920 return "on";
1921 case RTW_SLEEP:
1922 return "sleep";
1923 case RTW_OFF:
1924 return "off";
1925 default:
1926 return "unknown";
1927 }
1928}
1929#endif
1930
1931/* XXX For Maxim, I am using the RFMD settings gleaned from the
1932 * reference driver, plus a magic Maxim "ON" value that comes from
1933 * the Realtek document "Windows PG for Rtl8180."
1934 */
1935void
1936rtw_maxim_pwrstate(struct rtw_regs *regs, enum rtw_pwrstate power,
1937 int before_rf, int digphy)
1938{
1939 u_int32_t anaparm;
1940
1941 anaparm = RTW_READ(regs, RTW_ANAPARM_0)((*(regs)->r_read32)(regs, 0x54));
1942 anaparm &= ~(RTW_ANAPARM_RFPOW_MASK(0x70000000|0x7f00000) | RTW_ANAPARM_TXDACOFF(1<<27));
1943
1944 switch (power) {
1945 case RTW_OFF:
1946 if (before_rf)
1947 return;
1948 anaparm |= RTW_ANAPARM_RFPOW_MAXIM_OFF((0x379) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
1949 anaparm |= RTW_ANAPARM_TXDACOFF(1<<27);
1950 break;
1951 case RTW_SLEEP:
1952 if (!before_rf)
1953 return;
1954 anaparm |= RTW_ANAPARM_RFPOW_MAXIM_SLEEP((0x378) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
1955 anaparm |= RTW_ANAPARM_TXDACOFF(1<<27);
1956 break;
1957 case RTW_ON:
1958 if (!before_rf)
1959 return;
1960 anaparm |= RTW_ANAPARM_RFPOW_MAXIM_ON((0x8) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
1961 break;
1962 }
1963 RTW_DPRINTF(RTW_DEBUG_PWR,
1964 ("%s: power state %s, %s RF, reg[ANAPARM] <- %08x\n",
1965 __func__, rtw_pwrstate_string(power),
1966 (before_rf) ? "before" : "after", anaparm));
1967
1968 RTW_WRITE(regs, RTW_ANAPARM_0, anaparm)((*(regs)->r_write32)(regs, 0x54, anaparm));
1969 RTW_SYNC(regs, RTW_ANAPARM_0, RTW_ANAPARM_0)((*(regs)->r_barrier)(regs, 0x54, 0x54, (0x01|0x02)));
1970}
1971
1972/* XXX I am using the RFMD settings gleaned from the reference
1973 * driver. They agree
1974 */
1975void
1976rtw_rfmd_pwrstate(struct rtw_regs *regs, enum rtw_pwrstate power,
1977 int before_rf, int digphy)
1978{
1979 u_int32_t anaparm;
1980
1981 anaparm = RTW_READ(regs, RTW_ANAPARM_0)((*(regs)->r_read32)(regs, 0x54));
1982 anaparm &= ~(RTW_ANAPARM_RFPOW_MASK(0x70000000|0x7f00000) | RTW_ANAPARM_TXDACOFF(1<<27));
1983
1984 switch (power) {
1985 case RTW_OFF:
1986 if (before_rf)
1987 return;
1988 anaparm |= RTW_ANAPARM_RFPOW_RFMD_OFF((0x379) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
1989 anaparm |= RTW_ANAPARM_TXDACOFF(1<<27);
1990 break;
1991 case RTW_SLEEP:
1992 if (!before_rf)
1993 return;
1994 anaparm |= RTW_ANAPARM_RFPOW_RFMD_SLEEP((0x378) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
1995 anaparm |= RTW_ANAPARM_TXDACOFF(1<<27);
1996 break;
1997 case RTW_ON:
1998 if (!before_rf)
1999 return;
2000 anaparm |= RTW_ANAPARM_RFPOW_RFMD_ON((0x408) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
2001 break;
2002 }
2003 RTW_DPRINTF(RTW_DEBUG_PWR,
2004 ("%s: power state %s, %s RF, reg[ANAPARM] <- %08x\n",
2005 __func__, rtw_pwrstate_string(power),
2006 (before_rf) ? "before" : "after", anaparm));
2007
2008 RTW_WRITE(regs, RTW_ANAPARM_0, anaparm)((*(regs)->r_write32)(regs, 0x54, anaparm));
2009 RTW_SYNC(regs, RTW_ANAPARM_0, RTW_ANAPARM_0)((*(regs)->r_barrier)(regs, 0x54, 0x54, (0x01|0x02)));
2010}
2011
2012void
2013rtw_philips_pwrstate(struct rtw_regs *regs, enum rtw_pwrstate power,
2014 int before_rf, int digphy)
2015{
2016 u_int32_t anaparm;
2017
2018 anaparm = RTW_READ(regs, RTW_ANAPARM_0)((*(regs)->r_read32)(regs, 0x54));
2019 anaparm &= ~(RTW_ANAPARM_RFPOW_MASK(0x70000000|0x7f00000) | RTW_ANAPARM_TXDACOFF(1<<27));
2020
2021 switch (power) {
2022 case RTW_OFF:
2023 if (before_rf)
2024 return;
2025 anaparm |= RTW_ANAPARM_RFPOW_PHILIPS_OFF((0x379) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
2026 anaparm |= RTW_ANAPARM_TXDACOFF(1<<27);
2027 break;
2028 case RTW_SLEEP:
2029 if (!before_rf)
2030 return;
2031 anaparm |= RTW_ANAPARM_RFPOW_PHILIPS_SLEEP((0x378) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
2032 anaparm |= RTW_ANAPARM_TXDACOFF(1<<27);
2033 break;
2034 case RTW_ON:
2035 if (!before_rf)
2036 return;
2037 if (digphy) {
2038 anaparm |= RTW_ANAPARM_RFPOW_DIG_PHILIPS_ON((0x008) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
2039 /* XXX guess */
2040 anaparm |= RTW_ANAPARM_TXDACOFF(1<<27);
2041 } else
2042 anaparm |= RTW_ANAPARM_RFPOW_ANA_PHILIPS_ON((0x328) << ((((u_long)((((((0x7f00000)) - 1) & ((0x7f00000
))) ^ ((0x7f00000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0x7f00000) >> 16)) - 1) & (((0x7f00000) >>
16))) ^ (((0x7f00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x7f00000) >> 16) >> 8)) - 1
) & ((((0x7f00000) >> 16) >> 8))) ^ ((((0x7f00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7f00000) >> 16) >> 8) >> 4)) - 1
) & (((((0x7f00000) >> 16) >> 8) >> 4))
) ^ (((((0x7f00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f00000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f00000
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f00000) >> 16) >> 8)))
- 1) & (((((0x7f00000) >> 16) >> 8)))) ^ (((
((0x7f00000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x7f00000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0x7f00000) >> 16) >>
8)) >> 2))) ^ ((((((0x7f00000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x7f00000) >> 16) >> 8)))) - 1) & ((
((((0x7f00000) >> 16) >> 8))))) ^ ((((((0x7f00000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x7f00000) >> 16))) - 1) & (
(((0x7f00000) >> 16)))) ^ ((((0x7f00000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000) >>
16)) >> 4)) - 1) & (((((0x7f00000) >> 16)) >>
4))) ^ (((((0x7f00000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0x7f00000) >>
16)) >> 4) >> 2))) ^ ((((((0x7f00000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7f00000) >> 16)) >> 4))) - 1
) & ((((((0x7f00000) >> 16)) >> 4)))) ^ (((((
(0x7f00000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7f00000) >> 16)))) -
1) & (((((0x7f00000) >> 16))))) ^ (((((0x7f00000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f00000
) >> 16))) >> 2)) - 1) & ((((((0x7f00000) >>
16))) >> 2))) ^ ((((((0x7f00000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
) >> 16))))) - 1) & ((((((0x7f00000) >> 16)))
))) ^ ((((((0x7f00000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0x7f00000))) - 1) & (((0x7f00000
)))) ^ (((0x7f00000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f00000)) >> 8)) - 1) & ((((0x7f00000)) >>
8))) ^ ((((0x7f00000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7f00000)) >> 8) >> 4)) -
1) & (((((0x7f00000)) >> 8) >> 4))) ^ (((((0x7f00000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f00000)) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f00000)) >> 8) >> 4) >> 2
))) ^ ((((((0x7f00000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000
)) >> 8) >> 4))) - 1) & ((((((0x7f00000)) >>
8) >> 4)))) ^ ((((((0x7f00000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f00000
)) >> 8))) - 1) & (((((0x7f00000)) >> 8)))) ^
(((((0x7f00000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000)) >> 8)) >> 2)) - 1
) & ((((((0x7f00000)) >> 8)) >> 2))) ^ ((((((
0x7f00000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000)) >> 8)))) - 1
) & ((((((0x7f00000)) >> 8))))) ^ ((((((0x7f00000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f00000)))) - 1) & ((((0x7f00000))))) ^ ((((0x7f00000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f00000
))) >> 4)) - 1) & (((((0x7f00000))) >> 4))) ^
(((((0x7f00000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7f00000))) >> 4) >> 2)) - 1
) & ((((((0x7f00000))) >> 4) >> 2))) ^ ((((((
0x7f00000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f00000))) >> 4))) - 1
) & ((((((0x7f00000))) >> 4)))) ^ ((((((0x7f00000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x7f00000))))) - 1) & (((((0x7f00000)))))) ^ (((
((0x7f00000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f00000)))) >> 2)) - 1) & ((((((0x7f00000)))
) >> 2))) ^ ((((((0x7f00000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f00000)))))) -
1) & ((((((0x7f00000))))))) ^ ((((((0x7f00000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
2043 break;
2044 }
2045 RTW_DPRINTF(RTW_DEBUG_PWR,
2046 ("%s: power state %s, %s RF, reg[ANAPARM] <- %08x\n",
2047 __func__, rtw_pwrstate_string(power),
2048 (before_rf) ? "before" : "after", anaparm));
2049
2050 RTW_WRITE(regs, RTW_ANAPARM_0, anaparm)((*(regs)->r_write32)(regs, 0x54, anaparm));
2051 RTW_SYNC(regs, RTW_ANAPARM_0, RTW_ANAPARM_0)((*(regs)->r_barrier)(regs, 0x54, 0x54, (0x01|0x02)));
2052}
2053
2054void
2055rtw_rtl_pwrstate(struct rtw_regs *regs, enum rtw_pwrstate power,
2056 int before_rf, int digphy)
2057{
2058 /* empty */
2059}
2060
2061void
2062rtw_pwrstate0(struct rtw_softc *sc, enum rtw_pwrstate power, int before_rf,
2063 int digphy)
2064{
2065 struct rtw_regs *regs = &sc->sc_regs;
2066
2067 rtw_set_access(regs, RTW_ACCESS_ANAPARM);
2068
2069 (*sc->sc_pwrstate_cb)(regs, power, before_rf, digphy);
2070
2071 rtw_set_access(regs, RTW_ACCESS_NONE);
2072
2073 return;
2074}
2075
2076int
2077rtw_pwrstate(struct rtw_softc *sc, enum rtw_pwrstate power)
2078{
2079 int rc;
2080
2081 RTW_DPRINTF(RTW_DEBUG_PWR,
2082 ("%s: %s->%s\n", __func__,
2083 rtw_pwrstate_string(sc->sc_pwrstate), rtw_pwrstate_string(power)));
2084
2085 if (sc->sc_pwrstate == power)
2086 return 0;
2087
2088 rtw_pwrstate0(sc, power, 1, sc->sc_flags & RTW_F_DIGPHY0x00000002);
2089 rc = (*sc->sc_rf_pwrstate)(sc, power);
2090 rtw_pwrstate0(sc, power, 0, sc->sc_flags & RTW_F_DIGPHY0x00000002);
2091
2092 switch (power) {
2093 case RTW_ON:
2094 /* TBD set LEDs */
2095 break;
2096 case RTW_SLEEP:
2097 /* TBD */
2098 break;
2099 case RTW_OFF:
2100 /* TBD */
2101 break;
2102 }
2103 if (rc == 0)
2104 sc->sc_pwrstate = power;
2105 else
2106 sc->sc_pwrstate = RTW_OFF;
2107 return rc;
2108}
2109
2110int
2111rtw_tune(struct rtw_softc *sc)
2112{
2113 struct ieee80211com *ic = &sc->sc_ic;
2114 u_int chan, idx;
2115 u_int8_t txpower;
2116 int rc;
2117
2118 KASSERT(ic->ic_bss->ni_chan != NULL)((ic->ic_bss->ni_chan != ((void *)0)) ? (void)0 : __assert
("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 2118, "ic->ic_bss->ni_chan != NULL"
))
;
2119
2120 chan = ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan);
2121 if (chan == 0 || chan == IEEE80211_CHAN_ANY0xffff)
2122 return 0;
2123
2124 if (chan == sc->sc_cur_chan) {
2125 RTW_DPRINTF(RTW_DEBUG_TUNE,
2126 ("%s: already tuned chan #%d\n", __func__, chan));
2127 return 0;
2128 }
2129
2130 rtw_suspend_ticks(sc);
2131
2132 rtw_io_enable(&sc->sc_regs, RTW_CR_RE(1<<3) | RTW_CR_TE(1<<2), 0);
2133
2134 /* TBD wait for Tx to complete */
2135
2136 KASSERT((sc->sc_flags & RTW_F_ENABLED) != 0)(((sc->sc_flags & 0x00000001) != 0) ? (void)0 : __assert
("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 2136, "(sc->sc_flags & RTW_F_ENABLED) != 0"
))
;
2137
2138 idx = RTW_SR_TXPOWER10x20 +
2139 ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan) - 1;
2140 KASSERT2(idx >= RTW_SR_TXPOWER1 && idx <= RTW_SR_TXPOWER14,do { if (!(idx >= 0x20 && idx <= 0x2d)) panic (
"%s: channel %d out of range", __func__, idx - 0x20 + 1) ; } while
(0)
2141 ("%s: channel %d out of range", __func__,do { if (!(idx >= 0x20 && idx <= 0x2d)) panic (
"%s: channel %d out of range", __func__, idx - 0x20 + 1) ; } while
(0)
2142 idx - RTW_SR_TXPOWER1 + 1))do { if (!(idx >= 0x20 && idx <= 0x2d)) panic (
"%s: channel %d out of range", __func__, idx - 0x20 + 1) ; } while
(0)
;
2143 txpower = RTW_SR_GET(&sc->sc_srom, idx)(((&sc->sc_srom)->sr_content[(idx)/2] >> (((idx
) % 2 == 0) ? 0 : 8)) & 0xff)
;
2144
2145 if ((rc = rtw_phy_init(sc)) != 0) {
2146 /* XXX condition on powersaving */
2147 printf("%s: phy init failed\n", sc->sc_dev.dv_xname);
2148 }
2149
2150 sc->sc_cur_chan = chan;
2151
2152 rtw_io_enable(&sc->sc_regs, RTW_CR_RE(1<<3) | RTW_CR_TE(1<<2), 1);
2153
2154 rtw_resume_ticks(sc);
2155
2156 return rc;
2157}
2158
2159void
2160rtw_disable(struct rtw_softc *sc)
2161{
2162 int rc;
2163
2164 if ((sc->sc_flags & RTW_F_ENABLED0x00000001) == 0)
2165 return;
2166
2167 /* turn off PHY */
2168 if ((sc->sc_flags & RTW_F_INVALID0x00000080) == 0 &&
2169 (rc = rtw_pwrstate(sc, RTW_OFF)) != 0) {
2170 printf("%s: failed to turn off PHY (%d)\n",
2171 sc->sc_dev.dv_xname, rc);
2172 }
2173
2174 if (sc->sc_disable != NULL((void *)0))
2175 (*sc->sc_disable)(sc);
2176
2177 sc->sc_flags &= ~RTW_F_ENABLED0x00000001;
2178}
2179
2180int
2181rtw_enable(struct rtw_softc *sc)
2182{
2183 if ((sc->sc_flags & RTW_F_ENABLED0x00000001) == 0) {
2184 if (sc->sc_enable != NULL((void *)0) && (*sc->sc_enable)(sc) != 0) {
2185 printf("%s: device enable failed\n",
2186 sc->sc_dev.dv_xname);
2187 return (EIO5);
2188 }
2189 sc->sc_flags |= RTW_F_ENABLED0x00000001;
2190 }
2191 return (0);
2192}
2193
2194void
2195rtw_transmit_config(struct rtw_softc *sc)
2196{
2197 struct rtw_regs *regs = &sc->sc_regs;
2198 u_int32_t tcr;
2199
2200 tcr = RTW_READ(regs, RTW_TCR)((*(regs)->r_read32)(regs, 0x40));
2201
2202 tcr |= RTW_TCR_CWMIN(1<<31);
2203 tcr &= ~RTW_TCR_MXDMA_MASK0xe00000;
2204 tcr |= RTW_TCR_MXDMA_256((4) << ((((u_long)((((((0xe00000)) - 1) & ((0xe00000
))) ^ ((0xe00000)))) >> (16)) != 0) ? 16 + ((((u_long)(
((((((0xe00000) >> 16)) - 1) & (((0xe00000) >>
16))) ^ (((0xe00000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0xe00000) >> 16) >> 8)) - 1
) & ((((0xe00000) >> 16) >> 8))) ^ ((((0xe00000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xe00000) >> 16) >> 8) >> 4)) - 1
) & (((((0xe00000) >> 16) >> 8) >> 4)))
^ (((((0xe00000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xe00000) >> 16)
>> 8) >> 4) >> 2)) - 1) & ((((((0xe00000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xe00000) >> 16) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xe00000
) >> 16) >> 8) >> 4)))) ^ ((((((0xe00000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xe00000) >> 16) >> 8))) -
1) & (((((0xe00000) >> 16) >> 8)))) ^ (((((0xe00000
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xe00000) >> 16) >> 8)) >>
2)) - 1) & ((((((0xe00000) >> 16) >> 8)) >>
2))) ^ ((((((0xe00000) >> 16) >> 8)) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000
) >> 16) >> 8)))) - 1) & ((((((0xe00000) >>
16) >> 8))))) ^ ((((((0xe00000) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xe00000
) >> 16))) - 1) & ((((0xe00000) >> 16)))) ^ (
(((0xe00000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xe00000) >> 16)) >> 4)) - 1) & (((
((0xe00000) >> 16)) >> 4))) ^ (((((0xe00000) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xe00000) >> 16)) >> 4) >> 2)) - 1) &
((((((0xe00000) >> 16)) >> 4) >> 2))) ^ ((
((((0xe00000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000) >>
16)) >> 4))) - 1) & ((((((0xe00000) >> 16)) >>
4)))) ^ ((((((0xe00000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe00000) >>
16)))) - 1) & (((((0xe00000) >> 16))))) ^ (((((0xe00000
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0xe00000) >> 16))) >> 2)) - 1) & ((((((
0xe00000) >> 16))) >> 2))) ^ ((((((0xe00000) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xe00000) >> 16))))) - 1) & ((((((0xe00000
) >> 16)))))) ^ ((((((0xe00000) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xe00000))) - 1) &
(((0xe00000)))) ^ (((0xe00000))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0xe00000)) >> 8)) - 1) & ((((0xe00000
)) >> 8))) ^ ((((0xe00000)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xe00000)) >> 8) >>
4)) - 1) & (((((0xe00000)) >> 8) >> 4))) ^ (
((((0xe00000)) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xe00000)) >> 8) >> 4
) >> 2)) - 1) & ((((((0xe00000)) >> 8) >>
4) >> 2))) ^ ((((((0xe00000)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000
)) >> 8) >> 4))) - 1) & ((((((0xe00000)) >>
8) >> 4)))) ^ ((((((0xe00000)) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe00000
)) >> 8))) - 1) & (((((0xe00000)) >> 8)))) ^ (
((((0xe00000)) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xe00000)) >> 8)) >> 2)) - 1) &
((((((0xe00000)) >> 8)) >> 2))) ^ ((((((0xe00000
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xe00000)) >> 8)))) - 1) & ((
((((0xe00000)) >> 8))))) ^ ((((((0xe00000)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xe00000
)))) - 1) & ((((0xe00000))))) ^ ((((0xe00000)))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xe00000))) >> 4)
) - 1) & (((((0xe00000))) >> 4))) ^ (((((0xe00000))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xe00000))) >> 4) >> 2)) - 1) & ((((((0xe00000
))) >> 4) >> 2))) ^ ((((((0xe00000))) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0xe00000))) >> 4))) - 1) & ((((((0xe00000)))
>> 4)))) ^ ((((((0xe00000))) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe00000))))) - 1) &
(((((0xe00000)))))) ^ (((((0xe00000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0xe00000)))) >> 2)) - 1) &
((((((0xe00000)))) >> 2))) ^ ((((((0xe00000)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00000
)))))) - 1) & ((((((0xe00000))))))) ^ ((((((0xe00000)))))
))) >> (1)) != 0) ? 1 : 0))))))
;
2205 if ((sc->sc_flags & RTW_F_RTL81850x00000008) == 0)
2206 tcr |= RTW8180_TCR_SAT(1<<24); /* send ACK as fast as possible */
2207 tcr &= ~RTW_TCR_LBK_MASK0x60000;
2208 tcr |= RTW_TCR_LBK_NORMAL((0) << ((((u_long)((((((0x60000)) - 1) & ((0x60000
))) ^ ((0x60000)))) >> (16)) != 0) ? 16 + ((((u_long)((
(((((0x60000) >> 16)) - 1) & (((0x60000) >> 16
))) ^ (((0x60000) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0x60000) >> 16) >> 8)) - 1) &
((((0x60000) >> 16) >> 8))) ^ ((((0x60000) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0x60000) >> 16) >> 8) >> 4)) - 1) &
(((((0x60000) >> 16) >> 8) >> 4))) ^ (((((
0x60000) >> 16) >> 8) >> 4)))) >> (2)
) != 0) ? 2 + ((((u_long)((((((((((0x60000) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x60000) >>
16) >> 8) >> 4) >> 2))) ^ ((((((0x60000) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x60000) >> 16) >>
8) >> 4))) - 1) & ((((((0x60000) >> 16) >>
8) >> 4)))) ^ ((((((0x60000) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
) >> 16) >> 8))) - 1) & (((((0x60000) >>
16) >> 8)))) ^ (((((0x60000) >> 16) >> 8))
))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x60000) >>
16) >> 8)) >> 2)) - 1) & ((((((0x60000) >>
16) >> 8)) >> 2))) ^ ((((((0x60000) >> 16)
>> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x60000) >> 16) >> 8)))) - 1)
& ((((((0x60000) >> 16) >> 8))))) ^ ((((((0x60000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x60000) >> 16))) - 1) & (((
(0x60000) >> 16)))) ^ ((((0x60000) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x60000) >> 16)) >>
4)) - 1) & (((((0x60000) >> 16)) >> 4))) ^ (
((((0x60000) >> 16)) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x60000) >> 16)) >> 4
) >> 2)) - 1) & ((((((0x60000) >> 16)) >>
4) >> 2))) ^ ((((((0x60000) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000
) >> 16)) >> 4))) - 1) & ((((((0x60000) >>
16)) >> 4)))) ^ ((((((0x60000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
) >> 16)))) - 1) & (((((0x60000) >> 16))))) ^
(((((0x60000) >> 16)))))) >> (2)) != 0) ? 2 + ((
((u_long)((((((((((0x60000) >> 16))) >> 2)) - 1) &
((((((0x60000) >> 16))) >> 2))) ^ ((((((0x60000)
>> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x60000) >> 16))))) - 1) & ((
((((0x60000) >> 16)))))) ^ ((((((0x60000) >> 16))
))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x60000
))) - 1) & (((0x60000)))) ^ (((0x60000))))) >> (8))
!= 0) ? 8 + ((((u_long)((((((((0x60000)) >> 8)) - 1) &
((((0x60000)) >> 8))) ^ ((((0x60000)) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x60000)) >> 8) >>
4)) - 1) & (((((0x60000)) >> 8) >> 4))) ^ ((
(((0x60000)) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x60000)) >> 8) >> 4) >>
2)) - 1) & ((((((0x60000)) >> 8) >> 4) >>
2))) ^ ((((((0x60000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000
)) >> 8) >> 4))) - 1) & ((((((0x60000)) >>
8) >> 4)))) ^ ((((((0x60000)) >> 8) >> 4))
))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x60000
)) >> 8))) - 1) & (((((0x60000)) >> 8)))) ^ (
((((0x60000)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x60000)) >> 8)) >> 2)) - 1) & (((
(((0x60000)) >> 8)) >> 2))) ^ ((((((0x60000)) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x60000)) >> 8)))) - 1) & ((((((0x60000)
) >> 8))))) ^ ((((((0x60000)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x60000)))) - 1) &
((((0x60000))))) ^ ((((0x60000)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x60000))) >> 4)) - 1) & (((
((0x60000))) >> 4))) ^ (((((0x60000))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x60000))) >> 4)
>> 2)) - 1) & ((((((0x60000))) >> 4) >>
2))) ^ ((((((0x60000))) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x60000))) >>
4))) - 1) & ((((((0x60000))) >> 4)))) ^ ((((((0x60000
))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x60000))))) - 1) & (((((0x60000)))))) ^ (((((0x60000
))))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x60000
)))) >> 2)) - 1) & ((((((0x60000)))) >> 2))) ^
((((((0x60000)))) >> 2)))) >> (1)) != 0) ? 1 : 0
) : ((((u_long)((((((((((0x60000)))))) - 1) & ((((((0x60000
))))))) ^ ((((((0x60000)))))))) >> (1)) != 0) ? 1 : 0))
))))
; /* normal operating mode */
2209
2210 /* set short/long retry limits */
2211 tcr &= ~(RTW_TCR_SRL_MASK0xff00|RTW_TCR_LRL_MASK0xff);
2212 tcr |= LSHIFT(4, RTW_TCR_SRL_MASK)((4) << ((((u_long)((((((0xff00)) - 1) & ((0xff00))
) ^ ((0xff00)))) >> (16)) != 0) ? 16 + ((((u_long)(((((
((0xff00) >> 16)) - 1) & (((0xff00) >> 16))) ^
(((0xff00) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xff00) >> 16) >> 8)) - 1) & ((((0xff00
) >> 16) >> 8))) ^ ((((0xff00) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff00) >>
16) >> 8) >> 4)) - 1) & (((((0xff00) >>
16) >> 8) >> 4))) ^ (((((0xff00) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff00) >> 16) >> 8) >> 4) >> 2)
) - 1) & ((((((0xff00) >> 16) >> 8) >> 4
) >> 2))) ^ ((((((0xff00) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xff00) >> 16) >> 8) >> 4))) - 1)
& ((((((0xff00) >> 16) >> 8) >> 4)))) ^
((((((0xff00) >> 16) >> 8) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00) >> 16
) >> 8))) - 1) & (((((0xff00) >> 16) >>
8)))) ^ (((((0xff00) >> 16) >> 8))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0xff00) >> 16) >>
8)) >> 2)) - 1) & ((((((0xff00) >> 16) >>
8)) >> 2))) ^ ((((((0xff00) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
) >> 16) >> 8)))) - 1) & ((((((0xff00) >>
16) >> 8))))) ^ ((((((0xff00) >> 16) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff00
) >> 16))) - 1) & ((((0xff00) >> 16)))) ^ (((
(0xff00) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xff00) >> 16)) >> 4)) - 1) & (((((
0xff00) >> 16)) >> 4))) ^ (((((0xff00) >> 16
)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((
((((0xff00) >> 16)) >> 4) >> 2)) - 1) &
((((((0xff00) >> 16)) >> 4) >> 2))) ^ ((((
((0xff00) >> 16)) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00) >> 16
)) >> 4))) - 1) & ((((((0xff00) >> 16)) >>
4)))) ^ ((((((0xff00) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00) >> 16
)))) - 1) & (((((0xff00) >> 16))))) ^ (((((0xff00) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00
) >> 16))) >> 2)) - 1) & ((((((0xff00) >>
16))) >> 2))) ^ ((((((0xff00) >> 16))) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
) >> 16))))) - 1) & ((((((0xff00) >> 16))))))
^ ((((((0xff00) >> 16))))))) >> (1)) != 0) ? 1 :
0)))) : ((((u_long)(((((((0xff00))) - 1) & (((0xff00))))
^ (((0xff00))))) >> (8)) != 0) ? 8 + ((((u_long)((((((
((0xff00)) >> 8)) - 1) & ((((0xff00)) >> 8)))
^ ((((0xff00)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0xff00)) >> 8) >> 4)) - 1) & (
((((0xff00)) >> 8) >> 4))) ^ (((((0xff00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff00)) >> 8) >> 4) >> 2)) - 1) &
((((((0xff00)) >> 8) >> 4) >> 2))) ^ (((((
(0xff00)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8) >>
4))) - 1) & ((((((0xff00)) >> 8) >> 4)))) ^ (
(((((0xff00)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xff00)) >> 8))) - 1) &
(((((0xff00)) >> 8)))) ^ (((((0xff00)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00)) >>
8)) >> 2)) - 1) & ((((((0xff00)) >> 8)) >>
2))) ^ ((((((0xff00)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8
)))) - 1) & ((((((0xff00)) >> 8))))) ^ ((((((0xff00
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00)))) - 1) & ((((0xff00))))) ^ ((((0xff00))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff00))) >>
4)) - 1) & (((((0xff00))) >> 4))) ^ (((((0xff00)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xff00))) >> 4) >> 2)) - 1) & ((((((0xff00)
)) >> 4) >> 2))) ^ ((((((0xff00))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
))) >> 4))) - 1) & ((((((0xff00))) >> 4)))) ^
((((((0xff00))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff00))))) - 1) & (((((0xff00)))
))) ^ (((((0xff00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00)))) >> 2)) - 1) & ((((((0xff00)))
) >> 2))) ^ ((((((0xff00)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)))))) - 1) &
((((((0xff00))))))) ^ ((((((0xff00)))))))) >> (1)) != 0
) ? 1 : 0))))))
| LSHIFT(4, RTW_TCR_LRL_MASK)((4) << ((((u_long)((((((0xff)) - 1) & ((0xff))) ^ (
(0xff)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xff)
>> 16)) - 1) & (((0xff) >> 16))) ^ (((0xff) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xff) >>
16) >> 8)) - 1) & ((((0xff) >> 16) >> 8
))) ^ ((((0xff) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xff) >> 16) >> 8) >>
4)) - 1) & (((((0xff) >> 16) >> 8) >> 4
))) ^ (((((0xff) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xff) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xff) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16) >>
8) >> 4))) - 1) & ((((((0xff) >> 16) >>
8) >> 4)))) ^ ((((((0xff) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff
) >> 16) >> 8))) - 1) & (((((0xff) >> 16
) >> 8)))) ^ (((((0xff) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >> 16) >>
8)) >> 2)) - 1) & ((((((0xff) >> 16) >>
8)) >> 2))) ^ ((((((0xff) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff
) >> 16) >> 8)))) - 1) & ((((((0xff) >>
16) >> 8))))) ^ ((((((0xff) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff)
>> 16))) - 1) & ((((0xff) >> 16)))) ^ ((((0xff
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xff) >> 16)) >> 4)) - 1) & (((((0xff) >>
16)) >> 4))) ^ (((((0xff) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >>
16)) >> 4) >> 2)) - 1) & ((((((0xff) >>
16)) >> 4) >> 2))) ^ ((((((0xff) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xff) >> 16)) >> 4))) - 1) & ((((((
0xff) >> 16)) >> 4)))) ^ ((((((0xff) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xff) >> 16)))) - 1) & (((((0xff) >>
16))))) ^ (((((0xff) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xff) >> 16))) >> 2)) -
1) & ((((((0xff) >> 16))) >> 2))) ^ ((((((0xff
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xff) >> 16))))) - 1) & (((((
(0xff) >> 16)))))) ^ ((((((0xff) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xff))) - 1) &
(((0xff)))) ^ (((0xff))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xff)) >> 8)) - 1) & ((((0xff)) >> 8
))) ^ ((((0xff)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xff)) >> 8) >> 4)) - 1) & (
((((0xff)) >> 8) >> 4))) ^ (((((0xff)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xff)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xff)) >> 8) >> 4) >> 2))) ^ ((((((0xff)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xff)) >> 8) >> 4)
)) - 1) & ((((((0xff)) >> 8) >> 4)))) ^ (((((
(0xff)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xff)) >> 8))) - 1) & ((
(((0xff)) >> 8)))) ^ (((((0xff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff)) >> 8)) >>
2)) - 1) & ((((((0xff)) >> 8)) >> 2))) ^ (((
(((0xff)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xff)) >> 8)))) - 1) &
((((((0xff)) >> 8))))) ^ ((((((0xff)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff))))
- 1) & ((((0xff))))) ^ ((((0xff)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xff))) >> 4)) - 1) & (
((((0xff))) >> 4))) ^ (((((0xff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff))) >> 4) >>
2)) - 1) & ((((((0xff))) >> 4) >> 2))) ^ (((
(((0xff))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xff))) >> 4))) - 1) &
((((((0xff))) >> 4)))) ^ ((((((0xff))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff))))
) - 1) & (((((0xff)))))) ^ (((((0xff))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xff)))) >> 2)) - 1) &
((((((0xff)))) >> 2))) ^ ((((((0xff)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff))))
)) - 1) & ((((((0xff))))))) ^ ((((((0xff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
2213
2214 tcr &= ~RTW_TCR_CRC(1<<16); /* NIC appends CRC32 */
2215
2216 RTW_WRITE(regs, RTW_TCR, tcr)((*(regs)->r_write32)(regs, 0x40, tcr));
2217 RTW_SYNC(regs, RTW_TCR, RTW_TCR)((*(regs)->r_barrier)(regs, 0x40, 0x40, (0x01|0x02)));
2218}
2219
2220void
2221rtw_enable_interrupts(struct rtw_softc *sc)
2222{
2223 struct rtw_regs *regs = &sc->sc_regs;
2224
2225 sc->sc_inten = RTW_INTR_RX((1<<1)|(1<<0))|RTW_INTR_TX((1<<3)|(1<<2)|(1<<9)| (1<<8)|(1<<
7)|(1<<6)| (1<<11)|(1<<10))
|RTW_INTR_BEACON((1<<13)|(1<<11)|(1<<10))|RTW_INTR_ATIMINT(1<<12);
2226 sc->sc_inten |= RTW_INTR_IOERROR((1<<15)|(1<<5)|(1<<4))|RTW_INTR_TIMEOUT(1<<14);
2227
2228 RTW_WRITE16(regs, RTW_IMR, sc->sc_inten)((*(regs)->r_write16)(regs, 0x3c, sc->sc_inten));
2229 RTW_WBW(regs, RTW_IMR, RTW_ISR)((*(regs)->r_barrier)(regs, 0x3c, 0x3e, 0x02));
2230 RTW_WRITE16(regs, RTW_ISR, 0xffff)((*(regs)->r_write16)(regs, 0x3e, 0xffff));
2231 RTW_SYNC(regs, RTW_IMR, RTW_ISR)((*(regs)->r_barrier)(regs, 0x3c, 0x3e, (0x01|0x02)));
2232
2233 /* XXX necessary? */
2234 if (sc->sc_intr_ack != NULL((void *)0))
2235 (*sc->sc_intr_ack)(regs);
2236}
2237
2238void
2239rtw_set_nettype(struct rtw_softc *sc, enum ieee80211_opmode opmode)
2240{
2241 uint8_t msr;
2242
2243 /* I'm guessing that MSR is protected as CONFIG[0123] are. */
2244 rtw_set_access(&sc->sc_regs, RTW_ACCESS_CONFIG);
2245
2246 msr = RTW_READ8(&sc->sc_regs, RTW_MSR)((*(&sc->sc_regs)->r_read8)(&sc->sc_regs, 0x58
))
& ~RTW_MSR_NETYPE_MASK0xc;
2247
2248 switch (opmode) {
2249#ifndef IEEE80211_STA_ONLY
2250 case IEEE80211_M_AHDEMO:
2251 case IEEE80211_M_IBSS:
2252 msr |= RTW_MSR_NETYPE_ADHOC_OK((1) << ((((u_long)((((((0xc)) - 1) & ((0xc))) ^ ((
0xc)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc) >>
16)) - 1) & (((0xc) >> 16))) ^ (((0xc) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc) >>
16) >> 8)) - 1) & ((((0xc) >> 16) >> 8
))) ^ ((((0xc) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc) >> 16) >> 8) >>
4)) - 1) & (((((0xc) >> 16) >> 8) >> 4
))) ^ (((((0xc) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16) >> 8
) >> 4))) - 1) & ((((((0xc) >> 16) >> 8
) >> 4)))) ^ ((((((0xc) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc
) >> 16) >> 8))) - 1) & (((((0xc) >> 16
) >> 8)))) ^ (((((0xc) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc) >> 16) >>
8)) >> 2))) ^ ((((((0xc) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16) >> 8)))) - 1) & ((((((0xc) >> 16
) >> 8))))) ^ ((((((0xc) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc) >> 16)
)) - 1) & ((((0xc) >> 16)))) ^ ((((0xc) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xc) >>
16)) >> 4)) - 1) & (((((0xc) >> 16)) >>
4))) ^ (((((0xc) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xc) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xc) >> 16)) >> 4)
>> 2))) ^ ((((((0xc) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16)) >> 4))) - 1) & ((((((0xc) >> 16
)) >> 4)))) ^ ((((((0xc) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc) >> 16)
))) - 1) & (((((0xc) >> 16))))) ^ (((((0xc) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc)
>> 16))) >> 2)) - 1) & ((((((0xc) >> 16
))) >> 2))) ^ ((((((0xc) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16)
)))) - 1) & ((((((0xc) >> 16)))))) ^ ((((((0xc) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xc))) - 1) & (((0xc)))) ^ (((0xc))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xc)) >> 8)) - 1) & ((
((0xc)) >> 8))) ^ ((((0xc)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xc)) >> 8) >> 4
)) - 1) & (((((0xc)) >> 8) >> 4))) ^ (((((0xc
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xc)) >> 8) >> 4) >> 2)) - 1) &
((((((0xc)) >> 8) >> 4) >> 2))) ^ ((((((0xc
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xc)) >> 8) >> 4
))) - 1) & ((((((0xc)) >> 8) >> 4)))) ^ (((((
(0xc)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xc)) >> 8))) - 1) & (((((
0xc)) >> 8)))) ^ (((((0xc)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xc)) >> 8)) >>
2)) - 1) & ((((((0xc)) >> 8)) >> 2))) ^ ((((
((0xc)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)) >> 8)))) - 1) & ((
((((0xc)) >> 8))))) ^ ((((((0xc)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc)))) - 1) &
((((0xc))))) ^ ((((0xc)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xc))) >> 4)) - 1) & (((((0xc))) >>
4))) ^ (((((0xc))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xc))) >> 4) >> 2)) - 1) &
((((((0xc))) >> 4) >> 2))) ^ ((((((0xc))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc))) >> 4))) - 1) & ((((((0xc))) >>
4)))) ^ ((((((0xc))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xc))))) - 1) & (((((0xc))))
)) ^ (((((0xc))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xc)))) >> 2)) - 1) & ((((((0xc)))) >>
2))) ^ ((((((0xc)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)))))) - 1) & ((((((0xc))))
))) ^ ((((((0xc)))))))) >> (1)) != 0) ? 1 : 0))))))
;
2253 break;
2254 case IEEE80211_M_HOSTAP:
2255 msr |= RTW_MSR_NETYPE_AP_OK((3) << ((((u_long)((((((0xc)) - 1) & ((0xc))) ^ ((
0xc)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc) >>
16)) - 1) & (((0xc) >> 16))) ^ (((0xc) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc) >>
16) >> 8)) - 1) & ((((0xc) >> 16) >> 8
))) ^ ((((0xc) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc) >> 16) >> 8) >>
4)) - 1) & (((((0xc) >> 16) >> 8) >> 4
))) ^ (((((0xc) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16) >> 8
) >> 4))) - 1) & ((((((0xc) >> 16) >> 8
) >> 4)))) ^ ((((((0xc) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc
) >> 16) >> 8))) - 1) & (((((0xc) >> 16
) >> 8)))) ^ (((((0xc) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc) >> 16) >>
8)) >> 2))) ^ ((((((0xc) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16) >> 8)))) - 1) & ((((((0xc) >> 16
) >> 8))))) ^ ((((((0xc) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc) >> 16)
)) - 1) & ((((0xc) >> 16)))) ^ ((((0xc) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xc) >>
16)) >> 4)) - 1) & (((((0xc) >> 16)) >>
4))) ^ (((((0xc) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xc) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xc) >> 16)) >> 4)
>> 2))) ^ ((((((0xc) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16)) >> 4))) - 1) & ((((((0xc) >> 16
)) >> 4)))) ^ ((((((0xc) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc) >> 16)
))) - 1) & (((((0xc) >> 16))))) ^ (((((0xc) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc)
>> 16))) >> 2)) - 1) & ((((((0xc) >> 16
))) >> 2))) ^ ((((((0xc) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16)
)))) - 1) & ((((((0xc) >> 16)))))) ^ ((((((0xc) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xc))) - 1) & (((0xc)))) ^ (((0xc))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xc)) >> 8)) - 1) & ((
((0xc)) >> 8))) ^ ((((0xc)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xc)) >> 8) >> 4
)) - 1) & (((((0xc)) >> 8) >> 4))) ^ (((((0xc
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xc)) >> 8) >> 4) >> 2)) - 1) &
((((((0xc)) >> 8) >> 4) >> 2))) ^ ((((((0xc
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xc)) >> 8) >> 4
))) - 1) & ((((((0xc)) >> 8) >> 4)))) ^ (((((
(0xc)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xc)) >> 8))) - 1) & (((((
0xc)) >> 8)))) ^ (((((0xc)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xc)) >> 8)) >>
2)) - 1) & ((((((0xc)) >> 8)) >> 2))) ^ ((((
((0xc)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)) >> 8)))) - 1) & ((
((((0xc)) >> 8))))) ^ ((((((0xc)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc)))) - 1) &
((((0xc))))) ^ ((((0xc)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xc))) >> 4)) - 1) & (((((0xc))) >>
4))) ^ (((((0xc))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xc))) >> 4) >> 2)) - 1) &
((((((0xc))) >> 4) >> 2))) ^ ((((((0xc))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc))) >> 4))) - 1) & ((((((0xc))) >>
4)))) ^ ((((((0xc))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xc))))) - 1) & (((((0xc))))
)) ^ (((((0xc))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xc)))) >> 2)) - 1) & ((((((0xc)))) >>
2))) ^ ((((((0xc)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)))))) - 1) & ((((((0xc))))
))) ^ ((((((0xc)))))))) >> (1)) != 0) ? 1 : 0))))))
;
2256 break;
2257#endif
2258 case IEEE80211_M_MONITOR:
2259 /* XXX */
2260 msr |= RTW_MSR_NETYPE_NOLINK((0) << ((((u_long)((((((0xc)) - 1) & ((0xc))) ^ ((
0xc)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc) >>
16)) - 1) & (((0xc) >> 16))) ^ (((0xc) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc) >>
16) >> 8)) - 1) & ((((0xc) >> 16) >> 8
))) ^ ((((0xc) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc) >> 16) >> 8) >>
4)) - 1) & (((((0xc) >> 16) >> 8) >> 4
))) ^ (((((0xc) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16) >> 8
) >> 4))) - 1) & ((((((0xc) >> 16) >> 8
) >> 4)))) ^ ((((((0xc) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc
) >> 16) >> 8))) - 1) & (((((0xc) >> 16
) >> 8)))) ^ (((((0xc) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc) >> 16) >>
8)) >> 2))) ^ ((((((0xc) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16) >> 8)))) - 1) & ((((((0xc) >> 16
) >> 8))))) ^ ((((((0xc) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc) >> 16)
)) - 1) & ((((0xc) >> 16)))) ^ ((((0xc) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xc) >>
16)) >> 4)) - 1) & (((((0xc) >> 16)) >>
4))) ^ (((((0xc) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xc) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xc) >> 16)) >> 4)
>> 2))) ^ ((((((0xc) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16)) >> 4))) - 1) & ((((((0xc) >> 16
)) >> 4)))) ^ ((((((0xc) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc) >> 16)
))) - 1) & (((((0xc) >> 16))))) ^ (((((0xc) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc)
>> 16))) >> 2)) - 1) & ((((((0xc) >> 16
))) >> 2))) ^ ((((((0xc) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16)
)))) - 1) & ((((((0xc) >> 16)))))) ^ ((((((0xc) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xc))) - 1) & (((0xc)))) ^ (((0xc))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xc)) >> 8)) - 1) & ((
((0xc)) >> 8))) ^ ((((0xc)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xc)) >> 8) >> 4
)) - 1) & (((((0xc)) >> 8) >> 4))) ^ (((((0xc
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xc)) >> 8) >> 4) >> 2)) - 1) &
((((((0xc)) >> 8) >> 4) >> 2))) ^ ((((((0xc
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xc)) >> 8) >> 4
))) - 1) & ((((((0xc)) >> 8) >> 4)))) ^ (((((
(0xc)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xc)) >> 8))) - 1) & (((((
0xc)) >> 8)))) ^ (((((0xc)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xc)) >> 8)) >>
2)) - 1) & ((((((0xc)) >> 8)) >> 2))) ^ ((((
((0xc)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)) >> 8)))) - 1) & ((
((((0xc)) >> 8))))) ^ ((((((0xc)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc)))) - 1) &
((((0xc))))) ^ ((((0xc)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xc))) >> 4)) - 1) & (((((0xc))) >>
4))) ^ (((((0xc))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xc))) >> 4) >> 2)) - 1) &
((((((0xc))) >> 4) >> 2))) ^ ((((((0xc))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc))) >> 4))) - 1) & ((((((0xc))) >>
4)))) ^ ((((((0xc))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xc))))) - 1) & (((((0xc))))
)) ^ (((((0xc))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xc)))) >> 2)) - 1) & ((((((0xc)))) >>
2))) ^ ((((((0xc)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)))))) - 1) & ((((((0xc))))
))) ^ ((((((0xc)))))))) >> (1)) != 0) ? 1 : 0))))))
;
2261 break;
2262 case IEEE80211_M_STA:
2263 msr |= RTW_MSR_NETYPE_INFRA_OK((2) << ((((u_long)((((((0xc)) - 1) & ((0xc))) ^ ((
0xc)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc) >>
16)) - 1) & (((0xc) >> 16))) ^ (((0xc) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc) >>
16) >> 8)) - 1) & ((((0xc) >> 16) >> 8
))) ^ ((((0xc) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc) >> 16) >> 8) >>
4)) - 1) & (((((0xc) >> 16) >> 8) >> 4
))) ^ (((((0xc) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16) >> 8
) >> 4))) - 1) & ((((((0xc) >> 16) >> 8
) >> 4)))) ^ ((((((0xc) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc
) >> 16) >> 8))) - 1) & (((((0xc) >> 16
) >> 8)))) ^ (((((0xc) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc) >> 16) >>
8)) >> 2))) ^ ((((((0xc) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16) >> 8)))) - 1) & ((((((0xc) >> 16
) >> 8))))) ^ ((((((0xc) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc) >> 16)
)) - 1) & ((((0xc) >> 16)))) ^ ((((0xc) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xc) >>
16)) >> 4)) - 1) & (((((0xc) >> 16)) >>
4))) ^ (((((0xc) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xc) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xc) >> 16)) >> 4)
>> 2))) ^ ((((((0xc) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc
) >> 16)) >> 4))) - 1) & ((((((0xc) >> 16
)) >> 4)))) ^ ((((((0xc) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc) >> 16)
))) - 1) & (((((0xc) >> 16))))) ^ (((((0xc) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc)
>> 16))) >> 2)) - 1) & ((((((0xc) >> 16
))) >> 2))) ^ ((((((0xc) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc) >> 16)
)))) - 1) & ((((((0xc) >> 16)))))) ^ ((((((0xc) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xc))) - 1) & (((0xc)))) ^ (((0xc))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xc)) >> 8)) - 1) & ((
((0xc)) >> 8))) ^ ((((0xc)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xc)) >> 8) >> 4
)) - 1) & (((((0xc)) >> 8) >> 4))) ^ (((((0xc
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xc)) >> 8) >> 4) >> 2)) - 1) &
((((((0xc)) >> 8) >> 4) >> 2))) ^ ((((((0xc
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xc)) >> 8) >> 4
))) - 1) & ((((((0xc)) >> 8) >> 4)))) ^ (((((
(0xc)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xc)) >> 8))) - 1) & (((((
0xc)) >> 8)))) ^ (((((0xc)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xc)) >> 8)) >>
2)) - 1) & ((((((0xc)) >> 8)) >> 2))) ^ ((((
((0xc)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)) >> 8)))) - 1) & ((
((((0xc)) >> 8))))) ^ ((((((0xc)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc)))) - 1) &
((((0xc))))) ^ ((((0xc)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xc))) >> 4)) - 1) & (((((0xc))) >>
4))) ^ (((((0xc))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xc))) >> 4) >> 2)) - 1) &
((((((0xc))) >> 4) >> 2))) ^ ((((((0xc))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc))) >> 4))) - 1) & ((((((0xc))) >>
4)))) ^ ((((((0xc))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xc))))) - 1) & (((((0xc))))
)) ^ (((((0xc))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xc)))) >> 2)) - 1) & ((((((0xc)))) >>
2))) ^ ((((((0xc)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xc)))))) - 1) & ((((((0xc))))
))) ^ ((((((0xc)))))))) >> (1)) != 0) ? 1 : 0))))))
;
2264 break;
2265 default:
2266 break;
2267 }
2268 RTW_WRITE8(&sc->sc_regs, RTW_MSR, msr)((*(&sc->sc_regs)->r_write8)(&sc->sc_regs, 0x58
, msr))
;
2269
2270 rtw_set_access(&sc->sc_regs, RTW_ACCESS_NONE);
2271}
2272
2273void
2274rtw_pktfilt_load(struct rtw_softc *sc)
2275{
2276 struct rtw_regs *regs = &sc->sc_regs;
2277 struct ieee80211com *ic = &sc->sc_ic;
2278 struct arpcom *ac = &ic->ic_ac;
2279 struct ifnet *ifp = &sc->sc_ic.ic_ific_ac.ac_if;
2280 int hash;
2281 u_int32_t hashes[2] = { 0, 0 };
2282 struct ether_multi *enm;
2283 struct ether_multistep step;
2284
2285 /* XXX might be necessary to stop Rx/Tx engines while setting filters */
2286
2287 sc->sc_rcr &= ~RTW_RCR_PKTFILTER_MASK( (1<<0) | (1<<3) | (1<<19) | (1<<5) |
(1<<21) | (1<<18) | (1<<12) | (1<<2)
| (1<<20) | (1<<1) | (1<<22) | 0)
;
2288 sc->sc_rcr &= ~(RTW_RCR_MXDMA_MASK0x700 | RTW8180_RCR_RXFTH_MASK0xe000);
2289
2290 sc->sc_rcr |= RTW_RCR_PKTFILTER_DEFAULT( (1<<18) | (1<<20) | (1<<1) | (1<<22
) | 0)
;
2291 /* MAC auto-reset PHY (huh?) */
2292 sc->sc_rcr |= RTW_RCR_ENMARP(1<<28);
2293 /* DMA whole Rx packets, only. Set Tx DMA burst size to 1024 bytes. */
2294 sc->sc_rcr |= RTW_RCR_MXDMA_1024((6) << ((((u_long)((((((0x700)) - 1) & ((0x700))) ^
((0x700)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x700
) >> 16)) - 1) & (((0x700) >> 16))) ^ (((0x700
) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((
((0x700) >> 16) >> 8)) - 1) & ((((0x700) >>
16) >> 8))) ^ ((((0x700) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x700) >> 16) >>
8) >> 4)) - 1) & (((((0x700) >> 16) >>
8) >> 4))) ^ (((((0x700) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x700) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0x700
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x700) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700) >> 16
) >> 8) >> 4))) - 1) & ((((((0x700) >> 16
) >> 8) >> 4)))) ^ ((((((0x700) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x700) >> 16) >> 8))) - 1) & (((((0x700
) >> 16) >> 8)))) ^ (((((0x700) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x700)
>> 16) >> 8)) >> 2)) - 1) & ((((((0x700
) >> 16) >> 8)) >> 2))) ^ ((((((0x700) >>
16) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)((((((((((0x700) >> 16) >> 8)))) - 1
) & ((((((0x700) >> 16) >> 8))))) ^ ((((((0x700
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x700) >> 16))) - 1) & ((((0x700
) >> 16)))) ^ ((((0x700) >> 16))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0x700) >> 16)) >>
4)) - 1) & (((((0x700) >> 16)) >> 4))) ^ (((
((0x700) >> 16)) >> 4)))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x700) >> 16)) >> 4) >>
2)) - 1) & ((((((0x700) >> 16)) >> 4) >>
2))) ^ ((((((0x700) >> 16)) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700) >>
16)) >> 4))) - 1) & ((((((0x700) >> 16)) >>
4)))) ^ ((((((0x700) >> 16)) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x700) >> 16)
))) - 1) & (((((0x700) >> 16))))) ^ (((((0x700) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x700
) >> 16))) >> 2)) - 1) & ((((((0x700) >>
16))) >> 2))) ^ ((((((0x700) >> 16))) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700
) >> 16))))) - 1) & ((((((0x700) >> 16)))))) ^
((((((0x700) >> 16))))))) >> (1)) != 0) ? 1 : 0)
))) : ((((u_long)(((((((0x700))) - 1) & (((0x700)))) ^ ((
(0x700))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x700
)) >> 8)) - 1) & ((((0x700)) >> 8))) ^ ((((0x700
)) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((((
(((0x700)) >> 8) >> 4)) - 1) & (((((0x700)) >>
8) >> 4))) ^ (((((0x700)) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x700)) >> 8) >>
4) >> 2)) - 1) & ((((((0x700)) >> 8) >>
4) >> 2))) ^ ((((((0x700)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700
)) >> 8) >> 4))) - 1) & ((((((0x700)) >>
8) >> 4)))) ^ ((((((0x700)) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x700))
>> 8))) - 1) & (((((0x700)) >> 8)))) ^ (((((
0x700)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)
((((((((((0x700)) >> 8)) >> 2)) - 1) & ((((((
0x700)) >> 8)) >> 2))) ^ ((((((0x700)) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x700)) >> 8)))) - 1) & ((((((0x700)) >>
8))))) ^ ((((((0x700)) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0x700)))) - 1) & ((((0x700
))))) ^ ((((0x700)))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0x700))) >> 4)) - 1) & (((((0x700))) >>
4))) ^ (((((0x700))) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)((((((((((0x700))) >> 4) >> 2)) - 1) &
((((((0x700))) >> 4) >> 2))) ^ ((((((0x700))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x700))) >> 4))) - 1) & ((((((0x700))) >>
4)))) ^ ((((((0x700))) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x700))))) - 1) & (((((0x700
)))))) ^ (((((0x700))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x700)))) >> 2)) - 1) & ((((((0x700)))) >>
2))) ^ ((((((0x700)))) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x700)))))) - 1) & ((((((0x700
))))))) ^ ((((((0x700)))))))) >> (1)) != 0) ? 1 : 0))))
))
| RTW8180_RCR_RXFTH_WHOLE((7) << ((((u_long)((((((0xe000)) - 1) & ((0xe000))
) ^ ((0xe000)))) >> (16)) != 0) ? 16 + ((((u_long)(((((
((0xe000) >> 16)) - 1) & (((0xe000) >> 16))) ^
(((0xe000) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xe000) >> 16) >> 8)) - 1) & ((((0xe000
) >> 16) >> 8))) ^ ((((0xe000) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xe000) >>
16) >> 8) >> 4)) - 1) & (((((0xe000) >>
16) >> 8) >> 4))) ^ (((((0xe000) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xe000) >> 16) >> 8) >> 4) >> 2)
) - 1) & ((((((0xe000) >> 16) >> 8) >> 4
) >> 2))) ^ ((((((0xe000) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xe000) >> 16) >> 8) >> 4))) - 1)
& ((((((0xe000) >> 16) >> 8) >> 4)))) ^
((((((0xe000) >> 16) >> 8) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe000) >> 16
) >> 8))) - 1) & (((((0xe000) >> 16) >>
8)))) ^ (((((0xe000) >> 16) >> 8))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0xe000) >> 16) >>
8)) >> 2)) - 1) & ((((((0xe000) >> 16) >>
8)) >> 2))) ^ ((((((0xe000) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000
) >> 16) >> 8)))) - 1) & ((((((0xe000) >>
16) >> 8))))) ^ ((((((0xe000) >> 16) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xe000
) >> 16))) - 1) & ((((0xe000) >> 16)))) ^ (((
(0xe000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xe000) >> 16)) >> 4)) - 1) & (((((
0xe000) >> 16)) >> 4))) ^ (((((0xe000) >> 16
)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((
((((0xe000) >> 16)) >> 4) >> 2)) - 1) &
((((((0xe000) >> 16)) >> 4) >> 2))) ^ ((((
((0xe000) >> 16)) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000) >> 16
)) >> 4))) - 1) & ((((((0xe000) >> 16)) >>
4)))) ^ ((((((0xe000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe000) >> 16
)))) - 1) & (((((0xe000) >> 16))))) ^ (((((0xe000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xe000
) >> 16))) >> 2)) - 1) & ((((((0xe000) >>
16))) >> 2))) ^ ((((((0xe000) >> 16))) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000
) >> 16))))) - 1) & ((((((0xe000) >> 16))))))
^ ((((((0xe000) >> 16))))))) >> (1)) != 0) ? 1 :
0)))) : ((((u_long)(((((((0xe000))) - 1) & (((0xe000))))
^ (((0xe000))))) >> (8)) != 0) ? 8 + ((((u_long)((((((
((0xe000)) >> 8)) - 1) & ((((0xe000)) >> 8)))
^ ((((0xe000)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0xe000)) >> 8) >> 4)) - 1) & (
((((0xe000)) >> 8) >> 4))) ^ (((((0xe000)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xe000)) >> 8) >> 4) >> 2)) - 1) &
((((((0xe000)) >> 8) >> 4) >> 2))) ^ (((((
(0xe000)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000)) >> 8) >>
4))) - 1) & ((((((0xe000)) >> 8) >> 4)))) ^ (
(((((0xe000)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xe000)) >> 8))) - 1) &
(((((0xe000)) >> 8)))) ^ (((((0xe000)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xe000)) >>
8)) >> 2)) - 1) & ((((((0xe000)) >> 8)) >>
2))) ^ ((((((0xe000)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000)) >> 8
)))) - 1) & ((((((0xe000)) >> 8))))) ^ ((((((0xe000
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xe000)))) - 1) & ((((0xe000))))) ^ ((((0xe000))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xe000))) >>
4)) - 1) & (((((0xe000))) >> 4))) ^ (((((0xe000)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xe000))) >> 4) >> 2)) - 1) & ((((((0xe000)
)) >> 4) >> 2))) ^ ((((((0xe000))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000
))) >> 4))) - 1) & ((((((0xe000))) >> 4)))) ^
((((((0xe000))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xe000))))) - 1) & (((((0xe000)))
))) ^ (((((0xe000))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xe000)))) >> 2)) - 1) & ((((((0xe000)))
) >> 2))) ^ ((((((0xe000)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000)))))) - 1) &
((((((0xe000))))))) ^ ((((((0xe000)))))))) >> (1)) != 0
) ? 1 : 0))))))
;
2295
2296 switch (ic->ic_opmode) {
2297 case IEEE80211_M_MONITOR:
2298 sc->sc_rcr |= RTW_RCR_MONITOR( (1<<0) | (1<<19) | (1<<5) | (1<<12)
| 0)
;
2299 break;
2300#ifndef IEEE80211_STA_ONLY
2301 case IEEE80211_M_AHDEMO:
2302 case IEEE80211_M_IBSS:
2303 /* receive broadcasts in our BSS */
2304 sc->sc_rcr |= RTW_RCR_ADD3(1<<21);
2305 break;
2306#endif
2307 default:
2308 break;
2309 }
2310
2311 ifp->if_flags &= ~IFF_ALLMULTI0x200;
2312
2313 /* XXX accept all broadcast if scanning */
2314 if ((ifp->if_flags & IFF_BROADCAST0x2) != 0)
2315 sc->sc_rcr |= RTW_RCR_AB(1<<3); /* accept all broadcast */
2316
2317 if (ifp->if_flags & IFF_PROMISC0x100 || ac->ac_multirangecnt > 0) {
2318 if (ifp->if_flags & IFF_PROMISC0x100)
2319 sc->sc_rcr |= RTW_RCR_AB(1<<3); /* accept all broadcast */
2320allmulti:
2321 ifp->if_flags |= IFF_ALLMULTI0x200;
2322 goto setit;
2323 }
2324
2325 /*
2326 * Program the 64-bit multicast hash filter.
2327 */
2328 ETHER_FIRST_MULTI(step, ac, enm)do { (step).e_enm = ((&(ac)->ac_multiaddrs)->lh_first
); do { if ((((enm)) = ((step)).e_enm) != ((void *)0)) ((step
)).e_enm = ((((enm)))->enm_list.le_next); } while ( 0); } while
( 0)
;
2329 while (enm != NULL((void *)0)) {
2330 hash = ether_crc32_be((enm->enm_addrlo),
2331 IEEE80211_ADDR_LEN6) >> 26;
2332 hashes[hash >> 5] |= (1 << (hash & 0x1f));
2333 sc->sc_rcr |= RTW_RCR_AM(1<<2);
2334 ETHER_NEXT_MULTI(step, enm)do { if (((enm) = (step).e_enm) != ((void *)0)) (step).e_enm =
(((enm))->enm_list.le_next); } while ( 0)
;
2335 }
2336
2337 /* all bits set => hash is useless */
2338 if (~(hashes[0] & hashes[1]) == 0)
2339 goto allmulti;
2340
2341 setit:
2342 if (ifp->if_flags & IFF_ALLMULTI0x200) {
2343 sc->sc_rcr |= RTW_RCR_AM(1<<2); /* accept all multicast */
2344 hashes[0] = hashes[1] = 0xffffffff;
2345 }
2346
2347 RTW_WRITE(regs, RTW_MAR0, hashes[0])((*(regs)->r_write32)(regs, 0x08, hashes[0]));
2348 RTW_WRITE(regs, RTW_MAR1, hashes[1])((*(regs)->r_write32)(regs, 0x0c, hashes[1]));
2349 RTW_WRITE(regs, RTW_RCR, sc->sc_rcr)((*(regs)->r_write32)(regs, 0x44, sc->sc_rcr));
2350 RTW_SYNC(regs, RTW_MAR0, RTW_RCR)((*(regs)->r_barrier)(regs, 0x08, 0x44, (0x01|0x02))); /* RTW_MAR0 < RTW_MAR1 < RTW_RCR */
2351
2352 DPRINTF(sc, RTW_DEBUG_PKTFILT,
2353 ("%s: RTW_MAR0 %08x RTW_MAR1 %08x RTW_RCR %08x\n",
2354 sc->sc_dev.dv_xname, RTW_READ(regs, RTW_MAR0),
2355 RTW_READ(regs, RTW_MAR1), RTW_READ(regs, RTW_RCR)));
2356
2357 return;
2358}
2359
2360/* Must be called at splnet. */
2361int
2362rtw_init(struct ifnet *ifp)
2363{
2364 struct rtw_softc *sc = (struct rtw_softc *)ifp->if_softc;
2365 struct ieee80211com *ic = &sc->sc_ic;
2366 struct rtw_regs *regs = &sc->sc_regs;
2367 int rc = 0;
2368
2369 if ((rc = rtw_enable(sc)) != 0)
2370 goto out;
2371
2372 /* Cancel pending I/O and reset. */
2373 rtw_stop(ifp, 0);
2374
2375 ic->ic_bss->ni_chan = ic->ic_ibss_chan;
2376 DPRINTF(sc, RTW_DEBUG_TUNE, ("%s: channel %d freq %d flags 0x%04x\n",
2377 __func__, ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan),
2378 ic->ic_bss->ni_chan->ic_freq, ic->ic_bss->ni_chan->ic_flags));
2379
2380 if ((rc = rtw_pwrstate(sc, RTW_OFF)) != 0)
2381 goto out;
2382
2383 if ((rc = rtw_swring_setup(sc)) != 0)
2384 goto out;
2385
2386 rtw_transmit_config(sc);
2387
2388 rtw_set_access(regs, RTW_ACCESS_CONFIG);
2389
2390 RTW_WRITE8(regs, RTW_MSR, 0x0)((*(regs)->r_write8)(regs, 0x58, 0x0)); /* no link */
2391 RTW_WBW(regs, RTW_MSR, RTW_BRSR)((*(regs)->r_barrier)(regs, 0x58, 0x2c, 0x02));
2392
2393 /* long PLCP header, 1Mb/2Mb basic rate */
2394 if (sc->sc_flags & RTW_F_RTL81850x00000008)
2395 RTW_WRITE16(regs, RTW_BRSR, RTW8185_BRSR_MBR_2MBPS)((*(regs)->r_write16)(regs, 0x2c, (1<<1)));
2396 else
2397 RTW_WRITE16(regs, RTW_BRSR, RTW8180_BRSR_MBR_2MBPS)((*(regs)->r_write16)(regs, 0x2c, ((1) << ((((u_long
)((((((0x3)) - 1) & ((0x3))) ^ ((0x3)))) >> (16)) !=
0) ? 16 + ((((u_long)(((((((0x3) >> 16)) - 1) & ((
(0x3) >> 16))) ^ (((0x3) >> 16)))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3) >> 16) >> 8)) -
1) & ((((0x3) >> 16) >> 8))) ^ ((((0x3) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0x3) >> 16) >> 8) >> 4)) - 1) & ((
(((0x3) >> 16) >> 8) >> 4))) ^ (((((0x3) >>
16) >> 8) >> 4)))) >> (2)) != 0) ? 2 + (((
(u_long)((((((((((0x3) >> 16) >> 8) >> 4) >>
2)) - 1) & ((((((0x3) >> 16) >> 8) >> 4
) >> 2))) ^ ((((((0x3) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3) >> 16) >> 8) >> 4))) - 1) &
((((((0x3) >> 16) >> 8) >> 4)))) ^ ((((((0x3
) >> 16) >> 8) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16) >> 8
))) - 1) & (((((0x3) >> 16) >> 8)))) ^ (((((0x3
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0x3) >> 16) >> 8)) >> 2)) -
1) & ((((((0x3) >> 16) >> 8)) >> 2))) ^
((((((0x3) >> 16) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
>> 8)))) - 1) & ((((((0x3) >> 16) >> 8
))))) ^ ((((((0x3) >> 16) >> 8)))))) >> (1)
) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3) >> 16))) -
1) & ((((0x3) >> 16)))) ^ ((((0x3) >> 16))))
) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3) >>
16)) >> 4)) - 1) & (((((0x3) >> 16)) >>
4))) ^ (((((0x3) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x3) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x3) >> 16)) >> 4)
>> 2))) ^ ((((((0x3) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3
) >> 16)) >> 4))) - 1) & ((((((0x3) >> 16
)) >> 4)))) ^ ((((((0x3) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3) >> 16)
))) - 1) & (((((0x3) >> 16))))) ^ (((((0x3) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3)
>> 16))) >> 2)) - 1) & ((((((0x3) >> 16
))) >> 2))) ^ ((((((0x3) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3) >> 16)
)))) - 1) & ((((((0x3) >> 16)))))) ^ ((((((0x3) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x3))) - 1) & (((0x3)))) ^ (((0x3))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x3)) >> 8)) - 1) & ((
((0x3)) >> 8))) ^ ((((0x3)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3)) >> 8) >> 4
)) - 1) & (((((0x3)) >> 8) >> 4))) ^ (((((0x3
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3)) >> 8) >> 4) >> 2)) - 1) &
((((((0x3)) >> 8) >> 4) >> 2))) ^ ((((((0x3
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3)) >> 8) >> 4
))) - 1) & ((((((0x3)) >> 8) >> 4)))) ^ (((((
(0x3)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x3)) >> 8))) - 1) & (((((
0x3)) >> 8)))) ^ (((((0x3)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3)) >> 8)) >>
2)) - 1) & ((((((0x3)) >> 8)) >> 2))) ^ ((((
((0x3)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)) >> 8)))) - 1) & ((
((((0x3)) >> 8))))) ^ ((((((0x3)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3)))) - 1) &
((((0x3))))) ^ ((((0x3)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3))) >> 4)) - 1) & (((((0x3))) >>
4))) ^ (((((0x3))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x3))) >> 4) >> 2)) - 1) &
((((((0x3))) >> 4) >> 2))) ^ ((((((0x3))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3))) >> 4))) - 1) & ((((((0x3))) >>
4)))) ^ ((((((0x3))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x3))))) - 1) & (((((0x3))))
)) ^ (((((0x3))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3)))) >> 2)) - 1) & ((((((0x3)))) >>
2))) ^ ((((((0x3)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x3)))))) - 1) & ((((((0x3))))
))) ^ ((((((0x3)))))))) >> (1)) != 0) ? 1 : 0))))))))
;
2398 RTW_SYNC(regs, RTW_BRSR, RTW_BRSR)((*(regs)->r_barrier)(regs, 0x2c, 0x2c, (0x01|0x02)));
2399
2400 rtw_set_access(regs, RTW_ACCESS_ANAPARM);
2401 rtw_set_access(regs, RTW_ACCESS_NONE);
2402
2403 /* XXX from reference sources */
2404 RTW_WRITE(regs, RTW_FEMR, 0xffff)((*(regs)->r_write32)(regs, 0xf4, 0xffff));
2405 RTW_SYNC(regs, RTW_FEMR, RTW_FEMR)((*(regs)->r_barrier)(regs, 0xf4, 0xf4, (0x01|0x02)));
2406
2407 rtw_set_rfprog(regs, sc->sc_rfchipid, sc->sc_dev.dv_xname);
2408
2409 RTW_WRITE8(regs, RTW_PHYDELAY, sc->sc_phydelay)((*(regs)->r_write8)(regs, 0x78, sc->sc_phydelay));
2410 /* from Linux driver */
2411 RTW_WRITE8(regs, RTW_CRCOUNT, RTW_CRCOUNT_MAGIC)((*(regs)->r_write8)(regs, 0x79, 0x4c));
2412
2413 RTW_SYNC(regs, RTW_PHYDELAY, RTW_CRCOUNT)((*(regs)->r_barrier)(regs, 0x78, 0x79, (0x01|0x02)));
2414
2415 rtw_enable_interrupts(sc);
2416
2417 rtw_pktfilt_load(sc);
2418
2419 rtw_hwring_setup(sc);
2420
2421 rtw_io_enable(regs, RTW_CR_RE(1<<3)|RTW_CR_TE(1<<2), 1);
2422
2423 ifp->if_flags |= IFF_RUNNING0x40;
2424 ic->ic_state = IEEE80211_S_INIT;
2425
2426 RTW_WRITE16(regs, RTW_BSSID16, 0x0)((*(regs)->r_write16)(regs, 0x2e, 0x0));
2427 RTW_WRITE(regs, RTW_BSSID32, 0x0)((*(regs)->r_write32)(regs, (0x2e + 4), 0x0));
2428
2429 rtw_resume_ticks(sc);
2430
2431 rtw_set_nettype(sc, IEEE80211_M_MONITOR);
2432
2433 if (ic->ic_opmode == IEEE80211_M_MONITOR)
2434 return ieee80211_new_state(ic, IEEE80211_S_RUN, -1)(((ic)->ic_newstate)((ic), (IEEE80211_S_RUN), (-1)));
2435 else
2436 return ieee80211_new_state(ic, IEEE80211_S_SCAN, -1)(((ic)->ic_newstate)((ic), (IEEE80211_S_SCAN), (-1)));
2437
2438out:
2439 printf("%s: interface not running\n", sc->sc_dev.dv_xname);
2440 return rc;
2441}
2442
2443void
2444rtw_led_init(struct rtw_regs *regs)
2445{
2446 u_int8_t cfg0, cfg1;
2447
2448 rtw_set_access(regs, RTW_ACCESS_CONFIG);
2449
2450 cfg0 = RTW_READ8(regs, RTW_CONFIG0)((*(regs)->r_read8)(regs, 0x51));
2451 cfg0 |= RTW8180_CONFIG0_LEDGPOEN(1<<4);
2452 RTW_WRITE8(regs, RTW_CONFIG0, cfg0)((*(regs)->r_write8)(regs, 0x51, cfg0));
2453
2454 cfg1 = RTW_READ8(regs, RTW_CONFIG1)((*(regs)->r_read8)(regs, 0x52));
2455 RTW_DPRINTF(RTW_DEBUG_LED,
2456 ("%s: read % from reg[CONFIG1]\n", __func__, cfg1));
2457
2458 cfg1 &= ~RTW_CONFIG1_LEDS_MASK0xc0;
2459 cfg1 |= RTW_CONFIG1_LEDS_TX_RX((2) << ((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ (
(0xc0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc0)
>> 16)) - 1) & (((0xc0) >> 16))) ^ (((0xc0) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >>
16) >> 8)) - 1) & ((((0xc0) >> 16) >> 8
))) ^ ((((0xc0) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0) >> 16) >> 8) >>
4)) - 1) & (((((0xc0) >> 16) >> 8) >> 4
))) ^ (((((0xc0) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc0) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc0) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4))) - 1) & ((((((0xc0) >> 16) >>
8) >> 4)))) ^ ((((((0xc0) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0
) >> 16) >> 8))) - 1) & (((((0xc0) >> 16
) >> 8)))) ^ (((((0xc0) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
2460 RTW_WRITE8(regs, RTW_CONFIG1, cfg1)((*(regs)->r_write8)(regs, 0x52, cfg1));
2461
2462 rtw_set_access(regs, RTW_ACCESS_NONE);
2463}
2464
2465/*
2466 * IEEE80211_S_INIT: LED1 off
2467 *
2468 * IEEE80211_S_AUTH,
2469 * IEEE80211_S_ASSOC,
2470 * IEEE80211_S_SCAN: LED1 blinks @ 1 Hz, blinks at 5Hz for tx/rx
2471 *
2472 * IEEE80211_S_RUN: LED1 on, blinks @ 5Hz for tx/rx
2473 */
2474void
2475rtw_led_newstate(struct rtw_softc *sc, enum ieee80211_state nstate)
2476{
2477 struct rtw_led_state *ls;
2478
2479 ls = &sc->sc_led_state;
2480
2481 switch (nstate) {
2482 case IEEE80211_S_INIT:
2483 rtw_led_init(&sc->sc_regs);
2484 timeout_del(&ls->ls_slow_ch);
2485 timeout_del(&ls->ls_fast_ch);
2486 ls->ls_slowblink = 0;
2487 ls->ls_actblink = 0;
2488 ls->ls_default = 0;
2489 break;
2490 case IEEE80211_S_SCAN:
2491 timeout_add_msec(&ls->ls_slow_ch, RTW_LED_SLOW_MSEC500);
2492 timeout_add_msec(&ls->ls_fast_ch, RTW_LED_FAST_MSEC100);
2493 /*FALLTHROUGH*/
2494 case IEEE80211_S_AUTH:
2495 case IEEE80211_S_ASSOC:
2496 ls->ls_default = RTW_LED10x2;
2497 ls->ls_actblink = RTW_LED10x2;
2498 ls->ls_slowblink = RTW_LED10x2;
2499 break;
2500 case IEEE80211_S_RUN:
2501 ls->ls_slowblink = 0;
2502 break;
2503 }
2504 rtw_led_set(ls, &sc->sc_regs, sc->sc_hwverid);
2505}
2506
2507void
2508rtw_led_set(struct rtw_led_state *ls, struct rtw_regs *regs, u_int hwverid)
2509{
2510 u_int8_t led_condition;
2511 bus_size_t ofs;
2512 u_int8_t mask, newval, val;
2513
2514 led_condition = ls->ls_default;
2515
2516 if (ls->ls_state & RTW_LED_S_SLOW0x4)
2517 led_condition ^= ls->ls_slowblink;
2518 if (ls->ls_state & (RTW_LED_S_RX0x1|RTW_LED_S_TX0x2))
2519 led_condition ^= ls->ls_actblink;
2520
2521 RTW_DPRINTF(RTW_DEBUG_LED,
2522 ("%s: LED condition %\n", __func__, led_condition));
2523
2524 switch (hwverid) {
2525 default:
2526 case RTW_TCR_HWVERID_RTL8180F0x6000000:
2527 ofs = RTW_PSR0x5e;
2528 newval = mask = RTW_PSR_LEDGPO0(1<<4) | RTW_PSR_LEDGPO1(1<<5);
2529 if (led_condition & RTW_LED00x1)
2530 newval &= ~RTW_PSR_LEDGPO0(1<<4);
2531 if (led_condition & RTW_LED10x2)
2532 newval &= ~RTW_PSR_LEDGPO1(1<<5);
2533 break;
2534 case RTW_TCR_HWVERID_RTL8180D(1<<26):
2535 ofs = RTW_9346CR0x50;
2536 mask = RTW_9346CR_EEM_MASK0xc0 | RTW_9346CR_EEDI(1<<1) | RTW_9346CR_EECS(1<<3);
2537 newval = RTW_9346CR_EEM_PROGRAM((2) << ((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ (
(0xc0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc0)
>> 16)) - 1) & (((0xc0) >> 16))) ^ (((0xc0) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >>
16) >> 8)) - 1) & ((((0xc0) >> 16) >> 8
))) ^ ((((0xc0) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0) >> 16) >> 8) >>
4)) - 1) & (((((0xc0) >> 16) >> 8) >> 4
))) ^ (((((0xc0) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc0) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc0) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4))) - 1) & ((((((0xc0) >> 16) >>
8) >> 4)))) ^ ((((((0xc0) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0
) >> 16) >> 8))) - 1) & (((((0xc0) >> 16
) >> 8)))) ^ (((((0xc0) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
2538 if (led_condition & RTW_LED00x1)
2539 newval |= RTW_9346CR_EEDI(1<<1);
2540 if (led_condition & RTW_LED10x2)
2541 newval |= RTW_9346CR_EECS(1<<3);
2542 break;
2543 }
2544 val = RTW_READ8(regs, ofs)((*(regs)->r_read8)(regs, ofs));
2545 RTW_DPRINTF(RTW_DEBUG_LED,
2546 ("%s: read % from reg[%#02]\n", __func__, val,
2547 (u_int *)ofs));
2548 val &= ~mask;
2549 val |= newval;
2550 RTW_WRITE8(regs, ofs, val)((*(regs)->r_write8)(regs, ofs, val));
2551 RTW_DPRINTF(RTW_DEBUG_LED,
2552 ("%s: wrote % to reg[%#02]\n", __func__, val,
2553 (u_int *)ofs));
2554 RTW_SYNC(regs, ofs, ofs)((*(regs)->r_barrier)(regs, ofs, ofs, (0x01|0x02)));
2555}
2556
2557void
2558rtw_led_fastblink(void *arg)
2559{
2560 int ostate, s;
2561 struct rtw_softc *sc = (struct rtw_softc *)arg;
2562 struct rtw_led_state *ls = &sc->sc_led_state;
2563
2564 s = splnet()splraise(0x4);
2565 ostate = ls->ls_state;
2566 ls->ls_state ^= ls->ls_event;
2567
2568 if ((ls->ls_event & RTW_LED_S_TX0x2) == 0)
2569 ls->ls_state &= ~RTW_LED_S_TX0x2;
2570
2571 if ((ls->ls_event & RTW_LED_S_RX0x1) == 0)
2572 ls->ls_state &= ~RTW_LED_S_RX0x1;
2573
2574 ls->ls_event = 0;
2575
2576 if (ostate != ls->ls_state)
2577 rtw_led_set(ls, &sc->sc_regs, sc->sc_hwverid);
2578 splx(s)spllower(s);
2579
2580 timeout_add_msec(&ls->ls_fast_ch, RTW_LED_FAST_MSEC100);
2581}
2582
2583void
2584rtw_led_slowblink(void *arg)
2585{
2586 int s;
2587 struct rtw_softc *sc = (struct rtw_softc *)arg;
2588 struct rtw_led_state *ls = &sc->sc_led_state;
2589
2590 s = splnet()splraise(0x4);
2591 ls->ls_state ^= RTW_LED_S_SLOW0x4;
2592 rtw_led_set(ls, &sc->sc_regs, sc->sc_hwverid);
2593 splx(s)spllower(s);
2594 timeout_add_msec(&ls->ls_slow_ch, RTW_LED_SLOW_MSEC500);
2595}
2596
2597void
2598rtw_led_attach(struct rtw_led_state *ls, void *arg)
2599{
2600 timeout_set(&ls->ls_fast_ch, rtw_led_fastblink, arg);
2601 timeout_set(&ls->ls_slow_ch, rtw_led_slowblink, arg);
2602}
2603
2604int
2605rtw_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
2606{
2607 struct rtw_softc *sc = ifp->if_softc;
2608 struct ifreq *ifr = (struct ifreq *)data;
2609 int rc = 0, s;
2610
2611 s = splnet()splraise(0x4);
2612
2613 switch (cmd) {
2614 case SIOCSIFADDR((unsigned long)0x80000000 | ((sizeof(struct ifreq) & 0x1fff
) << 16) | ((('i')) << 8) | ((12)))
:
2615 ifp->if_flags |= IFF_UP0x1;
2616 /* FALLTHROUGH */
2617
2618 case SIOCSIFFLAGS((unsigned long)0x80000000 | ((sizeof(struct ifreq) & 0x1fff
) << 16) | ((('i')) << 8) | ((16)))
:
2619 if ((ifp->if_flags & IFF_UP0x1) != 0) {
2620 if ((sc->sc_flags & RTW_F_ENABLED0x00000001) != 0) {
2621 rtw_pktfilt_load(sc);
2622 } else
2623 rc = rtw_init(ifp);
2624 } else if ((sc->sc_flags & RTW_F_ENABLED0x00000001) != 0)
2625 rtw_stop(ifp, 1);
2626 break;
2627
2628 case SIOCADDMULTI((unsigned long)0x80000000 | ((sizeof(struct ifreq) & 0x1fff
) << 16) | ((('i')) << 8) | ((49)))
:
2629 case SIOCDELMULTI((unsigned long)0x80000000 | ((sizeof(struct ifreq) & 0x1fff
) << 16) | ((('i')) << 8) | ((50)))
:
2630 if (cmd == SIOCADDMULTI((unsigned long)0x80000000 | ((sizeof(struct ifreq) & 0x1fff
) << 16) | ((('i')) << 8) | ((49)))
)
2631 rc = ether_addmulti(ifr, &sc->sc_ic.ic_ac);
2632 else
2633 rc = ether_delmulti(ifr, &sc->sc_ic.ic_ac);
2634 if (rc != ENETRESET52)
2635 break;
2636 if (ifp->if_flags & IFF_RUNNING0x40)
2637 rtw_pktfilt_load(sc);
2638 rc = 0;
2639 break;
2640
2641 default:
2642 if ((rc = ieee80211_ioctl(ifp, cmd, data)) == ENETRESET52) {
2643 if ((sc->sc_flags & RTW_F_ENABLED0x00000001) != 0)
2644 rc = rtw_init(ifp);
2645 else
2646 rc = 0;
2647 }
2648 break;
2649 }
2650
2651 splx(s)spllower(s);
2652 return rc;
2653}
2654
2655/* Select a transmit ring with at least one h/w and s/w descriptor free.
2656 * Return 0 on success, -1 on failure.
2657 */
2658int
2659rtw_txring_choose(struct rtw_softc *sc, struct rtw_txsoft_blk **tsbp,
2660 struct rtw_txdesc_blk **tdbp, int pri)
2661{
2662 struct rtw_txsoft_blk *tsb;
2663 struct rtw_txdesc_blk *tdb;
2664
2665 KASSERT(pri >= 0 && pri < RTW_NTXPRI)((pri >= 0 && pri < 4) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 2665, "pri >= 0 && pri < RTW_NTXPRI"
))
;
2666
2667 tsb = &sc->sc_txsoft_blk[pri];
2668 tdb = &sc->sc_txdesc_blk[pri];
2669
2670 if (SIMPLEQ_EMPTY(&tsb->tsb_freeq)(((&tsb->tsb_freeq)->sqh_first) == ((void *)0)) || tdb->tdb_nfree == 0) {
2671 if (tsb->tsb_tx_timer == 0)
2672 tsb->tsb_tx_timer = 5;
2673 *tsbp = NULL((void *)0);
2674 *tdbp = NULL((void *)0);
2675 return -1;
2676 }
2677 *tsbp = tsb;
2678 *tdbp = tdb;
2679 return 0;
2680}
2681
2682struct mbuf *
2683rtw_80211_dequeue(struct rtw_softc *sc, struct mbuf_queue *ifq, int pri,
2684 struct rtw_txsoft_blk **tsbp, struct rtw_txdesc_blk **tdbp,
2685 struct ieee80211_node **nip)
2686{
2687 struct mbuf *m;
2688
2689 if (mq_empty(ifq)(({ typeof((ifq)->mq_list.ml_len) __tmp = *(volatile typeof
((ifq)->mq_list.ml_len) *)&((ifq)->mq_list.ml_len);
membar_datadep_consumer(); __tmp; }) == 0)
)
2690 return NULL((void *)0);
2691 if (rtw_txring_choose(sc, tsbp, tdbp, pri) == -1) {
2692 DPRINTF(sc, RTW_DEBUG_XMIT_RSRC, ("%s: no ring %d descriptor\n",
2693 __func__, pri));
2694 ifq_set_oactive(&sc->sc_ifsc_ic.ic_ac.ac_if.if_snd);
2695 sc->sc_ifsc_ic.ic_ac.ac_if.if_timer = 1;
2696 return NULL((void *)0);
2697 }
2698 m = mq_dequeue(ifq);
2699 *nip = m->m_pkthdrM_dat.MH.MH_pkthdr.ph_cookie;
2700 return m;
2701}
2702
2703/* Point *mp at the next 802.11 frame to transmit. Point *tsbp
2704 * at the driver's selection of transmit control block for the packet.
2705 */
2706int
2707rtw_dequeue(struct ifnet *ifp, struct rtw_txsoft_blk **tsbp,
2708 struct rtw_txdesc_blk **tdbp, struct mbuf **mp,
2709 struct ieee80211_node **nip)
2710{
2711 struct ieee80211com *ic;
2712 struct ieee80211_frame *wh;
2713 struct ieee80211_key *k;
2714 struct mbuf *m0;
2715 struct rtw_softc *sc;
2716
2717 sc = (struct rtw_softc *)ifp->if_softc;
2718 ic = &sc->sc_ic;
2719
2720 DPRINTF(sc, RTW_DEBUG_XMIT,
2721 ("%s: enter %s\n", sc->sc_dev.dv_xname, __func__));
2722
2723 if (ic->ic_state == IEEE80211_S_RUN &&
2724 (*mp = rtw_80211_dequeue(sc, &sc->sc_beaconq, RTW_TXPRIBCN3, tsbp,
2725 tdbp, nip)) != NULL((void *)0)) {
2726 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: dequeue beacon frame\n",
2727 __func__));
2728 return 0;
2729 }
2730
2731 if ((*mp = rtw_80211_dequeue(sc, &ic->ic_mgtq, RTW_TXPRIMD1, tsbp,
2732 tdbp, nip)) != NULL((void *)0)) {
2733 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: dequeue mgt frame\n",
2734 __func__));
2735 return 0;
2736 }
2737
2738 if (sc->sc_ic.ic_state != IEEE80211_S_RUN) {
2739 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: not running\n", __func__));
2740 return 0;
2741 }
2742
2743 if ((*mp = rtw_80211_dequeue(sc, &ic->ic_pwrsaveq, RTW_TXPRIHI2,
2744 tsbp, tdbp, nip)) != NULL((void *)0)) {
2745 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: dequeue pwrsave frame\n",
2746 __func__));
2747 return 0;
2748 }
2749
2750 if (ic->ic_state != IEEE80211_S_RUN) {
2751 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: not running\n", __func__));
2752 return 0;
2753 }
2754
2755 *mp = NULL((void *)0);
2756
2757 m0 = ifq_deq_begin(&ifp->if_snd);
2758 if (m0 == NULL((void *)0)) {
2759 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: no frame ready\n",
2760 __func__));
2761 return 0;
2762 }
2763
2764 if (rtw_txring_choose(sc, tsbp, tdbp, RTW_TXPRIMD1) == -1) {
2765 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: no descriptor\n", __func__));
2766 ifq_deq_rollback(&ifp->if_snd, m0);
2767 ifq_set_oactive(&ifp->if_snd);
2768 sc->sc_ifsc_ic.ic_ac.ac_if.if_timer = 1;
2769 return 0;
2770 }
2771
2772 ifq_deq_commit(&ifp->if_snd, m0);
2773 if (m0 == NULL((void *)0)) {
2774 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: no frame/ring ready\n",
2775 __func__));
2776 return 0;
2777 }
2778 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: dequeue data frame\n", __func__));
2779#if NBPFILTER1 > 0
2780 if (ifp->if_bpf)
2781 bpf_mtap(ifp->if_bpf, m0, BPF_DIRECTION_OUT(1 << 1));
2782#endif
2783 if ((m0 = ieee80211_encap(ifp, m0, nip)) == NULL((void *)0)) {
2784 DPRINTF(sc, RTW_DEBUG_XMIT,
2785 ("%s: encap error\n", __func__));
2786 ifp->if_oerrorsif_data.ifi_oerrors++;
2787 return -1;
2788 }
2789
2790 /* XXX should do WEP in hardware */
2791 if (ic->ic_flags & IEEE80211_F_WEPON0x00000100) {
2792 wh = mtod(m0, struct ieee80211_frame *)((struct ieee80211_frame *)((m0)->m_hdr.mh_data));
2793 k = ieee80211_get_txkey(ic, wh, *nip);
2794 if ((m0 = ieee80211_encrypt(ic, m0, k)) == NULL((void *)0))
2795 return -1;
2796 }
2797
2798 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: leave\n", __func__));
2799 *mp = m0;
2800 return 0;
2801}
2802
2803int
2804rtw_seg_too_short(bus_dmamap_t dmamap)
2805{
2806 int i;
2807 for (i = 0; i < dmamap->dm_nsegs; i++) {
2808 if (dmamap->dm_segs[i].ds_len < 4) {
2809 printf("%s: segment too short\n", __func__);
2810 return 1;
2811 }
2812 }
2813 return 0;
2814}
2815
2816/* TBD factor with atw_start */
2817struct mbuf *
2818rtw_dmamap_load_txbuf(bus_dma_tag_t dmat, bus_dmamap_t dmam, struct mbuf *chain,
2819 u_int ndescfree, short *ifflagsp, const char *dvname)
2820{
2821 int first, rc;
2822 struct mbuf *m, *m0;
2823
2824 m0 = chain;
2825
2826 /*
2827 * Load the DMA map. Copy and try (once) again if the packet
2828 * didn't fit in the allotted number of segments.
2829 */
2830 for (first = 1;
2831 ((rc = bus_dmamap_load_mbuf(dmat, dmam, m0,(*(dmat)->_dmamap_load_mbuf)((dmat), (dmam), (m0), (0x0400
|0x0001))
2832 BUS_DMA_WRITE|BUS_DMA_NOWAIT)(*(dmat)->_dmamap_load_mbuf)((dmat), (dmam), (m0), (0x0400
|0x0001))
) != 0 ||
2833 dmam->dm_nsegs > ndescfree || rtw_seg_too_short(dmam)) && first;
2834 first = 0) {
2835 if (rc == 0)
2836 bus_dmamap_unload(dmat, dmam)(*(dmat)->_dmamap_unload)((dmat), (dmam));
2837 MGETHDR(m, M_DONTWAIT, MT_DATA)m = m_gethdr((0x0002), (1));
2838 if (m == NULL((void *)0)) {
2839 printf("%s: unable to allocate Tx mbuf\n",
2840 dvname);
2841 break;
2842 }
2843 if (m0->m_pkthdrM_dat.MH.MH_pkthdr.len > MHLEN((256 - sizeof(struct m_hdr)) - sizeof(struct pkthdr))) {
2844 MCLGET(m, M_DONTWAIT)(void) m_clget((m), (0x0002), (1 << 11));
2845 if ((m->m_flagsm_hdr.mh_flags & M_EXT0x0001) == 0) {
2846 printf("%s: cannot allocate Tx cluster\n",
2847 dvname);
2848 m_freem(m);
2849 break;
2850 }
2851 }
2852 m_copydata(m0, 0, m0->m_pkthdrM_dat.MH.MH_pkthdr.len, mtod(m, caddr_t)((caddr_t)((m)->m_hdr.mh_data)));
2853 m->m_pkthdrM_dat.MH.MH_pkthdr.len = m->m_lenm_hdr.mh_len = m0->m_pkthdrM_dat.MH.MH_pkthdr.len;
2854 m_freem(m0);
2855 m0 = m;
2856 m = NULL((void *)0);
2857 }
2858 if (rc != 0) {
2859 printf("%s: cannot load Tx buffer, rc = %d\n", dvname, rc);
2860 m_freem(m0);
2861 return NULL((void *)0);
2862 } else if (rtw_seg_too_short(dmam)) {
2863 printf("%s: cannot load Tx buffer, segment too short\n",
2864 dvname);
2865 bus_dmamap_unload(dmat, dmam)(*(dmat)->_dmamap_unload)((dmat), (dmam));
2866 m_freem(m0);
2867 return NULL((void *)0);
2868 } else if (dmam->dm_nsegs > ndescfree) {
2869 printf("%s: too many tx segments\n", dvname);
2870 bus_dmamap_unload(dmat, dmam)(*(dmat)->_dmamap_unload)((dmat), (dmam));
2871 m_freem(m0);
2872 return NULL((void *)0);
2873 }
2874 return m0;
2875}
2876
2877
2878/*
2879 * Arguments in:
2880 *
2881 * paylen: payload length (no FCS, no WEP header)
2882 *
2883 * hdrlen: header length
2884 *
2885 * rate: MSDU speed, units 500kb/s
2886 *
2887 * flags: IEEE80211_F_SHPREAMBLE (use short preamble),
2888 * IEEE80211_F_SHSLOT (use short slot length)
2889 *
2890 * Arguments out:
2891 *
2892 * d: 802.11 Duration field for RTS,
2893 * 802.11 Duration field for data frame,
2894 * PLCP Length for data frame,
2895 * residual octets at end of data slot
2896 */
2897int
2898rtw_compute_duration1(int len, int use_ack, uint32_t flags, int rate,
2899 struct rtw_duration *d)
2900{
2901 int pre, ctsrate;
2902 int ack, bitlen, data_dur, remainder;
2903
2904 /* RTS reserves medium for SIFS | CTS | SIFS | (DATA) | SIFS | ACK
2905 * DATA reserves medium for SIFS | ACK
2906 *
2907 * XXXMYC: no ACK on multicast/broadcast or control packets
2908 */
2909
2910 bitlen = len * 8;
2911
2912 pre = IEEE80211_DUR_DS_SIFS10;
2913 if ((flags & IEEE80211_F_SHPREAMBLE0x00040000) != 0)
2914 pre += IEEE80211_DUR_DS_SHORT_PREAMBLE72 +
2915 IEEE80211_DUR_DS_FAST_PLCPHDR24;
2916 else
2917 pre += IEEE80211_DUR_DS_LONG_PREAMBLE144 +
2918 IEEE80211_DUR_DS_SLOW_PLCPHDR48;
2919
2920 d->d_residue = 0;
2921 data_dur = (bitlen * 2) / rate;
2922 remainder = (bitlen * 2) % rate;
2923 if (remainder != 0) {
2924 d->d_residue = (rate - remainder) / 16;
2925 data_dur++;
2926 }
2927
2928 switch (rate) {
2929 case 2: /* 1 Mb/s */
2930 case 4: /* 2 Mb/s */
2931 /* 1 - 2 Mb/s WLAN: send ACK/CTS at 1 Mb/s */
2932 ctsrate = 2;
2933 break;
2934 case 11: /* 5.5 Mb/s */
2935 case 22: /* 11 Mb/s */
2936 case 44: /* 22 Mb/s */
2937 /* 5.5 - 11 Mb/s WLAN: send ACK/CTS at 2 Mb/s */
2938 ctsrate = 4;
2939 break;
2940 default:
2941 /* TBD */
2942 return -1;
2943 }
2944
2945 d->d_plcp_len = data_dur;
2946
2947 ack = (use_ack) ? pre + (IEEE80211_DUR_DS_SLOW_ACK112 * 2) / ctsrate : 0;
2948
2949 d->d_rts_dur =
2950 pre + (IEEE80211_DUR_DS_SLOW_CTS112 * 2) / ctsrate +
2951 pre + data_dur +
2952 ack;
2953
2954 d->d_data_dur = ack;
2955
2956 return 0;
2957}
2958
2959/*
2960 * Arguments in:
2961 *
2962 * wh: 802.11 header
2963 *
2964 * len: packet length
2965 *
2966 * rate: MSDU speed, units 500kb/s
2967 *
2968 * fraglen: fragment length, set to maximum (or higher) for no
2969 * fragmentation
2970 *
2971 * flags: IEEE80211_F_WEPON (hardware adds WEP),
2972 * IEEE80211_F_SHPREAMBLE (use short preamble),
2973 * IEEE80211_F_SHSLOT (use short slot length)
2974 *
2975 * Arguments out:
2976 *
2977 * d0: 802.11 Duration fields (RTS/Data), PLCP Length, Service fields
2978 * of first/only fragment
2979 *
2980 * dn: 802.11 Duration fields (RTS/Data), PLCP Length, Service fields
2981 * of first/only fragment
2982 */
2983int
2984rtw_compute_duration(struct ieee80211_frame *wh, int len, uint32_t flags,
2985 int fraglen, int rate, struct rtw_duration *d0, struct rtw_duration *dn,
2986 int *npktp, int debug)
2987{
2988 int ack, rc;
2989 int firstlen, hdrlen, lastlen, lastlen0, npkt, overlen, paylen;
2990
2991 if (ieee80211_has_addr4(wh))
2992 hdrlen = sizeof(struct ieee80211_frame_addr4);
2993 else
2994 hdrlen = sizeof(struct ieee80211_frame);
2995
2996 paylen = len - hdrlen;
2997
2998 if ((flags & IEEE80211_F_WEPON0x00000100) != 0)
2999 overlen = IEEE80211_WEP_TOTLEN(3 + 1 + 4) + IEEE80211_CRC_LEN4;
3000 else
3001 overlen = IEEE80211_CRC_LEN4;
3002
3003 npkt = paylen / fraglen;
3004 lastlen0 = paylen % fraglen;
3005
3006 if (npkt == 0) /* no fragments */
3007 lastlen = paylen + overlen;
3008 else if (lastlen0 != 0) { /* a short "tail" fragment */
3009 lastlen = lastlen0 + overlen;
3010 npkt++;
3011 } else /* full-length "tail" fragment */
3012 lastlen = fraglen + overlen;
3013
3014 if (npktp != NULL((void *)0))
3015 *npktp = npkt;
3016
3017 if (npkt > 1)
3018 firstlen = fraglen + overlen;
3019 else
3020 firstlen = paylen + overlen;
3021
3022 if (debug) {
3023 printf("%s: npkt %d firstlen %d lastlen0 %d lastlen %d "
3024 "fraglen %d overlen %d len %d rate %d flags %08x\n",
3025 __func__, npkt, firstlen, lastlen0, lastlen, fraglen,
3026 overlen, len, rate, flags);
3027 }
3028
3029 ack = !IEEE80211_IS_MULTICAST(wh->i_addr1)(*(wh->i_addr1) & 0x01) &&
3030 (wh->i_fc[1] & IEEE80211_FC0_TYPE_MASK0x0c) != IEEE80211_FC0_TYPE_CTL0x04;
3031
3032 rc = rtw_compute_duration1(firstlen + hdrlen, ack, flags, rate, d0);
3033 if (rc == -1)
3034 return rc;
3035
3036 if (npkt <= 1) {
3037 *dn = *d0;
3038 return 0;
3039 }
3040 return rtw_compute_duration1(lastlen + hdrlen, ack, flags, rate, dn);
3041}
3042
3043#ifdef RTW_DEBUG
3044void
3045rtw_print_txdesc(struct rtw_softc *sc, const char *action,
3046 struct rtw_txsoft *ts, struct rtw_txdesc_blk *tdb, int desc)
3047{
3048 struct rtw_txdesc *td = &tdb->tdb_desc[desc];
3049 DPRINTF(sc, RTW_DEBUG_XMIT_DESC, ("%s: %p %s txdesc[%d] next %#08x "
3050 "buf %#08x ctl0 %#08x ctl1 %#08x len %#08x\n",
3051 sc->sc_dev.dv_xname, ts, action, desc,
3052 letoh32(td->td_buf), letoh32(td->td_next),
3053 letoh32(td->td_ctl0), letoh32(td->td_ctl1),
3054 letoh32(td->td_len)));
3055}
3056#endif /* RTW_DEBUG */
3057
3058void
3059rtw_start(struct ifnet *ifp)
3060{
3061 uint8_t tppoll;
3062 int desc, i, lastdesc, npkt, rate;
3063 uint32_t proto_ctl0, ctl0, ctl1;
3064 bus_dmamap_t dmamap;
3065 struct ieee80211com *ic;
3066 struct ieee80211_frame *wh;
3067 struct ieee80211_node *ni;
3068 struct mbuf *m0;
3069 struct rtw_softc *sc;
3070 struct rtw_duration *d0;
3071 struct rtw_txsoft_blk *tsb;
3072 struct rtw_txdesc_blk *tdb;
3073 struct rtw_txsoft *ts;
3074 struct rtw_txdesc *td;
3075
3076 sc = (struct rtw_softc *)ifp->if_softc;
3077 ic = &sc->sc_ic;
3078
3079 DPRINTF(sc, RTW_DEBUG_XMIT,
3080 ("%s: enter %s\n", sc->sc_dev.dv_xname, __func__));
3081
3082 if (!(ifp->if_flags & IFF_RUNNING0x40) || ifq_is_oactive(&ifp->if_snd))
3083 goto out;
3084
3085 /* XXX do real rate control */
3086 proto_ctl0 = RTW_TXCTL0_RTSRATE_1MBPS((0) << ((((u_long)((((((0x780000)) - 1) & ((0x780000
))) ^ ((0x780000)))) >> (16)) != 0) ? 16 + ((((u_long)(
((((((0x780000) >> 16)) - 1) & (((0x780000) >>
16))) ^ (((0x780000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x780000) >> 16) >> 8)) - 1
) & ((((0x780000) >> 16) >> 8))) ^ ((((0x780000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x780000) >> 16) >> 8) >> 4)) - 1
) & (((((0x780000) >> 16) >> 8) >> 4)))
^ (((((0x780000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x780000) >> 16)
>> 8) >> 4) >> 2)) - 1) & ((((((0x780000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x780000) >> 16) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x780000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x780000
) >> 16) >> 8) >> 4)))) ^ ((((((0x780000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x780000) >> 16) >> 8))) -
1) & (((((0x780000) >> 16) >> 8)))) ^ (((((0x780000
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0x780000) >> 16) >> 8)) >>
2)) - 1) & ((((((0x780000) >> 16) >> 8)) >>
2))) ^ ((((((0x780000) >> 16) >> 8)) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x780000
) >> 16) >> 8)))) - 1) & ((((((0x780000) >>
16) >> 8))))) ^ ((((((0x780000) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x780000
) >> 16))) - 1) & ((((0x780000) >> 16)))) ^ (
(((0x780000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x780000) >> 16)) >> 4)) - 1) & (((
((0x780000) >> 16)) >> 4))) ^ (((((0x780000) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x780000) >> 16)) >> 4) >> 2)) - 1) &
((((((0x780000) >> 16)) >> 4) >> 2))) ^ ((
((((0x780000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x780000) >>
16)) >> 4))) - 1) & ((((((0x780000) >> 16)) >>
4)))) ^ ((((((0x780000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x780000) >>
16)))) - 1) & (((((0x780000) >> 16))))) ^ (((((0x780000
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0x780000) >> 16))) >> 2)) - 1) & ((((((
0x780000) >> 16))) >> 2))) ^ ((((((0x780000) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x780000) >> 16))))) - 1) & ((((((0x780000
) >> 16)))))) ^ ((((((0x780000) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x780000))) - 1) &
(((0x780000)))) ^ (((0x780000))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0x780000)) >> 8)) - 1) & ((((0x780000
)) >> 8))) ^ ((((0x780000)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x780000)) >> 8) >>
4)) - 1) & (((((0x780000)) >> 8) >> 4))) ^ (
((((0x780000)) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x780000)) >> 8) >> 4
) >> 2)) - 1) & ((((((0x780000)) >> 8) >>
4) >> 2))) ^ ((((((0x780000)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x780000
)) >> 8) >> 4))) - 1) & ((((((0x780000)) >>
8) >> 4)))) ^ ((((((0x780000)) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x780000
)) >> 8))) - 1) & (((((0x780000)) >> 8)))) ^ (
((((0x780000)) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0x780000)) >> 8)) >> 2)) - 1) &
((((((0x780000)) >> 8)) >> 2))) ^ ((((((0x780000
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x780000)) >> 8)))) - 1) & ((
((((0x780000)) >> 8))))) ^ ((((((0x780000)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x780000
)))) - 1) & ((((0x780000))))) ^ ((((0x780000)))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x780000))) >> 4)
) - 1) & (((((0x780000))) >> 4))) ^ (((((0x780000))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0x780000))) >> 4) >> 2)) - 1) & ((((((0x780000
))) >> 4) >> 2))) ^ ((((((0x780000))) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0x780000))) >> 4))) - 1) & ((((((0x780000)))
>> 4)))) ^ ((((((0x780000))) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x780000))))) - 1) &
(((((0x780000)))))) ^ (((((0x780000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0x780000)))) >> 2)) - 1) &
((((((0x780000)))) >> 2))) ^ ((((((0x780000)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x780000
)))))) - 1) & ((((((0x780000))))))) ^ ((((((0x780000)))))
))) >> (1)) != 0) ? 1 : 0))))))
;
3087
3088 if ((ic->ic_flags & IEEE80211_F_SHPREAMBLE0x00040000) != 0)
3089 proto_ctl0 |= RTW_TXCTL0_SPLCP(1<<16);
3090
3091 for (;;) {
3092 if (rtw_dequeue(ifp, &tsb, &tdb, &m0, &ni) == -1)
3093 continue;
3094 if (m0 == NULL((void *)0))
3095 break;
3096 ts = SIMPLEQ_FIRST(&tsb->tsb_freeq)((&tsb->tsb_freeq)->sqh_first);
3097
3098 dmamap = ts->ts_dmamap;
3099
3100 m0 = rtw_dmamap_load_txbuf(sc->sc_dmat, dmamap, m0,
3101 tdb->tdb_nfree, &ifp->if_flags, sc->sc_dev.dv_xname);
3102
3103 if (m0 == NULL((void *)0) || dmamap->dm_nsegs == 0) {
3104 DPRINTF(sc, RTW_DEBUG_XMIT,
3105 ("%s: fail dmamap load\n", __func__));
3106 goto post_dequeue_err;
3107 }
3108
3109 wh = mtod(m0, struct ieee80211_frame *)((struct ieee80211_frame *)((m0)->m_hdr.mh_data));
3110
3111 /* XXX do real rate control */
3112 if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK0x0c) ==
3113 IEEE80211_FC0_TYPE_MGT0x00)
3114 rate = 2;
3115 else
3116 rate = MAX(2, ieee80211_get_rate(ic))(((2)>(ieee80211_get_rate(ic)))?(2):(ieee80211_get_rate(ic
)))
;
3117
3118#ifdef RTW_DEBUG
3119 if ((sc->sc_ifsc_ic.ic_ac.ac_if.if_flags & (IFF_DEBUG0x4|IFF_LINK20x4000)) ==
3120 (IFF_DEBUG0x4|IFF_LINK20x4000)) {
3121 ieee80211_dump_pkt(mtod(m0, uint8_t *)((uint8_t *)((m0)->m_hdr.mh_data)),
3122 (dmamap->dm_nsegs == 1) ? m0->m_pkthdrM_dat.MH.MH_pkthdr.len
3123 : sizeof(wh), rate, 0);
3124 }
3125#endif /* RTW_DEBUG */
3126 ctl0 = proto_ctl0 |
3127 LSHIFT(m0->m_pkthdr.len, RTW_TXCTL0_TPKTSIZE_MASK)((m0->M_dat.MH.MH_pkthdr.len) << ((((u_long)((((((0xfff
)) - 1) & ((0xfff))) ^ ((0xfff)))) >> (16)) != 0) ?
16 + ((((u_long)(((((((0xfff) >> 16)) - 1) & (((0xfff
) >> 16))) ^ (((0xfff) >> 16)))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xfff) >> 16) >> 8))
- 1) & ((((0xfff) >> 16) >> 8))) ^ ((((0xfff
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xfff) >> 16) >> 8) >> 4)) - 1) &
(((((0xfff) >> 16) >> 8) >> 4))) ^ (((((0xfff
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xfff) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xfff) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xfff) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xfff) >> 16) >> 8) >>
4))) - 1) & ((((((0xfff) >> 16) >> 8) >>
4)))) ^ ((((((0xfff) >> 16) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfff) >>
16) >> 8))) - 1) & (((((0xfff) >> 16) >>
8)))) ^ (((((0xfff) >> 16) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xfff) >> 16) >>
8)) >> 2)) - 1) & ((((((0xfff) >> 16) >>
8)) >> 2))) ^ ((((((0xfff) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfff
) >> 16) >> 8)))) - 1) & ((((((0xfff) >>
16) >> 8))))) ^ ((((((0xfff) >> 16) >> 8))
)))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xfff
) >> 16))) - 1) & ((((0xfff) >> 16)))) ^ ((((
0xfff) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0xfff) >> 16)) >> 4)) - 1) & (((((0xfff
) >> 16)) >> 4))) ^ (((((0xfff) >> 16)) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xfff) >>
16)) >> 4) >> 2)) - 1) & ((((((0xfff) >>
16)) >> 4) >> 2))) ^ ((((((0xfff) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xfff) >> 16)) >> 4))) - 1) & (((((
(0xfff) >> 16)) >> 4)))) ^ ((((((0xfff) >> 16
)) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xfff) >> 16)))) - 1) & (((((0xfff) >>
16))))) ^ (((((0xfff) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xfff) >> 16))) >> 2)) -
1) & ((((((0xfff) >> 16))) >> 2))) ^ ((((((0xfff
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xfff) >> 16))))) - 1) & ((((
((0xfff) >> 16)))))) ^ ((((((0xfff) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xfff))) - 1) &
(((0xfff)))) ^ (((0xfff))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xfff)) >> 8)) - 1) & ((((0xfff)) >>
8))) ^ ((((0xfff)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xfff)) >> 8) >> 4)) - 1) &
(((((0xfff)) >> 8) >> 4))) ^ (((((0xfff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xfff)) >> 8) >> 4) >> 2)) - 1) & (
(((((0xfff)) >> 8) >> 4) >> 2))) ^ ((((((0xfff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xfff)) >> 8) >>
4))) - 1) & ((((((0xfff)) >> 8) >> 4)))) ^ (
(((((0xfff)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0xfff)) >> 8))) - 1) &
(((((0xfff)) >> 8)))) ^ (((((0xfff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff)) >> 8)) >>
2)) - 1) & ((((((0xfff)) >> 8)) >> 2))) ^ ((
((((0xfff)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xfff)) >> 8)))) - 1) &
((((((0xfff)) >> 8))))) ^ ((((((0xfff)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xfff)
))) - 1) & ((((0xfff))))) ^ ((((0xfff)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0xfff))) >> 4)) - 1) &
(((((0xfff))) >> 4))) ^ (((((0xfff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff))) >> 4) >>
2)) - 1) & ((((((0xfff))) >> 4) >> 2))) ^ ((
((((0xfff))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xfff))) >> 4))) - 1) &
((((((0xfff))) >> 4)))) ^ ((((((0xfff))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfff)
)))) - 1) & (((((0xfff)))))) ^ (((((0xfff))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff)))) >> 2))
- 1) & ((((((0xfff)))) >> 2))) ^ ((((((0xfff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfff
)))))) - 1) & ((((((0xfff))))))) ^ ((((((0xfff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
3128
3129 switch (rate) {
3130 default:
3131 case 2:
3132 ctl0 |= RTW_TXCTL0_RATE_1MBPS((0) << ((((u_long)((((((0xf000000)) - 1) & ((0xf000000
))) ^ ((0xf000000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0xf000000) >> 16)) - 1) & (((0xf000000) >>
16))) ^ (((0xf000000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0xf000000) >> 16) >> 8)) - 1
) & ((((0xf000000) >> 16) >> 8))) ^ ((((0xf000000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf000000) >> 16) >> 8) >> 4)) - 1
) & (((((0xf000000) >> 16) >> 8) >> 4))
) ^ (((((0xf000000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xf000000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4)))) ^ ((((((0xf000000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xf000000) >> 16) >> 8)))
- 1) & (((((0xf000000) >> 16) >> 8)))) ^ (((
((0xf000000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xf000000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0xf000000) >> 16) >>
8)) >> 2))) ^ ((((((0xf000000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0xf000000) >> 16) >> 8)))) - 1) & ((
((((0xf000000) >> 16) >> 8))))) ^ ((((((0xf000000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0xf000000) >> 16))) - 1) & (
(((0xf000000) >> 16)))) ^ ((((0xf000000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000) >>
16)) >> 4)) - 1) & (((((0xf000000) >> 16)) >>
4))) ^ (((((0xf000000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0xf000000) >>
16)) >> 4) >> 2))) ^ ((((((0xf000000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0xf000000) >> 16)) >> 4))) - 1
) & ((((((0xf000000) >> 16)) >> 4)))) ^ (((((
(0xf000000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xf000000) >> 16)))) -
1) & (((((0xf000000) >> 16))))) ^ (((((0xf000000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
) >> 16))) >> 2)) - 1) & ((((((0xf000000) >>
16))) >> 2))) ^ ((((((0xf000000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16))))) - 1) & ((((((0xf000000) >> 16)))
))) ^ ((((((0xf000000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0xf000000))) - 1) & (((0xf000000
)))) ^ (((0xf000000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xf000000)) >> 8)) - 1) & ((((0xf000000)) >>
8))) ^ ((((0xf000000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xf000000)) >> 8) >> 4)) -
1) & (((((0xf000000)) >> 8) >> 4))) ^ (((((0xf000000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf000000)) >> 8) >> 4) >> 2)) -
1) & ((((((0xf000000)) >> 8) >> 4) >> 2
))) ^ ((((((0xf000000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
)) >> 8) >> 4))) - 1) & ((((((0xf000000)) >>
8) >> 4)))) ^ ((((((0xf000000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000
)) >> 8))) - 1) & (((((0xf000000)) >> 8)))) ^
(((((0xf000000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000)) >> 8)) >> 2)) - 1
) & ((((((0xf000000)) >> 8)) >> 2))) ^ ((((((
0xf000000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000)) >> 8)))) - 1
) & ((((((0xf000000)) >> 8))))) ^ ((((((0xf000000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xf000000)))) - 1) & ((((0xf000000))))) ^ ((((0xf000000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000
))) >> 4)) - 1) & (((((0xf000000))) >> 4))) ^
(((((0xf000000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000))) >> 4) >> 2)) - 1
) & ((((((0xf000000))) >> 4) >> 2))) ^ ((((((
0xf000000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000))) >> 4))) - 1
) & ((((((0xf000000))) >> 4)))) ^ ((((((0xf000000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xf000000))))) - 1) & (((((0xf000000)))))) ^ (((
((0xf000000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf000000)))) >> 2)) - 1) & ((((((0xf000000)))
) >> 2))) ^ ((((((0xf000000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000)))))) -
1) & ((((((0xf000000))))))) ^ ((((((0xf000000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
3133 break;
3134 case 4:
3135 ctl0 |= RTW_TXCTL0_RATE_2MBPS((1) << ((((u_long)((((((0xf000000)) - 1) & ((0xf000000
))) ^ ((0xf000000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0xf000000) >> 16)) - 1) & (((0xf000000) >>
16))) ^ (((0xf000000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0xf000000) >> 16) >> 8)) - 1
) & ((((0xf000000) >> 16) >> 8))) ^ ((((0xf000000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf000000) >> 16) >> 8) >> 4)) - 1
) & (((((0xf000000) >> 16) >> 8) >> 4))
) ^ (((((0xf000000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xf000000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4)))) ^ ((((((0xf000000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xf000000) >> 16) >> 8)))
- 1) & (((((0xf000000) >> 16) >> 8)))) ^ (((
((0xf000000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xf000000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0xf000000) >> 16) >>
8)) >> 2))) ^ ((((((0xf000000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0xf000000) >> 16) >> 8)))) - 1) & ((
((((0xf000000) >> 16) >> 8))))) ^ ((((((0xf000000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0xf000000) >> 16))) - 1) & (
(((0xf000000) >> 16)))) ^ ((((0xf000000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000) >>
16)) >> 4)) - 1) & (((((0xf000000) >> 16)) >>
4))) ^ (((((0xf000000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0xf000000) >>
16)) >> 4) >> 2))) ^ ((((((0xf000000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0xf000000) >> 16)) >> 4))) - 1
) & ((((((0xf000000) >> 16)) >> 4)))) ^ (((((
(0xf000000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xf000000) >> 16)))) -
1) & (((((0xf000000) >> 16))))) ^ (((((0xf000000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
) >> 16))) >> 2)) - 1) & ((((((0xf000000) >>
16))) >> 2))) ^ ((((((0xf000000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16))))) - 1) & ((((((0xf000000) >> 16)))
))) ^ ((((((0xf000000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0xf000000))) - 1) & (((0xf000000
)))) ^ (((0xf000000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xf000000)) >> 8)) - 1) & ((((0xf000000)) >>
8))) ^ ((((0xf000000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xf000000)) >> 8) >> 4)) -
1) & (((((0xf000000)) >> 8) >> 4))) ^ (((((0xf000000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf000000)) >> 8) >> 4) >> 2)) -
1) & ((((((0xf000000)) >> 8) >> 4) >> 2
))) ^ ((((((0xf000000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
)) >> 8) >> 4))) - 1) & ((((((0xf000000)) >>
8) >> 4)))) ^ ((((((0xf000000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000
)) >> 8))) - 1) & (((((0xf000000)) >> 8)))) ^
(((((0xf000000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000)) >> 8)) >> 2)) - 1
) & ((((((0xf000000)) >> 8)) >> 2))) ^ ((((((
0xf000000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000)) >> 8)))) - 1
) & ((((((0xf000000)) >> 8))))) ^ ((((((0xf000000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xf000000)))) - 1) & ((((0xf000000))))) ^ ((((0xf000000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000
))) >> 4)) - 1) & (((((0xf000000))) >> 4))) ^
(((((0xf000000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000))) >> 4) >> 2)) - 1
) & ((((((0xf000000))) >> 4) >> 2))) ^ ((((((
0xf000000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000))) >> 4))) - 1
) & ((((((0xf000000))) >> 4)))) ^ ((((((0xf000000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xf000000))))) - 1) & (((((0xf000000)))))) ^ (((
((0xf000000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf000000)))) >> 2)) - 1) & ((((((0xf000000)))
) >> 2))) ^ ((((((0xf000000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000)))))) -
1) & ((((((0xf000000))))))) ^ ((((((0xf000000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
3136 break;
3137 case 11:
3138 ctl0 |= RTW_TXCTL0_RATE_5MBPS((2) << ((((u_long)((((((0xf000000)) - 1) & ((0xf000000
))) ^ ((0xf000000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0xf000000) >> 16)) - 1) & (((0xf000000) >>
16))) ^ (((0xf000000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0xf000000) >> 16) >> 8)) - 1
) & ((((0xf000000) >> 16) >> 8))) ^ ((((0xf000000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf000000) >> 16) >> 8) >> 4)) - 1
) & (((((0xf000000) >> 16) >> 8) >> 4))
) ^ (((((0xf000000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xf000000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4)))) ^ ((((((0xf000000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xf000000) >> 16) >> 8)))
- 1) & (((((0xf000000) >> 16) >> 8)))) ^ (((
((0xf000000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xf000000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0xf000000) >> 16) >>
8)) >> 2))) ^ ((((((0xf000000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0xf000000) >> 16) >> 8)))) - 1) & ((
((((0xf000000) >> 16) >> 8))))) ^ ((((((0xf000000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0xf000000) >> 16))) - 1) & (
(((0xf000000) >> 16)))) ^ ((((0xf000000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000) >>
16)) >> 4)) - 1) & (((((0xf000000) >> 16)) >>
4))) ^ (((((0xf000000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0xf000000) >>
16)) >> 4) >> 2))) ^ ((((((0xf000000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0xf000000) >> 16)) >> 4))) - 1
) & ((((((0xf000000) >> 16)) >> 4)))) ^ (((((
(0xf000000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xf000000) >> 16)))) -
1) & (((((0xf000000) >> 16))))) ^ (((((0xf000000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
) >> 16))) >> 2)) - 1) & ((((((0xf000000) >>
16))) >> 2))) ^ ((((((0xf000000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16))))) - 1) & ((((((0xf000000) >> 16)))
))) ^ ((((((0xf000000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0xf000000))) - 1) & (((0xf000000
)))) ^ (((0xf000000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xf000000)) >> 8)) - 1) & ((((0xf000000)) >>
8))) ^ ((((0xf000000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xf000000)) >> 8) >> 4)) -
1) & (((((0xf000000)) >> 8) >> 4))) ^ (((((0xf000000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf000000)) >> 8) >> 4) >> 2)) -
1) & ((((((0xf000000)) >> 8) >> 4) >> 2
))) ^ ((((((0xf000000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
)) >> 8) >> 4))) - 1) & ((((((0xf000000)) >>
8) >> 4)))) ^ ((((((0xf000000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000
)) >> 8))) - 1) & (((((0xf000000)) >> 8)))) ^
(((((0xf000000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000)) >> 8)) >> 2)) - 1
) & ((((((0xf000000)) >> 8)) >> 2))) ^ ((((((
0xf000000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000)) >> 8)))) - 1
) & ((((((0xf000000)) >> 8))))) ^ ((((((0xf000000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xf000000)))) - 1) & ((((0xf000000))))) ^ ((((0xf000000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000
))) >> 4)) - 1) & (((((0xf000000))) >> 4))) ^
(((((0xf000000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000))) >> 4) >> 2)) - 1
) & ((((((0xf000000))) >> 4) >> 2))) ^ ((((((
0xf000000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000))) >> 4))) - 1
) & ((((((0xf000000))) >> 4)))) ^ ((((((0xf000000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xf000000))))) - 1) & (((((0xf000000)))))) ^ (((
((0xf000000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf000000)))) >> 2)) - 1) & ((((((0xf000000)))
) >> 2))) ^ ((((((0xf000000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000)))))) -
1) & ((((((0xf000000))))))) ^ ((((((0xf000000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
3139 break;
3140 case 22:
3141 ctl0 |= RTW_TXCTL0_RATE_11MBPS((3) << ((((u_long)((((((0xf000000)) - 1) & ((0xf000000
))) ^ ((0xf000000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0xf000000) >> 16)) - 1) & (((0xf000000) >>
16))) ^ (((0xf000000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0xf000000) >> 16) >> 8)) - 1
) & ((((0xf000000) >> 16) >> 8))) ^ ((((0xf000000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf000000) >> 16) >> 8) >> 4)) - 1
) & (((((0xf000000) >> 16) >> 8) >> 4))
) ^ (((((0xf000000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xf000000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4)))) ^ ((((((0xf000000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xf000000) >> 16) >> 8)))
- 1) & (((((0xf000000) >> 16) >> 8)))) ^ (((
((0xf000000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xf000000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0xf000000) >> 16) >>
8)) >> 2))) ^ ((((((0xf000000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0xf000000) >> 16) >> 8)))) - 1) & ((
((((0xf000000) >> 16) >> 8))))) ^ ((((((0xf000000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0xf000000) >> 16))) - 1) & (
(((0xf000000) >> 16)))) ^ ((((0xf000000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000) >>
16)) >> 4)) - 1) & (((((0xf000000) >> 16)) >>
4))) ^ (((((0xf000000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0xf000000) >>
16)) >> 4) >> 2))) ^ ((((((0xf000000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0xf000000) >> 16)) >> 4))) - 1
) & ((((((0xf000000) >> 16)) >> 4)))) ^ (((((
(0xf000000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xf000000) >> 16)))) -
1) & (((((0xf000000) >> 16))))) ^ (((((0xf000000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
) >> 16))) >> 2)) - 1) & ((((((0xf000000) >>
16))) >> 2))) ^ ((((((0xf000000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16))))) - 1) & ((((((0xf000000) >> 16)))
))) ^ ((((((0xf000000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0xf000000))) - 1) & (((0xf000000
)))) ^ (((0xf000000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xf000000)) >> 8)) - 1) & ((((0xf000000)) >>
8))) ^ ((((0xf000000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xf000000)) >> 8) >> 4)) -
1) & (((((0xf000000)) >> 8) >> 4))) ^ (((((0xf000000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf000000)) >> 8) >> 4) >> 2)) -
1) & ((((((0xf000000)) >> 8) >> 4) >> 2
))) ^ ((((((0xf000000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
)) >> 8) >> 4))) - 1) & ((((((0xf000000)) >>
8) >> 4)))) ^ ((((((0xf000000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000
)) >> 8))) - 1) & (((((0xf000000)) >> 8)))) ^
(((((0xf000000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000)) >> 8)) >> 2)) - 1
) & ((((((0xf000000)) >> 8)) >> 2))) ^ ((((((
0xf000000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000)) >> 8)))) - 1
) & ((((((0xf000000)) >> 8))))) ^ ((((((0xf000000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xf000000)))) - 1) & ((((0xf000000))))) ^ ((((0xf000000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000
))) >> 4)) - 1) & (((((0xf000000))) >> 4))) ^
(((((0xf000000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000))) >> 4) >> 2)) - 1
) & ((((((0xf000000))) >> 4) >> 2))) ^ ((((((
0xf000000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000))) >> 4))) - 1
) & ((((((0xf000000))) >> 4)))) ^ ((((((0xf000000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xf000000))))) - 1) & (((((0xf000000)))))) ^ (((
((0xf000000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf000000)))) >> 2)) - 1) & ((((((0xf000000)))
) >> 2))) ^ ((((((0xf000000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000)))))) -
1) & ((((((0xf000000))))))) ^ ((((((0xf000000)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
3142 break;
3143 }
3144
3145 /* XXX >= ? Compare after fragmentation? */
3146 if (m0->m_pkthdrM_dat.MH.MH_pkthdr.len > ic->ic_rtsthreshold)
3147 ctl0 |= RTW_TXCTL0_RTSEN(1<<23);
3148
3149 if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK0x0c) ==
3150 IEEE80211_FC0_TYPE_MGT0x00) {
3151 ctl0 &= ~(RTW_TXCTL0_SPLCP(1<<16) | RTW_TXCTL0_RTSEN(1<<23));
3152 if ((wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK0xf0) ==
3153 IEEE80211_FC0_SUBTYPE_BEACON0x80)
3154 ctl0 |= RTW_TXCTL0_BEACON(1<<18);
3155 }
3156
3157 if (rtw_compute_duration(wh, m0->m_pkthdrM_dat.MH.MH_pkthdr.len,
3158 ic->ic_flags & ~IEEE80211_F_WEPON0x00000100, ic->ic_fragthreshold,
3159 rate, &ts->ts_d0, &ts->ts_dn, &npkt,
3160 (sc->sc_ifsc_ic.ic_ac.ac_if.if_flags & (IFF_DEBUG0x4|IFF_LINK20x4000)) ==
3161 (IFF_DEBUG0x4|IFF_LINK20x4000)) == -1) {
3162 DPRINTF(sc, RTW_DEBUG_XMIT,
3163 ("%s: fail compute duration\n", __func__));
3164 goto post_load_err;
3165 }
3166
3167 d0 = &ts->ts_d0;
3168
3169 *(uint16_t*)wh->i_dur = htole16(d0->d_data_dur)((__uint16_t)(d0->d_data_dur));
3170
3171 ctl1 = LSHIFT(d0->d_plcp_len, RTW_TXCTL1_LENGTH_MASK)((d0->d_plcp_len) << ((((u_long)((((((0x7fff0000)) -
1) & ((0x7fff0000))) ^ ((0x7fff0000)))) >> (16)) !=
0) ? 16 + ((((u_long)(((((((0x7fff0000) >> 16)) - 1) &
(((0x7fff0000) >> 16))) ^ (((0x7fff0000) >> 16))
)) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x7fff0000) >>
16) >> 8)) - 1) & ((((0x7fff0000) >> 16) >>
8))) ^ ((((0x7fff0000) >> 16) >> 8)))) >> (
4)) != 0) ? 4 + ((((u_long)(((((((((0x7fff0000) >> 16) >>
8) >> 4)) - 1) & (((((0x7fff0000) >> 16) >>
8) >> 4))) ^ (((((0x7fff0000) >> 16) >> 8)
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0x7fff0000) >> 16) >> 8) >> 4) >> 2
)) - 1) & ((((((0x7fff0000) >> 16) >> 8) >>
4) >> 2))) ^ ((((((0x7fff0000) >> 16) >> 8
) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x7fff0000) >> 16) >> 8) >>
4))) - 1) & ((((((0x7fff0000) >> 16) >> 8) >>
4)))) ^ ((((((0x7fff0000) >> 16) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7fff0000
) >> 16) >> 8))) - 1) & (((((0x7fff0000) >>
16) >> 8)))) ^ (((((0x7fff0000) >> 16) >> 8
))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7fff0000
) >> 16) >> 8)) >> 2)) - 1) & ((((((0x7fff0000
) >> 16) >> 8)) >> 2))) ^ ((((((0x7fff0000)
>> 16) >> 8)) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x7fff0000) >> 16) >>
8)))) - 1) & ((((((0x7fff0000) >> 16) >> 8))
))) ^ ((((((0x7fff0000) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x7fff0000) >>
16))) - 1) & ((((0x7fff0000) >> 16)))) ^ ((((0x7fff0000
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0x7fff0000) >> 16)) >> 4)) - 1) & (((((0x7fff0000
) >> 16)) >> 4))) ^ (((((0x7fff0000) >> 16)
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0x7fff0000) >> 16)) >> 4) >> 2)) - 1) &
((((((0x7fff0000) >> 16)) >> 4) >> 2))) ^ (
(((((0x7fff0000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7fff0000) >>
16)) >> 4))) - 1) & ((((((0x7fff0000) >> 16)
) >> 4)))) ^ ((((((0x7fff0000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7fff0000
) >> 16)))) - 1) & (((((0x7fff0000) >> 16))))
) ^ (((((0x7fff0000) >> 16)))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x7fff0000) >> 16))) >> 2
)) - 1) & ((((((0x7fff0000) >> 16))) >> 2))) ^
((((((0x7fff0000) >> 16))) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7fff0000) >> 16
))))) - 1) & ((((((0x7fff0000) >> 16)))))) ^ ((((((
0x7fff0000) >> 16))))))) >> (1)) != 0) ? 1 : 0)))
) : ((((u_long)(((((((0x7fff0000))) - 1) & (((0x7fff0000)
))) ^ (((0x7fff0000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7fff0000)) >> 8)) - 1) & ((((0x7fff0000)
) >> 8))) ^ ((((0x7fff0000)) >> 8)))) >> (4
)) != 0) ? 4 + ((((u_long)(((((((((0x7fff0000)) >> 8) >>
4)) - 1) & (((((0x7fff0000)) >> 8) >> 4))) ^
(((((0x7fff0000)) >> 8) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x7fff0000)) >> 8) >>
4) >> 2)) - 1) & ((((((0x7fff0000)) >> 8) >>
4) >> 2))) ^ ((((((0x7fff0000)) >> 8) >> 4
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
((((((((0x7fff0000)) >> 8) >> 4))) - 1) & (((
(((0x7fff0000)) >> 8) >> 4)))) ^ ((((((0x7fff0000
)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)) :
((((u_long)(((((((((0x7fff0000)) >> 8))) - 1) & ((
(((0x7fff0000)) >> 8)))) ^ (((((0x7fff0000)) >> 8
))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7fff0000
)) >> 8)) >> 2)) - 1) & ((((((0x7fff0000)) >>
8)) >> 2))) ^ ((((((0x7fff0000)) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7fff0000
)) >> 8)))) - 1) & ((((((0x7fff0000)) >> 8)))
)) ^ ((((((0x7fff0000)) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0x7fff0000)))) - 1) & ((((
0x7fff0000))))) ^ ((((0x7fff0000)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x7fff0000))) >> 4)) - 1) & (
((((0x7fff0000))) >> 4))) ^ (((((0x7fff0000))) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7fff0000
))) >> 4) >> 2)) - 1) & ((((((0x7fff0000))) >>
4) >> 2))) ^ ((((((0x7fff0000))) >> 4) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7fff0000
))) >> 4))) - 1) & ((((((0x7fff0000))) >> 4))
)) ^ ((((((0x7fff0000))) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x7fff0000))))) - 1) & (((
((0x7fff0000)))))) ^ (((((0x7fff0000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0x7fff0000)))) >> 2)) - 1)
& ((((((0x7fff0000)))) >> 2))) ^ ((((((0x7fff0000)
))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x7fff0000)))))) - 1) & ((((((0x7fff0000)))))))
^ ((((((0x7fff0000)))))))) >> (1)) != 0) ? 1 : 0))))))
|
3172 LSHIFT(d0->d_rts_dur, RTW_TXCTL1_RTSDUR_MASK)((d0->d_rts_dur) << ((((u_long)((((((0xffff)) - 1) &
((0xffff))) ^ ((0xffff)))) >> (16)) != 0) ? 16 + ((((u_long
)(((((((0xffff) >> 16)) - 1) & (((0xffff) >> 16
))) ^ (((0xffff) >> 16)))) >> (8)) != 0) ? 8 + ((
((u_long)((((((((0xffff) >> 16) >> 8)) - 1) &
((((0xffff) >> 16) >> 8))) ^ ((((0xffff) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0xffff) >> 16) >> 8) >> 4)) - 1) &
(((((0xffff) >> 16) >> 8) >> 4))) ^ (((((0xffff
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xffff) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xffff) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xffff) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xffff) >> 16) >> 8) >>
4))) - 1) & ((((((0xffff) >> 16) >> 8) >>
4)))) ^ ((((((0xffff) >> 16) >> 8) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xffff
) >> 16) >> 8))) - 1) & (((((0xffff) >>
16) >> 8)))) ^ (((((0xffff) >> 16) >> 8)))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xffff) >>
16) >> 8)) >> 2)) - 1) & ((((((0xffff) >>
16) >> 8)) >> 2))) ^ ((((((0xffff) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xffff) >> 16) >> 8)))) - 1) & (((
(((0xffff) >> 16) >> 8))))) ^ ((((((0xffff) >>
16) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xffff) >> 16))) - 1) & ((((0xffff) >>
16)))) ^ ((((0xffff) >> 16))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xffff) >> 16)) >> 4)) - 1
) & (((((0xffff) >> 16)) >> 4))) ^ (((((0xffff
) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xffff) >> 16)) >> 4) >> 2
)) - 1) & ((((((0xffff) >> 16)) >> 4) >>
2))) ^ ((((((0xffff) >> 16)) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffff)
>> 16)) >> 4))) - 1) & ((((((0xffff) >>
16)) >> 4)))) ^ ((((((0xffff) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xffff
) >> 16)))) - 1) & (((((0xffff) >> 16))))) ^ (
((((0xffff) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xffff) >> 16))) >> 2)) - 1) & (((
(((0xffff) >> 16))) >> 2))) ^ ((((((0xffff) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xffff) >> 16))))) - 1) & ((((((0xffff) >>
16)))))) ^ ((((((0xffff) >> 16))))))) >> (1)) !=
0) ? 1 : 0)))) : ((((u_long)(((((((0xffff))) - 1) & (((0xffff
)))) ^ (((0xffff))))) >> (8)) != 0) ? 8 + ((((u_long)((
((((((0xffff)) >> 8)) - 1) & ((((0xffff)) >> 8
))) ^ ((((0xffff)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xffff)) >> 8) >> 4)) - 1) &
(((((0xffff)) >> 8) >> 4))) ^ (((((0xffff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xffff)) >> 8) >> 4) >> 2)) - 1) &
((((((0xffff)) >> 8) >> 4) >> 2))) ^ (((((
(0xffff)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffff)) >> 8) >>
4))) - 1) & ((((((0xffff)) >> 8) >> 4)))) ^ (
(((((0xffff)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xffff)) >> 8))) - 1) &
(((((0xffff)) >> 8)))) ^ (((((0xffff)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xffff)) >>
8)) >> 2)) - 1) & ((((((0xffff)) >> 8)) >>
2))) ^ ((((((0xffff)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffff)) >> 8
)))) - 1) & ((((((0xffff)) >> 8))))) ^ ((((((0xffff
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xffff)))) - 1) & ((((0xffff))))) ^ ((((0xffff))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xffff))) >>
4)) - 1) & (((((0xffff))) >> 4))) ^ (((((0xffff)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xffff))) >> 4) >> 2)) - 1) & ((((((0xffff)
)) >> 4) >> 2))) ^ ((((((0xffff))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffff
))) >> 4))) - 1) & ((((((0xffff))) >> 4)))) ^
((((((0xffff))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xffff))))) - 1) & (((((0xffff)))
))) ^ (((((0xffff))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xffff)))) >> 2)) - 1) & ((((((0xffff)))
) >> 2))) ^ ((((((0xffff)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffff)))))) - 1) &
((((((0xffff))))))) ^ ((((((0xffff)))))))) >> (1)) != 0
) ? 1 : 0))))))
;
3173
3174 if (d0->d_residue)
3175 ctl1 |= RTW_TXCTL1_LENGEXT(1<<31);
3176
3177 /* TBD fragmentation */
3178
3179 ts->ts_first = tdb->tdb_next;
3180
3181 rtw_txdescs_sync(tdb, ts->ts_first, dmamap->dm_nsegs,
3182 BUS_DMASYNC_PREWRITE0x04);
3183
3184 KASSERT(ts->ts_first < tdb->tdb_ndesc)((ts->ts_first < tdb->tdb_ndesc) ? (void)0 : __assert
("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 3184, "ts->ts_first < tdb->tdb_ndesc"
))
;
3185
3186#if NBPFILTER1 > 0
3187 if (ic->ic_rawbpf != NULL((void *)0))
3188 bpf_mtap((caddr_t)ic->ic_rawbpf, m0,
3189 BPF_DIRECTION_OUT(1 << 1));
3190
3191 if (sc->sc_radiobpf != NULL((void *)0)) {
3192 struct mbuf mb;
3193 struct rtw_tx_radiotap_header *rt = &sc->sc_txtapsc_txtapu.tap;
3194
3195 rt->rt_flags = 0;
3196 rt->rt_rate = rate;
3197 rt->rt_chan_freq =
3198 htole16(ic->ic_bss->ni_chan->ic_freq)((__uint16_t)(ic->ic_bss->ni_chan->ic_freq));
3199 rt->rt_chan_flags =
3200 htole16(ic->ic_bss->ni_chan->ic_flags)((__uint16_t)(ic->ic_bss->ni_chan->ic_flags));
3201
3202 mb.m_datam_hdr.mh_data = (caddr_t)rt;
3203 mb.m_lenm_hdr.mh_len = sizeof(sc->sc_txtapu);
3204 mb.m_nextm_hdr.mh_next = m0;
3205 mb.m_nextpktm_hdr.mh_nextpkt = NULL((void *)0);
3206 mb.m_typem_hdr.mh_type = 0;
3207 mb.m_flagsm_hdr.mh_flags = 0;
3208 bpf_mtap(sc->sc_radiobpf, &mb, BPF_DIRECTION_OUT(1 << 1));
3209
3210 }
3211#endif /* NBPFILTER > 0 */
3212
3213 for (i = 0, lastdesc = desc = ts->ts_first;
3214 i < dmamap->dm_nsegs;
3215 i++, desc = RTW_NEXT_IDX(tdb, desc)(((desc) + 1) % (tdb)->tdb_ndesc)) {
3216 if (dmamap->dm_segs[i].ds_len > RTW_TXLEN_LENGTH_MASK0xfff) {
3217 DPRINTF(sc, RTW_DEBUG_XMIT_DESC,
3218 ("%s: seg too long\n", __func__));
3219 goto post_load_err;
3220 }
3221 td = &tdb->tdb_desc[desc];
3222 td->td_ctl0 = htole32(ctl0)((__uint32_t)(ctl0));
3223 if (i != 0)
3224 td->td_ctl0 |= htole32(RTW_TXCTL0_OWN)((__uint32_t)((1<<31)));
3225 td->td_ctl1 = htole32(ctl1)((__uint32_t)(ctl1));
3226 td->td_buf = htole32(dmamap->dm_segs[i].ds_addr)((__uint32_t)(dmamap->dm_segs[i].ds_addr));
3227 td->td_len = htole32(dmamap->dm_segs[i].ds_len)((__uint32_t)(dmamap->dm_segs[i].ds_len));
3228 lastdesc = desc;
3229#ifdef RTW_DEBUG
3230 rtw_print_txdesc(sc, "load", ts, tdb, desc);
3231#endif /* RTW_DEBUG */
3232 }
3233
3234 KASSERT(desc < tdb->tdb_ndesc)((desc < tdb->tdb_ndesc) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 3234, "desc < tdb->tdb_ndesc"
))
;
3235
3236 ts->ts_ni = ni;
3237 ts->ts_mbuf = m0;
3238 ts->ts_last = lastdesc;
3239 tdb->tdb_desc[ts->ts_last].td_ctl0 |= htole32(RTW_TXCTL0_LS)((__uint32_t)((1<<28)));
3240 tdb->tdb_desc[ts->ts_first].td_ctl0 |=
3241 htole32(RTW_TXCTL0_FS)((__uint32_t)((1<<29)));
3242
3243#ifdef RTW_DEBUG
3244 rtw_print_txdesc(sc, "FS on", ts, tdb, ts->ts_first);
3245 rtw_print_txdesc(sc, "LS on", ts, tdb, ts->ts_last);
3246#endif /* RTW_DEBUG */
3247
3248 tdb->tdb_nfree -= dmamap->dm_nsegs;
3249 tdb->tdb_next = desc;
3250
3251 rtw_txdescs_sync(tdb, ts->ts_first, dmamap->dm_nsegs,
3252 BUS_DMASYNC_PREREAD0x01|BUS_DMASYNC_PREWRITE0x04);
3253
3254 tdb->tdb_desc[ts->ts_first].td_ctl0 |=
3255 htole32(RTW_TXCTL0_OWN)((__uint32_t)((1<<31)));
3256
3257#ifdef RTW_DEBUG
3258 rtw_print_txdesc(sc, "OWN on", ts, tdb, ts->ts_first);
3259#endif /* RTW_DEBUG */
3260
3261 rtw_txdescs_sync(tdb, ts->ts_first, 1,
3262 BUS_DMASYNC_PREREAD0x01|BUS_DMASYNC_PREWRITE0x04);
3263
3264 SIMPLEQ_REMOVE_HEAD(&tsb->tsb_freeq, ts_q)do { if (((&tsb->tsb_freeq)->sqh_first = (&tsb->
tsb_freeq)->sqh_first->ts_q.sqe_next) == ((void *)0)) (
&tsb->tsb_freeq)->sqh_last = &(&tsb->tsb_freeq
)->sqh_first; } while (0)
;
3265 SIMPLEQ_INSERT_TAIL(&tsb->tsb_dirtyq, ts, ts_q)do { (ts)->ts_q.sqe_next = ((void *)0); *(&tsb->tsb_dirtyq
)->sqh_last = (ts); (&tsb->tsb_dirtyq)->sqh_last
= &(ts)->ts_q.sqe_next; } while (0)
;
3266
3267 if (tsb != &sc->sc_txsoft_blk[RTW_TXPRIBCN3])
3268 sc->sc_led_state.ls_event |= RTW_LED_S_TX0x2;
3269 tsb->tsb_tx_timer = 5;
3270 ifp->if_timer = 1;
3271 tppoll = RTW_READ8(&sc->sc_regs, RTW_TPPOLL)((*(&sc->sc_regs)->r_read8)(&sc->sc_regs, 0xd9
))
;
3272 tppoll &= ~RTW_TPPOLL_SALL((1<<3) | (1<<2) | (1<<1) | (1<<0));
3273 tppoll |= tsb->tsb_poll & RTW_TPPOLL_ALL((1<<7) | (1<<6) | (1<<5) | (1<<4));
3274 RTW_WRITE8(&sc->sc_regs, RTW_TPPOLL, tppoll)((*(&sc->sc_regs)->r_write8)(&sc->sc_regs, 0xd9
, tppoll))
;
3275 RTW_SYNC(&sc->sc_regs, RTW_TPPOLL, RTW_TPPOLL)((*(&sc->sc_regs)->r_barrier)(&sc->sc_regs, 0xd9
, 0xd9, (0x01|0x02)))
;
3276 }
3277out:
3278 DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: leave\n", __func__));
3279 return;
3280post_load_err:
3281 bus_dmamap_unload(sc->sc_dmat, dmamap)(*(sc->sc_dmat)->_dmamap_unload)((sc->sc_dmat), (dmamap
))
;
3282 m_freem(m0);
3283post_dequeue_err:
3284 ieee80211_release_node(&sc->sc_ic, ni);
3285 return;
3286}
3287
3288void
3289rtw_idle(struct rtw_regs *regs)
3290{
3291 int active;
3292
3293 /* request stop DMA; wait for packets to stop transmitting. */
3294
3295 RTW_WRITE8(regs, RTW_TPPOLL, RTW_TPPOLL_SALL)((*(regs)->r_write8)(regs, 0xd9, ((1<<3) | (1<<
2) | (1<<1) | (1<<0))))
;
3296 RTW_WBR(regs, RTW_TPPOLL, RTW_TPPOLL)((*(regs)->r_barrier)(regs, 0xd9, 0xd9, 0x02));
3297
3298 for (active = 0; active < 300 &&
3299 (RTW_READ8(regs, RTW_TPPOLL)((*(regs)->r_read8)(regs, 0xd9)) & RTW_TPPOLL_ACTIVE((1<<7) | (1<<6) | (1<<5) | (1<<4))) != 0; active++)
3300 DELAY(10)(*delay_func)(10);
3301 RTW_DPRINTF(RTW_DEBUG_BUGS,
3302 ("%s: transmit DMA idle in %dus\n", __func__, active * 10));
3303}
3304
3305void
3306rtw_watchdog(struct ifnet *ifp)
3307{
3308 int pri, tx_timeouts = 0;
3309 struct rtw_softc *sc;
3310 struct rtw_txsoft_blk *tsb;
3311
3312 sc = ifp->if_softc;
3313
3314 ifp->if_timer = 0;
3315
3316 if ((sc->sc_flags & RTW_F_ENABLED0x00000001) == 0)
3317 return;
3318
3319 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
3320 tsb = &sc->sc_txsoft_blk[pri];
3321
3322 if (tsb->tsb_tx_timer == 0)
3323 continue;
3324 else if (--tsb->tsb_tx_timer == 0) {
3325 if (SIMPLEQ_EMPTY(&tsb->tsb_dirtyq)(((&tsb->tsb_dirtyq)->sqh_first) == ((void *)0)))
3326 continue;
3327 RTW_DPRINTF(RTW_DEBUG_BUGS,
3328 ("%s: transmit timeout, priority %d\n",
3329 ifp->if_xname, pri));
3330 ifp->if_oerrorsif_data.ifi_oerrors++;
3331 tx_timeouts++;
3332 } else
3333 ifp->if_timer = 1;
3334 }
3335
3336 if (tx_timeouts > 0) {
3337 /* Stop Tx DMA, disable xmtr, flush Tx rings, enable xmtr,
3338 * reset s/w tx-ring pointers, and start transmission.
3339 *
3340 * TBD Stop/restart just the broken rings?
3341 */
3342 rtw_idle(&sc->sc_regs);
3343 rtw_io_enable(&sc->sc_regs, RTW_CR_TE(1<<2), 0);
3344 rtw_txdescs_reset(sc);
3345 rtw_io_enable(&sc->sc_regs, RTW_CR_TE(1<<2), 1);
3346 rtw_txring_fixup(sc);
3347 rtw_start(ifp);
3348 }
3349 ieee80211_watchdog(ifp);
3350}
3351
3352void
3353rtw_next_scan(void *arg)
3354{
3355 struct rtw_softc *sc = arg;
3356 struct ieee80211com *ic = &sc->sc_ic;
3357 struct ifnet *ifp = &ic->ic_ific_ac.ac_if;
3358 int s;
3359
3360 /* don't call rtw_start w/o network interrupts blocked */
3361 s = splnet()splraise(0x4);
3362 if (ic->ic_state == IEEE80211_S_SCAN)
3363 ieee80211_next_scan(ifp);
3364 splx(s)spllower(s);
3365}
3366
3367void
3368rtw_join_bss(struct rtw_softc *sc, u_int8_t *bssid, u_int16_t intval0)
3369{
3370 uint16_t bcnitv, bintritv, intval;
3371 int i;
3372 struct rtw_regs *regs = &sc->sc_regs;
3373
3374 for (i = 0; i < IEEE80211_ADDR_LEN6; i++)
3375 RTW_WRITE8(regs, RTW_BSSID + i, bssid[i])((*(regs)->r_write8)(regs, 0x2e + i, bssid[i]));
3376
3377 RTW_SYNC(regs, RTW_BSSID16, RTW_BSSID32)((*(regs)->r_barrier)(regs, 0x2e, (0x2e + 4), (0x01|0x02))
)
;
3378
3379 rtw_set_access(regs, RTW_ACCESS_CONFIG);
3380
3381 intval = MIN(intval0, PRESHIFT(RTW_BCNITV_BCNITV_MASK))(((intval0)<(((((0x3ff)) & ((0x3ff))) >> ((((u_long
)(((((((0x3ff))) - 1) & (((0x3ff)))) ^ (((0x3ff))))) >>
(16)) != 0) ? 16 + ((((u_long)((((((((0x3ff)) >> 16)) -
1) & ((((0x3ff)) >> 16))) ^ ((((0x3ff)) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)(((((((((0x3ff)) >>
16) >> 8)) - 1) & (((((0x3ff)) >> 16) >>
8))) ^ (((((0x3ff)) >> 16) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)((((((((((0x3ff)) >> 16) >>
8) >> 4)) - 1) & ((((((0x3ff)) >> 16) >>
8) >> 4))) ^ ((((((0x3ff)) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0x3ff)
) >> 16) >> 8) >> 4) >> 2)) - 1) &
(((((((0x3ff)) >> 16) >> 8) >> 4) >>
2))) ^ (((((((0x3ff)) >> 16) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff
)) >> 16) >> 8) >> 4))) - 1) & (((((((0x3ff
)) >> 16) >> 8) >> 4)))) ^ (((((((0x3ff)) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)((((((((((0x3ff)) >> 16) >> 8))) -
1) & ((((((0x3ff)) >> 16) >> 8)))) ^ ((((((0x3ff
)) >> 16) >> 8))))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((0x3ff)) >> 16) >> 8)) >>
2)) - 1) & (((((((0x3ff)) >> 16) >> 8)) >>
2))) ^ (((((((0x3ff)) >> 16) >> 8)) >> 2))
)) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff
)) >> 16) >> 8)))) - 1) & (((((((0x3ff)) >>
16) >> 8))))) ^ (((((((0x3ff)) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((0x3ff
)) >> 16))) - 1) & (((((0x3ff)) >> 16)))) ^ (
((((0x3ff)) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)((((((((((0x3ff)) >> 16)) >> 4)) - 1) & ((((
((0x3ff)) >> 16)) >> 4))) ^ ((((((0x3ff)) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
((((((((0x3ff)) >> 16)) >> 4) >> 2)) - 1) &
(((((((0x3ff)) >> 16)) >> 4) >> 2))) ^ (((
((((0x3ff)) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff)) >>
16)) >> 4))) - 1) & (((((((0x3ff)) >> 16)) >>
4)))) ^ (((((((0x3ff)) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0x3ff)) >>
16)))) - 1) & ((((((0x3ff)) >> 16))))) ^ ((((((0x3ff
)) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)(((
((((((((0x3ff)) >> 16))) >> 2)) - 1) & ((((((
(0x3ff)) >> 16))) >> 2))) ^ (((((((0x3ff)) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)(((((((((((0x3ff)) >> 16))))) - 1) & (((((((0x3ff)
) >> 16)))))) ^ (((((((0x3ff)) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)((((((((0x3ff)))) - 1) &
((((0x3ff))))) ^ ((((0x3ff)))))) >> (8)) != 0) ? 8 + (
(((u_long)(((((((((0x3ff))) >> 8)) - 1) & (((((0x3ff
))) >> 8))) ^ (((((0x3ff))) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)((((((((((0x3ff))) >> 8) >>
4)) - 1) & ((((((0x3ff))) >> 8) >> 4))) ^ ((
((((0x3ff))) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)(((((((((((0x3ff))) >> 8) >> 4) >>
2)) - 1) & (((((((0x3ff))) >> 8) >> 4) >>
2))) ^ (((((((0x3ff))) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff)
)) >> 8) >> 4))) - 1) & (((((((0x3ff))) >>
8) >> 4)))) ^ (((((((0x3ff))) >> 8) >> 4))
))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0x3ff
))) >> 8))) - 1) & ((((((0x3ff))) >> 8)))) ^ (
(((((0x3ff))) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0x3ff))) >> 8)) >> 2)) - 1) & (((
((((0x3ff))) >> 8)) >> 2))) ^ (((((((0x3ff))) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)(((((((((((0x3ff))) >> 8)))) - 1) & (((((((0x3ff))
) >> 8))))) ^ (((((((0x3ff))) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((0x3ff))))) - 1) &
(((((0x3ff)))))) ^ (((((0x3ff))))))) >> (4)) != 0) ? 4
+ ((((u_long)((((((((((0x3ff)))) >> 4)) - 1) & (((
(((0x3ff)))) >> 4))) ^ ((((((0x3ff)))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((0x3ff)))) >> 4)
>> 2)) - 1) & (((((((0x3ff)))) >> 4) >>
2))) ^ (((((((0x3ff)))) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff)))) >>
4))) - 1) & (((((((0x3ff)))) >> 4)))) ^ (((((((0x3ff
)))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)((((((((((0x3ff)))))) - 1) & ((((((0x3ff))))))) ^ ((((((
0x3ff)))))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((
(0x3ff))))) >> 2)) - 1) & (((((((0x3ff))))) >>
2))) ^ (((((((0x3ff))))) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)(((((((((((0x3ff))))))) - 1) & (((((
((0x3ff)))))))) ^ (((((((0x3ff))))))))) >> (1)) != 0) ?
1 : 0))))))))?(intval0):(((((0x3ff)) & ((0x3ff))) >>
((((u_long)(((((((0x3ff))) - 1) & (((0x3ff)))) ^ (((0x3ff
))))) >> (16)) != 0) ? 16 + ((((u_long)((((((((0x3ff)) >>
16)) - 1) & ((((0x3ff)) >> 16))) ^ ((((0x3ff)) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)(((((((((0x3ff))
>> 16) >> 8)) - 1) & (((((0x3ff)) >> 16
) >> 8))) ^ (((((0x3ff)) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)((((((((((0x3ff)) >> 16) >>
8) >> 4)) - 1) & ((((((0x3ff)) >> 16) >>
8) >> 4))) ^ ((((((0x3ff)) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0x3ff)
) >> 16) >> 8) >> 4) >> 2)) - 1) &
(((((((0x3ff)) >> 16) >> 8) >> 4) >>
2))) ^ (((((((0x3ff)) >> 16) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff
)) >> 16) >> 8) >> 4))) - 1) & (((((((0x3ff
)) >> 16) >> 8) >> 4)))) ^ (((((((0x3ff)) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)((((((((((0x3ff)) >> 16) >> 8))) -
1) & ((((((0x3ff)) >> 16) >> 8)))) ^ ((((((0x3ff
)) >> 16) >> 8))))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((0x3ff)) >> 16) >> 8)) >>
2)) - 1) & (((((((0x3ff)) >> 16) >> 8)) >>
2))) ^ (((((((0x3ff)) >> 16) >> 8)) >> 2))
)) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff
)) >> 16) >> 8)))) - 1) & (((((((0x3ff)) >>
16) >> 8))))) ^ (((((((0x3ff)) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((0x3ff
)) >> 16))) - 1) & (((((0x3ff)) >> 16)))) ^ (
((((0x3ff)) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)((((((((((0x3ff)) >> 16)) >> 4)) - 1) & ((((
((0x3ff)) >> 16)) >> 4))) ^ ((((((0x3ff)) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
((((((((0x3ff)) >> 16)) >> 4) >> 2)) - 1) &
(((((((0x3ff)) >> 16)) >> 4) >> 2))) ^ (((
((((0x3ff)) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff)) >>
16)) >> 4))) - 1) & (((((((0x3ff)) >> 16)) >>
4)))) ^ (((((((0x3ff)) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0x3ff)) >>
16)))) - 1) & ((((((0x3ff)) >> 16))))) ^ ((((((0x3ff
)) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)(((
((((((((0x3ff)) >> 16))) >> 2)) - 1) & ((((((
(0x3ff)) >> 16))) >> 2))) ^ (((((((0x3ff)) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)(((((((((((0x3ff)) >> 16))))) - 1) & (((((((0x3ff)
) >> 16)))))) ^ (((((((0x3ff)) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)((((((((0x3ff)))) - 1) &
((((0x3ff))))) ^ ((((0x3ff)))))) >> (8)) != 0) ? 8 + (
(((u_long)(((((((((0x3ff))) >> 8)) - 1) & (((((0x3ff
))) >> 8))) ^ (((((0x3ff))) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)((((((((((0x3ff))) >> 8) >>
4)) - 1) & ((((((0x3ff))) >> 8) >> 4))) ^ ((
((((0x3ff))) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)(((((((((((0x3ff))) >> 8) >> 4) >>
2)) - 1) & (((((((0x3ff))) >> 8) >> 4) >>
2))) ^ (((((((0x3ff))) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff)
)) >> 8) >> 4))) - 1) & (((((((0x3ff))) >>
8) >> 4)))) ^ (((((((0x3ff))) >> 8) >> 4))
))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0x3ff
))) >> 8))) - 1) & ((((((0x3ff))) >> 8)))) ^ (
(((((0x3ff))) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0x3ff))) >> 8)) >> 2)) - 1) & (((
((((0x3ff))) >> 8)) >> 2))) ^ (((((((0x3ff))) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)(((((((((((0x3ff))) >> 8)))) - 1) & (((((((0x3ff))
) >> 8))))) ^ (((((((0x3ff))) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((0x3ff))))) - 1) &
(((((0x3ff)))))) ^ (((((0x3ff))))))) >> (4)) != 0) ? 4
+ ((((u_long)((((((((((0x3ff)))) >> 4)) - 1) & (((
(((0x3ff)))) >> 4))) ^ ((((((0x3ff)))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((0x3ff)))) >> 4)
>> 2)) - 1) & (((((((0x3ff)))) >> 4) >>
2))) ^ (((((((0x3ff)))) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ff)))) >>
4))) - 1) & (((((((0x3ff)))) >> 4)))) ^ (((((((0x3ff
)))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)((((((((((0x3ff)))))) - 1) & ((((((0x3ff))))))) ^ ((((((
0x3ff)))))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((
(0x3ff))))) >> 2)) - 1) & (((((((0x3ff))))) >>
2))) ^ (((((((0x3ff))))) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)(((((((((((0x3ff))))))) - 1) & (((((
((0x3ff)))))))) ^ (((((((0x3ff))))))))) >> (1)) != 0) ?
1 : 0))))))))
;
3382
3383 bcnitv = RTW_READ16(regs, RTW_BCNITV)((*(regs)->r_read16)(regs, 0x70)) & ~RTW_BCNITV_BCNITV_MASK0x3ff;
3384 bcnitv |= LSHIFT(intval, RTW_BCNITV_BCNITV_MASK)((intval) << ((((u_long)((((((0x3ff)) - 1) & ((0x3ff
))) ^ ((0x3ff)))) >> (16)) != 0) ? 16 + ((((u_long)((((
(((0x3ff) >> 16)) - 1) & (((0x3ff) >> 16))) ^
(((0x3ff) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x3ff) >> 16) >> 8)) - 1) & ((((0x3ff
) >> 16) >> 8))) ^ ((((0x3ff) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3ff) >>
16) >> 8) >> 4)) - 1) & (((((0x3ff) >>
16) >> 8) >> 4))) ^ (((((0x3ff) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x3ff) >> 16) >> 8) >> 4) >> 2))
- 1) & ((((((0x3ff) >> 16) >> 8) >> 4)
>> 2))) ^ ((((((0x3ff) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3ff) >> 16) >> 8) >> 4))) - 1) &
((((((0x3ff) >> 16) >> 8) >> 4)))) ^ (((((
(0x3ff) >> 16) >> 8) >> 4))))) >> (1)
) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff) >> 16) >>
8))) - 1) & (((((0x3ff) >> 16) >> 8)))) ^ ((
(((0x3ff) >> 16) >> 8))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x3ff) >> 16) >> 8)) >>
2)) - 1) & ((((((0x3ff) >> 16) >> 8)) >>
2))) ^ ((((((0x3ff) >> 16) >> 8)) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff) >>
16) >> 8)))) - 1) & ((((((0x3ff) >> 16) >>
8))))) ^ ((((((0x3ff) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff) >> 16
))) - 1) & ((((0x3ff) >> 16)))) ^ ((((0x3ff) >>
16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3ff)
>> 16)) >> 4)) - 1) & (((((0x3ff) >> 16
)) >> 4))) ^ (((((0x3ff) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff) >> 16)) >>
4) >> 2)) - 1) & ((((((0x3ff) >> 16)) >>
4) >> 2))) ^ ((((((0x3ff) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff
) >> 16)) >> 4))) - 1) & ((((((0x3ff) >>
16)) >> 4)))) ^ ((((((0x3ff) >> 16)) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff
) >> 16)))) - 1) & (((((0x3ff) >> 16))))) ^ (
((((0x3ff) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3ff) >> 16))) >> 2)) - 1) & ((((
((0x3ff) >> 16))) >> 2))) ^ ((((((0x3ff) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x3ff) >> 16))))) - 1) & ((((((0x3ff) >>
16)))))) ^ ((((((0x3ff) >> 16))))))) >> (1)) != 0
) ? 1 : 0)))) : ((((u_long)(((((((0x3ff))) - 1) & (((0x3ff
)))) ^ (((0x3ff))))) >> (8)) != 0) ? 8 + ((((u_long)(((
(((((0x3ff)) >> 8)) - 1) & ((((0x3ff)) >> 8))
) ^ ((((0x3ff)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0x3ff)) >> 8) >> 4)) - 1) & (
((((0x3ff)) >> 8) >> 4))) ^ (((((0x3ff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x3ff)) >> 8) >> 4) >> 2)) - 1) & (
(((((0x3ff)) >> 8) >> 4) >> 2))) ^ ((((((0x3ff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3ff)) >> 8) >>
4))) - 1) & ((((((0x3ff)) >> 8) >> 4)))) ^ (
(((((0x3ff)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x3ff)) >> 8))) - 1) &
(((((0x3ff)) >> 8)))) ^ (((((0x3ff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff)) >> 8)) >>
2)) - 1) & ((((((0x3ff)) >> 8)) >> 2))) ^ ((
((((0x3ff)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3ff)) >> 8)))) - 1) &
((((((0x3ff)) >> 8))))) ^ ((((((0x3ff)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff)
))) - 1) & ((((0x3ff))))) ^ ((((0x3ff)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0x3ff))) >> 4)) - 1) &
(((((0x3ff))) >> 4))) ^ (((((0x3ff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff))) >> 4) >>
2)) - 1) & ((((((0x3ff))) >> 4) >> 2))) ^ ((
((((0x3ff))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3ff))) >> 4))) - 1) &
((((((0x3ff))) >> 4)))) ^ ((((((0x3ff))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff)
)))) - 1) & (((((0x3ff)))))) ^ (((((0x3ff))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff)))) >> 2))
- 1) & ((((((0x3ff)))) >> 2))) ^ ((((((0x3ff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff
)))))) - 1) & ((((((0x3ff))))))) ^ ((((((0x3ff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
3385 RTW_WRITE16(regs, RTW_BCNITV, bcnitv)((*(regs)->r_write16)(regs, 0x70, bcnitv));
3386 /* interrupt host 1ms before the TBTT */
3387 bintritv = RTW_READ16(regs, RTW_BINTRITV)((*(regs)->r_read16)(regs, 0x74)) & ~RTW_BINTRITV_BINTRITV0x3ff;
3388 bintritv |= LSHIFT(1000, RTW_BINTRITV_BINTRITV)((1000) << ((((u_long)((((((0x3ff)) - 1) & ((0x3ff)
)) ^ ((0x3ff)))) >> (16)) != 0) ? 16 + ((((u_long)(((((
((0x3ff) >> 16)) - 1) & (((0x3ff) >> 16))) ^ (
((0x3ff) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x3ff) >> 16) >> 8)) - 1) & ((((0x3ff
) >> 16) >> 8))) ^ ((((0x3ff) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3ff) >>
16) >> 8) >> 4)) - 1) & (((((0x3ff) >>
16) >> 8) >> 4))) ^ (((((0x3ff) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x3ff) >> 16) >> 8) >> 4) >> 2))
- 1) & ((((((0x3ff) >> 16) >> 8) >> 4)
>> 2))) ^ ((((((0x3ff) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3ff) >> 16) >> 8) >> 4))) - 1) &
((((((0x3ff) >> 16) >> 8) >> 4)))) ^ (((((
(0x3ff) >> 16) >> 8) >> 4))))) >> (1)
) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff) >> 16) >>
8))) - 1) & (((((0x3ff) >> 16) >> 8)))) ^ ((
(((0x3ff) >> 16) >> 8))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x3ff) >> 16) >> 8)) >>
2)) - 1) & ((((((0x3ff) >> 16) >> 8)) >>
2))) ^ ((((((0x3ff) >> 16) >> 8)) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff) >>
16) >> 8)))) - 1) & ((((((0x3ff) >> 16) >>
8))))) ^ ((((((0x3ff) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff) >> 16
))) - 1) & ((((0x3ff) >> 16)))) ^ ((((0x3ff) >>
16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3ff)
>> 16)) >> 4)) - 1) & (((((0x3ff) >> 16
)) >> 4))) ^ (((((0x3ff) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff) >> 16)) >>
4) >> 2)) - 1) & ((((((0x3ff) >> 16)) >>
4) >> 2))) ^ ((((((0x3ff) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff
) >> 16)) >> 4))) - 1) & ((((((0x3ff) >>
16)) >> 4)))) ^ ((((((0x3ff) >> 16)) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff
) >> 16)))) - 1) & (((((0x3ff) >> 16))))) ^ (
((((0x3ff) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3ff) >> 16))) >> 2)) - 1) & ((((
((0x3ff) >> 16))) >> 2))) ^ ((((((0x3ff) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x3ff) >> 16))))) - 1) & ((((((0x3ff) >>
16)))))) ^ ((((((0x3ff) >> 16))))))) >> (1)) != 0
) ? 1 : 0)))) : ((((u_long)(((((((0x3ff))) - 1) & (((0x3ff
)))) ^ (((0x3ff))))) >> (8)) != 0) ? 8 + ((((u_long)(((
(((((0x3ff)) >> 8)) - 1) & ((((0x3ff)) >> 8))
) ^ ((((0x3ff)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0x3ff)) >> 8) >> 4)) - 1) & (
((((0x3ff)) >> 8) >> 4))) ^ (((((0x3ff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x3ff)) >> 8) >> 4) >> 2)) - 1) & (
(((((0x3ff)) >> 8) >> 4) >> 2))) ^ ((((((0x3ff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3ff)) >> 8) >>
4))) - 1) & ((((((0x3ff)) >> 8) >> 4)))) ^ (
(((((0x3ff)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x3ff)) >> 8))) - 1) &
(((((0x3ff)) >> 8)))) ^ (((((0x3ff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff)) >> 8)) >>
2)) - 1) & ((((((0x3ff)) >> 8)) >> 2))) ^ ((
((((0x3ff)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3ff)) >> 8)))) - 1) &
((((((0x3ff)) >> 8))))) ^ ((((((0x3ff)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff)
))) - 1) & ((((0x3ff))))) ^ ((((0x3ff)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0x3ff))) >> 4)) - 1) &
(((((0x3ff))) >> 4))) ^ (((((0x3ff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff))) >> 4) >>
2)) - 1) & ((((((0x3ff))) >> 4) >> 2))) ^ ((
((((0x3ff))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3ff))) >> 4))) - 1) &
((((((0x3ff))) >> 4)))) ^ ((((((0x3ff))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff)
)))) - 1) & (((((0x3ff)))))) ^ (((((0x3ff))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff)))) >> 2))
- 1) & ((((((0x3ff)))) >> 2))) ^ ((((((0x3ff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff
)))))) - 1) & ((((((0x3ff))))))) ^ ((((((0x3ff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
3389 RTW_WRITE16(regs, RTW_BINTRITV, bintritv)((*(regs)->r_write16)(regs, 0x74, bintritv));
3390 /* magic from Linux */
3391 RTW_WRITE16(regs, RTW_ATIMWND, LSHIFT(1, RTW_ATIMWND_ATIMWND))((*(regs)->r_write16)(regs, 0x72, ((1) << ((((u_long
)((((((0x3ff)) - 1) & ((0x3ff))) ^ ((0x3ff)))) >> (
16)) != 0) ? 16 + ((((u_long)(((((((0x3ff) >> 16)) - 1)
& (((0x3ff) >> 16))) ^ (((0x3ff) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)((((((((0x3ff) >> 16) >>
8)) - 1) & ((((0x3ff) >> 16) >> 8))) ^ ((((0x3ff
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3ff) >> 16) >> 8) >> 4)) - 1) &
(((((0x3ff) >> 16) >> 8) >> 4))) ^ (((((0x3ff
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x3ff) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0x3ff) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0x3ff) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x3ff) >> 16) >> 8) >>
4))) - 1) & ((((((0x3ff) >> 16) >> 8) >>
4)))) ^ ((((((0x3ff) >> 16) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff) >>
16) >> 8))) - 1) & (((((0x3ff) >> 16) >>
8)))) ^ (((((0x3ff) >> 16) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3ff) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3ff) >> 16) >>
8)) >> 2))) ^ ((((((0x3ff) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff
) >> 16) >> 8)))) - 1) & ((((((0x3ff) >>
16) >> 8))))) ^ ((((((0x3ff) >> 16) >> 8))
)))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff
) >> 16))) - 1) & ((((0x3ff) >> 16)))) ^ ((((
0x3ff) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0x3ff) >> 16)) >> 4)) - 1) & (((((0x3ff
) >> 16)) >> 4))) ^ (((((0x3ff) >> 16)) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff) >>
16)) >> 4) >> 2)) - 1) & ((((((0x3ff) >>
16)) >> 4) >> 2))) ^ ((((((0x3ff) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3ff) >> 16)) >> 4))) - 1) & (((((
(0x3ff) >> 16)) >> 4)))) ^ ((((((0x3ff) >> 16
)) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x3ff) >> 16)))) - 1) & (((((0x3ff) >>
16))))) ^ (((((0x3ff) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x3ff) >> 16))) >> 2)) -
1) & ((((((0x3ff) >> 16))) >> 2))) ^ ((((((0x3ff
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x3ff) >> 16))))) - 1) & ((((
((0x3ff) >> 16)))))) ^ ((((((0x3ff) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x3ff))) - 1) &
(((0x3ff)))) ^ (((0x3ff))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x3ff)) >> 8)) - 1) & ((((0x3ff)) >>
8))) ^ ((((0x3ff)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0x3ff)) >> 8) >> 4)) - 1) &
(((((0x3ff)) >> 8) >> 4))) ^ (((((0x3ff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x3ff)) >> 8) >> 4) >> 2)) - 1) & (
(((((0x3ff)) >> 8) >> 4) >> 2))) ^ ((((((0x3ff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3ff)) >> 8) >>
4))) - 1) & ((((((0x3ff)) >> 8) >> 4)))) ^ (
(((((0x3ff)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x3ff)) >> 8))) - 1) &
(((((0x3ff)) >> 8)))) ^ (((((0x3ff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff)) >> 8)) >>
2)) - 1) & ((((((0x3ff)) >> 8)) >> 2))) ^ ((
((((0x3ff)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3ff)) >> 8)))) - 1) &
((((((0x3ff)) >> 8))))) ^ ((((((0x3ff)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff)
))) - 1) & ((((0x3ff))))) ^ ((((0x3ff)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0x3ff))) >> 4)) - 1) &
(((((0x3ff))) >> 4))) ^ (((((0x3ff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff))) >> 4) >>
2)) - 1) & ((((((0x3ff))) >> 4) >> 2))) ^ ((
((((0x3ff))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3ff))) >> 4))) - 1) &
((((((0x3ff))) >> 4)))) ^ ((((((0x3ff))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff)
)))) - 1) & (((((0x3ff)))))) ^ (((((0x3ff))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff)))) >> 2))
- 1) & ((((((0x3ff)))) >> 2))) ^ ((((((0x3ff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff
)))))) - 1) & ((((((0x3ff))))))) ^ ((((((0x3ff)))))))) >>
(1)) != 0) ? 1 : 0))))))))
;
3392 RTW_WRITE16(regs, RTW_ATIMTRITV, LSHIFT(2, RTW_ATIMTRITV_ATIMTRITV))((*(regs)->r_write16)(regs, 0x76, ((2) << ((((u_long
)((((((0x3ff)) - 1) & ((0x3ff))) ^ ((0x3ff)))) >> (
16)) != 0) ? 16 + ((((u_long)(((((((0x3ff) >> 16)) - 1)
& (((0x3ff) >> 16))) ^ (((0x3ff) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)((((((((0x3ff) >> 16) >>
8)) - 1) & ((((0x3ff) >> 16) >> 8))) ^ ((((0x3ff
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3ff) >> 16) >> 8) >> 4)) - 1) &
(((((0x3ff) >> 16) >> 8) >> 4))) ^ (((((0x3ff
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x3ff) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0x3ff) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0x3ff) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x3ff) >> 16) >> 8) >>
4))) - 1) & ((((((0x3ff) >> 16) >> 8) >>
4)))) ^ ((((((0x3ff) >> 16) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff) >>
16) >> 8))) - 1) & (((((0x3ff) >> 16) >>
8)))) ^ (((((0x3ff) >> 16) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x3ff) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3ff) >> 16) >>
8)) >> 2))) ^ ((((((0x3ff) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff
) >> 16) >> 8)))) - 1) & ((((((0x3ff) >>
16) >> 8))))) ^ ((((((0x3ff) >> 16) >> 8))
)))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff
) >> 16))) - 1) & ((((0x3ff) >> 16)))) ^ ((((
0x3ff) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0x3ff) >> 16)) >> 4)) - 1) & (((((0x3ff
) >> 16)) >> 4))) ^ (((((0x3ff) >> 16)) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff) >>
16)) >> 4) >> 2)) - 1) & ((((((0x3ff) >>
16)) >> 4) >> 2))) ^ ((((((0x3ff) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3ff) >> 16)) >> 4))) - 1) & (((((
(0x3ff) >> 16)) >> 4)))) ^ ((((((0x3ff) >> 16
)) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x3ff) >> 16)))) - 1) & (((((0x3ff) >>
16))))) ^ (((((0x3ff) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x3ff) >> 16))) >> 2)) -
1) & ((((((0x3ff) >> 16))) >> 2))) ^ ((((((0x3ff
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x3ff) >> 16))))) - 1) & ((((
((0x3ff) >> 16)))))) ^ ((((((0x3ff) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x3ff))) - 1) &
(((0x3ff)))) ^ (((0x3ff))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x3ff)) >> 8)) - 1) & ((((0x3ff)) >>
8))) ^ ((((0x3ff)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0x3ff)) >> 8) >> 4)) - 1) &
(((((0x3ff)) >> 8) >> 4))) ^ (((((0x3ff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x3ff)) >> 8) >> 4) >> 2)) - 1) & (
(((((0x3ff)) >> 8) >> 4) >> 2))) ^ ((((((0x3ff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3ff)) >> 8) >>
4))) - 1) & ((((((0x3ff)) >> 8) >> 4)))) ^ (
(((((0x3ff)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x3ff)) >> 8))) - 1) &
(((((0x3ff)) >> 8)))) ^ (((((0x3ff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff)) >> 8)) >>
2)) - 1) & ((((((0x3ff)) >> 8)) >> 2))) ^ ((
((((0x3ff)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3ff)) >> 8)))) - 1) &
((((((0x3ff)) >> 8))))) ^ ((((((0x3ff)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff)
))) - 1) & ((((0x3ff))))) ^ ((((0x3ff)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0x3ff))) >> 4)) - 1) &
(((((0x3ff))) >> 4))) ^ (((((0x3ff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff))) >> 4) >>
2)) - 1) & ((((((0x3ff))) >> 4) >> 2))) ^ ((
((((0x3ff))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3ff))) >> 4))) - 1) &
((((((0x3ff))) >> 4)))) ^ ((((((0x3ff))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff)
)))) - 1) & (((((0x3ff)))))) ^ (((((0x3ff))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff)))) >> 2))
- 1) & ((((((0x3ff)))) >> 2))) ^ ((((((0x3ff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff
)))))) - 1) & ((((((0x3ff))))))) ^ ((((((0x3ff)))))))) >>
(1)) != 0) ? 1 : 0))))))))
;
3393 rtw_set_access(regs, RTW_ACCESS_NONE);
3394
3395 /* TBD WEP */
3396 RTW_WRITE8(regs, RTW8180_SCR, 0)((*(regs)->r_write8)(regs, 0x5f, 0));
3397
3398 rtw_io_enable(regs, RTW_CR_RE(1<<3) | RTW_CR_TE(1<<2), 1);
3399}
3400
3401/* Synchronize the hardware state with the software state. */
3402int
3403rtw_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
3404{
3405 struct ifnet *ifp = &ic->ic_ific_ac.ac_if;
3406 struct rtw_softc *sc = ifp->if_softc;
3407 enum ieee80211_state ostate;
3408 int error;
3409
3410 ostate = ic->ic_state;
3411
3412 rtw_led_newstate(sc, nstate);
3413
3414 if (nstate == IEEE80211_S_INIT) {
3415 timeout_del(&sc->sc_scan_to);
3416 sc->sc_cur_chan = IEEE80211_CHAN_ANY0xffff;
3417 return (*sc->sc_mtbl.mt_newstate)(ic, nstate, arg);
3418 }
3419
3420 if (ostate == IEEE80211_S_INIT && nstate != IEEE80211_S_INIT)
3421 rtw_pwrstate(sc, RTW_ON);
3422
3423 if ((error = rtw_tune(sc)) != 0)
3424 return error;
3425
3426 switch (nstate) {
3427 case IEEE80211_S_INIT:
3428 panic("%s: unexpected state IEEE80211_S_INIT", __func__);
3429 break;
3430 case IEEE80211_S_SCAN:
3431 if (ostate != IEEE80211_S_SCAN) {
3432 bzero(ic->ic_bss->ni_bssid, IEEE80211_ADDR_LEN)__builtin_bzero((ic->ic_bss->ni_bssid), (6));
3433 rtw_set_nettype(sc, IEEE80211_M_MONITOR);
3434 }
3435
3436 timeout_add_msec(&sc->sc_scan_to, rtw_dwelltime);
3437
3438 break;
3439 case IEEE80211_S_RUN:
3440 switch (ic->ic_opmode) {
3441#ifndef IEEE80211_STA_ONLY
3442 case IEEE80211_M_HOSTAP:
3443 case IEEE80211_M_IBSS:
3444 rtw_set_nettype(sc, IEEE80211_M_MONITOR);
3445 /*FALLTHROUGH*/
3446 case IEEE80211_M_AHDEMO:
3447#endif
3448 case IEEE80211_M_STA:
3449 rtw_join_bss(sc, ic->ic_bss->ni_bssid,
3450 ic->ic_bss->ni_intval);
3451 break;
3452 default:
3453 break;
3454 }
3455 rtw_set_nettype(sc, ic->ic_opmode);
3456 break;
3457 case IEEE80211_S_ASSOC:
3458 case IEEE80211_S_AUTH:
3459 break;
3460 }
3461
3462 if (nstate != IEEE80211_S_SCAN)
3463 timeout_del(&sc->sc_scan_to);
3464
3465 return (*sc->sc_mtbl.mt_newstate)(ic, nstate, arg);
3466}
3467
3468/* Extend a 32-bit TSF timestamp to a 64-bit timestamp. */
3469uint64_t
3470rtw_tsf_extend(struct rtw_regs *regs, u_int32_t rstamp)
3471{
3472 u_int32_t tsftl, tsfth;
3473
3474 tsfth = RTW_READ(regs, RTW_TSFTRH)((*(regs)->r_read32)(regs, 0x1c));
3475 tsftl = RTW_READ(regs, RTW_TSFTRL)((*(regs)->r_read32)(regs, 0x18));
3476 if (tsftl < rstamp) /* Compensate for rollover. */
3477 tsfth--;
3478 return ((u_int64_t)tsfth << 32) | rstamp;
3479}
3480
3481#ifndef IEEE80211_STA_ONLY
3482void
3483rtw_ibss_merge(struct rtw_softc *sc, struct ieee80211_node *ni,
3484 u_int32_t rstamp)
3485{
3486 u_int8_t tppoll;
3487 struct ieee80211com *ic = &sc->sc_ic;
3488
3489 if (ieee80211_ibss_merge(ic, ni,
3490 rtw_tsf_extend(&sc->sc_regs, rstamp)) == ENETRESET52) {
3491 /* Stop beacon queue. Kick state machine to synchronize
3492 * with the new IBSS.
3493 */
3494 tppoll = RTW_READ8(&sc->sc_regs, RTW_TPPOLL)((*(&sc->sc_regs)->r_read8)(&sc->sc_regs, 0xd9
))
;
3495 tppoll |= RTW_TPPOLL_SBQ(1<<3);
3496 RTW_WRITE8(&sc->sc_regs, RTW_TPPOLL, tppoll)((*(&sc->sc_regs)->r_write8)(&sc->sc_regs, 0xd9
, tppoll))
;
3497 (void)ieee80211_new_state(&sc->sc_ic, IEEE80211_S_RUN, -1)(((&sc->sc_ic)->ic_newstate)((&sc->sc_ic), (
IEEE80211_S_RUN), (-1)))
;
3498 }
3499 return;
3500}
3501
3502void
3503rtw_recv_mgmt(struct ieee80211com *ic, struct mbuf *m,
3504 struct ieee80211_node *ni, struct ieee80211_rxinfo *rxi, int subtype)
3505{
3506 struct rtw_softc *sc = (struct rtw_softc*)ic->ic_softcic_ac.ac_if.if_softc;
3507
3508 (*sc->sc_mtbl.mt_recv_mgmt)(ic, m, ni, rxi, subtype);
3509
3510 switch (subtype) {
3511 case IEEE80211_FC0_SUBTYPE_PROBE_RESP0x50:
3512 case IEEE80211_FC0_SUBTYPE_BEACON0x80:
3513 if (ic->ic_opmode != IEEE80211_M_IBSS ||
3514 ic->ic_state != IEEE80211_S_RUN)
3515 return;
3516 rtw_ibss_merge(sc, ni, rxi->rxi_tstamp);
3517 break;
3518 default:
3519 break;
3520 }
3521 return;
3522}
3523#endif /* IEEE80211_STA_ONLY */
3524
3525struct ieee80211_node *
3526rtw_node_alloc(struct ieee80211com *ic)
3527{
3528 struct rtw_softc *sc = (struct rtw_softc *)ic->ic_ific_ac.ac_if.if_softc;
3529 struct ieee80211_node *ni = (*sc->sc_mtbl.mt_node_alloc)(ic);
3530
3531 DPRINTF(sc, RTW_DEBUG_NODE,
3532 ("%s: alloc node %p\n", sc->sc_dev.dv_xname, ni));
3533 return ni;
3534}
3535
3536void
3537rtw_node_free(struct ieee80211com *ic, struct ieee80211_node *ni)
3538{
3539 struct rtw_softc *sc = (struct rtw_softc *)ic->ic_ific_ac.ac_if.if_softc;
3540
3541 DPRINTF(sc, RTW_DEBUG_NODE,
3542 ("%s: freeing node %p %s\n", sc->sc_dev.dv_xname, ni,
3543 ether_sprintf(ni->ni_bssid)));
3544 (*sc->sc_mtbl.mt_node_free)(ic, ni);
3545}
3546
3547int
3548rtw_media_change(struct ifnet *ifp)
3549{
3550 int error;
3551
3552 error = ieee80211_media_change(ifp);
3553 if (error == ENETRESET52) {
3554 if ((ifp->if_flags & (IFF_RUNNING0x40|IFF_UP0x1)) ==
3555 (IFF_RUNNING0x40|IFF_UP0x1))
3556 rtw_init(ifp); /* XXX lose error */
3557 error = 0;
3558 }
3559 return error;
3560}
3561
3562void
3563rtw_media_status(struct ifnet *ifp, struct ifmediareq *imr)
3564{
3565 struct rtw_softc *sc = ifp->if_softc;
3566
3567 if ((sc->sc_flags & RTW_F_ENABLED0x00000001) == 0) {
3568 imr->ifm_active = IFM_IEEE802110x0000000000000400ULL | IFM_NONE2ULL;
3569 imr->ifm_status = 0;
3570 return;
3571 }
3572 ieee80211_media_status(ifp, imr);
3573}
3574
3575int
3576rtw_activate(struct device *self, int act)
3577{
3578 struct rtw_softc *sc = (struct rtw_softc *)self;
3579 struct ifnet *ifp = &sc->sc_ic.ic_ific_ac.ac_if;
3580
3581 switch (act) {
3582 case DVACT_SUSPEND3:
3583 if (ifp->if_flags & IFF_RUNNING0x40) {
3584 rtw_stop(ifp, 1);
3585 if (sc->sc_power != NULL((void *)0))
3586 (*sc->sc_power)(sc, act);
3587 }
3588 break;
3589 case DVACT_RESUME4:
3590 if (ifp->if_flags & IFF_UP0x1) {
3591 if (sc->sc_power != NULL((void *)0))
3592 (*sc->sc_power)(sc, act);
3593 rtw_init(ifp);
3594 }
3595 break;
3596 }
3597 return 0;
3598}
3599
3600int
3601rtw_txsoft_blk_setup(struct rtw_txsoft_blk *tsb, u_int qlen)
3602{
3603 SIMPLEQ_INIT(&tsb->tsb_dirtyq)do { (&tsb->tsb_dirtyq)->sqh_first = ((void *)0); (
&tsb->tsb_dirtyq)->sqh_last = &(&tsb->tsb_dirtyq
)->sqh_first; } while (0)
;
3604 SIMPLEQ_INIT(&tsb->tsb_freeq)do { (&tsb->tsb_freeq)->sqh_first = ((void *)0); (&
tsb->tsb_freeq)->sqh_last = &(&tsb->tsb_freeq
)->sqh_first; } while (0)
;
3605 tsb->tsb_ndesc = qlen;
3606 tsb->tsb_desc = mallocarray(qlen, sizeof(*tsb->tsb_desc), M_DEVBUF2,
3607 M_NOWAIT0x0002);
3608 if (tsb->tsb_desc == NULL((void *)0))
3609 return ENOMEM12;
3610 return 0;
3611}
3612
3613void
3614rtw_txsoft_blk_cleanup_all(struct rtw_softc *sc)
3615{
3616 int pri;
3617 struct rtw_txsoft_blk *tsb;
3618
3619 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
3620 tsb = &sc->sc_txsoft_blk[pri];
3621 free(tsb->tsb_desc, M_DEVBUF2, 0);
3622 tsb->tsb_desc = NULL((void *)0);
3623 }
3624}
3625
3626int
3627rtw_txsoft_blk_setup_all(struct rtw_softc *sc)
3628{
3629 int pri, rc = 0;
3630 int qlen[RTW_NTXPRI4] =
3631 {RTW_TXQLENLO64, RTW_TXQLENMD64, RTW_TXQLENHI64, RTW_TXQLENBCN8};
3632 struct rtw_txsoft_blk *tsbs;
3633
3634 tsbs = sc->sc_txsoft_blk;
3635
3636 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
3637 rc = rtw_txsoft_blk_setup(&tsbs[pri], qlen[pri]);
3638 if (rc != 0)
3639 break;
3640 }
3641 tsbs[RTW_TXPRILO0].tsb_poll = RTW_TPPOLL_LPQ(1<<4) | RTW_TPPOLL_SLPQ(1<<0);
3642 tsbs[RTW_TXPRIMD1].tsb_poll = RTW_TPPOLL_NPQ(1<<5) | RTW_TPPOLL_SNPQ(1<<1);
3643 tsbs[RTW_TXPRIHI2].tsb_poll = RTW_TPPOLL_HPQ(1<<6) | RTW_TPPOLL_SHPQ(1<<2);
3644 tsbs[RTW_TXPRIBCN3].tsb_poll = RTW_TPPOLL_BQ(1<<7) | RTW_TPPOLL_SBQ(1<<3);
3645 return rc;
3646}
3647
3648void
3649rtw_txdesc_blk_setup(struct rtw_txdesc_blk *tdb, struct rtw_txdesc *desc,
3650 u_int ndesc, bus_addr_t ofs, bus_addr_t physbase)
3651{
3652 tdb->tdb_ndesc = ndesc;
3653 tdb->tdb_desc = desc;
3654 tdb->tdb_physbase = physbase;
3655 tdb->tdb_ofs = ofs;
3656
3657 bzero(tdb->tdb_desc, sizeof(tdb->tdb_desc[0]) * tdb->tdb_ndesc)__builtin_bzero((tdb->tdb_desc), (sizeof(tdb->tdb_desc[
0]) * tdb->tdb_ndesc))
;
3658
3659 rtw_txdesc_blk_init(tdb);
3660 tdb->tdb_next = 0;
3661}
3662
3663void
3664rtw_txdesc_blk_setup_all(struct rtw_softc *sc)
3665{
3666 rtw_txdesc_blk_setup(&sc->sc_txdesc_blk[RTW_TXPRILO0],
3667 &sc->sc_descs->hd_txlo[0], RTW_NTXDESCLO64,
3668 RTW_RING_OFFSET(hd_txlo)__builtin_offsetof(struct rtw_descs, hd_txlo[0]), RTW_RING_BASE(sc, hd_txlo)((sc)->sc_desc_dmamap->dm_segs[0].ds_addr + __builtin_offsetof
(struct rtw_descs, hd_txlo[0]))
);
3669
3670 rtw_txdesc_blk_setup(&sc->sc_txdesc_blk[RTW_TXPRIMD1],
3671 &sc->sc_descs->hd_txmd[0], RTW_NTXDESCMD64,
3672 RTW_RING_OFFSET(hd_txmd)__builtin_offsetof(struct rtw_descs, hd_txmd[0]), RTW_RING_BASE(sc, hd_txmd)((sc)->sc_desc_dmamap->dm_segs[0].ds_addr + __builtin_offsetof
(struct rtw_descs, hd_txmd[0]))
);
3673
3674 rtw_txdesc_blk_setup(&sc->sc_txdesc_blk[RTW_TXPRIHI2],
3675 &sc->sc_descs->hd_txhi[0], RTW_NTXDESCHI64,
3676 RTW_RING_OFFSET(hd_txhi)__builtin_offsetof(struct rtw_descs, hd_txhi[0]), RTW_RING_BASE(sc, hd_txhi)((sc)->sc_desc_dmamap->dm_segs[0].ds_addr + __builtin_offsetof
(struct rtw_descs, hd_txhi[0]))
);
3677
3678 rtw_txdesc_blk_setup(&sc->sc_txdesc_blk[RTW_TXPRIBCN3],
3679 &sc->sc_descs->hd_bcn[0], RTW_NTXDESCBCN8,
3680 RTW_RING_OFFSET(hd_bcn)__builtin_offsetof(struct rtw_descs, hd_bcn[0]), RTW_RING_BASE(sc, hd_bcn)((sc)->sc_desc_dmamap->dm_segs[0].ds_addr + __builtin_offsetof
(struct rtw_descs, hd_bcn[0]))
);
3681}
3682
3683int
3684rtw_rf_attach(struct rtw_softc *sc, int rfchipid)
3685{
3686 struct rtw_bbpset *bb = &sc->sc_bbpset;
3687 int notsup = 0;
3688 const char *rfname, *paname = NULL((void *)0);
3689 char scratch[sizeof("unknown 0xXX")];
3690
3691 switch (rfchipid) {
3692 case RTW_RFCHIPID_RTL82250x09:
3693 rfname = "RTL8225";
3694 sc->sc_pwrstate_cb = rtw_rtl_pwrstate;
3695 sc->sc_rf_init = rtw_rtl8255_init;
3696 sc->sc_rf_pwrstate = rtw_rtl8225_pwrstate;
3697 sc->sc_rf_tune = rtw_rtl8225_tune;
3698 sc->sc_rf_txpower = rtw_rtl8225_txpower;
3699 break;
3700 case RTW_RFCHIPID_RTL82550x0a:
3701 rfname = "RTL8255";
3702 sc->sc_pwrstate_cb = rtw_rtl_pwrstate;
3703 sc->sc_rf_init = rtw_rtl8255_init;
3704 sc->sc_rf_pwrstate = rtw_rtl8255_pwrstate;
3705 sc->sc_rf_tune = rtw_rtl8255_tune;
3706 sc->sc_rf_txpower = rtw_rtl8255_txpower;
3707 break;
3708 case RTW_RFCHIPID_MAXIM28200x04:
3709 rfname = "MAX2820"; /* guess */
3710 paname = "MAX2422"; /* guess */
3711 /* XXX magic */
3712 bb->bb_antatten = RTW_BBP_ANTATTEN_MAXIM_MAGIC0xb3;
3713 bb->bb_chestlim = 0x00;
3714 bb->bb_chsqlim = 0x9f;
3715 bb->bb_ifagcdet = 0x64;
3716 bb->bb_ifagcini = 0x90;
3717 bb->bb_ifagclimit = 0x1a;
3718 bb->bb_lnadet = 0xf8;
3719 bb->bb_sys1 = 0x88;
3720 bb->bb_sys2 = 0x47;
3721 bb->bb_sys3 = 0x9b;
3722 bb->bb_trl = 0x88;
3723 bb->bb_txagc = 0x08;
3724 sc->sc_pwrstate_cb = rtw_maxim_pwrstate;
3725 sc->sc_rf_init = rtw_max2820_init;
3726 sc->sc_rf_pwrstate = rtw_max2820_pwrstate;
3727 sc->sc_rf_tune = rtw_max2820_tune;
3728 sc->sc_rf_txpower = rtw_max2820_txpower;
3729 break;
3730 case RTW_RFCHIPID_PHILIPS0x03:
3731 rfname = "SA2400A";
3732 paname = "SA2411";
3733 /* XXX magic */
3734 bb->bb_antatten = RTW_BBP_ANTATTEN_PHILIPS_MAGIC0x91;
3735 bb->bb_chestlim = 0x00;
3736 bb->bb_chsqlim = 0xa0;
3737 bb->bb_ifagcdet = 0x64;
3738 bb->bb_ifagcini = 0x90;
3739 bb->bb_ifagclimit = 0x1a;
3740 bb->bb_lnadet = 0xe0;
3741 bb->bb_sys1 = 0x98;
3742 bb->bb_sys2 = 0x47;
3743 bb->bb_sys3 = 0x90;
3744 bb->bb_trl = 0x88;
3745 bb->bb_txagc = 0x38;
3746 sc->sc_pwrstate_cb = rtw_philips_pwrstate;
3747 sc->sc_rf_init = rtw_sa2400_init;
3748 sc->sc_rf_pwrstate = rtw_sa2400_pwrstate;
3749 sc->sc_rf_tune = rtw_sa2400_tune;
3750 sc->sc_rf_txpower = rtw_sa2400_txpower;
3751 break;
3752 case RTW_RFCHIPID_RFMD29480x02:
3753 /* this is the same front-end as an atw(4)! */
3754 rfname = "RFMD RF2948B, " /* mentioned in Realtek docs */
3755 "LNA: RFMD RF2494, " /* mentioned in Realtek docs */
3756 "SYN: Silicon Labs Si4126"; /* inferred from
3757 * reference driver
3758 */
3759 paname = "RF2189"; /* mentioned in Realtek docs */
3760 /* XXX RFMD has no RF constructor */
3761 sc->sc_pwrstate_cb = rtw_rfmd_pwrstate;
3762 notsup = 1;
3763 break;
3764 case RTW_RFCHIPID_GCT0x05: /* this combo seen in the wild */
3765 rfname = "GRF5101";
3766 paname = "WS9901";
3767 /* XXX magic */
3768 bb->bb_antatten = RTW_BBP_ANTATTEN_GCT_MAGIC0xa3;
3769 bb->bb_chestlim = 0x00;
3770 bb->bb_chsqlim = 0xa0;
3771 bb->bb_ifagcdet = 0x64;
3772 bb->bb_ifagcini = 0x90;
3773 bb->bb_ifagclimit = 0x1e;
3774 bb->bb_lnadet = 0xc0;
3775 bb->bb_sys1 = 0xa8;
3776 bb->bb_sys2 = 0x47;
3777 bb->bb_sys3 = 0x9b;
3778 bb->bb_trl = 0x88;
3779 bb->bb_txagc = 0x08;
3780 sc->sc_pwrstate_cb = rtw_maxim_pwrstate;
3781 sc->sc_rf_init = rtw_grf5101_init;
3782 sc->sc_rf_pwrstate = rtw_grf5101_pwrstate;
3783 sc->sc_rf_tune = rtw_grf5101_tune;
3784 sc->sc_rf_txpower = rtw_grf5101_txpower;
3785 break;
3786 case RTW_RFCHIPID_INTERSIL0x01:
3787 rfname = "HFA3873"; /* guess */
3788 paname = "Intersil <unknown>";
3789 notsup = 1;
3790 break;
3791 default:
3792 snprintf(scratch, sizeof(scratch), "unknown 0x%02x", rfchipid);
3793 rfname = scratch;
3794 notsup = 1;
3795 }
3796
3797 printf("radio %s, ", rfname);
3798 if (paname != NULL((void *)0))
3799 printf("amp %s, ", paname);
3800
3801 return (notsup);
3802}
3803
3804/* Revision C and later use a different PHY delay setting than
3805 * revisions A and B.
3806 */
3807u_int8_t
3808rtw_check_phydelay(struct rtw_regs *regs, u_int32_t rcr0)
3809{
3810#define REVAB(((7) << ((((u_long)((((((0x700)) - 1) & ((0x700)))
^ ((0x700)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((
0x700) >> 16)) - 1) & (((0x700) >> 16))) ^ ((
(0x700) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long)
((((((((0x700) >> 16) >> 8)) - 1) & ((((0x700
) >> 16) >> 8))) ^ ((((0x700) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x700) >>
16) >> 8) >> 4)) - 1) & (((((0x700) >>
16) >> 8) >> 4))) ^ (((((0x700) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x700) >> 16) >> 8) >> 4) >> 2))
- 1) & ((((((0x700) >> 16) >> 8) >> 4)
>> 2))) ^ ((((((0x700) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x700) >> 16) >> 8) >> 4))) - 1) &
((((((0x700) >> 16) >> 8) >> 4)))) ^ (((((
(0x700) >> 16) >> 8) >> 4))))) >> (1)
) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x700) >> 16) >>
8))) - 1) & (((((0x700) >> 16) >> 8)))) ^ ((
(((0x700) >> 16) >> 8))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x700) >> 16) >> 8)) >>
2)) - 1) & ((((((0x700) >> 16) >> 8)) >>
2))) ^ ((((((0x700) >> 16) >> 8)) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700) >>
16) >> 8)))) - 1) & ((((((0x700) >> 16) >>
8))))) ^ ((((((0x700) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x700) >> 16
))) - 1) & ((((0x700) >> 16)))) ^ ((((0x700) >>
16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x700)
>> 16)) >> 4)) - 1) & (((((0x700) >> 16
)) >> 4))) ^ (((((0x700) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x700) >> 16)) >>
4) >> 2)) - 1) & ((((((0x700) >> 16)) >>
4) >> 2))) ^ ((((((0x700) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700
) >> 16)) >> 4))) - 1) & ((((((0x700) >>
16)) >> 4)))) ^ ((((((0x700) >> 16)) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x700
) >> 16)))) - 1) & (((((0x700) >> 16))))) ^ (
((((0x700) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x700) >> 16))) >> 2)) - 1) & ((((
((0x700) >> 16))) >> 2))) ^ ((((((0x700) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x700) >> 16))))) - 1) & ((((((0x700) >>
16)))))) ^ ((((((0x700) >> 16))))))) >> (1)) != 0
) ? 1 : 0)))) : ((((u_long)(((((((0x700))) - 1) & (((0x700
)))) ^ (((0x700))))) >> (8)) != 0) ? 8 + ((((u_long)(((
(((((0x700)) >> 8)) - 1) & ((((0x700)) >> 8))
) ^ ((((0x700)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0x700)) >> 8) >> 4)) - 1) & (
((((0x700)) >> 8) >> 4))) ^ (((((0x700)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x700)) >> 8) >> 4) >> 2)) - 1) & (
(((((0x700)) >> 8) >> 4) >> 2))) ^ ((((((0x700
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x700)) >> 8) >>
4))) - 1) & ((((((0x700)) >> 8) >> 4)))) ^ (
(((((0x700)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x700)) >> 8))) - 1) &
(((((0x700)) >> 8)))) ^ (((((0x700)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x700)) >> 8)) >>
2)) - 1) & ((((((0x700)) >> 8)) >> 2))) ^ ((
((((0x700)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x700)) >> 8)))) - 1) &
((((((0x700)) >> 8))))) ^ ((((((0x700)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x700)
))) - 1) & ((((0x700))))) ^ ((((0x700)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0x700))) >> 4)) - 1) &
(((((0x700))) >> 4))) ^ (((((0x700))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x700))) >> 4) >>
2)) - 1) & ((((((0x700))) >> 4) >> 2))) ^ ((
((((0x700))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x700))) >> 4))) - 1) &
((((((0x700))) >> 4)))) ^ ((((((0x700))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x700)
)))) - 1) & (((((0x700)))))) ^ (((((0x700))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x700)))) >> 2))
- 1) & ((((((0x700)))) >> 2))) ^ ((((((0x700)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700
)))))) - 1) & ((((((0x700))))))) ^ ((((((0x700)))))))) >>
(1)) != 0) ? 1 : 0)))))) | (1<<12))
(RTW_RCR_MXDMA_UNLIMITED((7) << ((((u_long)((((((0x700)) - 1) & ((0x700))) ^
((0x700)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x700
) >> 16)) - 1) & (((0x700) >> 16))) ^ (((0x700
) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((
((0x700) >> 16) >> 8)) - 1) & ((((0x700) >>
16) >> 8))) ^ ((((0x700) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x700) >> 16) >>
8) >> 4)) - 1) & (((((0x700) >> 16) >>
8) >> 4))) ^ (((((0x700) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x700) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0x700
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x700) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700) >> 16
) >> 8) >> 4))) - 1) & ((((((0x700) >> 16
) >> 8) >> 4)))) ^ ((((((0x700) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x700) >> 16) >> 8))) - 1) & (((((0x700
) >> 16) >> 8)))) ^ (((((0x700) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x700)
>> 16) >> 8)) >> 2)) - 1) & ((((((0x700
) >> 16) >> 8)) >> 2))) ^ ((((((0x700) >>
16) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)((((((((((0x700) >> 16) >> 8)))) - 1
) & ((((((0x700) >> 16) >> 8))))) ^ ((((((0x700
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x700) >> 16))) - 1) & ((((0x700
) >> 16)))) ^ ((((0x700) >> 16))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0x700) >> 16)) >>
4)) - 1) & (((((0x700) >> 16)) >> 4))) ^ (((
((0x700) >> 16)) >> 4)))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x700) >> 16)) >> 4) >>
2)) - 1) & ((((((0x700) >> 16)) >> 4) >>
2))) ^ ((((((0x700) >> 16)) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700) >>
16)) >> 4))) - 1) & ((((((0x700) >> 16)) >>
4)))) ^ ((((((0x700) >> 16)) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x700) >> 16)
))) - 1) & (((((0x700) >> 16))))) ^ (((((0x700) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x700
) >> 16))) >> 2)) - 1) & ((((((0x700) >>
16))) >> 2))) ^ ((((((0x700) >> 16))) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700
) >> 16))))) - 1) & ((((((0x700) >> 16)))))) ^
((((((0x700) >> 16))))))) >> (1)) != 0) ? 1 : 0)
))) : ((((u_long)(((((((0x700))) - 1) & (((0x700)))) ^ ((
(0x700))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x700
)) >> 8)) - 1) & ((((0x700)) >> 8))) ^ ((((0x700
)) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((((
(((0x700)) >> 8) >> 4)) - 1) & (((((0x700)) >>
8) >> 4))) ^ (((((0x700)) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x700)) >> 8) >>
4) >> 2)) - 1) & ((((((0x700)) >> 8) >>
4) >> 2))) ^ ((((((0x700)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700
)) >> 8) >> 4))) - 1) & ((((((0x700)) >>
8) >> 4)))) ^ ((((((0x700)) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x700))
>> 8))) - 1) & (((((0x700)) >> 8)))) ^ (((((
0x700)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)
((((((((((0x700)) >> 8)) >> 2)) - 1) & ((((((
0x700)) >> 8)) >> 2))) ^ ((((((0x700)) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x700)) >> 8)))) - 1) & ((((((0x700)) >>
8))))) ^ ((((((0x700)) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0x700)))) - 1) & ((((0x700
))))) ^ ((((0x700)))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0x700))) >> 4)) - 1) & (((((0x700))) >>
4))) ^ (((((0x700))) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)((((((((((0x700))) >> 4) >> 2)) - 1) &
((((((0x700))) >> 4) >> 2))) ^ ((((((0x700))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x700))) >> 4))) - 1) & ((((((0x700))) >>
4)))) ^ ((((((0x700))) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x700))))) - 1) & (((((0x700
)))))) ^ (((((0x700))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x700)))) >> 2)) - 1) & ((((((0x700)))) >>
2))) ^ ((((((0x700)))) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x700)))))) - 1) & ((((((0x700
))))))) ^ ((((((0x700)))))))) >> (1)) != 0) ? 1 : 0))))
))
| RTW_RCR_AICV(1<<12))
3811#define REVC (REVAB(((7) << ((((u_long)((((((0x700)) - 1) & ((0x700)))
^ ((0x700)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((
0x700) >> 16)) - 1) & (((0x700) >> 16))) ^ ((
(0x700) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long)
((((((((0x700) >> 16) >> 8)) - 1) & ((((0x700
) >> 16) >> 8))) ^ ((((0x700) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x700) >>
16) >> 8) >> 4)) - 1) & (((((0x700) >>
16) >> 8) >> 4))) ^ (((((0x700) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x700) >> 16) >> 8) >> 4) >> 2))
- 1) & ((((((0x700) >> 16) >> 8) >> 4)
>> 2))) ^ ((((((0x700) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x700) >> 16) >> 8) >> 4))) - 1) &
((((((0x700) >> 16) >> 8) >> 4)))) ^ (((((
(0x700) >> 16) >> 8) >> 4))))) >> (1)
) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x700) >> 16) >>
8))) - 1) & (((((0x700) >> 16) >> 8)))) ^ ((
(((0x700) >> 16) >> 8))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x700) >> 16) >> 8)) >>
2)) - 1) & ((((((0x700) >> 16) >> 8)) >>
2))) ^ ((((((0x700) >> 16) >> 8)) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700) >>
16) >> 8)))) - 1) & ((((((0x700) >> 16) >>
8))))) ^ ((((((0x700) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x700) >> 16
))) - 1) & ((((0x700) >> 16)))) ^ ((((0x700) >>
16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x700)
>> 16)) >> 4)) - 1) & (((((0x700) >> 16
)) >> 4))) ^ (((((0x700) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x700) >> 16)) >>
4) >> 2)) - 1) & ((((((0x700) >> 16)) >>
4) >> 2))) ^ ((((((0x700) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700
) >> 16)) >> 4))) - 1) & ((((((0x700) >>
16)) >> 4)))) ^ ((((((0x700) >> 16)) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x700
) >> 16)))) - 1) & (((((0x700) >> 16))))) ^ (
((((0x700) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x700) >> 16))) >> 2)) - 1) & ((((
((0x700) >> 16))) >> 2))) ^ ((((((0x700) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x700) >> 16))))) - 1) & ((((((0x700) >>
16)))))) ^ ((((((0x700) >> 16))))))) >> (1)) != 0
) ? 1 : 0)))) : ((((u_long)(((((((0x700))) - 1) & (((0x700
)))) ^ (((0x700))))) >> (8)) != 0) ? 8 + ((((u_long)(((
(((((0x700)) >> 8)) - 1) & ((((0x700)) >> 8))
) ^ ((((0x700)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0x700)) >> 8) >> 4)) - 1) & (
((((0x700)) >> 8) >> 4))) ^ (((((0x700)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x700)) >> 8) >> 4) >> 2)) - 1) & (
(((((0x700)) >> 8) >> 4) >> 2))) ^ ((((((0x700
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x700)) >> 8) >>
4))) - 1) & ((((((0x700)) >> 8) >> 4)))) ^ (
(((((0x700)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x700)) >> 8))) - 1) &
(((((0x700)) >> 8)))) ^ (((((0x700)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x700)) >> 8)) >>
2)) - 1) & ((((((0x700)) >> 8)) >> 2))) ^ ((
((((0x700)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x700)) >> 8)))) - 1) &
((((((0x700)) >> 8))))) ^ ((((((0x700)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x700)
))) - 1) & ((((0x700))))) ^ ((((0x700)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0x700))) >> 4)) - 1) &
(((((0x700))) >> 4))) ^ (((((0x700))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x700))) >> 4) >>
2)) - 1) & ((((((0x700))) >> 4) >> 2))) ^ ((
((((0x700))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x700))) >> 4))) - 1) &
((((((0x700))) >> 4)))) ^ ((((((0x700))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x700)
)))) - 1) & (((((0x700)))))) ^ (((((0x700))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x700)))) >> 2))
- 1) & ((((((0x700)))) >> 2))) ^ ((((((0x700)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700
)))))) - 1) & ((((((0x700))))))) ^ ((((((0x700)))))))) >>
(1)) != 0) ? 1 : 0)))))) | (1<<12))
| RTW8180_RCR_RXFTH_WHOLE((7) << ((((u_long)((((((0xe000)) - 1) & ((0xe000))
) ^ ((0xe000)))) >> (16)) != 0) ? 16 + ((((u_long)(((((
((0xe000) >> 16)) - 1) & (((0xe000) >> 16))) ^
(((0xe000) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xe000) >> 16) >> 8)) - 1) & ((((0xe000
) >> 16) >> 8))) ^ ((((0xe000) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xe000) >>
16) >> 8) >> 4)) - 1) & (((((0xe000) >>
16) >> 8) >> 4))) ^ (((((0xe000) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xe000) >> 16) >> 8) >> 4) >> 2)
) - 1) & ((((((0xe000) >> 16) >> 8) >> 4
) >> 2))) ^ ((((((0xe000) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xe000) >> 16) >> 8) >> 4))) - 1)
& ((((((0xe000) >> 16) >> 8) >> 4)))) ^
((((((0xe000) >> 16) >> 8) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe000) >> 16
) >> 8))) - 1) & (((((0xe000) >> 16) >>
8)))) ^ (((((0xe000) >> 16) >> 8))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0xe000) >> 16) >>
8)) >> 2)) - 1) & ((((((0xe000) >> 16) >>
8)) >> 2))) ^ ((((((0xe000) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000
) >> 16) >> 8)))) - 1) & ((((((0xe000) >>
16) >> 8))))) ^ ((((((0xe000) >> 16) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xe000
) >> 16))) - 1) & ((((0xe000) >> 16)))) ^ (((
(0xe000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xe000) >> 16)) >> 4)) - 1) & (((((
0xe000) >> 16)) >> 4))) ^ (((((0xe000) >> 16
)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((
((((0xe000) >> 16)) >> 4) >> 2)) - 1) &
((((((0xe000) >> 16)) >> 4) >> 2))) ^ ((((
((0xe000) >> 16)) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000) >> 16
)) >> 4))) - 1) & ((((((0xe000) >> 16)) >>
4)))) ^ ((((((0xe000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe000) >> 16
)))) - 1) & (((((0xe000) >> 16))))) ^ (((((0xe000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xe000
) >> 16))) >> 2)) - 1) & ((((((0xe000) >>
16))) >> 2))) ^ ((((((0xe000) >> 16))) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000
) >> 16))))) - 1) & ((((((0xe000) >> 16))))))
^ ((((((0xe000) >> 16))))))) >> (1)) != 0) ? 1 :
0)))) : ((((u_long)(((((((0xe000))) - 1) & (((0xe000))))
^ (((0xe000))))) >> (8)) != 0) ? 8 + ((((u_long)((((((
((0xe000)) >> 8)) - 1) & ((((0xe000)) >> 8)))
^ ((((0xe000)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0xe000)) >> 8) >> 4)) - 1) & (
((((0xe000)) >> 8) >> 4))) ^ (((((0xe000)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xe000)) >> 8) >> 4) >> 2)) - 1) &
((((((0xe000)) >> 8) >> 4) >> 2))) ^ (((((
(0xe000)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000)) >> 8) >>
4))) - 1) & ((((((0xe000)) >> 8) >> 4)))) ^ (
(((((0xe000)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xe000)) >> 8))) - 1) &
(((((0xe000)) >> 8)))) ^ (((((0xe000)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xe000)) >>
8)) >> 2)) - 1) & ((((((0xe000)) >> 8)) >>
2))) ^ ((((((0xe000)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000)) >> 8
)))) - 1) & ((((((0xe000)) >> 8))))) ^ ((((((0xe000
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xe000)))) - 1) & ((((0xe000))))) ^ ((((0xe000))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xe000))) >>
4)) - 1) & (((((0xe000))) >> 4))) ^ (((((0xe000)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xe000))) >> 4) >> 2)) - 1) & ((((((0xe000)
)) >> 4) >> 2))) ^ ((((((0xe000))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000
))) >> 4))) - 1) & ((((((0xe000))) >> 4)))) ^
((((((0xe000))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xe000))))) - 1) & (((((0xe000)))
))) ^ (((((0xe000))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xe000)))) >> 2)) - 1) & ((((((0xe000)))
) >> 2))) ^ ((((((0xe000)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe000)))))) - 1) &
((((((0xe000))))))) ^ ((((((0xe000)))))))) >> (1)) != 0
) ? 1 : 0))))))
)
3812
3813 u_int8_t phydelay = LSHIFT(0x6, RTW_PHYDELAY_PHYDELAY)((0x6) << ((((u_long)((((((0x7)) - 1) & ((0x7))) ^ (
(0x7)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x7) >>
16)) - 1) & (((0x7) >> 16))) ^ (((0x7) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x7) >>
16) >> 8)) - 1) & ((((0x7) >> 16) >> 8
))) ^ ((((0x7) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x7) >> 16) >> 8) >>
4)) - 1) & (((((0x7) >> 16) >> 8) >> 4
))) ^ (((((0x7) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x7) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x7) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x7) >> 16) >> 8
) >> 4))) - 1) & ((((((0x7) >> 16) >> 8
) >> 4)))) ^ ((((((0x7) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7
) >> 16) >> 8))) - 1) & (((((0x7) >> 16
) >> 8)))) ^ (((((0x7) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7) >> 16) >>
8)) >> 2)) - 1) & ((((((0x7) >> 16) >>
8)) >> 2))) ^ ((((((0x7) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7
) >> 16) >> 8)))) - 1) & ((((((0x7) >> 16
) >> 8))))) ^ ((((((0x7) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x7) >> 16)
)) - 1) & ((((0x7) >> 16)))) ^ ((((0x7) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7) >>
16)) >> 4)) - 1) & (((((0x7) >> 16)) >>
4))) ^ (((((0x7) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x7) >> 16)) >> 4)
>> 2)) - 1) & ((((((0x7) >> 16)) >> 4)
>> 2))) ^ ((((((0x7) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7
) >> 16)) >> 4))) - 1) & ((((((0x7) >> 16
)) >> 4)))) ^ ((((((0x7) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7) >> 16)
))) - 1) & (((((0x7) >> 16))))) ^ (((((0x7) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7)
>> 16))) >> 2)) - 1) & ((((((0x7) >> 16
))) >> 2))) ^ ((((((0x7) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7) >> 16)
)))) - 1) & ((((((0x7) >> 16)))))) ^ ((((((0x7) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0x7))) - 1) & (((0x7)))) ^ (((0x7))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0x7)) >> 8)) - 1) & ((
((0x7)) >> 8))) ^ ((((0x7)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x7)) >> 8) >> 4
)) - 1) & (((((0x7)) >> 8) >> 4))) ^ (((((0x7
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7)) >> 8) >> 4) >> 2)) - 1) &
((((((0x7)) >> 8) >> 4) >> 2))) ^ ((((((0x7
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x7)) >> 8) >> 4
))) - 1) & ((((((0x7)) >> 8) >> 4)))) ^ (((((
(0x7)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0x7)) >> 8))) - 1) & (((((
0x7)) >> 8)))) ^ (((((0x7)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x7)) >> 8)) >>
2)) - 1) & ((((((0x7)) >> 8)) >> 2))) ^ ((((
((0x7)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x7)) >> 8)))) - 1) & ((
((((0x7)) >> 8))))) ^ ((((((0x7)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x7)))) - 1) &
((((0x7))))) ^ ((((0x7)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7))) >> 4)) - 1) & (((((0x7))) >>
4))) ^ (((((0x7))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0x7))) >> 4) >> 2)) - 1) &
((((((0x7))) >> 4) >> 2))) ^ ((((((0x7))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x7))) >> 4))) - 1) & ((((((0x7))) >>
4)))) ^ ((((((0x7))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0x7))))) - 1) & (((((0x7))))
)) ^ (((((0x7))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x7)))) >> 2)) - 1) & ((((((0x7)))) >>
2))) ^ ((((((0x7)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0x7)))))) - 1) & ((((((0x7))))
))) ^ ((((((0x7)))))))) >> (1)) != 0) ? 1 : 0))))))
;
3814
3815 RTW_WRITE(regs, RTW_RCR, REVAB)((*(regs)->r_write32)(regs, 0x44, (((7) << ((((u_long
)((((((0x700)) - 1) & ((0x700))) ^ ((0x700)))) >> (
16)) != 0) ? 16 + ((((u_long)(((((((0x700) >> 16)) - 1)
& (((0x700) >> 16))) ^ (((0x700) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)((((((((0x700) >> 16) >>
8)) - 1) & ((((0x700) >> 16) >> 8))) ^ ((((0x700
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x700) >> 16) >> 8) >> 4)) - 1) &
(((((0x700) >> 16) >> 8) >> 4))) ^ (((((0x700
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x700) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0x700) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0x700) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x700) >> 16) >> 8) >>
4))) - 1) & ((((((0x700) >> 16) >> 8) >>
4)))) ^ ((((((0x700) >> 16) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x700) >>
16) >> 8))) - 1) & (((((0x700) >> 16) >>
8)))) ^ (((((0x700) >> 16) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0x700) >> 16) >>
8)) >> 2)) - 1) & ((((((0x700) >> 16) >>
8)) >> 2))) ^ ((((((0x700) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700
) >> 16) >> 8)))) - 1) & ((((((0x700) >>
16) >> 8))))) ^ ((((((0x700) >> 16) >> 8))
)))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x700
) >> 16))) - 1) & ((((0x700) >> 16)))) ^ ((((
0x700) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0x700) >> 16)) >> 4)) - 1) & (((((0x700
) >> 16)) >> 4))) ^ (((((0x700) >> 16)) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x700) >>
16)) >> 4) >> 2)) - 1) & ((((((0x700) >>
16)) >> 4) >> 2))) ^ ((((((0x700) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x700) >> 16)) >> 4))) - 1) & (((((
(0x700) >> 16)) >> 4)))) ^ ((((((0x700) >> 16
)) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x700) >> 16)))) - 1) & (((((0x700) >>
16))))) ^ (((((0x700) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x700) >> 16))) >> 2)) -
1) & ((((((0x700) >> 16))) >> 2))) ^ ((((((0x700
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x700) >> 16))))) - 1) & ((((
((0x700) >> 16)))))) ^ ((((((0x700) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x700))) - 1) &
(((0x700)))) ^ (((0x700))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x700)) >> 8)) - 1) & ((((0x700)) >>
8))) ^ ((((0x700)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0x700)) >> 8) >> 4)) - 1) &
(((((0x700)) >> 8) >> 4))) ^ (((((0x700)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x700)) >> 8) >> 4) >> 2)) - 1) & (
(((((0x700)) >> 8) >> 4) >> 2))) ^ ((((((0x700
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x700)) >> 8) >>
4))) - 1) & ((((((0x700)) >> 8) >> 4)))) ^ (
(((((0x700)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x700)) >> 8))) - 1) &
(((((0x700)) >> 8)))) ^ (((((0x700)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x700)) >> 8)) >>
2)) - 1) & ((((((0x700)) >> 8)) >> 2))) ^ ((
((((0x700)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x700)) >> 8)))) - 1) &
((((((0x700)) >> 8))))) ^ ((((((0x700)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x700)
))) - 1) & ((((0x700))))) ^ ((((0x700)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0x700))) >> 4)) - 1) &
(((((0x700))) >> 4))) ^ (((((0x700))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x700))) >> 4) >>
2)) - 1) & ((((((0x700))) >> 4) >> 2))) ^ ((
((((0x700))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x700))) >> 4))) - 1) &
((((((0x700))) >> 4)))) ^ ((((((0x700))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x700)
)))) - 1) & (((((0x700)))))) ^ (((((0x700))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x700)))) >> 2))
- 1) & ((((((0x700)))) >> 2))) ^ ((((((0x700)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x700
)))))) - 1) & ((((((0x700))))))) ^ ((((((0x700)))))))) >>
(1)) != 0) ? 1 : 0)))))) | (1<<12))))
;
3816 RTW_WBW(regs, RTW_RCR, RTW_RCR)((*(regs)->r_barrier)(regs, 0x44, 0x44, 0x02));
3817 RTW_WRITE(regs, RTW_RCR, REVC)((*(regs)->r_write32)(regs, 0x44, REVC));
3818
3819 RTW_WBR(regs, RTW_RCR, RTW_RCR)((*(regs)->r_barrier)(regs, 0x44, 0x44, 0x02));
3820 if ((RTW_READ(regs, RTW_RCR)((*(regs)->r_read32)(regs, 0x44)) & REVC) == REVC)
3821 phydelay |= RTW_PHYDELAY_REVC_MAGIC(1<<3);
3822
3823 RTW_WRITE(regs, RTW_RCR, rcr0)((*(regs)->r_write32)(regs, 0x44, rcr0)); /* restore RCR */
3824 RTW_SYNC(regs, RTW_RCR, RTW_RCR)((*(regs)->r_barrier)(regs, 0x44, 0x44, (0x01|0x02)));
3825
3826 return phydelay;
3827#undef REVC
3828}
3829
3830void
3831rtw_attach(struct rtw_softc *sc)
3832{
3833 struct ieee80211com *ic = &sc->sc_ic;
3834 struct rtw_txsoft_blk *tsb;
3835 struct rtw_mtbl *mtbl;
3836 struct rtw_srom *sr;
3837 const char *vername;
3838 struct ifnet *ifp;
3839 char scratch[sizeof("unknown 0xXXXXXXXX")];
3840 int pri, rc, i;
3841
3842
3843 /* Use default DMA memory access */
3844 if (sc->sc_regs.r_read8 == NULL((void *)0)) {
3845 sc->sc_regs.r_read8 = rtw_read8;
3846 sc->sc_regs.r_read16 = rtw_read16;
3847 sc->sc_regs.r_read32 = rtw_read32;
3848 sc->sc_regs.r_write8 = rtw_write8;
3849 sc->sc_regs.r_write16 = rtw_write16;
3850 sc->sc_regs.r_write32 = rtw_write32;
3851 sc->sc_regs.r_barrier = rtw_barrier;
3852 }
3853
3854 sc->sc_hwverid = RTW_READ(&sc->sc_regs, RTW_TCR)((*(&sc->sc_regs)->r_read32)(&sc->sc_regs, 0x40
))
& RTW_TCR_HWVERID_MASK0xe000000;
3855 switch (sc->sc_hwverid) {
3856 case RTW_TCR_HWVERID_RTL8185((1<<27) | (1<<25)):
3857 vername = "RTL8185";
3858 sc->sc_flags |= RTW_F_RTL81850x00000008;
3859 break;
3860 case RTW_TCR_HWVERID_RTL8180F0x6000000:
3861 vername = "RTL8180F";
3862 break;
3863 case RTW_TCR_HWVERID_RTL8180D(1<<26):
3864 vername = "RTL8180D";
3865 break;
3866 default:
3867 snprintf(scratch, sizeof(scratch), "unknown 0x%08x",
3868 sc->sc_hwverid);
3869 vername = scratch;
3870 break;
3871 }
3872
3873 printf("%s: ver %s, ", sc->sc_dev.dv_xname, vername);
3874
3875 rc = bus_dmamem_alloc(sc->sc_dmat, sizeof(struct rtw_descs),(*(sc->sc_dmat)->_dmamem_alloc)((sc->sc_dmat), (sizeof
(struct rtw_descs)), (256), (0), (&sc->sc_desc_segs), (
1), (&sc->sc_desc_nsegs), (0))
3876 RTW_DESC_ALIGNMENT, 0, &sc->sc_desc_segs, 1, &sc->sc_desc_nsegs,(*(sc->sc_dmat)->_dmamem_alloc)((sc->sc_dmat), (sizeof
(struct rtw_descs)), (256), (0), (&sc->sc_desc_segs), (
1), (&sc->sc_desc_nsegs), (0))
3877 0)(*(sc->sc_dmat)->_dmamem_alloc)((sc->sc_dmat), (sizeof
(struct rtw_descs)), (256), (0), (&sc->sc_desc_segs), (
1), (&sc->sc_desc_nsegs), (0))
;
3878
3879 if (rc != 0) {
3880 printf("\n%s: could not allocate hw descriptors, error %d\n",
3881 sc->sc_dev.dv_xname, rc);
3882 goto fail0;
3883 }
3884
3885 rc = bus_dmamem_map(sc->sc_dmat, &sc->sc_desc_segs,(*(sc->sc_dmat)->_dmamem_map)((sc->sc_dmat), (&sc
->sc_desc_segs), (sc->sc_desc_nsegs), (sizeof(struct rtw_descs
)), ((caddr_t*)&sc->sc_descs), (0x0004))
3886 sc->sc_desc_nsegs, sizeof(struct rtw_descs),(*(sc->sc_dmat)->_dmamem_map)((sc->sc_dmat), (&sc
->sc_desc_segs), (sc->sc_desc_nsegs), (sizeof(struct rtw_descs
)), ((caddr_t*)&sc->sc_descs), (0x0004))
3887 (caddr_t*)&sc->sc_descs, BUS_DMA_COHERENT)(*(sc->sc_dmat)->_dmamem_map)((sc->sc_dmat), (&sc
->sc_desc_segs), (sc->sc_desc_nsegs), (sizeof(struct rtw_descs
)), ((caddr_t*)&sc->sc_descs), (0x0004))
;
3888
3889 if (rc != 0) {
3890 printf("\n%s: can't map hw descriptors, error %d\n",
3891 sc->sc_dev.dv_xname, rc);
3892 goto fail1;
3893 }
3894
3895 rc = bus_dmamap_create(sc->sc_dmat, sizeof(struct rtw_descs), 1,(*(sc->sc_dmat)->_dmamap_create)((sc->sc_dmat), (sizeof
(struct rtw_descs)), (1), (sizeof(struct rtw_descs)), (0), (0
), (&sc->sc_desc_dmamap))
3896 sizeof(struct rtw_descs), 0, 0, &sc->sc_desc_dmamap)(*(sc->sc_dmat)->_dmamap_create)((sc->sc_dmat), (sizeof
(struct rtw_descs)), (1), (sizeof(struct rtw_descs)), (0), (0
), (&sc->sc_desc_dmamap))
;
3897
3898 if (rc != 0) {
3899 printf("\n%s: could not create DMA map for hw descriptors, "
3900 "error %d\n", sc->sc_dev.dv_xname, rc);
3901 goto fail2;
3902 }
3903
3904 sc->sc_rxdesc_blk.rdb_dmat = sc->sc_dmat;
3905 sc->sc_rxdesc_blk.rdb_dmamap = sc->sc_desc_dmamap;
3906
3907 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
3908 sc->sc_txdesc_blk[pri].tdb_dmat = sc->sc_dmat;
3909 sc->sc_txdesc_blk[pri].tdb_dmamap = sc->sc_desc_dmamap;
3910 }
3911
3912 rc = bus_dmamap_load(sc->sc_dmat, sc->sc_desc_dmamap, sc->sc_descs,(*(sc->sc_dmat)->_dmamap_load)((sc->sc_dmat), (sc->
sc_desc_dmamap), (sc->sc_descs), (sizeof(struct rtw_descs)
), (((void *)0)), (0))
3913 sizeof(struct rtw_descs), NULL, 0)(*(sc->sc_dmat)->_dmamap_load)((sc->sc_dmat), (sc->
sc_desc_dmamap), (sc->sc_descs), (sizeof(struct rtw_descs)
), (((void *)0)), (0))
;
3914
3915 if (rc != 0) {
3916 printf("\n%s: could not load DMA map for hw descriptors, "
3917 "error %d\n", sc->sc_dev.dv_xname, rc);
3918 goto fail3;
3919 }
3920
3921 if (rtw_txsoft_blk_setup_all(sc) != 0)
3922 goto fail4;
3923
3924 rtw_txdesc_blk_setup_all(sc);
3925
3926 sc->sc_rxdesc_blk.rdb_desc = &sc->sc_descs->hd_rx[0];
3927
3928 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
3929 tsb = &sc->sc_txsoft_blk[pri];
3930
3931 if ((rc = rtw_txdesc_dmamaps_create(sc->sc_dmat,
3932 &tsb->tsb_desc[0], tsb->tsb_ndesc)) != 0) {
3933 printf("\n%s: could not load DMA map for "
3934 "hw tx descriptors, error %d\n",
3935 sc->sc_dev.dv_xname, rc);
3936 goto fail5;
3937 }
3938 }
3939
3940 if ((rc = rtw_rxdesc_dmamaps_create(sc->sc_dmat, &sc->sc_rxsoft[0],
3941 RTW_RXQLEN64)) != 0) {
3942 printf("\n%s: could not load DMA map for hw rx descriptors, "
3943 "error %d\n", sc->sc_dev.dv_xname, rc);
3944 goto fail6;
3945 }
3946
3947 /* Reset the chip to a known state. */
3948 if (rtw_reset(sc) != 0)
3949 goto fail7;
3950
3951 sc->sc_rcr = RTW_READ(&sc->sc_regs, RTW_RCR)((*(&sc->sc_regs)->r_read32)(&sc->sc_regs, 0x44
))
;
3952
3953 if ((sc->sc_rcr & RTW_RCR_9356SEL(1<<6)) != 0)
3954 sc->sc_flags |= RTW_F_9356SROM0x00000020;
3955
3956 if (rtw_srom_read(&sc->sc_regs, sc->sc_flags, &sc->sc_srom,
3957 sc->sc_dev.dv_xname) != 0)
3958 goto fail7;
3959
3960 if (rtw_srom_parse(sc) != 0) {
3961 printf("\n%s: attach failed, malformed serial ROM\n",
3962 sc->sc_dev.dv_xname);
3963 goto fail8;
3964 }
3965
3966 RTW_DPRINTF(RTW_DEBUG_ATTACH, ("%s: %s PHY\n", sc->sc_dev.dv_xname,
3967 ((sc->sc_flags & RTW_F_DIGPHY) != 0) ? "digital" : "analog"));
3968
3969 RTW_DPRINTF(RTW_DEBUG_ATTACH, ("%s: CS threshold %u\n",
3970 sc->sc_dev.dv_xname, sc->sc_csthr));
3971
3972 if ((rtw_rf_attach(sc, sc->sc_rfchipid)) != 0) {
3973 printf("\n%s: attach failed, could not attach RF\n",
3974 sc->sc_dev.dv_xname);
3975 goto fail8;
3976 }
3977
3978 sc->sc_phydelay = rtw_check_phydelay(&sc->sc_regs, sc->sc_rcr);
3979
3980 RTW_DPRINTF(RTW_DEBUG_ATTACH,
3981 ("%s: PHY delay %d\n", sc->sc_dev.dv_xname, sc->sc_phydelay));
3982
3983 if (sc->sc_locale == RTW_LOCALE_UNKNOWN)
3984 rtw_identify_country(&sc->sc_regs, &sc->sc_locale);
3985
3986 for (i = 1; i <= 14; i++) {
3987 sc->sc_ic.ic_channels[i].ic_flags = IEEE80211_CHAN_B(0x0080 | 0x0020);
3988 sc->sc_ic.ic_channels[i].ic_freq =
3989 ieee80211_ieee2mhz(i, sc->sc_ic.ic_channels[i].ic_flags);
3990 }
3991
3992 if (rtw_identify_sta(&sc->sc_regs, &sc->sc_ic.ic_myaddr,
3993 sc->sc_dev.dv_xname) != 0)
3994 goto fail8;
3995
3996 ifp = &sc->sc_ifsc_ic.ic_ac.ac_if;
3997 (void)memcpy(ifp->if_xname, sc->sc_dev.dv_xname, IFNAMSIZ)__builtin_memcpy((ifp->if_xname), (sc->sc_dev.dv_xname)
, (16))
;
3998 ifp->if_softc = sc;
3999 ifp->if_flags = IFF_SIMPLEX0x800 | IFF_BROADCAST0x2 | IFF_MULTICAST0x8000;
4000 ifp->if_ioctl = rtw_ioctl;
4001 ifp->if_start = rtw_start;
4002 ifp->if_watchdog = rtw_watchdog;
4003
4004
4005 ic->ic_phytype = IEEE80211_T_DS;
4006 ic->ic_opmode = IEEE80211_M_STA;
4007 ic->ic_caps = IEEE80211_C_PMGT0x00000004 | IEEE80211_C_MONITOR0x00000200 | IEEE80211_C_WEP0x00000001;
4008#ifndef IEEE80211_STA_ONLY
4009 ic->ic_caps |= IEEE80211_C_HOSTAP0x00000008 | IEEE80211_C_IBSS0x00000002;
4010#endif
4011 ic->ic_sup_rates[IEEE80211_MODE_11B] = ieee80211_std_rateset_11b;
4012
4013 rtw_led_attach(&sc->sc_led_state, (void *)sc);
4014
4015 /*
4016 * Call MI attach routines.
4017 */
4018 if_attach(&sc->sc_ifsc_ic.ic_ac.ac_if);
4019 ieee80211_ifattach(&sc->sc_ifsc_ic.ic_ac.ac_if);
4020
4021 mtbl = &sc->sc_mtbl;
4022 mtbl->mt_newstate = ic->ic_newstate;
4023 ic->ic_newstate = rtw_newstate;
4024
4025#ifndef IEEE80211_STA_ONLY
4026 mtbl->mt_recv_mgmt = ic->ic_recv_mgmt;
4027 ic->ic_recv_mgmt = rtw_recv_mgmt;
4028#endif
4029
4030 mtbl->mt_node_free = ic->ic_node_free;
4031 ic->ic_node_free = rtw_node_free;
4032
4033 mtbl->mt_node_alloc = ic->ic_node_alloc;
4034 ic->ic_node_alloc = rtw_node_alloc;
4035
4036 /* possibly we should fill in our own sc_send_prresp, since
4037 * the RTL8180 is probably sending probe responses in ad hoc
4038 * mode.
4039 */
4040
4041 /* complete initialization */
4042 ieee80211_media_init(&sc->sc_ifsc_ic.ic_ac.ac_if, rtw_media_change, rtw_media_status);
4043 timeout_set(&sc->sc_scan_to, rtw_next_scan, sc);
4044
4045#if NBPFILTER1 > 0
4046 bzero(&sc->sc_rxtapu, sizeof(sc->sc_rxtapu))__builtin_bzero((&sc->sc_rxtapu), (sizeof(sc->sc_rxtapu
)))
;
4047 sc->sc_rxtapsc_rxtapu.tap.rr_ihdr.it_len = sizeof(sc->sc_rxtapu);
4048 sc->sc_rxtapsc_rxtapu.tap.rr_ihdr.it_present = RTW_RX_RADIOTAP_PRESENT((1 << IEEE80211_RADIOTAP_TSFT) | (1 << IEEE80211_RADIOTAP_FLAGS
) | (1 << IEEE80211_RADIOTAP_RATE) | (1 << IEEE80211_RADIOTAP_CHANNEL
) | (1 << IEEE80211_RADIOTAP_LOCK_QUALITY) | (1 <<
IEEE80211_RADIOTAP_DB_ANTSIGNAL) | 0)
;
4049
4050 bzero(&sc->sc_txtapu, sizeof(sc->sc_txtapu))__builtin_bzero((&sc->sc_txtapu), (sizeof(sc->sc_txtapu
)))
;
4051 sc->sc_txtapsc_txtapu.tap.rt_ihdr.it_len = sizeof(sc->sc_txtapu);
4052 sc->sc_txtapsc_txtapu.tap.rt_ihdr.it_present = RTW_TX_RADIOTAP_PRESENT((1 << IEEE80211_RADIOTAP_FLAGS) | (1 << IEEE80211_RADIOTAP_RATE
) | (1 << IEEE80211_RADIOTAP_CHANNEL) | 0)
;
4053
4054 bpfattach(&sc->sc_radiobpf, &sc->sc_ic.ic_ific_ac.ac_if, DLT_IEEE802_11_RADIO127,
4055 sizeof(struct ieee80211_frame) + 64);
4056#endif
4057 return;
4058
4059fail8:
4060 sr = &sc->sc_srom;
4061 if (sr->sr_content != NULL((void *)0)) {
4062 free(sr->sr_content, M_DEVBUF2, sr->sr_size);
4063 sr->sr_content = NULL((void *)0);
4064 }
4065 sr->sr_size = 0;
4066
4067fail7:
4068 rtw_rxdesc_dmamaps_destroy(sc->sc_dmat, &sc->sc_rxsoft[0],
4069 RTW_RXQLEN64);
4070
4071fail6:
4072 for (pri = 0; pri < RTW_NTXPRI4; pri++) {
4073 rtw_txdesc_dmamaps_destroy(sc->sc_dmat,
4074 sc->sc_txsoft_blk[pri].tsb_desc,
4075 sc->sc_txsoft_blk[pri].tsb_ndesc);
4076 }
4077
4078fail5:
4079 rtw_txsoft_blk_cleanup_all(sc);
4080
4081fail4:
4082 bus_dmamap_unload(sc->sc_dmat, sc->sc_desc_dmamap)(*(sc->sc_dmat)->_dmamap_unload)((sc->sc_dmat), (sc->
sc_desc_dmamap))
;
4083fail3:
4084 bus_dmamap_destroy(sc->sc_dmat, sc->sc_desc_dmamap)(*(sc->sc_dmat)->_dmamap_destroy)((sc->sc_dmat), (sc
->sc_desc_dmamap))
;
4085fail2:
4086 bus_dmamem_unmap(sc->sc_dmat, (caddr_t)sc->sc_descs,(*(sc->sc_dmat)->_dmamem_unmap)((sc->sc_dmat), ((caddr_t
)sc->sc_descs), (sizeof(struct rtw_descs)))
4087 sizeof(struct rtw_descs))(*(sc->sc_dmat)->_dmamem_unmap)((sc->sc_dmat), ((caddr_t
)sc->sc_descs), (sizeof(struct rtw_descs)))
;
4088fail1:
4089 bus_dmamem_free(sc->sc_dmat, &sc->sc_desc_segs,(*(sc->sc_dmat)->_dmamem_free)((sc->sc_dmat), (&
sc->sc_desc_segs), (sc->sc_desc_nsegs))
4090 sc->sc_desc_nsegs)(*(sc->sc_dmat)->_dmamem_free)((sc->sc_dmat), (&
sc->sc_desc_segs), (sc->sc_desc_nsegs))
;
4091fail0:
4092 return;
4093}
4094
4095int
4096rtw_detach(struct rtw_softc *sc)
4097{
4098 sc->sc_flags |= RTW_F_INVALID0x00000080;
4099
4100 timeout_del(&sc->sc_scan_to);
4101
4102 rtw_stop(&sc->sc_ifsc_ic.ic_ac.ac_if, 1);
4103
4104 ieee80211_ifdetach(&sc->sc_ifsc_ic.ic_ac.ac_if);
4105 if_detach(&sc->sc_ifsc_ic.ic_ac.ac_if);
4106
4107 return 0;
4108}
4109
4110/*
4111 * PHY specific functions
4112 */
4113
4114int
4115rtw_bbp_preinit(struct rtw_regs *regs, u_int antatten0, int dflantb,
4116 u_int freq)
4117{
4118 u_int antatten = antatten0;
4119 if (dflantb)
4120 antatten |= RTW_BBP_ANTATTEN_DFLANTB0x40;
4121 if (freq == 2484) /* channel 14 */
4122 antatten |= RTW_BBP_ANTATTEN_CHAN140x0c;
4123 return rtw_bbp_write(regs, RTW_BBP_ANTATTEN0x10, antatten);
4124}
4125
4126int
4127rtw_bbp_init(struct rtw_regs *regs, struct rtw_bbpset *bb, int antdiv,
4128 int dflantb, u_int8_t cs_threshold, u_int freq)
4129{
4130 int rc;
4131 u_int32_t sys2, sys3;
4132
4133 sys2 = bb->bb_sys2;
4134 if (antdiv)
4135 sys2 |= RTW_BBP_SYS2_ANTDIV0x80;
4136 sys3 = bb->bb_sys3 |
4137 LSHIFT(cs_threshold, RTW_BBP_SYS3_CSTHRESH_MASK)((cs_threshold) << ((((u_long)((((((0xf)) - 1) & ((
0xf))) ^ ((0xf)))) >> (16)) != 0) ? 16 + ((((u_long)(((
((((0xf) >> 16)) - 1) & (((0xf) >> 16))) ^ ((
(0xf) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long)((
((((((0xf) >> 16) >> 8)) - 1) & ((((0xf) >>
16) >> 8))) ^ ((((0xf) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xf) >> 16) >>
8) >> 4)) - 1) & (((((0xf) >> 16) >> 8
) >> 4))) ^ (((((0xf) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0xf
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xf) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16)
>> 8) >> 4))) - 1) & ((((((0xf) >> 16)
>> 8) >> 4)))) ^ ((((((0xf) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xf) >> 16) >> 8))) - 1) & (((((0xf
) >> 16) >> 8)))) ^ (((((0xf) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >>
16) >> 8)) >> 2)) - 1) & ((((((0xf) >>
16) >> 8)) >> 2))) ^ ((((((0xf) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xf) >> 16) >> 8)))) - 1) & ((((((
0xf) >> 16) >> 8))))) ^ ((((((0xf) >> 16) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
0xf) >> 16))) - 1) & ((((0xf) >> 16)))) ^ (((
(0xf) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(
((((((((0xf) >> 16)) >> 4)) - 1) & (((((0xf) >>
16)) >> 4))) ^ (((((0xf) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16)) >>
4) >> 2)) - 1) & ((((((0xf) >> 16)) >>
4) >> 2))) ^ ((((((0xf) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16)) >> 4))) - 1) & ((((((0xf) >> 16
)) >> 4)))) ^ ((((((0xf) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf) >> 16)
))) - 1) & (((((0xf) >> 16))))) ^ (((((0xf) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf)
>> 16))) >> 2)) - 1) & ((((((0xf) >> 16
))) >> 2))) ^ ((((((0xf) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16)
)))) - 1) & ((((((0xf) >> 16)))))) ^ ((((((0xf) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xf))) - 1) & (((0xf)))) ^ (((0xf))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xf)) >> 8)) - 1) & ((
((0xf)) >> 8))) ^ ((((0xf)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xf)) >> 8) >> 4
)) - 1) & (((((0xf)) >> 8) >> 4))) ^ (((((0xf
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf)) >> 8) >> 4) >> 2)) - 1) &
((((((0xf)) >> 8) >> 4) >> 2))) ^ ((((((0xf
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xf)) >> 8) >> 4
))) - 1) & ((((((0xf)) >> 8) >> 4)))) ^ (((((
(0xf)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xf)) >> 8))) - 1) & (((((
0xf)) >> 8)))) ^ (((((0xf)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xf)) >> 8)) >>
2)) - 1) & ((((((0xf)) >> 8)) >> 2))) ^ ((((
((0xf)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)) >> 8)))) - 1) & ((
((((0xf)) >> 8))))) ^ ((((((0xf)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf)))) - 1) &
((((0xf))))) ^ ((((0xf)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf))) >> 4)) - 1) & (((((0xf))) >>
4))) ^ (((((0xf))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf))) >> 4) >> 2)) - 1) &
((((((0xf))) >> 4) >> 2))) ^ ((((((0xf))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xf))) >> 4))) - 1) & ((((((0xf))) >>
4)))) ^ ((((((0xf))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xf))))) - 1) & (((((0xf))))
)) ^ (((((0xf))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf)))) >> 2)) - 1) & ((((((0xf)))) >>
2))) ^ ((((((0xf)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)))))) - 1) & ((((((0xf))))
))) ^ ((((((0xf)))))))) >> (1)) != 0) ? 1 : 0))))))
;
4138
4139#define RTW_BBP_WRITE_OR_RETURN(reg, val)if ((rc = rtw_bbp_write(regs, reg, val)) != 0) return rc; \
4140 if ((rc = rtw_bbp_write(regs, reg, val)) != 0) \
4141 return rc;
4142
4143 RTW_BBP_WRITE_OR_RETURN(RTW_BBP_SYS1, bb->bb_sys1)if ((rc = rtw_bbp_write(regs, 0x00, bb->bb_sys1)) != 0) return
rc;
;
4144 RTW_BBP_WRITE_OR_RETURN(RTW_BBP_TXAGC, bb->bb_txagc)if ((rc = rtw_bbp_write(regs, 0x03, bb->bb_txagc)) != 0) return
rc;
;
4145 RTW_BBP_WRITE_OR_RETURN(RTW_BBP_LNADET, bb->bb_lnadet)if ((rc = rtw_bbp_write(regs, 0x04, bb->bb_lnadet)) != 0) return
rc;
;
4146 RTW_BBP_WRITE_OR_RETURN(RTW_BBP_IFAGCINI, bb->bb_ifagcini)if ((rc = rtw_bbp_write(regs, 0x05, bb->bb_ifagcini)) != 0
) return rc;
;
4147 RTW_BBP_WRITE_OR_RETURN(RTW_BBP_IFAGCLIMIT, bb->bb_ifagclimit)if ((rc = rtw_bbp_write(regs, 0x06, bb->bb_ifagclimit)) !=
0) return rc;
;
4148 RTW_BBP_WRITE_OR_RETURN(RTW_BBP_IFAGCDET, bb->bb_ifagcdet)if ((rc = rtw_bbp_write(regs, 0x07, bb->bb_ifagcdet)) != 0
) return rc;
;
4149
4150 if ((rc = rtw_bbp_preinit(regs, bb->bb_antatten, dflantb, freq)) != 0)
4151 return rc;
4152
4153 RTW_BBP_WRITE_OR_RETURN(RTW_BBP_TRL, bb->bb_trl)if ((rc = rtw_bbp_write(regs, 0x11, bb->bb_trl)) != 0) return
rc;
;
4154 RTW_BBP_WRITE_OR_RETURN(RTW_BBP_SYS2, sys2)if ((rc = rtw_bbp_write(regs, 0x12, sys2)) != 0) return rc;;
4155 RTW_BBP_WRITE_OR_RETURN(RTW_BBP_SYS3, sys3)if ((rc = rtw_bbp_write(regs, 0x13, sys3)) != 0) return rc;;
4156 RTW_BBP_WRITE_OR_RETURN(RTW_BBP_CHESTLIM, bb->bb_chestlim)if ((rc = rtw_bbp_write(regs, 0x19, bb->bb_chestlim)) != 0
) return rc;
;
4157 RTW_BBP_WRITE_OR_RETURN(RTW_BBP_CHSQLIM, bb->bb_chsqlim)if ((rc = rtw_bbp_write(regs, 0x1a, bb->bb_chsqlim)) != 0)
return rc;
;
4158 return 0;
4159}
4160
4161int
4162rtw_sa2400_txpower(struct rtw_softc *sc, u_int8_t opaque_txpower)
4163{
4164 return rtw_rf_macwrite(sc, SA2400_TX7, opaque_txpower);
4165}
4166
4167/* make sure we're using the same settings as the reference driver */
4168void
4169rtw_verify_syna(u_int freq, u_int32_t val)
4170{
4171 u_int32_t expected_val = ~val;
4172
4173 switch (freq) {
4174 case 2412:
4175 expected_val = 0x0000096c; /* ch 1 */
4176 break;
4177 case 2417:
4178 expected_val = 0x00080970; /* ch 2 */
4179 break;
4180 case 2422:
4181 expected_val = 0x00100974; /* ch 3 */
4182 break;
4183 case 2427:
4184 expected_val = 0x00180978; /* ch 4 */
4185 break;
4186 case 2432:
4187 expected_val = 0x00000980; /* ch 5 */
4188 break;
4189 case 2437:
4190 expected_val = 0x00080984; /* ch 6 */
4191 break;
4192 case 2442:
4193 expected_val = 0x00100988; /* ch 7 */
4194 break;
4195 case 2447:
4196 expected_val = 0x0018098c; /* ch 8 */
4197 break;
4198 case 2452:
4199 expected_val = 0x00000994; /* ch 9 */
4200 break;
4201 case 2457:
4202 expected_val = 0x00080998; /* ch 10 */
4203 break;
4204 case 2462:
4205 expected_val = 0x0010099c; /* ch 11 */
4206 break;
4207 case 2467:
4208 expected_val = 0x001809a0; /* ch 12 */
4209 break;
4210 case 2472:
4211 expected_val = 0x000009a8; /* ch 13 */
4212 break;
4213 case 2484:
4214 expected_val = 0x000009b4; /* ch 14 */
4215 break;
4216 }
4217 KASSERT(val == expected_val)((val == expected_val) ? (void)0 : __assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c"
, 4217, "val == expected_val"))
;
4218}
4219
4220/* freq is in MHz */
4221int
4222rtw_sa2400_tune(struct rtw_softc *sc, u_int freq)
4223{
4224 int rc;
4225 u_int32_t syna, synb, sync;
4226
4227 /* XO = 44MHz, R = 11, hence N is in units of XO / R = 4MHz.
4228 *
4229 * The channel spacing (5MHz) is not divisible by 4MHz, so
4230 * we set the fractional part of N to compensate.
4231 */
4232 int n = freq / 4, nf = (freq % 4) * 2;
4233
4234 syna = LSHIFT(nf, SA2400_SYNA_NF_MASK)((nf) << ((((u_long)((((((0x1c0000)) - 1) & ((0x1c0000
))) ^ ((0x1c0000)))) >> (16)) != 0) ? 16 + ((((u_long)(
((((((0x1c0000) >> 16)) - 1) & (((0x1c0000) >>
16))) ^ (((0x1c0000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x1c0000) >> 16) >> 8)) - 1
) & ((((0x1c0000) >> 16) >> 8))) ^ ((((0x1c0000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x1c0000) >> 16) >> 8) >> 4)) - 1
) & (((((0x1c0000) >> 16) >> 8) >> 4)))
^ (((((0x1c0000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x1c0000) >> 16)
>> 8) >> 4) >> 2)) - 1) & ((((((0x1c0000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x1c0000) >> 16) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x1c0000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x1c0000
) >> 16) >> 8) >> 4)))) ^ ((((((0x1c0000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x1c0000) >> 16) >> 8))) -
1) & (((((0x1c0000) >> 16) >> 8)))) ^ (((((0x1c0000
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0x1c0000) >> 16) >> 8)) >>
2)) - 1) & ((((((0x1c0000) >> 16) >> 8)) >>
2))) ^ ((((((0x1c0000) >> 16) >> 8)) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x1c0000
) >> 16) >> 8)))) - 1) & ((((((0x1c0000) >>
16) >> 8))))) ^ ((((((0x1c0000) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x1c0000
) >> 16))) - 1) & ((((0x1c0000) >> 16)))) ^ (
(((0x1c0000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x1c0000) >> 16)) >> 4)) - 1) & (((
((0x1c0000) >> 16)) >> 4))) ^ (((((0x1c0000) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x1c0000) >> 16)) >> 4) >> 2)) - 1) &
((((((0x1c0000) >> 16)) >> 4) >> 2))) ^ ((
((((0x1c0000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x1c0000) >>
16)) >> 4))) - 1) & ((((((0x1c0000) >> 16)) >>
4)))) ^ ((((((0x1c0000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x1c0000) >>
16)))) - 1) & (((((0x1c0000) >> 16))))) ^ (((((0x1c0000
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0x1c0000) >> 16))) >> 2)) - 1) & ((((((
0x1c0000) >> 16))) >> 2))) ^ ((((((0x1c0000) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x1c0000) >> 16))))) - 1) & ((((((0x1c0000
) >> 16)))))) ^ ((((((0x1c0000) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x1c0000))) - 1) &
(((0x1c0000)))) ^ (((0x1c0000))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0x1c0000)) >> 8)) - 1) & ((((0x1c0000
)) >> 8))) ^ ((((0x1c0000)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x1c0000)) >> 8) >>
4)) - 1) & (((((0x1c0000)) >> 8) >> 4))) ^ (
((((0x1c0000)) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x1c0000)) >> 8) >> 4
) >> 2)) - 1) & ((((((0x1c0000)) >> 8) >>
4) >> 2))) ^ ((((((0x1c0000)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x1c0000
)) >> 8) >> 4))) - 1) & ((((((0x1c0000)) >>
8) >> 4)))) ^ ((((((0x1c0000)) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x1c0000
)) >> 8))) - 1) & (((((0x1c0000)) >> 8)))) ^ (
((((0x1c0000)) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0x1c0000)) >> 8)) >> 2)) - 1) &
((((((0x1c0000)) >> 8)) >> 2))) ^ ((((((0x1c0000
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x1c0000)) >> 8)))) - 1) & ((
((((0x1c0000)) >> 8))))) ^ ((((((0x1c0000)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x1c0000
)))) - 1) & ((((0x1c0000))))) ^ ((((0x1c0000)))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x1c0000))) >> 4)
) - 1) & (((((0x1c0000))) >> 4))) ^ (((((0x1c0000))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0x1c0000))) >> 4) >> 2)) - 1) & ((((((0x1c0000
))) >> 4) >> 2))) ^ ((((((0x1c0000))) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0x1c0000))) >> 4))) - 1) & ((((((0x1c0000)))
>> 4)))) ^ ((((((0x1c0000))) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x1c0000))))) - 1) &
(((((0x1c0000)))))) ^ (((((0x1c0000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0x1c0000)))) >> 2)) - 1) &
((((((0x1c0000)))) >> 2))) ^ ((((((0x1c0000)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x1c0000
)))))) - 1) & ((((((0x1c0000))))))) ^ ((((((0x1c0000)))))
))) >> (1)) != 0) ? 1 : 0))))))
| LSHIFT(n, SA2400_SYNA_N_MASK)((n) << ((((u_long)((((((0x3fffc)) - 1) & ((0x3fffc
))) ^ ((0x3fffc)))) >> (16)) != 0) ? 16 + ((((u_long)((
(((((0x3fffc) >> 16)) - 1) & (((0x3fffc) >> 16
))) ^ (((0x3fffc) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0x3fffc) >> 16) >> 8)) - 1) &
((((0x3fffc) >> 16) >> 8))) ^ ((((0x3fffc) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0x3fffc) >> 16) >> 8) >> 4)) - 1) &
(((((0x3fffc) >> 16) >> 8) >> 4))) ^ (((((
0x3fffc) >> 16) >> 8) >> 4)))) >> (2)
) != 0) ? 2 + ((((u_long)((((((((((0x3fffc) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3fffc) >>
16) >> 8) >> 4) >> 2))) ^ ((((((0x3fffc) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3fffc) >> 16) >>
8) >> 4))) - 1) & ((((((0x3fffc) >> 16) >>
8) >> 4)))) ^ ((((((0x3fffc) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3fffc
) >> 16) >> 8))) - 1) & (((((0x3fffc) >>
16) >> 8)))) ^ (((((0x3fffc) >> 16) >> 8))
))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3fffc) >>
16) >> 8)) >> 2)) - 1) & ((((((0x3fffc) >>
16) >> 8)) >> 2))) ^ ((((((0x3fffc) >> 16)
>> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x3fffc) >> 16) >> 8)))) - 1)
& ((((((0x3fffc) >> 16) >> 8))))) ^ ((((((0x3fffc
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x3fffc) >> 16))) - 1) & (((
(0x3fffc) >> 16)))) ^ ((((0x3fffc) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x3fffc) >> 16)) >>
4)) - 1) & (((((0x3fffc) >> 16)) >> 4))) ^ (
((((0x3fffc) >> 16)) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x3fffc) >> 16)) >> 4
) >> 2)) - 1) & ((((((0x3fffc) >> 16)) >>
4) >> 2))) ^ ((((((0x3fffc) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3fffc
) >> 16)) >> 4))) - 1) & ((((((0x3fffc) >>
16)) >> 4)))) ^ ((((((0x3fffc) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3fffc
) >> 16)))) - 1) & (((((0x3fffc) >> 16))))) ^
(((((0x3fffc) >> 16)))))) >> (2)) != 0) ? 2 + ((
((u_long)((((((((((0x3fffc) >> 16))) >> 2)) - 1) &
((((((0x3fffc) >> 16))) >> 2))) ^ ((((((0x3fffc)
>> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x3fffc) >> 16))))) - 1) & ((
((((0x3fffc) >> 16)))))) ^ ((((((0x3fffc) >> 16))
))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x3fffc
))) - 1) & (((0x3fffc)))) ^ (((0x3fffc))))) >> (8))
!= 0) ? 8 + ((((u_long)((((((((0x3fffc)) >> 8)) - 1) &
((((0x3fffc)) >> 8))) ^ ((((0x3fffc)) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x3fffc)) >> 8) >>
4)) - 1) & (((((0x3fffc)) >> 8) >> 4))) ^ ((
(((0x3fffc)) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x3fffc)) >> 8) >> 4) >>
2)) - 1) & ((((((0x3fffc)) >> 8) >> 4) >>
2))) ^ ((((((0x3fffc)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3fffc
)) >> 8) >> 4))) - 1) & ((((((0x3fffc)) >>
8) >> 4)))) ^ ((((((0x3fffc)) >> 8) >> 4))
))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3fffc
)) >> 8))) - 1) & (((((0x3fffc)) >> 8)))) ^ (
((((0x3fffc)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3fffc)) >> 8)) >> 2)) - 1) & (((
(((0x3fffc)) >> 8)) >> 2))) ^ ((((((0x3fffc)) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x3fffc)) >> 8)))) - 1) & ((((((0x3fffc)
) >> 8))))) ^ ((((((0x3fffc)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3fffc)))) - 1) &
((((0x3fffc))))) ^ ((((0x3fffc)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x3fffc))) >> 4)) - 1) & (((
((0x3fffc))) >> 4))) ^ (((((0x3fffc))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3fffc))) >> 4)
>> 2)) - 1) & ((((((0x3fffc))) >> 4) >>
2))) ^ ((((((0x3fffc))) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3fffc))) >>
4))) - 1) & ((((((0x3fffc))) >> 4)))) ^ ((((((0x3fffc
))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x3fffc))))) - 1) & (((((0x3fffc)))))) ^ (((((0x3fffc
))))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3fffc
)))) >> 2)) - 1) & ((((((0x3fffc)))) >> 2))) ^
((((((0x3fffc)))) >> 2)))) >> (1)) != 0) ? 1 : 0
) : ((((u_long)((((((((((0x3fffc)))))) - 1) & ((((((0x3fffc
))))))) ^ ((((((0x3fffc)))))))) >> (1)) != 0) ? 1 : 0))
))))
;
4235 rtw_verify_syna(freq, syna);
4236
4237 /* Divide the 44MHz crystal down to 4MHz. Set the fractional
4238 * compensation charge pump value to agree with the fractional
4239 * modulus.
4240 */
4241 synb = LSHIFT(11, SA2400_SYNB_R_MASK)((11) << ((((u_long)((((((0x3ff000)) - 1) & ((0x3ff000
))) ^ ((0x3ff000)))) >> (16)) != 0) ? 16 + ((((u_long)(
((((((0x3ff000) >> 16)) - 1) & (((0x3ff000) >>
16))) ^ (((0x3ff000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x3ff000) >> 16) >> 8)) - 1
) & ((((0x3ff000) >> 16) >> 8))) ^ ((((0x3ff000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3ff000) >> 16) >> 8) >> 4)) - 1
) & (((((0x3ff000) >> 16) >> 8) >> 4)))
^ (((((0x3ff000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff000) >> 16)
>> 8) >> 4) >> 2)) - 1) & ((((((0x3ff000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x3ff000) >> 16) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff000
) >> 16) >> 8) >> 4))) - 1) & ((((((0x3ff000
) >> 16) >> 8) >> 4)))) ^ ((((((0x3ff000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x3ff000) >> 16) >> 8))) -
1) & (((((0x3ff000) >> 16) >> 8)))) ^ (((((0x3ff000
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0x3ff000) >> 16) >> 8)) >>
2)) - 1) & ((((((0x3ff000) >> 16) >> 8)) >>
2))) ^ ((((((0x3ff000) >> 16) >> 8)) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff000
) >> 16) >> 8)))) - 1) & ((((((0x3ff000) >>
16) >> 8))))) ^ ((((((0x3ff000) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff000
) >> 16))) - 1) & ((((0x3ff000) >> 16)))) ^ (
(((0x3ff000) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3ff000) >> 16)) >> 4)) - 1) & (((
((0x3ff000) >> 16)) >> 4))) ^ (((((0x3ff000) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3ff000) >> 16)) >> 4) >> 2)) - 1) &
((((((0x3ff000) >> 16)) >> 4) >> 2))) ^ ((
((((0x3ff000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff000) >>
16)) >> 4))) - 1) & ((((((0x3ff000) >> 16)) >>
4)))) ^ ((((((0x3ff000) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff000) >>
16)))) - 1) & (((((0x3ff000) >> 16))))) ^ (((((0x3ff000
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0x3ff000) >> 16))) >> 2)) - 1) & ((((((
0x3ff000) >> 16))) >> 2))) ^ ((((((0x3ff000) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x3ff000) >> 16))))) - 1) & ((((((0x3ff000
) >> 16)))))) ^ ((((((0x3ff000) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x3ff000))) - 1) &
(((0x3ff000)))) ^ (((0x3ff000))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0x3ff000)) >> 8)) - 1) & ((((0x3ff000
)) >> 8))) ^ ((((0x3ff000)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3ff000)) >> 8) >>
4)) - 1) & (((((0x3ff000)) >> 8) >> 4))) ^ (
((((0x3ff000)) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x3ff000)) >> 8) >> 4
) >> 2)) - 1) & ((((((0x3ff000)) >> 8) >>
4) >> 2))) ^ ((((((0x3ff000)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff000
)) >> 8) >> 4))) - 1) & ((((((0x3ff000)) >>
8) >> 4)))) ^ ((((((0x3ff000)) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff000
)) >> 8))) - 1) & (((((0x3ff000)) >> 8)))) ^ (
((((0x3ff000)) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0x3ff000)) >> 8)) >> 2)) - 1) &
((((((0x3ff000)) >> 8)) >> 2))) ^ ((((((0x3ff000
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x3ff000)) >> 8)))) - 1) & ((
((((0x3ff000)) >> 8))))) ^ ((((((0x3ff000)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff000
)))) - 1) & ((((0x3ff000))))) ^ ((((0x3ff000)))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x3ff000))) >> 4)
) - 1) & (((((0x3ff000))) >> 4))) ^ (((((0x3ff000))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0x3ff000))) >> 4) >> 2)) - 1) & ((((((0x3ff000
))) >> 4) >> 2))) ^ ((((((0x3ff000))) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0x3ff000))) >> 4))) - 1) & ((((((0x3ff000)))
>> 4)))) ^ ((((((0x3ff000))) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff000))))) - 1) &
(((((0x3ff000)))))) ^ (((((0x3ff000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0x3ff000)))) >> 2)) - 1) &
((((((0x3ff000)))) >> 2))) ^ ((((((0x3ff000)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff000
)))))) - 1) & ((((((0x3ff000))))))) ^ ((((((0x3ff000)))))
))) >> (1)) != 0) ? 1 : 0))))))
| SA2400_SYNB_L_NORMAL((2) << ((((u_long)((((((0xc00)) - 1) & ((0xc00))) ^
((0xc00)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc00
) >> 16)) - 1) & (((0xc00) >> 16))) ^ (((0xc00
) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((
((0xc00) >> 16) >> 8)) - 1) & ((((0xc00) >>
16) >> 8))) ^ ((((0xc00) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xc00) >> 16) >>
8) >> 4)) - 1) & (((((0xc00) >> 16) >>
8) >> 4))) ^ (((((0xc00) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc00) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0xc00
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xc00) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc00) >> 16
) >> 8) >> 4))) - 1) & ((((((0xc00) >> 16
) >> 8) >> 4)))) ^ ((((((0xc00) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xc00) >> 16) >> 8))) - 1) & (((((0xc00
) >> 16) >> 8)))) ^ (((((0xc00) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc00)
>> 16) >> 8)) >> 2)) - 1) & ((((((0xc00
) >> 16) >> 8)) >> 2))) ^ ((((((0xc00) >>
16) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)((((((((((0xc00) >> 16) >> 8)))) - 1
) & ((((((0xc00) >> 16) >> 8))))) ^ ((((((0xc00
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0xc00) >> 16))) - 1) & ((((0xc00
) >> 16)))) ^ ((((0xc00) >> 16))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0xc00) >> 16)) >>
4)) - 1) & (((((0xc00) >> 16)) >> 4))) ^ (((
((0xc00) >> 16)) >> 4)))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0xc00) >> 16)) >> 4) >>
2)) - 1) & ((((((0xc00) >> 16)) >> 4) >>
2))) ^ ((((((0xc00) >> 16)) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc00) >>
16)) >> 4))) - 1) & ((((((0xc00) >> 16)) >>
4)))) ^ ((((((0xc00) >> 16)) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc00) >> 16)
))) - 1) & (((((0xc00) >> 16))))) ^ (((((0xc00) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc00
) >> 16))) >> 2)) - 1) & ((((((0xc00) >>
16))) >> 2))) ^ ((((((0xc00) >> 16))) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc00
) >> 16))))) - 1) & ((((((0xc00) >> 16)))))) ^
((((((0xc00) >> 16))))))) >> (1)) != 0) ? 1 : 0)
))) : ((((u_long)(((((((0xc00))) - 1) & (((0xc00)))) ^ ((
(0xc00))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc00
)) >> 8)) - 1) & ((((0xc00)) >> 8))) ^ ((((0xc00
)) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((((
(((0xc00)) >> 8) >> 4)) - 1) & (((((0xc00)) >>
8) >> 4))) ^ (((((0xc00)) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc00)) >> 8) >>
4) >> 2)) - 1) & ((((((0xc00)) >> 8) >>
4) >> 2))) ^ ((((((0xc00)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc00
)) >> 8) >> 4))) - 1) & ((((((0xc00)) >>
8) >> 4)))) ^ ((((((0xc00)) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc00))
>> 8))) - 1) & (((((0xc00)) >> 8)))) ^ (((((
0xc00)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)
((((((((((0xc00)) >> 8)) >> 2)) - 1) & ((((((
0xc00)) >> 8)) >> 2))) ^ ((((((0xc00)) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0xc00)) >> 8)))) - 1) & ((((((0xc00)) >>
8))))) ^ ((((((0xc00)) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0xc00)))) - 1) & ((((0xc00
))))) ^ ((((0xc00)))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0xc00))) >> 4)) - 1) & (((((0xc00))) >>
4))) ^ (((((0xc00))) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)((((((((((0xc00))) >> 4) >> 2)) - 1) &
((((((0xc00))) >> 4) >> 2))) ^ ((((((0xc00))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc00))) >> 4))) - 1) & ((((((0xc00))) >>
4)))) ^ ((((((0xc00))) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0xc00))))) - 1) & (((((0xc00
)))))) ^ (((((0xc00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xc00)))) >> 2)) - 1) & ((((((0xc00)))) >>
2))) ^ ((((((0xc00)))) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc00)))))) - 1) & ((((((0xc00
))))))) ^ ((((((0xc00)))))))) >> (1)) != 0) ? 1 : 0))))
))
|
4242 SA2400_SYNB_ON(1<<9) | SA2400_SYNB_ONE(1<<8) |
4243 LSHIFT(80, SA2400_SYNB_FC_MASK)((80) << ((((u_long)((((((0xff)) - 1) & ((0xff))) ^
((0xff)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xff
) >> 16)) - 1) & (((0xff) >> 16))) ^ (((0xff)
>> 16)))) >> (8)) != 0) ? 8 + ((((u_long)(((((((
(0xff) >> 16) >> 8)) - 1) & ((((0xff) >>
16) >> 8))) ^ ((((0xff) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >> 16) >>
8) >> 4)) - 1) & (((((0xff) >> 16) >> 8
) >> 4))) ^ (((((0xff) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0xff
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xff) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16
) >> 8) >> 4))) - 1) & ((((((0xff) >> 16
) >> 8) >> 4)))) ^ ((((((0xff) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xff) >> 16) >> 8))) - 1) & (((((0xff
) >> 16) >> 8)))) ^ (((((0xff) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >>
16) >> 8)) >> 2)) - 1) & ((((((0xff) >>
16) >> 8)) >> 2))) ^ ((((((0xff) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff) >> 16) >> 8)))) - 1) & (((((
(0xff) >> 16) >> 8))))) ^ ((((((0xff) >> 16
) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff) >> 16))) - 1) & ((((0xff) >> 16
)))) ^ ((((0xff) >> 16))))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xff) >> 16)) >> 4)) - 1) &
(((((0xff) >> 16)) >> 4))) ^ (((((0xff) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xff) >> 16)) >> 4) >> 2)) - 1) &
((((((0xff) >> 16)) >> 4) >> 2))) ^ ((((((
0xff) >> 16)) >> 4) >> 2)))) >> (1)) !=
0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16)) >>
4))) - 1) & ((((((0xff) >> 16)) >> 4)))) ^ (
(((((0xff) >> 16)) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0xff) >> 16)))) - 1) &
(((((0xff) >> 16))))) ^ (((((0xff) >> 16)))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >> 16))) >>
2)) - 1) & ((((((0xff) >> 16))) >> 2))) ^ ((
((((0xff) >> 16))) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xff) >> 16))))) - 1) &
((((((0xff) >> 16)))))) ^ ((((((0xff) >> 16)))))
)) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xff))
) - 1) & (((0xff)))) ^ (((0xff))))) >> (8)) != 0) ?
8 + ((((u_long)((((((((0xff)) >> 8)) - 1) & ((((0xff
)) >> 8))) ^ ((((0xff)) >> 8)))) >> (4)) !=
0) ? 4 + ((((u_long)(((((((((0xff)) >> 8) >> 4))
- 1) & (((((0xff)) >> 8) >> 4))) ^ (((((0xff
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff)) >> 8) >> 4) >> 2)) - 1) &
((((((0xff)) >> 8) >> 4) >> 2))) ^ ((((((0xff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xff)) >> 8) >> 4
))) - 1) & ((((((0xff)) >> 8) >> 4)))) ^ ((((
((0xff)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xff)) >> 8))) - 1) & ((
(((0xff)) >> 8)))) ^ (((((0xff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff)) >> 8)) >>
2)) - 1) & ((((((0xff)) >> 8)) >> 2))) ^ (((
(((0xff)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xff)) >> 8)))) - 1) &
((((((0xff)) >> 8))))) ^ ((((((0xff)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff))))
- 1) & ((((0xff))))) ^ ((((0xff)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xff))) >> 4)) - 1) & (
((((0xff))) >> 4))) ^ (((((0xff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff))) >> 4) >>
2)) - 1) & ((((((0xff))) >> 4) >> 2))) ^ (((
(((0xff))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xff))) >> 4))) - 1) &
((((((0xff))) >> 4)))) ^ ((((((0xff))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff))))
) - 1) & (((((0xff)))))) ^ (((((0xff))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xff)))) >> 2)) - 1) &
((((((0xff)))) >> 2))) ^ ((((((0xff)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff))))
)) - 1) & ((((((0xff))))))) ^ ((((((0xff)))))))) >>
(1)) != 0) ? 1 : 0))))))
; /* agrees w/ SA2400_SYNA_FM = 0 */
4244
4245 sync = SA2400_SYNC_CP_NORMAL((2) << ((((u_long)((((((0xc0)) - 1) & ((0xc0))) ^ (
(0xc0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xc0)
>> 16)) - 1) & (((0xc0) >> 16))) ^ (((0xc0) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xc0) >>
16) >> 8)) - 1) & ((((0xc0) >> 16) >> 8
))) ^ ((((0xc0) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0) >> 16) >> 8) >>
4)) - 1) & (((((0xc0) >> 16) >> 8) >> 4
))) ^ (((((0xc0) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xc0) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xc0) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xc0) >> 16) >>
8) >> 4))) - 1) & ((((((0xc0) >> 16) >>
8) >> 4)))) ^ ((((((0xc0) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0
) >> 16) >> 8))) - 1) & (((((0xc0) >> 16
) >> 8)))) ^ (((((0xc0) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xc0) >> 16) >>
8)) >> 2))) ^ ((((((0xc0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0
) >> 16) >> 8)))) - 1) & ((((((0xc0) >>
16) >> 8))))) ^ ((((((0xc0) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0)
>> 16))) - 1) & ((((0xc0) >> 16)))) ^ ((((0xc0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xc0) >> 16)) >> 4)) - 1) & (((((0xc0) >>
16)) >> 4))) ^ (((((0xc0) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xc0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xc0) >>
16)) >> 4) >> 2))) ^ ((((((0xc0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xc0) >> 16)) >> 4))) - 1) & ((((((
0xc0) >> 16)) >> 4)))) ^ ((((((0xc0) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xc0) >> 16)))) - 1) & (((((0xc0) >>
16))))) ^ (((((0xc0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xc0) >> 16))) >> 2)) -
1) & ((((((0xc0) >> 16))) >> 2))) ^ ((((((0xc0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xc0) >> 16))))) - 1) & (((((
(0xc0) >> 16)))))) ^ ((((((0xc0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xc0))) - 1) &
(((0xc0)))) ^ (((0xc0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xc0)) >> 8)) - 1) & ((((0xc0)) >> 8
))) ^ ((((0xc0)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0xc0)) >> 8) >> 4)) - 1) & (
((((0xc0)) >> 8) >> 4))) ^ (((((0xc0)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xc0)) >> 8) >> 4) >> 2)) - 1) & (((
(((0xc0)) >> 8) >> 4) >> 2))) ^ ((((((0xc0)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xc0)) >> 8) >> 4)
)) - 1) & ((((((0xc0)) >> 8) >> 4)))) ^ (((((
(0xc0)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xc0)) >> 8))) - 1) & ((
(((0xc0)) >> 8)))) ^ (((((0xc0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0)) >> 8)) >>
2)) - 1) & ((((((0xc0)) >> 8)) >> 2))) ^ (((
(((0xc0)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0)) >> 8)))) - 1) &
((((((0xc0)) >> 8))))) ^ ((((((0xc0)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xc0))))
- 1) & ((((0xc0))))) ^ ((((0xc0)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xc0))) >> 4)) - 1) & (
((((0xc0))) >> 4))) ^ (((((0xc0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xc0))) >> 4) >>
2)) - 1) & ((((((0xc0))) >> 4) >> 2))) ^ (((
(((0xc0))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xc0))) >> 4))) - 1) &
((((((0xc0))) >> 4)))) ^ ((((((0xc0))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xc0))))
) - 1) & (((((0xc0)))))) ^ (((((0xc0))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xc0)))) >> 2)) - 1) &
((((((0xc0)))) >> 2))) ^ ((((((0xc0)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xc0))))
)) - 1) & ((((((0xc0))))))) ^ ((((((0xc0)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
4246
4247 if ((rc = rtw_rf_macwrite(sc, SA2400_SYNA0, syna)) != 0)
4248 return rc;
4249 if ((rc = rtw_rf_macwrite(sc, SA2400_SYNB1, synb)) != 0)
4250 return rc;
4251 if ((rc = rtw_rf_macwrite(sc, SA2400_SYNC2, sync)) != 0)
4252 return rc;
4253 return rtw_rf_macwrite(sc, SA2400_SYND3, 0x0);
4254}
4255
4256int
4257rtw_sa2400_pwrstate(struct rtw_softc *sc, enum rtw_pwrstate power)
4258{
4259 u_int32_t opmode;
4260 opmode = SA2400_OPMODE_DEFAULTS((1<<8) | (1<<6) | (1<<9) | (1<<12) |
((3) << ((((u_long)((((((0x38000)) - 1) & ((0x38000
))) ^ ((0x38000)))) >> (16)) != 0) ? 16 + ((((u_long)((
(((((0x38000) >> 16)) - 1) & (((0x38000) >> 16
))) ^ (((0x38000) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0x38000) >> 16) >> 8)) - 1) &
((((0x38000) >> 16) >> 8))) ^ ((((0x38000) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0x38000) >> 16) >> 8) >> 4)) - 1) &
(((((0x38000) >> 16) >> 8) >> 4))) ^ (((((
0x38000) >> 16) >> 8) >> 4)))) >> (2)
) != 0) ? 2 + ((((u_long)((((((((((0x38000) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x38000) >>
16) >> 8) >> 4) >> 2))) ^ ((((((0x38000) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x38000) >> 16) >>
8) >> 4))) - 1) & ((((((0x38000) >> 16) >>
8) >> 4)))) ^ ((((((0x38000) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x38000
) >> 16) >> 8))) - 1) & (((((0x38000) >>
16) >> 8)))) ^ (((((0x38000) >> 16) >> 8))
))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x38000) >>
16) >> 8)) >> 2)) - 1) & ((((((0x38000) >>
16) >> 8)) >> 2))) ^ ((((((0x38000) >> 16)
>> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x38000) >> 16) >> 8)))) - 1)
& ((((((0x38000) >> 16) >> 8))))) ^ ((((((0x38000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x38000) >> 16))) - 1) & (((
(0x38000) >> 16)))) ^ ((((0x38000) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x38000) >> 16)) >>
4)) - 1) & (((((0x38000) >> 16)) >> 4))) ^ (
((((0x38000) >> 16)) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x38000) >> 16)) >> 4
) >> 2)) - 1) & ((((((0x38000) >> 16)) >>
4) >> 2))) ^ ((((((0x38000) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x38000
) >> 16)) >> 4))) - 1) & ((((((0x38000) >>
16)) >> 4)))) ^ ((((((0x38000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x38000
) >> 16)))) - 1) & (((((0x38000) >> 16))))) ^
(((((0x38000) >> 16)))))) >> (2)) != 0) ? 2 + ((
((u_long)((((((((((0x38000) >> 16))) >> 2)) - 1) &
((((((0x38000) >> 16))) >> 2))) ^ ((((((0x38000)
>> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x38000) >> 16))))) - 1) & ((
((((0x38000) >> 16)))))) ^ ((((((0x38000) >> 16))
))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x38000
))) - 1) & (((0x38000)))) ^ (((0x38000))))) >> (8))
!= 0) ? 8 + ((((u_long)((((((((0x38000)) >> 8)) - 1) &
((((0x38000)) >> 8))) ^ ((((0x38000)) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x38000)) >> 8) >>
4)) - 1) & (((((0x38000)) >> 8) >> 4))) ^ ((
(((0x38000)) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x38000)) >> 8) >> 4) >>
2)) - 1) & ((((((0x38000)) >> 8) >> 4) >>
2))) ^ ((((((0x38000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x38000
)) >> 8) >> 4))) - 1) & ((((((0x38000)) >>
8) >> 4)))) ^ ((((((0x38000)) >> 8) >> 4))
))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x38000
)) >> 8))) - 1) & (((((0x38000)) >> 8)))) ^ (
((((0x38000)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x38000)) >> 8)) >> 2)) - 1) & (((
(((0x38000)) >> 8)) >> 2))) ^ ((((((0x38000)) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x38000)) >> 8)))) - 1) & ((((((0x38000)
) >> 8))))) ^ ((((((0x38000)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x38000)))) - 1) &
((((0x38000))))) ^ ((((0x38000)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x38000))) >> 4)) - 1) & (((
((0x38000))) >> 4))) ^ (((((0x38000))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x38000))) >> 4)
>> 2)) - 1) & ((((((0x38000))) >> 4) >>
2))) ^ ((((((0x38000))) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x38000))) >>
4))) - 1) & ((((((0x38000))) >> 4)))) ^ ((((((0x38000
))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x38000))))) - 1) & (((((0x38000)))))) ^ (((((0x38000
))))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x38000
)))) >> 2)) - 1) & ((((((0x38000)))) >> 2))) ^
((((((0x38000)))) >> 2)))) >> (1)) != 0) ? 1 : 0
) : ((((u_long)((((((((((0x38000)))))) - 1) & ((((((0x38000
))))))) ^ ((((((0x38000)))))))) >> (1)) != 0) ? 1 : 0))
)))))
;
4261 switch (power) {
4262 case RTW_ON:
4263 opmode |= SA2400_OPMODE_MODE_TXRX((1) << ((((u_long)((((((0xf)) - 1) & ((0xf))) ^ ((
0xf)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xf) >>
16)) - 1) & (((0xf) >> 16))) ^ (((0xf) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xf) >>
16) >> 8)) - 1) & ((((0xf) >> 16) >> 8
))) ^ ((((0xf) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xf) >> 16) >> 8) >>
4)) - 1) & (((((0xf) >> 16) >> 8) >> 4
))) ^ (((((0xf) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xf) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xf) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16) >> 8
) >> 4))) - 1) & ((((((0xf) >> 16) >> 8
) >> 4)))) ^ ((((((0xf) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf
) >> 16) >> 8))) - 1) & (((((0xf) >> 16
) >> 8)))) ^ (((((0xf) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8)) >> 2)) - 1) & ((((((0xf) >> 16) >>
8)) >> 2))) ^ ((((((0xf) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16) >> 8)))) - 1) & ((((((0xf) >> 16
) >> 8))))) ^ ((((((0xf) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf) >> 16)
)) - 1) & ((((0xf) >> 16)))) ^ ((((0xf) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf) >>
16)) >> 4)) - 1) & (((((0xf) >> 16)) >>
4))) ^ (((((0xf) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xf) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xf) >> 16)) >> 4)
>> 2))) ^ ((((((0xf) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16)) >> 4))) - 1) & ((((((0xf) >> 16
)) >> 4)))) ^ ((((((0xf) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf) >> 16)
))) - 1) & (((((0xf) >> 16))))) ^ (((((0xf) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf)
>> 16))) >> 2)) - 1) & ((((((0xf) >> 16
))) >> 2))) ^ ((((((0xf) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16)
)))) - 1) & ((((((0xf) >> 16)))))) ^ ((((((0xf) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xf))) - 1) & (((0xf)))) ^ (((0xf))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xf)) >> 8)) - 1) & ((
((0xf)) >> 8))) ^ ((((0xf)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xf)) >> 8) >> 4
)) - 1) & (((((0xf)) >> 8) >> 4))) ^ (((((0xf
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf)) >> 8) >> 4) >> 2)) - 1) &
((((((0xf)) >> 8) >> 4) >> 2))) ^ ((((((0xf
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xf)) >> 8) >> 4
))) - 1) & ((((((0xf)) >> 8) >> 4)))) ^ (((((
(0xf)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xf)) >> 8))) - 1) & (((((
0xf)) >> 8)))) ^ (((((0xf)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xf)) >> 8)) >>
2)) - 1) & ((((((0xf)) >> 8)) >> 2))) ^ ((((
((0xf)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)) >> 8)))) - 1) & ((
((((0xf)) >> 8))))) ^ ((((((0xf)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf)))) - 1) &
((((0xf))))) ^ ((((0xf)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf))) >> 4)) - 1) & (((((0xf))) >>
4))) ^ (((((0xf))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf))) >> 4) >> 2)) - 1) &
((((((0xf))) >> 4) >> 2))) ^ ((((((0xf))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xf))) >> 4))) - 1) & ((((((0xf))) >>
4)))) ^ ((((((0xf))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xf))))) - 1) & (((((0xf))))
)) ^ (((((0xf))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf)))) >> 2)) - 1) & ((((((0xf)))) >>
2))) ^ ((((((0xf)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)))))) - 1) & ((((((0xf))))
))) ^ ((((((0xf)))))))) >> (1)) != 0) ? 1 : 0))))))
;
4264 break;
4265 case RTW_SLEEP:
4266 opmode |= SA2400_OPMODE_MODE_WAIT((2) << ((((u_long)((((((0xf)) - 1) & ((0xf))) ^ ((
0xf)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xf) >>
16)) - 1) & (((0xf) >> 16))) ^ (((0xf) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xf) >>
16) >> 8)) - 1) & ((((0xf) >> 16) >> 8
))) ^ ((((0xf) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xf) >> 16) >> 8) >>
4)) - 1) & (((((0xf) >> 16) >> 8) >> 4
))) ^ (((((0xf) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xf) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xf) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16) >> 8
) >> 4))) - 1) & ((((((0xf) >> 16) >> 8
) >> 4)))) ^ ((((((0xf) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf
) >> 16) >> 8))) - 1) & (((((0xf) >> 16
) >> 8)))) ^ (((((0xf) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8)) >> 2)) - 1) & ((((((0xf) >> 16) >>
8)) >> 2))) ^ ((((((0xf) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16) >> 8)))) - 1) & ((((((0xf) >> 16
) >> 8))))) ^ ((((((0xf) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf) >> 16)
)) - 1) & ((((0xf) >> 16)))) ^ ((((0xf) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf) >>
16)) >> 4)) - 1) & (((((0xf) >> 16)) >>
4))) ^ (((((0xf) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xf) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xf) >> 16)) >> 4)
>> 2))) ^ ((((((0xf) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16)) >> 4))) - 1) & ((((((0xf) >> 16
)) >> 4)))) ^ ((((((0xf) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf) >> 16)
))) - 1) & (((((0xf) >> 16))))) ^ (((((0xf) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf)
>> 16))) >> 2)) - 1) & ((((((0xf) >> 16
))) >> 2))) ^ ((((((0xf) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16)
)))) - 1) & ((((((0xf) >> 16)))))) ^ ((((((0xf) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xf))) - 1) & (((0xf)))) ^ (((0xf))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xf)) >> 8)) - 1) & ((
((0xf)) >> 8))) ^ ((((0xf)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xf)) >> 8) >> 4
)) - 1) & (((((0xf)) >> 8) >> 4))) ^ (((((0xf
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf)) >> 8) >> 4) >> 2)) - 1) &
((((((0xf)) >> 8) >> 4) >> 2))) ^ ((((((0xf
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xf)) >> 8) >> 4
))) - 1) & ((((((0xf)) >> 8) >> 4)))) ^ (((((
(0xf)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xf)) >> 8))) - 1) & (((((
0xf)) >> 8)))) ^ (((((0xf)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xf)) >> 8)) >>
2)) - 1) & ((((((0xf)) >> 8)) >> 2))) ^ ((((
((0xf)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)) >> 8)))) - 1) & ((
((((0xf)) >> 8))))) ^ ((((((0xf)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf)))) - 1) &
((((0xf))))) ^ ((((0xf)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf))) >> 4)) - 1) & (((((0xf))) >>
4))) ^ (((((0xf))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf))) >> 4) >> 2)) - 1) &
((((((0xf))) >> 4) >> 2))) ^ ((((((0xf))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xf))) >> 4))) - 1) & ((((((0xf))) >>
4)))) ^ ((((((0xf))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xf))))) - 1) & (((((0xf))))
)) ^ (((((0xf))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf)))) >> 2)) - 1) & ((((((0xf)))) >>
2))) ^ ((((((0xf)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)))))) - 1) & ((((((0xf))))
))) ^ ((((((0xf)))))))) >> (1)) != 0) ? 1 : 0))))))
;
4267 break;
4268 case RTW_OFF:
4269 opmode |= SA2400_OPMODE_MODE_SLEEP((0) << ((((u_long)((((((0xf)) - 1) & ((0xf))) ^ ((
0xf)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xf) >>
16)) - 1) & (((0xf) >> 16))) ^ (((0xf) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xf) >>
16) >> 8)) - 1) & ((((0xf) >> 16) >> 8
))) ^ ((((0xf) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xf) >> 16) >> 8) >>
4)) - 1) & (((((0xf) >> 16) >> 8) >> 4
))) ^ (((((0xf) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xf) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xf) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16) >> 8
) >> 4))) - 1) & ((((((0xf) >> 16) >> 8
) >> 4)))) ^ ((((((0xf) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf
) >> 16) >> 8))) - 1) & (((((0xf) >> 16
) >> 8)))) ^ (((((0xf) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8)) >> 2)) - 1) & ((((((0xf) >> 16) >>
8)) >> 2))) ^ ((((((0xf) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16) >> 8)))) - 1) & ((((((0xf) >> 16
) >> 8))))) ^ ((((((0xf) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf) >> 16)
)) - 1) & ((((0xf) >> 16)))) ^ ((((0xf) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf) >>
16)) >> 4)) - 1) & (((((0xf) >> 16)) >>
4))) ^ (((((0xf) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xf) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xf) >> 16)) >> 4)
>> 2))) ^ ((((((0xf) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16)) >> 4))) - 1) & ((((((0xf) >> 16
)) >> 4)))) ^ ((((((0xf) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf) >> 16)
))) - 1) & (((((0xf) >> 16))))) ^ (((((0xf) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf)
>> 16))) >> 2)) - 1) & ((((((0xf) >> 16
))) >> 2))) ^ ((((((0xf) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16)
)))) - 1) & ((((((0xf) >> 16)))))) ^ ((((((0xf) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xf))) - 1) & (((0xf)))) ^ (((0xf))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xf)) >> 8)) - 1) & ((
((0xf)) >> 8))) ^ ((((0xf)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xf)) >> 8) >> 4
)) - 1) & (((((0xf)) >> 8) >> 4))) ^ (((((0xf
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf)) >> 8) >> 4) >> 2)) - 1) &
((((((0xf)) >> 8) >> 4) >> 2))) ^ ((((((0xf
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xf)) >> 8) >> 4
))) - 1) & ((((((0xf)) >> 8) >> 4)))) ^ (((((
(0xf)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xf)) >> 8))) - 1) & (((((
0xf)) >> 8)))) ^ (((((0xf)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xf)) >> 8)) >>
2)) - 1) & ((((((0xf)) >> 8)) >> 2))) ^ ((((
((0xf)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)) >> 8)))) - 1) & ((
((((0xf)) >> 8))))) ^ ((((((0xf)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf)))) - 1) &
((((0xf))))) ^ ((((0xf)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf))) >> 4)) - 1) & (((((0xf))) >>
4))) ^ (((((0xf))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf))) >> 4) >> 2)) - 1) &
((((((0xf))) >> 4) >> 2))) ^ ((((((0xf))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xf))) >> 4))) - 1) & ((((((0xf))) >>
4)))) ^ ((((((0xf))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xf))))) - 1) & (((((0xf))))
)) ^ (((((0xf))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf)))) >> 2)) - 1) & ((((((0xf)))) >>
2))) ^ ((((((0xf)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)))))) - 1) & ((((((0xf))))
))) ^ ((((((0xf)))))))) >> (1)) != 0) ? 1 : 0))))))
;
4270 break;
4271 }
4272
4273 if (sc->sc_flags & RTW_F_DIGPHY0x00000002)
4274 opmode |= SA2400_OPMODE_DIGIN(1<<7);
4275
4276 return rtw_rf_macwrite(sc, SA2400_OPMODE4, opmode);
4277}
4278
4279int
4280rtw_sa2400_vcocal_start(struct rtw_softc *sc, int start)
4281{
4282 u_int32_t opmode;
4283
4284 opmode = SA2400_OPMODE_DEFAULTS((1<<8) | (1<<6) | (1<<9) | (1<<12) |
((3) << ((((u_long)((((((0x38000)) - 1) & ((0x38000
))) ^ ((0x38000)))) >> (16)) != 0) ? 16 + ((((u_long)((
(((((0x38000) >> 16)) - 1) & (((0x38000) >> 16
))) ^ (((0x38000) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0x38000) >> 16) >> 8)) - 1) &
((((0x38000) >> 16) >> 8))) ^ ((((0x38000) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0x38000) >> 16) >> 8) >> 4)) - 1) &
(((((0x38000) >> 16) >> 8) >> 4))) ^ (((((
0x38000) >> 16) >> 8) >> 4)))) >> (2)
) != 0) ? 2 + ((((u_long)((((((((((0x38000) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x38000) >>
16) >> 8) >> 4) >> 2))) ^ ((((((0x38000) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x38000) >> 16) >>
8) >> 4))) - 1) & ((((((0x38000) >> 16) >>
8) >> 4)))) ^ ((((((0x38000) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x38000
) >> 16) >> 8))) - 1) & (((((0x38000) >>
16) >> 8)))) ^ (((((0x38000) >> 16) >> 8))
))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x38000) >>
16) >> 8)) >> 2)) - 1) & ((((((0x38000) >>
16) >> 8)) >> 2))) ^ ((((((0x38000) >> 16)
>> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x38000) >> 16) >> 8)))) - 1)
& ((((((0x38000) >> 16) >> 8))))) ^ ((((((0x38000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x38000) >> 16))) - 1) & (((
(0x38000) >> 16)))) ^ ((((0x38000) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x38000) >> 16)) >>
4)) - 1) & (((((0x38000) >> 16)) >> 4))) ^ (
((((0x38000) >> 16)) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x38000) >> 16)) >> 4
) >> 2)) - 1) & ((((((0x38000) >> 16)) >>
4) >> 2))) ^ ((((((0x38000) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x38000
) >> 16)) >> 4))) - 1) & ((((((0x38000) >>
16)) >> 4)))) ^ ((((((0x38000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x38000
) >> 16)))) - 1) & (((((0x38000) >> 16))))) ^
(((((0x38000) >> 16)))))) >> (2)) != 0) ? 2 + ((
((u_long)((((((((((0x38000) >> 16))) >> 2)) - 1) &
((((((0x38000) >> 16))) >> 2))) ^ ((((((0x38000)
>> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x38000) >> 16))))) - 1) & ((
((((0x38000) >> 16)))))) ^ ((((((0x38000) >> 16))
))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x38000
))) - 1) & (((0x38000)))) ^ (((0x38000))))) >> (8))
!= 0) ? 8 + ((((u_long)((((((((0x38000)) >> 8)) - 1) &
((((0x38000)) >> 8))) ^ ((((0x38000)) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x38000)) >> 8) >>
4)) - 1) & (((((0x38000)) >> 8) >> 4))) ^ ((
(((0x38000)) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x38000)) >> 8) >> 4) >>
2)) - 1) & ((((((0x38000)) >> 8) >> 4) >>
2))) ^ ((((((0x38000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x38000
)) >> 8) >> 4))) - 1) & ((((((0x38000)) >>
8) >> 4)))) ^ ((((((0x38000)) >> 8) >> 4))
))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x38000
)) >> 8))) - 1) & (((((0x38000)) >> 8)))) ^ (
((((0x38000)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x38000)) >> 8)) >> 2)) - 1) & (((
(((0x38000)) >> 8)) >> 2))) ^ ((((((0x38000)) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x38000)) >> 8)))) - 1) & ((((((0x38000)
) >> 8))))) ^ ((((((0x38000)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x38000)))) - 1) &
((((0x38000))))) ^ ((((0x38000)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x38000))) >> 4)) - 1) & (((
((0x38000))) >> 4))) ^ (((((0x38000))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x38000))) >> 4)
>> 2)) - 1) & ((((((0x38000))) >> 4) >>
2))) ^ ((((((0x38000))) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x38000))) >>
4))) - 1) & ((((((0x38000))) >> 4)))) ^ ((((((0x38000
))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x38000))))) - 1) & (((((0x38000)))))) ^ (((((0x38000
))))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x38000
)))) >> 2)) - 1) & ((((((0x38000)))) >> 2))) ^
((((((0x38000)))) >> 2)))) >> (1)) != 0) ? 1 : 0
) : ((((u_long)((((((((((0x38000)))))) - 1) & ((((((0x38000
))))))) ^ ((((((0x38000)))))))) >> (1)) != 0) ? 1 : 0))
)))))
;
4285 if (start)
4286 opmode |= SA2400_OPMODE_MODE_VCOCALIB((8) << ((((u_long)((((((0xf)) - 1) & ((0xf))) ^ ((
0xf)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xf) >>
16)) - 1) & (((0xf) >> 16))) ^ (((0xf) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xf) >>
16) >> 8)) - 1) & ((((0xf) >> 16) >> 8
))) ^ ((((0xf) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xf) >> 16) >> 8) >>
4)) - 1) & (((((0xf) >> 16) >> 8) >> 4
))) ^ (((((0xf) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xf) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xf) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16) >> 8
) >> 4))) - 1) & ((((((0xf) >> 16) >> 8
) >> 4)))) ^ ((((((0xf) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf
) >> 16) >> 8))) - 1) & (((((0xf) >> 16
) >> 8)))) ^ (((((0xf) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8)) >> 2)) - 1) & ((((((0xf) >> 16) >>
8)) >> 2))) ^ ((((((0xf) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16) >> 8)))) - 1) & ((((((0xf) >> 16
) >> 8))))) ^ ((((((0xf) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf) >> 16)
)) - 1) & ((((0xf) >> 16)))) ^ ((((0xf) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf) >>
16)) >> 4)) - 1) & (((((0xf) >> 16)) >>
4))) ^ (((((0xf) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xf) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xf) >> 16)) >> 4)
>> 2))) ^ ((((((0xf) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16)) >> 4))) - 1) & ((((((0xf) >> 16
)) >> 4)))) ^ ((((((0xf) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf) >> 16)
))) - 1) & (((((0xf) >> 16))))) ^ (((((0xf) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf)
>> 16))) >> 2)) - 1) & ((((((0xf) >> 16
))) >> 2))) ^ ((((((0xf) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16)
)))) - 1) & ((((((0xf) >> 16)))))) ^ ((((((0xf) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xf))) - 1) & (((0xf)))) ^ (((0xf))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xf)) >> 8)) - 1) & ((
((0xf)) >> 8))) ^ ((((0xf)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xf)) >> 8) >> 4
)) - 1) & (((((0xf)) >> 8) >> 4))) ^ (((((0xf
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf)) >> 8) >> 4) >> 2)) - 1) &
((((((0xf)) >> 8) >> 4) >> 2))) ^ ((((((0xf
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xf)) >> 8) >> 4
))) - 1) & ((((((0xf)) >> 8) >> 4)))) ^ (((((
(0xf)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xf)) >> 8))) - 1) & (((((
0xf)) >> 8)))) ^ (((((0xf)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xf)) >> 8)) >>
2)) - 1) & ((((((0xf)) >> 8)) >> 2))) ^ ((((
((0xf)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)) >> 8)))) - 1) & ((
((((0xf)) >> 8))))) ^ ((((((0xf)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf)))) - 1) &
((((0xf))))) ^ ((((0xf)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf))) >> 4)) - 1) & (((((0xf))) >>
4))) ^ (((((0xf))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf))) >> 4) >> 2)) - 1) &
((((((0xf))) >> 4) >> 2))) ^ ((((((0xf))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xf))) >> 4))) - 1) & ((((((0xf))) >>
4)))) ^ ((((((0xf))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xf))))) - 1) & (((((0xf))))
)) ^ (((((0xf))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf)))) >> 2)) - 1) & ((((((0xf)))) >>
2))) ^ ((((((0xf)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)))))) - 1) & ((((((0xf))))
))) ^ ((((((0xf)))))))) >> (1)) != 0) ? 1 : 0))))))
;
4287 else
4288 opmode |= SA2400_OPMODE_MODE_SLEEP((0) << ((((u_long)((((((0xf)) - 1) & ((0xf))) ^ ((
0xf)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xf) >>
16)) - 1) & (((0xf) >> 16))) ^ (((0xf) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xf) >>
16) >> 8)) - 1) & ((((0xf) >> 16) >> 8
))) ^ ((((0xf) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xf) >> 16) >> 8) >>
4)) - 1) & (((((0xf) >> 16) >> 8) >> 4
))) ^ (((((0xf) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xf) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xf) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16) >> 8
) >> 4))) - 1) & ((((((0xf) >> 16) >> 8
) >> 4)))) ^ ((((((0xf) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf
) >> 16) >> 8))) - 1) & (((((0xf) >> 16
) >> 8)))) ^ (((((0xf) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8)) >> 2)) - 1) & ((((((0xf) >> 16) >>
8)) >> 2))) ^ ((((((0xf) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16) >> 8)))) - 1) & ((((((0xf) >> 16
) >> 8))))) ^ ((((((0xf) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf) >> 16)
)) - 1) & ((((0xf) >> 16)))) ^ ((((0xf) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf) >>
16)) >> 4)) - 1) & (((((0xf) >> 16)) >>
4))) ^ (((((0xf) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xf) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xf) >> 16)) >> 4)
>> 2))) ^ ((((((0xf) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16)) >> 4))) - 1) & ((((((0xf) >> 16
)) >> 4)))) ^ ((((((0xf) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf) >> 16)
))) - 1) & (((((0xf) >> 16))))) ^ (((((0xf) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf)
>> 16))) >> 2)) - 1) & ((((((0xf) >> 16
))) >> 2))) ^ ((((((0xf) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16)
)))) - 1) & ((((((0xf) >> 16)))))) ^ ((((((0xf) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xf))) - 1) & (((0xf)))) ^ (((0xf))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xf)) >> 8)) - 1) & ((
((0xf)) >> 8))) ^ ((((0xf)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xf)) >> 8) >> 4
)) - 1) & (((((0xf)) >> 8) >> 4))) ^ (((((0xf
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf)) >> 8) >> 4) >> 2)) - 1) &
((((((0xf)) >> 8) >> 4) >> 2))) ^ ((((((0xf
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xf)) >> 8) >> 4
))) - 1) & ((((((0xf)) >> 8) >> 4)))) ^ (((((
(0xf)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xf)) >> 8))) - 1) & (((((
0xf)) >> 8)))) ^ (((((0xf)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xf)) >> 8)) >>
2)) - 1) & ((((((0xf)) >> 8)) >> 2))) ^ ((((
((0xf)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)) >> 8)))) - 1) & ((
((((0xf)) >> 8))))) ^ ((((((0xf)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf)))) - 1) &
((((0xf))))) ^ ((((0xf)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf))) >> 4)) - 1) & (((((0xf))) >>
4))) ^ (((((0xf))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf))) >> 4) >> 2)) - 1) &
((((((0xf))) >> 4) >> 2))) ^ ((((((0xf))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xf))) >> 4))) - 1) & ((((((0xf))) >>
4)))) ^ ((((((0xf))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xf))))) - 1) & (((((0xf))))
)) ^ (((((0xf))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf)))) >> 2)) - 1) & ((((((0xf)))) >>
2))) ^ ((((((0xf)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)))))) - 1) & ((((((0xf))))
))) ^ ((((((0xf)))))))) >> (1)) != 0) ? 1 : 0))))))
;
4289
4290 if (sc->sc_flags & RTW_F_DIGPHY0x00000002)
4291 opmode |= SA2400_OPMODE_DIGIN(1<<7);
4292
4293 return rtw_rf_macwrite(sc, SA2400_OPMODE4, opmode);
4294}
4295
4296int
4297rtw_sa2400_vco_calibration(struct rtw_softc *sc)
4298{
4299 int rc;
4300 /* calibrate VCO */
4301 if ((rc = rtw_sa2400_vcocal_start(sc, 1)) != 0)
4302 return rc;
4303 DELAY(2200)(*delay_func)(2200); /* 2.2 milliseconds */
4304 /* XXX superfluous: SA2400 automatically entered SLEEP mode. */
4305 return rtw_sa2400_vcocal_start(sc, 0);
4306}
4307
4308int
4309rtw_sa2400_filter_calibration(struct rtw_softc *sc)
4310{
4311 u_int32_t opmode;
4312
4313 opmode = SA2400_OPMODE_DEFAULTS((1<<8) | (1<<6) | (1<<9) | (1<<12) |
((3) << ((((u_long)((((((0x38000)) - 1) & ((0x38000
))) ^ ((0x38000)))) >> (16)) != 0) ? 16 + ((((u_long)((
(((((0x38000) >> 16)) - 1) & (((0x38000) >> 16
))) ^ (((0x38000) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0x38000) >> 16) >> 8)) - 1) &
((((0x38000) >> 16) >> 8))) ^ ((((0x38000) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0x38000) >> 16) >> 8) >> 4)) - 1) &
(((((0x38000) >> 16) >> 8) >> 4))) ^ (((((
0x38000) >> 16) >> 8) >> 4)))) >> (2)
) != 0) ? 2 + ((((u_long)((((((((((0x38000) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x38000) >>
16) >> 8) >> 4) >> 2))) ^ ((((((0x38000) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x38000) >> 16) >>
8) >> 4))) - 1) & ((((((0x38000) >> 16) >>
8) >> 4)))) ^ ((((((0x38000) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x38000
) >> 16) >> 8))) - 1) & (((((0x38000) >>
16) >> 8)))) ^ (((((0x38000) >> 16) >> 8))
))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x38000) >>
16) >> 8)) >> 2)) - 1) & ((((((0x38000) >>
16) >> 8)) >> 2))) ^ ((((((0x38000) >> 16)
>> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x38000) >> 16) >> 8)))) - 1)
& ((((((0x38000) >> 16) >> 8))))) ^ ((((((0x38000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x38000) >> 16))) - 1) & (((
(0x38000) >> 16)))) ^ ((((0x38000) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x38000) >> 16)) >>
4)) - 1) & (((((0x38000) >> 16)) >> 4))) ^ (
((((0x38000) >> 16)) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x38000) >> 16)) >> 4
) >> 2)) - 1) & ((((((0x38000) >> 16)) >>
4) >> 2))) ^ ((((((0x38000) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x38000
) >> 16)) >> 4))) - 1) & ((((((0x38000) >>
16)) >> 4)))) ^ ((((((0x38000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x38000
) >> 16)))) - 1) & (((((0x38000) >> 16))))) ^
(((((0x38000) >> 16)))))) >> (2)) != 0) ? 2 + ((
((u_long)((((((((((0x38000) >> 16))) >> 2)) - 1) &
((((((0x38000) >> 16))) >> 2))) ^ ((((((0x38000)
>> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x38000) >> 16))))) - 1) & ((
((((0x38000) >> 16)))))) ^ ((((((0x38000) >> 16))
))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x38000
))) - 1) & (((0x38000)))) ^ (((0x38000))))) >> (8))
!= 0) ? 8 + ((((u_long)((((((((0x38000)) >> 8)) - 1) &
((((0x38000)) >> 8))) ^ ((((0x38000)) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x38000)) >> 8) >>
4)) - 1) & (((((0x38000)) >> 8) >> 4))) ^ ((
(((0x38000)) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x38000)) >> 8) >> 4) >>
2)) - 1) & ((((((0x38000)) >> 8) >> 4) >>
2))) ^ ((((((0x38000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x38000
)) >> 8) >> 4))) - 1) & ((((((0x38000)) >>
8) >> 4)))) ^ ((((((0x38000)) >> 8) >> 4))
))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x38000
)) >> 8))) - 1) & (((((0x38000)) >> 8)))) ^ (
((((0x38000)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x38000)) >> 8)) >> 2)) - 1) & (((
(((0x38000)) >> 8)) >> 2))) ^ ((((((0x38000)) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x38000)) >> 8)))) - 1) & ((((((0x38000)
) >> 8))))) ^ ((((((0x38000)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x38000)))) - 1) &
((((0x38000))))) ^ ((((0x38000)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x38000))) >> 4)) - 1) & (((
((0x38000))) >> 4))) ^ (((((0x38000))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x38000))) >> 4)
>> 2)) - 1) & ((((((0x38000))) >> 4) >>
2))) ^ ((((((0x38000))) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x38000))) >>
4))) - 1) & ((((((0x38000))) >> 4)))) ^ ((((((0x38000
))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x38000))))) - 1) & (((((0x38000)))))) ^ (((((0x38000
))))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x38000
)))) >> 2)) - 1) & ((((((0x38000)))) >> 2))) ^
((((((0x38000)))) >> 2)))) >> (1)) != 0) ? 1 : 0
) : ((((u_long)((((((((((0x38000)))))) - 1) & ((((((0x38000
))))))) ^ ((((((0x38000)))))))) >> (1)) != 0) ? 1 : 0))
)))))
| SA2400_OPMODE_MODE_FCALIB((4) << ((((u_long)((((((0xf)) - 1) & ((0xf))) ^ ((
0xf)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xf) >>
16)) - 1) & (((0xf) >> 16))) ^ (((0xf) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xf) >>
16) >> 8)) - 1) & ((((0xf) >> 16) >> 8
))) ^ ((((0xf) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xf) >> 16) >> 8) >>
4)) - 1) & (((((0xf) >> 16) >> 8) >> 4
))) ^ (((((0xf) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xf) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xf) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16) >> 8
) >> 4))) - 1) & ((((((0xf) >> 16) >> 8
) >> 4)))) ^ ((((((0xf) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf
) >> 16) >> 8))) - 1) & (((((0xf) >> 16
) >> 8)))) ^ (((((0xf) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8)) >> 2)) - 1) & ((((((0xf) >> 16) >>
8)) >> 2))) ^ ((((((0xf) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16) >> 8)))) - 1) & ((((((0xf) >> 16
) >> 8))))) ^ ((((((0xf) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf) >> 16)
)) - 1) & ((((0xf) >> 16)))) ^ ((((0xf) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf) >>
16)) >> 4)) - 1) & (((((0xf) >> 16)) >>
4))) ^ (((((0xf) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xf) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xf) >> 16)) >> 4)
>> 2))) ^ ((((((0xf) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16)) >> 4))) - 1) & ((((((0xf) >> 16
)) >> 4)))) ^ ((((((0xf) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf) >> 16)
))) - 1) & (((((0xf) >> 16))))) ^ (((((0xf) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf)
>> 16))) >> 2)) - 1) & ((((((0xf) >> 16
))) >> 2))) ^ ((((((0xf) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16)
)))) - 1) & ((((((0xf) >> 16)))))) ^ ((((((0xf) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xf))) - 1) & (((0xf)))) ^ (((0xf))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xf)) >> 8)) - 1) & ((
((0xf)) >> 8))) ^ ((((0xf)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xf)) >> 8) >> 4
)) - 1) & (((((0xf)) >> 8) >> 4))) ^ (((((0xf
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf)) >> 8) >> 4) >> 2)) - 1) &
((((((0xf)) >> 8) >> 4) >> 2))) ^ ((((((0xf
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xf)) >> 8) >> 4
))) - 1) & ((((((0xf)) >> 8) >> 4)))) ^ (((((
(0xf)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xf)) >> 8))) - 1) & (((((
0xf)) >> 8)))) ^ (((((0xf)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xf)) >> 8)) >>
2)) - 1) & ((((((0xf)) >> 8)) >> 2))) ^ ((((
((0xf)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)) >> 8)))) - 1) & ((
((((0xf)) >> 8))))) ^ ((((((0xf)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf)))) - 1) &
((((0xf))))) ^ ((((0xf)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf))) >> 4)) - 1) & (((((0xf))) >>
4))) ^ (((((0xf))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf))) >> 4) >> 2)) - 1) &
((((((0xf))) >> 4) >> 2))) ^ ((((((0xf))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xf))) >> 4))) - 1) & ((((((0xf))) >>
4)))) ^ ((((((0xf))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xf))))) - 1) & (((((0xf))))
)) ^ (((((0xf))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf)))) >> 2)) - 1) & ((((((0xf)))) >>
2))) ^ ((((((0xf)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)))))) - 1) & ((((((0xf))))
))) ^ ((((((0xf)))))))) >> (1)) != 0) ? 1 : 0))))))
;
4314 if (sc->sc_flags & RTW_F_DIGPHY0x00000002)
4315 opmode |= SA2400_OPMODE_DIGIN(1<<7);
4316
4317 return rtw_rf_macwrite(sc, SA2400_OPMODE4, opmode);
4318}
4319
4320int
4321rtw_sa2400_dc_calibration(struct rtw_softc *sc)
4322{
4323 int rc;
4324 u_int32_t dccal;
4325
4326 rtw_continuous_tx_enable(sc, 1);
4327
4328 dccal = SA2400_OPMODE_DEFAULTS((1<<8) | (1<<6) | (1<<9) | (1<<12) |
((3) << ((((u_long)((((((0x38000)) - 1) & ((0x38000
))) ^ ((0x38000)))) >> (16)) != 0) ? 16 + ((((u_long)((
(((((0x38000) >> 16)) - 1) & (((0x38000) >> 16
))) ^ (((0x38000) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0x38000) >> 16) >> 8)) - 1) &
((((0x38000) >> 16) >> 8))) ^ ((((0x38000) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0x38000) >> 16) >> 8) >> 4)) - 1) &
(((((0x38000) >> 16) >> 8) >> 4))) ^ (((((
0x38000) >> 16) >> 8) >> 4)))) >> (2)
) != 0) ? 2 + ((((u_long)((((((((((0x38000) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x38000) >>
16) >> 8) >> 4) >> 2))) ^ ((((((0x38000) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x38000) >> 16) >>
8) >> 4))) - 1) & ((((((0x38000) >> 16) >>
8) >> 4)))) ^ ((((((0x38000) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x38000
) >> 16) >> 8))) - 1) & (((((0x38000) >>
16) >> 8)))) ^ (((((0x38000) >> 16) >> 8))
))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x38000) >>
16) >> 8)) >> 2)) - 1) & ((((((0x38000) >>
16) >> 8)) >> 2))) ^ ((((((0x38000) >> 16)
>> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x38000) >> 16) >> 8)))) - 1)
& ((((((0x38000) >> 16) >> 8))))) ^ ((((((0x38000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x38000) >> 16))) - 1) & (((
(0x38000) >> 16)))) ^ ((((0x38000) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x38000) >> 16)) >>
4)) - 1) & (((((0x38000) >> 16)) >> 4))) ^ (
((((0x38000) >> 16)) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x38000) >> 16)) >> 4
) >> 2)) - 1) & ((((((0x38000) >> 16)) >>
4) >> 2))) ^ ((((((0x38000) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x38000
) >> 16)) >> 4))) - 1) & ((((((0x38000) >>
16)) >> 4)))) ^ ((((((0x38000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x38000
) >> 16)))) - 1) & (((((0x38000) >> 16))))) ^
(((((0x38000) >> 16)))))) >> (2)) != 0) ? 2 + ((
((u_long)((((((((((0x38000) >> 16))) >> 2)) - 1) &
((((((0x38000) >> 16))) >> 2))) ^ ((((((0x38000)
>> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x38000) >> 16))))) - 1) & ((
((((0x38000) >> 16)))))) ^ ((((((0x38000) >> 16))
))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x38000
))) - 1) & (((0x38000)))) ^ (((0x38000))))) >> (8))
!= 0) ? 8 + ((((u_long)((((((((0x38000)) >> 8)) - 1) &
((((0x38000)) >> 8))) ^ ((((0x38000)) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x38000)) >> 8) >>
4)) - 1) & (((((0x38000)) >> 8) >> 4))) ^ ((
(((0x38000)) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x38000)) >> 8) >> 4) >>
2)) - 1) & ((((((0x38000)) >> 8) >> 4) >>
2))) ^ ((((((0x38000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x38000
)) >> 8) >> 4))) - 1) & ((((((0x38000)) >>
8) >> 4)))) ^ ((((((0x38000)) >> 8) >> 4))
))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x38000
)) >> 8))) - 1) & (((((0x38000)) >> 8)))) ^ (
((((0x38000)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x38000)) >> 8)) >> 2)) - 1) & (((
(((0x38000)) >> 8)) >> 2))) ^ ((((((0x38000)) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x38000)) >> 8)))) - 1) & ((((((0x38000)
) >> 8))))) ^ ((((((0x38000)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x38000)))) - 1) &
((((0x38000))))) ^ ((((0x38000)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x38000))) >> 4)) - 1) & (((
((0x38000))) >> 4))) ^ (((((0x38000))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x38000))) >> 4)
>> 2)) - 1) & ((((((0x38000))) >> 4) >>
2))) ^ ((((((0x38000))) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x38000))) >>
4))) - 1) & ((((((0x38000))) >> 4)))) ^ ((((((0x38000
))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x38000))))) - 1) & (((((0x38000)))))) ^ (((((0x38000
))))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x38000
)))) >> 2)) - 1) & ((((((0x38000)))) >> 2))) ^
((((((0x38000)))) >> 2)))) >> (1)) != 0) ? 1 : 0
) : ((((u_long)((((((((((0x38000)))))) - 1) & ((((((0x38000
))))))) ^ ((((((0x38000)))))))) >> (1)) != 0) ? 1 : 0))
)))))
| SA2400_OPMODE_MODE_TXRX((1) << ((((u_long)((((((0xf)) - 1) & ((0xf))) ^ ((
0xf)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xf) >>
16)) - 1) & (((0xf) >> 16))) ^ (((0xf) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xf) >>
16) >> 8)) - 1) & ((((0xf) >> 16) >> 8
))) ^ ((((0xf) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xf) >> 16) >> 8) >>
4)) - 1) & (((((0xf) >> 16) >> 8) >> 4
))) ^ (((((0xf) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xf) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xf) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16) >> 8
) >> 4))) - 1) & ((((((0xf) >> 16) >> 8
) >> 4)))) ^ ((((((0xf) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf
) >> 16) >> 8))) - 1) & (((((0xf) >> 16
) >> 8)))) ^ (((((0xf) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8)) >> 2)) - 1) & ((((((0xf) >> 16) >>
8)) >> 2))) ^ ((((((0xf) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16) >> 8)))) - 1) & ((((((0xf) >> 16
) >> 8))))) ^ ((((((0xf) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf) >> 16)
)) - 1) & ((((0xf) >> 16)))) ^ ((((0xf) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf) >>
16)) >> 4)) - 1) & (((((0xf) >> 16)) >>
4))) ^ (((((0xf) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xf) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xf) >> 16)) >> 4)
>> 2))) ^ ((((((0xf) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16)) >> 4))) - 1) & ((((((0xf) >> 16
)) >> 4)))) ^ ((((((0xf) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf) >> 16)
))) - 1) & (((((0xf) >> 16))))) ^ (((((0xf) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf)
>> 16))) >> 2)) - 1) & ((((((0xf) >> 16
))) >> 2))) ^ ((((((0xf) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16)
)))) - 1) & ((((((0xf) >> 16)))))) ^ ((((((0xf) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xf))) - 1) & (((0xf)))) ^ (((0xf))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xf)) >> 8)) - 1) & ((
((0xf)) >> 8))) ^ ((((0xf)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xf)) >> 8) >> 4
)) - 1) & (((((0xf)) >> 8) >> 4))) ^ (((((0xf
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf)) >> 8) >> 4) >> 2)) - 1) &
((((((0xf)) >> 8) >> 4) >> 2))) ^ ((((((0xf
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xf)) >> 8) >> 4
))) - 1) & ((((((0xf)) >> 8) >> 4)))) ^ (((((
(0xf)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xf)) >> 8))) - 1) & (((((
0xf)) >> 8)))) ^ (((((0xf)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xf)) >> 8)) >>
2)) - 1) & ((((((0xf)) >> 8)) >> 2))) ^ ((((
((0xf)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)) >> 8)))) - 1) & ((
((((0xf)) >> 8))))) ^ ((((((0xf)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf)))) - 1) &
((((0xf))))) ^ ((((0xf)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf))) >> 4)) - 1) & (((((0xf))) >>
4))) ^ (((((0xf))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf))) >> 4) >> 2)) - 1) &
((((((0xf))) >> 4) >> 2))) ^ ((((((0xf))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xf))) >> 4))) - 1) & ((((((0xf))) >>
4)))) ^ ((((((0xf))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xf))))) - 1) & (((((0xf))))
)) ^ (((((0xf))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf)))) >> 2)) - 1) & ((((((0xf)))) >>
2))) ^ ((((((0xf)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)))))) - 1) & ((((((0xf))))
))) ^ ((((((0xf)))))))) >> (1)) != 0) ? 1 : 0))))))
;
4329
4330 rc = rtw_rf_macwrite(sc, SA2400_OPMODE4, dccal);
4331
4332 if (rc != 0)
4333 return rc;
4334
4335 DELAY(5)(*delay_func)(5); /* DCALIB after being in Tx mode for 5
4336 * microseconds
4337 */
4338
4339 dccal &= ~SA2400_OPMODE_MODE_MASK0xf;
4340 dccal |= SA2400_OPMODE_MODE_DCALIB((5) << ((((u_long)((((((0xf)) - 1) & ((0xf))) ^ ((
0xf)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xf) >>
16)) - 1) & (((0xf) >> 16))) ^ (((0xf) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xf) >>
16) >> 8)) - 1) & ((((0xf) >> 16) >> 8
))) ^ ((((0xf) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xf) >> 16) >> 8) >>
4)) - 1) & (((((0xf) >> 16) >> 8) >> 4
))) ^ (((((0xf) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xf) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xf) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16) >> 8
) >> 4))) - 1) & ((((((0xf) >> 16) >> 8
) >> 4)))) ^ ((((((0xf) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf
) >> 16) >> 8))) - 1) & (((((0xf) >> 16
) >> 8)))) ^ (((((0xf) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8)) >> 2)) - 1) & ((((((0xf) >> 16) >>
8)) >> 2))) ^ ((((((0xf) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16) >> 8)))) - 1) & ((((((0xf) >> 16
) >> 8))))) ^ ((((((0xf) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf) >> 16)
)) - 1) & ((((0xf) >> 16)))) ^ ((((0xf) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf) >>
16)) >> 4)) - 1) & (((((0xf) >> 16)) >>
4))) ^ (((((0xf) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xf) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xf) >> 16)) >> 4)
>> 2))) ^ ((((((0xf) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16)) >> 4))) - 1) & ((((((0xf) >> 16
)) >> 4)))) ^ ((((((0xf) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf) >> 16)
))) - 1) & (((((0xf) >> 16))))) ^ (((((0xf) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf)
>> 16))) >> 2)) - 1) & ((((((0xf) >> 16
))) >> 2))) ^ ((((((0xf) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16)
)))) - 1) & ((((((0xf) >> 16)))))) ^ ((((((0xf) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xf))) - 1) & (((0xf)))) ^ (((0xf))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xf)) >> 8)) - 1) & ((
((0xf)) >> 8))) ^ ((((0xf)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xf)) >> 8) >> 4
)) - 1) & (((((0xf)) >> 8) >> 4))) ^ (((((0xf
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf)) >> 8) >> 4) >> 2)) - 1) &
((((((0xf)) >> 8) >> 4) >> 2))) ^ ((((((0xf
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xf)) >> 8) >> 4
))) - 1) & ((((((0xf)) >> 8) >> 4)))) ^ (((((
(0xf)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xf)) >> 8))) - 1) & (((((
0xf)) >> 8)))) ^ (((((0xf)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xf)) >> 8)) >>
2)) - 1) & ((((((0xf)) >> 8)) >> 2))) ^ ((((
((0xf)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)) >> 8)))) - 1) & ((
((((0xf)) >> 8))))) ^ ((((((0xf)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf)))) - 1) &
((((0xf))))) ^ ((((0xf)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf))) >> 4)) - 1) & (((((0xf))) >>
4))) ^ (((((0xf))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf))) >> 4) >> 2)) - 1) &
((((((0xf))) >> 4) >> 2))) ^ ((((((0xf))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xf))) >> 4))) - 1) & ((((((0xf))) >>
4)))) ^ ((((((0xf))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xf))))) - 1) & (((((0xf))))
)) ^ (((((0xf))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf)))) >> 2)) - 1) & ((((((0xf)))) >>
2))) ^ ((((((0xf)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)))))) - 1) & ((((((0xf))))
))) ^ ((((((0xf)))))))) >> (1)) != 0) ? 1 : 0))))))
;
4341
4342 rc = rtw_rf_macwrite(sc, SA2400_OPMODE4, dccal);
4343 if (rc != 0)
4344 return rc;
4345
4346 DELAY(20)(*delay_func)(20); /* calibration takes at most 20 microseconds */
4347
4348 rtw_continuous_tx_enable(sc, 0);
4349
4350 return 0;
4351}
4352
4353int
4354rtw_sa2400_calibrate(struct rtw_softc *sc, u_int freq)
4355{
4356 int i, rc;
4357
4358 /* XXX reference driver calibrates VCO twice. Is it a bug? */
4359 for (i = 0; i < 2; i++) {
4360 if ((rc = rtw_sa2400_vco_calibration(sc)) != 0)
4361 return rc;
4362 }
4363 /* VCO calibration erases synthesizer registers, so re-tune */
4364 if ((rc = rtw_sa2400_tune(sc, freq)) != 0)
4365 return rc;
4366 if ((rc = rtw_sa2400_filter_calibration(sc)) != 0)
4367 return rc;
4368 /* analog PHY needs DC calibration */
4369 if (!(sc->sc_flags & RTW_F_DIGPHY0x00000002))
4370 return rtw_sa2400_dc_calibration(sc);
4371 return 0;
4372}
4373
4374int
4375rtw_sa2400_init(struct rtw_softc *sc, u_int freq, u_int8_t opaque_txpower,
4376 enum rtw_pwrstate power)
4377{
4378 int rc;
4379 u_int32_t agc, manrx;
4380
4381 if ((rc = rtw_sa2400_txpower(sc, opaque_txpower)) != 0)
4382 return rc;
4383
4384 /* skip configuration if it's time to sleep or to power-down. */
4385 if (power == RTW_SLEEP || power == RTW_OFF)
4386 return rtw_sa2400_pwrstate(sc, power);
4387
4388 /* go to sleep for configuration */
4389 if ((rc = rtw_sa2400_pwrstate(sc, RTW_SLEEP)) != 0)
4390 return rc;
4391
4392 if ((rc = rtw_sa2400_tune(sc, freq)) != 0)
4393 return rc;
4394
4395 agc = LSHIFT(25, SA2400_AGC_MAXGAIN_MASK)((25) << ((((u_long)((((((0xf8000)) - 1) & ((0xf8000
))) ^ ((0xf8000)))) >> (16)) != 0) ? 16 + ((((u_long)((
(((((0xf8000) >> 16)) - 1) & (((0xf8000) >> 16
))) ^ (((0xf8000) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0xf8000) >> 16) >> 8)) - 1) &
((((0xf8000) >> 16) >> 8))) ^ ((((0xf8000) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
(((((0xf8000) >> 16) >> 8) >> 4)) - 1) &
(((((0xf8000) >> 16) >> 8) >> 4))) ^ (((((
0xf8000) >> 16) >> 8) >> 4)))) >> (2)
) != 0) ? 2 + ((((u_long)((((((((((0xf8000) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xf8000) >>
16) >> 8) >> 4) >> 2))) ^ ((((((0xf8000) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xf8000) >> 16) >>
8) >> 4))) - 1) & ((((((0xf8000) >> 16) >>
8) >> 4)))) ^ ((((((0xf8000) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf8000
) >> 16) >> 8))) - 1) & (((((0xf8000) >>
16) >> 8)))) ^ (((((0xf8000) >> 16) >> 8))
))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf8000) >>
16) >> 8)) >> 2)) - 1) & ((((((0xf8000) >>
16) >> 8)) >> 2))) ^ ((((((0xf8000) >> 16)
>> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0xf8000) >> 16) >> 8)))) - 1)
& ((((((0xf8000) >> 16) >> 8))))) ^ ((((((0xf8000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0xf8000) >> 16))) - 1) & (((
(0xf8000) >> 16)))) ^ ((((0xf8000) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xf8000) >> 16)) >>
4)) - 1) & (((((0xf8000) >> 16)) >> 4))) ^ (
((((0xf8000) >> 16)) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xf8000) >> 16)) >> 4
) >> 2)) - 1) & ((((((0xf8000) >> 16)) >>
4) >> 2))) ^ ((((((0xf8000) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf8000
) >> 16)) >> 4))) - 1) & ((((((0xf8000) >>
16)) >> 4)))) ^ ((((((0xf8000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf8000
) >> 16)))) - 1) & (((((0xf8000) >> 16))))) ^
(((((0xf8000) >> 16)))))) >> (2)) != 0) ? 2 + ((
((u_long)((((((((((0xf8000) >> 16))) >> 2)) - 1) &
((((((0xf8000) >> 16))) >> 2))) ^ ((((((0xf8000)
>> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xf8000) >> 16))))) - 1) & ((
((((0xf8000) >> 16)))))) ^ ((((((0xf8000) >> 16))
))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xf8000
))) - 1) & (((0xf8000)))) ^ (((0xf8000))))) >> (8))
!= 0) ? 8 + ((((u_long)((((((((0xf8000)) >> 8)) - 1) &
((((0xf8000)) >> 8))) ^ ((((0xf8000)) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xf8000)) >> 8) >>
4)) - 1) & (((((0xf8000)) >> 8) >> 4))) ^ ((
(((0xf8000)) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xf8000)) >> 8) >> 4) >>
2)) - 1) & ((((((0xf8000)) >> 8) >> 4) >>
2))) ^ ((((((0xf8000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf8000
)) >> 8) >> 4))) - 1) & ((((((0xf8000)) >>
8) >> 4)))) ^ ((((((0xf8000)) >> 8) >> 4))
))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf8000
)) >> 8))) - 1) & (((((0xf8000)) >> 8)))) ^ (
((((0xf8000)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf8000)) >> 8)) >> 2)) - 1) & (((
(((0xf8000)) >> 8)) >> 2))) ^ ((((((0xf8000)) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xf8000)) >> 8)))) - 1) & ((((((0xf8000)
) >> 8))))) ^ ((((((0xf8000)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf8000)))) - 1) &
((((0xf8000))))) ^ ((((0xf8000)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xf8000))) >> 4)) - 1) & (((
((0xf8000))) >> 4))) ^ (((((0xf8000))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf8000))) >> 4)
>> 2)) - 1) & ((((((0xf8000))) >> 4) >>
2))) ^ ((((((0xf8000))) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf8000))) >>
4))) - 1) & ((((((0xf8000))) >> 4)))) ^ ((((((0xf8000
))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xf8000))))) - 1) & (((((0xf8000)))))) ^ (((((0xf8000
))))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf8000
)))) >> 2)) - 1) & ((((((0xf8000)))) >> 2))) ^
((((((0xf8000)))) >> 2)))) >> (1)) != 0) ? 1 : 0
) : ((((u_long)((((((((((0xf8000)))))) - 1) & ((((((0xf8000
))))))) ^ ((((((0xf8000)))))))) >> (1)) != 0) ? 1 : 0))
))))
;
4396 agc |= LSHIFT(7, SA2400_AGC_BBPDELAY_MASK)((7) << ((((u_long)((((((0x7c00)) - 1) & ((0x7c00))
) ^ ((0x7c00)))) >> (16)) != 0) ? 16 + ((((u_long)(((((
((0x7c00) >> 16)) - 1) & (((0x7c00) >> 16))) ^
(((0x7c00) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7c00) >> 16) >> 8)) - 1) & ((((0x7c00
) >> 16) >> 8))) ^ ((((0x7c00) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7c00) >>
16) >> 8) >> 4)) - 1) & (((((0x7c00) >>
16) >> 8) >> 4))) ^ (((((0x7c00) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7c00) >> 16) >> 8) >> 4) >> 2)
) - 1) & ((((((0x7c00) >> 16) >> 8) >> 4
) >> 2))) ^ ((((((0x7c00) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x7c00) >> 16) >> 8) >> 4))) - 1)
& ((((((0x7c00) >> 16) >> 8) >> 4)))) ^
((((((0x7c00) >> 16) >> 8) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7c00) >> 16
) >> 8))) - 1) & (((((0x7c00) >> 16) >>
8)))) ^ (((((0x7c00) >> 16) >> 8))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0x7c00) >> 16) >>
8)) >> 2)) - 1) & ((((((0x7c00) >> 16) >>
8)) >> 2))) ^ ((((((0x7c00) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7c00
) >> 16) >> 8)))) - 1) & ((((((0x7c00) >>
16) >> 8))))) ^ ((((((0x7c00) >> 16) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x7c00
) >> 16))) - 1) & ((((0x7c00) >> 16)))) ^ (((
(0x7c00) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x7c00) >> 16)) >> 4)) - 1) & (((((
0x7c00) >> 16)) >> 4))) ^ (((((0x7c00) >> 16
)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((
((((0x7c00) >> 16)) >> 4) >> 2)) - 1) &
((((((0x7c00) >> 16)) >> 4) >> 2))) ^ ((((
((0x7c00) >> 16)) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7c00) >> 16
)) >> 4))) - 1) & ((((((0x7c00) >> 16)) >>
4)))) ^ ((((((0x7c00) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7c00) >> 16
)))) - 1) & (((((0x7c00) >> 16))))) ^ (((((0x7c00) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7c00
) >> 16))) >> 2)) - 1) & ((((((0x7c00) >>
16))) >> 2))) ^ ((((((0x7c00) >> 16))) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7c00
) >> 16))))) - 1) & ((((((0x7c00) >> 16))))))
^ ((((((0x7c00) >> 16))))))) >> (1)) != 0) ? 1 :
0)))) : ((((u_long)(((((((0x7c00))) - 1) & (((0x7c00))))
^ (((0x7c00))))) >> (8)) != 0) ? 8 + ((((u_long)((((((
((0x7c00)) >> 8)) - 1) & ((((0x7c00)) >> 8)))
^ ((((0x7c00)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0x7c00)) >> 8) >> 4)) - 1) & (
((((0x7c00)) >> 8) >> 4))) ^ (((((0x7c00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7c00)) >> 8) >> 4) >> 2)) - 1) &
((((((0x7c00)) >> 8) >> 4) >> 2))) ^ (((((
(0x7c00)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7c00)) >> 8) >>
4))) - 1) & ((((((0x7c00)) >> 8) >> 4)))) ^ (
(((((0x7c00)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0x7c00)) >> 8))) - 1) &
(((((0x7c00)) >> 8)))) ^ (((((0x7c00)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7c00)) >>
8)) >> 2)) - 1) & ((((((0x7c00)) >> 8)) >>
2))) ^ ((((((0x7c00)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7c00)) >> 8
)))) - 1) & ((((((0x7c00)) >> 8))))) ^ ((((((0x7c00
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7c00)))) - 1) & ((((0x7c00))))) ^ ((((0x7c00))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7c00))) >>
4)) - 1) & (((((0x7c00))) >> 4))) ^ (((((0x7c00)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0x7c00))) >> 4) >> 2)) - 1) & ((((((0x7c00)
)) >> 4) >> 2))) ^ ((((((0x7c00))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7c00
))) >> 4))) - 1) & ((((((0x7c00))) >> 4)))) ^
((((((0x7c00))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7c00))))) - 1) & (((((0x7c00)))
))) ^ (((((0x7c00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7c00)))) >> 2)) - 1) & ((((((0x7c00)))
) >> 2))) ^ ((((((0x7c00)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7c00)))))) - 1) &
((((((0x7c00))))))) ^ ((((((0x7c00)))))))) >> (1)) != 0
) ? 1 : 0))))))
;
4397 agc |= LSHIFT(15, SA2400_AGC_LNADELAY_MASK)((15) << ((((u_long)((((((0x3e0)) - 1) & ((0x3e0)))
^ ((0x3e0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((
0x3e0) >> 16)) - 1) & (((0x3e0) >> 16))) ^ ((
(0x3e0) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long)
((((((((0x3e0) >> 16) >> 8)) - 1) & ((((0x3e0
) >> 16) >> 8))) ^ ((((0x3e0) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3e0) >>
16) >> 8) >> 4)) - 1) & (((((0x3e0) >>
16) >> 8) >> 4))) ^ (((((0x3e0) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x3e0) >> 16) >> 8) >> 4) >> 2))
- 1) & ((((((0x3e0) >> 16) >> 8) >> 4)
>> 2))) ^ ((((((0x3e0) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3e0) >> 16) >> 8) >> 4))) - 1) &
((((((0x3e0) >> 16) >> 8) >> 4)))) ^ (((((
(0x3e0) >> 16) >> 8) >> 4))))) >> (1)
) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3e0) >> 16) >>
8))) - 1) & (((((0x3e0) >> 16) >> 8)))) ^ ((
(((0x3e0) >> 16) >> 8))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x3e0) >> 16) >> 8)) >>
2)) - 1) & ((((((0x3e0) >> 16) >> 8)) >>
2))) ^ ((((((0x3e0) >> 16) >> 8)) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3e0) >>
16) >> 8)))) - 1) & ((((((0x3e0) >> 16) >>
8))))) ^ ((((((0x3e0) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3e0) >> 16
))) - 1) & ((((0x3e0) >> 16)))) ^ ((((0x3e0) >>
16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3e0)
>> 16)) >> 4)) - 1) & (((((0x3e0) >> 16
)) >> 4))) ^ (((((0x3e0) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3e0) >> 16)) >>
4) >> 2)) - 1) & ((((((0x3e0) >> 16)) >>
4) >> 2))) ^ ((((((0x3e0) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3e0
) >> 16)) >> 4))) - 1) & ((((((0x3e0) >>
16)) >> 4)))) ^ ((((((0x3e0) >> 16)) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3e0
) >> 16)))) - 1) & (((((0x3e0) >> 16))))) ^ (
((((0x3e0) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3e0) >> 16))) >> 2)) - 1) & ((((
((0x3e0) >> 16))) >> 2))) ^ ((((((0x3e0) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x3e0) >> 16))))) - 1) & ((((((0x3e0) >>
16)))))) ^ ((((((0x3e0) >> 16))))))) >> (1)) != 0
) ? 1 : 0)))) : ((((u_long)(((((((0x3e0))) - 1) & (((0x3e0
)))) ^ (((0x3e0))))) >> (8)) != 0) ? 8 + ((((u_long)(((
(((((0x3e0)) >> 8)) - 1) & ((((0x3e0)) >> 8))
) ^ ((((0x3e0)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0x3e0)) >> 8) >> 4)) - 1) & (
((((0x3e0)) >> 8) >> 4))) ^ (((((0x3e0)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x3e0)) >> 8) >> 4) >> 2)) - 1) & (
(((((0x3e0)) >> 8) >> 4) >> 2))) ^ ((((((0x3e0
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3e0)) >> 8) >>
4))) - 1) & ((((((0x3e0)) >> 8) >> 4)))) ^ (
(((((0x3e0)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x3e0)) >> 8))) - 1) &
(((((0x3e0)) >> 8)))) ^ (((((0x3e0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3e0)) >> 8)) >>
2)) - 1) & ((((((0x3e0)) >> 8)) >> 2))) ^ ((
((((0x3e0)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3e0)) >> 8)))) - 1) &
((((((0x3e0)) >> 8))))) ^ ((((((0x3e0)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3e0)
))) - 1) & ((((0x3e0))))) ^ ((((0x3e0)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0x3e0))) >> 4)) - 1) &
(((((0x3e0))) >> 4))) ^ (((((0x3e0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3e0))) >> 4) >>
2)) - 1) & ((((((0x3e0))) >> 4) >> 2))) ^ ((
((((0x3e0))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3e0))) >> 4))) - 1) &
((((((0x3e0))) >> 4)))) ^ ((((((0x3e0))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3e0)
)))) - 1) & (((((0x3e0)))))) ^ (((((0x3e0))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3e0)))) >> 2))
- 1) & ((((((0x3e0)))) >> 2))) ^ ((((((0x3e0)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3e0
)))))) - 1) & ((((((0x3e0))))))) ^ ((((((0x3e0)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
4398 agc |= LSHIFT(27, SA2400_AGC_RXONDELAY_MASK)((27) << ((((u_long)((((((0x1f)) - 1) & ((0x1f))) ^
((0x1f)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x1f
) >> 16)) - 1) & (((0x1f) >> 16))) ^ (((0x1f)
>> 16)))) >> (8)) != 0) ? 8 + ((((u_long)(((((((
(0x1f) >> 16) >> 8)) - 1) & ((((0x1f) >>
16) >> 8))) ^ ((((0x1f) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x1f) >> 16) >>
8) >> 4)) - 1) & (((((0x1f) >> 16) >> 8
) >> 4))) ^ (((((0x1f) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x1f) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0x1f
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x1f) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x1f) >> 16
) >> 8) >> 4))) - 1) & ((((((0x1f) >> 16
) >> 8) >> 4)))) ^ ((((((0x1f) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x1f) >> 16) >> 8))) - 1) & (((((0x1f
) >> 16) >> 8)))) ^ (((((0x1f) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x1f) >>
16) >> 8)) >> 2)) - 1) & ((((((0x1f) >>
16) >> 8)) >> 2))) ^ ((((((0x1f) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x1f) >> 16) >> 8)))) - 1) & (((((
(0x1f) >> 16) >> 8))))) ^ ((((((0x1f) >> 16
) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x1f) >> 16))) - 1) & ((((0x1f) >> 16
)))) ^ ((((0x1f) >> 16))))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0x1f) >> 16)) >> 4)) - 1) &
(((((0x1f) >> 16)) >> 4))) ^ (((((0x1f) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x1f) >> 16)) >> 4) >> 2)) - 1) &
((((((0x1f) >> 16)) >> 4) >> 2))) ^ ((((((
0x1f) >> 16)) >> 4) >> 2)))) >> (1)) !=
0) ? 1 : 0) : ((((u_long)((((((((((0x1f) >> 16)) >>
4))) - 1) & ((((((0x1f) >> 16)) >> 4)))) ^ (
(((((0x1f) >> 16)) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x1f) >> 16)))) - 1) &
(((((0x1f) >> 16))))) ^ (((((0x1f) >> 16)))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x1f) >> 16))) >>
2)) - 1) & ((((((0x1f) >> 16))) >> 2))) ^ ((
((((0x1f) >> 16))) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x1f) >> 16))))) - 1) &
((((((0x1f) >> 16)))))) ^ ((((((0x1f) >> 16)))))
)) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x1f))
) - 1) & (((0x1f)))) ^ (((0x1f))))) >> (8)) != 0) ?
8 + ((((u_long)((((((((0x1f)) >> 8)) - 1) & ((((0x1f
)) >> 8))) ^ ((((0x1f)) >> 8)))) >> (4)) !=
0) ? 4 + ((((u_long)(((((((((0x1f)) >> 8) >> 4))
- 1) & (((((0x1f)) >> 8) >> 4))) ^ (((((0x1f
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x1f)) >> 8) >> 4) >> 2)) - 1) &
((((((0x1f)) >> 8) >> 4) >> 2))) ^ ((((((0x1f
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x1f)) >> 8) >> 4
))) - 1) & ((((((0x1f)) >> 8) >> 4)))) ^ ((((
((0x1f)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0x1f)) >> 8))) - 1) & ((
(((0x1f)) >> 8)))) ^ (((((0x1f)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x1f)) >> 8)) >>
2)) - 1) & ((((((0x1f)) >> 8)) >> 2))) ^ (((
(((0x1f)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x1f)) >> 8)))) - 1) &
((((((0x1f)) >> 8))))) ^ ((((((0x1f)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x1f))))
- 1) & ((((0x1f))))) ^ ((((0x1f)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x1f))) >> 4)) - 1) & (
((((0x1f))) >> 4))) ^ (((((0x1f))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x1f))) >> 4) >>
2)) - 1) & ((((((0x1f))) >> 4) >> 2))) ^ (((
(((0x1f))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x1f))) >> 4))) - 1) &
((((((0x1f))) >> 4)))) ^ ((((((0x1f))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x1f))))
) - 1) & (((((0x1f)))))) ^ (((((0x1f))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0x1f)))) >> 2)) - 1) &
((((((0x1f)))) >> 2))) ^ ((((((0x1f)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x1f))))
)) - 1) & ((((((0x1f))))))) ^ ((((((0x1f)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
4399
4400 if ((rc = rtw_rf_macwrite(sc, SA2400_AGC5, agc)) != 0)
4401 return rc;
4402
4403 /* XXX we are not supposed to be in RXMGC mode when we do this? */
4404 manrx = SA2400_MANRX_AHSN(1<<23);
4405 manrx |= SA2400_MANRX_TEN(1<<12);
4406 manrx |= LSHIFT(1023, SA2400_MANRX_RXGAIN_MASK)((1023) << ((((u_long)((((((0x3ff)) - 1) & ((0x3ff)
)) ^ ((0x3ff)))) >> (16)) != 0) ? 16 + ((((u_long)(((((
((0x3ff) >> 16)) - 1) & (((0x3ff) >> 16))) ^ (
((0x3ff) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x3ff) >> 16) >> 8)) - 1) & ((((0x3ff
) >> 16) >> 8))) ^ ((((0x3ff) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3ff) >>
16) >> 8) >> 4)) - 1) & (((((0x3ff) >>
16) >> 8) >> 4))) ^ (((((0x3ff) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x3ff) >> 16) >> 8) >> 4) >> 2))
- 1) & ((((((0x3ff) >> 16) >> 8) >> 4)
>> 2))) ^ ((((((0x3ff) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3ff) >> 16) >> 8) >> 4))) - 1) &
((((((0x3ff) >> 16) >> 8) >> 4)))) ^ (((((
(0x3ff) >> 16) >> 8) >> 4))))) >> (1)
) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff) >> 16) >>
8))) - 1) & (((((0x3ff) >> 16) >> 8)))) ^ ((
(((0x3ff) >> 16) >> 8))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x3ff) >> 16) >> 8)) >>
2)) - 1) & ((((((0x3ff) >> 16) >> 8)) >>
2))) ^ ((((((0x3ff) >> 16) >> 8)) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff) >>
16) >> 8)))) - 1) & ((((((0x3ff) >> 16) >>
8))))) ^ ((((((0x3ff) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff) >> 16
))) - 1) & ((((0x3ff) >> 16)))) ^ ((((0x3ff) >>
16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x3ff)
>> 16)) >> 4)) - 1) & (((((0x3ff) >> 16
)) >> 4))) ^ (((((0x3ff) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff) >> 16)) >>
4) >> 2)) - 1) & ((((((0x3ff) >> 16)) >>
4) >> 2))) ^ ((((((0x3ff) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff
) >> 16)) >> 4))) - 1) & ((((((0x3ff) >>
16)) >> 4)))) ^ ((((((0x3ff) >> 16)) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff
) >> 16)))) - 1) & (((((0x3ff) >> 16))))) ^ (
((((0x3ff) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x3ff) >> 16))) >> 2)) - 1) & ((((
((0x3ff) >> 16))) >> 2))) ^ ((((((0x3ff) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x3ff) >> 16))))) - 1) & ((((((0x3ff) >>
16)))))) ^ ((((((0x3ff) >> 16))))))) >> (1)) != 0
) ? 1 : 0)))) : ((((u_long)(((((((0x3ff))) - 1) & (((0x3ff
)))) ^ (((0x3ff))))) >> (8)) != 0) ? 8 + ((((u_long)(((
(((((0x3ff)) >> 8)) - 1) & ((((0x3ff)) >> 8))
) ^ ((((0x3ff)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0x3ff)) >> 8) >> 4)) - 1) & (
((((0x3ff)) >> 8) >> 4))) ^ (((((0x3ff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x3ff)) >> 8) >> 4) >> 2)) - 1) & (
(((((0x3ff)) >> 8) >> 4) >> 2))) ^ ((((((0x3ff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x3ff)) >> 8) >>
4))) - 1) & ((((((0x3ff)) >> 8) >> 4)))) ^ (
(((((0x3ff)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x3ff)) >> 8))) - 1) &
(((((0x3ff)) >> 8)))) ^ (((((0x3ff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff)) >> 8)) >>
2)) - 1) & ((((((0x3ff)) >> 8)) >> 2))) ^ ((
((((0x3ff)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3ff)) >> 8)))) - 1) &
((((((0x3ff)) >> 8))))) ^ ((((((0x3ff)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ff)
))) - 1) & ((((0x3ff))))) ^ ((((0x3ff)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0x3ff))) >> 4)) - 1) &
(((((0x3ff))) >> 4))) ^ (((((0x3ff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff))) >> 4) >>
2)) - 1) & ((((((0x3ff))) >> 4) >> 2))) ^ ((
((((0x3ff))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3ff))) >> 4))) - 1) &
((((((0x3ff))) >> 4)))) ^ ((((((0x3ff))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ff)
)))) - 1) & (((((0x3ff)))))) ^ (((((0x3ff))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ff)))) >> 2))
- 1) & ((((((0x3ff)))) >> 2))) ^ ((((((0x3ff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ff
)))))) - 1) & ((((((0x3ff))))))) ^ ((((((0x3ff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
4407
4408 if ((rc = rtw_rf_macwrite(sc, SA2400_MANRX6, manrx)) != 0)
4409 return rc;
4410
4411 if ((rc = rtw_sa2400_calibrate(sc, freq)) != 0)
4412 return rc;
4413
4414 /* enter Tx/Rx mode */
4415 return rtw_sa2400_pwrstate(sc, power);
4416}
4417
4418/* freq is in MHz */
4419int
4420rtw_max2820_tune(struct rtw_softc *sc, u_int freq)
4421{
4422 if (freq < 2400 || freq > 2499)
4423 return -1;
4424
4425 return rtw_rf_hostwrite(sc, MAX2820_CHANNEL3,
4426 LSHIFT(freq - 2400, MAX2820_CHANNEL_CF_MASK)((freq - 2400) << ((((u_long)((((((0x7f)) - 1) & ((
0x7f))) ^ ((0x7f)))) >> (16)) != 0) ? 16 + ((((u_long)(
((((((0x7f) >> 16)) - 1) & (((0x7f) >> 16))) ^
(((0x7f) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x7f) >> 16) >> 8)) - 1) & ((((0x7f)
>> 16) >> 8))) ^ ((((0x7f) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f) >>
16) >> 8) >> 4)) - 1) & (((((0x7f) >> 16
) >> 8) >> 4))) ^ (((((0x7f) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0x7f) >> 16) >> 8) >> 4) >> 2)) -
1) & ((((((0x7f) >> 16) >> 8) >> 4) >>
2))) ^ ((((((0x7f) >> 16) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f
) >> 16) >> 8) >> 4))) - 1) & ((((((0x7f
) >> 16) >> 8) >> 4)))) ^ ((((((0x7f) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x7f) >> 16) >> 8))) - 1)
& (((((0x7f) >> 16) >> 8)))) ^ (((((0x7f) >>
16) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x7f) >> 16) >> 8)) >> 2)) - 1) &
((((((0x7f) >> 16) >> 8)) >> 2))) ^ ((((((
0x7f) >> 16) >> 8)) >> 2)))) >> (1)) !=
0) ? 1 : 0) : ((((u_long)((((((((((0x7f) >> 16) >>
8)))) - 1) & ((((((0x7f) >> 16) >> 8))))) ^ (
(((((0x7f) >> 16) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0x7f) >> 16))) - 1) &
((((0x7f) >> 16)))) ^ ((((0x7f) >> 16))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x7f) >> 16)) >>
4)) - 1) & (((((0x7f) >> 16)) >> 4))) ^ ((((
(0x7f) >> 16)) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)((((((((((0x7f) >> 16)) >> 4) >>
2)) - 1) & ((((((0x7f) >> 16)) >> 4) >>
2))) ^ ((((((0x7f) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f) >> 16
)) >> 4))) - 1) & ((((((0x7f) >> 16)) >>
4)))) ^ ((((((0x7f) >> 16)) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f) >> 16))
)) - 1) & (((((0x7f) >> 16))))) ^ (((((0x7f) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f
) >> 16))) >> 2)) - 1) & ((((((0x7f) >>
16))) >> 2))) ^ ((((((0x7f) >> 16))) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f)
>> 16))))) - 1) & ((((((0x7f) >> 16)))))) ^ (
(((((0x7f) >> 16))))))) >> (1)) != 0) ? 1 : 0))))
: ((((u_long)(((((((0x7f))) - 1) & (((0x7f)))) ^ (((0x7f
))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x7f)) >>
8)) - 1) & ((((0x7f)) >> 8))) ^ ((((0x7f)) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0x7f)) >>
8) >> 4)) - 1) & (((((0x7f)) >> 8) >> 4
))) ^ (((((0x7f)) >> 8) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x7f)) >> 8) >> 4)
>> 2)) - 1) & ((((((0x7f)) >> 8) >> 4)
>> 2))) ^ ((((((0x7f)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f
)) >> 8) >> 4))) - 1) & ((((((0x7f)) >>
8) >> 4)))) ^ ((((((0x7f)) >> 8) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f)) >>
8))) - 1) & (((((0x7f)) >> 8)))) ^ (((((0x7f)) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f))
>> 8)) >> 2)) - 1) & ((((((0x7f)) >> 8
)) >> 2))) ^ ((((((0x7f)) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f)) >> 8
)))) - 1) & ((((((0x7f)) >> 8))))) ^ ((((((0x7f)) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
0x7f)))) - 1) & ((((0x7f))))) ^ ((((0x7f)))))) >> (
4)) != 0) ? 4 + ((((u_long)(((((((((0x7f))) >> 4)) - 1)
& (((((0x7f))) >> 4))) ^ (((((0x7f))) >> 4))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f))) >>
4) >> 2)) - 1) & ((((((0x7f))) >> 4) >>
2))) ^ ((((((0x7f))) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f))) >> 4)))
- 1) & ((((((0x7f))) >> 4)))) ^ ((((((0x7f))) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f
))))) - 1) & (((((0x7f)))))) ^ (((((0x7f))))))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0x7f)))) >> 2)) - 1
) & ((((((0x7f)))) >> 2))) ^ ((((((0x7f)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f
)))))) - 1) & ((((((0x7f))))))) ^ ((((((0x7f)))))))) >>
(1)) != 0) ? 1 : 0))))))
);
4427}
4428
4429int
4430rtw_max2820_init(struct rtw_softc *sc, u_int freq, u_int8_t opaque_txpower,
4431 enum rtw_pwrstate power)
4432{
4433 int rc;
4434
4435 if ((rc = rtw_rf_hostwrite(sc, MAX2820_TEST0,
4436 MAX2820_TEST_DEFAULT0x7)) != 0)
4437 return rc;
4438
4439 if ((rc = rtw_rf_hostwrite(sc, MAX2820_ENABLE1,
4440 MAX2820_ENABLE_DEFAULT((1<<4)|(1<<3)| (1<<2)|(1<<1)))) != 0)
4441 return rc;
4442
4443 /* skip configuration if it's time to sleep or to power-down. */
4444 if ((rc = rtw_max2820_pwrstate(sc, power)) != 0)
4445 return rc;
4446 else if (power == RTW_OFF || power == RTW_SLEEP)
4447 return 0;
4448
4449 if ((rc = rtw_rf_hostwrite(sc, MAX2820_SYNTH2,
4450 MAX2820_SYNTH_R_44MHZ((1) << ((((u_long)((((((0x3f)) - 1) & ((0x3f))) ^ (
(0x3f)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x3f)
>> 16)) - 1) & (((0x3f) >> 16))) ^ (((0x3f) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x3f) >>
16) >> 8)) - 1) & ((((0x3f) >> 16) >> 8
))) ^ ((((0x3f) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3f) >> 16) >> 8) >>
4)) - 1) & (((((0x3f) >> 16) >> 8) >> 4
))) ^ (((((0x3f) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3f) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x3f) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x3f) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x3f) >> 16) >>
8) >> 4))) - 1) & ((((((0x3f) >> 16) >>
8) >> 4)))) ^ ((((((0x3f) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3f
) >> 16) >> 8))) - 1) & (((((0x3f) >> 16
) >> 8)))) ^ (((((0x3f) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3f) >> 16) >>
8)) >> 2)) - 1) & ((((((0x3f) >> 16) >>
8)) >> 2))) ^ ((((((0x3f) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3f
) >> 16) >> 8)))) - 1) & ((((((0x3f) >>
16) >> 8))))) ^ ((((((0x3f) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3f)
>> 16))) - 1) & ((((0x3f) >> 16)))) ^ ((((0x3f
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0x3f) >> 16)) >> 4)) - 1) & (((((0x3f) >>
16)) >> 4))) ^ (((((0x3f) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0x3f) >>
16)) >> 4) >> 2)) - 1) & ((((((0x3f) >>
16)) >> 4) >> 2))) ^ ((((((0x3f) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x3f) >> 16)) >> 4))) - 1) & ((((((
0x3f) >> 16)) >> 4)))) ^ ((((((0x3f) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x3f) >> 16)))) - 1) & (((((0x3f) >>
16))))) ^ (((((0x3f) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x3f) >> 16))) >> 2)) -
1) & ((((((0x3f) >> 16))) >> 2))) ^ ((((((0x3f
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x3f) >> 16))))) - 1) & (((((
(0x3f) >> 16)))))) ^ ((((((0x3f) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x3f))) - 1) &
(((0x3f)))) ^ (((0x3f))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x3f)) >> 8)) - 1) & ((((0x3f)) >> 8
))) ^ ((((0x3f)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0x3f)) >> 8) >> 4)) - 1) & (
((((0x3f)) >> 8) >> 4))) ^ (((((0x3f)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0x3f)) >> 8) >> 4) >> 2)) - 1) & (((
(((0x3f)) >> 8) >> 4) >> 2))) ^ ((((((0x3f)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x3f)) >> 8) >> 4)
)) - 1) & ((((((0x3f)) >> 8) >> 4)))) ^ (((((
(0x3f)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0x3f)) >> 8))) - 1) & ((
(((0x3f)) >> 8)))) ^ (((((0x3f)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3f)) >> 8)) >>
2)) - 1) & ((((((0x3f)) >> 8)) >> 2))) ^ (((
(((0x3f)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x3f)) >> 8)))) - 1) &
((((((0x3f)) >> 8))))) ^ ((((((0x3f)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3f))))
- 1) & ((((0x3f))))) ^ ((((0x3f)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x3f))) >> 4)) - 1) & (
((((0x3f))) >> 4))) ^ (((((0x3f))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3f))) >> 4) >>
2)) - 1) & ((((((0x3f))) >> 4) >> 2))) ^ (((
(((0x3f))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x3f))) >> 4))) - 1) &
((((((0x3f))) >> 4)))) ^ ((((((0x3f))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3f))))
) - 1) & (((((0x3f)))))) ^ (((((0x3f))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0x3f)))) >> 2)) - 1) &
((((((0x3f)))) >> 2))) ^ ((((((0x3f)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3f))))
)) - 1) & ((((((0x3f))))))) ^ ((((((0x3f)))))))) >>
(1)) != 0) ? 1 : 0))))))
)) != 0)
4451 return rc;
4452
4453 if ((rc = rtw_max2820_tune(sc, freq)) != 0)
4454 return rc;
4455
4456 /* XXX The MAX2820 datasheet indicates that 1C and 2C should not
4457 * be changed from 7, however, the reference driver sets them
4458 * to 4 and 1, respectively.
4459 */
4460 if ((rc = rtw_rf_hostwrite(sc, MAX2820_RECEIVE4,
4461 MAX2820_RECEIVE_DL_DEFAULT((1) << ((((u_long)((((((0x30)) - 1) & ((0x30))) ^ (
(0x30)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x30)
>> 16)) - 1) & (((0x30) >> 16))) ^ (((0x30) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x30) >>
16) >> 8)) - 1) & ((((0x30) >> 16) >> 8
))) ^ ((((0x30) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x30) >> 16) >> 8) >>
4)) - 1) & (((((0x30) >> 16) >> 8) >> 4
))) ^ (((((0x30) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x30) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0x30) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0x30) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0x30) >> 16) >>
8) >> 4))) - 1) & ((((((0x30) >> 16) >>
8) >> 4)))) ^ ((((((0x30) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x30
) >> 16) >> 8))) - 1) & (((((0x30) >> 16
) >> 8)))) ^ (((((0x30) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x30) >> 16) >>
8)) >> 2)) - 1) & ((((((0x30) >> 16) >>
8)) >> 2))) ^ ((((((0x30) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x30
) >> 16) >> 8)))) - 1) & ((((((0x30) >>
16) >> 8))))) ^ ((((((0x30) >> 16) >> 8)))
))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x30)
>> 16))) - 1) & ((((0x30) >> 16)))) ^ ((((0x30
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0x30) >> 16)) >> 4)) - 1) & (((((0x30) >>
16)) >> 4))) ^ (((((0x30) >> 16)) >> 4))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0x30) >>
16)) >> 4) >> 2)) - 1) & ((((((0x30) >>
16)) >> 4) >> 2))) ^ ((((((0x30) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x30) >> 16)) >> 4))) - 1) & ((((((
0x30) >> 16)) >> 4)))) ^ ((((((0x30) >> 16)
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0x30) >> 16)))) - 1) & (((((0x30) >>
16))))) ^ (((((0x30) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0x30) >> 16))) >> 2)) -
1) & ((((((0x30) >> 16))) >> 2))) ^ ((((((0x30
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x30) >> 16))))) - 1) & (((((
(0x30) >> 16)))))) ^ ((((((0x30) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x30))) - 1) &
(((0x30)))) ^ (((0x30))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x30)) >> 8)) - 1) & ((((0x30)) >> 8
))) ^ ((((0x30)) >> 8)))) >> (4)) != 0) ? 4 + (((
(u_long)(((((((((0x30)) >> 8) >> 4)) - 1) & (
((((0x30)) >> 8) >> 4))) ^ (((((0x30)) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0x30)) >> 8) >> 4) >> 2)) - 1) & (((
(((0x30)) >> 8) >> 4) >> 2))) ^ ((((((0x30)
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x30)) >> 8) >> 4)
)) - 1) & ((((((0x30)) >> 8) >> 4)))) ^ (((((
(0x30)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0x30)) >> 8))) - 1) & ((
(((0x30)) >> 8)))) ^ (((((0x30)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x30)) >> 8)) >>
2)) - 1) & ((((((0x30)) >> 8)) >> 2))) ^ (((
(((0x30)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x30)) >> 8)))) - 1) &
((((((0x30)) >> 8))))) ^ ((((((0x30)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x30))))
- 1) & ((((0x30))))) ^ ((((0x30)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x30))) >> 4)) - 1) & (
((((0x30))) >> 4))) ^ (((((0x30))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x30))) >> 4) >>
2)) - 1) & ((((((0x30))) >> 4) >> 2))) ^ (((
(((0x30))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x30))) >> 4))) - 1) &
((((((0x30))) >> 4)))) ^ ((((((0x30))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x30))))
) - 1) & (((((0x30)))))) ^ (((((0x30))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0x30)))) >> 2)) - 1) &
((((((0x30)))) >> 2))) ^ ((((((0x30)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x30))))
)) - 1) & ((((((0x30))))))) ^ ((((((0x30)))))))) >>
(1)) != 0) ? 1 : 0))))))
|
4462 LSHIFT(4, MAX2820A_RECEIVE_1C_MASK)((4) << ((((u_long)((((((0x1c0)) - 1) & ((0x1c0))) ^
((0x1c0)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x1c0
) >> 16)) - 1) & (((0x1c0) >> 16))) ^ (((0x1c0
) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((
((0x1c0) >> 16) >> 8)) - 1) & ((((0x1c0) >>
16) >> 8))) ^ ((((0x1c0) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x1c0) >> 16) >>
8) >> 4)) - 1) & (((((0x1c0) >> 16) >>
8) >> 4))) ^ (((((0x1c0) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x1c0) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0x1c0
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x1c0) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x1c0) >> 16
) >> 8) >> 4))) - 1) & ((((((0x1c0) >> 16
) >> 8) >> 4)))) ^ ((((((0x1c0) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x1c0) >> 16) >> 8))) - 1) & (((((0x1c0
) >> 16) >> 8)))) ^ (((((0x1c0) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x1c0)
>> 16) >> 8)) >> 2)) - 1) & ((((((0x1c0
) >> 16) >> 8)) >> 2))) ^ ((((((0x1c0) >>
16) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)((((((((((0x1c0) >> 16) >> 8)))) - 1
) & ((((((0x1c0) >> 16) >> 8))))) ^ ((((((0x1c0
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0x1c0) >> 16))) - 1) & ((((0x1c0
) >> 16)))) ^ ((((0x1c0) >> 16))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0x1c0) >> 16)) >>
4)) - 1) & (((((0x1c0) >> 16)) >> 4))) ^ (((
((0x1c0) >> 16)) >> 4)))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x1c0) >> 16)) >> 4) >>
2)) - 1) & ((((((0x1c0) >> 16)) >> 4) >>
2))) ^ ((((((0x1c0) >> 16)) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x1c0) >>
16)) >> 4))) - 1) & ((((((0x1c0) >> 16)) >>
4)))) ^ ((((((0x1c0) >> 16)) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x1c0) >> 16)
))) - 1) & (((((0x1c0) >> 16))))) ^ (((((0x1c0) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x1c0
) >> 16))) >> 2)) - 1) & ((((((0x1c0) >>
16))) >> 2))) ^ ((((((0x1c0) >> 16))) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x1c0
) >> 16))))) - 1) & ((((((0x1c0) >> 16)))))) ^
((((((0x1c0) >> 16))))))) >> (1)) != 0) ? 1 : 0)
))) : ((((u_long)(((((((0x1c0))) - 1) & (((0x1c0)))) ^ ((
(0x1c0))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0x1c0
)) >> 8)) - 1) & ((((0x1c0)) >> 8))) ^ ((((0x1c0
)) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((((
(((0x1c0)) >> 8) >> 4)) - 1) & (((((0x1c0)) >>
8) >> 4))) ^ (((((0x1c0)) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x1c0)) >> 8) >>
4) >> 2)) - 1) & ((((((0x1c0)) >> 8) >>
4) >> 2))) ^ ((((((0x1c0)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x1c0
)) >> 8) >> 4))) - 1) & ((((((0x1c0)) >>
8) >> 4)))) ^ ((((((0x1c0)) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x1c0))
>> 8))) - 1) & (((((0x1c0)) >> 8)))) ^ (((((
0x1c0)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)
((((((((((0x1c0)) >> 8)) >> 2)) - 1) & ((((((
0x1c0)) >> 8)) >> 2))) ^ ((((((0x1c0)) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0x1c0)) >> 8)))) - 1) & ((((((0x1c0)) >>
8))))) ^ ((((((0x1c0)) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0x1c0)))) - 1) & ((((0x1c0
))))) ^ ((((0x1c0)))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0x1c0))) >> 4)) - 1) & (((((0x1c0))) >>
4))) ^ (((((0x1c0))) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)((((((((((0x1c0))) >> 4) >> 2)) - 1) &
((((((0x1c0))) >> 4) >> 2))) ^ ((((((0x1c0))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x1c0))) >> 4))) - 1) & ((((((0x1c0))) >>
4)))) ^ ((((((0x1c0))) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x1c0))))) - 1) & (((((0x1c0
)))))) ^ (((((0x1c0))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x1c0)))) >> 2)) - 1) & ((((((0x1c0)))) >>
2))) ^ ((((((0x1c0)))) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x1c0)))))) - 1) & ((((((0x1c0
))))))) ^ ((((((0x1c0)))))))) >> (1)) != 0) ? 1 : 0))))
))
|
4463 LSHIFT(1, MAX2820A_RECEIVE_2C_MASK)((1) << ((((u_long)((((((0xe00)) - 1) & ((0xe00))) ^
((0xe00)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xe00
) >> 16)) - 1) & (((0xe00) >> 16))) ^ (((0xe00
) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((
((0xe00) >> 16) >> 8)) - 1) & ((((0xe00) >>
16) >> 8))) ^ ((((0xe00) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xe00) >> 16) >>
8) >> 4)) - 1) & (((((0xe00) >> 16) >>
8) >> 4))) ^ (((((0xe00) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xe00) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0xe00
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xe00) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00) >> 16
) >> 8) >> 4))) - 1) & ((((((0xe00) >> 16
) >> 8) >> 4)))) ^ ((((((0xe00) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xe00) >> 16) >> 8))) - 1) & (((((0xe00
) >> 16) >> 8)))) ^ (((((0xe00) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xe00)
>> 16) >> 8)) >> 2)) - 1) & ((((((0xe00
) >> 16) >> 8)) >> 2))) ^ ((((((0xe00) >>
16) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)((((((((((0xe00) >> 16) >> 8)))) - 1
) & ((((((0xe00) >> 16) >> 8))))) ^ ((((((0xe00
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0xe00) >> 16))) - 1) & ((((0xe00
) >> 16)))) ^ ((((0xe00) >> 16))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0xe00) >> 16)) >>
4)) - 1) & (((((0xe00) >> 16)) >> 4))) ^ (((
((0xe00) >> 16)) >> 4)))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0xe00) >> 16)) >> 4) >>
2)) - 1) & ((((((0xe00) >> 16)) >> 4) >>
2))) ^ ((((((0xe00) >> 16)) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00) >>
16)) >> 4))) - 1) & ((((((0xe00) >> 16)) >>
4)))) ^ ((((((0xe00) >> 16)) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe00) >> 16)
))) - 1) & (((((0xe00) >> 16))))) ^ (((((0xe00) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xe00
) >> 16))) >> 2)) - 1) & ((((((0xe00) >>
16))) >> 2))) ^ ((((((0xe00) >> 16))) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00
) >> 16))))) - 1) & ((((((0xe00) >> 16)))))) ^
((((((0xe00) >> 16))))))) >> (1)) != 0) ? 1 : 0)
))) : ((((u_long)(((((((0xe00))) - 1) & (((0xe00)))) ^ ((
(0xe00))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xe00
)) >> 8)) - 1) & ((((0xe00)) >> 8))) ^ ((((0xe00
)) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((((
(((0xe00)) >> 8) >> 4)) - 1) & (((((0xe00)) >>
8) >> 4))) ^ (((((0xe00)) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xe00)) >> 8) >>
4) >> 2)) - 1) & ((((((0xe00)) >> 8) >>
4) >> 2))) ^ ((((((0xe00)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xe00
)) >> 8) >> 4))) - 1) & ((((((0xe00)) >>
8) >> 4)))) ^ ((((((0xe00)) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xe00))
>> 8))) - 1) & (((((0xe00)) >> 8)))) ^ (((((
0xe00)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)
((((((((((0xe00)) >> 8)) >> 2)) - 1) & ((((((
0xe00)) >> 8)) >> 2))) ^ ((((((0xe00)) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0xe00)) >> 8)))) - 1) & ((((((0xe00)) >>
8))))) ^ ((((((0xe00)) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0xe00)))) - 1) & ((((0xe00
))))) ^ ((((0xe00)))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0xe00))) >> 4)) - 1) & (((((0xe00))) >>
4))) ^ (((((0xe00))) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)((((((((((0xe00))) >> 4) >> 2)) - 1) &
((((((0xe00))) >> 4) >> 2))) ^ ((((((0xe00))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xe00))) >> 4))) - 1) & ((((((0xe00))) >>
4)))) ^ ((((((0xe00))) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0xe00))))) - 1) & (((((0xe00
)))))) ^ (((((0xe00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xe00)))) >> 2)) - 1) & ((((((0xe00)))) >>
2))) ^ ((((((0xe00)))) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xe00)))))) - 1) & ((((((0xe00
))))))) ^ ((((((0xe00)))))))) >> (1)) != 0) ? 1 : 0))))
))
)) != 0)
4464 return rc;
4465
4466 return rtw_rf_hostwrite(sc, MAX2820_TRANSMIT5,
4467 MAX2820_TRANSMIT_PA_DEFAULT((0) << ((((u_long)((((((0xf)) - 1) & ((0xf))) ^ ((
0xf)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xf) >>
16)) - 1) & (((0xf) >> 16))) ^ (((0xf) >> 16
)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xf) >>
16) >> 8)) - 1) & ((((0xf) >> 16) >> 8
))) ^ ((((0xf) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xf) >> 16) >> 8) >>
4)) - 1) & (((((0xf) >> 16) >> 8) >> 4
))) ^ (((((0xf) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xf) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xf) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16) >> 8
) >> 4))) - 1) & ((((((0xf) >> 16) >> 8
) >> 4)))) ^ ((((((0xf) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf
) >> 16) >> 8))) - 1) & (((((0xf) >> 16
) >> 8)))) ^ (((((0xf) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8)) >> 2)) - 1) & ((((((0xf) >> 16) >>
8)) >> 2))) ^ ((((((0xf) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16) >> 8)))) - 1) & ((((((0xf) >> 16
) >> 8))))) ^ ((((((0xf) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf) >> 16)
)) - 1) & ((((0xf) >> 16)))) ^ ((((0xf) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf) >>
16)) >> 4)) - 1) & (((((0xf) >> 16)) >>
4))) ^ (((((0xf) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xf) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xf) >> 16)) >> 4)
>> 2))) ^ ((((((0xf) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16)) >> 4))) - 1) & ((((((0xf) >> 16
)) >> 4)))) ^ ((((((0xf) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf) >> 16)
))) - 1) & (((((0xf) >> 16))))) ^ (((((0xf) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf)
>> 16))) >> 2)) - 1) & ((((((0xf) >> 16
))) >> 2))) ^ ((((((0xf) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16)
)))) - 1) & ((((((0xf) >> 16)))))) ^ ((((((0xf) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xf))) - 1) & (((0xf)))) ^ (((0xf))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xf)) >> 8)) - 1) & ((
((0xf)) >> 8))) ^ ((((0xf)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xf)) >> 8) >> 4
)) - 1) & (((((0xf)) >> 8) >> 4))) ^ (((((0xf
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf)) >> 8) >> 4) >> 2)) - 1) &
((((((0xf)) >> 8) >> 4) >> 2))) ^ ((((((0xf
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xf)) >> 8) >> 4
))) - 1) & ((((((0xf)) >> 8) >> 4)))) ^ (((((
(0xf)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xf)) >> 8))) - 1) & (((((
0xf)) >> 8)))) ^ (((((0xf)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xf)) >> 8)) >>
2)) - 1) & ((((((0xf)) >> 8)) >> 2))) ^ ((((
((0xf)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)) >> 8)))) - 1) & ((
((((0xf)) >> 8))))) ^ ((((((0xf)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf)))) - 1) &
((((0xf))))) ^ ((((0xf)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf))) >> 4)) - 1) & (((((0xf))) >>
4))) ^ (((((0xf))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf))) >> 4) >> 2)) - 1) &
((((((0xf))) >> 4) >> 2))) ^ ((((((0xf))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xf))) >> 4))) - 1) & ((((((0xf))) >>
4)))) ^ ((((((0xf))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xf))))) - 1) & (((((0xf))))
)) ^ (((((0xf))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf)))) >> 2)) - 1) & ((((((0xf)))) >>
2))) ^ ((((((0xf)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)))))) - 1) & ((((((0xf))))
))) ^ ((((((0xf)))))))) >> (1)) != 0) ? 1 : 0))))))
);
4468}
4469
4470int
4471rtw_max2820_txpower(struct rtw_softc *sc, u_int8_t opaque_txpower)
4472{
4473 /* TBD */
4474 return 0;
4475}
4476
4477int
4478rtw_max2820_pwrstate(struct rtw_softc *sc, enum rtw_pwrstate power)
4479{
4480 uint32_t enable;
4481
4482 switch (power) {
4483 case RTW_OFF:
4484 case RTW_SLEEP:
4485 default:
4486 enable = 0x0;
4487 break;
4488 case RTW_ON:
4489 enable = MAX2820_ENABLE_DEFAULT((1<<4)|(1<<3)| (1<<2)|(1<<1));
4490 break;
4491 }
4492 return rtw_rf_hostwrite(sc, MAX2820_ENABLE1, enable);
4493}
4494
4495int
4496rtw_grf5101_init(struct rtw_softc *sc, u_int freq, u_int8_t opaque_txpower,
4497 enum rtw_pwrstate power)
4498{
4499 int rc;
4500
4501 /*
4502 * These values have been derived from the rtl8180-sa2400 Linux driver.
4503 * It is unknown what they all do, GCT refuse to release any documentation
4504 * so these are more than likely sub optimal settings
4505 */
4506
4507 rtw_rf_macwrite(sc, 0x01, 0x1a23);
4508 rtw_rf_macwrite(sc, 0x02, 0x4971);
4509 rtw_rf_macwrite(sc, 0x03, 0x41de);
4510 rtw_rf_macwrite(sc, 0x04, 0x2d80);
4511
4512 rtw_rf_macwrite(sc, 0x05, 0x61ff);
4513
4514 rtw_rf_macwrite(sc, 0x06, 0x0);
4515
4516 rtw_rf_macwrite(sc, 0x08, 0x7533);
4517 rtw_rf_macwrite(sc, 0x09, 0xc401);
4518 rtw_rf_macwrite(sc, 0x0a, 0x0);
4519 rtw_rf_macwrite(sc, 0x0c, 0x1c7);
4520 rtw_rf_macwrite(sc, 0x0d, 0x29d3);
4521 rtw_rf_macwrite(sc, 0x0e, 0x2e8);
4522 rtw_rf_macwrite(sc, 0x10, 0x192);
4523 rtw_rf_macwrite(sc, 0x11, 0x248);
4524 rtw_rf_macwrite(sc, 0x12, 0x0);
4525 rtw_rf_macwrite(sc, 0x13, 0x20c4);
4526 rtw_rf_macwrite(sc, 0x14, 0xf4fc);
4527 rtw_rf_macwrite(sc, 0x15, 0x0);
4528 rtw_rf_macwrite(sc, 0x16, 0x1500);
4529
4530 if ((rc = rtw_grf5101_txpower(sc, opaque_txpower)) != 0)
4531 return rc;
4532
4533 if ((rc = rtw_grf5101_tune(sc, freq)) != 0)
4534 return rc;
4535
4536 return (0);
4537}
4538
4539int
4540rtw_grf5101_tune(struct rtw_softc *sc, u_int freq)
4541{
4542 struct ieee80211com *ic = &sc->sc_ic;
4543 u_int channel = ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan);
4544
4545 /* set channel */
4546 rtw_rf_macwrite(sc, 0x07, 0);
4547 rtw_rf_macwrite(sc, 0x0b, channel - 1);
4548 rtw_rf_macwrite(sc, 0x07, 0x1000);
4549
4550 return (0);
4551}
4552
4553int
4554rtw_grf5101_txpower(struct rtw_softc *sc, u_int8_t opaque_txpower)
4555{
4556 rtw_rf_macwrite(sc, 0x15, 0);
4557 rtw_rf_macwrite(sc, 0x06, opaque_txpower);
4558 rtw_rf_macwrite(sc, 0x15, 0x10);
4559 rtw_rf_macwrite(sc, 0x15, 0x00);
4560
4561 return (0);
4562}
4563
4564int
4565rtw_grf5101_pwrstate(struct rtw_softc *sc, enum rtw_pwrstate power)
4566{
4567 switch (power) {
4568 case RTW_OFF:
4569 /* FALLTHROUGH */
4570 case RTW_SLEEP:
4571 rtw_rf_macwrite(sc, 0x07, 0x0000);
4572 rtw_rf_macwrite(sc, 0x1f, 0x0045);
4573 rtw_rf_macwrite(sc, 0x1f, 0x0005);
4574 rtw_rf_macwrite(sc, 0x00, 0x08e4);
4575 break;
4576 case RTW_ON:
4577 rtw_rf_macwrite(sc, 0x1f, 0x0001);
4578 DELAY(10)(*delay_func)(10);
4579 rtw_rf_macwrite(sc, 0x1f, 0x0001);
4580 DELAY(10)(*delay_func)(10);
4581 rtw_rf_macwrite(sc, 0x1f, 0x0041);
4582 DELAY(10)(*delay_func)(10);
4583 rtw_rf_macwrite(sc, 0x1f, 0x0061);
4584 DELAY(10)(*delay_func)(10);
4585 rtw_rf_macwrite(sc, 0x00, 0x0ae4);
4586 DELAY(10)(*delay_func)(10);
4587 rtw_rf_macwrite(sc, 0x07, 0x1000);
4588 DELAY(100)(*delay_func)(100);
4589 break;
4590 }
4591
4592 return 0;
4593}
4594
4595int
4596rtw_rtl8225_pwrstate(struct rtw_softc *sc, enum rtw_pwrstate power)
4597{
4598 return (0);
4599}
4600
4601int
4602rtw_rtl8225_init(struct rtw_softc *sc, u_int freq, u_int8_t opaque_txpower,
4603 enum rtw_pwrstate power)
4604{
4605 return (0);
4606}
4607
4608int
4609rtw_rtl8225_txpower(struct rtw_softc *sc, u_int8_t opaque_txpower)
4610{
4611 return (0);
4612}
4613
4614int
4615rtw_rtl8225_tune(struct rtw_softc *sc, u_int freq)
4616{
4617 return (0);
4618}
4619
4620int
4621rtw_rtl8255_pwrstate(struct rtw_softc *sc, enum rtw_pwrstate power)
4622{
4623 return (0);
4624}
4625
4626int
4627rtw_rtl8255_init(struct rtw_softc *sc, u_int freq, u_int8_t opaque_txpower,
4628 enum rtw_pwrstate power)
4629{
4630 return (0);
4631}
4632
4633int
4634rtw_rtl8255_txpower(struct rtw_softc *sc, u_int8_t opaque_txpower)
4635{
4636 return (0);
4637}
4638
4639int
4640rtw_rtl8255_tune(struct rtw_softc *sc, u_int freq)
4641{
4642 return (0);
4643}
4644
4645int
4646rtw_phy_init(struct rtw_softc *sc)
4647{
4648 int rc;
4649 struct ieee80211com *ic = &sc->sc_ic;
4650 struct rtw_regs *regs = &sc->sc_regs;
4651 int antdiv = sc->sc_flags & RTW_F_ANTDIV0x00000010;
4652 int dflantb = sc->sc_flags & RTW_F_DFLANTB0x00000004;
4653 u_int freq = ic->ic_bss->ni_chan->ic_freq; /* freq is in MHz */
4654 u_int8_t opaque_txpower = rtw_chan2txpower(&sc->sc_srom, ic,
4655 ic->ic_bss->ni_chan);
4656 u_int8_t cs_threshold = sc->sc_csthr;
4657 enum rtw_pwrstate power = RTW_ON;
4658
4659 RTW_DPRINTF(RTW_DEBUG_PHY,
4660 ("%s: txpower %u csthresh %u freq %u antdiv %u dflantb %u "
4661 "pwrstate %s\n", __func__, opaque_txpower, cs_threshold, freq,
4662 antdiv, dflantb, rtw_pwrstate_string(power)));
4663
4664 /* XXX is this really necessary? */
4665 if ((rc = (*sc->sc_rf_txpower)(sc, opaque_txpower)) != 0)
4666 return rc;
4667 if ((rc = rtw_bbp_preinit(regs, sc->sc_bbpset.bb_antatten, dflantb,
4668 freq)) != 0)
4669 return rc;
4670 if ((rc = (*sc->sc_rf_tune)(sc, freq)) != 0)
4671 return rc;
4672 /* initialize RF */
4673 if ((rc = (*sc->sc_rf_init)(sc, freq, opaque_txpower, power)) != 0)
4674 return rc;
4675#if 0 /* what is this redundant tx power setting here for? */
4676 if ((rc = (*sc->sc_rf_txpower)(sc, opaque_txpower)) != 0)
4677 return rc;
4678#endif
4679 return rtw_bbp_init(regs, &sc->sc_bbpset, antdiv, dflantb,
4680 cs_threshold, freq);
4681}
4682
4683/*
4684 * Generic PHY I/O functions
4685 */
4686
4687int
4688rtw_bbp_write(struct rtw_regs *regs, u_int addr, u_int val)
4689{
4690#define BBP_WRITE_ITERS50 50
4691#define BBP_WRITE_DELAY1 1
4692 int i;
4693 u_int32_t wrbbp, rdbbp;
4694
4695 RTW_DPRINTF(RTW_DEBUG_PHYIO,
4696 ("%s: bbp[%u] <- %u\n", __func__, addr, val));
4697
4698 KASSERT((addr & ~PRESHIFT(RTW_BB_ADDR_MASK)) == 0)(((addr & ~((((0x7f)) & ((0x7f))) >> ((((u_long
)(((((((0x7f))) - 1) & (((0x7f)))) ^ (((0x7f))))) >>
(16)) != 0) ? 16 + ((((u_long)((((((((0x7f)) >> 16)) -
1) & ((((0x7f)) >> 16))) ^ ((((0x7f)) >> 16)
))) >> (8)) != 0) ? 8 + ((((u_long)(((((((((0x7f)) >>
16) >> 8)) - 1) & (((((0x7f)) >> 16) >>
8))) ^ (((((0x7f)) >> 16) >> 8)))) >> (4))
!= 0) ? 4 + ((((u_long)((((((((((0x7f)) >> 16) >>
8) >> 4)) - 1) & ((((((0x7f)) >> 16) >>
8) >> 4))) ^ ((((((0x7f)) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0x7f))
>> 16) >> 8) >> 4) >> 2)) - 1) &
(((((((0x7f)) >> 16) >> 8) >> 4) >> 2
))) ^ (((((((0x7f)) >> 16) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x7f
)) >> 16) >> 8) >> 4))) - 1) & (((((((0x7f
)) >> 16) >> 8) >> 4)))) ^ (((((((0x7f)) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)((((((((((0x7f)) >> 16) >> 8))) - 1
) & ((((((0x7f)) >> 16) >> 8)))) ^ ((((((0x7f
)) >> 16) >> 8))))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((0x7f)) >> 16) >> 8)) >> 2
)) - 1) & (((((((0x7f)) >> 16) >> 8)) >>
2))) ^ (((((((0x7f)) >> 16) >> 8)) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x7f))
>> 16) >> 8)))) - 1) & (((((((0x7f)) >>
16) >> 8))))) ^ (((((((0x7f)) >> 16) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((0x7f
)) >> 16))) - 1) & (((((0x7f)) >> 16)))) ^ ((
(((0x7f)) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)((((((((((0x7f)) >> 16)) >> 4)) - 1) & (((((
(0x7f)) >> 16)) >> 4))) ^ ((((((0x7f)) >> 16
)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((
(((((0x7f)) >> 16)) >> 4) >> 2)) - 1) &
(((((((0x7f)) >> 16)) >> 4) >> 2))) ^ ((((
(((0x7f)) >> 16)) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x7f)) >> 16
)) >> 4))) - 1) & (((((((0x7f)) >> 16)) >>
4)))) ^ (((((((0x7f)) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0x7f)) >> 16
)))) - 1) & ((((((0x7f)) >> 16))))) ^ ((((((0x7f)) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0x7f
)) >> 16))) >> 2)) - 1) & (((((((0x7f)) >>
16))) >> 2))) ^ (((((((0x7f)) >> 16))) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x7f
)) >> 16))))) - 1) & (((((((0x7f)) >> 16)))))
) ^ (((((((0x7f)) >> 16))))))) >> (1)) != 0) ? 1 :
0)))) : ((((u_long)((((((((0x7f)))) - 1) & ((((0x7f)))))
^ ((((0x7f)))))) >> (8)) != 0) ? 8 + ((((u_long)((((((
(((0x7f))) >> 8)) - 1) & (((((0x7f))) >> 8)))
^ (((((0x7f))) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)((((((((((0x7f))) >> 8) >> 4)) - 1) & (
(((((0x7f))) >> 8) >> 4))) ^ ((((((0x7f))) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
((((((0x7f))) >> 8) >> 4) >> 2)) - 1) &
(((((((0x7f))) >> 8) >> 4) >> 2))) ^ (((((
((0x7f))) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x7f))) >> 8) >>
4))) - 1) & (((((((0x7f))) >> 8) >> 4)))) ^ (
((((((0x7f))) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)((((((((((0x7f))) >> 8))) - 1) &
((((((0x7f))) >> 8)))) ^ ((((((0x7f))) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)(((((((((((0x7f))) >>
8)) >> 2)) - 1) & (((((((0x7f))) >> 8)) >>
2))) ^ (((((((0x7f))) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x7f))) >> 8
)))) - 1) & (((((((0x7f))) >> 8))))) ^ (((((((0x7f)
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)(((((((((0x7f))))) - 1) & (((((0x7f)))))) ^ (((((0x7f)))
)))) >> (4)) != 0) ? 4 + ((((u_long)((((((((((0x7f)))) >>
4)) - 1) & ((((((0x7f)))) >> 4))) ^ ((((((0x7f))))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
(((0x7f)))) >> 4) >> 2)) - 1) & (((((((0x7f))
)) >> 4) >> 2))) ^ (((((((0x7f)))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x7f
)))) >> 4))) - 1) & (((((((0x7f)))) >> 4)))) ^
(((((((0x7f)))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)((((((((((0x7f)))))) - 1) & ((((((0x7f))))
))) ^ ((((((0x7f)))))))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0x7f))))) >> 2)) - 1) & (((((((0x7f))))
) >> 2))) ^ (((((((0x7f))))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x7f))))))) - 1) &
(((((((0x7f)))))))) ^ (((((((0x7f))))))))) >> (1)) != 0
) ? 1 : 0))))))) == 0) ? (void)0 : __assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c"
, 4698, "(addr & ~PRESHIFT(RTW_BB_ADDR_MASK)) == 0"))
;
4699 KASSERT((val & ~PRESHIFT(RTW_BB_WR_MASK)) == 0)(((val & ~((((0xff00)) & ((0xff00))) >> ((((u_long
)(((((((0xff00))) - 1) & (((0xff00)))) ^ (((0xff00))))) >>
(16)) != 0) ? 16 + ((((u_long)((((((((0xff00)) >> 16))
- 1) & ((((0xff00)) >> 16))) ^ ((((0xff00)) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)(((((((((0xff00)
) >> 16) >> 8)) - 1) & (((((0xff00)) >>
16) >> 8))) ^ (((((0xff00)) >> 16) >> 8)))
) >> (4)) != 0) ? 4 + ((((u_long)((((((((((0xff00)) >>
16) >> 8) >> 4)) - 1) & ((((((0xff00)) >>
16) >> 8) >> 4))) ^ ((((((0xff00)) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
((((((0xff00)) >> 16) >> 8) >> 4) >> 2
)) - 1) & (((((((0xff00)) >> 16) >> 8) >>
4) >> 2))) ^ (((((((0xff00)) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
(((((((((((0xff00)) >> 16) >> 8) >> 4))) - 1
) & (((((((0xff00)) >> 16) >> 8) >> 4))
)) ^ (((((((0xff00)) >> 16) >> 8) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0xff00)
) >> 16) >> 8))) - 1) & ((((((0xff00)) >>
16) >> 8)))) ^ ((((((0xff00)) >> 16) >> 8)
)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0xff00))
>> 16) >> 8)) >> 2)) - 1) & (((((((0xff00
)) >> 16) >> 8)) >> 2))) ^ (((((((0xff00)) >>
16) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)(((((((((((0xff00)) >> 16) >> 8))))
- 1) & (((((((0xff00)) >> 16) >> 8))))) ^ ((
(((((0xff00)) >> 16) >> 8)))))) >> (1)) != 0
) ? 1 : 0))) : ((((u_long)(((((((((0xff00)) >> 16))) - 1
) & (((((0xff00)) >> 16)))) ^ (((((0xff00)) >>
16))))) >> (4)) != 0) ? 4 + ((((u_long)((((((((((0xff00
)) >> 16)) >> 4)) - 1) & ((((((0xff00)) >>
16)) >> 4))) ^ ((((((0xff00)) >> 16)) >> 4
)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0xff00))
>> 16)) >> 4) >> 2)) - 1) & (((((((0xff00
)) >> 16)) >> 4) >> 2))) ^ (((((((0xff00)) >>
16)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)(((((((((((0xff00)) >> 16)) >> 4)))
- 1) & (((((((0xff00)) >> 16)) >> 4)))) ^ ((
(((((0xff00)) >> 16)) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)((((((((((0xff00)) >> 16)))) -
1) & ((((((0xff00)) >> 16))))) ^ ((((((0xff00)) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0xff00
)) >> 16))) >> 2)) - 1) & (((((((0xff00)) >>
16))) >> 2))) ^ (((((((0xff00)) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xff00
)) >> 16))))) - 1) & (((((((0xff00)) >> 16)))
))) ^ (((((((0xff00)) >> 16))))))) >> (1)) != 0) ?
1 : 0)))) : ((((u_long)((((((((0xff00)))) - 1) & ((((0xff00
))))) ^ ((((0xff00)))))) >> (8)) != 0) ? 8 + ((((u_long
)(((((((((0xff00))) >> 8)) - 1) & (((((0xff00))) >>
8))) ^ (((((0xff00))) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)((((((((((0xff00))) >> 8) >> 4)) - 1
) & ((((((0xff00))) >> 8) >> 4))) ^ ((((((0xff00
))) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((
u_long)(((((((((((0xff00))) >> 8) >> 4) >> 2
)) - 1) & (((((((0xff00))) >> 8) >> 4) >>
2))) ^ (((((((0xff00))) >> 8) >> 4) >> 2))
)) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xff00
))) >> 8) >> 4))) - 1) & (((((((0xff00))) >>
8) >> 4)))) ^ (((((((0xff00))) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0xff00
))) >> 8))) - 1) & ((((((0xff00))) >> 8)))) ^
((((((0xff00))) >> 8))))) >> (2)) != 0) ? 2 + ((
((u_long)(((((((((((0xff00))) >> 8)) >> 2)) - 1) &
(((((((0xff00))) >> 8)) >> 2))) ^ (((((((0xff00)
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)(((((((((((0xff00))) >> 8)))) - 1) & ((
(((((0xff00))) >> 8))))) ^ (((((((0xff00))) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((0xff00
))))) - 1) & (((((0xff00)))))) ^ (((((0xff00))))))) >>
(4)) != 0) ? 4 + ((((u_long)((((((((((0xff00)))) >> 4)
) - 1) & ((((((0xff00)))) >> 4))) ^ ((((((0xff00)))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
((((0xff00)))) >> 4) >> 2)) - 1) & (((((((0xff00
)))) >> 4) >> 2))) ^ (((((((0xff00)))) >> 4
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
(((((((((0xff00)))) >> 4))) - 1) & (((((((0xff00)))
) >> 4)))) ^ (((((((0xff00)))) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0xff00)))))) - 1
) & ((((((0xff00))))))) ^ ((((((0xff00)))))))) >> (
2)) != 0) ? 2 + ((((u_long)(((((((((((0xff00))))) >> 2)
) - 1) & (((((((0xff00))))) >> 2))) ^ (((((((0xff00
))))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)(((((((((((0xff00))))))) - 1) & (((((((0xff00)))))))) ^ (
((((((0xff00))))))))) >> (1)) != 0) ? 1 : 0))))))) == 0
) ? (void)0 : __assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c"
, 4699, "(val & ~PRESHIFT(RTW_BB_WR_MASK)) == 0"))
;
4700
4701 wrbbp = LSHIFT(addr, RTW_BB_ADDR_MASK)((addr) << ((((u_long)((((((0x7f)) - 1) & ((0x7f)))
^ ((0x7f)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x7f
) >> 16)) - 1) & (((0x7f) >> 16))) ^ (((0x7f)
>> 16)))) >> (8)) != 0) ? 8 + ((((u_long)(((((((
(0x7f) >> 16) >> 8)) - 1) & ((((0x7f) >>
16) >> 8))) ^ ((((0x7f) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x7f) >> 16) >>
8) >> 4)) - 1) & (((((0x7f) >> 16) >> 8
) >> 4))) ^ (((((0x7f) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f) >> 16
) >> 8) >> 4))) - 1) & ((((((0x7f) >> 16
) >> 8) >> 4)))) ^ ((((((0x7f) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x7f) >> 16) >> 8))) - 1) & (((((0x7f
) >> 16) >> 8)))) ^ (((((0x7f) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f) >>
16) >> 8)) >> 2)) - 1) & ((((((0x7f) >>
16) >> 8)) >> 2))) ^ ((((((0x7f) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x7f) >> 16) >> 8)))) - 1) & (((((
(0x7f) >> 16) >> 8))))) ^ ((((((0x7f) >> 16
) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f) >> 16))) - 1) & ((((0x7f) >> 16
)))) ^ ((((0x7f) >> 16))))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0x7f) >> 16)) >> 4)) - 1) &
(((((0x7f) >> 16)) >> 4))) ^ (((((0x7f) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x7f) >> 16)) >> 4) >> 2)) - 1) &
((((((0x7f) >> 16)) >> 4) >> 2))) ^ ((((((
0x7f) >> 16)) >> 4) >> 2)))) >> (1)) !=
0) ? 1 : 0) : ((((u_long)((((((((((0x7f) >> 16)) >>
4))) - 1) & ((((((0x7f) >> 16)) >> 4)))) ^ (
(((((0x7f) >> 16)) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x7f) >> 16)))) - 1) &
(((((0x7f) >> 16))))) ^ (((((0x7f) >> 16)))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f) >> 16))) >>
2)) - 1) & ((((((0x7f) >> 16))) >> 2))) ^ ((
((((0x7f) >> 16))) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f) >> 16))))) - 1) &
((((((0x7f) >> 16)))))) ^ ((((((0x7f) >> 16)))))
)) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x7f))
) - 1) & (((0x7f)))) ^ (((0x7f))))) >> (8)) != 0) ?
8 + ((((u_long)((((((((0x7f)) >> 8)) - 1) & ((((0x7f
)) >> 8))) ^ ((((0x7f)) >> 8)))) >> (4)) !=
0) ? 4 + ((((u_long)(((((((((0x7f)) >> 8) >> 4))
- 1) & (((((0x7f)) >> 8) >> 4))) ^ (((((0x7f
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f)) >> 8) >> 4) >> 2)) - 1) &
((((((0x7f)) >> 8) >> 4) >> 2))) ^ ((((((0x7f
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x7f)) >> 8) >> 4
))) - 1) & ((((((0x7f)) >> 8) >> 4)))) ^ ((((
((0x7f)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0x7f)) >> 8))) - 1) & ((
(((0x7f)) >> 8)))) ^ (((((0x7f)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f)) >> 8)) >>
2)) - 1) & ((((((0x7f)) >> 8)) >> 2))) ^ (((
(((0x7f)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x7f)) >> 8)))) - 1) &
((((((0x7f)) >> 8))))) ^ ((((((0x7f)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x7f))))
- 1) & ((((0x7f))))) ^ ((((0x7f)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x7f))) >> 4)) - 1) & (
((((0x7f))) >> 4))) ^ (((((0x7f))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f))) >> 4) >>
2)) - 1) & ((((((0x7f))) >> 4) >> 2))) ^ (((
(((0x7f))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x7f))) >> 4))) - 1) &
((((((0x7f))) >> 4)))) ^ ((((((0x7f))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f))))
) - 1) & (((((0x7f)))))) ^ (((((0x7f))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0x7f)))) >> 2)) - 1) &
((((((0x7f)))) >> 2))) ^ ((((((0x7f)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f))))
)) - 1) & ((((((0x7f))))))) ^ ((((((0x7f)))))))) >>
(1)) != 0) ? 1 : 0))))))
| RTW_BB_WREN(1<<7) |
4702 LSHIFT(val, RTW_BB_WR_MASK)((val) << ((((u_long)((((((0xff00)) - 1) & ((0xff00
))) ^ ((0xff00)))) >> (16)) != 0) ? 16 + ((((u_long)(((
((((0xff00) >> 16)) - 1) & (((0xff00) >> 16))
) ^ (((0xff00) >> 16)))) >> (8)) != 0) ? 8 + ((((
u_long)((((((((0xff00) >> 16) >> 8)) - 1) & (
(((0xff00) >> 16) >> 8))) ^ ((((0xff00) >> 16
) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((
((0xff00) >> 16) >> 8) >> 4)) - 1) & ((
(((0xff00) >> 16) >> 8) >> 4))) ^ (((((0xff00
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xff00) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xff00) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xff00) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xff00) >> 16) >> 8) >>
4))) - 1) & ((((((0xff00) >> 16) >> 8) >>
4)))) ^ ((((((0xff00) >> 16) >> 8) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00
) >> 16) >> 8))) - 1) & (((((0xff00) >>
16) >> 8)))) ^ (((((0xff00) >> 16) >> 8)))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00) >>
16) >> 8)) >> 2)) - 1) & ((((((0xff00) >>
16) >> 8)) >> 2))) ^ ((((((0xff00) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff00) >> 16) >> 8)))) - 1) & (((
(((0xff00) >> 16) >> 8))))) ^ ((((((0xff00) >>
16) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00) >> 16))) - 1) & ((((0xff00) >>
16)))) ^ ((((0xff00) >> 16))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xff00) >> 16)) >> 4)) - 1
) & (((((0xff00) >> 16)) >> 4))) ^ (((((0xff00
) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xff00) >> 16)) >> 4) >> 2
)) - 1) & ((((((0xff00) >> 16)) >> 4) >>
2))) ^ ((((((0xff00) >> 16)) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)
>> 16)) >> 4))) - 1) & ((((((0xff00) >>
16)) >> 4)))) ^ ((((((0xff00) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff00
) >> 16)))) - 1) & (((((0xff00) >> 16))))) ^ (
((((0xff00) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00) >> 16))) >> 2)) - 1) & (((
(((0xff00) >> 16))) >> 2))) ^ ((((((0xff00) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff00) >> 16))))) - 1) & ((((((0xff00) >>
16)))))) ^ ((((((0xff00) >> 16))))))) >> (1)) !=
0) ? 1 : 0)))) : ((((u_long)(((((((0xff00))) - 1) & (((0xff00
)))) ^ (((0xff00))))) >> (8)) != 0) ? 8 + ((((u_long)((
((((((0xff00)) >> 8)) - 1) & ((((0xff00)) >> 8
))) ^ ((((0xff00)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xff00)) >> 8) >> 4)) - 1) &
(((((0xff00)) >> 8) >> 4))) ^ (((((0xff00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff00)) >> 8) >> 4) >> 2)) - 1) &
((((((0xff00)) >> 8) >> 4) >> 2))) ^ (((((
(0xff00)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8) >>
4))) - 1) & ((((((0xff00)) >> 8) >> 4)))) ^ (
(((((0xff00)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xff00)) >> 8))) - 1) &
(((((0xff00)) >> 8)))) ^ (((((0xff00)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff00)) >>
8)) >> 2)) - 1) & ((((((0xff00)) >> 8)) >>
2))) ^ ((((((0xff00)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)) >> 8
)))) - 1) & ((((((0xff00)) >> 8))))) ^ ((((((0xff00
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff00)))) - 1) & ((((0xff00))))) ^ ((((0xff00))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff00))) >>
4)) - 1) & (((((0xff00))) >> 4))) ^ (((((0xff00)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xff00))) >> 4) >> 2)) - 1) & ((((((0xff00)
)) >> 4) >> 2))) ^ ((((((0xff00))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00
))) >> 4))) - 1) & ((((((0xff00))) >> 4)))) ^
((((((0xff00))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xff00))))) - 1) & (((((0xff00)))
))) ^ (((((0xff00))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff00)))) >> 2)) - 1) & ((((((0xff00)))
) >> 2))) ^ ((((((0xff00)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff00)))))) - 1) &
((((((0xff00))))))) ^ ((((((0xff00)))))))) >> (1)) != 0
) ? 1 : 0))))))
| RTW_BB_RD_MASK0xff0000,
4703
4704 rdbbp = LSHIFT(addr, RTW_BB_ADDR_MASK)((addr) << ((((u_long)((((((0x7f)) - 1) & ((0x7f)))
^ ((0x7f)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x7f
) >> 16)) - 1) & (((0x7f) >> 16))) ^ (((0x7f)
>> 16)))) >> (8)) != 0) ? 8 + ((((u_long)(((((((
(0x7f) >> 16) >> 8)) - 1) & ((((0x7f) >>
16) >> 8))) ^ ((((0x7f) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x7f) >> 16) >>
8) >> 4)) - 1) & (((((0x7f) >> 16) >> 8
) >> 4))) ^ (((((0x7f) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f) >> 16
) >> 8) >> 4))) - 1) & ((((((0x7f) >> 16
) >> 8) >> 4)))) ^ ((((((0x7f) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x7f) >> 16) >> 8))) - 1) & (((((0x7f
) >> 16) >> 8)))) ^ (((((0x7f) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f) >>
16) >> 8)) >> 2)) - 1) & ((((((0x7f) >>
16) >> 8)) >> 2))) ^ ((((((0x7f) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x7f) >> 16) >> 8)))) - 1) & (((((
(0x7f) >> 16) >> 8))))) ^ ((((((0x7f) >> 16
) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f) >> 16))) - 1) & ((((0x7f) >> 16
)))) ^ ((((0x7f) >> 16))))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0x7f) >> 16)) >> 4)) - 1) &
(((((0x7f) >> 16)) >> 4))) ^ (((((0x7f) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x7f) >> 16)) >> 4) >> 2)) - 1) &
((((((0x7f) >> 16)) >> 4) >> 2))) ^ ((((((
0x7f) >> 16)) >> 4) >> 2)))) >> (1)) !=
0) ? 1 : 0) : ((((u_long)((((((((((0x7f) >> 16)) >>
4))) - 1) & ((((((0x7f) >> 16)) >> 4)))) ^ (
(((((0x7f) >> 16)) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x7f) >> 16)))) - 1) &
(((((0x7f) >> 16))))) ^ (((((0x7f) >> 16)))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f) >> 16))) >>
2)) - 1) & ((((((0x7f) >> 16))) >> 2))) ^ ((
((((0x7f) >> 16))) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f) >> 16))))) - 1) &
((((((0x7f) >> 16)))))) ^ ((((((0x7f) >> 16)))))
)) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x7f))
) - 1) & (((0x7f)))) ^ (((0x7f))))) >> (8)) != 0) ?
8 + ((((u_long)((((((((0x7f)) >> 8)) - 1) & ((((0x7f
)) >> 8))) ^ ((((0x7f)) >> 8)))) >> (4)) !=
0) ? 4 + ((((u_long)(((((((((0x7f)) >> 8) >> 4))
- 1) & (((((0x7f)) >> 8) >> 4))) ^ (((((0x7f
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f)) >> 8) >> 4) >> 2)) - 1) &
((((((0x7f)) >> 8) >> 4) >> 2))) ^ ((((((0x7f
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x7f)) >> 8) >> 4
))) - 1) & ((((((0x7f)) >> 8) >> 4)))) ^ ((((
((0x7f)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0x7f)) >> 8))) - 1) & ((
(((0x7f)) >> 8)))) ^ (((((0x7f)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f)) >> 8)) >>
2)) - 1) & ((((((0x7f)) >> 8)) >> 2))) ^ (((
(((0x7f)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x7f)) >> 8)))) - 1) &
((((((0x7f)) >> 8))))) ^ ((((((0x7f)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x7f))))
- 1) & ((((0x7f))))) ^ ((((0x7f)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x7f))) >> 4)) - 1) & (
((((0x7f))) >> 4))) ^ (((((0x7f))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f))) >> 4) >>
2)) - 1) & ((((((0x7f))) >> 4) >> 2))) ^ (((
(((0x7f))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x7f))) >> 4))) - 1) &
((((((0x7f))) >> 4)))) ^ ((((((0x7f))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f))))
) - 1) & (((((0x7f)))))) ^ (((((0x7f))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0x7f)))) >> 2)) - 1) &
((((((0x7f)))) >> 2))) ^ ((((((0x7f)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f))))
)) - 1) & ((((((0x7f))))))) ^ ((((((0x7f)))))))) >>
(1)) != 0) ? 1 : 0))))))
|
4705 RTW_BB_WR_MASK0xff00 | RTW_BB_RD_MASK0xff0000;
4706
4707 RTW_DPRINTF(RTW_DEBUG_PHYIO,
4708 ("%s: rdbbp = %#08x, wrbbp = %#08x\n", __func__, rdbbp, wrbbp));
4709
4710 for (i = BBP_WRITE_ITERS50; --i >= 0; ) {
4711 RTW_RBW(regs, RTW_BB, RTW_BB)((*(regs)->r_barrier)(regs, 0x7c, 0x7c, 0x01));
4712 RTW_WRITE(regs, RTW_BB, wrbbp)((*(regs)->r_write32)(regs, 0x7c, wrbbp));
4713 RTW_SYNC(regs, RTW_BB, RTW_BB)((*(regs)->r_barrier)(regs, 0x7c, 0x7c, (0x01|0x02)));
4714 RTW_WRITE(regs, RTW_BB, rdbbp)((*(regs)->r_write32)(regs, 0x7c, rdbbp));
4715 RTW_SYNC(regs, RTW_BB, RTW_BB)((*(regs)->r_barrier)(regs, 0x7c, 0x7c, (0x01|0x02)));
4716 delay(BBP_WRITE_DELAY)(*delay_func)(1); /* 1 microsecond */
4717 if (MASK_AND_RSHIFT(RTW_READ(regs, RTW_BB),(((((*(regs)->r_read32)(regs, 0x7c))) & (0xff0000)) >>
((((u_long)((((((0xff0000)) - 1) & ((0xff0000))) ^ ((0xff0000
)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xff0000) >>
16)) - 1) & (((0xff0000) >> 16))) ^ (((0xff0000) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xff0000
) >> 16) >> 8)) - 1) & ((((0xff0000) >>
16) >> 8))) ^ ((((0xff0000) >> 16) >> 8)))
) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff0000) >>
16) >> 8) >> 4)) - 1) & (((((0xff0000) >>
16) >> 8) >> 4))) ^ (((((0xff0000) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff0000) >> 16) >> 8) >> 4) >> 2
)) - 1) & ((((((0xff0000) >> 16) >> 8) >>
4) >> 2))) ^ ((((((0xff0000) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xff0000) >> 16) >> 8) >> 4))) - 1
) & ((((((0xff0000) >> 16) >> 8) >> 4))
)) ^ ((((((0xff0000) >> 16) >> 8) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff0000
) >> 16) >> 8))) - 1) & (((((0xff0000) >>
16) >> 8)))) ^ (((((0xff0000) >> 16) >> 8)
)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff0000)
>> 16) >> 8)) >> 2)) - 1) & ((((((0xff0000
) >> 16) >> 8)) >> 2))) ^ ((((((0xff0000) >>
16) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)((((((((((0xff0000) >> 16) >> 8))))
- 1) & ((((((0xff0000) >> 16) >> 8))))) ^ ((
((((0xff0000) >> 16) >> 8)))))) >> (1)) != 0
) ? 1 : 0))) : ((((u_long)((((((((0xff0000) >> 16))) - 1
) & ((((0xff0000) >> 16)))) ^ ((((0xff0000) >>
16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff0000
) >> 16)) >> 4)) - 1) & (((((0xff0000) >>
16)) >> 4))) ^ (((((0xff0000) >> 16)) >> 4
)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff0000)
>> 16)) >> 4) >> 2)) - 1) & ((((((0xff0000
) >> 16)) >> 4) >> 2))) ^ ((((((0xff0000) >>
16)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)((((((((((0xff0000) >> 16)) >> 4)))
- 1) & ((((((0xff0000) >> 16)) >> 4)))) ^ ((
((((0xff0000) >> 16)) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)(((((((((0xff0000) >> 16)))) -
1) & (((((0xff0000) >> 16))))) ^ (((((0xff0000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff0000
) >> 16))) >> 2)) - 1) & ((((((0xff0000) >>
16))) >> 2))) ^ ((((((0xff0000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0000
) >> 16))))) - 1) & ((((((0xff0000) >> 16))))
)) ^ ((((((0xff0000) >> 16))))))) >> (1)) != 0) ?
1 : 0)))) : ((((u_long)(((((((0xff0000))) - 1) & (((0xff0000
)))) ^ (((0xff0000))))) >> (8)) != 0) ? 8 + ((((u_long)
((((((((0xff0000)) >> 8)) - 1) & ((((0xff0000)) >>
8))) ^ ((((0xff0000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xff0000)) >> 8) >> 4)) - 1
) & (((((0xff0000)) >> 8) >> 4))) ^ (((((0xff0000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff0000)) >> 8) >> 4) >> 2)) - 1
) & ((((((0xff0000)) >> 8) >> 4) >> 2))
) ^ ((((((0xff0000)) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0000)) >>
8) >> 4))) - 1) & ((((((0xff0000)) >> 8) >>
4)))) ^ ((((((0xff0000)) >> 8) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff0000)) >>
8))) - 1) & (((((0xff0000)) >> 8)))) ^ (((((0xff0000
)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff0000)) >> 8)) >> 2)) - 1) & ((((((0xff0000
)) >> 8)) >> 2))) ^ ((((((0xff0000)) >> 8))
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0xff0000)) >> 8)))) - 1) & ((((((0xff0000)) >>
8))))) ^ ((((((0xff0000)) >> 8)))))) >> (1)) != 0
) ? 1 : 0))) : ((((u_long)((((((((0xff0000)))) - 1) & (((
(0xff0000))))) ^ ((((0xff0000)))))) >> (4)) != 0) ? 4 +
((((u_long)(((((((((0xff0000))) >> 4)) - 1) & ((((
(0xff0000))) >> 4))) ^ (((((0xff0000))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff0000))) >> 4
) >> 2)) - 1) & ((((((0xff0000))) >> 4) >>
2))) ^ ((((((0xff0000))) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0000))) >>
4))) - 1) & ((((((0xff0000))) >> 4)))) ^ ((((((0xff0000
))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xff0000))))) - 1) & (((((0xff0000)))))) ^ ((((
(0xff0000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xff0000)))) >> 2)) - 1) & ((((((0xff0000)))) >>
2))) ^ ((((((0xff0000)))) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xff0000)))))) - 1) & ((
((((0xff0000))))))) ^ ((((((0xff0000)))))))) >> (1)) !=
0) ? 1 : 0))))))
4718 RTW_BB_RD_MASK)(((((*(regs)->r_read32)(regs, 0x7c))) & (0xff0000)) >>
((((u_long)((((((0xff0000)) - 1) & ((0xff0000))) ^ ((0xff0000
)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xff0000) >>
16)) - 1) & (((0xff0000) >> 16))) ^ (((0xff0000) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xff0000
) >> 16) >> 8)) - 1) & ((((0xff0000) >>
16) >> 8))) ^ ((((0xff0000) >> 16) >> 8)))
) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff0000) >>
16) >> 8) >> 4)) - 1) & (((((0xff0000) >>
16) >> 8) >> 4))) ^ (((((0xff0000) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff0000) >> 16) >> 8) >> 4) >> 2
)) - 1) & ((((((0xff0000) >> 16) >> 8) >>
4) >> 2))) ^ ((((((0xff0000) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xff0000) >> 16) >> 8) >> 4))) - 1
) & ((((((0xff0000) >> 16) >> 8) >> 4))
)) ^ ((((((0xff0000) >> 16) >> 8) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff0000
) >> 16) >> 8))) - 1) & (((((0xff0000) >>
16) >> 8)))) ^ (((((0xff0000) >> 16) >> 8)
)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff0000)
>> 16) >> 8)) >> 2)) - 1) & ((((((0xff0000
) >> 16) >> 8)) >> 2))) ^ ((((((0xff0000) >>
16) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)((((((((((0xff0000) >> 16) >> 8))))
- 1) & ((((((0xff0000) >> 16) >> 8))))) ^ ((
((((0xff0000) >> 16) >> 8)))))) >> (1)) != 0
) ? 1 : 0))) : ((((u_long)((((((((0xff0000) >> 16))) - 1
) & ((((0xff0000) >> 16)))) ^ ((((0xff0000) >>
16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xff0000
) >> 16)) >> 4)) - 1) & (((((0xff0000) >>
16)) >> 4))) ^ (((((0xff0000) >> 16)) >> 4
)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff0000)
>> 16)) >> 4) >> 2)) - 1) & ((((((0xff0000
) >> 16)) >> 4) >> 2))) ^ ((((((0xff0000) >>
16)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)((((((((((0xff0000) >> 16)) >> 4)))
- 1) & ((((((0xff0000) >> 16)) >> 4)))) ^ ((
((((0xff0000) >> 16)) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)(((((((((0xff0000) >> 16)))) -
1) & (((((0xff0000) >> 16))))) ^ (((((0xff0000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff0000
) >> 16))) >> 2)) - 1) & ((((((0xff0000) >>
16))) >> 2))) ^ ((((((0xff0000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0000
) >> 16))))) - 1) & ((((((0xff0000) >> 16))))
)) ^ ((((((0xff0000) >> 16))))))) >> (1)) != 0) ?
1 : 0)))) : ((((u_long)(((((((0xff0000))) - 1) & (((0xff0000
)))) ^ (((0xff0000))))) >> (8)) != 0) ? 8 + ((((u_long)
((((((((0xff0000)) >> 8)) - 1) & ((((0xff0000)) >>
8))) ^ ((((0xff0000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xff0000)) >> 8) >> 4)) - 1
) & (((((0xff0000)) >> 8) >> 4))) ^ (((((0xff0000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff0000)) >> 8) >> 4) >> 2)) - 1
) & ((((((0xff0000)) >> 8) >> 4) >> 2))
) ^ ((((((0xff0000)) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0000)) >>
8) >> 4))) - 1) & ((((((0xff0000)) >> 8) >>
4)))) ^ ((((((0xff0000)) >> 8) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff0000)) >>
8))) - 1) & (((((0xff0000)) >> 8)))) ^ (((((0xff0000
)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff0000)) >> 8)) >> 2)) - 1) & ((((((0xff0000
)) >> 8)) >> 2))) ^ ((((((0xff0000)) >> 8))
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0xff0000)) >> 8)))) - 1) & ((((((0xff0000)) >>
8))))) ^ ((((((0xff0000)) >> 8)))))) >> (1)) != 0
) ? 1 : 0))) : ((((u_long)((((((((0xff0000)))) - 1) & (((
(0xff0000))))) ^ ((((0xff0000)))))) >> (4)) != 0) ? 4 +
((((u_long)(((((((((0xff0000))) >> 4)) - 1) & ((((
(0xff0000))) >> 4))) ^ (((((0xff0000))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff0000))) >> 4
) >> 2)) - 1) & ((((((0xff0000))) >> 4) >>
2))) ^ ((((((0xff0000))) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0000))) >>
4))) - 1) & ((((((0xff0000))) >> 4)))) ^ ((((((0xff0000
))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xff0000))))) - 1) & (((((0xff0000)))))) ^ ((((
(0xff0000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xff0000)))) >> 2)) - 1) & ((((((0xff0000)))) >>
2))) ^ ((((((0xff0000)))) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xff0000)))))) - 1) & ((
((((0xff0000))))))) ^ ((((((0xff0000)))))))) >> (1)) !=
0) ? 1 : 0))))))
== val) {
4719 RTW_DPRINTF(RTW_DEBUG_PHYIO,
4720 ("%s: finished in %dus\n", __func__,
4721 BBP_WRITE_DELAY * (BBP_WRITE_ITERS - i)));
4722 return 0;
4723 }
4724 delay(BBP_WRITE_DELAY)(*delay_func)(1); /* again */
4725 }
4726 printf("%s: timeout\n", __func__);
4727 return -1;
4728}
4729
4730/* Help rtw_rf_hostwrite bang bits to RF over 3-wire interface. */
4731void
4732rtw_rf_hostbangbits(struct rtw_regs *regs, u_int32_t bits, int lo_to_hi,
4733 u_int nbits)
4734{
4735 int i;
4736 u_int32_t mask, reg;
4737
4738 KASSERT(nbits <= 32)((nbits <= 32) ? (void)0 : __assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c"
, 4738, "nbits <= 32"))
;
4739
4740 RTW_DPRINTF(RTW_DEBUG_PHYIO,
4741 ("%s: %u bits, %#08x, %s\n", __func__, nbits, bits,
4742 (lo_to_hi) ? "lo to hi" : "hi to lo"));
4743
4744 reg = RTW8180_PHYCFG_HST(1<<30);
4745 RTW_WRITE(regs, RTW8180_PHYCFG, reg)((*(regs)->r_write32)(regs, 0x80, reg));
4746 RTW_SYNC(regs, RTW8180_PHYCFG, RTW8180_PHYCFG)((*(regs)->r_barrier)(regs, 0x80, 0x80, (0x01|0x02)));
4747
4748 if (lo_to_hi)
4749 mask = 0x1;
4750 else
4751 mask = 1 << (nbits - 1);
4752
4753 for (i = 0; i < nbits; i++) {
4754 RTW_DPRINTF(RTW_DEBUG_PHYBITIO,
4755 ("%s: bits %#08x mask %#08x -> bit %#08x\n",
4756 __func__, bits, mask, bits & mask));
4757
4758 if ((bits & mask) != 0)
4759 reg |= RTW8180_PHYCFG_HST_DATA(1<<0);
4760 else
4761 reg &= ~RTW8180_PHYCFG_HST_DATA(1<<0);
4762
4763 reg |= RTW8180_PHYCFG_HST_CLK(1<<1);
4764 RTW_WRITE(regs, RTW8180_PHYCFG, reg)((*(regs)->r_write32)(regs, 0x80, reg));
4765 RTW_SYNC(regs, RTW8180_PHYCFG, RTW8180_PHYCFG)((*(regs)->r_barrier)(regs, 0x80, 0x80, (0x01|0x02)));
4766
4767 DELAY(2)(*delay_func)(2); /* arbitrary delay */
4768
4769 reg &= ~RTW8180_PHYCFG_HST_CLK(1<<1);
4770 RTW_WRITE(regs, RTW8180_PHYCFG, reg)((*(regs)->r_write32)(regs, 0x80, reg));
4771 RTW_SYNC(regs, RTW8180_PHYCFG, RTW8180_PHYCFG)((*(regs)->r_barrier)(regs, 0x80, 0x80, (0x01|0x02)));
4772
4773 if (lo_to_hi)
4774 mask <<= 1;
4775 else
4776 mask >>= 1;
4777 }
4778
4779 reg |= RTW8180_PHYCFG_HST_EN(1<<2);
4780 KASSERT((reg & RTW8180_PHYCFG_HST_CLK) == 0)(((reg & (1<<1)) == 0) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 4780, "(reg & RTW8180_PHYCFG_HST_CLK) == 0"
))
;
4781 RTW_WRITE(regs, RTW8180_PHYCFG, reg)((*(regs)->r_write32)(regs, 0x80, reg));
4782 RTW_SYNC(regs, RTW8180_PHYCFG, RTW8180_PHYCFG)((*(regs)->r_barrier)(regs, 0x80, 0x80, (0x01|0x02)));
4783}
4784
4785#if 0
4786void
4787rtw_rf_rtl8225_hostbangbits(struct rtw_regs *regs, u_int32_t bits, int lo_to_hi,
4788 u_int nbits)
4789{
4790 int i;
4791 u_int8_t page;
4792 u_int16_t reg0, reg1, reg2;
4793 u_int32_t mask;
4794
4795 /* enable page 0 */
4796 page = RTW_READ8(regs, RTW_PSR)((*(regs)->r_read8)(regs, 0x5e));
4797 RTW_WRITE8(regs, RTW_PSR, page & ~RTW_PSR_PSEN)((*(regs)->r_write8)(regs, 0x5e, page & ~(1<<0))
)
;
4798
4799 /* enable RF access */
4800 reg0 = RTW_READ16(regs, RTW8185_RFPINSOUTPUT)((*(regs)->r_read16)(regs, 0x80)) &
4801 RTW8185_RFPINSOUTPUT_MASK0xfff3;
4802 reg1 = RTW_READ16(regs, RTW8185_RFPINSENABLE)((*(regs)->r_read16)(regs, 0x82));
4803 RTW_WRITE16(regs, RTW8185_RFPINSENABLE,((*(regs)->r_write16)(regs, 0x82, 0x0007 | reg0))
4804 RTW8185_RFPINSENABLE_ENABLE | reg0)((*(regs)->r_write16)(regs, 0x82, 0x0007 | reg0));
4805 reg2 = RTW_READ16(regs, RTW8185_RFPINSSELECT)((*(regs)->r_read16)(regs, 0x84));
4806 RTW_WRITE16(regs, RTW8185_RFPINSSELECT,((*(regs)->r_write16)(regs, 0x84, 0x0007 | reg1))
4807 RTW8185_RFPINSSELECT_ENABLE | reg1 /* XXX | SW_GPIO_CTL */)((*(regs)->r_write16)(regs, 0x84, 0x0007 | reg1));
4808 DELAY(10)(*delay_func)(10);
4809
4810 RTW_WRITE16(regs, RTW8185_RFPINSOUTPUT, reg0)((*(regs)->r_write16)(regs, 0x80, reg0));
4811 DELAY(10)(*delay_func)(10);
4812
4813 if (lo_to_hi)
4814 mask = 0x1;
4815 else
4816 mask = 1 << (nbits - 1);
4817
4818 for (i = 0; i < nbits; i++) {
4819 RTW_DPRINTF(RTW_DEBUG_PHYBITIO,
4820 ("%s: bits %#08x mask %#08x -> bit %#08x\n",
4821 __func__, bits, mask, bits & mask));
4822
4823 if ((bits & mask) != 0)
4824 reg |= RTW8180_PHYCFG_HST_DATA(1<<0);
4825 else
4826 reg &= ~RTW8180_PHYCFG_HST_DATA(1<<0);
4827
4828 reg |= RTW8180_PHYCFG_HST_CLK(1<<1);
4829 RTW_WRITE(regs, RTW8180_PHYCFG, reg)((*(regs)->r_write32)(regs, 0x80, reg));
4830 RTW_SYNC(regs, RTW8180_PHYCFG, RTW8180_PHYCFG)((*(regs)->r_barrier)(regs, 0x80, 0x80, (0x01|0x02)));
4831
4832 DELAY(2)(*delay_func)(2); /* arbitrary delay */
4833
4834 reg &= ~RTW8180_PHYCFG_HST_CLK(1<<1);
4835 RTW_WRITE(regs, RTW8180_PHYCFG, reg)((*(regs)->r_write32)(regs, 0x80, reg));
4836 RTW_SYNC(regs, RTW8180_PHYCFG, RTW8180_PHYCFG)((*(regs)->r_barrier)(regs, 0x80, 0x80, (0x01|0x02)));
4837
4838 if (lo_to_hi)
4839 mask <<= 1;
4840 else
4841 mask >>= 1;
4842 }
4843
4844 /* reset the page */
4845 RTW_WRITE8(regs, RTW_PSR, page)((*(regs)->r_write8)(regs, 0x5e, page));
4846}
4847#endif
4848
4849/* Help rtw_rf_macwrite: tell MAC to bang bits to RF over the 3-wire
4850 * interface.
4851 */
4852int
4853rtw_rf_macbangbits(struct rtw_regs *regs, u_int32_t reg)
4854{
4855 int i;
4856
4857 RTW_DPRINTF(RTW_DEBUG_PHY, ("%s: %#08x\n", __func__, reg));
4858
4859 RTW_WRITE(regs, RTW8180_PHYCFG, RTW8180_PHYCFG_MAC_POLL | reg)((*(regs)->r_write32)(regs, 0x80, (1<<31) | reg));
4860
4861 RTW_WBR(regs, RTW8180_PHYCFG, RTW8180_PHYCFG)((*(regs)->r_barrier)(regs, 0x80, 0x80, 0x02));
4862
4863 for (i = rtw_macbangbits_timeout; --i >= 0; delay(1)(*delay_func)(1)) {
4864 if ((RTW_READ(regs, RTW8180_PHYCFG)((*(regs)->r_read32)(regs, 0x80)) &
4865 RTW8180_PHYCFG_MAC_POLL(1<<31)) == 0) {
4866 RTW_DPRINTF(RTW_DEBUG_PHY,
4867 ("%s: finished in %dus\n", __func__,
4868 rtw_macbangbits_timeout - i));
4869 return 0;
4870 }
4871 RTW_RBR(regs, RTW8180_PHYCFG, RTW8180_PHYCFG)((*(regs)->r_barrier)(regs, 0x80, 0x80, 0x01));
4872 }
4873
4874 printf("%s: RTW8180_PHYCFG_MAC_POLL still set.\n", __func__);
4875 return -1;
4876}
4877
4878u_int32_t
4879rtw_grf5101_host_crypt(u_int addr, u_int32_t val)
4880{
4881 /* TBD */
4882 return 0;
4883}
4884
4885u_int32_t
4886rtw_grf5101_mac_crypt(u_int addr, u_int32_t val)
4887{
4888 u_int32_t data_and_addr;
4889#define EXTRACT_NIBBLE(d, which) (((d) >> (4 * (which))) & 0xf)
4890 static u_int8_t caesar[16] = {
4891 0x0, 0x8, 0x4, 0xc,
4892 0x2, 0xa, 0x6, 0xe,
4893 0x1, 0x9, 0x5, 0xd,
4894 0x3, 0xb, 0x7, 0xf
4895 };
4896 data_and_addr =
4897 caesar[EXTRACT_NIBBLE(val, 2)] |
4898 (caesar[EXTRACT_NIBBLE(val, 1)] << 4) |
4899 (caesar[EXTRACT_NIBBLE(val, 0)] << 8) |
4900 (caesar[(addr >> 1) & 0xf] << 12) |
4901 ((addr & 0x1) << 16) |
4902 (caesar[EXTRACT_NIBBLE(val, 3)] << 24);
4903 return LSHIFT(data_and_addr, RTW8180_PHYCFG_MAC_PHILIPS_ADDR_MASK |((data_and_addr) << ((((u_long)((((((0xf000000 | 0xffffff
)) - 1) & ((0xf000000 | 0xffffff))) ^ ((0xf000000 | 0xffffff
)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xf000000 |
0xffffff) >> 16)) - 1) & (((0xf000000 | 0xffffff) >>
16))) ^ (((0xf000000 | 0xffffff) >> 16)))) >> (8
)) != 0) ? 8 + ((((u_long)((((((((0xf000000 | 0xffffff) >>
16) >> 8)) - 1) & ((((0xf000000 | 0xffffff) >>
16) >> 8))) ^ ((((0xf000000 | 0xffffff) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000
| 0xffffff) >> 16) >> 8) >> 4)) - 1) &
(((((0xf000000 | 0xffffff) >> 16) >> 8) >>
4))) ^ (((((0xf000000 | 0xffffff) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
| 0xffffff) >> 16) >> 8) >> 4) >> 2)
) - 1) & ((((((0xf000000 | 0xffffff) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xf000000 | 0xffffff) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xf000000 | 0xffffff) >>
16) >> 8) >> 4))) - 1) & ((((((0xf000000 | 0xffffff
) >> 16) >> 8) >> 4)))) ^ ((((((0xf000000 |
0xffffff) >> 16) >> 8) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000 | 0xffffff
) >> 16) >> 8))) - 1) & (((((0xf000000 | 0xffffff
) >> 16) >> 8)))) ^ (((((0xf000000 | 0xffffff) >>
16) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf000000 | 0xffffff) >> 16) >> 8)) >>
2)) - 1) & ((((((0xf000000 | 0xffffff) >> 16) >>
8)) >> 2))) ^ ((((((0xf000000 | 0xffffff) >> 16)
>> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0xf000000 | 0xffffff) >> 16) >>
8)))) - 1) & ((((((0xf000000 | 0xffffff) >> 16) >>
8))))) ^ ((((((0xf000000 | 0xffffff) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf000000
| 0xffffff) >> 16))) - 1) & ((((0xf000000 | 0xffffff
) >> 16)))) ^ ((((0xf000000 | 0xffffff) >> 16))))
) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000 | 0xffffff
) >> 16)) >> 4)) - 1) & (((((0xf000000 | 0xffffff
) >> 16)) >> 4))) ^ (((((0xf000000 | 0xffffff) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf000000 | 0xffffff) >> 16)) >> 4) >>
2)) - 1) & ((((((0xf000000 | 0xffffff) >> 16)) >>
4) >> 2))) ^ ((((((0xf000000 | 0xffffff) >> 16))
>> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((
((u_long)((((((((((0xf000000 | 0xffffff) >> 16)) >>
4))) - 1) & ((((((0xf000000 | 0xffffff) >> 16)) >>
4)))) ^ ((((((0xf000000 | 0xffffff) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000
| 0xffffff) >> 16)))) - 1) & (((((0xf000000 | 0xffffff
) >> 16))))) ^ (((((0xf000000 | 0xffffff) >> 16))
)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
| 0xffffff) >> 16))) >> 2)) - 1) & ((((((0xf000000
| 0xffffff) >> 16))) >> 2))) ^ ((((((0xf000000 |
0xffffff) >> 16))) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000 | 0xffffff) >>
16))))) - 1) & ((((((0xf000000 | 0xffffff) >> 16))
)))) ^ ((((((0xf000000 | 0xffffff) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xf000000 | 0xffffff
))) - 1) & (((0xf000000 | 0xffffff)))) ^ (((0xf000000 | 0xffffff
))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xf000000 |
0xffffff)) >> 8)) - 1) & ((((0xf000000 | 0xffffff)
) >> 8))) ^ ((((0xf000000 | 0xffffff)) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000 | 0xffffff)) >>
8) >> 4)) - 1) & (((((0xf000000 | 0xffffff)) >>
8) >> 4))) ^ (((((0xf000000 | 0xffffff)) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
| 0xffffff)) >> 8) >> 4) >> 2)) - 1) &
((((((0xf000000 | 0xffffff)) >> 8) >> 4) >>
2))) ^ ((((((0xf000000 | 0xffffff)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
| 0xffffff)) >> 8) >> 4))) - 1) & ((((((0xf000000
| 0xffffff)) >> 8) >> 4)))) ^ ((((((0xf000000 | 0xffffff
)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)) :
((((u_long)(((((((((0xf000000 | 0xffffff)) >> 8))) - 1
) & (((((0xf000000 | 0xffffff)) >> 8)))) ^ (((((0xf000000
| 0xffffff)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf000000 | 0xffffff)) >> 8)) >> 2)) -
1) & ((((((0xf000000 | 0xffffff)) >> 8)) >> 2
))) ^ ((((((0xf000000 | 0xffffff)) >> 8)) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
| 0xffffff)) >> 8)))) - 1) & ((((((0xf000000 | 0xffffff
)) >> 8))))) ^ ((((((0xf000000 | 0xffffff)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf000000
| 0xffffff)))) - 1) & ((((0xf000000 | 0xffffff))))) ^ ((
((0xf000000 | 0xffffff)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf000000 | 0xffffff))) >> 4)) - 1) & (((
((0xf000000 | 0xffffff))) >> 4))) ^ (((((0xf000000 | 0xffffff
))) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf000000 | 0xffffff))) >> 4) >> 2)) - 1) &
((((((0xf000000 | 0xffffff))) >> 4) >> 2))) ^ ((
((((0xf000000 | 0xffffff))) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000 | 0xffffff
))) >> 4))) - 1) & ((((((0xf000000 | 0xffffff))) >>
4)))) ^ ((((((0xf000000 | 0xffffff))) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000 | 0xffffff
))))) - 1) & (((((0xf000000 | 0xffffff)))))) ^ (((((0xf000000
| 0xffffff))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf000000 | 0xffffff)))) >> 2)) - 1) & ((((((0xf000000
| 0xffffff)))) >> 2))) ^ ((((((0xf000000 | 0xffffff)))
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
((((((((0xf000000 | 0xffffff)))))) - 1) & ((((((0xf000000
| 0xffffff))))))) ^ ((((((0xf000000 | 0xffffff)))))))) >>
(1)) != 0) ? 1 : 0))))))
4904 RTW8180_PHYCFG_MAC_PHILIPS_DATA_MASK)((data_and_addr) << ((((u_long)((((((0xf000000 | 0xffffff
)) - 1) & ((0xf000000 | 0xffffff))) ^ ((0xf000000 | 0xffffff
)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xf000000 |
0xffffff) >> 16)) - 1) & (((0xf000000 | 0xffffff) >>
16))) ^ (((0xf000000 | 0xffffff) >> 16)))) >> (8
)) != 0) ? 8 + ((((u_long)((((((((0xf000000 | 0xffffff) >>
16) >> 8)) - 1) & ((((0xf000000 | 0xffffff) >>
16) >> 8))) ^ ((((0xf000000 | 0xffffff) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000
| 0xffffff) >> 16) >> 8) >> 4)) - 1) &
(((((0xf000000 | 0xffffff) >> 16) >> 8) >>
4))) ^ (((((0xf000000 | 0xffffff) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
| 0xffffff) >> 16) >> 8) >> 4) >> 2)
) - 1) & ((((((0xf000000 | 0xffffff) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xf000000 | 0xffffff) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xf000000 | 0xffffff) >>
16) >> 8) >> 4))) - 1) & ((((((0xf000000 | 0xffffff
) >> 16) >> 8) >> 4)))) ^ ((((((0xf000000 |
0xffffff) >> 16) >> 8) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000 | 0xffffff
) >> 16) >> 8))) - 1) & (((((0xf000000 | 0xffffff
) >> 16) >> 8)))) ^ (((((0xf000000 | 0xffffff) >>
16) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf000000 | 0xffffff) >> 16) >> 8)) >>
2)) - 1) & ((((((0xf000000 | 0xffffff) >> 16) >>
8)) >> 2))) ^ ((((((0xf000000 | 0xffffff) >> 16)
>> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0xf000000 | 0xffffff) >> 16) >>
8)))) - 1) & ((((((0xf000000 | 0xffffff) >> 16) >>
8))))) ^ ((((((0xf000000 | 0xffffff) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf000000
| 0xffffff) >> 16))) - 1) & ((((0xf000000 | 0xffffff
) >> 16)))) ^ ((((0xf000000 | 0xffffff) >> 16))))
) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000 | 0xffffff
) >> 16)) >> 4)) - 1) & (((((0xf000000 | 0xffffff
) >> 16)) >> 4))) ^ (((((0xf000000 | 0xffffff) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf000000 | 0xffffff) >> 16)) >> 4) >>
2)) - 1) & ((((((0xf000000 | 0xffffff) >> 16)) >>
4) >> 2))) ^ ((((((0xf000000 | 0xffffff) >> 16))
>> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((
((u_long)((((((((((0xf000000 | 0xffffff) >> 16)) >>
4))) - 1) & ((((((0xf000000 | 0xffffff) >> 16)) >>
4)))) ^ ((((((0xf000000 | 0xffffff) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000
| 0xffffff) >> 16)))) - 1) & (((((0xf000000 | 0xffffff
) >> 16))))) ^ (((((0xf000000 | 0xffffff) >> 16))
)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
| 0xffffff) >> 16))) >> 2)) - 1) & ((((((0xf000000
| 0xffffff) >> 16))) >> 2))) ^ ((((((0xf000000 |
0xffffff) >> 16))) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000 | 0xffffff) >>
16))))) - 1) & ((((((0xf000000 | 0xffffff) >> 16))
)))) ^ ((((((0xf000000 | 0xffffff) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xf000000 | 0xffffff
))) - 1) & (((0xf000000 | 0xffffff)))) ^ (((0xf000000 | 0xffffff
))))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xf000000 |
0xffffff)) >> 8)) - 1) & ((((0xf000000 | 0xffffff)
) >> 8))) ^ ((((0xf000000 | 0xffffff)) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000 | 0xffffff)) >>
8) >> 4)) - 1) & (((((0xf000000 | 0xffffff)) >>
8) >> 4))) ^ (((((0xf000000 | 0xffffff)) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
| 0xffffff)) >> 8) >> 4) >> 2)) - 1) &
((((((0xf000000 | 0xffffff)) >> 8) >> 4) >>
2))) ^ ((((((0xf000000 | 0xffffff)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
| 0xffffff)) >> 8) >> 4))) - 1) & ((((((0xf000000
| 0xffffff)) >> 8) >> 4)))) ^ ((((((0xf000000 | 0xffffff
)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)) :
((((u_long)(((((((((0xf000000 | 0xffffff)) >> 8))) - 1
) & (((((0xf000000 | 0xffffff)) >> 8)))) ^ (((((0xf000000
| 0xffffff)) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf000000 | 0xffffff)) >> 8)) >> 2)) -
1) & ((((((0xf000000 | 0xffffff)) >> 8)) >> 2
))) ^ ((((((0xf000000 | 0xffffff)) >> 8)) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
| 0xffffff)) >> 8)))) - 1) & ((((((0xf000000 | 0xffffff
)) >> 8))))) ^ ((((((0xf000000 | 0xffffff)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf000000
| 0xffffff)))) - 1) & ((((0xf000000 | 0xffffff))))) ^ ((
((0xf000000 | 0xffffff)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf000000 | 0xffffff))) >> 4)) - 1) & (((
((0xf000000 | 0xffffff))) >> 4))) ^ (((((0xf000000 | 0xffffff
))) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf000000 | 0xffffff))) >> 4) >> 2)) - 1) &
((((((0xf000000 | 0xffffff))) >> 4) >> 2))) ^ ((
((((0xf000000 | 0xffffff))) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000 | 0xffffff
))) >> 4))) - 1) & ((((((0xf000000 | 0xffffff))) >>
4)))) ^ ((((((0xf000000 | 0xffffff))) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000 | 0xffffff
))))) - 1) & (((((0xf000000 | 0xffffff)))))) ^ (((((0xf000000
| 0xffffff))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf000000 | 0xffffff)))) >> 2)) - 1) & ((((((0xf000000
| 0xffffff)))) >> 2))) ^ ((((((0xf000000 | 0xffffff)))
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
((((((((0xf000000 | 0xffffff)))))) - 1) & ((((((0xf000000
| 0xffffff))))))) ^ ((((((0xf000000 | 0xffffff)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
4905#undef EXTRACT_NIBBLE
4906}
4907
4908/* Bang bits over the 3-wire interface. */
4909int
4910rtw_rf_hostwrite(struct rtw_softc *sc, u_int addr, u_int32_t val)
4911{
4912 u_int nbits;
4913 int lo_to_hi;
4914 u_int32_t bits;
4915 void(*rf_bangbits)(struct rtw_regs *, u_int32_t, int, u_int) =
4916 rtw_rf_hostbangbits;
4917
4918 RTW_DPRINTF(RTW_DEBUG_PHYIO, ("%s: [%u] <- %#08x\n", __func__,
4919 addr, val));
4920
4921 switch (sc->sc_rfchipid) {
4922 case RTW_RFCHIPID_MAXIM28200x04:
4923 nbits = 16;
4924 lo_to_hi = 0;
4925 bits = LSHIFT(val, MAX2820_TWI_DATA_MASK)((val) << ((((u_long)((((((0xfff)) - 1) & ((0xfff))
) ^ ((0xfff)))) >> (16)) != 0) ? 16 + ((((u_long)((((((
(0xfff) >> 16)) - 1) & (((0xfff) >> 16))) ^ (
((0xfff) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xfff) >> 16) >> 8)) - 1) & ((((0xfff
) >> 16) >> 8))) ^ ((((0xfff) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xfff) >>
16) >> 8) >> 4)) - 1) & (((((0xfff) >>
16) >> 8) >> 4))) ^ (((((0xfff) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xfff) >> 16) >> 8) >> 4) >> 2))
- 1) & ((((((0xfff) >> 16) >> 8) >> 4)
>> 2))) ^ ((((((0xfff) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xfff) >> 16) >> 8) >> 4))) - 1) &
((((((0xfff) >> 16) >> 8) >> 4)))) ^ (((((
(0xfff) >> 16) >> 8) >> 4))))) >> (1)
) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfff) >> 16) >>
8))) - 1) & (((((0xfff) >> 16) >> 8)))) ^ ((
(((0xfff) >> 16) >> 8))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0xfff) >> 16) >> 8)) >>
2)) - 1) & ((((((0xfff) >> 16) >> 8)) >>
2))) ^ ((((((0xfff) >> 16) >> 8)) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfff) >>
16) >> 8)))) - 1) & ((((((0xfff) >> 16) >>
8))))) ^ ((((((0xfff) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xfff) >> 16
))) - 1) & ((((0xfff) >> 16)))) ^ ((((0xfff) >>
16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xfff)
>> 16)) >> 4)) - 1) & (((((0xfff) >> 16
)) >> 4))) ^ (((((0xfff) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff) >> 16)) >>
4) >> 2)) - 1) & ((((((0xfff) >> 16)) >>
4) >> 2))) ^ ((((((0xfff) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfff
) >> 16)) >> 4))) - 1) & ((((((0xfff) >>
16)) >> 4)))) ^ ((((((0xfff) >> 16)) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfff
) >> 16)))) - 1) & (((((0xfff) >> 16))))) ^ (
((((0xfff) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xfff) >> 16))) >> 2)) - 1) & ((((
((0xfff) >> 16))) >> 2))) ^ ((((((0xfff) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xfff) >> 16))))) - 1) & ((((((0xfff) >>
16)))))) ^ ((((((0xfff) >> 16))))))) >> (1)) != 0
) ? 1 : 0)))) : ((((u_long)(((((((0xfff))) - 1) & (((0xfff
)))) ^ (((0xfff))))) >> (8)) != 0) ? 8 + ((((u_long)(((
(((((0xfff)) >> 8)) - 1) & ((((0xfff)) >> 8))
) ^ ((((0xfff)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0xfff)) >> 8) >> 4)) - 1) & (
((((0xfff)) >> 8) >> 4))) ^ (((((0xfff)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xfff)) >> 8) >> 4) >> 2)) - 1) & (
(((((0xfff)) >> 8) >> 4) >> 2))) ^ ((((((0xfff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xfff)) >> 8) >>
4))) - 1) & ((((((0xfff)) >> 8) >> 4)))) ^ (
(((((0xfff)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0xfff)) >> 8))) - 1) &
(((((0xfff)) >> 8)))) ^ (((((0xfff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff)) >> 8)) >>
2)) - 1) & ((((((0xfff)) >> 8)) >> 2))) ^ ((
((((0xfff)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xfff)) >> 8)))) - 1) &
((((((0xfff)) >> 8))))) ^ ((((((0xfff)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xfff)
))) - 1) & ((((0xfff))))) ^ ((((0xfff)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0xfff))) >> 4)) - 1) &
(((((0xfff))) >> 4))) ^ (((((0xfff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff))) >> 4) >>
2)) - 1) & ((((((0xfff))) >> 4) >> 2))) ^ ((
((((0xfff))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xfff))) >> 4))) - 1) &
((((((0xfff))) >> 4)))) ^ ((((((0xfff))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfff)
)))) - 1) & (((((0xfff)))))) ^ (((((0xfff))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xfff)))) >> 2))
- 1) & ((((((0xfff)))) >> 2))) ^ ((((((0xfff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfff
)))))) - 1) & ((((((0xfff))))))) ^ ((((((0xfff)))))))) >>
(1)) != 0) ? 1 : 0))))))
|
4926 LSHIFT(addr, MAX2820_TWI_ADDR_MASK)((addr) << ((((u_long)((((((0xf000)) - 1) & ((0xf000
))) ^ ((0xf000)))) >> (16)) != 0) ? 16 + ((((u_long)(((
((((0xf000) >> 16)) - 1) & (((0xf000) >> 16))
) ^ (((0xf000) >> 16)))) >> (8)) != 0) ? 8 + ((((
u_long)((((((((0xf000) >> 16) >> 8)) - 1) & (
(((0xf000) >> 16) >> 8))) ^ ((((0xf000) >> 16
) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((
((0xf000) >> 16) >> 8) >> 4)) - 1) & ((
(((0xf000) >> 16) >> 8) >> 4))) ^ (((((0xf000
) >> 16) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xf000) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xf000) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xf000) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xf000) >> 16) >> 8) >>
4))) - 1) & ((((((0xf000) >> 16) >> 8) >>
4)))) ^ ((((((0xf000) >> 16) >> 8) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000
) >> 16) >> 8))) - 1) & (((((0xf000) >>
16) >> 8)))) ^ (((((0xf000) >> 16) >> 8)))
)) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000) >>
16) >> 8)) >> 2)) - 1) & ((((((0xf000) >>
16) >> 8)) >> 2))) ^ ((((((0xf000) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xf000) >> 16) >> 8)))) - 1) & (((
(((0xf000) >> 16) >> 8))))) ^ ((((((0xf000) >>
16) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xf000) >> 16))) - 1) & ((((0xf000) >>
16)))) ^ ((((0xf000) >> 16))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xf000) >> 16)) >> 4)) - 1
) & (((((0xf000) >> 16)) >> 4))) ^ (((((0xf000
) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xf000) >> 16)) >> 4) >> 2
)) - 1) & ((((((0xf000) >> 16)) >> 4) >>
2))) ^ ((((((0xf000) >> 16)) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000)
>> 16)) >> 4))) - 1) & ((((((0xf000) >>
16)) >> 4)))) ^ ((((((0xf000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000
) >> 16)))) - 1) & (((((0xf000) >> 16))))) ^ (
((((0xf000) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf000) >> 16))) >> 2)) - 1) & (((
(((0xf000) >> 16))) >> 2))) ^ ((((((0xf000) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xf000) >> 16))))) - 1) & ((((((0xf000) >>
16)))))) ^ ((((((0xf000) >> 16))))))) >> (1)) !=
0) ? 1 : 0)))) : ((((u_long)(((((((0xf000))) - 1) & (((0xf000
)))) ^ (((0xf000))))) >> (8)) != 0) ? 8 + ((((u_long)((
((((((0xf000)) >> 8)) - 1) & ((((0xf000)) >> 8
))) ^ ((((0xf000)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xf000)) >> 8) >> 4)) - 1) &
(((((0xf000)) >> 8) >> 4))) ^ (((((0xf000)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf000)) >> 8) >> 4) >> 2)) - 1) &
((((((0xf000)) >> 8) >> 4) >> 2))) ^ (((((
(0xf000)) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000)) >> 8) >>
4))) - 1) & ((((((0xf000)) >> 8) >> 4)))) ^ (
(((((0xf000)) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xf000)) >> 8))) - 1) &
(((((0xf000)) >> 8)))) ^ (((((0xf000)) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000)) >>
8)) >> 2)) - 1) & ((((((0xf000)) >> 8)) >>
2))) ^ ((((((0xf000)) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000)) >> 8
)))) - 1) & ((((((0xf000)) >> 8))))) ^ ((((((0xf000
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xf000)))) - 1) & ((((0xf000))))) ^ ((((0xf000))
)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000))) >>
4)) - 1) & (((((0xf000))) >> 4))) ^ (((((0xf000)))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xf000))) >> 4) >> 2)) - 1) & ((((((0xf000)
)) >> 4) >> 2))) ^ ((((((0xf000))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000
))) >> 4))) - 1) & ((((((0xf000))) >> 4)))) ^
((((((0xf000))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xf000))))) - 1) & (((((0xf000)))
))) ^ (((((0xf000))))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf000)))) >> 2)) - 1) & ((((((0xf000)))
) >> 2))) ^ ((((((0xf000)))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000)))))) - 1) &
((((((0xf000))))))) ^ ((((((0xf000)))))))) >> (1)) != 0
) ? 1 : 0))))))
;
4927 break;
4928 case RTW_RFCHIPID_PHILIPS0x03:
4929 KASSERT((addr & ~PRESHIFT(SA2400_TWI_ADDR_MASK)) == 0)(((addr & ~((((0x7f)) & ((0x7f))) >> ((((u_long
)(((((((0x7f))) - 1) & (((0x7f)))) ^ (((0x7f))))) >>
(16)) != 0) ? 16 + ((((u_long)((((((((0x7f)) >> 16)) -
1) & ((((0x7f)) >> 16))) ^ ((((0x7f)) >> 16)
))) >> (8)) != 0) ? 8 + ((((u_long)(((((((((0x7f)) >>
16) >> 8)) - 1) & (((((0x7f)) >> 16) >>
8))) ^ (((((0x7f)) >> 16) >> 8)))) >> (4))
!= 0) ? 4 + ((((u_long)((((((((((0x7f)) >> 16) >>
8) >> 4)) - 1) & ((((((0x7f)) >> 16) >>
8) >> 4))) ^ ((((((0x7f)) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0x7f))
>> 16) >> 8) >> 4) >> 2)) - 1) &
(((((((0x7f)) >> 16) >> 8) >> 4) >> 2
))) ^ (((((((0x7f)) >> 16) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x7f
)) >> 16) >> 8) >> 4))) - 1) & (((((((0x7f
)) >> 16) >> 8) >> 4)))) ^ (((((((0x7f)) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)((((((((((0x7f)) >> 16) >> 8))) - 1
) & ((((((0x7f)) >> 16) >> 8)))) ^ ((((((0x7f
)) >> 16) >> 8))))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((0x7f)) >> 16) >> 8)) >> 2
)) - 1) & (((((((0x7f)) >> 16) >> 8)) >>
2))) ^ (((((((0x7f)) >> 16) >> 8)) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x7f))
>> 16) >> 8)))) - 1) & (((((((0x7f)) >>
16) >> 8))))) ^ (((((((0x7f)) >> 16) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((0x7f
)) >> 16))) - 1) & (((((0x7f)) >> 16)))) ^ ((
(((0x7f)) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)((((((((((0x7f)) >> 16)) >> 4)) - 1) & (((((
(0x7f)) >> 16)) >> 4))) ^ ((((((0x7f)) >> 16
)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((
(((((0x7f)) >> 16)) >> 4) >> 2)) - 1) &
(((((((0x7f)) >> 16)) >> 4) >> 2))) ^ ((((
(((0x7f)) >> 16)) >> 4) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x7f)) >> 16
)) >> 4))) - 1) & (((((((0x7f)) >> 16)) >>
4)))) ^ (((((((0x7f)) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0x7f)) >> 16
)))) - 1) & ((((((0x7f)) >> 16))))) ^ ((((((0x7f)) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0x7f
)) >> 16))) >> 2)) - 1) & (((((((0x7f)) >>
16))) >> 2))) ^ (((((((0x7f)) >> 16))) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x7f
)) >> 16))))) - 1) & (((((((0x7f)) >> 16)))))
) ^ (((((((0x7f)) >> 16))))))) >> (1)) != 0) ? 1 :
0)))) : ((((u_long)((((((((0x7f)))) - 1) & ((((0x7f)))))
^ ((((0x7f)))))) >> (8)) != 0) ? 8 + ((((u_long)((((((
(((0x7f))) >> 8)) - 1) & (((((0x7f))) >> 8)))
^ (((((0x7f))) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)((((((((((0x7f))) >> 8) >> 4)) - 1) & (
(((((0x7f))) >> 8) >> 4))) ^ ((((((0x7f))) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
((((((0x7f))) >> 8) >> 4) >> 2)) - 1) &
(((((((0x7f))) >> 8) >> 4) >> 2))) ^ (((((
((0x7f))) >> 8) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x7f))) >> 8) >>
4))) - 1) & (((((((0x7f))) >> 8) >> 4)))) ^ (
((((((0x7f))) >> 8) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)((((((((((0x7f))) >> 8))) - 1) &
((((((0x7f))) >> 8)))) ^ ((((((0x7f))) >> 8)))))
>> (2)) != 0) ? 2 + ((((u_long)(((((((((((0x7f))) >>
8)) >> 2)) - 1) & (((((((0x7f))) >> 8)) >>
2))) ^ (((((((0x7f))) >> 8)) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x7f))) >> 8
)))) - 1) & (((((((0x7f))) >> 8))))) ^ (((((((0x7f)
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)(((((((((0x7f))))) - 1) & (((((0x7f)))))) ^ (((((0x7f)))
)))) >> (4)) != 0) ? 4 + ((((u_long)((((((((((0x7f)))) >>
4)) - 1) & ((((((0x7f)))) >> 4))) ^ ((((((0x7f))))
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
(((0x7f)))) >> 4) >> 2)) - 1) & (((((((0x7f))
)) >> 4) >> 2))) ^ (((((((0x7f)))) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x7f
)))) >> 4))) - 1) & (((((((0x7f)))) >> 4)))) ^
(((((((0x7f)))) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)((((((((((0x7f)))))) - 1) & ((((((0x7f))))
))) ^ ((((((0x7f)))))))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0x7f))))) >> 2)) - 1) & (((((((0x7f))))
) >> 2))) ^ (((((((0x7f))))) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x7f))))))) - 1) &
(((((((0x7f)))))))) ^ (((((((0x7f))))))))) >> (1)) != 0
) ? 1 : 0))))))) == 0) ? (void)0 : __assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c"
, 4929, "(addr & ~PRESHIFT(SA2400_TWI_ADDR_MASK)) == 0"))
;
4930 KASSERT((val & ~PRESHIFT(SA2400_TWI_DATA_MASK)) == 0)(((val & ~((((0xffffff00)) & ((0xffffff00))) >>
((((u_long)(((((((0xffffff00))) - 1) & (((0xffffff00))))
^ (((0xffffff00))))) >> (16)) != 0) ? 16 + ((((u_long)
((((((((0xffffff00)) >> 16)) - 1) & ((((0xffffff00)
) >> 16))) ^ ((((0xffffff00)) >> 16)))) >> (
8)) != 0) ? 8 + ((((u_long)(((((((((0xffffff00)) >> 16)
>> 8)) - 1) & (((((0xffffff00)) >> 16) >>
8))) ^ (((((0xffffff00)) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)((((((((((0xffffff00)) >> 16
) >> 8) >> 4)) - 1) & ((((((0xffffff00)) >>
16) >> 8) >> 4))) ^ ((((((0xffffff00)) >> 16
) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0xffffff00)) >> 16) >> 8) >> 4)
>> 2)) - 1) & (((((((0xffffff00)) >> 16) >>
8) >> 4) >> 2))) ^ (((((((0xffffff00)) >> 16
) >> 8) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)(((((((((((0xffffff00)) >> 16) >>
8) >> 4))) - 1) & (((((((0xffffff00)) >> 16)
>> 8) >> 4)))) ^ (((((((0xffffff00)) >> 16
) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)) :
((((u_long)((((((((((0xffffff00)) >> 16) >> 8)))
- 1) & ((((((0xffffff00)) >> 16) >> 8)))) ^ (
(((((0xffffff00)) >> 16) >> 8))))) >> (2)) !=
0) ? 2 + ((((u_long)(((((((((((0xffffff00)) >> 16) >>
8)) >> 2)) - 1) & (((((((0xffffff00)) >> 16)
>> 8)) >> 2))) ^ (((((((0xffffff00)) >> 16
) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)(((((((((((0xffffff00)) >> 16) >> 8))))
- 1) & (((((((0xffffff00)) >> 16) >> 8))))) ^
(((((((0xffffff00)) >> 16) >> 8)))))) >> (
1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((0xffffff00)) >>
16))) - 1) & (((((0xffffff00)) >> 16)))) ^ (((((0xffffff00
)) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)((((
((((((0xffffff00)) >> 16)) >> 4)) - 1) & ((((
((0xffffff00)) >> 16)) >> 4))) ^ ((((((0xffffff00
)) >> 16)) >> 4)))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((0xffffff00)) >> 16)) >> 4) >>
2)) - 1) & (((((((0xffffff00)) >> 16)) >> 4)
>> 2))) ^ (((((((0xffffff00)) >> 16)) >> 4
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
(((((((((0xffffff00)) >> 16)) >> 4))) - 1) & (
((((((0xffffff00)) >> 16)) >> 4)))) ^ (((((((0xffffff00
)) >> 16)) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)((((((((((0xffffff00)) >> 16)))) - 1) &
((((((0xffffff00)) >> 16))))) ^ ((((((0xffffff00)) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0xffffff00
)) >> 16))) >> 2)) - 1) & (((((((0xffffff00))
>> 16))) >> 2))) ^ (((((((0xffffff00)) >> 16
))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
(((((((((((0xffffff00)) >> 16))))) - 1) & (((((((0xffffff00
)) >> 16)))))) ^ (((((((0xffffff00)) >> 16)))))))
>> (1)) != 0) ? 1 : 0)))) : ((((u_long)((((((((0xffffff00
)))) - 1) & ((((0xffffff00))))) ^ ((((0xffffff00)))))) >>
(8)) != 0) ? 8 + ((((u_long)(((((((((0xffffff00))) >> 8
)) - 1) & (((((0xffffff00))) >> 8))) ^ (((((0xffffff00
))) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((
(((((0xffffff00))) >> 8) >> 4)) - 1) & ((((((
0xffffff00))) >> 8) >> 4))) ^ ((((((0xffffff00)))
>> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0xffffff00))) >> 8) >> 4) >> 2)
) - 1) & (((((((0xffffff00))) >> 8) >> 4) >>
2))) ^ (((((((0xffffff00))) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xffffff00
))) >> 8) >> 4))) - 1) & (((((((0xffffff00)))
>> 8) >> 4)))) ^ (((((((0xffffff00))) >> 8
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
((((((((((0xffffff00))) >> 8))) - 1) & ((((((0xffffff00
))) >> 8)))) ^ ((((((0xffffff00))) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((0xffffff00))) >>
8)) >> 2)) - 1) & (((((((0xffffff00))) >> 8)
) >> 2))) ^ (((((((0xffffff00))) >> 8)) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xffffff00
))) >> 8)))) - 1) & (((((((0xffffff00))) >> 8
))))) ^ (((((((0xffffff00))) >> 8)))))) >> (1)) !=
0) ? 1 : 0))) : ((((u_long)(((((((((0xffffff00))))) - 1) &
(((((0xffffff00)))))) ^ (((((0xffffff00))))))) >> (4))
!= 0) ? 4 + ((((u_long)((((((((((0xffffff00)))) >> 4))
- 1) & ((((((0xffffff00)))) >> 4))) ^ ((((((0xffffff00
)))) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((
(((((((0xffffff00)))) >> 4) >> 2)) - 1) & (((
((((0xffffff00)))) >> 4) >> 2))) ^ (((((((0xffffff00
)))) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)(((((((((((0xffffff00)))) >> 4))) - 1) &
(((((((0xffffff00)))) >> 4)))) ^ (((((((0xffffff00))))
>> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(
(((((((((0xffffff00)))))) - 1) & ((((((0xffffff00))))))) ^
((((((0xffffff00)))))))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0xffffff00))))) >> 2)) - 1) & (((((((0xffffff00
))))) >> 2))) ^ (((((((0xffffff00))))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xffffff00))))))
) - 1) & (((((((0xffffff00)))))))) ^ (((((((0xffffff00)))
)))))) >> (1)) != 0) ? 1 : 0))))))) == 0) ? (void)0 : __assert
("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 4930, "(val & ~PRESHIFT(SA2400_TWI_DATA_MASK)) == 0"
))
;
4931 bits = LSHIFT(val, SA2400_TWI_DATA_MASK)((val) << ((((u_long)((((((0xffffff00)) - 1) & ((0xffffff00
))) ^ ((0xffffff00)))) >> (16)) != 0) ? 16 + ((((u_long
)(((((((0xffffff00) >> 16)) - 1) & (((0xffffff00) >>
16))) ^ (((0xffffff00) >> 16)))) >> (8)) != 0) ?
8 + ((((u_long)((((((((0xffffff00) >> 16) >> 8))
- 1) & ((((0xffffff00) >> 16) >> 8))) ^ ((((
0xffffff00) >> 16) >> 8)))) >> (4)) != 0) ?
4 + ((((u_long)(((((((((0xffffff00) >> 16) >> 8)
>> 4)) - 1) & (((((0xffffff00) >> 16) >>
8) >> 4))) ^ (((((0xffffff00) >> 16) >> 8)
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xffffff00) >> 16) >> 8) >> 4) >> 2
)) - 1) & ((((((0xffffff00) >> 16) >> 8) >>
4) >> 2))) ^ ((((((0xffffff00) >> 16) >> 8
) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0xffffff00) >> 16) >> 8) >>
4))) - 1) & ((((((0xffffff00) >> 16) >> 8) >>
4)))) ^ ((((((0xffffff00) >> 16) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xffffff00
) >> 16) >> 8))) - 1) & (((((0xffffff00) >>
16) >> 8)))) ^ (((((0xffffff00) >> 16) >> 8
))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xffffff00
) >> 16) >> 8)) >> 2)) - 1) & ((((((0xffffff00
) >> 16) >> 8)) >> 2))) ^ ((((((0xffffff00)
>> 16) >> 8)) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xffffff00) >> 16) >>
8)))) - 1) & ((((((0xffffff00) >> 16) >> 8))
))) ^ ((((((0xffffff00) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xffffff00) >>
16))) - 1) & ((((0xffffff00) >> 16)))) ^ ((((0xffffff00
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xffffff00) >> 16)) >> 4)) - 1) & (((((0xffffff00
) >> 16)) >> 4))) ^ (((((0xffffff00) >> 16)
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xffffff00) >> 16)) >> 4) >> 2)) - 1) &
((((((0xffffff00) >> 16)) >> 4) >> 2))) ^ (
(((((0xffffff00) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffffff00) >>
16)) >> 4))) - 1) & ((((((0xffffff00) >> 16)
) >> 4)))) ^ ((((((0xffffff00) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xffffff00
) >> 16)))) - 1) & (((((0xffffff00) >> 16))))
) ^ (((((0xffffff00) >> 16)))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0xffffff00) >> 16))) >> 2
)) - 1) & ((((((0xffffff00) >> 16))) >> 2))) ^
((((((0xffffff00) >> 16))) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffffff00) >> 16
))))) - 1) & ((((((0xffffff00) >> 16)))))) ^ ((((((
0xffffff00) >> 16))))))) >> (1)) != 0) ? 1 : 0)))
) : ((((u_long)(((((((0xffffff00))) - 1) & (((0xffffff00)
))) ^ (((0xffffff00))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xffffff00)) >> 8)) - 1) & ((((0xffffff00)
) >> 8))) ^ ((((0xffffff00)) >> 8)))) >> (4
)) != 0) ? 4 + ((((u_long)(((((((((0xffffff00)) >> 8) >>
4)) - 1) & (((((0xffffff00)) >> 8) >> 4))) ^
(((((0xffffff00)) >> 8) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xffffff00)) >> 8) >>
4) >> 2)) - 1) & ((((((0xffffff00)) >> 8) >>
4) >> 2))) ^ ((((((0xffffff00)) >> 8) >> 4
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
((((((((0xffffff00)) >> 8) >> 4))) - 1) & (((
(((0xffffff00)) >> 8) >> 4)))) ^ ((((((0xffffff00
)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)) :
((((u_long)(((((((((0xffffff00)) >> 8))) - 1) & ((
(((0xffffff00)) >> 8)))) ^ (((((0xffffff00)) >> 8
))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xffffff00
)) >> 8)) >> 2)) - 1) & ((((((0xffffff00)) >>
8)) >> 2))) ^ ((((((0xffffff00)) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffffff00
)) >> 8)))) - 1) & ((((((0xffffff00)) >> 8)))
)) ^ ((((((0xffffff00)) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0xffffff00)))) - 1) & ((((
0xffffff00))))) ^ ((((0xffffff00)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xffffff00))) >> 4)) - 1) & (
((((0xffffff00))) >> 4))) ^ (((((0xffffff00))) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xffffff00
))) >> 4) >> 2)) - 1) & ((((((0xffffff00))) >>
4) >> 2))) ^ ((((((0xffffff00))) >> 4) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffffff00
))) >> 4))) - 1) & ((((((0xffffff00))) >> 4))
)) ^ ((((((0xffffff00))) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0xffffff00))))) - 1) & (((
((0xffffff00)))))) ^ (((((0xffffff00))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0xffffff00)))) >> 2)) - 1)
& ((((((0xffffff00)))) >> 2))) ^ ((((((0xffffff00)
))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xffffff00)))))) - 1) & ((((((0xffffff00)))))))
^ ((((((0xffffff00)))))))) >> (1)) != 0) ? 1 : 0))))))
|
4932 LSHIFT(addr, SA2400_TWI_ADDR_MASK)((addr) << ((((u_long)((((((0x7f)) - 1) & ((0x7f)))
^ ((0x7f)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x7f
) >> 16)) - 1) & (((0x7f) >> 16))) ^ (((0x7f)
>> 16)))) >> (8)) != 0) ? 8 + ((((u_long)(((((((
(0x7f) >> 16) >> 8)) - 1) & ((((0x7f) >>
16) >> 8))) ^ ((((0x7f) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x7f) >> 16) >>
8) >> 4)) - 1) & (((((0x7f) >> 16) >> 8
) >> 4))) ^ (((((0x7f) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0x7f
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x7f) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f) >> 16
) >> 8) >> 4))) - 1) & ((((((0x7f) >> 16
) >> 8) >> 4)))) ^ ((((((0x7f) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x7f) >> 16) >> 8))) - 1) & (((((0x7f
) >> 16) >> 8)))) ^ (((((0x7f) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x7f) >>
16) >> 8)) >> 2)) - 1) & ((((((0x7f) >>
16) >> 8)) >> 2))) ^ ((((((0x7f) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x7f) >> 16) >> 8)))) - 1) & (((((
(0x7f) >> 16) >> 8))))) ^ ((((((0x7f) >> 16
) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x7f) >> 16))) - 1) & ((((0x7f) >> 16
)))) ^ ((((0x7f) >> 16))))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0x7f) >> 16)) >> 4)) - 1) &
(((((0x7f) >> 16)) >> 4))) ^ (((((0x7f) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x7f) >> 16)) >> 4) >> 2)) - 1) &
((((((0x7f) >> 16)) >> 4) >> 2))) ^ ((((((
0x7f) >> 16)) >> 4) >> 2)))) >> (1)) !=
0) ? 1 : 0) : ((((u_long)((((((((((0x7f) >> 16)) >>
4))) - 1) & ((((((0x7f) >> 16)) >> 4)))) ^ (
(((((0x7f) >> 16)) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x7f) >> 16)))) - 1) &
(((((0x7f) >> 16))))) ^ (((((0x7f) >> 16)))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f) >> 16))) >>
2)) - 1) & ((((((0x7f) >> 16))) >> 2))) ^ ((
((((0x7f) >> 16))) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x7f) >> 16))))) - 1) &
((((((0x7f) >> 16)))))) ^ ((((((0x7f) >> 16)))))
)) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x7f))
) - 1) & (((0x7f)))) ^ (((0x7f))))) >> (8)) != 0) ?
8 + ((((u_long)((((((((0x7f)) >> 8)) - 1) & ((((0x7f
)) >> 8))) ^ ((((0x7f)) >> 8)))) >> (4)) !=
0) ? 4 + ((((u_long)(((((((((0x7f)) >> 8) >> 4))
- 1) & (((((0x7f)) >> 8) >> 4))) ^ (((((0x7f
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x7f)) >> 8) >> 4) >> 2)) - 1) &
((((((0x7f)) >> 8) >> 4) >> 2))) ^ ((((((0x7f
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x7f)) >> 8) >> 4
))) - 1) & ((((((0x7f)) >> 8) >> 4)))) ^ ((((
((0x7f)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0x7f)) >> 8))) - 1) & ((
(((0x7f)) >> 8)))) ^ (((((0x7f)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f)) >> 8)) >>
2)) - 1) & ((((((0x7f)) >> 8)) >> 2))) ^ (((
(((0x7f)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x7f)) >> 8)))) - 1) &
((((((0x7f)) >> 8))))) ^ ((((((0x7f)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x7f))))
- 1) & ((((0x7f))))) ^ ((((0x7f)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x7f))) >> 4)) - 1) & (
((((0x7f))) >> 4))) ^ (((((0x7f))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x7f))) >> 4) >>
2)) - 1) & ((((((0x7f))) >> 4) >> 2))) ^ (((
(((0x7f))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x7f))) >> 4))) - 1) &
((((((0x7f))) >> 4)))) ^ ((((((0x7f))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x7f))))
) - 1) & (((((0x7f)))))) ^ (((((0x7f))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0x7f)))) >> 2)) - 1) &
((((((0x7f)))) >> 2))) ^ ((((((0x7f)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x7f))))
)) - 1) & ((((((0x7f))))))) ^ ((((((0x7f)))))))) >>
(1)) != 0) ? 1 : 0))))))
| SA2400_TWI_WREN(1<<7);
4933 nbits = 32;
4934 lo_to_hi = 1;
4935 break;
4936 case RTW_RFCHIPID_GCT0x05:
4937 KASSERT((addr & ~PRESHIFT(SI4126_TWI_ADDR_MASK)) == 0)(((addr & ~((((0xf)) & ((0xf))) >> ((((u_long)(
((((((0xf))) - 1) & (((0xf)))) ^ (((0xf))))) >> (16
)) != 0) ? 16 + ((((u_long)((((((((0xf)) >> 16)) - 1) &
((((0xf)) >> 16))) ^ ((((0xf)) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)(((((((((0xf)) >> 16) >>
8)) - 1) & (((((0xf)) >> 16) >> 8))) ^ (((((
0xf)) >> 16) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)((((((((((0xf)) >> 16) >> 8) >> 4
)) - 1) & ((((((0xf)) >> 16) >> 8) >> 4
))) ^ ((((((0xf)) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((0xf)) >> 16) >>
8) >> 4) >> 2)) - 1) & (((((((0xf)) >>
16) >> 8) >> 4) >> 2))) ^ (((((((0xf)) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)(((((((((((0xf)) >> 16) >>
8) >> 4))) - 1) & (((((((0xf)) >> 16) >>
8) >> 4)))) ^ (((((((0xf)) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((
0xf)) >> 16) >> 8))) - 1) & ((((((0xf)) >>
16) >> 8)))) ^ ((((((0xf)) >> 16) >> 8))))
) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0xf)) >>
16) >> 8)) >> 2)) - 1) & (((((((0xf)) >>
16) >> 8)) >> 2))) ^ (((((((0xf)) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)(((((((((((0xf)) >> 16) >> 8)))) - 1) & ((((
(((0xf)) >> 16) >> 8))))) ^ (((((((0xf)) >>
16) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)(((((((((0xf)) >> 16))) - 1) & (((((0xf)) >>
16)))) ^ (((((0xf)) >> 16))))) >> (4)) != 0) ? 4
+ ((((u_long)((((((((((0xf)) >> 16)) >> 4)) - 1)
& ((((((0xf)) >> 16)) >> 4))) ^ ((((((0xf)) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
((((((((0xf)) >> 16)) >> 4) >> 2)) - 1) &
(((((((0xf)) >> 16)) >> 4) >> 2))) ^ (((((
((0xf)) >> 16)) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xf)) >> 16)) >>
4))) - 1) & (((((((0xf)) >> 16)) >> 4)))) ^ (
((((((0xf)) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)((((((((((0xf)) >> 16)))) - 1) &
((((((0xf)) >> 16))))) ^ ((((((0xf)) >> 16))))))
>> (2)) != 0) ? 2 + ((((u_long)(((((((((((0xf)) >>
16))) >> 2)) - 1) & (((((((0xf)) >> 16))) >>
2))) ^ (((((((0xf)) >> 16))) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xf)) >> 16)
)))) - 1) & (((((((0xf)) >> 16)))))) ^ (((((((0xf))
>> 16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long
)((((((((0xf)))) - 1) & ((((0xf))))) ^ ((((0xf)))))) >>
(8)) != 0) ? 8 + ((((u_long)(((((((((0xf))) >> 8)) - 1
) & (((((0xf))) >> 8))) ^ (((((0xf))) >> 8)))
) >> (4)) != 0) ? 4 + ((((u_long)((((((((((0xf))) >>
8) >> 4)) - 1) & ((((((0xf))) >> 8) >>
4))) ^ ((((((0xf))) >> 8) >> 4)))) >> (2))
!= 0) ? 2 + ((((u_long)(((((((((((0xf))) >> 8) >>
4) >> 2)) - 1) & (((((((0xf))) >> 8) >>
4) >> 2))) ^ (((((((0xf))) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xf
))) >> 8) >> 4))) - 1) & (((((((0xf))) >>
8) >> 4)))) ^ (((((((0xf))) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0xf)))
>> 8))) - 1) & ((((((0xf))) >> 8)))) ^ (((((
(0xf))) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)
(((((((((((0xf))) >> 8)) >> 2)) - 1) & ((((((
(0xf))) >> 8)) >> 2))) ^ (((((((0xf))) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
((((((((((0xf))) >> 8)))) - 1) & (((((((0xf))) >>
8))))) ^ (((((((0xf))) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)(((((((((0xf))))) - 1) & (((((0xf)
))))) ^ (((((0xf))))))) >> (4)) != 0) ? 4 + ((((u_long)
((((((((((0xf)))) >> 4)) - 1) & ((((((0xf)))) >>
4))) ^ ((((((0xf)))) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)(((((((((((0xf)))) >> 4) >> 2)) - 1) &
(((((((0xf)))) >> 4) >> 2))) ^ (((((((0xf)))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
(((((((((((0xf)))) >> 4))) - 1) & (((((((0xf)))) >>
4)))) ^ (((((((0xf)))) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)((((((((((0xf)))))) - 1) & ((((((0xf
))))))) ^ ((((((0xf)))))))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0xf))))) >> 2)) - 1) & (((((((0xf))))) >>
2))) ^ (((((((0xf))))) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)(((((((((((0xf))))))) - 1) & (((((((0xf
)))))))) ^ (((((((0xf))))))))) >> (1)) != 0) ? 1 : 0)))
)))) == 0) ? (void)0 : __assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c"
, 4937, "(addr & ~PRESHIFT(SI4126_TWI_ADDR_MASK)) == 0"))
;
4938 KASSERT((val & ~PRESHIFT(SI4126_TWI_DATA_MASK)) == 0)(((val & ~((((0x3ffff0)) & ((0x3ffff0))) >> (((
(u_long)(((((((0x3ffff0))) - 1) & (((0x3ffff0)))) ^ (((0x3ffff0
))))) >> (16)) != 0) ? 16 + ((((u_long)((((((((0x3ffff0
)) >> 16)) - 1) & ((((0x3ffff0)) >> 16))) ^ (
(((0x3ffff0)) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)(((((((((0x3ffff0)) >> 16) >> 8)) - 1) & (((
((0x3ffff0)) >> 16) >> 8))) ^ (((((0x3ffff0)) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
((((((0x3ffff0)) >> 16) >> 8) >> 4)) - 1) &
((((((0x3ffff0)) >> 16) >> 8) >> 4))) ^ ((
((((0x3ffff0)) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((0x3ffff0)) >> 16
) >> 8) >> 4) >> 2)) - 1) & (((((((0x3ffff0
)) >> 16) >> 8) >> 4) >> 2))) ^ (((((
((0x3ffff0)) >> 16) >> 8) >> 4) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ffff0
)) >> 16) >> 8) >> 4))) - 1) & (((((((0x3ffff0
)) >> 16) >> 8) >> 4)))) ^ (((((((0x3ffff0)
) >> 16) >> 8) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)((((((((((0x3ffff0)) >> 16) >>
8))) - 1) & ((((((0x3ffff0)) >> 16) >> 8))))
^ ((((((0x3ffff0)) >> 16) >> 8))))) >> (2)
) != 0) ? 2 + ((((u_long)(((((((((((0x3ffff0)) >> 16) >>
8)) >> 2)) - 1) & (((((((0x3ffff0)) >> 16) >>
8)) >> 2))) ^ (((((((0x3ffff0)) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
((((((((((0x3ffff0)) >> 16) >> 8)))) - 1) & (
((((((0x3ffff0)) >> 16) >> 8))))) ^ (((((((0x3ffff0
)) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0)
)) : ((((u_long)(((((((((0x3ffff0)) >> 16))) - 1) &
(((((0x3ffff0)) >> 16)))) ^ (((((0x3ffff0)) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)((((((((((0x3ffff0
)) >> 16)) >> 4)) - 1) & ((((((0x3ffff0)) >>
16)) >> 4))) ^ ((((((0x3ffff0)) >> 16)) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0x3ffff0
)) >> 16)) >> 4) >> 2)) - 1) & (((((((0x3ffff0
)) >> 16)) >> 4) >> 2))) ^ (((((((0x3ffff0)
) >> 16)) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)(((((((((((0x3ffff0)) >> 16)) >>
4))) - 1) & (((((((0x3ffff0)) >> 16)) >> 4))
)) ^ (((((((0x3ffff0)) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0x3ffff0)) >>
16)))) - 1) & ((((((0x3ffff0)) >> 16))))) ^ ((((((
0x3ffff0)) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0x3ffff0)) >> 16))) >> 2)) - 1) &
(((((((0x3ffff0)) >> 16))) >> 2))) ^ (((((((0x3ffff0
)) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)(((((((((((0x3ffff0)) >> 16))))) - 1) &
(((((((0x3ffff0)) >> 16)))))) ^ (((((((0x3ffff0)) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
(((0x3ffff0)))) - 1) & ((((0x3ffff0))))) ^ ((((0x3ffff0))
)))) >> (8)) != 0) ? 8 + ((((u_long)(((((((((0x3ffff0))
) >> 8)) - 1) & (((((0x3ffff0))) >> 8))) ^ ((
(((0x3ffff0))) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)((((((((((0x3ffff0))) >> 8) >> 4)) - 1) & ((
((((0x3ffff0))) >> 8) >> 4))) ^ ((((((0x3ffff0)))
>> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0x3ffff0))) >> 8) >> 4) >> 2)) -
1) & (((((((0x3ffff0))) >> 8) >> 4) >>
2))) ^ (((((((0x3ffff0))) >> 8) >> 4) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ffff0
))) >> 8) >> 4))) - 1) & (((((((0x3ffff0))) >>
8) >> 4)))) ^ (((((((0x3ffff0))) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0x3ffff0
))) >> 8))) - 1) & ((((((0x3ffff0))) >> 8))))
^ ((((((0x3ffff0))) >> 8))))) >> (2)) != 0) ? 2 +
((((u_long)(((((((((((0x3ffff0))) >> 8)) >> 2)) -
1) & (((((((0x3ffff0))) >> 8)) >> 2))) ^ (((
((((0x3ffff0))) >> 8)) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)(((((((((((0x3ffff0))) >> 8))))
- 1) & (((((((0x3ffff0))) >> 8))))) ^ (((((((0x3ffff0
))) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)(((((((((0x3ffff0))))) - 1) & (((((0x3ffff0)))))) ^ ((((
(0x3ffff0))))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((
(((0x3ffff0)))) >> 4)) - 1) & ((((((0x3ffff0)))) >>
4))) ^ ((((((0x3ffff0)))) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)(((((((((((0x3ffff0)))) >> 4) >>
2)) - 1) & (((((((0x3ffff0)))) >> 4) >> 2)))
^ (((((((0x3ffff0)))) >> 4) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ffff0)))) >>
4))) - 1) & (((((((0x3ffff0)))) >> 4)))) ^ (((((((
0x3ffff0)))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : (
(((u_long)((((((((((0x3ffff0)))))) - 1) & ((((((0x3ffff0)
)))))) ^ ((((((0x3ffff0)))))))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((0x3ffff0))))) >> 2)) - 1) & ((((
(((0x3ffff0))))) >> 2))) ^ (((((((0x3ffff0))))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ffff0
))))))) - 1) & (((((((0x3ffff0)))))))) ^ (((((((0x3ffff0)
)))))))) >> (1)) != 0) ? 1 : 0))))))) == 0) ? (void)0 :
__assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 4938, "(val & ~PRESHIFT(SI4126_TWI_DATA_MASK)) == 0"
))
;
4939 bits = rtw_grf5101_host_crypt(addr, val);
4940 nbits = 21;
4941 lo_to_hi = 1;
4942 break;
4943 case RTW_RFCHIPID_RFMD29480x02:
4944 KASSERT((addr & ~PRESHIFT(SI4126_TWI_ADDR_MASK)) == 0)(((addr & ~((((0xf)) & ((0xf))) >> ((((u_long)(
((((((0xf))) - 1) & (((0xf)))) ^ (((0xf))))) >> (16
)) != 0) ? 16 + ((((u_long)((((((((0xf)) >> 16)) - 1) &
((((0xf)) >> 16))) ^ ((((0xf)) >> 16)))) >>
(8)) != 0) ? 8 + ((((u_long)(((((((((0xf)) >> 16) >>
8)) - 1) & (((((0xf)) >> 16) >> 8))) ^ (((((
0xf)) >> 16) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)((((((((((0xf)) >> 16) >> 8) >> 4
)) - 1) & ((((((0xf)) >> 16) >> 8) >> 4
))) ^ ((((((0xf)) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((0xf)) >> 16) >>
8) >> 4) >> 2)) - 1) & (((((((0xf)) >>
16) >> 8) >> 4) >> 2))) ^ (((((((0xf)) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)(((((((((((0xf)) >> 16) >>
8) >> 4))) - 1) & (((((((0xf)) >> 16) >>
8) >> 4)))) ^ (((((((0xf)) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((
0xf)) >> 16) >> 8))) - 1) & ((((((0xf)) >>
16) >> 8)))) ^ ((((((0xf)) >> 16) >> 8))))
) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0xf)) >>
16) >> 8)) >> 2)) - 1) & (((((((0xf)) >>
16) >> 8)) >> 2))) ^ (((((((0xf)) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)(((((((((((0xf)) >> 16) >> 8)))) - 1) & ((((
(((0xf)) >> 16) >> 8))))) ^ (((((((0xf)) >>
16) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)(((((((((0xf)) >> 16))) - 1) & (((((0xf)) >>
16)))) ^ (((((0xf)) >> 16))))) >> (4)) != 0) ? 4
+ ((((u_long)((((((((((0xf)) >> 16)) >> 4)) - 1)
& ((((((0xf)) >> 16)) >> 4))) ^ ((((((0xf)) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
((((((((0xf)) >> 16)) >> 4) >> 2)) - 1) &
(((((((0xf)) >> 16)) >> 4) >> 2))) ^ (((((
((0xf)) >> 16)) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xf)) >> 16)) >>
4))) - 1) & (((((((0xf)) >> 16)) >> 4)))) ^ (
((((((0xf)) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)((((((((((0xf)) >> 16)))) - 1) &
((((((0xf)) >> 16))))) ^ ((((((0xf)) >> 16))))))
>> (2)) != 0) ? 2 + ((((u_long)(((((((((((0xf)) >>
16))) >> 2)) - 1) & (((((((0xf)) >> 16))) >>
2))) ^ (((((((0xf)) >> 16))) >> 2)))) >> (
1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xf)) >> 16)
)))) - 1) & (((((((0xf)) >> 16)))))) ^ (((((((0xf))
>> 16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long
)((((((((0xf)))) - 1) & ((((0xf))))) ^ ((((0xf)))))) >>
(8)) != 0) ? 8 + ((((u_long)(((((((((0xf))) >> 8)) - 1
) & (((((0xf))) >> 8))) ^ (((((0xf))) >> 8)))
) >> (4)) != 0) ? 4 + ((((u_long)((((((((((0xf))) >>
8) >> 4)) - 1) & ((((((0xf))) >> 8) >>
4))) ^ ((((((0xf))) >> 8) >> 4)))) >> (2))
!= 0) ? 2 + ((((u_long)(((((((((((0xf))) >> 8) >>
4) >> 2)) - 1) & (((((((0xf))) >> 8) >>
4) >> 2))) ^ (((((((0xf))) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xf
))) >> 8) >> 4))) - 1) & (((((((0xf))) >>
8) >> 4)))) ^ (((((((0xf))) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0xf)))
>> 8))) - 1) & ((((((0xf))) >> 8)))) ^ (((((
(0xf))) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)
(((((((((((0xf))) >> 8)) >> 2)) - 1) & ((((((
(0xf))) >> 8)) >> 2))) ^ (((((((0xf))) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
((((((((((0xf))) >> 8)))) - 1) & (((((((0xf))) >>
8))))) ^ (((((((0xf))) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)(((((((((0xf))))) - 1) & (((((0xf)
))))) ^ (((((0xf))))))) >> (4)) != 0) ? 4 + ((((u_long)
((((((((((0xf)))) >> 4)) - 1) & ((((((0xf)))) >>
4))) ^ ((((((0xf)))) >> 4)))) >> (2)) != 0) ? 2 +
((((u_long)(((((((((((0xf)))) >> 4) >> 2)) - 1) &
(((((((0xf)))) >> 4) >> 2))) ^ (((((((0xf)))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
(((((((((((0xf)))) >> 4))) - 1) & (((((((0xf)))) >>
4)))) ^ (((((((0xf)))) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)((((((((((0xf)))))) - 1) & ((((((0xf
))))))) ^ ((((((0xf)))))))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0xf))))) >> 2)) - 1) & (((((((0xf))))) >>
2))) ^ (((((((0xf))))) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)(((((((((((0xf))))))) - 1) & (((((((0xf
)))))))) ^ (((((((0xf))))))))) >> (1)) != 0) ? 1 : 0)))
)))) == 0) ? (void)0 : __assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c"
, 4944, "(addr & ~PRESHIFT(SI4126_TWI_ADDR_MASK)) == 0"))
;
4945 KASSERT((val & ~PRESHIFT(SI4126_TWI_DATA_MASK)) == 0)(((val & ~((((0x3ffff0)) & ((0x3ffff0))) >> (((
(u_long)(((((((0x3ffff0))) - 1) & (((0x3ffff0)))) ^ (((0x3ffff0
))))) >> (16)) != 0) ? 16 + ((((u_long)((((((((0x3ffff0
)) >> 16)) - 1) & ((((0x3ffff0)) >> 16))) ^ (
(((0x3ffff0)) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)(((((((((0x3ffff0)) >> 16) >> 8)) - 1) & (((
((0x3ffff0)) >> 16) >> 8))) ^ (((((0x3ffff0)) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
((((((0x3ffff0)) >> 16) >> 8) >> 4)) - 1) &
((((((0x3ffff0)) >> 16) >> 8) >> 4))) ^ ((
((((0x3ffff0)) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((0x3ffff0)) >> 16
) >> 8) >> 4) >> 2)) - 1) & (((((((0x3ffff0
)) >> 16) >> 8) >> 4) >> 2))) ^ (((((
((0x3ffff0)) >> 16) >> 8) >> 4) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ffff0
)) >> 16) >> 8) >> 4))) - 1) & (((((((0x3ffff0
)) >> 16) >> 8) >> 4)))) ^ (((((((0x3ffff0)
) >> 16) >> 8) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)((((((((((0x3ffff0)) >> 16) >>
8))) - 1) & ((((((0x3ffff0)) >> 16) >> 8))))
^ ((((((0x3ffff0)) >> 16) >> 8))))) >> (2)
) != 0) ? 2 + ((((u_long)(((((((((((0x3ffff0)) >> 16) >>
8)) >> 2)) - 1) & (((((((0x3ffff0)) >> 16) >>
8)) >> 2))) ^ (((((((0x3ffff0)) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
((((((((((0x3ffff0)) >> 16) >> 8)))) - 1) & (
((((((0x3ffff0)) >> 16) >> 8))))) ^ (((((((0x3ffff0
)) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0)
)) : ((((u_long)(((((((((0x3ffff0)) >> 16))) - 1) &
(((((0x3ffff0)) >> 16)))) ^ (((((0x3ffff0)) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)((((((((((0x3ffff0
)) >> 16)) >> 4)) - 1) & ((((((0x3ffff0)) >>
16)) >> 4))) ^ ((((((0x3ffff0)) >> 16)) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0x3ffff0
)) >> 16)) >> 4) >> 2)) - 1) & (((((((0x3ffff0
)) >> 16)) >> 4) >> 2))) ^ (((((((0x3ffff0)
) >> 16)) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)(((((((((((0x3ffff0)) >> 16)) >>
4))) - 1) & (((((((0x3ffff0)) >> 16)) >> 4))
)) ^ (((((((0x3ffff0)) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0x3ffff0)) >>
16)))) - 1) & ((((((0x3ffff0)) >> 16))))) ^ ((((((
0x3ffff0)) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0x3ffff0)) >> 16))) >> 2)) - 1) &
(((((((0x3ffff0)) >> 16))) >> 2))) ^ (((((((0x3ffff0
)) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)(((((((((((0x3ffff0)) >> 16))))) - 1) &
(((((((0x3ffff0)) >> 16)))))) ^ (((((((0x3ffff0)) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
(((0x3ffff0)))) - 1) & ((((0x3ffff0))))) ^ ((((0x3ffff0))
)))) >> (8)) != 0) ? 8 + ((((u_long)(((((((((0x3ffff0))
) >> 8)) - 1) & (((((0x3ffff0))) >> 8))) ^ ((
(((0x3ffff0))) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)((((((((((0x3ffff0))) >> 8) >> 4)) - 1) & ((
((((0x3ffff0))) >> 8) >> 4))) ^ ((((((0x3ffff0)))
>> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0x3ffff0))) >> 8) >> 4) >> 2)) -
1) & (((((((0x3ffff0))) >> 8) >> 4) >>
2))) ^ (((((((0x3ffff0))) >> 8) >> 4) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ffff0
))) >> 8) >> 4))) - 1) & (((((((0x3ffff0))) >>
8) >> 4)))) ^ (((((((0x3ffff0))) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0x3ffff0
))) >> 8))) - 1) & ((((((0x3ffff0))) >> 8))))
^ ((((((0x3ffff0))) >> 8))))) >> (2)) != 0) ? 2 +
((((u_long)(((((((((((0x3ffff0))) >> 8)) >> 2)) -
1) & (((((((0x3ffff0))) >> 8)) >> 2))) ^ (((
((((0x3ffff0))) >> 8)) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)(((((((((((0x3ffff0))) >> 8))))
- 1) & (((((((0x3ffff0))) >> 8))))) ^ (((((((0x3ffff0
))) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)(((((((((0x3ffff0))))) - 1) & (((((0x3ffff0)))))) ^ ((((
(0x3ffff0))))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((
(((0x3ffff0)))) >> 4)) - 1) & ((((((0x3ffff0)))) >>
4))) ^ ((((((0x3ffff0)))) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)(((((((((((0x3ffff0)))) >> 4) >>
2)) - 1) & (((((((0x3ffff0)))) >> 4) >> 2)))
^ (((((((0x3ffff0)))) >> 4) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ffff0)))) >>
4))) - 1) & (((((((0x3ffff0)))) >> 4)))) ^ (((((((
0x3ffff0)))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : (
(((u_long)((((((((((0x3ffff0)))))) - 1) & ((((((0x3ffff0)
)))))) ^ ((((((0x3ffff0)))))))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((0x3ffff0))))) >> 2)) - 1) & ((((
(((0x3ffff0))))) >> 2))) ^ (((((((0x3ffff0))))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0x3ffff0
))))))) - 1) & (((((((0x3ffff0)))))))) ^ (((((((0x3ffff0)
)))))))) >> (1)) != 0) ? 1 : 0))))))) == 0) ? (void)0 :
__assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 4945, "(val & ~PRESHIFT(SI4126_TWI_DATA_MASK)) == 0"
))
;
4946 bits = LSHIFT(val, SI4126_TWI_DATA_MASK)((val) << ((((u_long)((((((0x3ffff0)) - 1) & ((0x3ffff0
))) ^ ((0x3ffff0)))) >> (16)) != 0) ? 16 + ((((u_long)(
((((((0x3ffff0) >> 16)) - 1) & (((0x3ffff0) >>
16))) ^ (((0x3ffff0) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0x3ffff0) >> 16) >> 8)) - 1
) & ((((0x3ffff0) >> 16) >> 8))) ^ ((((0x3ffff0
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3ffff0) >> 16) >> 8) >> 4)) - 1
) & (((((0x3ffff0) >> 16) >> 8) >> 4)))
^ (((((0x3ffff0) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x3ffff0) >> 16)
>> 8) >> 4) >> 2)) - 1) & ((((((0x3ffff0
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x3ffff0) >> 16) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ffff0
) >> 16) >> 8) >> 4))) - 1) & ((((((0x3ffff0
) >> 16) >> 8) >> 4)))) ^ ((((((0x3ffff0) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0x3ffff0) >> 16) >> 8))) -
1) & (((((0x3ffff0) >> 16) >> 8)))) ^ (((((0x3ffff0
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0x3ffff0) >> 16) >> 8)) >>
2)) - 1) & ((((((0x3ffff0) >> 16) >> 8)) >>
2))) ^ ((((((0x3ffff0) >> 16) >> 8)) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ffff0
) >> 16) >> 8)))) - 1) & ((((((0x3ffff0) >>
16) >> 8))))) ^ ((((((0x3ffff0) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ffff0
) >> 16))) - 1) & ((((0x3ffff0) >> 16)))) ^ (
(((0x3ffff0) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0x3ffff0) >> 16)) >> 4)) - 1) & (((
((0x3ffff0) >> 16)) >> 4))) ^ (((((0x3ffff0) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x3ffff0) >> 16)) >> 4) >> 2)) - 1) &
((((((0x3ffff0) >> 16)) >> 4) >> 2))) ^ ((
((((0x3ffff0) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ffff0) >>
16)) >> 4))) - 1) & ((((((0x3ffff0) >> 16)) >>
4)))) ^ ((((((0x3ffff0) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ffff0) >>
16)))) - 1) & (((((0x3ffff0) >> 16))))) ^ (((((0x3ffff0
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0x3ffff0) >> 16))) >> 2)) - 1) & ((((((
0x3ffff0) >> 16))) >> 2))) ^ ((((((0x3ffff0) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x3ffff0) >> 16))))) - 1) & ((((((0x3ffff0
) >> 16)))))) ^ ((((((0x3ffff0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x3ffff0))) - 1) &
(((0x3ffff0)))) ^ (((0x3ffff0))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0x3ffff0)) >> 8)) - 1) & ((((0x3ffff0
)) >> 8))) ^ ((((0x3ffff0)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0x3ffff0)) >> 8) >>
4)) - 1) & (((((0x3ffff0)) >> 8) >> 4))) ^ (
((((0x3ffff0)) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0x3ffff0)) >> 8) >> 4
) >> 2)) - 1) & ((((((0x3ffff0)) >> 8) >>
4) >> 2))) ^ ((((((0x3ffff0)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ffff0
)) >> 8) >> 4))) - 1) & ((((((0x3ffff0)) >>
8) >> 4)))) ^ ((((((0x3ffff0)) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ffff0
)) >> 8))) - 1) & (((((0x3ffff0)) >> 8)))) ^ (
((((0x3ffff0)) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0x3ffff0)) >> 8)) >> 2)) - 1) &
((((((0x3ffff0)) >> 8)) >> 2))) ^ ((((((0x3ffff0
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0x3ffff0)) >> 8)))) - 1) & ((
((((0x3ffff0)) >> 8))))) ^ ((((((0x3ffff0)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x3ffff0
)))) - 1) & ((((0x3ffff0))))) ^ ((((0x3ffff0)))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x3ffff0))) >> 4)
) - 1) & (((((0x3ffff0))) >> 4))) ^ (((((0x3ffff0))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0x3ffff0))) >> 4) >> 2)) - 1) & ((((((0x3ffff0
))) >> 4) >> 2))) ^ ((((((0x3ffff0))) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0x3ffff0))) >> 4))) - 1) & ((((((0x3ffff0)))
>> 4)))) ^ ((((((0x3ffff0))) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x3ffff0))))) - 1) &
(((((0x3ffff0)))))) ^ (((((0x3ffff0))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0x3ffff0)))) >> 2)) - 1) &
((((((0x3ffff0)))) >> 2))) ^ ((((((0x3ffff0)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x3ffff0
)))))) - 1) & ((((((0x3ffff0))))))) ^ ((((((0x3ffff0)))))
))) >> (1)) != 0) ? 1 : 0))))))
|
4947 LSHIFT(addr, SI4126_TWI_ADDR_MASK)((addr) << ((((u_long)((((((0xf)) - 1) & ((0xf))) ^
((0xf)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0xf)
>> 16)) - 1) & (((0xf) >> 16))) ^ (((0xf) >>
16)))) >> (8)) != 0) ? 8 + ((((u_long)((((((((0xf) >>
16) >> 8)) - 1) & ((((0xf) >> 16) >> 8
))) ^ ((((0xf) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xf) >> 16) >> 8) >>
4)) - 1) & (((((0xf) >> 16) >> 8) >> 4
))) ^ (((((0xf) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8) >> 4) >> 2)) - 1) & ((((((0xf) >> 16
) >> 8) >> 4) >> 2))) ^ ((((((0xf) >>
16) >> 8) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16) >> 8
) >> 4))) - 1) & ((((((0xf) >> 16) >> 8
) >> 4)))) ^ ((((((0xf) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf
) >> 16) >> 8))) - 1) & (((((0xf) >> 16
) >> 8)))) ^ (((((0xf) >> 16) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16) >>
8)) >> 2)) - 1) & ((((((0xf) >> 16) >>
8)) >> 2))) ^ ((((((0xf) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16) >> 8)))) - 1) & ((((((0xf) >> 16
) >> 8))))) ^ ((((((0xf) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf) >> 16)
)) - 1) & ((((0xf) >> 16)))) ^ ((((0xf) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf) >>
16)) >> 4)) - 1) & (((((0xf) >> 16)) >>
4))) ^ (((((0xf) >> 16)) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xf) >> 16)) >> 4)
>> 2)) - 1) & ((((((0xf) >> 16)) >> 4)
>> 2))) ^ ((((((0xf) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16)) >> 4))) - 1) & ((((((0xf) >> 16
)) >> 4)))) ^ ((((((0xf) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf) >> 16)
))) - 1) & (((((0xf) >> 16))))) ^ (((((0xf) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf)
>> 16))) >> 2)) - 1) & ((((((0xf) >> 16
))) >> 2))) ^ ((((((0xf) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16)
)))) - 1) & ((((((0xf) >> 16)))))) ^ ((((((0xf) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xf))) - 1) & (((0xf)))) ^ (((0xf))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xf)) >> 8)) - 1) & ((
((0xf)) >> 8))) ^ ((((0xf)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xf)) >> 8) >> 4
)) - 1) & (((((0xf)) >> 8) >> 4))) ^ (((((0xf
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf)) >> 8) >> 4) >> 2)) - 1) &
((((((0xf)) >> 8) >> 4) >> 2))) ^ ((((((0xf
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xf)) >> 8) >> 4
))) - 1) & ((((((0xf)) >> 8) >> 4)))) ^ (((((
(0xf)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xf)) >> 8))) - 1) & (((((
0xf)) >> 8)))) ^ (((((0xf)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xf)) >> 8)) >>
2)) - 1) & ((((((0xf)) >> 8)) >> 2))) ^ ((((
((0xf)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)) >> 8)))) - 1) & ((
((((0xf)) >> 8))))) ^ ((((((0xf)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf)))) - 1) &
((((0xf))))) ^ ((((0xf)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf))) >> 4)) - 1) & (((((0xf))) >>
4))) ^ (((((0xf))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf))) >> 4) >> 2)) - 1) &
((((((0xf))) >> 4) >> 2))) ^ ((((((0xf))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xf))) >> 4))) - 1) & ((((((0xf))) >>
4)))) ^ ((((((0xf))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xf))))) - 1) & (((((0xf))))
)) ^ (((((0xf))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf)))) >> 2)) - 1) & ((((((0xf)))) >>
2))) ^ ((((((0xf)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)))))) - 1) & ((((((0xf))))
))) ^ ((((((0xf)))))))) >> (1)) != 0) ? 1 : 0))))))
;
4948 nbits = 22;
4949 lo_to_hi = 0;
4950 break;
4951 case RTW_RFCHIPID_RTL82250x09:
4952 case RTW_RFCHIPID_RTL82550x0a:
4953 nbits = 16;
4954 lo_to_hi = 0;
4955 bits = LSHIFT(val, RTL8225_TWI_DATA_MASK)((val) << ((((u_long)((((((0xfffffff0)) - 1) & ((0xfffffff0
))) ^ ((0xfffffff0)))) >> (16)) != 0) ? 16 + ((((u_long
)(((((((0xfffffff0) >> 16)) - 1) & (((0xfffffff0) >>
16))) ^ (((0xfffffff0) >> 16)))) >> (8)) != 0) ?
8 + ((((u_long)((((((((0xfffffff0) >> 16) >> 8))
- 1) & ((((0xfffffff0) >> 16) >> 8))) ^ ((((
0xfffffff0) >> 16) >> 8)))) >> (4)) != 0) ?
4 + ((((u_long)(((((((((0xfffffff0) >> 16) >> 8)
>> 4)) - 1) & (((((0xfffffff0) >> 16) >>
8) >> 4))) ^ (((((0xfffffff0) >> 16) >> 8)
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0xfffffff0) >> 16) >> 8) >> 4) >> 2
)) - 1) & ((((((0xfffffff0) >> 16) >> 8) >>
4) >> 2))) ^ ((((((0xfffffff0) >> 16) >> 8
) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0xfffffff0) >> 16) >> 8) >>
4))) - 1) & ((((((0xfffffff0) >> 16) >> 8) >>
4)))) ^ ((((((0xfffffff0) >> 16) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfffffff0
) >> 16) >> 8))) - 1) & (((((0xfffffff0) >>
16) >> 8)))) ^ (((((0xfffffff0) >> 16) >> 8
))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xfffffff0
) >> 16) >> 8)) >> 2)) - 1) & ((((((0xfffffff0
) >> 16) >> 8)) >> 2))) ^ ((((((0xfffffff0)
>> 16) >> 8)) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xfffffff0) >> 16) >>
8)))) - 1) & ((((((0xfffffff0) >> 16) >> 8))
))) ^ ((((((0xfffffff0) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xfffffff0) >>
16))) - 1) & ((((0xfffffff0) >> 16)))) ^ ((((0xfffffff0
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0xfffffff0) >> 16)) >> 4)) - 1) & (((((0xfffffff0
) >> 16)) >> 4))) ^ (((((0xfffffff0) >> 16)
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xfffffff0) >> 16)) >> 4) >> 2)) - 1) &
((((((0xfffffff0) >> 16)) >> 4) >> 2))) ^ (
(((((0xfffffff0) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfffffff0) >>
16)) >> 4))) - 1) & ((((((0xfffffff0) >> 16)
) >> 4)))) ^ ((((((0xfffffff0) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xfffffff0
) >> 16)))) - 1) & (((((0xfffffff0) >> 16))))
) ^ (((((0xfffffff0) >> 16)))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0xfffffff0) >> 16))) >> 2
)) - 1) & ((((((0xfffffff0) >> 16))) >> 2))) ^
((((((0xfffffff0) >> 16))) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfffffff0) >> 16
))))) - 1) & ((((((0xfffffff0) >> 16)))))) ^ ((((((
0xfffffff0) >> 16))))))) >> (1)) != 0) ? 1 : 0)))
) : ((((u_long)(((((((0xfffffff0))) - 1) & (((0xfffffff0)
))) ^ (((0xfffffff0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xfffffff0)) >> 8)) - 1) & ((((0xfffffff0)
) >> 8))) ^ ((((0xfffffff0)) >> 8)))) >> (4
)) != 0) ? 4 + ((((u_long)(((((((((0xfffffff0)) >> 8) >>
4)) - 1) & (((((0xfffffff0)) >> 8) >> 4))) ^
(((((0xfffffff0)) >> 8) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0xfffffff0)) >> 8) >>
4) >> 2)) - 1) & ((((((0xfffffff0)) >> 8) >>
4) >> 2))) ^ ((((((0xfffffff0)) >> 8) >> 4
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
((((((((0xfffffff0)) >> 8) >> 4))) - 1) & (((
(((0xfffffff0)) >> 8) >> 4)))) ^ ((((((0xfffffff0
)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)) :
((((u_long)(((((((((0xfffffff0)) >> 8))) - 1) & ((
(((0xfffffff0)) >> 8)))) ^ (((((0xfffffff0)) >> 8
))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xfffffff0
)) >> 8)) >> 2)) - 1) & ((((((0xfffffff0)) >>
8)) >> 2))) ^ ((((((0xfffffff0)) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfffffff0
)) >> 8)))) - 1) & ((((((0xfffffff0)) >> 8)))
)) ^ ((((((0xfffffff0)) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0xfffffff0)))) - 1) & ((((
0xfffffff0))))) ^ ((((0xfffffff0)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xfffffff0))) >> 4)) - 1) & (
((((0xfffffff0))) >> 4))) ^ (((((0xfffffff0))) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xfffffff0
))) >> 4) >> 2)) - 1) & ((((((0xfffffff0))) >>
4) >> 2))) ^ ((((((0xfffffff0))) >> 4) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xfffffff0
))) >> 4))) - 1) & ((((((0xfffffff0))) >> 4))
)) ^ ((((((0xfffffff0))) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0xfffffff0))))) - 1) & (((
((0xfffffff0)))))) ^ (((((0xfffffff0))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0xfffffff0)))) >> 2)) - 1)
& ((((((0xfffffff0)))) >> 2))) ^ ((((((0xfffffff0)
))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xfffffff0)))))) - 1) & ((((((0xfffffff0)))))))
^ ((((((0xfffffff0)))))))) >> (1)) != 0) ? 1 : 0))))))
|
4956 LSHIFT(addr, RTL8225_TWI_ADDR_MASK)((addr) << ((((u_long)((((((0x1f)) - 1) & ((0x1f)))
^ ((0x1f)))) >> (16)) != 0) ? 16 + ((((u_long)(((((((0x1f
) >> 16)) - 1) & (((0x1f) >> 16))) ^ (((0x1f)
>> 16)))) >> (8)) != 0) ? 8 + ((((u_long)(((((((
(0x1f) >> 16) >> 8)) - 1) & ((((0x1f) >>
16) >> 8))) ^ ((((0x1f) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0x1f) >> 16) >>
8) >> 4)) - 1) & (((((0x1f) >> 16) >> 8
) >> 4))) ^ (((((0x1f) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x1f) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0x1f
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0x1f) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x1f) >> 16
) >> 8) >> 4))) - 1) & ((((((0x1f) >> 16
) >> 8) >> 4)))) ^ ((((((0x1f) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0x1f) >> 16) >> 8))) - 1) & (((((0x1f
) >> 16) >> 8)))) ^ (((((0x1f) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x1f) >>
16) >> 8)) >> 2)) - 1) & ((((((0x1f) >>
16) >> 8)) >> 2))) ^ ((((((0x1f) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0x1f) >> 16) >> 8)))) - 1) & (((((
(0x1f) >> 16) >> 8))))) ^ ((((((0x1f) >> 16
) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0x1f) >> 16))) - 1) & ((((0x1f) >> 16
)))) ^ ((((0x1f) >> 16))))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0x1f) >> 16)) >> 4)) - 1) &
(((((0x1f) >> 16)) >> 4))) ^ (((((0x1f) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0x1f) >> 16)) >> 4) >> 2)) - 1) &
((((((0x1f) >> 16)) >> 4) >> 2))) ^ ((((((
0x1f) >> 16)) >> 4) >> 2)))) >> (1)) !=
0) ? 1 : 0) : ((((u_long)((((((((((0x1f) >> 16)) >>
4))) - 1) & ((((((0x1f) >> 16)) >> 4)))) ^ (
(((((0x1f) >> 16)) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x1f) >> 16)))) - 1) &
(((((0x1f) >> 16))))) ^ (((((0x1f) >> 16)))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x1f) >> 16))) >>
2)) - 1) & ((((((0x1f) >> 16))) >> 2))) ^ ((
((((0x1f) >> 16))) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0x1f) >> 16))))) - 1) &
((((((0x1f) >> 16)))))) ^ ((((((0x1f) >> 16)))))
)) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0x1f))
) - 1) & (((0x1f)))) ^ (((0x1f))))) >> (8)) != 0) ?
8 + ((((u_long)((((((((0x1f)) >> 8)) - 1) & ((((0x1f
)) >> 8))) ^ ((((0x1f)) >> 8)))) >> (4)) !=
0) ? 4 + ((((u_long)(((((((((0x1f)) >> 8) >> 4))
- 1) & (((((0x1f)) >> 8) >> 4))) ^ (((((0x1f
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0x1f)) >> 8) >> 4) >> 2)) - 1) &
((((((0x1f)) >> 8) >> 4) >> 2))) ^ ((((((0x1f
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x1f)) >> 8) >> 4
))) - 1) & ((((((0x1f)) >> 8) >> 4)))) ^ ((((
((0x1f)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0x1f)) >> 8))) - 1) & ((
(((0x1f)) >> 8)))) ^ (((((0x1f)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x1f)) >> 8)) >>
2)) - 1) & ((((((0x1f)) >> 8)) >> 2))) ^ (((
(((0x1f)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x1f)) >> 8)))) - 1) &
((((((0x1f)) >> 8))))) ^ ((((((0x1f)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x1f))))
- 1) & ((((0x1f))))) ^ ((((0x1f)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0x1f))) >> 4)) - 1) & (
((((0x1f))) >> 4))) ^ (((((0x1f))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0x1f))) >> 4) >>
2)) - 1) & ((((((0x1f))) >> 4) >> 2))) ^ (((
(((0x1f))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0x1f))) >> 4))) - 1) &
((((((0x1f))) >> 4)))) ^ ((((((0x1f))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x1f))))
) - 1) & (((((0x1f)))))) ^ (((((0x1f))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0x1f)))) >> 2)) - 1) &
((((((0x1f)))) >> 2))) ^ ((((((0x1f)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x1f))))
)) - 1) & ((((((0x1f))))))) ^ ((((((0x1f)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
4957
4958 /* the RTL8225 uses a slightly modified RF interface */
4959 rf_bangbits = rtw_rf_hostbangbits;
4960 break;
4961 case RTW_RFCHIPID_INTERSIL0x01:
4962 default:
4963 printf("%s: unknown rfchipid %d\n", __func__, sc->sc_rfchipid);
4964 return -1;
4965 }
4966
4967 (*rf_bangbits)(&sc->sc_regs, bits, lo_to_hi, nbits);
4968
4969 return 0;
4970}
4971
4972u_int32_t
4973rtw_maxim_swizzle(u_int addr, u_int32_t val)
4974{
4975 u_int32_t hidata, lodata;
4976
4977 KASSERT((val & ~(RTW_MAXIM_LODATA_MASK|RTW_MAXIM_HIDATA_MASK)) == 0)(((val & ~(0xf|0xff0)) == 0) ? (void)0 : __assert("diagnostic "
, "/usr/src/sys/dev/ic/rtw.c", 4977, "(val & ~(RTW_MAXIM_LODATA_MASK|RTW_MAXIM_HIDATA_MASK)) == 0"
))
;
4978 lodata = MASK_AND_RSHIFT(val, RTW_MAXIM_LODATA_MASK)(((val) & (0xf)) >> ((((u_long)((((((0xf)) - 1) &
((0xf))) ^ ((0xf)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0xf) >> 16)) - 1) & (((0xf) >> 16))) ^
(((0xf) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xf) >> 16) >> 8)) - 1) & ((((0xf) >>
16) >> 8))) ^ ((((0xf) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xf) >> 16) >>
8) >> 4)) - 1) & (((((0xf) >> 16) >> 8
) >> 4))) ^ (((((0xf) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0xf
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xf) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16)
>> 8) >> 4))) - 1) & ((((((0xf) >> 16)
>> 8) >> 4)))) ^ ((((((0xf) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xf) >> 16) >> 8))) - 1) & (((((0xf
) >> 16) >> 8)))) ^ (((((0xf) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >>
16) >> 8)) >> 2)) - 1) & ((((((0xf) >>
16) >> 8)) >> 2))) ^ ((((((0xf) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xf) >> 16) >> 8)))) - 1) & ((((((
0xf) >> 16) >> 8))))) ^ ((((((0xf) >> 16) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
0xf) >> 16))) - 1) & ((((0xf) >> 16)))) ^ (((
(0xf) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(
((((((((0xf) >> 16)) >> 4)) - 1) & (((((0xf) >>
16)) >> 4))) ^ (((((0xf) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf) >> 16)) >>
4) >> 2)) - 1) & ((((((0xf) >> 16)) >>
4) >> 2))) ^ ((((((0xf) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf
) >> 16)) >> 4))) - 1) & ((((((0xf) >> 16
)) >> 4)))) ^ ((((((0xf) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf) >> 16)
))) - 1) & (((((0xf) >> 16))))) ^ (((((0xf) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf)
>> 16))) >> 2)) - 1) & ((((((0xf) >> 16
))) >> 2))) ^ ((((((0xf) >> 16))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf) >> 16)
)))) - 1) & ((((((0xf) >> 16)))))) ^ ((((((0xf) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
((0xf))) - 1) & (((0xf)))) ^ (((0xf))))) >> (8)) !=
0) ? 8 + ((((u_long)((((((((0xf)) >> 8)) - 1) & ((
((0xf)) >> 8))) ^ ((((0xf)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xf)) >> 8) >> 4
)) - 1) & (((((0xf)) >> 8) >> 4))) ^ (((((0xf
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf)) >> 8) >> 4) >> 2)) - 1) &
((((((0xf)) >> 8) >> 4) >> 2))) ^ ((((((0xf
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xf)) >> 8) >> 4
))) - 1) & ((((((0xf)) >> 8) >> 4)))) ^ (((((
(0xf)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0
)) : ((((u_long)(((((((((0xf)) >> 8))) - 1) & (((((
0xf)) >> 8)))) ^ (((((0xf)) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xf)) >> 8)) >>
2)) - 1) & ((((((0xf)) >> 8)) >> 2))) ^ ((((
((0xf)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)) >> 8)))) - 1) & ((
((((0xf)) >> 8))))) ^ ((((((0xf)) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf)))) - 1) &
((((0xf))))) ^ ((((0xf)))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf))) >> 4)) - 1) & (((((0xf))) >>
4))) ^ (((((0xf))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf))) >> 4) >> 2)) - 1) &
((((((0xf))) >> 4) >> 2))) ^ ((((((0xf))) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xf))) >> 4))) - 1) & ((((((0xf))) >>
4)))) ^ ((((((0xf))) >> 4))))) >> (1)) != 0) ? 1
: 0)) : ((((u_long)(((((((((0xf))))) - 1) & (((((0xf))))
)) ^ (((((0xf))))))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xf)))) >> 2)) - 1) & ((((((0xf)))) >>
2))) ^ ((((((0xf)))) >> 2)))) >> (1)) != 0) ? 1 :
0) : ((((u_long)((((((((((0xf)))))) - 1) & ((((((0xf))))
))) ^ ((((((0xf)))))))) >> (1)) != 0) ? 1 : 0))))))
;
4979 hidata = MASK_AND_RSHIFT(val, RTW_MAXIM_HIDATA_MASK)(((val) & (0xff0)) >> ((((u_long)((((((0xff0)) - 1)
& ((0xff0))) ^ ((0xff0)))) >> (16)) != 0) ? 16 + (
(((u_long)(((((((0xff0) >> 16)) - 1) & (((0xff0) >>
16))) ^ (((0xff0) >> 16)))) >> (8)) != 0) ? 8 + (
(((u_long)((((((((0xff0) >> 16) >> 8)) - 1) &
((((0xff0) >> 16) >> 8))) ^ ((((0xff0) >> 16
) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((
((0xff0) >> 16) >> 8) >> 4)) - 1) & (((
((0xff0) >> 16) >> 8) >> 4))) ^ (((((0xff0)
>> 16) >> 8) >> 4)))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xff0) >> 16) >> 8) >>
4) >> 2)) - 1) & ((((((0xff0) >> 16) >>
8) >> 4) >> 2))) ^ ((((((0xff0) >> 16) >>
8) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xff0) >> 16) >> 8) >>
4))) - 1) & ((((((0xff0) >> 16) >> 8) >>
4)))) ^ ((((((0xff0) >> 16) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff0) >>
16) >> 8))) - 1) & (((((0xff0) >> 16) >>
8)))) ^ (((((0xff0) >> 16) >> 8))))) >> (2
)) != 0) ? 2 + ((((u_long)((((((((((0xff0) >> 16) >>
8)) >> 2)) - 1) & ((((((0xff0) >> 16) >>
8)) >> 2))) ^ ((((((0xff0) >> 16) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0
) >> 16) >> 8)))) - 1) & ((((((0xff0) >>
16) >> 8))))) ^ ((((((0xff0) >> 16) >> 8))
)))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff0
) >> 16))) - 1) & ((((0xff0) >> 16)))) ^ ((((
0xff0) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)
(((((((((0xff0) >> 16)) >> 4)) - 1) & (((((0xff0
) >> 16)) >> 4))) ^ (((((0xff0) >> 16)) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff0) >>
16)) >> 4) >> 2)) - 1) & ((((((0xff0) >>
16)) >> 4) >> 2))) ^ ((((((0xff0) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xff0) >> 16)) >> 4))) - 1) & (((((
(0xff0) >> 16)) >> 4)))) ^ ((((((0xff0) >> 16
)) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xff0) >> 16)))) - 1) & (((((0xff0) >>
16))))) ^ (((((0xff0) >> 16)))))) >> (2)) != 0) ?
2 + ((((u_long)((((((((((0xff0) >> 16))) >> 2)) -
1) & ((((((0xff0) >> 16))) >> 2))) ^ ((((((0xff0
) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xff0) >> 16))))) - 1) & ((((
((0xff0) >> 16)))))) ^ ((((((0xff0) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xff0))) - 1) &
(((0xff0)))) ^ (((0xff0))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xff0)) >> 8)) - 1) & ((((0xff0)) >>
8))) ^ ((((0xff0)) >> 8)))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xff0)) >> 8) >> 4)) - 1) &
(((((0xff0)) >> 8) >> 4))) ^ (((((0xff0)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xff0)) >> 8) >> 4) >> 2)) - 1) & (
(((((0xff0)) >> 8) >> 4) >> 2))) ^ ((((((0xff0
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xff0)) >> 8) >>
4))) - 1) & ((((((0xff0)) >> 8) >> 4)))) ^ (
(((((0xff0)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0xff0)) >> 8))) - 1) &
(((((0xff0)) >> 8)))) ^ (((((0xff0)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff0)) >> 8)) >>
2)) - 1) & ((((((0xff0)) >> 8)) >> 2))) ^ ((
((((0xff0)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xff0)) >> 8)))) - 1) &
((((((0xff0)) >> 8))))) ^ ((((((0xff0)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff0)
))) - 1) & ((((0xff0))))) ^ ((((0xff0)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0xff0))) >> 4)) - 1) &
(((((0xff0))) >> 4))) ^ (((((0xff0))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff0))) >> 4) >>
2)) - 1) & ((((((0xff0))) >> 4) >> 2))) ^ ((
((((0xff0))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xff0))) >> 4))) - 1) &
((((((0xff0))) >> 4)))) ^ ((((((0xff0))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff0)
)))) - 1) & (((((0xff0)))))) ^ (((((0xff0))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff0)))) >> 2))
- 1) & ((((((0xff0)))) >> 2))) ^ ((((((0xff0)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff0
)))))) - 1) & ((((((0xff0))))))) ^ ((((((0xff0)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
4980 return LSHIFT(lodata, RTW8180_PHYCFG_MAC_MAXIM_LODATA_MASK)((lodata) << ((((u_long)((((((0xf000000)) - 1) & ((
0xf000000))) ^ ((0xf000000)))) >> (16)) != 0) ? 16 + ((
((u_long)(((((((0xf000000) >> 16)) - 1) & (((0xf000000
) >> 16))) ^ (((0xf000000) >> 16)))) >> (8)
) != 0) ? 8 + ((((u_long)((((((((0xf000000) >> 16) >>
8)) - 1) & ((((0xf000000) >> 16) >> 8))) ^ (
(((0xf000000) >> 16) >> 8)))) >> (4)) != 0)
? 4 + ((((u_long)(((((((((0xf000000) >> 16) >> 8
) >> 4)) - 1) & (((((0xf000000) >> 16) >>
8) >> 4))) ^ (((((0xf000000) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
) >> 16) >> 8) >> 4) >> 2)) - 1) &
((((((0xf000000) >> 16) >> 8) >> 4) >>
2))) ^ ((((((0xf000000) >> 16) >> 8) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0xf000000) >> 16) >> 8) >> 4))) - 1)
& ((((((0xf000000) >> 16) >> 8) >> 4))
)) ^ ((((((0xf000000) >> 16) >> 8) >> 4))))
) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000
) >> 16) >> 8))) - 1) & (((((0xf000000) >>
16) >> 8)))) ^ (((((0xf000000) >> 16) >> 8
))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
) >> 16) >> 8)) >> 2)) - 1) & ((((((0xf000000
) >> 16) >> 8)) >> 2))) ^ ((((((0xf000000) >>
16) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)((((((((((0xf000000) >> 16) >> 8)))
) - 1) & ((((((0xf000000) >> 16) >> 8))))) ^ (
(((((0xf000000) >> 16) >> 8)))))) >> (1)) !=
0) ? 1 : 0))) : ((((u_long)((((((((0xf000000) >> 16)))
- 1) & ((((0xf000000) >> 16)))) ^ ((((0xf000000) >>
16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000
) >> 16)) >> 4)) - 1) & (((((0xf000000) >>
16)) >> 4))) ^ (((((0xf000000) >> 16)) >> 4
)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
) >> 16)) >> 4) >> 2)) - 1) & ((((((0xf000000
) >> 16)) >> 4) >> 2))) ^ ((((((0xf000000) >>
16)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)((((((((((0xf000000) >> 16)) >> 4))
) - 1) & ((((((0xf000000) >> 16)) >> 4)))) ^ (
(((((0xf000000) >> 16)) >> 4))))) >> (1)) !=
0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000) >> 16)))
) - 1) & (((((0xf000000) >> 16))))) ^ (((((0xf000000
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0xf000000) >> 16))) >> 2)) - 1) & (((((
(0xf000000) >> 16))) >> 2))) ^ ((((((0xf000000) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xf000000) >> 16))))) - 1) & ((((((0xf000000
) >> 16)))))) ^ ((((((0xf000000) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xf000000))) - 1)
& (((0xf000000)))) ^ (((0xf000000))))) >> (8)) != 0
) ? 8 + ((((u_long)((((((((0xf000000)) >> 8)) - 1) &
((((0xf000000)) >> 8))) ^ ((((0xf000000)) >> 8))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000)) >>
8) >> 4)) - 1) & (((((0xf000000)) >> 8) >>
4))) ^ (((((0xf000000)) >> 8) >> 4)))) >> (
2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000)) >> 8) >>
4) >> 2)) - 1) & ((((((0xf000000)) >> 8) >>
4) >> 2))) ^ ((((((0xf000000)) >> 8) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0xf000000)) >> 8) >> 4))) - 1) & (((((
(0xf000000)) >> 8) >> 4)))) ^ ((((((0xf000000)) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xf000000)) >> 8))) - 1) & (((((0xf000000
)) >> 8)))) ^ (((((0xf000000)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000)) >> 8
)) >> 2)) - 1) & ((((((0xf000000)) >> 8)) >>
2))) ^ ((((((0xf000000)) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000)) >>
8)))) - 1) & ((((((0xf000000)) >> 8))))) ^ ((((((0xf000000
)) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xf000000)))) - 1) & ((((0xf000000))))) ^ ((((0xf000000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000
))) >> 4)) - 1) & (((((0xf000000))) >> 4))) ^
(((((0xf000000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000))) >> 4) >> 2)) - 1
) & ((((((0xf000000))) >> 4) >> 2))) ^ ((((((
0xf000000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000))) >> 4))) - 1
) & ((((((0xf000000))) >> 4)))) ^ ((((((0xf000000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xf000000))))) - 1) & (((((0xf000000)))))) ^ (((
((0xf000000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf000000)))) >> 2)) - 1) & ((((((0xf000000)))
) >> 2))) ^ ((((((0xf000000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000)))))) -
1) & ((((((0xf000000))))))) ^ ((((((0xf000000)))))))) >>
(1)) != 0) ? 1 : 0))))))
|
4981 LSHIFT(hidata, RTW8180_PHYCFG_MAC_MAXIM_HIDATA_MASK)((hidata) << ((((u_long)((((((0xff)) - 1) & ((0xff)
)) ^ ((0xff)))) >> (16)) != 0) ? 16 + ((((u_long)((((((
(0xff) >> 16)) - 1) & (((0xff) >> 16))) ^ (((
0xff) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long)((
((((((0xff) >> 16) >> 8)) - 1) & ((((0xff) >>
16) >> 8))) ^ ((((0xff) >> 16) >> 8)))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xff) >> 16) >>
8) >> 4)) - 1) & (((((0xff) >> 16) >> 8
) >> 4))) ^ (((((0xff) >> 16) >> 8) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >>
16) >> 8) >> 4) >> 2)) - 1) & ((((((0xff
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xff) >> 16) >> 8) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16
) >> 8) >> 4))) - 1) & ((((((0xff) >> 16
) >> 8) >> 4)))) ^ ((((((0xff) >> 16) >>
8) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long
)(((((((((0xff) >> 16) >> 8))) - 1) & (((((0xff
) >> 16) >> 8)))) ^ (((((0xff) >> 16) >>
8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >>
16) >> 8)) >> 2)) - 1) & ((((((0xff) >>
16) >> 8)) >> 2))) ^ ((((((0xff) >> 16) >>
8)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xff) >> 16) >> 8)))) - 1) & (((((
(0xff) >> 16) >> 8))))) ^ ((((((0xff) >> 16
) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xff) >> 16))) - 1) & ((((0xff) >> 16
)))) ^ ((((0xff) >> 16))))) >> (4)) != 0) ? 4 + (
(((u_long)(((((((((0xff) >> 16)) >> 4)) - 1) &
(((((0xff) >> 16)) >> 4))) ^ (((((0xff) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xff) >> 16)) >> 4) >> 2)) - 1) &
((((((0xff) >> 16)) >> 4) >> 2))) ^ ((((((
0xff) >> 16)) >> 4) >> 2)))) >> (1)) !=
0) ? 1 : 0) : ((((u_long)((((((((((0xff) >> 16)) >>
4))) - 1) & ((((((0xff) >> 16)) >> 4)))) ^ (
(((((0xff) >> 16)) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0xff) >> 16)))) - 1) &
(((((0xff) >> 16))))) ^ (((((0xff) >> 16)))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff) >> 16))) >>
2)) - 1) & ((((((0xff) >> 16))) >> 2))) ^ ((
((((0xff) >> 16))) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xff) >> 16))))) - 1) &
((((((0xff) >> 16)))))) ^ ((((((0xff) >> 16)))))
)) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xff))
) - 1) & (((0xff)))) ^ (((0xff))))) >> (8)) != 0) ?
8 + ((((u_long)((((((((0xff)) >> 8)) - 1) & ((((0xff
)) >> 8))) ^ ((((0xff)) >> 8)))) >> (4)) !=
0) ? 4 + ((((u_long)(((((((((0xff)) >> 8) >> 4))
- 1) & (((((0xff)) >> 8) >> 4))) ^ (((((0xff
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xff)) >> 8) >> 4) >> 2)) - 1) &
((((((0xff)) >> 8) >> 4) >> 2))) ^ ((((((0xff
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xff)) >> 8) >> 4
))) - 1) & ((((((0xff)) >> 8) >> 4)))) ^ ((((
((0xff)) >> 8) >> 4))))) >> (1)) != 0) ? 1 :
0)) : ((((u_long)(((((((((0xff)) >> 8))) - 1) & ((
(((0xff)) >> 8)))) ^ (((((0xff)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff)) >> 8)) >>
2)) - 1) & ((((((0xff)) >> 8)) >> 2))) ^ (((
(((0xff)) >> 8)) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xff)) >> 8)))) - 1) &
((((((0xff)) >> 8))))) ^ ((((((0xff)) >> 8))))))
>> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xff))))
- 1) & ((((0xff))))) ^ ((((0xff)))))) >> (4)) != 0
) ? 4 + ((((u_long)(((((((((0xff))) >> 4)) - 1) & (
((((0xff))) >> 4))) ^ (((((0xff))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xff))) >> 4) >>
2)) - 1) & ((((((0xff))) >> 4) >> 2))) ^ (((
(((0xff))) >> 4) >> 2)))) >> (1)) != 0) ? 1
: 0) : ((((u_long)((((((((((0xff))) >> 4))) - 1) &
((((((0xff))) >> 4)))) ^ ((((((0xff))) >> 4)))))
>> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xff))))
) - 1) & (((((0xff)))))) ^ (((((0xff))))))) >> (2))
!= 0) ? 2 + ((((u_long)((((((((((0xff)))) >> 2)) - 1) &
((((((0xff)))) >> 2))) ^ ((((((0xff)))) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xff))))
)) - 1) & ((((((0xff))))))) ^ ((((((0xff)))))))) >>
(1)) != 0) ? 1 : 0))))))
|
4982 LSHIFT(addr, RTW8180_PHYCFG_MAC_MAXIM_ADDR_MASK)((addr) << ((((u_long)((((((0xf00)) - 1) & ((0xf00)
)) ^ ((0xf00)))) >> (16)) != 0) ? 16 + ((((u_long)(((((
((0xf00) >> 16)) - 1) & (((0xf00) >> 16))) ^ (
((0xf00) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xf00) >> 16) >> 8)) - 1) & ((((0xf00
) >> 16) >> 8))) ^ ((((0xf00) >> 16) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf00) >>
16) >> 8) >> 4)) - 1) & (((((0xf00) >>
16) >> 8) >> 4))) ^ (((((0xf00) >> 16) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf00) >> 16) >> 8) >> 4) >> 2))
- 1) & ((((((0xf00) >> 16) >> 8) >> 4)
>> 2))) ^ ((((((0xf00) >> 16) >> 8) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0xf00) >> 16) >> 8) >> 4))) - 1) &
((((((0xf00) >> 16) >> 8) >> 4)))) ^ (((((
(0xf00) >> 16) >> 8) >> 4))))) >> (1)
) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf00) >> 16) >>
8))) - 1) & (((((0xf00) >> 16) >> 8)))) ^ ((
(((0xf00) >> 16) >> 8))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0xf00) >> 16) >> 8)) >>
2)) - 1) & ((((((0xf00) >> 16) >> 8)) >>
2))) ^ ((((((0xf00) >> 16) >> 8)) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00) >>
16) >> 8)))) - 1) & ((((((0xf00) >> 16) >>
8))))) ^ ((((((0xf00) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf00) >> 16
))) - 1) & ((((0xf00) >> 16)))) ^ ((((0xf00) >>
16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf00)
>> 16)) >> 4)) - 1) & (((((0xf00) >> 16
)) >> 4))) ^ (((((0xf00) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf00) >> 16)) >>
4) >> 2)) - 1) & ((((((0xf00) >> 16)) >>
4) >> 2))) ^ ((((((0xf00) >> 16)) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00
) >> 16)) >> 4))) - 1) & ((((((0xf00) >>
16)) >> 4)))) ^ ((((((0xf00) >> 16)) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf00
) >> 16)))) - 1) & (((((0xf00) >> 16))))) ^ (
((((0xf00) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf00) >> 16))) >> 2)) - 1) & ((((
((0xf00) >> 16))) >> 2))) ^ ((((((0xf00) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xf00) >> 16))))) - 1) & ((((((0xf00) >>
16)))))) ^ ((((((0xf00) >> 16))))))) >> (1)) != 0
) ? 1 : 0)))) : ((((u_long)(((((((0xf00))) - 1) & (((0xf00
)))) ^ (((0xf00))))) >> (8)) != 0) ? 8 + ((((u_long)(((
(((((0xf00)) >> 8)) - 1) & ((((0xf00)) >> 8))
) ^ ((((0xf00)) >> 8)))) >> (4)) != 0) ? 4 + ((((
u_long)(((((((((0xf00)) >> 8) >> 4)) - 1) & (
((((0xf00)) >> 8) >> 4))) ^ (((((0xf00)) >>
8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf00)) >> 8) >> 4) >> 2)) - 1) & (
(((((0xf00)) >> 8) >> 4) >> 2))) ^ ((((((0xf00
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0xf00)) >> 8) >>
4))) - 1) & ((((((0xf00)) >> 8) >> 4)))) ^ (
(((((0xf00)) >> 8) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0xf00)) >> 8))) - 1) &
(((((0xf00)) >> 8)))) ^ (((((0xf00)) >> 8))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf00)) >> 8)) >>
2)) - 1) & ((((((0xf00)) >> 8)) >> 2))) ^ ((
((((0xf00)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf00)) >> 8)))) - 1) &
((((((0xf00)) >> 8))))) ^ ((((((0xf00)) >> 8))))
)) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xf00)
))) - 1) & ((((0xf00))))) ^ ((((0xf00)))))) >> (4))
!= 0) ? 4 + ((((u_long)(((((((((0xf00))) >> 4)) - 1) &
(((((0xf00))) >> 4))) ^ (((((0xf00))) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf00))) >> 4) >>
2)) - 1) & ((((((0xf00))) >> 4) >> 2))) ^ ((
((((0xf00))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf00))) >> 4))) - 1) &
((((((0xf00))) >> 4)))) ^ ((((((0xf00))) >> 4)))
)) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf00)
)))) - 1) & (((((0xf00)))))) ^ (((((0xf00))))))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf00)))) >> 2))
- 1) & ((((((0xf00)))) >> 2))) ^ ((((((0xf00)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf00
)))))) - 1) & ((((((0xf00))))))) ^ ((((((0xf00)))))))) >>
(1)) != 0) ? 1 : 0))))))
;
4983}
4984
4985/* Tell the MAC what to bang over the 3-wire interface. */
4986int
4987rtw_rf_macwrite(struct rtw_softc *sc, u_int addr, u_int32_t val)
4988{
4989 u_int32_t reg;
4990
4991 RTW_DPRINTF(RTW_DEBUG_PHYIO, ("%s: %s[%u] <- %#08x\n", __func__,
4992 addr, val));
4993
4994 switch (sc->sc_rfchipid) {
4995 case RTW_RFCHIPID_GCT0x05:
4996 reg = rtw_grf5101_mac_crypt(addr, val);
4997 break;
4998 case RTW_RFCHIPID_MAXIM28200x04:
4999 reg = rtw_maxim_swizzle(addr, val);
5000 break;
5001 default: /* XXX */
5002 case RTW_RFCHIPID_PHILIPS0x03:
5003 KASSERT((addr &(((addr & ~((((0xf000000)) & ((0xf000000))) >> (
(((u_long)(((((((0xf000000))) - 1) & (((0xf000000)))) ^ (
((0xf000000))))) >> (16)) != 0) ? 16 + ((((u_long)(((((
(((0xf000000)) >> 16)) - 1) & ((((0xf000000)) >>
16))) ^ ((((0xf000000)) >> 16)))) >> (8)) != 0) ?
8 + ((((u_long)(((((((((0xf000000)) >> 16) >> 8)
) - 1) & (((((0xf000000)) >> 16) >> 8))) ^ ((
(((0xf000000)) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)((((((((((0xf000000)) >> 16) >>
8) >> 4)) - 1) & ((((((0xf000000)) >> 16) >>
8) >> 4))) ^ ((((((0xf000000)) >> 16) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
((((0xf000000)) >> 16) >> 8) >> 4) >>
2)) - 1) & (((((((0xf000000)) >> 16) >> 8) >>
4) >> 2))) ^ (((((((0xf000000)) >> 16) >> 8
) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)(((((((((((0xf000000)) >> 16) >> 8) >>
4))) - 1) & (((((((0xf000000)) >> 16) >> 8) >>
4)))) ^ (((((((0xf000000)) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((
0xf000000)) >> 16) >> 8))) - 1) & ((((((0xf000000
)) >> 16) >> 8)))) ^ ((((((0xf000000)) >> 16
) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((
(((((0xf000000)) >> 16) >> 8)) >> 2)) - 1) &
(((((((0xf000000)) >> 16) >> 8)) >> 2))) ^
(((((((0xf000000)) >> 16) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xf000000)) >>
16) >> 8)))) - 1) & (((((((0xf000000)) >> 16
) >> 8))))) ^ (((((((0xf000000)) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((0xf000000
)) >> 16))) - 1) & (((((0xf000000)) >> 16))))
^ (((((0xf000000)) >> 16))))) >> (4)) != 0) ? 4 +
((((u_long)((((((((((0xf000000)) >> 16)) >> 4)) -
1) & ((((((0xf000000)) >> 16)) >> 4))) ^ (((
(((0xf000000)) >> 16)) >> 4)))) >> (2)) != 0
) ? 2 + ((((u_long)(((((((((((0xf000000)) >> 16)) >>
4) >> 2)) - 1) & (((((((0xf000000)) >> 16)) >>
4) >> 2))) ^ (((((((0xf000000)) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
(((((((((((0xf000000)) >> 16)) >> 4))) - 1) &
(((((((0xf000000)) >> 16)) >> 4)))) ^ (((((((0xf000000
)) >> 16)) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)((((((((((0xf000000)) >> 16)))) - 1) &
((((((0xf000000)) >> 16))))) ^ ((((((0xf000000)) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0xf000000
)) >> 16))) >> 2)) - 1) & (((((((0xf000000)) >>
16))) >> 2))) ^ (((((((0xf000000)) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xf000000
)) >> 16))))) - 1) & (((((((0xf000000)) >> 16
)))))) ^ (((((((0xf000000)) >> 16))))))) >> (1)) !=
0) ? 1 : 0)))) : ((((u_long)((((((((0xf000000)))) - 1) &
((((0xf000000))))) ^ ((((0xf000000)))))) >> (8)) != 0)
? 8 + ((((u_long)(((((((((0xf000000))) >> 8)) - 1) &
(((((0xf000000))) >> 8))) ^ (((((0xf000000))) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)((((((((((0xf000000
))) >> 8) >> 4)) - 1) & ((((((0xf000000))) >>
8) >> 4))) ^ ((((((0xf000000))) >> 8) >> 4
)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0xf000000
))) >> 8) >> 4) >> 2)) - 1) & (((((((0xf000000
))) >> 8) >> 4) >> 2))) ^ (((((((0xf000000)
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)(((((((((((0xf000000))) >> 8) >>
4))) - 1) & (((((((0xf000000))) >> 8) >> 4))
)) ^ (((((((0xf000000))) >> 8) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0xf000000))) >>
8))) - 1) & ((((((0xf000000))) >> 8)))) ^ ((((((0xf000000
))) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)((((
(((((((0xf000000))) >> 8)) >> 2)) - 1) & ((((
(((0xf000000))) >> 8)) >> 2))) ^ (((((((0xf000000
))) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)(((((((((((0xf000000))) >> 8)))) - 1) &
(((((((0xf000000))) >> 8))))) ^ (((((((0xf000000))) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
(0xf000000))))) - 1) & (((((0xf000000)))))) ^ (((((0xf000000
))))))) >> (4)) != 0) ? 4 + ((((u_long)((((((((((0xf000000
)))) >> 4)) - 1) & ((((((0xf000000)))) >> 4))
) ^ ((((((0xf000000)))) >> 4)))) >> (2)) != 0) ? 2
+ ((((u_long)(((((((((((0xf000000)))) >> 4) >> 2
)) - 1) & (((((((0xf000000)))) >> 4) >> 2))) ^
(((((((0xf000000)))) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xf000000)))) >>
4))) - 1) & (((((((0xf000000)))) >> 4)))) ^ ((((((
(0xf000000)))) >> 4))))) >> (1)) != 0) ? 1 : 0)) :
((((u_long)((((((((((0xf000000)))))) - 1) & ((((((0xf000000
))))))) ^ ((((((0xf000000)))))))) >> (2)) != 0) ? 2 + (
(((u_long)(((((((((((0xf000000))))) >> 2)) - 1) & (
((((((0xf000000))))) >> 2))) ^ (((((((0xf000000))))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xf000000
))))))) - 1) & (((((((0xf000000)))))))) ^ (((((((0xf000000
))))))))) >> (1)) != 0) ? 1 : 0))))))) == 0) ? (void)0 :
__assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 5004, "(addr & ~PRESHIFT(RTW8180_PHYCFG_MAC_PHILIPS_ADDR_MASK)) == 0"
))
5004 ~PRESHIFT(RTW8180_PHYCFG_MAC_PHILIPS_ADDR_MASK)) == 0)(((addr & ~((((0xf000000)) & ((0xf000000))) >> (
(((u_long)(((((((0xf000000))) - 1) & (((0xf000000)))) ^ (
((0xf000000))))) >> (16)) != 0) ? 16 + ((((u_long)(((((
(((0xf000000)) >> 16)) - 1) & ((((0xf000000)) >>
16))) ^ ((((0xf000000)) >> 16)))) >> (8)) != 0) ?
8 + ((((u_long)(((((((((0xf000000)) >> 16) >> 8)
) - 1) & (((((0xf000000)) >> 16) >> 8))) ^ ((
(((0xf000000)) >> 16) >> 8)))) >> (4)) != 0
) ? 4 + ((((u_long)((((((((((0xf000000)) >> 16) >>
8) >> 4)) - 1) & ((((((0xf000000)) >> 16) >>
8) >> 4))) ^ ((((((0xf000000)) >> 16) >> 8
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
((((0xf000000)) >> 16) >> 8) >> 4) >>
2)) - 1) & (((((((0xf000000)) >> 16) >> 8) >>
4) >> 2))) ^ (((((((0xf000000)) >> 16) >> 8
) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)(((((((((((0xf000000)) >> 16) >> 8) >>
4))) - 1) & (((((((0xf000000)) >> 16) >> 8) >>
4)))) ^ (((((((0xf000000)) >> 16) >> 8) >>
4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((
0xf000000)) >> 16) >> 8))) - 1) & ((((((0xf000000
)) >> 16) >> 8)))) ^ ((((((0xf000000)) >> 16
) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)((((((
(((((0xf000000)) >> 16) >> 8)) >> 2)) - 1) &
(((((((0xf000000)) >> 16) >> 8)) >> 2))) ^
(((((((0xf000000)) >> 16) >> 8)) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xf000000)) >>
16) >> 8)))) - 1) & (((((((0xf000000)) >> 16
) >> 8))))) ^ (((((((0xf000000)) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)(((((((((0xf000000
)) >> 16))) - 1) & (((((0xf000000)) >> 16))))
^ (((((0xf000000)) >> 16))))) >> (4)) != 0) ? 4 +
((((u_long)((((((((((0xf000000)) >> 16)) >> 4)) -
1) & ((((((0xf000000)) >> 16)) >> 4))) ^ (((
(((0xf000000)) >> 16)) >> 4)))) >> (2)) != 0
) ? 2 + ((((u_long)(((((((((((0xf000000)) >> 16)) >>
4) >> 2)) - 1) & (((((((0xf000000)) >> 16)) >>
4) >> 2))) ^ (((((((0xf000000)) >> 16)) >>
4) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
(((((((((((0xf000000)) >> 16)) >> 4))) - 1) &
(((((((0xf000000)) >> 16)) >> 4)))) ^ (((((((0xf000000
)) >> 16)) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)((((((((((0xf000000)) >> 16)))) - 1) &
((((((0xf000000)) >> 16))))) ^ ((((((0xf000000)) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0xf000000
)) >> 16))) >> 2)) - 1) & (((((((0xf000000)) >>
16))) >> 2))) ^ (((((((0xf000000)) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xf000000
)) >> 16))))) - 1) & (((((((0xf000000)) >> 16
)))))) ^ (((((((0xf000000)) >> 16))))))) >> (1)) !=
0) ? 1 : 0)))) : ((((u_long)((((((((0xf000000)))) - 1) &
((((0xf000000))))) ^ ((((0xf000000)))))) >> (8)) != 0)
? 8 + ((((u_long)(((((((((0xf000000))) >> 8)) - 1) &
(((((0xf000000))) >> 8))) ^ (((((0xf000000))) >>
8)))) >> (4)) != 0) ? 4 + ((((u_long)((((((((((0xf000000
))) >> 8) >> 4)) - 1) & ((((((0xf000000))) >>
8) >> 4))) ^ ((((((0xf000000))) >> 8) >> 4
)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0xf000000
))) >> 8) >> 4) >> 2)) - 1) & (((((((0xf000000
))) >> 8) >> 4) >> 2))) ^ (((((((0xf000000)
)) >> 8) >> 4) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)(((((((((((0xf000000))) >> 8) >>
4))) - 1) & (((((((0xf000000))) >> 8) >> 4))
)) ^ (((((((0xf000000))) >> 8) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0xf000000))) >>
8))) - 1) & ((((((0xf000000))) >> 8)))) ^ ((((((0xf000000
))) >> 8))))) >> (2)) != 0) ? 2 + ((((u_long)((((
(((((((0xf000000))) >> 8)) >> 2)) - 1) & ((((
(((0xf000000))) >> 8)) >> 2))) ^ (((((((0xf000000
))) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)(((((((((((0xf000000))) >> 8)))) - 1) &
(((((((0xf000000))) >> 8))))) ^ (((((((0xf000000))) >>
8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((
(0xf000000))))) - 1) & (((((0xf000000)))))) ^ (((((0xf000000
))))))) >> (4)) != 0) ? 4 + ((((u_long)((((((((((0xf000000
)))) >> 4)) - 1) & ((((((0xf000000)))) >> 4))
) ^ ((((((0xf000000)))) >> 4)))) >> (2)) != 0) ? 2
+ ((((u_long)(((((((((((0xf000000)))) >> 4) >> 2
)) - 1) & (((((((0xf000000)))) >> 4) >> 2))) ^
(((((((0xf000000)))) >> 4) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xf000000)))) >>
4))) - 1) & (((((((0xf000000)))) >> 4)))) ^ ((((((
(0xf000000)))) >> 4))))) >> (1)) != 0) ? 1 : 0)) :
((((u_long)((((((((((0xf000000)))))) - 1) & ((((((0xf000000
))))))) ^ ((((((0xf000000)))))))) >> (2)) != 0) ? 2 + (
(((u_long)(((((((((((0xf000000))))) >> 2)) - 1) & (
((((((0xf000000))))) >> 2))) ^ (((((((0xf000000))))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xf000000
))))))) - 1) & (((((((0xf000000)))))))) ^ (((((((0xf000000
))))))))) >> (1)) != 0) ? 1 : 0))))))) == 0) ? (void)0 :
__assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 5004, "(addr & ~PRESHIFT(RTW8180_PHYCFG_MAC_PHILIPS_ADDR_MASK)) == 0"
))
;
5005 KASSERT((val &(((val & ~((((0xffffff)) & ((0xffffff))) >> (((
(u_long)(((((((0xffffff))) - 1) & (((0xffffff)))) ^ (((0xffffff
))))) >> (16)) != 0) ? 16 + ((((u_long)((((((((0xffffff
)) >> 16)) - 1) & ((((0xffffff)) >> 16))) ^ (
(((0xffffff)) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)(((((((((0xffffff)) >> 16) >> 8)) - 1) & (((
((0xffffff)) >> 16) >> 8))) ^ (((((0xffffff)) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
((((((0xffffff)) >> 16) >> 8) >> 4)) - 1) &
((((((0xffffff)) >> 16) >> 8) >> 4))) ^ ((
((((0xffffff)) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((0xffffff)) >> 16
) >> 8) >> 4) >> 2)) - 1) & (((((((0xffffff
)) >> 16) >> 8) >> 4) >> 2))) ^ (((((
((0xffffff)) >> 16) >> 8) >> 4) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xffffff
)) >> 16) >> 8) >> 4))) - 1) & (((((((0xffffff
)) >> 16) >> 8) >> 4)))) ^ (((((((0xffffff)
) >> 16) >> 8) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)((((((((((0xffffff)) >> 16) >>
8))) - 1) & ((((((0xffffff)) >> 16) >> 8))))
^ ((((((0xffffff)) >> 16) >> 8))))) >> (2)
) != 0) ? 2 + ((((u_long)(((((((((((0xffffff)) >> 16) >>
8)) >> 2)) - 1) & (((((((0xffffff)) >> 16) >>
8)) >> 2))) ^ (((((((0xffffff)) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
((((((((((0xffffff)) >> 16) >> 8)))) - 1) & (
((((((0xffffff)) >> 16) >> 8))))) ^ (((((((0xffffff
)) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0)
)) : ((((u_long)(((((((((0xffffff)) >> 16))) - 1) &
(((((0xffffff)) >> 16)))) ^ (((((0xffffff)) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)((((((((((0xffffff
)) >> 16)) >> 4)) - 1) & ((((((0xffffff)) >>
16)) >> 4))) ^ ((((((0xffffff)) >> 16)) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0xffffff
)) >> 16)) >> 4) >> 2)) - 1) & (((((((0xffffff
)) >> 16)) >> 4) >> 2))) ^ (((((((0xffffff)
) >> 16)) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)(((((((((((0xffffff)) >> 16)) >>
4))) - 1) & (((((((0xffffff)) >> 16)) >> 4))
)) ^ (((((((0xffffff)) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0xffffff)) >>
16)))) - 1) & ((((((0xffffff)) >> 16))))) ^ ((((((
0xffffff)) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0xffffff)) >> 16))) >> 2)) - 1) &
(((((((0xffffff)) >> 16))) >> 2))) ^ (((((((0xffffff
)) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)(((((((((((0xffffff)) >> 16))))) - 1) &
(((((((0xffffff)) >> 16)))))) ^ (((((((0xffffff)) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
(((0xffffff)))) - 1) & ((((0xffffff))))) ^ ((((0xffffff))
)))) >> (8)) != 0) ? 8 + ((((u_long)(((((((((0xffffff))
) >> 8)) - 1) & (((((0xffffff))) >> 8))) ^ ((
(((0xffffff))) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)((((((((((0xffffff))) >> 8) >> 4)) - 1) & ((
((((0xffffff))) >> 8) >> 4))) ^ ((((((0xffffff)))
>> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0xffffff))) >> 8) >> 4) >> 2)) -
1) & (((((((0xffffff))) >> 8) >> 4) >>
2))) ^ (((((((0xffffff))) >> 8) >> 4) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xffffff
))) >> 8) >> 4))) - 1) & (((((((0xffffff))) >>
8) >> 4)))) ^ (((((((0xffffff))) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0xffffff
))) >> 8))) - 1) & ((((((0xffffff))) >> 8))))
^ ((((((0xffffff))) >> 8))))) >> (2)) != 0) ? 2 +
((((u_long)(((((((((((0xffffff))) >> 8)) >> 2)) -
1) & (((((((0xffffff))) >> 8)) >> 2))) ^ (((
((((0xffffff))) >> 8)) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)(((((((((((0xffffff))) >> 8))))
- 1) & (((((((0xffffff))) >> 8))))) ^ (((((((0xffffff
))) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)(((((((((0xffffff))))) - 1) & (((((0xffffff)))))) ^ ((((
(0xffffff))))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((
(((0xffffff)))) >> 4)) - 1) & ((((((0xffffff)))) >>
4))) ^ ((((((0xffffff)))) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)(((((((((((0xffffff)))) >> 4) >>
2)) - 1) & (((((((0xffffff)))) >> 4) >> 2)))
^ (((((((0xffffff)))) >> 4) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xffffff)))) >>
4))) - 1) & (((((((0xffffff)))) >> 4)))) ^ (((((((
0xffffff)))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : (
(((u_long)((((((((((0xffffff)))))) - 1) & ((((((0xffffff)
)))))) ^ ((((((0xffffff)))))))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((0xffffff))))) >> 2)) - 1) & ((((
(((0xffffff))))) >> 2))) ^ (((((((0xffffff))))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xffffff
))))))) - 1) & (((((((0xffffff)))))))) ^ (((((((0xffffff)
)))))))) >> (1)) != 0) ? 1 : 0))))))) == 0) ? (void)0 :
__assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 5006, "(val & ~PRESHIFT(RTW8180_PHYCFG_MAC_PHILIPS_DATA_MASK)) == 0"
))
5006 ~PRESHIFT(RTW8180_PHYCFG_MAC_PHILIPS_DATA_MASK)) == 0)(((val & ~((((0xffffff)) & ((0xffffff))) >> (((
(u_long)(((((((0xffffff))) - 1) & (((0xffffff)))) ^ (((0xffffff
))))) >> (16)) != 0) ? 16 + ((((u_long)((((((((0xffffff
)) >> 16)) - 1) & ((((0xffffff)) >> 16))) ^ (
(((0xffffff)) >> 16)))) >> (8)) != 0) ? 8 + ((((u_long
)(((((((((0xffffff)) >> 16) >> 8)) - 1) & (((
((0xffffff)) >> 16) >> 8))) ^ (((((0xffffff)) >>
16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long)((((
((((((0xffffff)) >> 16) >> 8) >> 4)) - 1) &
((((((0xffffff)) >> 16) >> 8) >> 4))) ^ ((
((((0xffffff)) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)(((((((((((0xffffff)) >> 16
) >> 8) >> 4) >> 2)) - 1) & (((((((0xffffff
)) >> 16) >> 8) >> 4) >> 2))) ^ (((((
((0xffffff)) >> 16) >> 8) >> 4) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xffffff
)) >> 16) >> 8) >> 4))) - 1) & (((((((0xffffff
)) >> 16) >> 8) >> 4)))) ^ (((((((0xffffff)
) >> 16) >> 8) >> 4))))) >> (1)) != 0
) ? 1 : 0)) : ((((u_long)((((((((((0xffffff)) >> 16) >>
8))) - 1) & ((((((0xffffff)) >> 16) >> 8))))
^ ((((((0xffffff)) >> 16) >> 8))))) >> (2)
) != 0) ? 2 + ((((u_long)(((((((((((0xffffff)) >> 16) >>
8)) >> 2)) - 1) & (((((((0xffffff)) >> 16) >>
8)) >> 2))) ^ (((((((0xffffff)) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
((((((((((0xffffff)) >> 16) >> 8)))) - 1) & (
((((((0xffffff)) >> 16) >> 8))))) ^ (((((((0xffffff
)) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0)
)) : ((((u_long)(((((((((0xffffff)) >> 16))) - 1) &
(((((0xffffff)) >> 16)))) ^ (((((0xffffff)) >> 16
))))) >> (4)) != 0) ? 4 + ((((u_long)((((((((((0xffffff
)) >> 16)) >> 4)) - 1) & ((((((0xffffff)) >>
16)) >> 4))) ^ ((((((0xffffff)) >> 16)) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((((((0xffffff
)) >> 16)) >> 4) >> 2)) - 1) & (((((((0xffffff
)) >> 16)) >> 4) >> 2))) ^ (((((((0xffffff)
) >> 16)) >> 4) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)(((((((((((0xffffff)) >> 16)) >>
4))) - 1) & (((((((0xffffff)) >> 16)) >> 4))
)) ^ (((((((0xffffff)) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0xffffff)) >>
16)))) - 1) & ((((((0xffffff)) >> 16))))) ^ ((((((
0xffffff)) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0xffffff)) >> 16))) >> 2)) - 1) &
(((((((0xffffff)) >> 16))) >> 2))) ^ (((((((0xffffff
)) >> 16))) >> 2)))) >> (1)) != 0) ? 1 : 0)
: ((((u_long)(((((((((((0xffffff)) >> 16))))) - 1) &
(((((((0xffffff)) >> 16)))))) ^ (((((((0xffffff)) >>
16))))))) >> (1)) != 0) ? 1 : 0)))) : ((((u_long)(((((
(((0xffffff)))) - 1) & ((((0xffffff))))) ^ ((((0xffffff))
)))) >> (8)) != 0) ? 8 + ((((u_long)(((((((((0xffffff))
) >> 8)) - 1) & (((((0xffffff))) >> 8))) ^ ((
(((0xffffff))) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)((((((((((0xffffff))) >> 8) >> 4)) - 1) & ((
((((0xffffff))) >> 8) >> 4))) ^ ((((((0xffffff)))
>> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)(((((((((((0xffffff))) >> 8) >> 4) >> 2)) -
1) & (((((((0xffffff))) >> 8) >> 4) >>
2))) ^ (((((((0xffffff))) >> 8) >> 4) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xffffff
))) >> 8) >> 4))) - 1) & (((((((0xffffff))) >>
8) >> 4)))) ^ (((((((0xffffff))) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)((((((((((0xffffff
))) >> 8))) - 1) & ((((((0xffffff))) >> 8))))
^ ((((((0xffffff))) >> 8))))) >> (2)) != 0) ? 2 +
((((u_long)(((((((((((0xffffff))) >> 8)) >> 2)) -
1) & (((((((0xffffff))) >> 8)) >> 2))) ^ (((
((((0xffffff))) >> 8)) >> 2)))) >> (1)) != 0
) ? 1 : 0) : ((((u_long)(((((((((((0xffffff))) >> 8))))
- 1) & (((((((0xffffff))) >> 8))))) ^ (((((((0xffffff
))) >> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)(((((((((0xffffff))))) - 1) & (((((0xffffff)))))) ^ ((((
(0xffffff))))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((
(((0xffffff)))) >> 4)) - 1) & ((((((0xffffff)))) >>
4))) ^ ((((((0xffffff)))) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)(((((((((((0xffffff)))) >> 4) >>
2)) - 1) & (((((((0xffffff)))) >> 4) >> 2)))
^ (((((((0xffffff)))) >> 4) >> 2)))) >> (1
)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xffffff)))) >>
4))) - 1) & (((((((0xffffff)))) >> 4)))) ^ (((((((
0xffffff)))) >> 4))))) >> (1)) != 0) ? 1 : 0)) : (
(((u_long)((((((((((0xffffff)))))) - 1) & ((((((0xffffff)
)))))) ^ ((((((0xffffff)))))))) >> (2)) != 0) ? 2 + (((
(u_long)(((((((((((0xffffff))))) >> 2)) - 1) & ((((
(((0xffffff))))) >> 2))) ^ (((((((0xffffff))))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((((((((((0xffffff
))))))) - 1) & (((((((0xffffff)))))))) ^ (((((((0xffffff)
)))))))) >> (1)) != 0) ? 1 : 0))))))) == 0) ? (void)0 :
__assert("diagnostic ", "/usr/src/sys/dev/ic/rtw.c", 5006, "(val & ~PRESHIFT(RTW8180_PHYCFG_MAC_PHILIPS_DATA_MASK)) == 0"
))
;
5007
5008 reg = LSHIFT(addr, RTW8180_PHYCFG_MAC_PHILIPS_ADDR_MASK)((addr) << ((((u_long)((((((0xf000000)) - 1) & ((0xf000000
))) ^ ((0xf000000)))) >> (16)) != 0) ? 16 + ((((u_long)
(((((((0xf000000) >> 16)) - 1) & (((0xf000000) >>
16))) ^ (((0xf000000) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0xf000000) >> 16) >> 8)) - 1
) & ((((0xf000000) >> 16) >> 8))) ^ ((((0xf000000
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xf000000) >> 16) >> 8) >> 4)) - 1
) & (((((0xf000000) >> 16) >> 8) >> 4))
) ^ (((((0xf000000) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
) >> 8) >> 4) >> 2)) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xf000000) >> 16) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16) >> 8) >> 4))) - 1) & ((((((0xf000000
) >> 16) >> 8) >> 4)))) ^ ((((((0xf000000) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xf000000) >> 16) >> 8)))
- 1) & (((((0xf000000) >> 16) >> 8)))) ^ (((
((0xf000000) >> 16) >> 8))))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xf000000) >> 16) >> 8
)) >> 2)) - 1) & ((((((0xf000000) >> 16) >>
8)) >> 2))) ^ ((((((0xf000000) >> 16) >> 8
)) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(
(((((((((0xf000000) >> 16) >> 8)))) - 1) & ((
((((0xf000000) >> 16) >> 8))))) ^ ((((((0xf000000
) >> 16) >> 8)))))) >> (1)) != 0) ? 1 : 0))
) : ((((u_long)((((((((0xf000000) >> 16))) - 1) & (
(((0xf000000) >> 16)))) ^ ((((0xf000000) >> 16)))
)) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000) >>
16)) >> 4)) - 1) & (((((0xf000000) >> 16)) >>
4))) ^ (((((0xf000000) >> 16)) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000) >> 16
)) >> 4) >> 2)) - 1) & ((((((0xf000000) >>
16)) >> 4) >> 2))) ^ ((((((0xf000000) >> 16
)) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0xf000000) >> 16)) >> 4))) - 1
) & ((((((0xf000000) >> 16)) >> 4)))) ^ (((((
(0xf000000) >> 16)) >> 4))))) >> (1)) != 0)
? 1 : 0)) : ((((u_long)(((((((((0xf000000) >> 16)))) -
1) & (((((0xf000000) >> 16))))) ^ (((((0xf000000) >>
16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0xf000000
) >> 16))) >> 2)) - 1) & ((((((0xf000000) >>
16))) >> 2))) ^ ((((((0xf000000) >> 16))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
) >> 16))))) - 1) & ((((((0xf000000) >> 16)))
))) ^ ((((((0xf000000) >> 16))))))) >> (1)) != 0)
? 1 : 0)))) : ((((u_long)(((((((0xf000000))) - 1) & (((0xf000000
)))) ^ (((0xf000000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0xf000000)) >> 8)) - 1) & ((((0xf000000)) >>
8))) ^ ((((0xf000000)) >> 8)))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0xf000000)) >> 8) >> 4)) -
1) & (((((0xf000000)) >> 8) >> 4))) ^ (((((0xf000000
)) >> 8) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long
)((((((((((0xf000000)) >> 8) >> 4) >> 2)) -
1) & ((((((0xf000000)) >> 8) >> 4) >> 2
))) ^ ((((((0xf000000)) >> 8) >> 4) >> 2)))
) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000
)) >> 8) >> 4))) - 1) & ((((((0xf000000)) >>
8) >> 4)))) ^ ((((((0xf000000)) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xf000000
)) >> 8))) - 1) & (((((0xf000000)) >> 8)))) ^
(((((0xf000000)) >> 8))))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000)) >> 8)) >> 2)) - 1
) & ((((((0xf000000)) >> 8)) >> 2))) ^ ((((((
0xf000000)) >> 8)) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000)) >> 8)))) - 1
) & ((((((0xf000000)) >> 8))))) ^ ((((((0xf000000))
>> 8)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long
)((((((((0xf000000)))) - 1) & ((((0xf000000))))) ^ ((((0xf000000
)))))) >> (4)) != 0) ? 4 + ((((u_long)(((((((((0xf000000
))) >> 4)) - 1) & (((((0xf000000))) >> 4))) ^
(((((0xf000000))) >> 4)))) >> (2)) != 0) ? 2 + (
(((u_long)((((((((((0xf000000))) >> 4) >> 2)) - 1
) & ((((((0xf000000))) >> 4) >> 2))) ^ ((((((
0xf000000))) >> 4) >> 2)))) >> (1)) != 0) ?
1 : 0) : ((((u_long)((((((((((0xf000000))) >> 4))) - 1
) & ((((((0xf000000))) >> 4)))) ^ ((((((0xf000000))
) >> 4))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)
(((((((((0xf000000))))) - 1) & (((((0xf000000)))))) ^ (((
((0xf000000))))))) >> (2)) != 0) ? 2 + ((((u_long)(((((
(((((0xf000000)))) >> 2)) - 1) & ((((((0xf000000)))
) >> 2))) ^ ((((((0xf000000)))) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xf000000)))))) -
1) & ((((((0xf000000))))))) ^ ((((((0xf000000)))))))) >>
(1)) != 0) ? 1 : 0))))))
|
5009 LSHIFT(val, RTW8180_PHYCFG_MAC_PHILIPS_DATA_MASK)((val) << ((((u_long)((((((0xffffff)) - 1) & ((0xffffff
))) ^ ((0xffffff)))) >> (16)) != 0) ? 16 + ((((u_long)(
((((((0xffffff) >> 16)) - 1) & (((0xffffff) >>
16))) ^ (((0xffffff) >> 16)))) >> (8)) != 0) ? 8
+ ((((u_long)((((((((0xffffff) >> 16) >> 8)) - 1
) & ((((0xffffff) >> 16) >> 8))) ^ ((((0xffffff
) >> 16) >> 8)))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xffffff) >> 16) >> 8) >> 4)) - 1
) & (((((0xffffff) >> 16) >> 8) >> 4)))
^ (((((0xffffff) >> 16) >> 8) >> 4)))) >>
(2)) != 0) ? 2 + ((((u_long)((((((((((0xffffff) >> 16)
>> 8) >> 4) >> 2)) - 1) & ((((((0xffffff
) >> 16) >> 8) >> 4) >> 2))) ^ ((((((
0xffffff) >> 16) >> 8) >> 4) >> 2))))
>> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffffff
) >> 16) >> 8) >> 4))) - 1) & ((((((0xffffff
) >> 16) >> 8) >> 4)))) ^ ((((((0xffffff) >>
16) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)
) : ((((u_long)(((((((((0xffffff) >> 16) >> 8))) -
1) & (((((0xffffff) >> 16) >> 8)))) ^ (((((0xffffff
) >> 16) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xffffff) >> 16) >> 8)) >>
2)) - 1) & ((((((0xffffff) >> 16) >> 8)) >>
2))) ^ ((((((0xffffff) >> 16) >> 8)) >> 2)
))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffffff
) >> 16) >> 8)))) - 1) & ((((((0xffffff) >>
16) >> 8))))) ^ ((((((0xffffff) >> 16) >> 8
)))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xffffff
) >> 16))) - 1) & ((((0xffffff) >> 16)))) ^ (
(((0xffffff) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long
)(((((((((0xffffff) >> 16)) >> 4)) - 1) & (((
((0xffffff) >> 16)) >> 4))) ^ (((((0xffffff) >>
16)) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((
(((((((0xffffff) >> 16)) >> 4) >> 2)) - 1) &
((((((0xffffff) >> 16)) >> 4) >> 2))) ^ ((
((((0xffffff) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffffff) >>
16)) >> 4))) - 1) & ((((((0xffffff) >> 16)) >>
4)))) ^ ((((((0xffffff) >> 16)) >> 4))))) >>
(1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xffffff) >>
16)))) - 1) & (((((0xffffff) >> 16))))) ^ (((((0xffffff
) >> 16)))))) >> (2)) != 0) ? 2 + ((((u_long)((((
((((((0xffffff) >> 16))) >> 2)) - 1) & ((((((
0xffffff) >> 16))) >> 2))) ^ ((((((0xffffff) >>
16))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long
)((((((((((0xffffff) >> 16))))) - 1) & ((((((0xffffff
) >> 16)))))) ^ ((((((0xffffff) >> 16))))))) >>
(1)) != 0) ? 1 : 0)))) : ((((u_long)(((((((0xffffff))) - 1) &
(((0xffffff)))) ^ (((0xffffff))))) >> (8)) != 0) ? 8 +
((((u_long)((((((((0xffffff)) >> 8)) - 1) & ((((0xffffff
)) >> 8))) ^ ((((0xffffff)) >> 8)))) >> (4)
) != 0) ? 4 + ((((u_long)(((((((((0xffffff)) >> 8) >>
4)) - 1) & (((((0xffffff)) >> 8) >> 4))) ^ (
((((0xffffff)) >> 8) >> 4)))) >> (2)) != 0)
? 2 + ((((u_long)((((((((((0xffffff)) >> 8) >> 4
) >> 2)) - 1) & ((((((0xffffff)) >> 8) >>
4) >> 2))) ^ ((((((0xffffff)) >> 8) >> 4) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffffff
)) >> 8) >> 4))) - 1) & ((((((0xffffff)) >>
8) >> 4)))) ^ ((((((0xffffff)) >> 8) >> 4)
)))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xffffff
)) >> 8))) - 1) & (((((0xffffff)) >> 8)))) ^ (
((((0xffffff)) >> 8))))) >> (2)) != 0) ? 2 + ((((
u_long)((((((((((0xffffff)) >> 8)) >> 2)) - 1) &
((((((0xffffff)) >> 8)) >> 2))) ^ ((((((0xffffff
)) >> 8)) >> 2)))) >> (1)) != 0) ? 1 : 0) :
((((u_long)((((((((((0xffffff)) >> 8)))) - 1) & ((
((((0xffffff)) >> 8))))) ^ ((((((0xffffff)) >> 8)
))))) >> (1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0xffffff
)))) - 1) & ((((0xffffff))))) ^ ((((0xffffff)))))) >>
(4)) != 0) ? 4 + ((((u_long)(((((((((0xffffff))) >> 4)
) - 1) & (((((0xffffff))) >> 4))) ^ (((((0xffffff))
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0xffffff))) >> 4) >> 2)) - 1) & ((((((0xffffff
))) >> 4) >> 2))) ^ ((((((0xffffff))) >> 4)
>> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)(((
(((((((0xffffff))) >> 4))) - 1) & ((((((0xffffff)))
>> 4)))) ^ ((((((0xffffff))) >> 4))))) >> (
1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0xffffff))))) - 1) &
(((((0xffffff)))))) ^ (((((0xffffff))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0xffffff)))) >> 2)) - 1) &
((((((0xffffff)))) >> 2))) ^ ((((((0xffffff)))) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0xffffff
)))))) - 1) & ((((((0xffffff))))))) ^ ((((((0xffffff)))))
))) >> (1)) != 0) ? 1 : 0))))))
;
5010 }
5011
5012 switch (sc->sc_rfchipid) {
5013 case RTW_RFCHIPID_GCT0x05:
5014 case RTW_RFCHIPID_MAXIM28200x04:
5015 case RTW_RFCHIPID_RFMD29480x02:
5016 reg |= RTW8180_PHYCFG_MAC_RFTYPE_RFMD((1) << ((((u_long)((((((0x30000000)) - 1) & ((0x30000000
))) ^ ((0x30000000)))) >> (16)) != 0) ? 16 + ((((u_long
)(((((((0x30000000) >> 16)) - 1) & (((0x30000000) >>
16))) ^ (((0x30000000) >> 16)))) >> (8)) != 0) ?
8 + ((((u_long)((((((((0x30000000) >> 16) >> 8))
- 1) & ((((0x30000000) >> 16) >> 8))) ^ ((((
0x30000000) >> 16) >> 8)))) >> (4)) != 0) ?
4 + ((((u_long)(((((((((0x30000000) >> 16) >> 8)
>> 4)) - 1) & (((((0x30000000) >> 16) >>
8) >> 4))) ^ (((((0x30000000) >> 16) >> 8)
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0x30000000) >> 16) >> 8) >> 4) >> 2
)) - 1) & ((((((0x30000000) >> 16) >> 8) >>
4) >> 2))) ^ ((((((0x30000000) >> 16) >> 8
) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x30000000) >> 16) >> 8) >>
4))) - 1) & ((((((0x30000000) >> 16) >> 8) >>
4)))) ^ ((((((0x30000000) >> 16) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x30000000
) >> 16) >> 8))) - 1) & (((((0x30000000) >>
16) >> 8)))) ^ (((((0x30000000) >> 16) >> 8
))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x30000000
) >> 16) >> 8)) >> 2)) - 1) & ((((((0x30000000
) >> 16) >> 8)) >> 2))) ^ ((((((0x30000000)
>> 16) >> 8)) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x30000000) >> 16) >>
8)))) - 1) & ((((((0x30000000) >> 16) >> 8))
))) ^ ((((((0x30000000) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x30000000) >>
16))) - 1) & ((((0x30000000) >> 16)))) ^ ((((0x30000000
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0x30000000) >> 16)) >> 4)) - 1) & (((((0x30000000
) >> 16)) >> 4))) ^ (((((0x30000000) >> 16)
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0x30000000) >> 16)) >> 4) >> 2)) - 1) &
((((((0x30000000) >> 16)) >> 4) >> 2))) ^ (
(((((0x30000000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x30000000) >>
16)) >> 4))) - 1) & ((((((0x30000000) >> 16)
) >> 4)))) ^ ((((((0x30000000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x30000000
) >> 16)))) - 1) & (((((0x30000000) >> 16))))
) ^ (((((0x30000000) >> 16)))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x30000000) >> 16))) >> 2
)) - 1) & ((((((0x30000000) >> 16))) >> 2))) ^
((((((0x30000000) >> 16))) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0x30000000) >> 16
))))) - 1) & ((((((0x30000000) >> 16)))))) ^ ((((((
0x30000000) >> 16))))))) >> (1)) != 0) ? 1 : 0)))
) : ((((u_long)(((((((0x30000000))) - 1) & (((0x30000000)
))) ^ (((0x30000000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x30000000)) >> 8)) - 1) & ((((0x30000000)
) >> 8))) ^ ((((0x30000000)) >> 8)))) >> (4
)) != 0) ? 4 + ((((u_long)(((((((((0x30000000)) >> 8) >>
4)) - 1) & (((((0x30000000)) >> 8) >> 4))) ^
(((((0x30000000)) >> 8) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x30000000)) >> 8) >>
4) >> 2)) - 1) & ((((((0x30000000)) >> 8) >>
4) >> 2))) ^ ((((((0x30000000)) >> 8) >> 4
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
((((((((0x30000000)) >> 8) >> 4))) - 1) & (((
(((0x30000000)) >> 8) >> 4)))) ^ ((((((0x30000000
)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)) :
((((u_long)(((((((((0x30000000)) >> 8))) - 1) & ((
(((0x30000000)) >> 8)))) ^ (((((0x30000000)) >> 8
))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x30000000
)) >> 8)) >> 2)) - 1) & ((((((0x30000000)) >>
8)) >> 2))) ^ ((((((0x30000000)) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x30000000
)) >> 8)))) - 1) & ((((((0x30000000)) >> 8)))
)) ^ ((((((0x30000000)) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0x30000000)))) - 1) & ((((
0x30000000))))) ^ ((((0x30000000)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x30000000))) >> 4)) - 1) & (
((((0x30000000))) >> 4))) ^ (((((0x30000000))) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x30000000
))) >> 4) >> 2)) - 1) & ((((((0x30000000))) >>
4) >> 2))) ^ ((((((0x30000000))) >> 4) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x30000000
))) >> 4))) - 1) & ((((((0x30000000))) >> 4))
)) ^ ((((((0x30000000))) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x30000000))))) - 1) & (((
((0x30000000)))))) ^ (((((0x30000000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0x30000000)))) >> 2)) - 1)
& ((((((0x30000000)))) >> 2))) ^ ((((((0x30000000)
))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x30000000)))))) - 1) & ((((((0x30000000)))))))
^ ((((((0x30000000)))))))) >> (1)) != 0) ? 1 : 0))))))
;
5017 break;
5018 case RTW_RFCHIPID_INTERSIL0x01:
5019 reg |= RTW8180_PHYCFG_MAC_RFTYPE_INTERSIL((0) << ((((u_long)((((((0x30000000)) - 1) & ((0x30000000
))) ^ ((0x30000000)))) >> (16)) != 0) ? 16 + ((((u_long
)(((((((0x30000000) >> 16)) - 1) & (((0x30000000) >>
16))) ^ (((0x30000000) >> 16)))) >> (8)) != 0) ?
8 + ((((u_long)((((((((0x30000000) >> 16) >> 8))
- 1) & ((((0x30000000) >> 16) >> 8))) ^ ((((
0x30000000) >> 16) >> 8)))) >> (4)) != 0) ?
4 + ((((u_long)(((((((((0x30000000) >> 16) >> 8)
>> 4)) - 1) & (((((0x30000000) >> 16) >>
8) >> 4))) ^ (((((0x30000000) >> 16) >> 8)
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0x30000000) >> 16) >> 8) >> 4) >> 2
)) - 1) & ((((((0x30000000) >> 16) >> 8) >>
4) >> 2))) ^ ((((((0x30000000) >> 16) >> 8
) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x30000000) >> 16) >> 8) >>
4))) - 1) & ((((((0x30000000) >> 16) >> 8) >>
4)))) ^ ((((((0x30000000) >> 16) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x30000000
) >> 16) >> 8))) - 1) & (((((0x30000000) >>
16) >> 8)))) ^ (((((0x30000000) >> 16) >> 8
))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x30000000
) >> 16) >> 8)) >> 2)) - 1) & ((((((0x30000000
) >> 16) >> 8)) >> 2))) ^ ((((((0x30000000)
>> 16) >> 8)) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x30000000) >> 16) >>
8)))) - 1) & ((((((0x30000000) >> 16) >> 8))
))) ^ ((((((0x30000000) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x30000000) >>
16))) - 1) & ((((0x30000000) >> 16)))) ^ ((((0x30000000
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0x30000000) >> 16)) >> 4)) - 1) & (((((0x30000000
) >> 16)) >> 4))) ^ (((((0x30000000) >> 16)
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0x30000000) >> 16)) >> 4) >> 2)) - 1) &
((((((0x30000000) >> 16)) >> 4) >> 2))) ^ (
(((((0x30000000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x30000000) >>
16)) >> 4))) - 1) & ((((((0x30000000) >> 16)
) >> 4)))) ^ ((((((0x30000000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x30000000
) >> 16)))) - 1) & (((((0x30000000) >> 16))))
) ^ (((((0x30000000) >> 16)))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x30000000) >> 16))) >> 2
)) - 1) & ((((((0x30000000) >> 16))) >> 2))) ^
((((((0x30000000) >> 16))) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0x30000000) >> 16
))))) - 1) & ((((((0x30000000) >> 16)))))) ^ ((((((
0x30000000) >> 16))))))) >> (1)) != 0) ? 1 : 0)))
) : ((((u_long)(((((((0x30000000))) - 1) & (((0x30000000)
))) ^ (((0x30000000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x30000000)) >> 8)) - 1) & ((((0x30000000)
) >> 8))) ^ ((((0x30000000)) >> 8)))) >> (4
)) != 0) ? 4 + ((((u_long)(((((((((0x30000000)) >> 8) >>
4)) - 1) & (((((0x30000000)) >> 8) >> 4))) ^
(((((0x30000000)) >> 8) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x30000000)) >> 8) >>
4) >> 2)) - 1) & ((((((0x30000000)) >> 8) >>
4) >> 2))) ^ ((((((0x30000000)) >> 8) >> 4
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
((((((((0x30000000)) >> 8) >> 4))) - 1) & (((
(((0x30000000)) >> 8) >> 4)))) ^ ((((((0x30000000
)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)) :
((((u_long)(((((((((0x30000000)) >> 8))) - 1) & ((
(((0x30000000)) >> 8)))) ^ (((((0x30000000)) >> 8
))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x30000000
)) >> 8)) >> 2)) - 1) & ((((((0x30000000)) >>
8)) >> 2))) ^ ((((((0x30000000)) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x30000000
)) >> 8)))) - 1) & ((((((0x30000000)) >> 8)))
)) ^ ((((((0x30000000)) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0x30000000)))) - 1) & ((((
0x30000000))))) ^ ((((0x30000000)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x30000000))) >> 4)) - 1) & (
((((0x30000000))) >> 4))) ^ (((((0x30000000))) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x30000000
))) >> 4) >> 2)) - 1) & ((((((0x30000000))) >>
4) >> 2))) ^ ((((((0x30000000))) >> 4) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x30000000
))) >> 4))) - 1) & ((((((0x30000000))) >> 4))
)) ^ ((((((0x30000000))) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x30000000))))) - 1) & (((
((0x30000000)))))) ^ (((((0x30000000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0x30000000)))) >> 2)) - 1)
& ((((((0x30000000)))) >> 2))) ^ ((((((0x30000000)
))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x30000000)))))) - 1) & ((((((0x30000000)))))))
^ ((((((0x30000000)))))))) >> (1)) != 0) ? 1 : 0))))))
;
5020 break;
5021 case RTW_RFCHIPID_PHILIPS0x03:
5022 reg |= RTW8180_PHYCFG_MAC_RFTYPE_PHILIPS((3) << ((((u_long)((((((0x30000000)) - 1) & ((0x30000000
))) ^ ((0x30000000)))) >> (16)) != 0) ? 16 + ((((u_long
)(((((((0x30000000) >> 16)) - 1) & (((0x30000000) >>
16))) ^ (((0x30000000) >> 16)))) >> (8)) != 0) ?
8 + ((((u_long)((((((((0x30000000) >> 16) >> 8))
- 1) & ((((0x30000000) >> 16) >> 8))) ^ ((((
0x30000000) >> 16) >> 8)))) >> (4)) != 0) ?
4 + ((((u_long)(((((((((0x30000000) >> 16) >> 8)
>> 4)) - 1) & (((((0x30000000) >> 16) >>
8) >> 4))) ^ (((((0x30000000) >> 16) >> 8)
>> 4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((
((0x30000000) >> 16) >> 8) >> 4) >> 2
)) - 1) & ((((((0x30000000) >> 16) >> 8) >>
4) >> 2))) ^ ((((((0x30000000) >> 16) >> 8
) >> 4) >> 2)))) >> (1)) != 0) ? 1 : 0) : (
(((u_long)((((((((((0x30000000) >> 16) >> 8) >>
4))) - 1) & ((((((0x30000000) >> 16) >> 8) >>
4)))) ^ ((((((0x30000000) >> 16) >> 8) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x30000000
) >> 16) >> 8))) - 1) & (((((0x30000000) >>
16) >> 8)))) ^ (((((0x30000000) >> 16) >> 8
))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x30000000
) >> 16) >> 8)) >> 2)) - 1) & ((((((0x30000000
) >> 16) >> 8)) >> 2))) ^ ((((((0x30000000)
>> 16) >> 8)) >> 2)))) >> (1)) != 0)
? 1 : 0) : ((((u_long)((((((((((0x30000000) >> 16) >>
8)))) - 1) & ((((((0x30000000) >> 16) >> 8))
))) ^ ((((((0x30000000) >> 16) >> 8)))))) >>
(1)) != 0) ? 1 : 0))) : ((((u_long)((((((((0x30000000) >>
16))) - 1) & ((((0x30000000) >> 16)))) ^ ((((0x30000000
) >> 16))))) >> (4)) != 0) ? 4 + ((((u_long)(((((
((((0x30000000) >> 16)) >> 4)) - 1) & (((((0x30000000
) >> 16)) >> 4))) ^ (((((0x30000000) >> 16)
) >> 4)))) >> (2)) != 0) ? 2 + ((((u_long)(((((((
(((0x30000000) >> 16)) >> 4) >> 2)) - 1) &
((((((0x30000000) >> 16)) >> 4) >> 2))) ^ (
(((((0x30000000) >> 16)) >> 4) >> 2)))) >>
(1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x30000000) >>
16)) >> 4))) - 1) & ((((((0x30000000) >> 16)
) >> 4)))) ^ ((((((0x30000000) >> 16)) >> 4
))))) >> (1)) != 0) ? 1 : 0)) : ((((u_long)(((((((((0x30000000
) >> 16)))) - 1) & (((((0x30000000) >> 16))))
) ^ (((((0x30000000) >> 16)))))) >> (2)) != 0) ? 2
+ ((((u_long)((((((((((0x30000000) >> 16))) >> 2
)) - 1) & ((((((0x30000000) >> 16))) >> 2))) ^
((((((0x30000000) >> 16))) >> 2)))) >> (1)
) != 0) ? 1 : 0) : ((((u_long)((((((((((0x30000000) >> 16
))))) - 1) & ((((((0x30000000) >> 16)))))) ^ ((((((
0x30000000) >> 16))))))) >> (1)) != 0) ? 1 : 0)))
) : ((((u_long)(((((((0x30000000))) - 1) & (((0x30000000)
))) ^ (((0x30000000))))) >> (8)) != 0) ? 8 + ((((u_long
)((((((((0x30000000)) >> 8)) - 1) & ((((0x30000000)
) >> 8))) ^ ((((0x30000000)) >> 8)))) >> (4
)) != 0) ? 4 + ((((u_long)(((((((((0x30000000)) >> 8) >>
4)) - 1) & (((((0x30000000)) >> 8) >> 4))) ^
(((((0x30000000)) >> 8) >> 4)))) >> (2)) !=
0) ? 2 + ((((u_long)((((((((((0x30000000)) >> 8) >>
4) >> 2)) - 1) & ((((((0x30000000)) >> 8) >>
4) >> 2))) ^ ((((((0x30000000)) >> 8) >> 4
) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((
((((((((0x30000000)) >> 8) >> 4))) - 1) & (((
(((0x30000000)) >> 8) >> 4)))) ^ ((((((0x30000000
)) >> 8) >> 4))))) >> (1)) != 0) ? 1 : 0)) :
((((u_long)(((((((((0x30000000)) >> 8))) - 1) & ((
(((0x30000000)) >> 8)))) ^ (((((0x30000000)) >> 8
))))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x30000000
)) >> 8)) >> 2)) - 1) & ((((((0x30000000)) >>
8)) >> 2))) ^ ((((((0x30000000)) >> 8)) >>
2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x30000000
)) >> 8)))) - 1) & ((((((0x30000000)) >> 8)))
)) ^ ((((((0x30000000)) >> 8)))))) >> (1)) != 0) ?
1 : 0))) : ((((u_long)((((((((0x30000000)))) - 1) & ((((
0x30000000))))) ^ ((((0x30000000)))))) >> (4)) != 0) ? 4
+ ((((u_long)(((((((((0x30000000))) >> 4)) - 1) & (
((((0x30000000))) >> 4))) ^ (((((0x30000000))) >>
4)))) >> (2)) != 0) ? 2 + ((((u_long)((((((((((0x30000000
))) >> 4) >> 2)) - 1) & ((((((0x30000000))) >>
4) >> 2))) ^ ((((((0x30000000))) >> 4) >> 2
)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)((((((((((0x30000000
))) >> 4))) - 1) & ((((((0x30000000))) >> 4))
)) ^ ((((((0x30000000))) >> 4))))) >> (1)) != 0) ?
1 : 0)) : ((((u_long)(((((((((0x30000000))))) - 1) & (((
((0x30000000)))))) ^ (((((0x30000000))))))) >> (2)) != 0
) ? 2 + ((((u_long)((((((((((0x30000000)))) >> 2)) - 1)
& ((((((0x30000000)))) >> 2))) ^ ((((((0x30000000)
))) >> 2)))) >> (1)) != 0) ? 1 : 0) : ((((u_long)
((((((((((0x30000000)))))) - 1) & ((((((0x30000000)))))))
^ ((((((0x30000000)))))))) >> (1)) != 0) ? 1 : 0))))))
;
5023 break;
5024 default:
5025 printf("%s: unknown rfchipid %d\n", __func__, sc->sc_rfchipid);
5026 return -1;
5027 }
5028
5029 return rtw_rf_macbangbits(&sc->sc_regs, reg);
5030}
5031
5032
5033u_int8_t
5034rtw_read8(void *arg, u_int32_t off)
5035{
5036 struct rtw_regs *regs = (struct rtw_regs *)arg;
5037 return (bus_space_read_1(regs->r_bt, regs->r_bh, off)((regs->r_bt)->read_1((regs->r_bh), (off))));
5038}
5039
5040u_int16_t
5041rtw_read16(void *arg, u_int32_t off)
5042{
5043 struct rtw_regs *regs = (struct rtw_regs *)arg;
5044 return (bus_space_read_2(regs->r_bt, regs->r_bh, off)((regs->r_bt)->read_2((regs->r_bh), (off))));
5045}
5046
5047u_int32_t
5048rtw_read32(void *arg, u_int32_t off)
5049{
5050 struct rtw_regs *regs = (struct rtw_regs *)arg;
5051 return (bus_space_read_4(regs->r_bt, regs->r_bh, off)((regs->r_bt)->read_4((regs->r_bh), (off))));
5052}
5053
5054void
5055rtw_write8(void *arg, u_int32_t off, u_int8_t val)
5056{
5057 struct rtw_regs *regs = (struct rtw_regs *)arg;
5058 bus_space_write_1(regs->r_bt, regs->r_bh, off, val)((regs->r_bt)->write_1((regs->r_bh), (off), (val)));
5059}
5060
5061void
5062rtw_write16(void *arg, u_int32_t off, u_int16_t val)
5063{
5064 struct rtw_regs *regs = (struct rtw_regs *)arg;
5065 bus_space_write_2(regs->r_bt, regs->r_bh, off, val)((regs->r_bt)->write_2((regs->r_bh), (off), (val)));
5066}
5067
5068void
5069rtw_write32(void *arg, u_int32_t off, u_int32_t val)
5070{
5071 struct rtw_regs *regs = (struct rtw_regs *)arg;
5072 bus_space_write_4(regs->r_bt, regs->r_bh, off, val)((regs->r_bt)->write_4((regs->r_bh), (off), (val)));
5073}
5074
5075void
5076rtw_barrier(void *arg, u_int32_t reg0, u_int32_t reg1, int flags)
5077{
5078 struct rtw_regs *regs = (struct rtw_regs *)arg;
5079 bus_space_barrier(regs->r_bt, regs->r_bh, MIN(reg0, reg1)(((reg0)<(reg1))?(reg0):(reg1)),
5080 MAX(reg0, reg1)(((reg0)>(reg1))?(reg0):(reg1)) - MIN(reg0, reg1)(((reg0)<(reg1))?(reg0):(reg1)) + 4, flags);
5081}