hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
....@@ -1,17 +1,6 @@
1
+// SPDX-License-Identifier: ISC
12 /*
23 * Copyright (c) 2010 Broadcom Corporation
3
- *
4
- * Permission to use, copy, modify, and/or distribute this software for any
5
- * purpose with or without fee is hereby granted, provided that the above
6
- * copyright notice and this permission notice appear in all copies.
7
- *
8
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
154 */
165
176 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -17759,7 +17748,7 @@
1775917748 num = 8 *
1776017749 (16 * b0[tbl_id - 26] + b1[tbl_id - 26] * idx);
1776117750 den = 32768 + a1[tbl_id - 26] * idx;
17762
- pwr_est = max(((4 * num + den / 2) / den), -8);
17751
+ pwr_est = max(DIV_ROUND_CLOSEST(4 * num, den), -8);
1776317752 if (NREV_LT(pi->pubpi.phy_rev, 3)) {
1776417753 if (idx <=
1776517754 (uint) (31 - idle_tssi[tbl_id - 26] + 1))
....@@ -19044,7 +19033,6 @@
1904419033 u32 nphy_adj_noise_var_buf[] = { 0x3ff, 0x3ff };
1904519034 bool isAdjustNoiseVar = false;
1904619035 uint numTonesAdjust = 0;
19047
- u32 tempval = 0;
1904819036
1904919037 if (NREV_GE(pi->pubpi.phy_rev, 3)) {
1905019038 if (pi->phyhang_avoid)
....@@ -19150,9 +19138,6 @@
1915019138 numTonesAdjust,
1915119139 nphy_adj_tone_id_buf,
1915219140 nphy_adj_noise_var_buf);
19153
-
19154
- tempval = 0;
19155
-
1915619141 } else {
1915719142 wlc_phy_adjust_min_noisevar_nphy(pi, 0, NULL,
1915819143 NULL);
....@@ -20046,7 +20031,7 @@
2004620031 break;
2004720032
2004820033 default:
20049
- break;
20034
+ return;
2005020035 }
2005120036 }
2005220037
....@@ -21991,7 +21976,7 @@
2199121976 u16 auxADC_rssi_ctrlL, auxADC_rssi_ctrlH;
2199221977 s32 auxADC_Vl;
2199321978 u16 RfctrlOverride5_save, RfctrlOverride6_save;
21994
- u16 RfctrlMiscReg5_save, RfctrlMiscReg6_save;
21979
+ u16 RfctrlMiscReg5_save;
2199521980 u16 RSSIMultCoef0QPowerDet_save;
2199621981 u16 tempsense_Rcal;
2199721982
....@@ -22006,7 +21991,7 @@
2200621991 RfctrlOverride5_save = read_phy_reg(pi, 0x346);
2200721992 RfctrlOverride6_save = read_phy_reg(pi, 0x347);
2200821993 RfctrlMiscReg5_save = read_phy_reg(pi, 0x344);
22009
- RfctrlMiscReg6_save = read_phy_reg(pi, 0x345);
21994
+ read_phy_reg(pi, 0x345); /* RfctrlMiscReg6_save */
2201021995
2201121996 wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_AFECTRL, 1, 0x0A, 16,
2201221997 &auxADC_Vmid_save);
....@@ -22994,7 +22979,7 @@
2299422979 wlc_phy_rssi_compute_nphy(struct brcms_phy *pi, struct d11rxhdr *rxh)
2299522980 {
2299622981 s16 rxpwr, rxpwr0, rxpwr1;
22997
- s16 phyRx0_l, phyRx2_l;
22982
+ s16 phyRx2_l;
2299822983
2299922984 rxpwr = 0;
2300022985 rxpwr0 = rxh->PhyRxStatus_1 & PRXS1_nphy_PWR0_MASK;
....@@ -23005,7 +22990,6 @@
2300522990 if (rxpwr1 > 127)
2300622991 rxpwr1 -= 256;
2300722992
23008
- phyRx0_l = rxh->PhyRxStatus_0 & 0x00ff;
2300922993 phyRx2_l = rxh->PhyRxStatus_2 & 0x00ff;
2301022994 if (phyRx2_l > 127)
2301122995 phyRx2_l -= 256;
....@@ -23089,8 +23073,8 @@
2308923073
2309023074 theta += rot;
2309123075
23092
- tone_buf[t].q = (s32) FLOAT(tone_buf[t].q * max_val);
23093
- tone_buf[t].i = (s32) FLOAT(tone_buf[t].i * max_val);
23076
+ tone_buf[t].q = (s32)CORDIC_FLOAT(tone_buf[t].q * max_val);
23077
+ tone_buf[t].i = (s32)CORDIC_FLOAT(tone_buf[t].i * max_val);
2309423078 }
2309523079
2309623080 wlc_phy_loadsampletable_nphy(pi, tone_buf, num_samps);
....@@ -23108,8 +23092,7 @@
2310823092 u16 bb_mult;
2310923093 u8 phy_bw, sample_cmd;
2311023094 u16 orig_RfseqCoreActv;
23111
- u16 lpf_bw_ctl_override3, lpf_bw_ctl_override4, lpf_bw_ctl_miscreg3,
23112
- lpf_bw_ctl_miscreg4;
23095
+ u16 lpf_bw_ctl_override3, lpf_bw_ctl_override4;
2311323096
2311423097 if (pi->phyhang_avoid)
2311523098 wlc_phy_stay_in_carriersearch_nphy(pi, true);
....@@ -23122,12 +23105,7 @@
2312223105
2312323106 lpf_bw_ctl_override3 = read_phy_reg(pi, 0x342) & (0x1 << 7);
2312423107 lpf_bw_ctl_override4 = read_phy_reg(pi, 0x343) & (0x1 << 7);
23125
- if (lpf_bw_ctl_override3 | lpf_bw_ctl_override4) {
23126
- lpf_bw_ctl_miscreg3 = read_phy_reg(pi, 0x340) &
23127
- (0x7 << 8);
23128
- lpf_bw_ctl_miscreg4 = read_phy_reg(pi, 0x341) &
23129
- (0x7 << 8);
23130
- } else {
23108
+ if (!(lpf_bw_ctl_override3 | lpf_bw_ctl_override4)) {
2313123109 wlc_phy_rfctrl_override_nphy_rev7(
2313223110 pi,
2313323111 (0x1 << 7),
....@@ -23137,12 +23115,9 @@
2313723115 NPHY_REV7_RFCTRLOVERRIDE_ID1);
2313823116
2313923117 pi->nphy_sample_play_lpf_bw_ctl_ovr = true;
23140
-
23141
- lpf_bw_ctl_miscreg3 = read_phy_reg(pi, 0x340) &
23142
- (0x7 << 8);
23143
- lpf_bw_ctl_miscreg4 = read_phy_reg(pi, 0x341) &
23144
- (0x7 << 8);
2314523118 }
23119
+ read_phy_reg(pi, 0x340); /* lpf_bw_ctl_miscreg3 */
23120
+ read_phy_reg(pi, 0x341); /* lpf_bw_ctl_miscreg4 */
2314623121 }
2314723122
2314823123 if ((pi->nphy_bb_mult_save & BB_MULT_VALID_MASK) == 0) {
....@@ -23414,7 +23389,6 @@
2341423389 struct nphy_iqcal_params *params)
2341523390 {
2341623391 u8 k;
23417
- int idx;
2341823392 u16 gain_index;
2341923393 u8 band_idx = (CHSPEC_IS5G(pi->radio_chanspec) ? 1 : 0);
2342023394
....@@ -23447,13 +23421,10 @@
2344723421 (target_gain.pga[core_no] << 4) |
2344823422 (target_gain.txgm[core_no] << 8));
2344923423
23450
- idx = -1;
2345123424 for (k = 0; k < NPHY_IQCAL_NUMGAINS; k++) {
2345223425 if (tbl_iqcal_gainparams_nphy[band_idx][k][0] ==
23453
- gain_index) {
23454
- idx = k;
23426
+ gain_index)
2345523427 break;
23456
- }
2345723428 }
2345823429
2345923430 params->txgm = tbl_iqcal_gainparams_nphy[band_idx][k][1];
....@@ -24715,7 +24686,6 @@
2471524686 {
2471624687 u16 phy_a1, phy_a2, phy_a3;
2471724688 u16 phy_a4, phy_a5;
24718
- bool phy_a6;
2471924689 u8 phy_a7, m[2];
2472024690 u32 phy_a8 = 0;
2472124691 struct nphy_txgains phy_a9;
....@@ -24724,9 +24694,6 @@
2472424694 return;
2472524695
2472624696 phy_a7 = (core == PHY_CORE_0) ? 1 : 0;
24727
-
24728
- phy_a6 = ((cal_mode == CAL_GCTRL)
24729
- || (cal_mode == CAL_SOFT)) ? true : false;
2473024697
2473124698 if (NREV_GE(pi->pubpi.phy_rev, 7)) {
2473224699
....@@ -25007,7 +24974,6 @@
2500724974 s32 phy_a7, phy_a8;
2500824975 u32 phy_a9;
2500924976 int phy_a10;
25010
- bool phy_a11 = false;
2501124977 int phy_a12;
2501224978 u8 phy_a13 = 0;
2501324979 u8 phy_a14;
....@@ -25075,8 +25041,6 @@
2507525041 if (!phy_a6 && (phy_a3 != phy_a5)) {
2507625042 if (!phy_a3)
2507725043 phy_a12 -= (u8) phy_a1;
25078
-
25079
- phy_a11 = true;
2508025044 break;
2508125045 }
2508225046
....@@ -25090,8 +25054,6 @@
2509025054 phy_a12 = phy_a14;
2509125055 else
2509225056 phy_a12 = phy_a13;
25093
-
25094
- phy_a11 = true;
2509525057 break;
2509625058 }
2509725059
....@@ -25121,8 +25083,6 @@
2512125083 if (!phy_a6 && (phy_a3 != phy_a5)) {
2512225084 if (!phy_a3)
2512325085 phy_a12 -= (u8) phy_a1;
25124
-
25125
- phy_a11 = true;
2512625086 break;
2512725087 }
2512825088
....@@ -25136,8 +25096,6 @@
2513625096 phy_a12 = 0;
2513725097 else
2513825098 phy_a12 = 127;
25139
-
25140
- phy_a11 = true;
2514125099 break;
2514225100 }
2514325101
....@@ -25453,12 +25411,12 @@
2545325411 (pi->cal_type_override ==
2545425412 PHY_PERICAL_FULL) ? true : false;
2545525413
25456
- if ((pi->mphase_cal_phase_id > MPHASE_CAL_STATE_INIT)) {
25414
+ if (pi->mphase_cal_phase_id > MPHASE_CAL_STATE_INIT) {
2545725415 if (pi->nphy_txiqlocal_chanspec != pi->radio_chanspec)
2545825416 wlc_phy_cal_perical_mphase_restart(pi);
2545925417 }
2546025418
25461
- if ((pi->mphase_cal_phase_id == MPHASE_CAL_STATE_RXCAL))
25419
+ if (pi->mphase_cal_phase_id == MPHASE_CAL_STATE_RXCAL)
2546225420 wlapi_bmac_write_shm(pi->sh->physhim, M_CTS_DURATION, 10000);
2546325421
2546425422 wlapi_suspend_mac_and_wait(pi->sh->physhim);
....@@ -27001,8 +26959,8 @@
2700126959 NPHY_RXCAL_TONEAMP, 0, cal_type, false);
2700226960
2700326961 wlc_phy_rx_iq_est_nphy(pi, est, num_samps, 32, 0);
27004
- i_pwr = (est[rx_core].i_pwr + num_samps / 2) / num_samps;
27005
- q_pwr = (est[rx_core].q_pwr + num_samps / 2) / num_samps;
26962
+ i_pwr = DIV_ROUND_CLOSEST(est[rx_core].i_pwr, num_samps);
26963
+ q_pwr = DIV_ROUND_CLOSEST(est[rx_core].q_pwr, num_samps);
2700626964 curr_pwr = i_pwr + q_pwr;
2700726965
2700826966 switch (gainctrl_dirn) {
....@@ -27684,10 +27642,10 @@
2768427642 wlc_phy_rx_iq_est_nphy(pi, est,
2768527643 num_samps, 32,
2768627644 0);
27687
- i_pwr = (est[rx_core].i_pwr +
27688
- num_samps / 2) / num_samps;
27689
- q_pwr = (est[rx_core].q_pwr +
27690
- num_samps / 2) / num_samps;
27645
+ i_pwr = DIV_ROUND_CLOSEST(est[rx_core].i_pwr,
27646
+ num_samps);
27647
+ q_pwr = DIV_ROUND_CLOSEST(est[rx_core].q_pwr,
27648
+ num_samps);
2769127649 tot_pwr[gain_pass] = i_pwr + q_pwr;
2769227650 } else {
2769327651