Lines Matching refs:dev

13 static void mt76x2u_init_dma(struct mt76x02_dev *dev)  in mt76x2u_init_dma()  argument
15 u32 val = mt76_rr(dev, MT_VEND_ADDR(CFG, MT_USB_U3DMA_CFG)); in mt76x2u_init_dma()
25 mt76_wr(dev, MT_VEND_ADDR(CFG, MT_USB_U3DMA_CFG), val); in mt76x2u_init_dma()
28 static void mt76x2u_power_on_rf_patch(struct mt76x02_dev *dev) in mt76x2u_power_on_rf_patch() argument
30 mt76_set(dev, MT_VEND_ADDR(CFG, 0x130), BIT(0) | BIT(16)); in mt76x2u_power_on_rf_patch()
33 mt76_clear(dev, MT_VEND_ADDR(CFG, 0x1c), 0xff); in mt76x2u_power_on_rf_patch()
34 mt76_set(dev, MT_VEND_ADDR(CFG, 0x1c), 0x30); in mt76x2u_power_on_rf_patch()
36 mt76_wr(dev, MT_VEND_ADDR(CFG, 0x14), 0x484f); in mt76x2u_power_on_rf_patch()
39 mt76_set(dev, MT_VEND_ADDR(CFG, 0x130), BIT(17)); in mt76x2u_power_on_rf_patch()
42 mt76_clear(dev, MT_VEND_ADDR(CFG, 0x130), BIT(16)); in mt76x2u_power_on_rf_patch()
45 mt76_set(dev, MT_VEND_ADDR(CFG, 0x14c), BIT(19) | BIT(20)); in mt76x2u_power_on_rf_patch()
48 static void mt76x2u_power_on_rf(struct mt76x02_dev *dev, int unit) in mt76x2u_power_on_rf() argument
54 mt76_set(dev, MT_VEND_ADDR(CFG, 0x130), BIT(0) << shift); in mt76x2u_power_on_rf()
58 mt76_set(dev, MT_VEND_ADDR(CFG, 0x130), val); in mt76x2u_power_on_rf()
62 mt76_clear(dev, MT_VEND_ADDR(CFG, 0x130), BIT(2) << shift); in mt76x2u_power_on_rf()
65 mt76x2u_power_on_rf_patch(dev); in mt76x2u_power_on_rf()
67 mt76_set(dev, 0x530, 0xf); in mt76x2u_power_on_rf()
70 static void mt76x2u_power_on(struct mt76x02_dev *dev) in mt76x2u_power_on() argument
75 mt76_set(dev, MT_VEND_ADDR(CFG, 0x148), in mt76x2u_power_on()
82 mt76_poll(dev, MT_VEND_ADDR(CFG, 0x148), val, val, 1000); in mt76x2u_power_on()
84 mt76_clear(dev, MT_VEND_ADDR(CFG, 0x148), 0x7f << 16); in mt76x2u_power_on()
87 mt76_clear(dev, MT_VEND_ADDR(CFG, 0x148), 0xf << 24); in mt76x2u_power_on()
90 mt76_set(dev, MT_VEND_ADDR(CFG, 0x148), 0xf << 24); in mt76x2u_power_on()
91 mt76_clear(dev, MT_VEND_ADDR(CFG, 0x148), 0xfff); in mt76x2u_power_on()
94 mt76_clear(dev, MT_VEND_ADDR(CFG, 0x1204), BIT(3)); in mt76x2u_power_on()
97 mt76_set(dev, MT_VEND_ADDR(CFG, 0x80), BIT(0)); in mt76x2u_power_on()
100 mt76_clear(dev, MT_VEND_ADDR(CFG, 0x64), BIT(18)); in mt76x2u_power_on()
102 mt76x2u_power_on_rf(dev, 0); in mt76x2u_power_on()
103 mt76x2u_power_on_rf(dev, 1); in mt76x2u_power_on()
106 static int mt76x2u_init_eeprom(struct mt76x02_dev *dev) in mt76x2u_init_eeprom() argument
110 dev->mt76.eeprom.data = devm_kzalloc(dev->mt76.dev, in mt76x2u_init_eeprom()
113 dev->mt76.eeprom.size = MT7612U_EEPROM_SIZE; in mt76x2u_init_eeprom()
114 if (!dev->mt76.eeprom.data) in mt76x2u_init_eeprom()
118 val = mt76_rr(dev, MT_VEND_ADDR(EEPROM, i)); in mt76x2u_init_eeprom()
119 put_unaligned_le32(val, dev->mt76.eeprom.data + i); in mt76x2u_init_eeprom()
122 mt76x02_eeprom_parse_hw_cap(dev); in mt76x2u_init_eeprom()
126 int mt76x2u_init_hardware(struct mt76x02_dev *dev) in mt76x2u_init_hardware() argument
130 mt76x2_reset_wlan(dev, true); in mt76x2u_init_hardware()
131 mt76x2u_power_on(dev); in mt76x2u_init_hardware()
133 if (!mt76x02_wait_for_mac(&dev->mt76)) in mt76x2u_init_hardware()
136 err = mt76x2u_mcu_fw_init(dev); in mt76x2u_init_hardware()
140 if (!mt76_poll_msec(dev, MT_WPDMA_GLO_CFG, in mt76x2u_init_hardware()
146 if (!mt76x02_wait_for_mac(&dev->mt76)) in mt76x2u_init_hardware()
149 mt76x2u_init_dma(dev); in mt76x2u_init_hardware()
151 err = mt76x2u_mcu_init(dev); in mt76x2u_init_hardware()
155 err = mt76x2u_mac_reset(dev); in mt76x2u_init_hardware()
159 mt76x02_mac_setaddr(dev, dev->mt76.eeprom.data + MT_EE_MAC_ADDR); in mt76x2u_init_hardware()
160 dev->mt76.rxfilter = mt76_rr(dev, MT_RX_FILTR_CFG); in mt76x2u_init_hardware()
162 if (!mt76x02_wait_for_txrx_idle(&dev->mt76)) in mt76x2u_init_hardware()
167 mt76x02_mac_wcid_setup(dev, i, 0, NULL); in mt76x2u_init_hardware()
172 mt76x02_mac_shared_key_setup(dev, i, k, NULL); in mt76x2u_init_hardware()
175 mt76x02u_init_beacon_config(dev); in mt76x2u_init_hardware()
177 mt76_rmw(dev, MT_US_CYC_CFG, MT_US_CYC_CNT, 0x1e); in mt76x2u_init_hardware()
178 mt76_wr(dev, MT_TXOP_CTRL_CFG, 0x583f); in mt76x2u_init_hardware()
180 err = mt76x2_mcu_load_cr(dev, MT_RF_BBP_CR, 0, 0); in mt76x2u_init_hardware()
184 mt76x02_phy_set_rxpath(dev); in mt76x2u_init_hardware()
185 mt76x02_phy_set_txdac(dev); in mt76x2u_init_hardware()
187 return mt76x2u_mac_stop(dev); in mt76x2u_init_hardware()
190 int mt76x2u_register_device(struct mt76x02_dev *dev) in mt76x2u_register_device() argument
192 struct ieee80211_hw *hw = mt76_hw(dev); in mt76x2u_register_device()
193 struct mt76_usb *usb = &dev->mt76.usb; in mt76x2u_register_device()
196 INIT_DELAYED_WORK(&dev->cal_work, mt76x2u_phy_calibrate); in mt76x2u_register_device()
197 err = mt76x02_init_device(dev); in mt76x2u_register_device()
201 err = mt76x2u_init_eeprom(dev); in mt76x2u_register_device()
205 usb->mcu.data = devm_kmalloc(dev->mt76.dev, MCU_RESP_URB_SIZE, in mt76x2u_register_device()
210 err = mt76u_alloc_queues(&dev->mt76); in mt76x2u_register_device()
214 err = mt76x2u_init_hardware(dev); in mt76x2u_register_device()
219 hw->max_tx_fragments = dev->mt76.usb.sg_en ? MT_TX_SG_MAX_SIZE : 1; in mt76x2u_register_device()
220 err = mt76_register_device(&dev->mt76, true, mt76x02_rates, in mt76x2u_register_device()
225 set_bit(MT76_STATE_INITIALIZED, &dev->mphy.state); in mt76x2u_register_device()
227 mt76x02_init_debugfs(dev); in mt76x2u_register_device()
228 mt76x2_init_txpower(dev, &dev->mphy.sband_2g.sband); in mt76x2u_register_device()
229 mt76x2_init_txpower(dev, &dev->mphy.sband_5g.sband); in mt76x2u_register_device()
234 mt76x2u_cleanup(dev); in mt76x2u_register_device()
238 void mt76x2u_stop_hw(struct mt76x02_dev *dev) in mt76x2u_stop_hw() argument
240 cancel_delayed_work_sync(&dev->cal_work); in mt76x2u_stop_hw()
241 cancel_delayed_work_sync(&dev->mphy.mac_work); in mt76x2u_stop_hw()
242 mt76x2u_mac_stop(dev); in mt76x2u_stop_hw()
245 void mt76x2u_cleanup(struct mt76x02_dev *dev) in mt76x2u_cleanup() argument
247 mt76x02_mcu_set_radio_state(dev, false); in mt76x2u_cleanup()
248 mt76x2u_stop_hw(dev); in mt76x2u_cleanup()
249 mt76u_queues_deinit(&dev->mt76); in mt76x2u_cleanup()