All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislaw Gruszka <stf_xl@wp.pl>
To: Daniel Golle <daniel@makrotopia.org>
Cc: linux-wireless@vger.kernel.org,
	Helmut Schaa <helmut.schaa@googlemail.com>,
	Kalle Valo <kvalo@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Johannes Berg <johannes.berg@intel.com>
Subject: Re: [PATCH 07/15] rt2x00: add RXIQ calibration for MT7620
Date: Sat, 17 Sep 2022 14:47:19 +0200	[thread overview]
Message-ID: <20220917124719.GE17901@wp.pl> (raw)
In-Reply-To: <YyUBbZxKGljegJR5@makrotopia.org>

On Sat, Sep 17, 2022 at 12:06:21AM +0100, Daniel Golle wrote:
> From: Tomislav Požega <pozega.tomislav@gmail.com>
> 
> Add RXIQ calibration found in mtk driver. With old openwrt builds this
> gets us ~8Mbps more of RX bandwidth (test with iPA/eLNA layout).
> 
> Signed-off-by: Tomislav Požega <pozega.tomislav@gmail.com>
> ---
>  .../net/wireless/ralink/rt2x00/rt2800lib.c    | 384 ++++++++++++++++++
>  1 file changed, 384 insertions(+)
> 
> diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
> index d5b4dba3b27203..6e5a72cf2a81a0 100644
> --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
> +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
> @@ -8695,6 +8695,389 @@ static void rt2800_rxdcoc_calibration(struct rt2x00_dev *rt2x00dev)
>  	rt2800_rfcsr_write_bank(rt2x00dev, 0, 2, saverfb0r2);
>  }
>  
> +static u32 rt2800_do_sqrt_accumulation(u32 si)
> +{
> +	u32 root, root_pre, bit;
> +	char i;
> +
> +	bit = 1 << 15;
> +	root = 0;
> +	for (i = 15; i >= 0; i = i - 1) {
> +		root_pre = root + bit;
> +		if ((root_pre * root_pre) <= si)
> +			root = root_pre;
> +		bit = bit >> 1;
> +	}
> +
> +	return root;
> +}
> +
> +static void rt2800_rxiq_calibration(struct rt2x00_dev *rt2x00dev)
> +{
> +	u8 rfb0r1, rfb0r2, rfb0r42;
> +	u8 rfb4r0, rfb4r19;
> +	u8 rfb5r3, rfb5r4, rfb5r17, rfb5r18, rfb5r19, rfb5r20;
> +	u8 rfb6r0, rfb6r19;
> +	u8 rfb7r3, rfb7r4, rfb7r17, rfb7r18, rfb7r19, rfb7r20;
> +
> +	u8 bbp1, bbp4;
> +	u8 bbpr241, bbpr242;
> +	u32 i;
> +	u8 ch_idx;
> +	u8 bbpval;
> +	u8 rfval, vga_idx = 0;
> +	int mi = 0, mq = 0, si = 0, sq = 0, riq = 0;
> +	int sigma_i, sigma_q, r_iq, g_rx;
> +	int g_imb;
> +	int ph_rx;
> +	u32 savemacsysctrl = 0;
> +	u32 orig_RF_CONTROL0 = 0;
> +	u32 orig_RF_BYPASS0 = 0;
> +	u32 orig_RF_CONTROL1 = 0;
> +	u32 orig_RF_BYPASS1 = 0;
> +	u32 orig_RF_CONTROL3 = 0;
> +	u32 orig_RF_BYPASS3 = 0;
> +	u32 macstatus, bbpval1 = 0;

> +	u8 rf_vga_table[] = {0x20, 0x21, 0x22, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f};

static const maybe ? 

> +	savemacsysctrl = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL);
> +	orig_RF_CONTROL0 = rt2800_register_read(rt2x00dev, RF_CONTROL0);
> +	orig_RF_BYPASS0 = rt2800_register_read(rt2x00dev, RF_BYPASS0);
> +	orig_RF_CONTROL1 = rt2800_register_read(rt2x00dev, RF_CONTROL1);
> +	orig_RF_BYPASS1 = rt2800_register_read(rt2x00dev, RF_BYPASS1);
> +	orig_RF_CONTROL3 = rt2800_register_read(rt2x00dev, RF_CONTROL3);
> +	orig_RF_BYPASS3 = rt2800_register_read(rt2x00dev, RF_BYPASS3);
> +
> +	bbp1 = rt2800_bbp_read(rt2x00dev, 1);
> +	bbp4 = rt2800_bbp_read(rt2x00dev, 4);
> +
> +	rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x0);
> +
> +	for (i = 0; i < 10000; i++) {
> +		macstatus = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG);
> +		if (macstatus & 0x3)
> +			usleep_range(50, 100);
> +		else
> +			break;
> +	}

This one is used frequently , I think we can add helper for that.
mt76 has mt76x02_wait_for_txrx_idle , so we can create something
similar.


> +		vga_idx = 0;
> +			while (vga_idx < 11) {

Looks like ideation issue.  In general this function is too big.
Could be split into small sub-functions ? 



      reply	other threads:[~2022-09-17 12:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-16 23:06 [PATCH 07/15] rt2x00: add RXIQ calibration for MT7620 Daniel Golle
2022-09-17 12:47 ` Stanislaw Gruszka [this message]

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=20220917124719.GE17901@wp.pl \
    --to=stf_xl@wp.pl \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=helmut.schaa@googlemail.com \
    --cc=johannes.berg@intel.com \
    --cc=kuba@kernel.org \
    --cc=kvalo@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pabeni@redhat.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.