Lines Matching refs:dev

20 	struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);  in mt7603_mcu_parse_response()  local
24 dev_err(mdev->dev, "MCU message %02x (seq %d) timed out\n", in mt7603_mcu_parse_response()
26 dev->mcu_hang = MT7603_WATCHDOG_TIMEOUT; in mt7603_mcu_parse_response()
41 struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76); in mt7603_mcu_skb_send_msg() local
42 int hdrlen = dev->mcu_running ? sizeof(struct mt7603_mcu_txd) : 12; in mt7603_mcu_skb_send_msg()
75 return mt76_tx_queue_skb_raw(dev, mdev->q_mcu[MT_MCUQ_WM], skb, 0); in mt7603_mcu_skb_send_msg()
79 mt7603_mcu_init_download(struct mt7603_dev *dev, u32 addr, u32 len) in mt7603_mcu_init_download() argument
91 return mt76_mcu_send_msg(&dev->mt76, -MCU_CMD_TARGET_ADDRESS_LEN_REQ, in mt7603_mcu_init_download()
96 mt7603_mcu_start_firmware(struct mt7603_dev *dev, u32 addr) in mt7603_mcu_start_firmware() argument
106 return mt76_mcu_send_msg(&dev->mt76, -MCU_CMD_FW_START_REQ, &req, in mt7603_mcu_start_firmware()
111 mt7603_mcu_restart(struct mt76_dev *dev) in mt7603_mcu_restart() argument
113 return mt76_mcu_send_msg(dev, -MCU_CMD_RESTART_DL_REQ, NULL, 0, true); in mt7603_mcu_restart()
116 static int mt7603_load_firmware(struct mt7603_dev *dev) in mt7603_load_firmware() argument
125 if (is_mt7628(dev)) { in mt7603_load_firmware()
126 if (mt76xx_rev(dev) == MT7628_REV_E1) in mt7603_load_firmware()
131 if (mt76xx_rev(dev) < MT7603_REV_E2) in mt7603_load_firmware()
137 ret = request_firmware(&fw, firmware, dev->mt76.dev); in mt7603_load_firmware()
142 dev_err(dev->mt76.dev, "Invalid firmware\n"); in mt7603_load_firmware()
150 dev_info(dev->mt76.dev, "Firmware Version: %.10s\n", hdr->fw_ver); in mt7603_load_firmware()
151 dev_info(dev->mt76.dev, "Build Time: %.15s\n", hdr->build_date); in mt7603_load_firmware()
153 addr = mt7603_reg_map(dev, 0x50012498); in mt7603_load_firmware()
154 mt76_wr(dev, addr, 0x5); in mt7603_load_firmware()
155 mt76_wr(dev, addr, 0x5); in mt7603_load_firmware()
159 mt76_rmw(dev, MT_SCH_4, MT_SCH_4_FORCE_QID, in mt7603_load_firmware()
162 val = mt76_rr(dev, MT_TOP_MISC2); in mt7603_load_firmware()
164 dev_info(dev->mt76.dev, "Firmware already running...\n"); in mt7603_load_firmware()
168 if (!mt76_poll_msec(dev, MT_TOP_MISC2, BIT(0) | BIT(1), BIT(0), 500)) { in mt7603_load_firmware()
169 dev_err(dev->mt76.dev, "Timeout waiting for ROM code to become ready\n"); in mt7603_load_firmware()
175 ret = mt7603_mcu_init_download(dev, MCU_FIRMWARE_ADDRESS, dl_len); in mt7603_load_firmware()
177 dev_err(dev->mt76.dev, "Download request failed\n"); in mt7603_load_firmware()
181 ret = mt76_mcu_send_firmware(&dev->mt76, -MCU_CMD_FW_SCATTER, in mt7603_load_firmware()
184 dev_err(dev->mt76.dev, "Failed to send firmware to device\n"); in mt7603_load_firmware()
188 ret = mt7603_mcu_start_firmware(dev, MCU_FIRMWARE_ADDRESS); in mt7603_load_firmware()
190 dev_err(dev->mt76.dev, "Failed to start firmware\n"); in mt7603_load_firmware()
194 if (!mt76_poll_msec(dev, MT_TOP_MISC2, BIT(1), BIT(1), 500)) { in mt7603_load_firmware()
195 dev_err(dev->mt76.dev, "Timeout waiting for firmware to initialize\n"); in mt7603_load_firmware()
201 mt76_clear(dev, MT_SCH_4, MT_SCH_4_FORCE_QID | MT_SCH_4_BYPASS); in mt7603_load_firmware()
203 mt76_set(dev, MT_SCH_4, BIT(8)); in mt7603_load_firmware()
204 mt76_clear(dev, MT_SCH_4, BIT(8)); in mt7603_load_firmware()
206 dev->mcu_running = true; in mt7603_load_firmware()
207 snprintf(dev->mt76.hw->wiphy->fw_version, in mt7603_load_firmware()
208 sizeof(dev->mt76.hw->wiphy->fw_version), in mt7603_load_firmware()
210 dev_info(dev->mt76.dev, "firmware init done\n"); in mt7603_load_firmware()
218 int mt7603_mcu_init(struct mt7603_dev *dev) in mt7603_mcu_init() argument
226 dev->mt76.mcu_ops = &mt7603_mcu_ops; in mt7603_mcu_init()
227 return mt7603_load_firmware(dev); in mt7603_mcu_init()
230 void mt7603_mcu_exit(struct mt7603_dev *dev) in mt7603_mcu_exit() argument
232 mt7603_mcu_restart(&dev->mt76); in mt7603_mcu_exit()
233 skb_queue_purge(&dev->mt76.mcu.res_q); in mt7603_mcu_exit()
236 int mt7603_mcu_set_eeprom(struct mt7603_dev *dev) in mt7603_mcu_set_eeprom() argument
315 u8 *req, *eep = (u8 *)dev->mt76.eeprom.data; in mt7603_mcu_set_eeprom()
333 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EFUSE_BUFFER_MODE, in mt7603_mcu_set_eeprom()
340 static int mt7603_mcu_set_tx_power(struct mt7603_dev *dev) in mt7603_mcu_set_tx_power() argument
353 .center_channel = dev->mphy.chandef.chan->hw_value, in mt7603_mcu_set_tx_power()
354 #define EEP_VAL(n) ((u8 *)dev->mt76.eeprom.data)[n] in mt7603_mcu_set_tx_power()
372 u8 *eep = (u8 *)dev->mt76.eeprom.data; in mt7603_mcu_set_tx_power()
380 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_SET_TX_POWER_CTRL, in mt7603_mcu_set_tx_power()
384 int mt7603_mcu_set_channel(struct mt7603_dev *dev) in mt7603_mcu_set_channel() argument
386 struct cfg80211_chan_def *chandef = &dev->mphy.chandef; in mt7603_mcu_set_channel()
387 struct ieee80211_hw *hw = mt76_hw(dev); in mt7603_mcu_set_channel()
388 int n_chains = hweight8(dev->mphy.antenna_mask); in mt7603_mcu_set_channel()
408 if (dev->mphy.chandef.width == NL80211_CHAN_WIDTH_40) { in mt7603_mcu_set_channel()
416 tx_power = mt76_get_sar_power(&dev->mphy, chandef->chan, tx_power); in mt7603_mcu_set_channel()
417 if (dev->mphy.antenna_mask == 3) in mt7603_mcu_set_channel()
419 tx_power = min(tx_power, dev->tx_power_limit); in mt7603_mcu_set_channel()
421 dev->mphy.txpower_cur = tx_power; in mt7603_mcu_set_channel()
426 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_CHANNEL_SWITCH, &req, in mt7603_mcu_set_channel()
431 return mt7603_mcu_set_tx_power(dev); in mt7603_mcu_set_channel()