mcu.c (b7bfad2c83cdbbd7cd502bebdc75ef703c980634) mcu.c (78562b2cafc61a0c08dc949eacb942ac756aae37)
1// SPDX-License-Identifier: ISC
2/* Copyright (C) 2020 MediaTek Inc. */
3
4#include <linux/fs.h>
5#include <linux/firmware.h>
6#include "mt7921.h"
7#include "mt7921_trace.h"
8#include "mcu.h"

--- 146 unchanged lines hidden (view full) ---

155 mod_timer(&dev->phy.roc_timer,
156 jiffies + msecs_to_jiffies(duration));
157}
158
159static void
160mt7921_mcu_scan_event(struct mt7921_dev *dev, struct sk_buff *skb)
161{
162 struct mt76_phy *mphy = &dev->mt76.phy;
1// SPDX-License-Identifier: ISC
2/* Copyright (C) 2020 MediaTek Inc. */
3
4#include <linux/fs.h>
5#include <linux/firmware.h>
6#include "mt7921.h"
7#include "mt7921_trace.h"
8#include "mcu.h"

--- 146 unchanged lines hidden (view full) ---

155 mod_timer(&dev->phy.roc_timer,
156 jiffies + msecs_to_jiffies(duration));
157}
158
159static void
160mt7921_mcu_scan_event(struct mt7921_dev *dev, struct sk_buff *skb)
161{
162 struct mt76_phy *mphy = &dev->mt76.phy;
163 struct mt7921_phy *phy = (struct mt7921_phy *)mphy->priv;
163 struct mt792x_phy *phy = (struct mt792x_phy *)mphy->priv;
164
165 spin_lock_bh(&dev->mt76.lock);
166 __skb_queue_tail(&phy->scan_event_list, skb);
167 spin_unlock_bh(&dev->mt76.lock);
168
169 ieee80211_queue_delayed_work(mphy->hw, &phy->scan_work,
170 MT7921_HW_SCAN_TIMEOUT);
171}

--- 217 unchanged lines hidden (view full) ---

389}
390
391static int mt7921_load_clc(struct mt7921_dev *dev, const char *fw_name)
392{
393 const struct mt76_connac2_fw_trailer *hdr;
394 const struct mt76_connac2_fw_region *region;
395 const struct mt7921_clc *clc;
396 struct mt76_dev *mdev = &dev->mt76;
164
165 spin_lock_bh(&dev->mt76.lock);
166 __skb_queue_tail(&phy->scan_event_list, skb);
167 spin_unlock_bh(&dev->mt76.lock);
168
169 ieee80211_queue_delayed_work(mphy->hw, &phy->scan_work,
170 MT7921_HW_SCAN_TIMEOUT);
171}

--- 217 unchanged lines hidden (view full) ---

389}
390
391static int mt7921_load_clc(struct mt7921_dev *dev, const char *fw_name)
392{
393 const struct mt76_connac2_fw_trailer *hdr;
394 const struct mt76_connac2_fw_region *region;
395 const struct mt7921_clc *clc;
396 struct mt76_dev *mdev = &dev->mt76;
397 struct mt7921_phy *phy = &dev->phy;
397 struct mt792x_phy *phy = &dev->phy;
398 const struct firmware *fw;
399 int ret, i, len, offset = 0;
400 u8 *clc_base = NULL, hw_encap = 0;
401
402 if (mt7921_disable_clc ||
403 mt76_is_usb(&dev->mt76))
404 return 0;
405

--- 224 unchanged lines hidden (view full) ---

630 e->aifsn = q->aifsn;
631 e->timer = q->mu_edca_timer;
632 }
633
634 return mt76_mcu_send_msg(&dev->mt76, MCU_CE_CMD(SET_MU_EDCA_PARMS),
635 &req_mu, sizeof(req_mu), false);
636}
637
398 const struct firmware *fw;
399 int ret, i, len, offset = 0;
400 u8 *clc_base = NULL, hw_encap = 0;
401
402 if (mt7921_disable_clc ||
403 mt76_is_usb(&dev->mt76))
404 return 0;
405

--- 224 unchanged lines hidden (view full) ---

630 e->aifsn = q->aifsn;
631 e->timer = q->mu_edca_timer;
632 }
633
634 return mt76_mcu_send_msg(&dev->mt76, MCU_CE_CMD(SET_MU_EDCA_PARMS),
635 &req_mu, sizeof(req_mu), false);
636}
637
638int mt7921_mcu_set_roc(struct mt7921_phy *phy, struct mt792x_vif *vif,
638int mt7921_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
639 struct ieee80211_channel *chan, int duration,
640 enum mt7921_roc_req type, u8 token_id)
641{
642 int center_ch = ieee80211_frequency_to_channel(chan->center_freq);
643 struct mt7921_dev *dev = phy->dev;
644 struct {
645 struct {
646 u8 rsv[4];

--- 50 unchanged lines hidden (view full) ---

697 req.roc.band = 1;
698 break;
699 }
700
701 return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(ROC),
702 &req, sizeof(req), false);
703}
704
639 struct ieee80211_channel *chan, int duration,
640 enum mt7921_roc_req type, u8 token_id)
641{
642 int center_ch = ieee80211_frequency_to_channel(chan->center_freq);
643 struct mt7921_dev *dev = phy->dev;
644 struct {
645 struct {
646 u8 rsv[4];

--- 50 unchanged lines hidden (view full) ---

697 req.roc.band = 1;
698 break;
699 }
700
701 return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(ROC),
702 &req, sizeof(req), false);
703}
704
705int mt7921_mcu_abort_roc(struct mt7921_phy *phy, struct mt792x_vif *vif,
705int mt7921_mcu_abort_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
706 u8 token_id)
707{
708 struct mt7921_dev *dev = phy->dev;
709 struct {
710 struct {
711 u8 rsv[4];
712 } __packed hdr;
713 struct roc_abort_tlv {

--- 13 unchanged lines hidden (view full) ---

727 .dbdcband = 0xff, /* auto*/
728 },
729 };
730
731 return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(ROC),
732 &req, sizeof(req), false);
733}
734
706 u8 token_id)
707{
708 struct mt7921_dev *dev = phy->dev;
709 struct {
710 struct {
711 u8 rsv[4];
712 } __packed hdr;
713 struct roc_abort_tlv {

--- 13 unchanged lines hidden (view full) ---

727 .dbdcband = 0xff, /* auto*/
728 },
729 };
730
731 return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(ROC),
732 &req, sizeof(req), false);
733}
734
735int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd)
735int mt7921_mcu_set_chan_info(struct mt792x_phy *phy, int cmd)
736{
737 struct mt7921_dev *dev = phy->dev;
738 struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
739 int freq1 = chandef->center_freq1;
740 struct {
741 u8 control_ch;
742 u8 center_ch;
743 u8 bw;

--- 537 unchanged lines hidden (view full) ---

1281 return -ENOENT;
1282
1283 return 0;
1284}
1285
1286int mt7921_mcu_set_clc(struct mt7921_dev *dev, u8 *alpha2,
1287 enum environment_cap env_cap)
1288{
736{
737 struct mt7921_dev *dev = phy->dev;
738 struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
739 int freq1 = chandef->center_freq1;
740 struct {
741 u8 control_ch;
742 u8 center_ch;
743 u8 bw;

--- 537 unchanged lines hidden (view full) ---

1281 return -ENOENT;
1282
1283 return 0;
1284}
1285
1286int mt7921_mcu_set_clc(struct mt7921_dev *dev, u8 *alpha2,
1287 enum environment_cap env_cap)
1288{
1289 struct mt7921_phy *phy = (struct mt7921_phy *)&dev->phy;
1289 struct mt792x_phy *phy = (struct mt792x_phy *)&dev->phy;
1290 int i, ret;
1291
1292 /* submit all clc config */
1293 for (i = 0; i < ARRAY_SIZE(phy->clc); i++) {
1294 ret = __mt7921_mcu_set_clc(dev, alpha2, env_cap,
1295 phy->clc[i], i);
1296
1297 /* If no country found, set "00" as default */
1298 if (ret == -ENOENT)
1299 ret = __mt7921_mcu_set_clc(dev, "00",
1300 ENVIRON_INDOOR,
1301 phy->clc[i], i);
1302 if (ret < 0)
1303 return ret;
1304 }
1305 return 0;
1306}
1307
1290 int i, ret;
1291
1292 /* submit all clc config */
1293 for (i = 0; i < ARRAY_SIZE(phy->clc); i++) {
1294 ret = __mt7921_mcu_set_clc(dev, alpha2, env_cap,
1295 phy->clc[i], i);
1296
1297 /* If no country found, set "00" as default */
1298 if (ret == -ENOENT)
1299 ret = __mt7921_mcu_set_clc(dev, "00",
1300 ENVIRON_INDOOR,
1301 phy->clc[i], i);
1302 if (ret < 0)
1303 return ret;
1304 }
1305 return 0;
1306}
1307
1308int mt7921_mcu_get_temperature(struct mt7921_phy *phy)
1308int mt7921_mcu_get_temperature(struct mt792x_phy *phy)
1309{
1310 struct mt7921_dev *dev = phy->dev;
1311 struct {
1312 u8 ctrl_id;
1313 u8 action;
1314 u8 band_idx;
1315 u8 rsv[5];
1316 } req = {

--- 29 unchanged lines hidden ---
1309{
1310 struct mt7921_dev *dev = phy->dev;
1311 struct {
1312 u8 ctrl_id;
1313 u8 action;
1314 u8 band_idx;
1315 u8 rsv[5];
1316 } req = {

--- 29 unchanged lines hidden ---