diff mbox series

mt76x0: antenna select corrections

Message ID 1539850059-11886-1-git-send-email-sgruszka@redhat.com (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series mt76x0: antenna select corrections | expand

Commit Message

Stanislaw Gruszka Oct. 18, 2018, 8:07 a.m. UTC
Update mt76x0_phy_ant_select() to conform vendor driver, most notably
add dual antenna mode support, read configuration from EEPROM and
move ant select out of channel config to init phase. Plus small MT7630E
quirk for MT_CMB_CTRL register which vendor driver dedicated to this
chip do.

This make MT7630E workable with mt76x0e driver and do not cause any
problems on MT7610U for me.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/mediatek/mt76/mt76x0/phy.c    | 52 ++++++++++++++++------
 .../net/wireless/mediatek/mt76/mt76x02_eeprom.h    | 10 ++---
 2 files changed, 44 insertions(+), 18 deletions(-)

Comments

Lorenzo Bianconi Oct. 18, 2018, 9:13 a.m. UTC | #1
> Update mt76x0_phy_ant_select() to conform vendor driver, most notably
> add dual antenna mode support, read configuration from EEPROM and
> move ant select out of channel config to init phase. Plus small MT7630E
> quirk for MT_CMB_CTRL register which vendor driver dedicated to this
> chip do.
> 
> This make MT7630E workable with mt76x0e driver and do not cause any
> problems on MT7610U for me.
> 
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mt76x0/phy.c    | 52 ++++++++++++++++------
>  .../net/wireless/mediatek/mt76/mt76x02_eeprom.h    | 10 ++---
>  2 files changed, 44 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
> index 37e1ead1dc85..143cbe6d7899 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
> @@ -431,21 +431,47 @@ int mt76x0_phy_wait_bbp_ready(struct mt76x02_dev *dev)
>  
>  static void mt76x0_phy_ant_select(struct mt76x02_dev *dev)
>  {
> -	struct ieee80211_channel *chan = dev->mt76.chandef.chan;
> -
> -	/* single antenna mode */
> -	if (chan->band == NL80211_BAND_2GHZ) {
> -		mt76_rmw(dev, MT_COEXCFG3,
> -			 BIT(5) | BIT(4) | BIT(3) | BIT(2), BIT(1));
> -		mt76_rmw(dev, MT_WLAN_FUN_CTRL, BIT(5), BIT(6));
> +	u16 ee_ant = mt76x02_eeprom_get(dev, MT_EE_ANTENNA);
> +	u16 nic_conf2 = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_2);
> +	u32 wlan, coex3, cmb;
> +	bool ant_div;
> +
> +	wlan = mt76_rr(dev, MT_WLAN_FUN_CTRL);
> +	cmb = mt76_rr(dev, MT_CMB_CTRL);
> +	coex3 = mt76_rr(dev, MT_COEXCFG3);
> +
> +	cmb   &= ~(BIT(15) | BIT(12));

I guess should be BIT(14) here (at least for single antenna mode)

> +	wlan  &= ~(BIT(6) | BIT(5));
> +	coex3 &= ~GENMASK(5, 1);

according to vendor sdk BIT(1) should not cleared if device supports 5GHz band
(signle antenna mode)

Regards,
Lorenzo

> +
> +	if (ee_ant & MT_EE_ANTENNA_DUAL) {
> +		/* dual antenna mode */
> +		ant_div = !(nic_conf2 & MT_EE_NIC_CONF_2_ANT_OPT) &&
> +			  (nic_conf2 & MT_EE_NIC_CONF_2_ANT_DIV);
> +		if (ant_div)
> +			cmb |= BIT(12);
> +		else
> +			coex3 |= BIT(4);
> +		coex3 |= BIT(3);
> +		if (dev->mt76.cap.has_2ghz)
> +			wlan |= BIT(6);
>  	} else {
> -		mt76_rmw(dev, MT_COEXCFG3, BIT(5) | BIT(2),
> -			 BIT(4) | BIT(3));
> -		mt76_clear(dev, MT_WLAN_FUN_CTRL,
> -			   BIT(6) | BIT(5));
> +		/* sigle antenna mode */
> +		if (dev->mt76.cap.has_5ghz) {
> +			coex3 |= BIT(3) | BIT(4);
> +		} else {
> +			wlan |= BIT(6);
> +			coex3 |= BIT(1);
> +		}
>  	}
> -	mt76_clear(dev, MT_CMB_CTRL, BIT(14) | BIT(12));
> +
> +	if (is_mt7630(dev))
> +		cmb |= BIT(14) | BIT(11);
> +
> +	mt76_wr(dev, MT_WLAN_FUN_CTRL, wlan);
> +	mt76_wr(dev, MT_CMB_CTRL, cmb);
>  	mt76_clear(dev, MT_COEXCFG0, BIT(2));
> +	mt76_wr(dev, MT_COEXCFG3, coex3);
>  }
>  
>  static void
> @@ -612,7 +638,6 @@ int mt76x0_phy_set_channel(struct mt76x02_dev *dev,
>  	mt76x02_phy_set_bw(dev, chandef->width, ch_group_index);
>  	mt76x02_phy_set_band(dev, chandef->chan->band,
>  			     ch_group_index & 1);
> -	mt76x0_phy_ant_select(dev);
>  
>  	mt76_rmw(dev, MT_EXT_CCA_CFG,
>  		 (MT_EXT_CCA_CFG_CCA0 |
> @@ -795,6 +820,7 @@ void mt76x0_phy_init(struct mt76x02_dev *dev)
>  {
>  	INIT_DELAYED_WORK(&dev->cal_work, mt76x0_phy_calibration_work);
>  
> +	mt76x0_phy_ant_select(dev);
>  	mt76x0_phy_rf_init(dev);
>  	mt76x02_phy_set_rxpath(dev);
>  	mt76x02_phy_set_txdac(dev);
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h b/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h
> index b3ec74835d10..1de041590050 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h
> @@ -25,6 +25,7 @@ enum mt76x02_eeprom_field {
>  	MT_EE_VERSION =				0x002,
>  	MT_EE_MAC_ADDR =			0x004,
>  	MT_EE_PCI_ID =				0x00A,
> +	MT_EE_ANTENNA =				0x022,
>  	MT_EE_NIC_CONF_0 =			0x034,
>  	MT_EE_NIC_CONF_1 =			0x036,
>  	MT_EE_COUNTRY_REGION_5GHZ =		0x038,
> @@ -104,6 +105,8 @@ enum mt76x02_eeprom_field {
>  	__MT_EE_MAX
>  };
>  
> +#define MT_EE_ANTENNA_DUAL			BIT(15)
> +
>  #define MT_EE_NIC_CONF_0_RX_PATH		GENMASK(3, 0)
>  #define MT_EE_NIC_CONF_0_TX_PATH		GENMASK(7, 4)
>  #define MT_EE_NIC_CONF_0_PA_TYPE		GENMASK(9, 8)
> @@ -118,12 +121,9 @@ enum mt76x02_eeprom_field {
>  #define MT_EE_NIC_CONF_1_LNA_EXT_5G		BIT(3)
>  #define MT_EE_NIC_CONF_1_TX_ALC_EN		BIT(13)
>  
> -#define MT_EE_NIC_CONF_2_RX_STREAM		GENMASK(3, 0)
> -#define MT_EE_NIC_CONF_2_TX_STREAM		GENMASK(7, 4)
> -#define MT_EE_NIC_CONF_2_HW_ANTDIV		BIT(8)
> +#define MT_EE_NIC_CONF_2_ANT_OPT		BIT(3)
> +#define MT_EE_NIC_CONF_2_ANT_DIV		BIT(4)
>  #define MT_EE_NIC_CONF_2_XTAL_OPTION		GENMASK(10, 9)
> -#define MT_EE_NIC_CONF_2_TEMP_DISABLE		BIT(11)
> -#define MT_EE_NIC_CONF_2_COEX_METHOD		GENMASK(15, 13)
>  
>  #define MT_EFUSE_USAGE_MAP_SIZE			(MT_EE_USAGE_MAP_END - \
>  						 MT_EE_USAGE_MAP_START + 1)
> -- 
> 1.9.3
>
Stanislaw Gruszka Oct. 18, 2018, 9:21 a.m. UTC | #2
On Thu, Oct 18, 2018 at 11:13:36AM +0200, Lorenzo Bianconi wrote:
> >  static void mt76x0_phy_ant_select(struct mt76x02_dev *dev)
> >  {
> > -	struct ieee80211_channel *chan = dev->mt76.chandef.chan;
> > -
> > -	/* single antenna mode */
> > -	if (chan->band == NL80211_BAND_2GHZ) {
> > -		mt76_rmw(dev, MT_COEXCFG3,
> > -			 BIT(5) | BIT(4) | BIT(3) | BIT(2), BIT(1));
> > -		mt76_rmw(dev, MT_WLAN_FUN_CTRL, BIT(5), BIT(6));
> > +	u16 ee_ant = mt76x02_eeprom_get(dev, MT_EE_ANTENNA);
> > +	u16 nic_conf2 = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_2);
> > +	u32 wlan, coex3, cmb;
> > +	bool ant_div;
> > +
> > +	wlan = mt76_rr(dev, MT_WLAN_FUN_CTRL);
> > +	cmb = mt76_rr(dev, MT_CMB_CTRL);
> > +	coex3 = mt76_rr(dev, MT_COEXCFG3);
> > +
> > +	cmb   &= ~(BIT(15) | BIT(12));
> 
> I guess should be BIT(14) here (at least for single antenna mode)

Yes , I will fix it.

> > +	coex3 &= ~GENMASK(5, 1);
> 
> according to vendor sdk BIT(1) should not cleared if device supports 5GHz band
> (signle antenna mode)

It is set below for that case:

> > +		if (dev->mt76.cap.has_5ghz) {
> > +			coex3 |= BIT(3) | BIT(4);
> > +		} else {
> > +			wlan |= BIT(6);
> > +			coex3 |= BIT(1);
> > +		}


Thanks
Stanislaw
Lorenzo Bianconi Oct. 18, 2018, 9:28 a.m. UTC | #3
> On Thu, Oct 18, 2018 at 11:13:36AM +0200, Lorenzo Bianconi wrote:
> > >  static void mt76x0_phy_ant_select(struct mt76x02_dev *dev)
> > >  {
> > > -	struct ieee80211_channel *chan = dev->mt76.chandef.chan;
> > > -
> > > -	/* single antenna mode */
> > > -	if (chan->band == NL80211_BAND_2GHZ) {
> > > -		mt76_rmw(dev, MT_COEXCFG3,
> > > -			 BIT(5) | BIT(4) | BIT(3) | BIT(2), BIT(1));
> > > -		mt76_rmw(dev, MT_WLAN_FUN_CTRL, BIT(5), BIT(6));
> > > +	u16 ee_ant = mt76x02_eeprom_get(dev, MT_EE_ANTENNA);
> > > +	u16 nic_conf2 = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_2);
> > > +	u32 wlan, coex3, cmb;
> > > +	bool ant_div;
> > > +
> > > +	wlan = mt76_rr(dev, MT_WLAN_FUN_CTRL);
> > > +	cmb = mt76_rr(dev, MT_CMB_CTRL);
> > > +	coex3 = mt76_rr(dev, MT_COEXCFG3);
> > > +
> > > +	cmb   &= ~(BIT(15) | BIT(12));
> > 
> > I guess should be BIT(14) here (at least for single antenna mode)
> 
> Yes , I will fix it.
> 
> > > +	coex3 &= ~GENMASK(5, 1);
> > 
> > according to vendor sdk BIT(1) should not cleared if device supports 5GHz band
> > (signle antenna mode)
> 
> It is set below for that case:

it is set just if the device does not support 5GHz band but it is cleared in
the other case (and sdk driver does not clear it in that case, do not know if
it does a real difference)

Lorenzo

> 
> > > +		if (dev->mt76.cap.has_5ghz) {
> > > +			coex3 |= BIT(3) | BIT(4);
> > > +		} else {
> > > +			wlan |= BIT(6);
> > > +			coex3 |= BIT(1);
> > > +		}
> 
> 
> Thanks
> Stanislaw
Stanislaw Gruszka Oct. 18, 2018, 9:40 a.m. UTC | #4
On Thu, Oct 18, 2018 at 11:28:19AM +0200, Lorenzo Bianconi wrote:
> > On Thu, Oct 18, 2018 at 11:13:36AM +0200, Lorenzo Bianconi wrote:
> > > >  static void mt76x0_phy_ant_select(struct mt76x02_dev *dev)
> > > >  {
> > > > -	struct ieee80211_channel *chan = dev->mt76.chandef.chan;
> > > > -
> > > > -	/* single antenna mode */
> > > > -	if (chan->band == NL80211_BAND_2GHZ) {
> > > > -		mt76_rmw(dev, MT_COEXCFG3,
> > > > -			 BIT(5) | BIT(4) | BIT(3) | BIT(2), BIT(1));
> > > > -		mt76_rmw(dev, MT_WLAN_FUN_CTRL, BIT(5), BIT(6));
> > > > +	u16 ee_ant = mt76x02_eeprom_get(dev, MT_EE_ANTENNA);
> > > > +	u16 nic_conf2 = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_2);
> > > > +	u32 wlan, coex3, cmb;
> > > > +	bool ant_div;
> > > > +
> > > > +	wlan = mt76_rr(dev, MT_WLAN_FUN_CTRL);
> > > > +	cmb = mt76_rr(dev, MT_CMB_CTRL);
> > > > +	coex3 = mt76_rr(dev, MT_COEXCFG3);
> > > > +
> > > > +	cmb   &= ~(BIT(15) | BIT(12));
> > > 
> > > I guess should be BIT(14) here (at least for single antenna mode)
> > 
> > Yes , I will fix it.
> > 
> > > > +	coex3 &= ~GENMASK(5, 1);
> > > 
> > > according to vendor sdk BIT(1) should not cleared if device supports 5GHz band
> > > (signle antenna mode)
> > 
> > It is set below for that case:
> 
> it is set just if the device does not support 5GHz band but it is cleared in
> the other case (and sdk driver does not clear it in that case, do not know if
> it does a real difference)

On GPL realeased driver for MT7610U ( mt7610u_wifi_sta_v3002_dpo_2013091 )
it's like this:

        CoexCfg3 &= ~(BIT5 | BIT4 | BIT3 | BIT2 | BIT1);

	<snip>

        {
                if (WMODE_CAP_5G(pAd->CommonCfg.PhyMode))
                {
                        CoexCfg3 |= (BIT3 | BIT4); /* 0x4C[3]=1, 0x4C[4]=1 */
                }
                else
                {
                        WlanFunCtrl |= BIT6; /* 0x80[6]=1 */
                        CoexCfg3 |= BIT1; /* 0x4C[1]=1 */
                }
                DBGPRINT(RT_DEBUG_ERROR, ("%s - Single antenna mode\n", __FUNCTION__));
        }

Which I belive is reflected in my patch in this parts:

	coex3 &= ~GENMASK(5, 1);

	<snip>

	if (dev->mt76.cap.has_5ghz) {
		coex3 |= BIT(3) | BIT(4);
	} else {
		wlan |= BIT(6);
		coex3 |= BIT(1);
	}

Does your SDK do something diffrent ?

Thanks
Stanislaw
Lorenzo Bianconi Oct. 18, 2018, 9:45 a.m. UTC | #5
> On Thu, Oct 18, 2018 at 11:28:19AM +0200, Lorenzo Bianconi wrote:
> > > On Thu, Oct 18, 2018 at 11:13:36AM +0200, Lorenzo Bianconi wrote:
> > > > >  static void mt76x0_phy_ant_select(struct mt76x02_dev *dev)
> > > > >  {
> > > > > -	struct ieee80211_channel *chan = dev->mt76.chandef.chan;
> > > > > -
> > > > > -	/* single antenna mode */
> > > > > -	if (chan->band == NL80211_BAND_2GHZ) {
> > > > > -		mt76_rmw(dev, MT_COEXCFG3,
> > > > > -			 BIT(5) | BIT(4) | BIT(3) | BIT(2), BIT(1));
> > > > > -		mt76_rmw(dev, MT_WLAN_FUN_CTRL, BIT(5), BIT(6));
> > > > > +	u16 ee_ant = mt76x02_eeprom_get(dev, MT_EE_ANTENNA);
> > > > > +	u16 nic_conf2 = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_2);
> > > > > +	u32 wlan, coex3, cmb;
> > > > > +	bool ant_div;
> > > > > +
> > > > > +	wlan = mt76_rr(dev, MT_WLAN_FUN_CTRL);
> > > > > +	cmb = mt76_rr(dev, MT_CMB_CTRL);
> > > > > +	coex3 = mt76_rr(dev, MT_COEXCFG3);
> > > > > +
> > > > > +	cmb   &= ~(BIT(15) | BIT(12));
> > > > 
> > > > I guess should be BIT(14) here (at least for single antenna mode)
> > > 
> > > Yes , I will fix it.
> > > 
> > > > > +	coex3 &= ~GENMASK(5, 1);
> > > > 
> > > > according to vendor sdk BIT(1) should not cleared if device supports 5GHz band
> > > > (signle antenna mode)
> > > 
> > > It is set below for that case:
> > 
> > it is set just if the device does not support 5GHz band but it is cleared in
> > the other case (and sdk driver does not clear it in that case, do not know if
> > it does a real difference)
> 
> On GPL realeased driver for MT7610U ( mt7610u_wifi_sta_v3002_dpo_2013091 )
> it's like this:
> 
>         CoexCfg3 &= ~(BIT5 | BIT4 | BIT3 | BIT2 | BIT1);

here I have:

	CoexCfg3 &= ~(BIT5 | BIT4 | BIT3 | BIT2);

> 
> 	<snip>
> 
>         {
>                 if (WMODE_CAP_5G(pAd->CommonCfg.PhyMode))
>                 {
>                         CoexCfg3 |= (BIT3 | BIT4); /* 0x4C[3]=1, 0x4C[4]=1 */
>                 }
>                 else
>                 {
>                         WlanFunCtrl |= BIT6; /* 0x80[6]=1 */
>                         CoexCfg3 |= BIT1; /* 0x4C[1]=1 */
>                 }
>                 DBGPRINT(RT_DEBUG_ERROR, ("%s - Single antenna mode\n", __FUNCTION__));
>         }
> 
> Which I belive is reflected in my patch in this parts:
> 

correct :)

> 	coex3 &= ~GENMASK(5, 1);
> 
> 	<snip>
> 
> 	if (dev->mt76.cap.has_5ghz) {
> 		coex3 |= BIT(3) | BIT(4);
> 	} else {
> 		wlan |= BIT(6);
> 		coex3 |= BIT(1);
> 	}
> 
> Does your SDK do something diffrent ?
> 
> Thanks
> Stanislaw
Stanislaw Gruszka Oct. 18, 2018, 9:53 a.m. UTC | #6
On Thu, Oct 18, 2018 at 11:40:56AM +0200, Stanislaw Gruszka wrote:
> On GPL realeased driver for MT7610U ( mt7610u_wifi_sta_v3002_dpo_2013091 )
> it's like this:
> 
>         CoexCfg3 &= ~(BIT5 | BIT4 | BIT3 | BIT2 | BIT1);

<snip>
> Does your SDK do something diffrent ?
Ok I can see:

	CoexCfg3 &= ~(BIT5 | BIT4 | BIT3 | BIT2);

in
https://github.com/i80s/mtk-sources 
which is newer version of the driver, so preasumely BIT1
should not be cleared. Will fix that in the patch.

Thanks
Stanislaw
Lorenzo Bianconi Oct. 18, 2018, 9:54 a.m. UTC | #7
> On Thu, Oct 18, 2018 at 11:40:56AM +0200, Stanislaw Gruszka wrote:
> > On GPL realeased driver for MT7610U ( mt7610u_wifi_sta_v3002_dpo_2013091 )
> > it's like this:
> > 
> >         CoexCfg3 &= ~(BIT5 | BIT4 | BIT3 | BIT2 | BIT1);
> 
> <snip>
> > Does your SDK do something diffrent ?
> Ok I can see:
> 
> 	CoexCfg3 &= ~(BIT5 | BIT4 | BIT3 | BIT2);
> 
> in
> https://github.com/i80s/mtk-sources 
> which is newer version of the driver, so preasumely BIT1
> should not be cleared. Will fix that in the patch.

ack

Regards,
Lorenzo

> 
> Thanks
> Stanislaw
Lorenzo Bianconi Oct. 18, 2018, 10:02 a.m. UTC | #8
> On Thu, Oct 18, 2018 at 11:40:56AM +0200, Stanislaw Gruszka wrote:
> > On GPL realeased driver for MT7610U ( mt7610u_wifi_sta_v3002_dpo_2013091 )
> > it's like this:
> > 
> >         CoexCfg3 &= ~(BIT5 | BIT4 | BIT3 | BIT2 | BIT1);
> 
> <snip>
> > Does your SDK do something diffrent ?
> Ok I can see:
> 
> 	CoexCfg3 &= ~(BIT5 | BIT4 | BIT3 | BIT2);
> 
> in
> https://github.com/i80s/mtk-sources 
> which is newer version of the driver, so preasumely BIT1
> should not be cleared. Will fix that in the patch.
> 
> Thanks
> Stanislaw

Btw fixing that bits:

Acked-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
index 37e1ead1dc85..143cbe6d7899 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
@@ -431,21 +431,47 @@  int mt76x0_phy_wait_bbp_ready(struct mt76x02_dev *dev)
 
 static void mt76x0_phy_ant_select(struct mt76x02_dev *dev)
 {
-	struct ieee80211_channel *chan = dev->mt76.chandef.chan;
-
-	/* single antenna mode */
-	if (chan->band == NL80211_BAND_2GHZ) {
-		mt76_rmw(dev, MT_COEXCFG3,
-			 BIT(5) | BIT(4) | BIT(3) | BIT(2), BIT(1));
-		mt76_rmw(dev, MT_WLAN_FUN_CTRL, BIT(5), BIT(6));
+	u16 ee_ant = mt76x02_eeprom_get(dev, MT_EE_ANTENNA);
+	u16 nic_conf2 = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_2);
+	u32 wlan, coex3, cmb;
+	bool ant_div;
+
+	wlan = mt76_rr(dev, MT_WLAN_FUN_CTRL);
+	cmb = mt76_rr(dev, MT_CMB_CTRL);
+	coex3 = mt76_rr(dev, MT_COEXCFG3);
+
+	cmb   &= ~(BIT(15) | BIT(12));
+	wlan  &= ~(BIT(6) | BIT(5));
+	coex3 &= ~GENMASK(5, 1);
+
+	if (ee_ant & MT_EE_ANTENNA_DUAL) {
+		/* dual antenna mode */
+		ant_div = !(nic_conf2 & MT_EE_NIC_CONF_2_ANT_OPT) &&
+			  (nic_conf2 & MT_EE_NIC_CONF_2_ANT_DIV);
+		if (ant_div)
+			cmb |= BIT(12);
+		else
+			coex3 |= BIT(4);
+		coex3 |= BIT(3);
+		if (dev->mt76.cap.has_2ghz)
+			wlan |= BIT(6);
 	} else {
-		mt76_rmw(dev, MT_COEXCFG3, BIT(5) | BIT(2),
-			 BIT(4) | BIT(3));
-		mt76_clear(dev, MT_WLAN_FUN_CTRL,
-			   BIT(6) | BIT(5));
+		/* sigle antenna mode */
+		if (dev->mt76.cap.has_5ghz) {
+			coex3 |= BIT(3) | BIT(4);
+		} else {
+			wlan |= BIT(6);
+			coex3 |= BIT(1);
+		}
 	}
-	mt76_clear(dev, MT_CMB_CTRL, BIT(14) | BIT(12));
+
+	if (is_mt7630(dev))
+		cmb |= BIT(14) | BIT(11);
+
+	mt76_wr(dev, MT_WLAN_FUN_CTRL, wlan);
+	mt76_wr(dev, MT_CMB_CTRL, cmb);
 	mt76_clear(dev, MT_COEXCFG0, BIT(2));
+	mt76_wr(dev, MT_COEXCFG3, coex3);
 }
 
 static void
@@ -612,7 +638,6 @@  int mt76x0_phy_set_channel(struct mt76x02_dev *dev,
 	mt76x02_phy_set_bw(dev, chandef->width, ch_group_index);
 	mt76x02_phy_set_band(dev, chandef->chan->band,
 			     ch_group_index & 1);
-	mt76x0_phy_ant_select(dev);
 
 	mt76_rmw(dev, MT_EXT_CCA_CFG,
 		 (MT_EXT_CCA_CFG_CCA0 |
@@ -795,6 +820,7 @@  void mt76x0_phy_init(struct mt76x02_dev *dev)
 {
 	INIT_DELAYED_WORK(&dev->cal_work, mt76x0_phy_calibration_work);
 
+	mt76x0_phy_ant_select(dev);
 	mt76x0_phy_rf_init(dev);
 	mt76x02_phy_set_rxpath(dev);
 	mt76x02_phy_set_txdac(dev);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h b/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h
index b3ec74835d10..1de041590050 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h
@@ -25,6 +25,7 @@  enum mt76x02_eeprom_field {
 	MT_EE_VERSION =				0x002,
 	MT_EE_MAC_ADDR =			0x004,
 	MT_EE_PCI_ID =				0x00A,
+	MT_EE_ANTENNA =				0x022,
 	MT_EE_NIC_CONF_0 =			0x034,
 	MT_EE_NIC_CONF_1 =			0x036,
 	MT_EE_COUNTRY_REGION_5GHZ =		0x038,
@@ -104,6 +105,8 @@  enum mt76x02_eeprom_field {
 	__MT_EE_MAX
 };
 
+#define MT_EE_ANTENNA_DUAL			BIT(15)
+
 #define MT_EE_NIC_CONF_0_RX_PATH		GENMASK(3, 0)
 #define MT_EE_NIC_CONF_0_TX_PATH		GENMASK(7, 4)
 #define MT_EE_NIC_CONF_0_PA_TYPE		GENMASK(9, 8)
@@ -118,12 +121,9 @@  enum mt76x02_eeprom_field {
 #define MT_EE_NIC_CONF_1_LNA_EXT_5G		BIT(3)
 #define MT_EE_NIC_CONF_1_TX_ALC_EN		BIT(13)
 
-#define MT_EE_NIC_CONF_2_RX_STREAM		GENMASK(3, 0)
-#define MT_EE_NIC_CONF_2_TX_STREAM		GENMASK(7, 4)
-#define MT_EE_NIC_CONF_2_HW_ANTDIV		BIT(8)
+#define MT_EE_NIC_CONF_2_ANT_OPT		BIT(3)
+#define MT_EE_NIC_CONF_2_ANT_DIV		BIT(4)
 #define MT_EE_NIC_CONF_2_XTAL_OPTION		GENMASK(10, 9)
-#define MT_EE_NIC_CONF_2_TEMP_DISABLE		BIT(11)
-#define MT_EE_NIC_CONF_2_COEX_METHOD		GENMASK(15, 13)
 
 #define MT_EFUSE_USAGE_MAP_SIZE			(MT_EE_USAGE_MAP_END - \
 						 MT_EE_USAGE_MAP_START + 1)