All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Chuang <yhchuang@realtek.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: "kvalo@codeaurora.org" <kvalo@codeaurora.org>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	Pkshih <pkshih@realtek.com>
Subject: RE: [PATCH v3 3/8] rtw88: 8723d: Add set_channel
Date: Mon, 4 May 2020 10:45:13 +0000	[thread overview]
Message-ID: <4d13c81b03bd4d948160d6eab41cdb33@realtek.com> (raw)
In-Reply-To: <20200430105051.5aom7pn6ng2vubz3@linutronix.de>

Sebastian Andrzej Siewior <bigeasy@linutronix.de> writes:

> On 2020-04-29 17:56:51 [+0800], yhchuang@realtek.com wrote:
> > diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.c
> b/drivers/net/wireless/realtek/rtw88/rtw8723d.c
> > index 653cfa9445fc..4e6ee00697be 100644
> > --- a/drivers/net/wireless/realtek/rtw88/rtw8723d.c
> > +++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.c
> > @@ -287,6 +287,168 @@ static void rtw8723d_query_rx_desc(struct
> rtw_dev *rtwdev, u8 *rx_desc,
> …
> > +static void rtw8723d_cfg_notch(struct rtw_dev *rtwdev, u8 channel, bool
> notch)
> > +{
> > +	if (!notch)
> 
> Would it make sense in pull in the code from the no_notch label up here
> and avoid the goto?

That will be great.

> 
> > +		goto no_notch;
> > +
> > +	switch (channel) {
> > +	case 13:
> > +		rtw_write32_mask(rtwdev, REG_OFDM0_RXDSP, BIT_MASK_RXDSP,
> 0xB);
> > +		rtw_write32_mask(rtwdev, REG_OFDM0_RXDSP, BIT_EN_RXDSP,
> 0x1);
> > +		rtw_write32(rtwdev, REG_OFDM1_CSI1, 0x04000000);
> > +		rtw_write32(rtwdev, REG_OFDM1_CSI2, 0x00000000);
> > +		rtw_write32(rtwdev, REG_OFDM1_CSI3, 0x00000000);
> > +		rtw_write32(rtwdev, REG_OFDM1_CSI4, 0x00000000);
> > +		rtw_write32_mask(rtwdev, REG_OFDM1_CFOTRK, BIT_EN_CFOTRK,
> 0x1);
> > +		break;
> > +	case 14:
> > +		rtw_write32_mask(rtwdev, REG_OFDM0_RXDSP, BIT_MASK_RXDSP,
> 0x5);
> > +		rtw_write32_mask(rtwdev, REG_OFDM0_RXDSP, BIT_EN_RXDSP,
> 0x1);
> > +		rtw_write32(rtwdev, REG_OFDM1_CSI1, 0x00000000);
> > +		rtw_write32(rtwdev, REG_OFDM1_CSI2, 0x00000000);
> > +		rtw_write32(rtwdev, REG_OFDM1_CSI3, 0x00000000);
> > +		rtw_write32(rtwdev, REG_OFDM1_CSI4, 0x00080000);
> > +		rtw_write32_mask(rtwdev, REG_OFDM1_CFOTRK, BIT_EN_CFOTRK,
> 0x1);
> > +		break;
> > +	default:
> > +		rtw_write32_mask(rtwdev, REG_OFDM0_RXDSP, BIT_EN_RXDSP,
> 0x0);
> > +		rtw_write32_mask(rtwdev, REG_OFDM1_CFOTRK, BIT_EN_CFOTRK,
> 0x0);
> > +		break;
> > +	}
> > +
> > +	return;
> > +
> > +no_notch:
> > +	rtw_write32_mask(rtwdev, REG_OFDM0_RXDSP, BIT_MASK_RXDSP,
> 0x1f);
> > +	rtw_write32_mask(rtwdev, REG_OFDM0_RXDSP, BIT_EN_RXDSP, 0x0);
> > +	rtw_write32(rtwdev, REG_OFDM1_CSI1, 0x00000000);
> > +	rtw_write32(rtwdev, REG_OFDM1_CSI2, 0x00000000);
> > +	rtw_write32(rtwdev, REG_OFDM1_CSI3, 0x00000000);
> > +	rtw_write32(rtwdev, REG_OFDM1_CSI4, 0x00000000);
> > +	rtw_write32_mask(rtwdev, REG_OFDM1_CFOTRK, BIT_EN_CFOTRK, 0x0);
> > +}
> > +
> > +static void rtw8723d_spur_cal(struct rtw_dev *rtwdev, u8 channel)
> > +{
> > +	bool notch = false;
> > +
> > +	if (channel < 13)
> > +		goto do_notch;
> 
> if you reverse the if statement, then you could avoid the goto.

I think yes, we can make it look better.

> 
> > +
> > +	notch = rtw8723d_check_spur_ov_thres(rtwdev, channel, SPUR_THRES);
> > +
> > +do_notch:
> > +	rtw8723d_cfg_notch(rtwdev, channel, notch);
> > +}
> > +
> > +static void rtw8723d_set_channel_rf(struct rtw_dev *rtwdev, u8 channel,
> u8 bw)
> > +{
> > +	u32 rf_cfgch[2];
> 
> Would it make sense to use rf_cfgch_A rf_cfgch_B instead the array?

Great.

> 
> > +	rf_cfgch[0] = rtw_read_rf(rtwdev, RF_PATH_A, RF_CFGCH, RFREG_MASK);
> > +	rf_cfgch[1] = rtw_read_rf(rtwdev, RF_PATH_B, RF_CFGCH, RFREG_MASK);
> > +
> > +	rf_cfgch[0] &= ~RFCFGCH_CHANNEL_MASK;
> > +	rf_cfgch[1] &= ~RFCFGCH_CHANNEL_MASK;
> > +	rf_cfgch[0] |= (channel & RFCFGCH_CHANNEL_MASK);
> > +	rf_cfgch[1] |= (channel & RFCFGCH_CHANNEL_MASK);
> > +
> > +	rf_cfgch[0] &= ~RFCFGCH_BW_MASK;
> > +	switch (bw) {
> > +	case RTW_CHANNEL_WIDTH_20:
> > +		rf_cfgch[0] |= RFCFGCH_BW_20M;
> > +		break;
> > +	case RTW_CHANNEL_WIDTH_40:
> > +		rf_cfgch[0] |= RFCFGCH_BW_40M;
> > +		break;
> > +	default:
> > +		break;
> > +	}
> > +
> > +	rtw_write_rf(rtwdev, RF_PATH_A, RF_CFGCH, RFREG_MASK, rf_cfgch[0]);
> > +	rtw_write_rf(rtwdev, RF_PATH_B, RF_CFGCH, RFREG_MASK, rf_cfgch[1]);
> > +
> > +	rtw8723d_spur_cal(rtwdev, channel);
> > +}
> …
> > +static void rtw8723d_set_channel_bb(struct rtw_dev *rtwdev, u8 channel,
> u8 bw,
> > +				    u8 primary_ch_idx)
> > +{
> > +	const struct rtw_backup_info *cck_dfir =
> > +			channel <= 13 ? cck_dfir_cfg[0] : cck_dfir_cfg[1];
> > +	int i;
> 
> If you move the assignment of `cck_dfir' here the definition block
> would look a nicer.
> 
> > +
> > +	for (i = 0; i < CCK_DFIR_NR; i++, cck_dfir++)
> > +		rtw_write32(rtwdev, cck_dfir->reg, cck_dfir->val);
> > +
> > +	switch (bw) {
> > +	case RTW_CHANNEL_WIDTH_20:
> > +		rtw_write32_mask(rtwdev, REG_FPGA0_RFMOD, BIT_MASK_RFMOD,
> 0x0);
> > +		rtw_write32_mask(rtwdev, REG_FPGA1_RFMOD, BIT_MASK_RFMOD,
> 0x0);
> > +		rtw_write32_mask(rtwdev, REG_BBRX_DFIR, BIT_RXBB_DFIR_EN, 1);
> > +		rtw_write32_mask(rtwdev, REG_BBRX_DFIR, BIT_MASK_RXBB_DFIR,
> 0xa);
> > +		break;
> > +	case RTW_CHANNEL_WIDTH_40:
> > +		rtw_write32_mask(rtwdev, REG_FPGA0_RFMOD, BIT_MASK_RFMOD,
> 0x1);
> > +		rtw_write32_mask(rtwdev, REG_FPGA1_RFMOD, BIT_MASK_RFMOD,
> 0x1);
> > +		rtw_write32_mask(rtwdev, REG_BBRX_DFIR, BIT_RXBB_DFIR_EN, 0);
> > +		rtw_write32_mask(rtwdev, REG_CCK0_SYS, BIT_CCK_SIDE_BAND,
> > +				 (primary_ch_idx == RTW_SC_20_UPPER ? 1 : 0));
> > +		break;
> > +	default:
> > +		break;
> > +	}
> > +}
> 
> Sebastian
> 

Yen-Hsuan

  reply	other threads:[~2020-05-04 10:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-29  9:56 [PATCH v3 0/8] rtw88: 8723d: add BB related routines yhchuang
2020-04-29  9:56 ` [PATCH v3 1/8] rtw88: 8723d: Add DIG parameter yhchuang
2020-04-29  9:56 ` [PATCH v3 2/8] rtw88: 8723d: Add query_rx_desc yhchuang
2020-04-29  9:56 ` [PATCH v3 3/8] rtw88: 8723d: Add set_channel yhchuang
2020-04-30 10:50   ` Sebastian Andrzej Siewior
2020-05-04 10:45     ` Tony Chuang [this message]
2020-04-29  9:56 ` [PATCH v3 4/8] rtw88: handle C2H_CCX_TX_RPT to know if packet TX'ed successfully yhchuang
2020-04-29  9:56 ` [PATCH v3 5/8] rtw88: 8723d: 11N chips don't support LDPC yhchuang
2020-04-30 10:54   ` Sebastian Andrzej Siewior
2020-04-30 11:55     ` Kalle Valo
2020-05-04  8:38       ` Tony Chuang
2020-04-29  9:56 ` [PATCH v3 6/8] rtw88: 8723d: Add chip_ops::false_alarm_statistics yhchuang
2020-04-29  9:56 ` [PATCH v3 7/8] rtw88: 8723d: Set IG register for CCK rate yhchuang
2020-04-29  9:56 ` [PATCH v3 8/8] rtw88: 8723d: add interface configurations table yhchuang

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=4d13c81b03bd4d948160d6eab41cdb33@realtek.com \
    --to=yhchuang@realtek.com \
    --cc=bigeasy@linutronix.de \
    --cc=kvalo@codeaurora.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.