Lines Matching refs:dev

46 static void mt76x0_init_usb_dma(struct mt76x02_dev *dev)  in mt76x0_init_usb_dma()  argument
50 val = mt76_rr(dev, MT_USB_DMA_CFG); in mt76x0_init_usb_dma()
59 mt76_wr(dev, MT_USB_DMA_CFG, val); in mt76x0_init_usb_dma()
61 val = mt76_rr(dev, MT_COM_REG0); in mt76x0_init_usb_dma()
63 dev_dbg(dev->mt76.dev, "MCU not ready\n"); in mt76x0_init_usb_dma()
65 val = mt76_rr(dev, MT_USB_DMA_CFG); in mt76x0_init_usb_dma()
68 mt76_wr(dev, MT_USB_DMA_CFG, val); in mt76x0_init_usb_dma()
70 mt76_wr(dev, MT_USB_DMA_CFG, val); in mt76x0_init_usb_dma()
73 static void mt76x0u_cleanup(struct mt76x02_dev *dev) in mt76x0u_cleanup() argument
75 clear_bit(MT76_STATE_INITIALIZED, &dev->mphy.state); in mt76x0u_cleanup()
76 mt76x0_chip_onoff(dev, false, false); in mt76x0u_cleanup()
77 mt76u_queues_deinit(&dev->mt76); in mt76x0u_cleanup()
82 struct mt76x02_dev *dev = hw->priv; in mt76x0u_stop() local
84 clear_bit(MT76_STATE_RUNNING, &dev->mphy.state); in mt76x0u_stop()
85 cancel_delayed_work_sync(&dev->cal_work); in mt76x0u_stop()
86 cancel_delayed_work_sync(&dev->mphy.mac_work); in mt76x0u_stop()
87 mt76u_stop_tx(&dev->mt76); in mt76x0u_stop()
88 mt76x02u_exit_beacon_config(dev); in mt76x0u_stop()
90 if (test_bit(MT76_REMOVED, &dev->mphy.state)) in mt76x0u_stop()
93 if (!mt76_poll(dev, MT_USB_DMA_CFG, MT_USB_DMA_CFG_TX_BUSY, 0, 1000)) in mt76x0u_stop()
94 dev_warn(dev->mt76.dev, "TX DMA did not stop\n"); in mt76x0u_stop()
96 mt76x0_mac_stop(dev); in mt76x0u_stop()
98 if (!mt76_poll(dev, MT_USB_DMA_CFG, MT_USB_DMA_CFG_RX_BUSY, 0, 1000)) in mt76x0u_stop()
99 dev_warn(dev->mt76.dev, "RX DMA did not stop\n"); in mt76x0u_stop()
104 struct mt76x02_dev *dev = hw->priv; in mt76x0u_start() local
107 ret = mt76x02u_mac_start(dev); in mt76x0u_start()
111 mt76x0_phy_calibrate(dev, true); in mt76x0u_start()
112 ieee80211_queue_delayed_work(dev->mt76.hw, &dev->mphy.mac_work, in mt76x0u_start()
114 ieee80211_queue_delayed_work(dev->mt76.hw, &dev->cal_work, in mt76x0u_start()
116 set_bit(MT76_STATE_RUNNING, &dev->mphy.state); in mt76x0u_start()
147 static int mt76x0u_init_hardware(struct mt76x02_dev *dev, bool reset) in mt76x0u_init_hardware() argument
151 mt76x0_chip_onoff(dev, true, reset); in mt76x0u_init_hardware()
153 if (!mt76x02_wait_for_mac(&dev->mt76)) in mt76x0u_init_hardware()
156 err = mt76x0u_mcu_init(dev); in mt76x0u_init_hardware()
160 mt76x0_init_usb_dma(dev); in mt76x0u_init_hardware()
161 err = mt76x0_init_hardware(dev); in mt76x0u_init_hardware()
165 mt76x02u_init_beacon_config(dev); in mt76x0u_init_hardware()
167 mt76_rmw(dev, MT_US_CYC_CFG, MT_US_CYC_CNT, 0x1e); in mt76x0u_init_hardware()
168 mt76_wr(dev, MT_TXOP_CTRL_CFG, in mt76x0u_init_hardware()
175 static int mt76x0u_register_device(struct mt76x02_dev *dev) in mt76x0u_register_device() argument
177 struct ieee80211_hw *hw = dev->mt76.hw; in mt76x0u_register_device()
178 struct mt76_usb *usb = &dev->mt76.usb; in mt76x0u_register_device()
181 usb->mcu.data = devm_kmalloc(dev->mt76.dev, MCU_RESP_URB_SIZE, in mt76x0u_register_device()
186 err = mt76u_alloc_queues(&dev->mt76); in mt76x0u_register_device()
190 err = mt76x0u_init_hardware(dev, true); in mt76x0u_register_device()
195 hw->max_tx_fragments = dev->mt76.usb.sg_en ? MT_TX_SG_MAX_SIZE : 1; in mt76x0u_register_device()
196 err = mt76x0_register_device(dev); in mt76x0u_register_device()
200 set_bit(MT76_STATE_INITIALIZED, &dev->mphy.state); in mt76x0u_register_device()
205 mt76x0u_cleanup(dev); in mt76x0u_register_device()
225 struct mt76x02_dev *dev; in mt76x0u_probe() local
230 mdev = mt76_alloc_device(&usb_intf->dev, sizeof(*dev), &mt76x0u_ops, in mt76x0u_probe()
235 dev = container_of(mdev, struct mt76x02_dev, mt76); in mt76x0u_probe()
236 mutex_init(&dev->phy_mutex); in mt76x0u_probe()
240 dev->no_2ghz = true; in mt76x0u_probe()
245 usb_set_intfdata(usb_intf, dev); in mt76x0u_probe()
253 mt76x0_chip_onoff(dev, false, false); in mt76x0u_probe()
260 mdev->rev = mt76_rr(dev, MT_ASIC_VERSION); in mt76x0u_probe()
261 mac_rev = mt76_rr(dev, MT_MAC_CSR0); in mt76x0u_probe()
262 dev_info(mdev->dev, "ASIC revision: %08x MAC revision: %08x\n", in mt76x0u_probe()
264 if (!is_mt76x0(dev)) { in mt76x0u_probe()
270 if (!(mt76_rr(dev, MT_EFUSE_CTRL) & MT_EFUSE_CTRL_SEL)) in mt76x0u_probe()
271 dev_warn(mdev->dev, "Warning: eFUSE not present\n"); in mt76x0u_probe()
273 ret = mt76x0u_register_device(dev); in mt76x0u_probe()
282 mt76u_queues_deinit(&dev->mt76); in mt76x0u_probe()
283 mt76_free_device(&dev->mt76); in mt76x0u_probe()
290 struct mt76x02_dev *dev = usb_get_intfdata(usb_intf); in mt76x0_disconnect() local
291 bool initialized = test_bit(MT76_STATE_INITIALIZED, &dev->mphy.state); in mt76x0_disconnect()
296 ieee80211_unregister_hw(dev->mt76.hw); in mt76x0_disconnect()
297 mt76x0u_cleanup(dev); in mt76x0_disconnect()
302 mt76_free_device(&dev->mt76); in mt76x0_disconnect()
308 struct mt76x02_dev *dev = usb_get_intfdata(usb_intf); in mt76x0_suspend() local
310 mt76u_stop_rx(&dev->mt76); in mt76x0_suspend()
311 clear_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state); in mt76x0_suspend()
312 mt76x0_chip_onoff(dev, false, false); in mt76x0_suspend()
319 struct mt76x02_dev *dev = usb_get_intfdata(usb_intf); in mt76x0_resume() local
322 ret = mt76u_resume_rx(&dev->mt76); in mt76x0_resume()
326 ret = mt76x0u_init_hardware(dev, false); in mt76x0_resume()
332 mt76x0u_cleanup(dev); in mt76x0_resume()