FreeBSD kernel ATH device code
ar5416_spectral.c
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: ISC
3 *
4 * Copyright (c) 2012 Qualcomm Atheros, All Rights Reserved.
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 *
18 * $FreeBSD$
19 */
20#include "opt_ah.h"
21
22#include "ah.h"
23#include "ah_internal.h"
24#include "ah_devid.h"
25#include "ah_desc.h" /* NB: for HAL_PHYERR* */
26
27#include "ar5416/ar5416.h"
28#include "ar5416/ar5416reg.h"
29#include "ar5416/ar5416phy.h"
30
31/*
32 * Default AR9280 spectral scan parameters
33 */
34#define AR5416_SPECTRAL_SCAN_ENA 0
35#define AR5416_SPECTRAL_SCAN_ACTIVE 0
36#define AR5416_SPECTRAL_SCAN_FFT_PERIOD 8
37#define AR5416_SPECTRAL_SCAN_PERIOD 1
38#define AR5416_SPECTRAL_SCAN_COUNT 16 //used to be 128
39#define AR5416_SPECTRAL_SCAN_SHORT_REPEAT 1
40
41/* constants */
42#define MAX_RADAR_RSSI_THRESH 0x3f
43#define MAX_RADAR_HEIGHT 0x3f
44#define ENABLE_ALL_PHYERR 0xffffffff
45
46static void ar5416DisableRadar(struct ath_hal *ah);
47static void ar5416PrepSpectralScan(struct ath_hal *ah);
48
49static void
51{
52 uint32_t val;
53
54 // Enable radar FFT
55 val = OS_REG_READ(ah, AR_PHY_RADAR_0);
57
58 // set radar detect thresholds to max to effectively disable radar
59 val &= ~AR_PHY_RADAR_0_RRSSI;
61
62 val &= ~AR_PHY_RADAR_0_HEIGHT;
64
65 val &= ~(AR_PHY_RADAR_0_ENA);
67
68 // disable extension radar detect
71
72 val = OS_REG_READ(ah, AR_RX_FILTER);
73 val |= (1<<13);
74 OS_REG_WRITE(ah, AR_RX_FILTER, val);
75}
76
77static void
79{
80
83}
84
85void
87{
88 uint32_t val;
89
91
93
95 val &= ~AR_PHY_SPECTRAL_SCAN_FFT_PERIOD;
97 }
98
100 val &= ~AR_PHY_SPECTRAL_SCAN_PERIOD;
102 }
103
105 val &= ~AR_PHY_SPECTRAL_SCAN_PERIOD;
107 }
108
109 /* This section is different for Kiwi and Merlin */
110 if (AR_SREV_MERLIN(ah) ) {
112 val &= ~AR_PHY_SPECTRAL_SCAN_COUNT;
114 }
115
116 if (ss->ss_short_report == AH_TRUE) {
118 } else if (ss->ss_short_report != HAL_SPECTRAL_PARAM_NOVAL) {
119 val &= ~AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT;
120 }
121 } else {
123 /*
124 * In Merlin, for continuous scan, scan_count = 128.
125 * In case of Kiwi, this value should be 0
126 */
127 if (ss->ss_count == 128)
128 ss->ss_count = 0;
129 val &= ~AR_PHY_SPECTRAL_SCAN_COUNT_KIWI;
131 }
132
133 if (ss->ss_short_report == AH_TRUE) {
135 } else if (ss->ss_short_report != HAL_SPECTRAL_PARAM_NOVAL) {
136 val &= ~AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT_KIWI;
137 }
138
139 //Select the mask to be same as before
141 }
142 // Enable spectral scan
144
146}
147
148/*
149 * Get the spectral parameter values and return them in the pe
150 * structure
151 */
152void
154{
155 uint32_t val;
156
158
161 if (AR_SREV_MERLIN(ah) ) {
164 } else {
167 }
168 val = OS_REG_READ(ah, AR_PHY_RADAR_1);
170}
171
174{
175 uint32_t val;
176
178 return MS(val, AR_PHY_SPECTRAL_SCAN_ACTIVE);
179}
180
183{
184 uint32_t val;
185
187 return MS(val,AR_PHY_SPECTRAL_SCAN_ENA);
188}
189
190void
192{
193 uint32_t val;
194
196
197 // Activate spectral scan
205}
206
207void
209{
210 uint32_t val;
212
213 // Deactivate spectral scan
214 val &= ~AR_PHY_SPECTRAL_SCAN_ENA;
215 val &= ~AR_PHY_SPECTRAL_SCAN_ACTIVE;
218 val = OS_REG_READ(ah, AR_PHY_ERR_MASK_REG) & (~AR_PHY_ERR_RADAR);
220}
221
222uint32_t
224{
225 uint32_t val;
226
228 return val;
229}
230
231void
232ar5416RestoreSpectralConfig(struct ath_hal *ah, uint32_t restoreval)
233{
234 uint32_t curval;
235
237
238 curval = OS_REG_READ(ah, AR_PHY_SPECTRAL_SCAN);
239
240 if (restoreval != curval) {
242 OS_REG_WRITE(ah, AR_PHY_SPECTRAL_SCAN, restoreval);
243 }
244 return;
245}
#define HAL_SPECTRAL_PARAM_NOVAL
Definition: ah.h:1042
HAL_BOOL
Definition: ah.h:93
@ AH_TRUE
Definition: ah.h:95
#define SM(_v, _f)
Definition: ah_internal.h:587
#define MS(_v, _f)
Definition: ah_internal.h:588
#define OS_REG_WRITE(_ah, _reg, _val)
Definition: ah_osdep.h:139
#define OS_REG_READ(_ah, _reg)
Definition: ah_osdep.h:140
#define AR_RX_FILTER
Definition: ar5210reg.h:88
#define AR_PHY_RADAR_0
Definition: ar5211phy.h:81
#define AR_PHY_RADAR_0_ENA
Definition: ar5211phy.h:82
#define AR_PHY_RADAR_0_HEIGHT
Definition: ar5212phy.h:218
#define AR_PHY_RADAR_0_RRSSI
Definition: ar5212phy.h:220
#define AR_PHY_ERR
Definition: ar5212reg.h:317
#define AR_PHY_ERR_RADAR
Definition: ar5212reg.h:948
static void ar5416DisableRadar(struct ath_hal *ah)
void ar5416ConfigureSpectralScan(struct ath_hal *ah, HAL_SPECTRAL_PARAM *ss)
void ar5416GetSpectralParams(struct ath_hal *ah, HAL_SPECTRAL_PARAM *ss)
void ar5416StopSpectralScan(struct ath_hal *ah)
static void ar5416PrepSpectralScan(struct ath_hal *ah)
uint32_t ar5416GetSpectralConfig(struct ath_hal *ah)
void ar5416RestoreSpectralConfig(struct ath_hal *ah, uint32_t restoreval)
HAL_BOOL ar5416IsSpectralActive(struct ath_hal *ah)
#define MAX_RADAR_HEIGHT
HAL_BOOL ar5416IsSpectralEnabled(struct ath_hal *ah)
#define ENABLE_ALL_PHYERR
#define MAX_RADAR_RSSI_THRESH
void ar5416StartSpectralScan(struct ath_hal *ah)
#define AR_PHY_RADAR_EXT
Definition: ar5416phy.h:96
#define AR_PHY_SPECTRAL_SCAN_PERIOD
Definition: ar5416phy.h:69
#define AR_PHY_SPECTRAL_SCAN_ACTIVE
Definition: ar5416phy.h:65
#define AR_PHY_RADAR_1_BIN_THRESH_SELECT
Definition: ar5416phy.h:100
#define AR_PHY_RADAR_0_FFT_ENA
Definition: ar5416phy.h:94
#define AR_PHY_SPECTRAL_SCAN_FFT_PERIOD
Definition: ar5416phy.h:67
#define AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT_KIWI
Definition: ar5416phy.h:80
#define AR_PHY_RADAR_1
Definition: ar5416phy.h:99
#define AR_PHY_SPECTRAL_SCAN_COUNT_KIWI
Definition: ar5416phy.h:75
#define AR_PHY_SPECTRAL_SCAN
Definition: ar5416phy.h:62
#define AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT
Definition: ar5416phy.h:78
#define AR_PHY_SPECTRAL_SCAN_ENA
Definition: ar5416phy.h:63
#define AR_PHY_SPECTRAL_SCAN_COUNT
Definition: ar5416phy.h:73
#define AR_PHY_SPECTRAL_SCAN_PHYERR_MASK_SELECT_KIWI
Definition: ar5416phy.h:87
#define AR_PHY_RADAR_EXT_ENA
Definition: ar5416phy.h:97
#define AR_PHY_ERR_MASK_REG
Definition: ar5416reg.h:184
#define AR_SREV_MERLIN(_ah)
Definition: ar5416reg.h:737
u_int8_t radar_bin_thresh_sel
Definition: ah.h:1034
u_int16_t ss_short_report
Definition: ah.h:1033
u_int16_t ss_fft_period
Definition: ah.h:1030
u_int16_t ss_period
Definition: ah.h:1031
u_int16_t ss_count
Definition: ah.h:1032
Definition: ah.h:1219