hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.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 #include <linux/kernel.h>
....@@ -366,61 +355,6 @@
366355 RADIO_2064_REG114,
367356 RADIO_2064_REG02E,
368357 RADIO_2064_REG12A,
369
-};
370
-
371
-static const
372
-struct lcnphy_rx_iqcomp lcnphy_rx_iqcomp_table_rev0[] = {
373
- {1, 0, 0},
374
- {2, 0, 0},
375
- {3, 0, 0},
376
- {4, 0, 0},
377
- {5, 0, 0},
378
- {6, 0, 0},
379
- {7, 0, 0},
380
- {8, 0, 0},
381
- {9, 0, 0},
382
- {10, 0, 0},
383
- {11, 0, 0},
384
- {12, 0, 0},
385
- {13, 0, 0},
386
- {14, 0, 0},
387
- {34, 0, 0},
388
- {38, 0, 0},
389
- {42, 0, 0},
390
- {46, 0, 0},
391
- {36, 0, 0},
392
- {40, 0, 0},
393
- {44, 0, 0},
394
- {48, 0, 0},
395
- {52, 0, 0},
396
- {56, 0, 0},
397
- {60, 0, 0},
398
- {64, 0, 0},
399
- {100, 0, 0},
400
- {104, 0, 0},
401
- {108, 0, 0},
402
- {112, 0, 0},
403
- {116, 0, 0},
404
- {120, 0, 0},
405
- {124, 0, 0},
406
- {128, 0, 0},
407
- {132, 0, 0},
408
- {136, 0, 0},
409
- {140, 0, 0},
410
- {149, 0, 0},
411
- {153, 0, 0},
412
- {157, 0, 0},
413
- {161, 0, 0},
414
- {165, 0, 0},
415
- {184, 0, 0},
416
- {188, 0, 0},
417
- {192, 0, 0},
418
- {196, 0, 0},
419
- {200, 0, 0},
420
- {204, 0, 0},
421
- {208, 0, 0},
422
- {212, 0, 0},
423
- {216, 0, 0},
424358 };
425359
426360 static const u32 lcnphy_23bitgaincode_table[] = {
....@@ -1199,8 +1133,6 @@
11991133 {
12001134 int wait_count = 0;
12011135 bool result = true;
1202
- u8 phybw40;
1203
- phybw40 = CHSPEC_IS40(pi->radio_chanspec);
12041136
12051137 mod_phy_reg(pi, 0x6da, (0x1 << 5), (1) << 5);
12061138
....@@ -1376,7 +1308,7 @@
13761308 u16 tx_pwr_ctrl;
13771309 u8 tx_gain_index_old = 0;
13781310 bool result = false, tx_gain_override_old = false;
1379
- u16 i, Core1TxControl_old, RFOverride0_old,
1311
+ u16 i, Core1TxControl_old,
13801312 RFOverrideVal0_old, rfoverride2_old, rfoverride2val_old,
13811313 rfoverride3_old, rfoverride3val_old, rfoverride4_old,
13821314 rfoverride4val_old, afectrlovr_old, afectrlovrval_old;
....@@ -1417,7 +1349,7 @@
14171349
14181350 or_phy_reg(pi, 0x631, 0x0015);
14191351
1420
- RFOverride0_old = read_phy_reg(pi, 0x44c);
1352
+ read_phy_reg(pi, 0x44c); /* RFOverride0_old */
14211353 RFOverrideVal0_old = read_phy_reg(pi, 0x44d);
14221354 rfoverride2_old = read_phy_reg(pi, 0x4b0);
14231355 rfoverride2val_old = read_phy_reg(pi, 0x4b1);
....@@ -1677,7 +1609,7 @@
16771609 const struct chan_info_2064_lcnphy *ci;
16781610 u8 rfpll_doubler = 0;
16791611 u8 pll_pwrup, pll_pwrup_ovr;
1680
- s32 qFxtal, qFref, qFvco, qFcal;
1612
+ s32 qFcal;
16811613 u8 d15, d16, f16, e44, e45;
16821614 u32 div_int, div_frac, fvco3, fpfd, fref3, fcal_div;
16831615 u16 loop_bw, d30, setCount;
....@@ -1751,10 +1683,7 @@
17511683 fvco3 = (ci->freq * 3);
17521684 fref3 = 2 * fpfd;
17531685
1754
- qFxtal = wlc_lcnphy_qdiv_roundup(pi->xtalfreq, PLL_2064_MHZ, 16);
1755
- qFref = wlc_lcnphy_qdiv_roundup(fpfd, PLL_2064_MHZ, 16);
17561686 qFcal = pi->xtalfreq * fcal_div / PLL_2064_MHZ;
1757
- qFvco = wlc_lcnphy_qdiv_roundup(fvco3, 2, 16);
17581687
17591688 write_radio_reg(pi, RADIO_2064_REG04F, 0x02);
17601689
....@@ -2866,7 +2795,7 @@
28662795 bool suspend, tx_gain_override_old;
28672796 struct lcnphy_txgains old_gains;
28682797 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
2869
- u16 idleTssi, idleTssi0_2C, idleTssi0_OB, idleTssi0_regvalue_OB,
2798
+ u16 idleTssi0_2C, idleTssi0_OB, idleTssi0_regvalue_OB,
28702799 idleTssi0_regvalue_2C;
28712800 u16 SAVE_txpwrctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi);
28722801 u16 SAVE_lpfgain = read_radio_reg(pi, RADIO_2064_REG112);
....@@ -2876,7 +2805,7 @@
28762805 u16 SAVE_iqadc_aux_en = read_radio_reg(pi, RADIO_2064_REG11F) & 4;
28772806 u8 SAVE_bbmult = wlc_lcnphy_get_bbmult(pi);
28782807
2879
- idleTssi = read_phy_reg(pi, 0x4ab);
2808
+ read_phy_reg(pi, 0x4ab); /* idleTssi */
28802809 suspend = (0 == (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) &
28812810 MCTL_EN_MAC));
28822811 if (!suspend)
....@@ -2900,8 +2829,7 @@
29002829 wlc_lcnphy_set_bbmult(pi, 0x0);
29012830
29022831 wlc_phy_do_dummy_tx(pi, true, OFF);
2903
- idleTssi = ((read_phy_reg(pi, 0x4ab) & (0x1ff << 0))
2904
- >> 0);
2832
+ read_phy_reg(pi, 0x4ab); /* idleTssi */
29052833
29062834 idleTssi0_2C = ((read_phy_reg(pi, 0x63e) & (0x1ff << 0))
29072835 >> 0);
....@@ -3082,7 +3010,7 @@
30823010 u8 bbmult;
30833011 struct phytbl_info tab;
30843012 s32 a1, b0, b1;
3085
- s32 tssi, pwr, maxtargetpwr, mintargetpwr;
3013
+ s32 tssi, pwr, mintargetpwr;
30863014 bool suspend;
30873015 struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
30883016
....@@ -3119,7 +3047,6 @@
31193047 b0 = pi->txpa_2g[0];
31203048 b1 = pi->txpa_2g[1];
31213049 a1 = pi->txpa_2g[2];
3122
- maxtargetpwr = wlc_lcnphy_tssi2dbm(10, a1, b0, b1);
31233050 mintargetpwr = wlc_lcnphy_tssi2dbm(125, a1, b0, b1);
31243051
31253052 tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL;
....@@ -3447,8 +3374,8 @@
34473374
34483375 theta += rot;
34493376
3450
- i_samp = (u16) (FLOAT(tone_samp.i * max_val) & 0x3ff);
3451
- q_samp = (u16) (FLOAT(tone_samp.q * max_val) & 0x3ff);
3377
+ i_samp = (u16)(CORDIC_FLOAT(tone_samp.i * max_val) & 0x3ff);
3378
+ q_samp = (u16)(CORDIC_FLOAT(tone_samp.q * max_val) & 0x3ff);
34523379 data_buf[t] = (i_samp << 10) | q_samp;
34533380 }
34543381
....@@ -3872,8 +3799,6 @@
38723799
38733800 static void wlc_lcnphy_tx_iqlo_soft_cal_full(struct brcms_phy *pi)
38743801 {
3875
- struct lcnphy_unsign16_struct iqcc0, locc2, locc3, locc4;
3876
-
38773802 wlc_lcnphy_set_cc(pi, 0, 0, 0);
38783803 wlc_lcnphy_set_cc(pi, 2, 0, 0);
38793804 wlc_lcnphy_set_cc(pi, 3, 0, 0);
....@@ -3886,10 +3811,10 @@
38863811 wlc_lcnphy_a1(pi, 2, 2, 1);
38873812 wlc_lcnphy_a1(pi, 0, 4, 3);
38883813
3889
- iqcc0 = wlc_lcnphy_get_cc(pi, 0);
3890
- locc2 = wlc_lcnphy_get_cc(pi, 2);
3891
- locc3 = wlc_lcnphy_get_cc(pi, 3);
3892
- locc4 = wlc_lcnphy_get_cc(pi, 4);
3814
+ wlc_lcnphy_get_cc(pi, 0);
3815
+ wlc_lcnphy_get_cc(pi, 2);
3816
+ wlc_lcnphy_get_cc(pi, 3);
3817
+ wlc_lcnphy_get_cc(pi, 4);
38933818 }
38943819
38953820 u16 wlc_lcnphy_get_tx_locc(struct brcms_phy *pi)
....@@ -4205,21 +4130,16 @@
42054130
42064131 static void wlc_lcnphy_periodic_cal(struct brcms_phy *pi)
42074132 {
4208
- bool suspend, full_cal;
4209
- const struct lcnphy_rx_iqcomp *rx_iqcomp;
4210
- int rx_iqcomp_sz;
4133
+ bool suspend;
42114134 u16 SAVE_pwrctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi);
42124135 s8 index;
42134136 struct phytbl_info tab;
42144137 s32 a1, b0, b1;
4215
- s32 tssi, pwr, maxtargetpwr, mintargetpwr;
4138
+ s32 tssi, pwr, mintargetpwr;
42164139 struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy;
42174140
42184141 pi->phy_lastcal = pi->sh->now;
42194142 pi->phy_forcecal = false;
4220
- full_cal =
4221
- (pi_lcn->lcnphy_full_cal_channel !=
4222
- CHSPEC_CHANNEL(pi->radio_chanspec));
42234143 pi_lcn->lcnphy_full_cal_channel = CHSPEC_CHANNEL(pi->radio_chanspec);
42244144 index = pi_lcn->lcnphy_current_index;
42254145
....@@ -4234,9 +4154,6 @@
42344154
42354155 wlc_lcnphy_txpwrtbl_iqlo_cal(pi);
42364156
4237
- rx_iqcomp = lcnphy_rx_iqcomp_table_rev0;
4238
- rx_iqcomp_sz = ARRAY_SIZE(lcnphy_rx_iqcomp_table_rev0);
4239
-
42404157 if (LCNREV_IS(pi->pubpi.phy_rev, 1))
42414158 wlc_lcnphy_rx_iq_cal(pi, NULL, 0, true, false, 1, 40);
42424159 else
....@@ -4249,7 +4166,6 @@
42494166 b0 = pi->txpa_2g[0];
42504167 b1 = pi->txpa_2g[1];
42514168 a1 = pi->txpa_2g[2];
4252
- maxtargetpwr = wlc_lcnphy_tssi2dbm(10, a1, b0, b1);
42534169 mintargetpwr = wlc_lcnphy_tssi2dbm(125, a1, b0, b1);
42544170
42554171 tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL;
....@@ -4622,12 +4538,9 @@
46224538 static void wlc_lcnphy_tbl_init(struct brcms_phy *pi)
46234539 {
46244540 uint idx;
4625
- u8 phybw40;
46264541 struct phytbl_info tab;
46274542 const struct phytbl_info *tb;
46284543 u32 val;
4629
-
4630
- phybw40 = CHSPEC_IS40(pi->radio_chanspec);
46314544
46324545 for (idx = 0; idx < dot11lcnphytbl_info_sz_rev0; idx++)
46334546 wlc_lcnphy_write_table(pi, &dot11lcnphytbl_info_rev0[idx]);
....@@ -4831,9 +4744,7 @@
48314744
48324745 void wlc_phy_init_lcnphy(struct brcms_phy *pi)
48334746 {
4834
- u8 phybw40;
48354747 struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy;
4836
- phybw40 = CHSPEC_IS40(pi->radio_chanspec);
48374748
48384749 pi_lcn->lcnphy_cal_counter = 0;
48394750 pi_lcn->lcnphy_cal_temper = pi_lcn->lcnphy_rawtempsense;
....@@ -4936,10 +4847,6 @@
49364847 offset_ofdm >>= 4;
49374848 }
49384849 } else {
4939
- u8 opo = 0;
4940
-
4941
- opo = sprom->opo;
4942
-
49434850 for (i = TXP_FIRST_CCK; i <= TXP_LAST_CCK; i++)
49444851 pi->tx_srom_max_rate_2g[i] = txpwr;
49454852