Lines Matching refs:dev
25 static int mt7925e_init_reset(struct mt792x_dev *dev) in mt7925e_init_reset() argument
27 return mt792x_wpdma_reset(dev, true); in mt7925e_init_reset()
30 static void mt7925e_unregister_device(struct mt792x_dev *dev) in mt7925e_unregister_device() argument
33 struct mt76_connac_pm *pm = &dev->pm; in mt7925e_unregister_device()
34 struct ieee80211_hw *hw = mt76_hw(dev); in mt7925e_unregister_device()
36 if (dev->phy.chip_cap & MT792x_CHIP_CAP_WF_RF_PIN_CTRL_EVT_EN) in mt7925e_unregister_device()
39 cancel_work_sync(&dev->init_work); in mt7925e_unregister_device()
40 mt76_unregister_device(&dev->mt76); in mt7925e_unregister_device()
41 mt76_for_each_q_rx(&dev->mt76, i) in mt7925e_unregister_device()
42 napi_disable(&dev->mt76.napi[i]); in mt7925e_unregister_device()
45 cancel_work_sync(&dev->reset_work); in mt7925e_unregister_device()
47 mt7925_tx_token_put(dev); in mt7925e_unregister_device()
48 __mt792x_mcu_drv_pmctrl(dev); in mt7925e_unregister_device()
49 mt792x_dma_cleanup(dev); in mt7925e_unregister_device()
50 mt792x_wfsys_reset(dev); in mt7925e_unregister_device()
51 skb_queue_purge(&dev->mt76.mcu.res_q); in mt7925e_unregister_device()
53 tasklet_disable(&dev->mt76.irq_tasklet); in mt7925e_unregister_device()
56 static void mt7925_reg_remap_restore(struct mt792x_dev *dev) in mt7925_reg_remap_restore() argument
59 if (unlikely(dev->backup_l1)) { in mt7925_reg_remap_restore()
60 dev->bus_ops->wr(&dev->mt76, MT_HIF_REMAP_L1, dev->backup_l1); in mt7925_reg_remap_restore()
61 dev->backup_l1 = 0; in mt7925_reg_remap_restore()
64 if (dev->backup_l2) { in mt7925_reg_remap_restore()
65 dev->bus_ops->wr(&dev->mt76, MT_HIF_REMAP_L2, dev->backup_l2); in mt7925_reg_remap_restore()
66 dev->backup_l2 = 0; in mt7925_reg_remap_restore()
70 static u32 mt7925_reg_map_l1(struct mt792x_dev *dev, u32 addr) in mt7925_reg_map_l1() argument
75 dev->backup_l1 = dev->bus_ops->rr(&dev->mt76, MT_HIF_REMAP_L1); in mt7925_reg_map_l1()
77 dev->bus_ops->rmw(&dev->mt76, MT_HIF_REMAP_L1, in mt7925_reg_map_l1()
82 dev->bus_ops->rr(&dev->mt76, MT_HIF_REMAP_L1); in mt7925_reg_map_l1()
87 static u32 mt7925_reg_map_l2(struct mt792x_dev *dev, u32 addr) in mt7925_reg_map_l2() argument
91 dev->backup_l2 = dev->bus_ops->rr(&dev->mt76, MT_HIF_REMAP_L1); in mt7925_reg_map_l2()
93 dev->bus_ops->rmw(&dev->mt76, MT_HIF_REMAP_L1, in mt7925_reg_map_l2()
97 dev->bus_ops->wr(&dev->mt76, MT_HIF_REMAP_L2, addr); in mt7925_reg_map_l2()
99 dev->bus_ops->rr(&dev->mt76, MT_HIF_REMAP_L1); in mt7925_reg_map_l2()
104 static u32 __mt7925_reg_addr(struct mt792x_dev *dev, u32 addr) in __mt7925_reg_addr() argument
165 mt7925_reg_remap_restore(dev); in __mt7925_reg_addr()
183 return mt7925_reg_map_l1(dev, addr); in __mt7925_reg_addr()
185 return mt7925_reg_map_l2(dev, addr); in __mt7925_reg_addr()
190 struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); in mt7925_rr() local
191 u32 addr = __mt7925_reg_addr(dev, offset); in mt7925_rr()
193 return dev->bus_ops->rr(mdev, addr); in mt7925_rr()
198 struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); in mt7925_wr() local
199 u32 addr = __mt7925_reg_addr(dev, offset); in mt7925_wr()
201 dev->bus_ops->wr(mdev, addr, val); in mt7925_wr()
206 struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); in mt7925_rmw() local
207 u32 addr = __mt7925_reg_addr(dev, offset); in mt7925_rmw()
209 return dev->bus_ops->rmw(mdev, addr, mask, val); in mt7925_rmw()
212 static int mt7925_dma_init(struct mt792x_dev *dev) in mt7925_dma_init() argument
216 mt76_dma_attach(&dev->mt76); in mt7925_dma_init()
218 ret = mt792x_dma_disable(dev, true); in mt7925_dma_init()
223 ret = mt76_connac_init_tx_queues(dev->phy.mt76, MT7925_TXQ_BAND0, in mt7925_dma_init()
229 mt76_wr(dev, MT_WFDMA0_TX_RING0_EXT_CTRL, 0x4); in mt7925_dma_init()
232 ret = mt76_init_mcu_queue(&dev->mt76, MT_MCUQ_WM, MT7925_TXQ_MCU_WM, in mt7925_dma_init()
238 ret = mt76_init_mcu_queue(&dev->mt76, MT_MCUQ_FWDL, MT7925_TXQ_FWDL, in mt7925_dma_init()
244 ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_MCU], in mt7925_dma_init()
251 ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_MAIN], in mt7925_dma_init()
257 ret = mt76_init_queues(dev, mt792x_poll_rx); in mt7925_dma_init()
261 netif_napi_add_tx(dev->mt76.tx_napi_dev, &dev->mt76.tx_napi, in mt7925_dma_init()
263 napi_enable(&dev->mt76.tx_napi); in mt7925_dma_init()
265 return mt792x_dma_enable(dev); in mt7925_dma_init()
310 struct mt792x_dev *dev; in mt7925_pci_probe() local
335 ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); in mt7925_pci_probe()
342 ops = mt792x_get_mac80211_ops(&pdev->dev, &mt7925_ops, in mt7925_pci_probe()
349 mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), ops, &drv_ops); in mt7925_pci_probe()
357 dev = container_of(mdev, struct mt792x_dev, mt76); in mt7925_pci_probe()
358 dev->fw_features = features; in mt7925_pci_probe()
359 dev->hif_ops = &mt7925_pcie_ops; in mt7925_pci_probe()
360 dev->irq_map = &irq_map; in mt7925_pci_probe()
361 mt76_mmio_init(&dev->mt76, pcim_iomap_table(pdev)[0]); in mt7925_pci_probe()
362 tasklet_init(&mdev->irq_tasklet, mt792x_irq_tasklet, (unsigned long)dev); in mt7925_pci_probe()
364 dev->phy.dev = dev; in mt7925_pci_probe()
365 dev->phy.mt76 = &dev->mt76.phy; in mt7925_pci_probe()
366 dev->mt76.phy.priv = &dev->phy; in mt7925_pci_probe()
367 dev->bus_ops = dev->mt76.bus; in mt7925_pci_probe()
368 bus_ops = devm_kmemdup(dev->mt76.dev, dev->bus_ops, sizeof(*bus_ops), in mt7925_pci_probe()
378 dev->mt76.bus = bus_ops; in mt7925_pci_probe()
381 dev->aspm_supported = true; in mt7925_pci_probe()
383 ret = __mt792x_mcu_fw_pmctrl(dev); in mt7925_pci_probe()
387 ret = __mt792xe_mcu_drv_pmctrl(dev); in mt7925_pci_probe()
391 mdev->rev = (mt76_rr(dev, MT_HW_CHIPID) << 16) | in mt7925_pci_probe()
392 (mt76_rr(dev, MT_HW_REV) & 0xff); in mt7925_pci_probe()
394 dev_info(mdev->dev, "ASIC revision: %04x\n", mdev->rev); in mt7925_pci_probe()
396 mt76_rmw_field(dev, MT_HW_EMI_CTL, MT_HW_EMI_CTL_SLPPROT_EN, 1); in mt7925_pci_probe()
398 ret = mt792x_wfsys_reset(dev); in mt7925_pci_probe()
402 mt76_wr(dev, irq_map.host_irq_enable, 0); in mt7925_pci_probe()
404 mt76_wr(dev, MT_PCIE_MAC_INT_ENABLE, 0xff); in mt7925_pci_probe()
406 ret = devm_request_irq(mdev->dev, pdev->irq, mt792x_irq_handler, in mt7925_pci_probe()
407 IRQF_SHARED, KBUILD_MODNAME, dev); in mt7925_pci_probe()
411 ret = mt7925_dma_init(dev); in mt7925_pci_probe()
415 ret = mt7925_register_device(dev); in mt7925_pci_probe()
422 devm_free_irq(&pdev->dev, pdev->irq, dev); in mt7925_pci_probe()
424 mt76_free_device(&dev->mt76); in mt7925_pci_probe()
434 struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); in mt7925_pci_remove() local
436 mt7925e_unregister_device(dev); in mt7925_pci_remove()
438 devm_free_irq(&pdev->dev, pdev->irq, dev); in mt7925_pci_remove()
439 mt76_free_device(&dev->mt76); in mt7925_pci_remove()
448 struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); in mt7925_pci_suspend() local
449 struct mt76_connac_pm *pm = &dev->pm; in mt7925_pci_suspend()
453 dev->hif_resumed = false; in mt7925_pci_suspend()
454 flush_work(&dev->reset_work); in mt7925_pci_suspend()
458 mt7925_roc_abort_sync(dev); in mt7925_pci_suspend()
460 err = mt792x_mcu_drv_pmctrl(dev); in mt7925_pci_suspend()
464 wait_event_timeout(dev->wait, in mt7925_pci_suspend()
465 !dev->regd_in_progress, 5 * HZ); in mt7925_pci_suspend()
470 mt7925_mcu_set_deep_sleep(dev, true); in mt7925_pci_suspend()
473 ret = wait_event_timeout(dev->wait, in mt7925_pci_suspend()
474 dev->hif_idle, 3 * HZ); in mt7925_pci_suspend()
488 mt76_poll(dev, MT_WFDMA0_GLO_CFG, in mt7925_pci_suspend()
493 mt76_clear(dev, MT_WFDMA0_GLO_CFG, in mt7925_pci_suspend()
497 mt76_wr(dev, dev->irq_map->host_irq_enable, 0); in mt7925_pci_suspend()
499 mt76_wr(dev, MT_PCIE_MAC_INT_ENABLE, 0x0); in mt7925_pci_suspend()
504 err = mt792x_mcu_fw_pmctrl(dev); in mt7925_pci_suspend()
517 mt7925_mcu_set_deep_sleep(dev, false); in mt7925_pci_suspend()
520 ret = wait_event_timeout(dev->wait, in mt7925_pci_suspend()
521 dev->hif_resumed, 3 * HZ); in mt7925_pci_suspend()
528 mt792x_reset(&dev->mt76); in mt7925_pci_suspend()
537 struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); in mt7925_pci_resume() local
538 struct mt76_connac_pm *pm = &dev->pm; in mt7925_pci_resume()
541 dev->hif_idle = false; in mt7925_pci_resume()
542 err = mt792x_mcu_drv_pmctrl(dev); in mt7925_pci_resume()
546 mt792x_wpdma_reinit_cond(dev); in mt7925_pci_resume()
549 mt76_wr(dev, MT_PCIE_MAC_INT_ENABLE, 0xff); in mt7925_pci_resume()
550 mt76_connac_irq_enable(&dev->mt76, in mt7925_pci_resume()
551 dev->irq_map->tx.all_complete_mask | in mt7925_pci_resume()
553 mt76_set(dev, MT_MCU2HOST_SW_INT_ENA, MT_MCU_CMD_WAKE_RX_PCIE); in mt7925_pci_resume()
556 mt76_set(dev, MT_WFDMA0_GLO_CFG, in mt7925_pci_resume()
574 ret = wait_event_timeout(dev->wait, in mt7925_pci_resume()
575 dev->hif_resumed, 3 * HZ); in mt7925_pci_resume()
583 mt7925_mcu_set_deep_sleep(dev, false); in mt7925_pci_resume()
585 mt7925_regd_update(dev); in mt7925_pci_resume()
590 mt792x_reset(&dev->mt76); in mt7925_pci_resume()