Lines Matching +full:wed +full:- +full:pcie

1 // SPDX-License-Identifier: ISC
95 { 0x74030000, 0x10000, 0x1000 }, /* PCIe MAC */
143 dev->bus_ops->rmw(&dev->mt76, MT_HIF_REMAP_L1, in mt7996_reg_map_l1()
147 dev->bus_ops->rr(&dev->mt76, MT_HIF_REMAP_L1); in mt7996_reg_map_l1()
157 dev->bus_ops->rmw(&dev->mt76, MT_HIF_REMAP_L2, in mt7996_reg_map_l2()
161 dev->bus_ops->rr(&dev->mt76, MT_HIF_REMAP_L2); in mt7996_reg_map_l2()
173 for (i = 0; i < dev->reg.map_size; i++) { in __mt7996_reg_addr()
176 if (addr < dev->reg.map[i].phys) in __mt7996_reg_addr()
179 ofs = addr - dev->reg.map[i].phys; in __mt7996_reg_addr()
180 if (ofs > dev->reg.map[i].size) in __mt7996_reg_addr()
183 return dev->reg.map[i].mapped + ofs; in __mt7996_reg_addr()
196 if (dev_is_pci(dev->mt76.dev) && in __mt7996_reg_remap_addr()
203 addr = addr - MT_INFRA_MCU_START + MT_INFRA_BASE; in __mt7996_reg_remap_addr()
216 memcpy_fromio(buf, dev->mt76.mmio.regs + addr, len); in mt7996_memcpy_fromio()
220 spin_lock_bh(&dev->reg_lock); in mt7996_memcpy_fromio()
221 memcpy_fromio(buf, dev->mt76.mmio.regs + in mt7996_memcpy_fromio()
223 spin_unlock_bh(&dev->reg_lock); in mt7996_memcpy_fromio()
232 return dev->bus_ops->rr(mdev, addr); in mt7996_rr()
234 spin_lock_bh(&dev->reg_lock); in mt7996_rr()
235 val = dev->bus_ops->rr(mdev, __mt7996_reg_remap_addr(dev, offset)); in mt7996_rr()
236 spin_unlock_bh(&dev->reg_lock); in mt7996_rr()
247 dev->bus_ops->wr(mdev, addr, val); in mt7996_wr()
251 spin_lock_bh(&dev->reg_lock); in mt7996_wr()
252 dev->bus_ops->wr(mdev, __mt7996_reg_remap_addr(dev, offset), val); in mt7996_wr()
253 spin_unlock_bh(&dev->reg_lock); in mt7996_wr()
262 return dev->bus_ops->rmw(mdev, addr, mask, val); in mt7996_rmw()
264 spin_lock_bh(&dev->reg_lock); in mt7996_rmw()
265 val = dev->bus_ops->rmw(mdev, __mt7996_reg_remap_addr(dev, offset), mask, val); in mt7996_rmw()
266 spin_unlock_bh(&dev->reg_lock); in mt7996_rmw()
272 static int mt7996_mmio_wed_reset(struct mtk_wed_device *wed) in mt7996_mmio_wed_reset() argument
274 struct mt76_dev *mdev = container_of(wed, struct mt76_dev, mmio.wed); in mt7996_mmio_wed_reset()
276 struct mt76_phy *mphy = &dev->mphy; in mt7996_mmio_wed_reset()
281 if (test_and_set_bit(MT76_STATE_WED_RESET, &mphy->state)) in mt7996_mmio_wed_reset()
282 return -EBUSY; in mt7996_mmio_wed_reset()
285 mphy->band_idx); in mt7996_mmio_wed_reset()
290 if (!wait_for_completion_timeout(&mdev->mmio.wed_reset, 20 * HZ)) { in mt7996_mmio_wed_reset()
291 dev_err(mdev->dev, "wed reset timeout\n"); in mt7996_mmio_wed_reset()
292 ret = -ETIMEDOUT; in mt7996_mmio_wed_reset()
296 clear_bit(MT76_STATE_WED_RESET, &mphy->state); in mt7996_mmio_wed_reset()
306 struct mtk_wed_device *wed = &dev->mt76.mmio.wed; in mt7996_mmio_wed_init() local
313 dev->has_rro = true; in mt7996_mmio_wed_init()
315 hif1_ofs = MT_WFDMA0_PCIE1(0) - MT_WFDMA0(0); in mt7996_mmio_wed_init()
318 wed = &dev->mt76.mmio.wed_hif2; in mt7996_mmio_wed_init()
320 wed->wlan.pci_dev = pci_dev; in mt7996_mmio_wed_init()
321 wed->wlan.bus_type = MTK_WED_BUS_PCIE; in mt7996_mmio_wed_init()
323 wed->wlan.base = devm_ioremap(dev->mt76.dev, in mt7996_mmio_wed_init()
326 wed->wlan.phy_base = pci_resource_start(pci_dev, 0); in mt7996_mmio_wed_init()
329 wed->wlan.wpdma_int = wed->wlan.phy_base + in mt7996_mmio_wed_init()
331 wed->wlan.wpdma_mask = wed->wlan.phy_base + in mt7996_mmio_wed_init()
333 wed->wlan.wpdma_tx = wed->wlan.phy_base + hif1_ofs + in mt7996_mmio_wed_init()
336 if (dev->has_rro) { in mt7996_mmio_wed_init()
337 wed->wlan.wpdma_txfree = wed->wlan.phy_base + hif1_ofs + in mt7996_mmio_wed_init()
340 wed->wlan.txfree_tbit = ffs(MT_INT_RX_TXFREE_EXT) - 1; in mt7996_mmio_wed_init()
342 wed->wlan.wpdma_txfree = wed->wlan.phy_base + hif1_ofs + in mt7996_mmio_wed_init()
345 wed->wlan.txfree_tbit = ffs(MT_INT_RX_DONE_WA_TRI) - 1; in mt7996_mmio_wed_init()
348 wed->wlan.wpdma_rx_glo = wed->wlan.phy_base + hif1_ofs + MT_WFDMA0_GLO_CFG; in mt7996_mmio_wed_init()
349 wed->wlan.wpdma_rx = wed->wlan.phy_base + hif1_ofs + in mt7996_mmio_wed_init()
353 wed->wlan.id = 0x7991; in mt7996_mmio_wed_init()
354 wed->wlan.tx_tbit[0] = ffs(MT_INT_TX_DONE_BAND2) - 1; in mt7996_mmio_wed_init()
356 wed->wlan.hw_rro = dev->has_rro; /* default on */ in mt7996_mmio_wed_init()
357 wed->wlan.wpdma_int = wed->wlan.phy_base + MT_INT_SOURCE_CSR; in mt7996_mmio_wed_init()
358 wed->wlan.wpdma_mask = wed->wlan.phy_base + MT_INT_MASK_CSR; in mt7996_mmio_wed_init()
359 wed->wlan.wpdma_tx = wed->wlan.phy_base + MT_TXQ_RING_BASE(0) + in mt7996_mmio_wed_init()
362 wed->wlan.wpdma_rx_glo = wed->wlan.phy_base + MT_WFDMA0_GLO_CFG; in mt7996_mmio_wed_init()
364 wed->wlan.wpdma_rx = wed->wlan.phy_base + in mt7996_mmio_wed_init()
368 wed->wlan.wpdma_rx_rro[0] = wed->wlan.phy_base + in mt7996_mmio_wed_init()
371 wed->wlan.wpdma_rx_rro[1] = wed->wlan.phy_base + hif1_ofs + in mt7996_mmio_wed_init()
374 wed->wlan.wpdma_rx_pg = wed->wlan.phy_base + in mt7996_mmio_wed_init()
378 wed->wlan.rx_nbuf = 65536; in mt7996_mmio_wed_init()
379 wed->wlan.rx_npkt = dev->hif2 ? 32768 : 24576; in mt7996_mmio_wed_init()
380 wed->wlan.rx_size = SKB_WITH_OVERHEAD(MT_RX_BUF_SIZE); in mt7996_mmio_wed_init()
382 wed->wlan.rx_tbit[0] = ffs(MT_INT_RX_DONE_BAND0) - 1; in mt7996_mmio_wed_init()
383 wed->wlan.rx_tbit[1] = ffs(MT_INT_RX_DONE_BAND2) - 1; in mt7996_mmio_wed_init()
385 wed->wlan.rro_rx_tbit[0] = ffs(MT_INT_RX_DONE_RRO_BAND0) - 1; in mt7996_mmio_wed_init()
386 wed->wlan.rro_rx_tbit[1] = ffs(MT_INT_RX_DONE_RRO_BAND2) - 1; in mt7996_mmio_wed_init()
388 wed->wlan.rx_pg_tbit[0] = ffs(MT_INT_RX_DONE_MSDU_PG_BAND0) - 1; in mt7996_mmio_wed_init()
389 wed->wlan.rx_pg_tbit[1] = ffs(MT_INT_RX_DONE_MSDU_PG_BAND1) - 1; in mt7996_mmio_wed_init()
390 wed->wlan.rx_pg_tbit[2] = ffs(MT_INT_RX_DONE_MSDU_PG_BAND2) - 1; in mt7996_mmio_wed_init()
392 wed->wlan.tx_tbit[0] = ffs(MT_INT_TX_DONE_BAND0) - 1; in mt7996_mmio_wed_init()
393 wed->wlan.tx_tbit[1] = ffs(MT_INT_TX_DONE_BAND1) - 1; in mt7996_mmio_wed_init()
394 if (dev->has_rro) { in mt7996_mmio_wed_init()
395 wed->wlan.wpdma_txfree = wed->wlan.phy_base + MT_RXQ_RING_BASE(0) + in mt7996_mmio_wed_init()
397 wed->wlan.txfree_tbit = ffs(MT_INT_RX_TXFREE_MAIN) - 1; in mt7996_mmio_wed_init()
399 wed->wlan.txfree_tbit = ffs(MT_INT_RX_DONE_WA_MAIN) - 1; in mt7996_mmio_wed_init()
400 wed->wlan.wpdma_txfree = wed->wlan.phy_base + MT_RXQ_RING_BASE(0) + in mt7996_mmio_wed_init()
403 dev->mt76.rx_token_size = MT7996_TOKEN_SIZE + wed->wlan.rx_npkt; in mt7996_mmio_wed_init()
406 wed->wlan.nbuf = MT7996_HW_TOKEN_SIZE; in mt7996_mmio_wed_init()
407 wed->wlan.token_start = MT7996_TOKEN_SIZE - wed->wlan.nbuf; in mt7996_mmio_wed_init()
409 wed->wlan.amsdu_max_subframes = 8; in mt7996_mmio_wed_init()
410 wed->wlan.amsdu_max_len = 1536; in mt7996_mmio_wed_init()
412 wed->wlan.init_buf = mt7996_wed_init_buf; in mt7996_mmio_wed_init()
413 wed->wlan.init_rx_buf = mt76_wed_init_rx_buf; in mt7996_mmio_wed_init()
414 wed->wlan.release_rx_buf = mt76_wed_release_rx_buf; in mt7996_mmio_wed_init()
415 wed->wlan.offload_enable = mt76_wed_offload_enable; in mt7996_mmio_wed_init()
416 wed->wlan.offload_disable = mt76_wed_offload_disable; in mt7996_mmio_wed_init()
418 wed->wlan.reset = mt7996_mmio_wed_reset; in mt7996_mmio_wed_init()
419 wed->wlan.reset_complete = mt76_wed_reset_complete; in mt7996_mmio_wed_init()
422 if (mtk_wed_device_attach(wed)) in mt7996_mmio_wed_init()
425 *irq = wed->irq; in mt7996_mmio_wed_init()
426 dev->mt76.dma_dev = wed->dev; in mt7996_mmio_wed_init()
442 mt76_mmio_init(&dev->mt76, mem_base); in mt7996_mmio_init()
443 spin_lock_init(&dev->reg_lock); in mt7996_mmio_init()
447 dev->reg.base = mt7996_reg_base; in mt7996_mmio_init()
448 dev->reg.offs_rev = mt7996_offs; in mt7996_mmio_init()
449 dev->reg.map = mt7996_reg_map; in mt7996_mmio_init()
450 dev->reg.map_size = ARRAY_SIZE(mt7996_reg_map); in mt7996_mmio_init()
453 dev->reg.base = mt7996_reg_base; in mt7996_mmio_init()
454 dev->reg.offs_rev = mt7992_offs; in mt7996_mmio_init()
455 dev->reg.map = mt7996_reg_map; in mt7996_mmio_init()
456 dev->reg.map_size = ARRAY_SIZE(mt7996_reg_map); in mt7996_mmio_init()
459 return -EINVAL; in mt7996_mmio_init()
462 dev->bus_ops = dev->mt76.bus; in mt7996_mmio_init()
463 bus_ops = devm_kmemdup(dev->mt76.dev, dev->bus_ops, sizeof(*bus_ops), in mt7996_mmio_init()
466 return -ENOMEM; in mt7996_mmio_init()
468 bus_ops->rr = mt7996_rr; in mt7996_mmio_init()
469 bus_ops->wr = mt7996_wr; in mt7996_mmio_init()
470 bus_ops->rmw = mt7996_rmw; in mt7996_mmio_init()
471 dev->mt76.bus = bus_ops; in mt7996_mmio_init()
473 mdev->rev = (device_id << 16) | (mt76_rr(dev, MT_HW_REV) & 0xff); in mt7996_mmio_init()
475 dev_dbg(mdev->dev, "ASIC revision: %04x\n", mdev->rev); in mt7996_mmio_init()
483 struct mt76_dev *mdev = &dev->mt76; in mt7996_dual_hif_set_irq_mask()
486 spin_lock_irqsave(&mdev->mmio.irq_lock, flags); in mt7996_dual_hif_set_irq_mask()
488 mdev->mmio.irqmask &= ~clear; in mt7996_dual_hif_set_irq_mask()
489 mdev->mmio.irqmask |= set; in mt7996_dual_hif_set_irq_mask()
492 if (mtk_wed_device_active(&mdev->mmio.wed)) { in mt7996_dual_hif_set_irq_mask()
493 mtk_wed_device_irq_set_mask(&mdev->mmio.wed, in mt7996_dual_hif_set_irq_mask()
494 mdev->mmio.irqmask); in mt7996_dual_hif_set_irq_mask()
495 if (mtk_wed_device_active(&mdev->mmio.wed_hif2)) { in mt7996_dual_hif_set_irq_mask()
496 mtk_wed_device_irq_set_mask(&mdev->mmio.wed_hif2, in mt7996_dual_hif_set_irq_mask()
497 mdev->mmio.irqmask); in mt7996_dual_hif_set_irq_mask()
500 mt76_wr(dev, MT_INT_MASK_CSR, mdev->mmio.irqmask); in mt7996_dual_hif_set_irq_mask()
501 mt76_wr(dev, MT_INT1_MASK_CSR, mdev->mmio.irqmask); in mt7996_dual_hif_set_irq_mask()
505 spin_unlock_irqrestore(&mdev->mmio.irq_lock, flags); in mt7996_dual_hif_set_irq_mask()
516 /* TODO: support 2/4/6/8 MSI-X vectors */
520 struct mtk_wed_device *wed = &dev->mt76.mmio.wed; in mt7996_irq_tasklet() local
521 struct mtk_wed_device *wed_hif2 = &dev->mt76.mmio.wed_hif2; in mt7996_irq_tasklet()
524 if (dev->hif2 && mtk_wed_device_active(wed_hif2)) { in mt7996_irq_tasklet()
527 dev->mt76.mmio.irqmask); in mt7996_irq_tasklet()
529 napi_schedule(&dev->mt76.napi[MT_RXQ_TXFREE_BAND2]); in mt7996_irq_tasklet()
532 if (mtk_wed_device_active(wed)) { in mt7996_irq_tasklet()
533 mtk_wed_device_irq_set_mask(wed, 0); in mt7996_irq_tasklet()
534 intr = mtk_wed_device_irq_get(wed, dev->mt76.mmio.irqmask); in mt7996_irq_tasklet()
538 if (dev->hif2) in mt7996_irq_tasklet()
542 intr &= dev->mt76.mmio.irqmask; in mt7996_irq_tasklet()
544 if (dev->hif2) { in mt7996_irq_tasklet()
546 intr1 &= dev->mt76.mmio.irqmask; in mt7996_irq_tasklet()
552 trace_dev_irq(&dev->mt76, intr, dev->mt76.mmio.irqmask); in mt7996_irq_tasklet()
560 napi_schedule(&dev->mt76.tx_napi); in mt7996_irq_tasklet()
564 napi_schedule(&dev->mt76.napi[i]); in mt7996_irq_tasklet()
572 dev->recovery.state = val; in mt7996_irq_tasklet()
582 if (mtk_wed_device_active(&dev->mt76.mmio.wed)) in mt7996_irq_handler()
583 mtk_wed_device_irq_set_mask(&dev->mt76.mmio.wed, 0); in mt7996_irq_handler()
587 if (dev->hif2) { in mt7996_irq_handler()
588 if (mtk_wed_device_active(&dev->mt76.mmio.wed_hif2)) in mt7996_irq_handler()
589 mtk_wed_device_irq_set_mask(&dev->mt76.mmio.wed_hif2, 0); in mt7996_irq_handler()
594 if (!test_bit(MT76_STATE_INITIALIZED, &dev->mphy.state)) in mt7996_irq_handler()
597 tasklet_schedule(&dev->mt76.irq_tasklet); in mt7996_irq_handler()
631 return ERR_PTR(-ENOMEM); in mt7996_mmio_probe()
639 tasklet_setup(&mdev->irq_tasklet, mt7996_irq_tasklet); in mt7996_mmio_probe()
646 mt76_free_device(&dev->mt76); in mt7996_mmio_probe()