.. | .. |
---|
| 1 | +// SPDX-License-Identifier: ISC |
---|
1 | 2 | /* |
---|
2 | 3 | * 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. |
---|
15 | 4 | */ |
---|
16 | 5 | |
---|
17 | 6 | #include <linux/kernel.h> |
---|
.. | .. |
---|
366 | 355 | RADIO_2064_REG114, |
---|
367 | 356 | RADIO_2064_REG02E, |
---|
368 | 357 | 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}, |
---|
424 | 358 | }; |
---|
425 | 359 | |
---|
426 | 360 | static const u32 lcnphy_23bitgaincode_table[] = { |
---|
.. | .. |
---|
1199 | 1133 | { |
---|
1200 | 1134 | int wait_count = 0; |
---|
1201 | 1135 | bool result = true; |
---|
1202 | | - u8 phybw40; |
---|
1203 | | - phybw40 = CHSPEC_IS40(pi->radio_chanspec); |
---|
1204 | 1136 | |
---|
1205 | 1137 | mod_phy_reg(pi, 0x6da, (0x1 << 5), (1) << 5); |
---|
1206 | 1138 | |
---|
.. | .. |
---|
1376 | 1308 | u16 tx_pwr_ctrl; |
---|
1377 | 1309 | u8 tx_gain_index_old = 0; |
---|
1378 | 1310 | bool result = false, tx_gain_override_old = false; |
---|
1379 | | - u16 i, Core1TxControl_old, RFOverride0_old, |
---|
| 1311 | + u16 i, Core1TxControl_old, |
---|
1380 | 1312 | RFOverrideVal0_old, rfoverride2_old, rfoverride2val_old, |
---|
1381 | 1313 | rfoverride3_old, rfoverride3val_old, rfoverride4_old, |
---|
1382 | 1314 | rfoverride4val_old, afectrlovr_old, afectrlovrval_old; |
---|
.. | .. |
---|
1417 | 1349 | |
---|
1418 | 1350 | or_phy_reg(pi, 0x631, 0x0015); |
---|
1419 | 1351 | |
---|
1420 | | - RFOverride0_old = read_phy_reg(pi, 0x44c); |
---|
| 1352 | + read_phy_reg(pi, 0x44c); /* RFOverride0_old */ |
---|
1421 | 1353 | RFOverrideVal0_old = read_phy_reg(pi, 0x44d); |
---|
1422 | 1354 | rfoverride2_old = read_phy_reg(pi, 0x4b0); |
---|
1423 | 1355 | rfoverride2val_old = read_phy_reg(pi, 0x4b1); |
---|
.. | .. |
---|
1677 | 1609 | const struct chan_info_2064_lcnphy *ci; |
---|
1678 | 1610 | u8 rfpll_doubler = 0; |
---|
1679 | 1611 | u8 pll_pwrup, pll_pwrup_ovr; |
---|
1680 | | - s32 qFxtal, qFref, qFvco, qFcal; |
---|
| 1612 | + s32 qFcal; |
---|
1681 | 1613 | u8 d15, d16, f16, e44, e45; |
---|
1682 | 1614 | u32 div_int, div_frac, fvco3, fpfd, fref3, fcal_div; |
---|
1683 | 1615 | u16 loop_bw, d30, setCount; |
---|
.. | .. |
---|
1751 | 1683 | fvco3 = (ci->freq * 3); |
---|
1752 | 1684 | fref3 = 2 * fpfd; |
---|
1753 | 1685 | |
---|
1754 | | - qFxtal = wlc_lcnphy_qdiv_roundup(pi->xtalfreq, PLL_2064_MHZ, 16); |
---|
1755 | | - qFref = wlc_lcnphy_qdiv_roundup(fpfd, PLL_2064_MHZ, 16); |
---|
1756 | 1686 | qFcal = pi->xtalfreq * fcal_div / PLL_2064_MHZ; |
---|
1757 | | - qFvco = wlc_lcnphy_qdiv_roundup(fvco3, 2, 16); |
---|
1758 | 1687 | |
---|
1759 | 1688 | write_radio_reg(pi, RADIO_2064_REG04F, 0x02); |
---|
1760 | 1689 | |
---|
.. | .. |
---|
2866 | 2795 | bool suspend, tx_gain_override_old; |
---|
2867 | 2796 | struct lcnphy_txgains old_gains; |
---|
2868 | 2797 | 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, |
---|
2870 | 2799 | idleTssi0_regvalue_2C; |
---|
2871 | 2800 | u16 SAVE_txpwrctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); |
---|
2872 | 2801 | u16 SAVE_lpfgain = read_radio_reg(pi, RADIO_2064_REG112); |
---|
.. | .. |
---|
2876 | 2805 | u16 SAVE_iqadc_aux_en = read_radio_reg(pi, RADIO_2064_REG11F) & 4; |
---|
2877 | 2806 | u8 SAVE_bbmult = wlc_lcnphy_get_bbmult(pi); |
---|
2878 | 2807 | |
---|
2879 | | - idleTssi = read_phy_reg(pi, 0x4ab); |
---|
| 2808 | + read_phy_reg(pi, 0x4ab); /* idleTssi */ |
---|
2880 | 2809 | suspend = (0 == (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & |
---|
2881 | 2810 | MCTL_EN_MAC)); |
---|
2882 | 2811 | if (!suspend) |
---|
.. | .. |
---|
2900 | 2829 | wlc_lcnphy_set_bbmult(pi, 0x0); |
---|
2901 | 2830 | |
---|
2902 | 2831 | 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 */ |
---|
2905 | 2833 | |
---|
2906 | 2834 | idleTssi0_2C = ((read_phy_reg(pi, 0x63e) & (0x1ff << 0)) |
---|
2907 | 2835 | >> 0); |
---|
.. | .. |
---|
3082 | 3010 | u8 bbmult; |
---|
3083 | 3011 | struct phytbl_info tab; |
---|
3084 | 3012 | s32 a1, b0, b1; |
---|
3085 | | - s32 tssi, pwr, maxtargetpwr, mintargetpwr; |
---|
| 3013 | + s32 tssi, pwr, mintargetpwr; |
---|
3086 | 3014 | bool suspend; |
---|
3087 | 3015 | struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro); |
---|
3088 | 3016 | |
---|
.. | .. |
---|
3119 | 3047 | b0 = pi->txpa_2g[0]; |
---|
3120 | 3048 | b1 = pi->txpa_2g[1]; |
---|
3121 | 3049 | a1 = pi->txpa_2g[2]; |
---|
3122 | | - maxtargetpwr = wlc_lcnphy_tssi2dbm(10, a1, b0, b1); |
---|
3123 | 3050 | mintargetpwr = wlc_lcnphy_tssi2dbm(125, a1, b0, b1); |
---|
3124 | 3051 | |
---|
3125 | 3052 | tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; |
---|
.. | .. |
---|
3447 | 3374 | |
---|
3448 | 3375 | theta += rot; |
---|
3449 | 3376 | |
---|
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); |
---|
3452 | 3379 | data_buf[t] = (i_samp << 10) | q_samp; |
---|
3453 | 3380 | } |
---|
3454 | 3381 | |
---|
.. | .. |
---|
3872 | 3799 | |
---|
3873 | 3800 | static void wlc_lcnphy_tx_iqlo_soft_cal_full(struct brcms_phy *pi) |
---|
3874 | 3801 | { |
---|
3875 | | - struct lcnphy_unsign16_struct iqcc0, locc2, locc3, locc4; |
---|
3876 | | - |
---|
3877 | 3802 | wlc_lcnphy_set_cc(pi, 0, 0, 0); |
---|
3878 | 3803 | wlc_lcnphy_set_cc(pi, 2, 0, 0); |
---|
3879 | 3804 | wlc_lcnphy_set_cc(pi, 3, 0, 0); |
---|
.. | .. |
---|
3886 | 3811 | wlc_lcnphy_a1(pi, 2, 2, 1); |
---|
3887 | 3812 | wlc_lcnphy_a1(pi, 0, 4, 3); |
---|
3888 | 3813 | |
---|
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); |
---|
3893 | 3818 | } |
---|
3894 | 3819 | |
---|
3895 | 3820 | u16 wlc_lcnphy_get_tx_locc(struct brcms_phy *pi) |
---|
.. | .. |
---|
4205 | 4130 | |
---|
4206 | 4131 | static void wlc_lcnphy_periodic_cal(struct brcms_phy *pi) |
---|
4207 | 4132 | { |
---|
4208 | | - bool suspend, full_cal; |
---|
4209 | | - const struct lcnphy_rx_iqcomp *rx_iqcomp; |
---|
4210 | | - int rx_iqcomp_sz; |
---|
| 4133 | + bool suspend; |
---|
4211 | 4134 | u16 SAVE_pwrctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); |
---|
4212 | 4135 | s8 index; |
---|
4213 | 4136 | struct phytbl_info tab; |
---|
4214 | 4137 | s32 a1, b0, b1; |
---|
4215 | | - s32 tssi, pwr, maxtargetpwr, mintargetpwr; |
---|
| 4138 | + s32 tssi, pwr, mintargetpwr; |
---|
4216 | 4139 | struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; |
---|
4217 | 4140 | |
---|
4218 | 4141 | pi->phy_lastcal = pi->sh->now; |
---|
4219 | 4142 | pi->phy_forcecal = false; |
---|
4220 | | - full_cal = |
---|
4221 | | - (pi_lcn->lcnphy_full_cal_channel != |
---|
4222 | | - CHSPEC_CHANNEL(pi->radio_chanspec)); |
---|
4223 | 4143 | pi_lcn->lcnphy_full_cal_channel = CHSPEC_CHANNEL(pi->radio_chanspec); |
---|
4224 | 4144 | index = pi_lcn->lcnphy_current_index; |
---|
4225 | 4145 | |
---|
.. | .. |
---|
4234 | 4154 | |
---|
4235 | 4155 | wlc_lcnphy_txpwrtbl_iqlo_cal(pi); |
---|
4236 | 4156 | |
---|
4237 | | - rx_iqcomp = lcnphy_rx_iqcomp_table_rev0; |
---|
4238 | | - rx_iqcomp_sz = ARRAY_SIZE(lcnphy_rx_iqcomp_table_rev0); |
---|
4239 | | - |
---|
4240 | 4157 | if (LCNREV_IS(pi->pubpi.phy_rev, 1)) |
---|
4241 | 4158 | wlc_lcnphy_rx_iq_cal(pi, NULL, 0, true, false, 1, 40); |
---|
4242 | 4159 | else |
---|
.. | .. |
---|
4249 | 4166 | b0 = pi->txpa_2g[0]; |
---|
4250 | 4167 | b1 = pi->txpa_2g[1]; |
---|
4251 | 4168 | a1 = pi->txpa_2g[2]; |
---|
4252 | | - maxtargetpwr = wlc_lcnphy_tssi2dbm(10, a1, b0, b1); |
---|
4253 | 4169 | mintargetpwr = wlc_lcnphy_tssi2dbm(125, a1, b0, b1); |
---|
4254 | 4170 | |
---|
4255 | 4171 | tab.tbl_id = LCNPHY_TBL_ID_TXPWRCTL; |
---|
.. | .. |
---|
4622 | 4538 | static void wlc_lcnphy_tbl_init(struct brcms_phy *pi) |
---|
4623 | 4539 | { |
---|
4624 | 4540 | uint idx; |
---|
4625 | | - u8 phybw40; |
---|
4626 | 4541 | struct phytbl_info tab; |
---|
4627 | 4542 | const struct phytbl_info *tb; |
---|
4628 | 4543 | u32 val; |
---|
4629 | | - |
---|
4630 | | - phybw40 = CHSPEC_IS40(pi->radio_chanspec); |
---|
4631 | 4544 | |
---|
4632 | 4545 | for (idx = 0; idx < dot11lcnphytbl_info_sz_rev0; idx++) |
---|
4633 | 4546 | wlc_lcnphy_write_table(pi, &dot11lcnphytbl_info_rev0[idx]); |
---|
.. | .. |
---|
4831 | 4744 | |
---|
4832 | 4745 | void wlc_phy_init_lcnphy(struct brcms_phy *pi) |
---|
4833 | 4746 | { |
---|
4834 | | - u8 phybw40; |
---|
4835 | 4747 | struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; |
---|
4836 | | - phybw40 = CHSPEC_IS40(pi->radio_chanspec); |
---|
4837 | 4748 | |
---|
4838 | 4749 | pi_lcn->lcnphy_cal_counter = 0; |
---|
4839 | 4750 | pi_lcn->lcnphy_cal_temper = pi_lcn->lcnphy_rawtempsense; |
---|
.. | .. |
---|
4936 | 4847 | offset_ofdm >>= 4; |
---|
4937 | 4848 | } |
---|
4938 | 4849 | } else { |
---|
4939 | | - u8 opo = 0; |
---|
4940 | | - |
---|
4941 | | - opo = sprom->opo; |
---|
4942 | | - |
---|
4943 | 4850 | for (i = TXP_FIRST_CCK; i <= TXP_LAST_CCK; i++) |
---|
4944 | 4851 | pi->tx_srom_max_rate_2g[i] = txpwr; |
---|
4945 | 4852 | |
---|