Commit 4c430774 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau
Browse files

mt76: mt7915: introduce dbdc support



Introduce mt7915 dbdc support. If dbdc is available, mt7915 primary phy
will work on 2.4GHz band, while secondary one on 5GHz band.

Co-developed-by: default avatarShayne Chen <shayne.chen@mediatek.com>
Signed-off-by: default avatarShayne Chen <shayne.chen@mediatek.com>
Co-developed-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 98df2bae
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ enum mt76_rxq_id {
	MT_RXQ_MAIN,
	MT_RXQ_MCU,
	MT_RXQ_MCU_WA,
	MT_RXQ_EXT,
	__MT_RXQ_MAX
};

+10 −3
Original line number Diff line number Diff line
@@ -280,10 +280,14 @@ static int
mt7915_queues_read(struct seq_file *s, void *data)
{
	struct mt7915_dev *dev = dev_get_drvdata(s->private);
	struct mt76_phy *mphy_ext = dev->mt76.phy2;
	struct mt76_queue *ext_q = mphy_ext ? mphy_ext->q_tx[MT_TXQ_BE] : NULL;
	struct {
		struct mt76_queue *q;
		char *queue;
	} queue_map[] = {
		{ dev->mphy.q_tx[MT_TXQ_BE],	 "WFDMA0" },
		{ ext_q,			 "WFDMA1" },
		{ dev->mphy.q_tx[MT_TXQ_BE],	 "WFDMA0" },
		{ dev->mt76.q_mcu[MT_MCUQ_WM],	 "MCUWM"  },
		{ dev->mt76.q_mcu[MT_MCUQ_WA],	 "MCUWA"  },
@@ -294,6 +298,9 @@ mt7915_queues_read(struct seq_file *s, void *data)
	for (i = 0; i < ARRAY_SIZE(queue_map); i++) {
		struct mt76_queue *q = queue_map[i].q;

		if (!q)
			continue;

		seq_printf(s,
			   "%s:	queued=%d head=%d tail=%d\n",
			   queue_map[i].queue, q->queued, q->head,
+13 −6
Original line number Diff line number Diff line
@@ -5,8 +5,7 @@
#include "../dma.h"
#include "mac.h"

static int
mt7915_init_tx_queues(struct mt7915_phy *phy, int idx, int n_desc)
int mt7915_init_tx_queues(struct mt7915_phy *phy, int idx, int n_desc)
{
	int i, err;

@@ -274,13 +273,21 @@ int mt7915_dma_init(struct mt7915_dev *dev)
	if (ret)
		return ret;

	/* rx data */
	ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_MAIN], 0,
			       MT7915_RX_RING_SIZE, rx_buf_size,
			       MT_RX_DATA_RING_BASE);
	/* rx data queue */
	ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_MAIN],
			       MT7915_RXQ_BAND0, MT7915_RX_RING_SIZE,
			       rx_buf_size, MT_RX_DATA_RING_BASE);
	if (ret)
		return ret;

	if (dev->dbdc_support) {
		ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_EXT],
				       MT7915_RXQ_BAND1, MT7915_RX_RING_SIZE,
				       rx_buf_size, MT_RX_DATA_RING_BASE);
		if (ret)
			return ret;
	}

	ret = mt76_init_queues(dev);
	if (ret < 0)
		return ret;
+31 −16
Original line number Diff line number Diff line
@@ -43,35 +43,50 @@ static int mt7915_check_eeprom(struct mt7915_dev *dev)
	}
}

static void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev)
void mt7915_eeprom_parse_band_config(struct mt7915_phy *phy)
{
	u8 *eeprom = dev->mt76.eeprom.data;
	u8 tx_mask, max_nss = 4;
	u32 val = mt7915_eeprom_read(dev, MT_EE_WIFI_CONF);
	struct mt7915_dev *dev = phy->dev;
	bool ext_phy = phy != &dev->phy;
	u32 val;

	val = mt7915_eeprom_read(dev, MT_EE_WIFI_CONF + ext_phy);
	val = FIELD_GET(MT_EE_WIFI_CONF_BAND_SEL, val);
	switch (val) {
	case MT_EE_5GHZ:
		dev->mphy.cap.has_5ghz = true;
		phy->mt76->cap.has_5ghz = true;
		break;
	case MT_EE_2GHZ:
		dev->mphy.cap.has_2ghz = true;
		phy->mt76->cap.has_2ghz = true;
		break;
	default:
		dev->mphy.cap.has_2ghz = true;
		dev->mphy.cap.has_5ghz = true;
		phy->mt76->cap.has_2ghz = true;
		phy->mt76->cap.has_5ghz = true;
		break;
	}
}

static void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev)
{
	u8 nss, tx_mask[2] = {}, *eeprom = dev->mt76.eeprom.data;

	mt7915_eeprom_parse_band_config(&dev->phy);

	/* read tx mask from eeprom */
	tx_mask =  FIELD_GET(MT_EE_WIFI_CONF_TX_MASK,
	tx_mask[0] = FIELD_GET(MT_EE_WIFI_CONF_TX_MASK,
			       eeprom[MT_EE_WIFI_CONF]);
	if (!tx_mask || tx_mask > max_nss)
		tx_mask = max_nss;
	if (dev->dbdc_support)
		tx_mask[1] = FIELD_GET(MT_EE_WIFI_CONF_TX_MASK,
				       eeprom[MT_EE_WIFI_CONF + 1]);

	nss = tx_mask[0] + tx_mask[1];
	if (!nss || nss > 4) {
		tx_mask[0] = 4;
		nss = 4;
	}

	dev->chainmask = BIT(tx_mask) - 1;
	dev->mphy.antenna_mask = dev->chainmask;
	dev->phy.chainmask = dev->chainmask;
	dev->chainmask = BIT(nss) - 1;
	dev->mphy.antenna_mask = BIT(tx_mask[0]) - 1;
	dev->phy.chainmask = dev->mphy.antenna_mask;
}

int mt7915_eeprom_init(struct mt7915_dev *dev)
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ enum mt7915_eeprom_field {
	MT_EE_CHIP_ID =		0x000,
	MT_EE_VERSION =		0x002,
	MT_EE_MAC_ADDR =	0x004,
	MT_EE_MAC_ADDR2 =	0x00a,
	MT_EE_DDIE_FT_VERSION =	0x050,
	MT_EE_WIFI_CONF =	0x190,
	MT_EE_TX0_POWER_2G =	0x2fc,
Loading