linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
To: Ryder Lee <ryder.lee@mediatek.com>
Cc: Felix Fietkau <nbd@nbd.name>,
	Shayne Chen <shayne.chen@mediatek.com>,
	Evelyn Tsai <evelyn.tsai@mediatek.com>,
	linux-wireless@vger.kernel.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH 1/2] mt76: mt7915: add .offset_tsf callback
Date: Tue, 25 May 2021 11:01:32 +0200	[thread overview]
Message-ID: <YKy87P+PcRTdNkwN@lore-desk> (raw)
In-Reply-To: <324aa6af6a191a1f929fd3054148b001acd0bd13.1621931743.git.ryder.lee@mediatek.com>


[-- Attachment #1.1: Type: text/plain, Size: 3461 bytes --]

> It's much more accurate than .get_tsf + .set_tsf, and switch to use
> mt76_rmw to operate tsf registers.
> 
> Tested-by: Xing Song <xing.song@mediatek.com>
> Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
> ---
>  .../net/wireless/mediatek/mt76/mt7915/main.c  | 33 +++++++++++++++++--
>  .../net/wireless/mediatek/mt76/mt7915/regs.h  |  2 ++
>  2 files changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
> index 64f9ebe4424a..2485f65766e7 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
> @@ -816,7 +816,8 @@ mt7915_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
>  
>  	n = mvif->omac_idx > HW_BSSID_MAX ? HW_BSSID_0 : mvif->omac_idx;
>  	/* TSF software read */
> -	mt76_set(dev, MT_LPON_TCR(band, n), MT_LPON_TCR_SW_MODE);
> +	mt76_rmw(dev, MT_LPON_TCR(band, n), MT_LPON_TCR_SW_MODE,
> +		 MT_LPON_TCR_SW_READ);
>  	tsf.t32[0] = mt76_rr(dev, MT_LPON_UTTR0(band));
>  	tsf.t32[1] = mt76_rr(dev, MT_LPON_UTTR1(band));
>  
> @@ -845,7 +846,34 @@ mt7915_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
>  	mt76_wr(dev, MT_LPON_UTTR0(band), tsf.t32[0]);
>  	mt76_wr(dev, MT_LPON_UTTR1(band), tsf.t32[1]);
>  	/* TSF software overwrite */
> -	mt76_set(dev, MT_LPON_TCR(band, n), MT_LPON_TCR_SW_WRITE);
> +	mt76_rmw(dev, MT_LPON_TCR(band, n), MT_LPON_TCR_SW_MODE,
> +		 MT_LPON_TCR_SW_WRITE);
> +
> +	mutex_unlock(&dev->mt76.mutex);
> +}
> +
> +static void
> +mt7915_offset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
> +		  s64 timestamp)
> +{
> +	struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
> +	struct mt7915_dev *dev = mt7915_hw_dev(hw);
> +	struct mt7915_phy *phy = mt7915_hw_phy(hw);
> +	bool band = phy != &dev->phy;
> +	union {
> +		u64 t64;
> +		u32 t32[2];
> +	} tsf = { .t64 = timestamp, };

nit: new line here after '{' and before '}'

Regards,
Lorenzo

> +	u16 n;
> +
> +	mutex_lock(&dev->mt76.mutex);
> +
> +	n = mvif->omac_idx > HW_BSSID_MAX ? HW_BSSID_0 : mvif->omac_idx;
> +	mt76_wr(dev, MT_LPON_UTTR0(band), tsf.t32[0]);
> +	mt76_wr(dev, MT_LPON_UTTR1(band), tsf.t32[1]);
> +	/* TSF software adjust*/
> +	mt76_rmw(dev, MT_LPON_TCR(band, n), MT_LPON_TCR_SW_MODE,
> +		 MT_LPON_TCR_SW_ADJUST);
>  
>  	mutex_unlock(&dev->mt76.mutex);
>  }
> @@ -1036,6 +1064,7 @@ const struct ieee80211_ops mt7915_ops = {
>  	.get_stats = mt7915_get_stats,
>  	.get_tsf = mt7915_get_tsf,
>  	.set_tsf = mt7915_set_tsf,
> +	.offset_tsf = mt7915_offset_tsf,
>  	.get_survey = mt76_get_survey,
>  	.get_antenna = mt76_get_antenna,
>  	.set_antenna = mt7915_set_antenna,
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
> index efe0f2904c66..e36b30d84f07 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
> @@ -124,6 +124,8 @@
>  #define MT_LPON_TCR(_band, n)		MT_WF_LPON(_band, 0x0a8 + (n) * 4)
>  #define MT_LPON_TCR_SW_MODE		GENMASK(1, 0)
>  #define MT_LPON_TCR_SW_WRITE		BIT(0)
> +#define MT_LPON_TCR_SW_ADJUST		BIT(1)
> +#define MT_LPON_TCR_SW_READ		GENMASK(1, 0)
>  
>  /* MIB: band 0(0x24800), band 1(0xa4800) */
>  #define MT_WF_MIB_BASE(_band)		((_band) ? 0xa4800 : 0x24800)
> -- 
> 2.18.0
> 

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

      parent reply	other threads:[~2021-05-25  9:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-25  8:45 [PATCH 1/2] mt76: mt7915: add .offset_tsf callback Ryder Lee
2021-05-25  8:45 ` [PATCH 2/2] mt76: mt7615: " Ryder Lee
2021-05-25  9:03   ` Lorenzo Bianconi
2021-05-25  9:01 ` Lorenzo Bianconi [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=YKy87P+PcRTdNkwN@lore-desk \
    --to=lorenzo.bianconi@redhat.com \
    --cc=evelyn.tsai@mediatek.com \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nbd@nbd.name \
    --cc=ryder.lee@mediatek.com \
    --cc=shayne.chen@mediatek.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).