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

wifi: mt76: move wed reset common code in mt76 module



Move WED reset code shared between mt7915 and mt7996 in common module.
This is a preliminary patch to introduce WED reset support for mt7996.

Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 950d0abb
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1036,6 +1036,20 @@ void mt76_dma_attach(struct mt76_dev *dev)
}
EXPORT_SYMBOL_GPL(mt76_dma_attach);

void mt76_dma_wed_reset(struct mt76_dev *dev)
{
	struct mt76_mmio *mmio = &dev->mmio;

	if (!test_bit(MT76_STATE_WED_RESET, &dev->phy.state))
		return;

	complete(&mmio->wed_reset);

	if (!wait_for_completion_timeout(&mmio->wed_reset_complete, 3 * HZ))
		dev_err(dev->dev, "wed reset complete timeout\n");
}
EXPORT_SYMBOL_GPL(mt76_dma_wed_reset);

void mt76_dma_cleanup(struct mt76_dev *dev)
{
	int i;
+9 −0
Original line number Diff line number Diff line
@@ -78,6 +78,15 @@ int mt76_dma_rx_poll(struct napi_struct *napi, int budget);
void mt76_dma_attach(struct mt76_dev *dev);
void mt76_dma_cleanup(struct mt76_dev *dev);
int mt76_dma_wed_setup(struct mt76_dev *dev, struct mt76_queue *q, bool reset);
void mt76_dma_wed_reset(struct mt76_dev *dev);

static inline void
mt76_dma_reset_tx_queue(struct mt76_dev *dev, struct mt76_queue *q)
{
	dev->queue_ops->reset_q(dev, q);
	if (mtk_wed_device_active(&dev->mmio.wed))
		mt76_dma_wed_setup(dev, q, true);
}

static inline void
mt76_dma_should_drop_buf(bool *drop, u32 ctrl, u32 buf1, u32 info)
+8 −0
Original line number Diff line number Diff line
@@ -179,6 +179,14 @@ void mt76_mmio_wed_offload_disable(struct mtk_wed_device *wed)
	spin_unlock_bh(&dev->token_lock);
}
EXPORT_SYMBOL_GPL(mt76_mmio_wed_offload_disable);

void mt76_mmio_wed_reset_complete(struct mtk_wed_device *wed)
{
	struct mt76_dev *dev = container_of(wed, struct mt76_dev, mmio.wed);

	complete(&dev->mmio.wed_reset_complete);
}
EXPORT_SYMBOL_GPL(mt76_mmio_wed_reset_complete);
#endif /*CONFIG_NET_MEDIATEK_SOC_WED */

void mt76_mmio_init(struct mt76_dev *dev, void __iomem *regs)
+1 −0
Original line number Diff line number Diff line
@@ -1102,6 +1102,7 @@ u32 mt76_mmio_wed_init_rx_buf(struct mtk_wed_device *wed, int size);
void mt76_mmio_wed_release_rx_buf(struct mtk_wed_device *wed);
int mt76_mmio_wed_offload_enable(struct mtk_wed_device *wed);
void mt76_mmio_wed_offload_disable(struct mtk_wed_device *wed);
void mt76_mmio_wed_reset_complete(struct mtk_wed_device *wed);
#endif /*CONFIG_NET_MEDIATEK_SOC_WED */

#define mt76xx_chip(dev) mt76_chip(&((dev)->mt76))
+3 −25
Original line number Diff line number Diff line
@@ -587,28 +587,6 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2)
	return 0;
}

static void mt7915_dma_wed_reset(struct mt7915_dev *dev)
{
	struct mt76_dev *mdev = &dev->mt76;

	if (!test_bit(MT76_STATE_WED_RESET, &dev->mphy.state))
		return;

	complete(&mdev->mmio.wed_reset);

	if (!wait_for_completion_timeout(&dev->mt76.mmio.wed_reset_complete,
					 3 * HZ))
		dev_err(dev->mt76.dev, "wed reset complete timeout\n");
}

static void
mt7915_dma_reset_tx_queue(struct mt7915_dev *dev, struct mt76_queue *q)
{
	mt76_queue_reset(dev, q);
	if (mtk_wed_device_active(&dev->mt76.mmio.wed))
		mt76_dma_wed_setup(&dev->mt76, q, true);
}

int mt7915_dma_reset(struct mt7915_dev *dev, bool force)
{
	struct mt76_phy *mphy_ext = dev->mt76.phys[MT_BAND1];
@@ -636,13 +614,13 @@ int mt7915_dma_reset(struct mt7915_dev *dev, bool force)
		mtk_wed_device_dma_reset(wed);

	mt7915_dma_disable(dev, force);
	mt7915_dma_wed_reset(dev);
	mt76_dma_wed_reset(&dev->mt76);

	/* reset hw queues */
	for (i = 0; i < __MT_TXQ_MAX; i++) {
		mt7915_dma_reset_tx_queue(dev, dev->mphy.q_tx[i]);
		mt76_dma_reset_tx_queue(&dev->mt76, dev->mphy.q_tx[i]);
		if (mphy_ext)
			mt7915_dma_reset_tx_queue(dev, mphy_ext->q_tx[i]);
			mt76_dma_reset_tx_queue(&dev->mt76, mphy_ext->q_tx[i]);
	}

	for (i = 0; i < __MT_MCUQ_MAX; i++)
Loading