From: Kalle Valo <kvalo@kernel.org>
To: Ping-Ke Shih <pkshih@realtek.com>
Cc: <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH v2 04/16] rtw89: 8852c: rfk: add TSSI
Date: Mon, 02 May 2022 09:39:07 +0300 [thread overview]
Message-ID: <871qxccub8.fsf@kernel.org> (raw)
In-Reply-To: <20220429071809.32104-5-pkshih@realtek.com> (Ping-Ke Shih's message of "Fri, 29 Apr 2022 15:17:57 +0800")
Ping-Ke Shih <pkshih@realtek.com> writes:
> TSSI is transmitter signal strength indication, which is a close-loop
> hardware circuit to feedback actual transmitting power as a reference for
> next transmission.
>
> When we setup channel to connect an AP, it does full calibration. When
> switching bands or channels, it needs to reset hardware status to prevent
> use wrong feedback of previous transmission.
>
> To do TX power compensation reflecting current temperature, it loads tables
> of compensation values into registers according to channel and band group.
>
> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
[...]
> +static void _tssi_set_tmeter_tbl(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy,
> + enum rtw89_rf_path path)
> +{
> +#define __get_val(ptr, idx) \
> +({ \
> + s8 *__ptr = (ptr); \
> + u8 __idx = (idx), __i, __v; \
> + u32 __val = 0; \
> + for (__i = 0; __i < 4; __i++) { \
> + __v = (__ptr[__idx + __i]); \
> + __val |= (__v << (8 * __i)); \
> + } \
> + __val; \
> +})
The convention is to use upper case for macros. And maybe __get_val() is
too generic name, RTW89_GET_VAL() or something like that?
> +static void _tssi_set_efuse_to_de(struct rtw89_dev *rtwdev,
> + enum rtw89_phy_idx phy)
> +{
> +#define __DE_MASK 0x003ff000
> + struct rtw89_tssi_info *tssi_info = &rtwdev->tssi;
> + static const u32 r_cck_long[RF_PATH_NUM_8852C] = {0x5858, 0x7858};
> + static const u32 r_cck_short[RF_PATH_NUM_8852C] = {0x5860, 0x7860};
> + static const u32 r_mcs_20m[RF_PATH_NUM_8852C] = {0x5838, 0x7838};
> + static const u32 r_mcs_40m[RF_PATH_NUM_8852C] = {0x5840, 0x7840};
> + static const u32 r_mcs_80m[RF_PATH_NUM_8852C] = {0x5848, 0x7848};
> + static const u32 r_mcs_80m_80m[RF_PATH_NUM_8852C] = {0x5850, 0x7850};
> + static const u32 r_mcs_5m[RF_PATH_NUM_8852C] = {0x5828, 0x7828};
> + static const u32 r_mcs_10m[RF_PATH_NUM_8852C] = {0x5830, 0x7830};
> + u8 ch = rtwdev->hal.current_channel;
> + u8 gidx;
> + s8 ofdm_de;
> + s8 trim_de;
> + s32 val;
> + u32 i, path = RF_PATH_A, path_max = RF_PATH_NUM_8852C;
> +
> + rtw89_debug(rtwdev, RTW89_DBG_TSSI, "[TSSI][TRIM]: phy=%d ch=%d\n",
> + phy, ch);
> +
> + if (rtwdev->dbcc_en) {
> + if (phy == RTW89_PHY_0) {
> + path = RF_PATH_A;
> + path_max = RF_PATH_B;
> + } else if (phy == RTW89_PHY_1) {
> + path = RF_PATH_B;
> + path_max = RF_PATH_NUM_8852C;
> + }
> + }
> +
> + for (i = path; i < path_max; i++) {
> + gidx = _tssi_get_cck_group(rtwdev, ch);
> + trim_de = _tssi_get_ofdm_trim_de(rtwdev, phy, i);
> + val = tssi_info->tssi_cck[i][gidx] + trim_de;
> +
> + rtw89_debug(rtwdev, RTW89_DBG_TSSI,
> + "[TSSI][TRIM]: path=%d cck[%d]=0x%x trim=0x%x\n",
> + i, gidx, tssi_info->tssi_cck[i][gidx], trim_de);
> +
> + rtw89_phy_write32_mask(rtwdev, r_cck_long[i], __DE_MASK, val);
> + rtw89_phy_write32_mask(rtwdev, r_cck_short[i], __DE_MASK, val);
> +
> + rtw89_debug(rtwdev, RTW89_DBG_TSSI,
> + "[TSSI] Set TSSI CCK DE 0x%x[21:12]=0x%x\n",
> + r_cck_long[i],
> + rtw89_phy_read32_mask(rtwdev, r_cck_long[i],
> + __DE_MASK));
> +
> + ofdm_de = _tssi_get_ofdm_de(rtwdev, phy, i);
> + trim_de = _tssi_get_ofdm_trim_de(rtwdev, phy, i);
> + val = ofdm_de + trim_de;
> +
> + rtw89_debug(rtwdev, RTW89_DBG_TSSI,
> + "[TSSI][TRIM]: path=%d mcs=0x%x trim=0x%x\n",
> + i, ofdm_de, trim_de);
> +
> + rtw89_phy_write32_mask(rtwdev, r_mcs_20m[i], __DE_MASK, val);
> + rtw89_phy_write32_mask(rtwdev, r_mcs_40m[i], __DE_MASK, val);
> + rtw89_phy_write32_mask(rtwdev, r_mcs_80m[i], __DE_MASK, val);
> + rtw89_phy_write32_mask(rtwdev, r_mcs_80m_80m[i], __DE_MASK, val);
> + rtw89_phy_write32_mask(rtwdev, r_mcs_5m[i], __DE_MASK, val);
> + rtw89_phy_write32_mask(rtwdev, r_mcs_10m[i], __DE_MASK, val);
> +
> + rtw89_debug(rtwdev, RTW89_DBG_TSSI,
> + "[TSSI] Set TSSI MCS DE 0x%x[21:12]=0x%x\n",
> + r_mcs_20m[i],
> + rtw89_phy_read32_mask(rtwdev, r_mcs_20m[i],
> + __DE_MASK));
> + }
> +#undef __DE_MASK
> +}
That __DE_MASK is odd and even more so when undeffing it. I would create
a proper name for it and also group all such register and mask
definitions to the beginning of the .c file.
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
next prev parent reply other threads:[~2022-05-02 6:39 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-29 7:17 [PATCH v2 00/16] rtw89: 8852c: add RFK and then enable 8852ce in Makefile and Kconfig Ping-Ke Shih
2022-04-29 7:17 ` [PATCH v2 01/16] rtw89: 8852c: rfk: add RFK tables Ping-Ke Shih
2022-05-02 6:45 ` Kalle Valo
2022-05-03 0:05 ` Pkshih
2022-04-29 7:17 ` [PATCH v2 02/16] rtw89: 8852c: rfk: add DACK Ping-Ke Shih
2022-05-02 6:34 ` Kalle Valo
2022-04-29 7:17 ` [PATCH v2 03/16] rtw89: 8852c: rfk: add LCK Ping-Ke Shih
2022-04-29 7:17 ` [PATCH v2 04/16] rtw89: 8852c: rfk: add TSSI Ping-Ke Shih
2022-05-02 6:39 ` Kalle Valo [this message]
2022-04-29 7:17 ` [PATCH v2 05/16] rtw89: 8852c: rfk: add RCK Ping-Ke Shih
2022-04-29 7:17 ` [PATCH v2 06/16] rtw89: 8852c: rfk: add RX DCK Ping-Ke Shih
2022-04-29 7:18 ` [PATCH v2 07/16] rtw89: 8852c: rfk: add IQK Ping-Ke Shih
2022-04-29 7:18 ` [PATCH v2 08/16] rtw89: 8852c: rfk: add DPK Ping-Ke Shih
2022-04-29 7:18 ` [PATCH v2 09/16] rtw89: 8852c: rfk: get calibrated channels to notify firmware Ping-Ke Shih
2022-04-29 7:18 ` [PATCH v2 10/16] rtw89: 8852c: add chip_ops::bb_ctrl_btc_preagc Ping-Ke Shih
2022-04-29 7:18 ` [PATCH v2 11/16] rtw89: 8852c: add basic and remaining chip_info Ping-Ke Shih
2022-04-29 7:18 ` [PATCH v2 12/16] rtw89: ps: fine tune polling interval while changing low power mode Ping-Ke Shih
2022-04-29 7:18 ` [PATCH v2 13/16] rtw89: correct AID settings of beamformee Ping-Ke Shih
2022-04-29 7:18 ` [PATCH v2 14/16] rtw89: 8852c: correct register definitions used by 8852c Ping-Ke Shih
2022-04-29 7:18 ` [PATCH v2 15/16] rtw89: 8852c: fix warning of FIELD_PREP() mask type Ping-Ke Shih
2022-04-29 7:18 ` [PATCH v2 16/16] rtw89: 8852c: add 8852ce to Makefile and Kconfig Ping-Ke Shih
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871qxccub8.fsf@kernel.org \
--to=kvalo@kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=pkshih@realtek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.