Commit 499cd0aa authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: use mt76x02_dev instead of mt76_dev in mt76x02_mcu.c

Use mt76x02_dev data structure as reference in mt76x02_mcu.c
instead of mt76_dev
Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent a14054ce
...@@ -280,7 +280,7 @@ int mt76x0_init_hardware(struct mt76x02_dev *dev) ...@@ -280,7 +280,7 @@ int mt76x0_init_hardware(struct mt76x02_dev *dev)
return -ETIMEDOUT; return -ETIMEDOUT;
mt76x0_reset_csr_bbp(dev); mt76x0_reset_csr_bbp(dev);
ret = mt76x02_mcu_function_select(&dev->mt76, Q_SELECT, 1, false); ret = mt76x02_mcu_function_select(dev, Q_SELECT, 1, false);
if (ret) if (ret)
return ret; return ret;
......
...@@ -167,7 +167,7 @@ static void mt76x0e_cleanup(struct mt76x02_dev *dev) ...@@ -167,7 +167,7 @@ static void mt76x0e_cleanup(struct mt76x02_dev *dev)
mt76x0_chip_onoff(dev, false, false); mt76x0_chip_onoff(dev, false, false);
mt76x0e_stop_hw(dev); mt76x0e_stop_hw(dev);
mt76x02_dma_cleanup(dev); mt76x02_dma_cleanup(dev);
mt76x02_mcu_cleanup(&dev->mt76); mt76x02_mcu_cleanup(dev);
} }
static void static void
......
...@@ -602,7 +602,7 @@ mt76x0_bbp_set_bw(struct mt76x02_dev *dev, enum nl80211_chan_width width) ...@@ -602,7 +602,7 @@ mt76x0_bbp_set_bw(struct mt76x02_dev *dev, enum nl80211_chan_width width)
return ; return ;
} }
mt76x02_mcu_function_select(&dev->mt76, BW_SETTING, bw, false); mt76x02_mcu_function_select(dev, BW_SETTING, bw, false);
} }
void mt76x0_phy_set_txpower(struct mt76x02_dev *dev) void mt76x0_phy_set_txpower(struct mt76x02_dev *dev)
...@@ -712,7 +712,7 @@ int mt76x0_phy_set_channel(struct mt76x02_dev *dev, ...@@ -712,7 +712,7 @@ int mt76x0_phy_set_channel(struct mt76x02_dev *dev,
mt76x0_vco_cal(dev, channel); mt76x0_vco_cal(dev, channel);
if (scan) if (scan)
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RXDCOC, 1, false); mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, 1, false);
mt76x0_phy_set_txpower(dev); mt76x0_phy_set_txpower(dev);
...@@ -725,7 +725,7 @@ void mt76x0_phy_recalibrate_after_assoc(struct mt76x02_dev *dev) ...@@ -725,7 +725,7 @@ void mt76x0_phy_recalibrate_after_assoc(struct mt76x02_dev *dev)
u8 channel = dev->mt76.chandef.chan->hw_value; u8 channel = dev->mt76.chandef.chan->hw_value;
int is_5ghz = (dev->mt76.chandef.chan->band == NL80211_BAND_5GHZ) ? 1 : 0; int is_5ghz = (dev->mt76.chandef.chan->band == NL80211_BAND_5GHZ) ? 1 : 0;
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_R, 0, false); mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0, false);
mt76x0_vco_cal(dev, channel); mt76x0_vco_cal(dev, channel);
...@@ -737,22 +737,20 @@ void mt76x0_phy_recalibrate_after_assoc(struct mt76x02_dev *dev) ...@@ -737,22 +737,20 @@ void mt76x0_phy_recalibrate_after_assoc(struct mt76x02_dev *dev)
reg_val &= 0xffffff7e; reg_val &= 0xffffff7e;
mt76_wr(dev, 0x2124, reg_val); mt76_wr(dev, 0x2124, reg_val);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RXDCOC, 0, false); mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, 0, false);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_LC, is_5ghz, false); mt76x02_mcu_calibrate(dev, MCU_CAL_LC, is_5ghz, false);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_LOFT, is_5ghz, false); mt76x02_mcu_calibrate(dev, MCU_CAL_LOFT, is_5ghz, false);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TXIQ, is_5ghz, false); mt76x02_mcu_calibrate(dev, MCU_CAL_TXIQ, is_5ghz, false);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TX_GROUP_DELAY, mt76x02_mcu_calibrate(dev, MCU_CAL_TX_GROUP_DELAY, is_5ghz, false);
is_5ghz, false); mt76x02_mcu_calibrate(dev, MCU_CAL_RXIQ, is_5ghz, false);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RXIQ, is_5ghz, false); mt76x02_mcu_calibrate(dev, MCU_CAL_RX_GROUP_DELAY, is_5ghz, false);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RX_GROUP_DELAY,
is_5ghz, false);
mt76_wr(dev, 0x2124, reg_val); mt76_wr(dev, 0x2124, reg_val);
mt76_wr(dev, MT_TX_ALC_CFG_0, tx_alc); mt76_wr(dev, MT_TX_ALC_CFG_0, tx_alc);
msleep(100); msleep(100);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RXDCOC, 1, false); mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, 1, false);
} }
void mt76x0_agc_save(struct mt76x02_dev *dev) void mt76x0_agc_save(struct mt76x02_dev *dev)
......
...@@ -19,9 +19,7 @@ ...@@ -19,9 +19,7 @@
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/delay.h> #include <linux/delay.h>
#include "mt76.h"
#include "mt76x02_mcu.h" #include "mt76x02_mcu.h"
#include "mt76x02_dma.h"
struct sk_buff *mt76x02_mcu_msg_alloc(const void *data, int len) struct sk_buff *mt76x02_mcu_msg_alloc(const void *data, int len)
{ {
...@@ -37,7 +35,7 @@ struct sk_buff *mt76x02_mcu_msg_alloc(const void *data, int len) ...@@ -37,7 +35,7 @@ struct sk_buff *mt76x02_mcu_msg_alloc(const void *data, int len)
EXPORT_SYMBOL_GPL(mt76x02_mcu_msg_alloc); EXPORT_SYMBOL_GPL(mt76x02_mcu_msg_alloc);
static struct sk_buff * static struct sk_buff *
mt76x02_mcu_get_response(struct mt76_dev *dev, unsigned long expires) mt76x02_mcu_get_response(struct mt76x02_dev *dev, unsigned long expires)
{ {
unsigned long timeout; unsigned long timeout;
...@@ -45,17 +43,17 @@ mt76x02_mcu_get_response(struct mt76_dev *dev, unsigned long expires) ...@@ -45,17 +43,17 @@ mt76x02_mcu_get_response(struct mt76_dev *dev, unsigned long expires)
return NULL; return NULL;
timeout = expires - jiffies; timeout = expires - jiffies;
wait_event_timeout(dev->mmio.mcu.wait, wait_event_timeout(dev->mt76.mmio.mcu.wait,
!skb_queue_empty(&dev->mmio.mcu.res_q), !skb_queue_empty(&dev->mt76.mmio.mcu.res_q),
timeout); timeout);
return skb_dequeue(&dev->mmio.mcu.res_q); return skb_dequeue(&dev->mt76.mmio.mcu.res_q);
} }
static int static int
mt76x02_tx_queue_mcu(struct mt76_dev *dev, enum mt76_txq_id qid, mt76x02_tx_queue_mcu(struct mt76x02_dev *dev, enum mt76_txq_id qid,
struct sk_buff *skb, int cmd, int seq) struct sk_buff *skb, int cmd, int seq)
{ {
struct mt76_queue *q = &dev->q_tx[qid]; struct mt76_queue *q = &dev->mt76.q_tx[qid];
struct mt76_queue_buf buf; struct mt76_queue_buf buf;
dma_addr_t addr; dma_addr_t addr;
u32 tx_info; u32 tx_info;
...@@ -66,24 +64,26 @@ mt76x02_tx_queue_mcu(struct mt76_dev *dev, enum mt76_txq_id qid, ...@@ -66,24 +64,26 @@ mt76x02_tx_queue_mcu(struct mt76_dev *dev, enum mt76_txq_id qid,
FIELD_PREP(MT_MCU_MSG_PORT, CPU_TX_PORT) | FIELD_PREP(MT_MCU_MSG_PORT, CPU_TX_PORT) |
FIELD_PREP(MT_MCU_MSG_LEN, skb->len); FIELD_PREP(MT_MCU_MSG_LEN, skb->len);
addr = dma_map_single(dev->dev, skb->data, skb->len, addr = dma_map_single(dev->mt76.dev, skb->data, skb->len,
DMA_TO_DEVICE); DMA_TO_DEVICE);
if (dma_mapping_error(dev->dev, addr)) if (dma_mapping_error(dev->mt76.dev, addr))
return -ENOMEM; return -ENOMEM;
buf.addr = addr; buf.addr = addr;
buf.len = skb->len; buf.len = skb->len;
spin_lock_bh(&q->lock); spin_lock_bh(&q->lock);
dev->queue_ops->add_buf(dev, q, &buf, 1, tx_info, skb, NULL); mt76_queue_add_buf(dev, q, &buf, 1, tx_info, skb, NULL);
dev->queue_ops->kick(dev, q); mt76_queue_kick(dev, q);
spin_unlock_bh(&q->lock); spin_unlock_bh(&q->lock);
return 0; return 0;
} }
int mt76x02_mcu_msg_send(struct mt76_dev *dev, struct sk_buff *skb, int mt76x02_mcu_msg_send(struct mt76_dev *mdev, struct sk_buff *skb,
int cmd, bool wait_resp) int cmd, bool wait_resp)
{ {
struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
unsigned long expires = jiffies + HZ; unsigned long expires = jiffies + HZ;
int ret; int ret;
u8 seq; u8 seq;
...@@ -91,11 +91,11 @@ int mt76x02_mcu_msg_send(struct mt76_dev *dev, struct sk_buff *skb, ...@@ -91,11 +91,11 @@ int mt76x02_mcu_msg_send(struct mt76_dev *dev, struct sk_buff *skb,
if (!skb) if (!skb)
return -EINVAL; return -EINVAL;
mutex_lock(&dev->mmio.mcu.mutex); mutex_lock(&mdev->mmio.mcu.mutex);
seq = ++dev->mmio.mcu.msg_seq & 0xf; seq = ++mdev->mmio.mcu.msg_seq & 0xf;
if (!seq) if (!seq)
seq = ++dev->mmio.mcu.msg_seq & 0xf; seq = ++mdev->mmio.mcu.msg_seq & 0xf;
ret = mt76x02_tx_queue_mcu(dev, MT_TXQ_MCU, skb, cmd, seq); ret = mt76x02_tx_queue_mcu(dev, MT_TXQ_MCU, skb, cmd, seq);
if (ret) if (ret)
...@@ -107,7 +107,7 @@ int mt76x02_mcu_msg_send(struct mt76_dev *dev, struct sk_buff *skb, ...@@ -107,7 +107,7 @@ int mt76x02_mcu_msg_send(struct mt76_dev *dev, struct sk_buff *skb,
skb = mt76x02_mcu_get_response(dev, expires); skb = mt76x02_mcu_get_response(dev, expires);
if (!skb) { if (!skb) {
dev_err(dev->dev, dev_err(mdev->dev,
"MCU message %d (seq %d) timed out\n", cmd, "MCU message %d (seq %d) timed out\n", cmd,
seq); seq);
ret = -ETIMEDOUT; ret = -ETIMEDOUT;
...@@ -125,13 +125,13 @@ int mt76x02_mcu_msg_send(struct mt76_dev *dev, struct sk_buff *skb, ...@@ -125,13 +125,13 @@ int mt76x02_mcu_msg_send(struct mt76_dev *dev, struct sk_buff *skb,
} }
out: out:
mutex_unlock(&dev->mmio.mcu.mutex); mutex_unlock(&mdev->mmio.mcu.mutex);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(mt76x02_mcu_msg_send); EXPORT_SYMBOL_GPL(mt76x02_mcu_msg_send);
int mt76x02_mcu_function_select(struct mt76_dev *dev, int mt76x02_mcu_function_select(struct mt76x02_dev *dev,
enum mcu_function func, enum mcu_function func,
u32 val, bool wait_resp) u32 val, bool wait_resp)
{ {
...@@ -144,13 +144,12 @@ int mt76x02_mcu_function_select(struct mt76_dev *dev, ...@@ -144,13 +144,12 @@ int mt76x02_mcu_function_select(struct mt76_dev *dev,
.value = cpu_to_le32(val), .value = cpu_to_le32(val),
}; };
skb = dev->mcu_ops->mcu_msg_alloc(&msg, sizeof(msg)); skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
return dev->mcu_ops->mcu_send_msg(dev, skb, CMD_FUN_SET_OP, return mt76_mcu_send_msg(dev, skb, CMD_FUN_SET_OP, wait_resp);
wait_resp);
} }
EXPORT_SYMBOL_GPL(mt76x02_mcu_function_select); EXPORT_SYMBOL_GPL(mt76x02_mcu_function_select);
int mt76x02_mcu_set_radio_state(struct mt76_dev *dev, bool on, int mt76x02_mcu_set_radio_state(struct mt76x02_dev *dev, bool on,
bool wait_resp) bool wait_resp)
{ {
struct sk_buff *skb; struct sk_buff *skb;
...@@ -162,13 +161,12 @@ int mt76x02_mcu_set_radio_state(struct mt76_dev *dev, bool on, ...@@ -162,13 +161,12 @@ int mt76x02_mcu_set_radio_state(struct mt76_dev *dev, bool on,
.level = cpu_to_le32(0), .level = cpu_to_le32(0),
}; };
skb = dev->mcu_ops->mcu_msg_alloc(&msg, sizeof(msg)); skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
return dev->mcu_ops->mcu_send_msg(dev, skb, CMD_POWER_SAVING_OP, return mt76_mcu_send_msg(dev, skb, CMD_POWER_SAVING_OP, wait_resp);
wait_resp);
} }
EXPORT_SYMBOL_GPL(mt76x02_mcu_set_radio_state); EXPORT_SYMBOL_GPL(mt76x02_mcu_set_radio_state);
int mt76x02_mcu_calibrate(struct mt76_dev *dev, int type, int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type,
u32 param, bool wait) u32 param, bool wait)
{ {
struct sk_buff *skb; struct sk_buff *skb;
...@@ -182,15 +180,15 @@ int mt76x02_mcu_calibrate(struct mt76_dev *dev, int type, ...@@ -182,15 +180,15 @@ int mt76x02_mcu_calibrate(struct mt76_dev *dev, int type,
int ret; int ret;
if (wait) if (wait)
dev->bus->rmw(dev, MT_MCU_COM_REG0, BIT(31), 0); mt76_rmw(dev, MT_MCU_COM_REG0, BIT(31), 0);
skb = dev->mcu_ops->mcu_msg_alloc(&msg, sizeof(msg)); skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
ret = dev->mcu_ops->mcu_send_msg(dev, skb, CMD_CALIBRATION_OP, true); ret = mt76_mcu_send_msg(dev, skb, CMD_CALIBRATION_OP, true);
if (ret) if (ret)
return ret; return ret;
if (wait && if (wait &&
WARN_ON(!__mt76_poll_msec(dev, MT_MCU_COM_REG0, WARN_ON(!mt76_poll_msec(dev, MT_MCU_COM_REG0,
BIT(31), BIT(31), 100))) BIT(31), BIT(31), 100)))
return -ETIMEDOUT; return -ETIMEDOUT;
...@@ -198,28 +196,28 @@ int mt76x02_mcu_calibrate(struct mt76_dev *dev, int type, ...@@ -198,28 +196,28 @@ int mt76x02_mcu_calibrate(struct mt76_dev *dev, int type,
} }
EXPORT_SYMBOL_GPL(mt76x02_mcu_calibrate); EXPORT_SYMBOL_GPL(mt76x02_mcu_calibrate);
int mt76x02_mcu_cleanup(struct mt76_dev *dev) int mt76x02_mcu_cleanup(struct mt76x02_dev *dev)
{ {
struct sk_buff *skb; struct sk_buff *skb;
dev->bus->wr(dev, MT_MCU_INT_LEVEL, 1); mt76_wr(dev, MT_MCU_INT_LEVEL, 1);
usleep_range(20000, 30000); usleep_range(20000, 30000);
while ((skb = skb_dequeue(&dev->mmio.mcu.res_q)) != NULL) while ((skb = skb_dequeue(&dev->mt76.mmio.mcu.res_q)) != NULL)
dev_kfree_skb(skb); dev_kfree_skb(skb);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(mt76x02_mcu_cleanup); EXPORT_SYMBOL_GPL(mt76x02_mcu_cleanup);
void mt76x02_set_ethtool_fwver(struct mt76_dev *dev, void mt76x02_set_ethtool_fwver(struct mt76x02_dev *dev,
const struct mt76x02_fw_header *h) const struct mt76x02_fw_header *h)
{ {
u16 bld = le16_to_cpu(h->build_ver); u16 bld = le16_to_cpu(h->build_ver);
u16 ver = le16_to_cpu(h->fw_ver); u16 ver = le16_to_cpu(h->fw_ver);
snprintf(dev->hw->wiphy->fw_version, snprintf(dev->mt76.hw->wiphy->fw_version,
sizeof(dev->hw->wiphy->fw_version), sizeof(dev->mt76.hw->wiphy->fw_version),
"%d.%d.%02d-b%x", "%d.%d.%02d-b%x",
(ver >> 12) & 0xf, (ver >> 8) & 0xf, ver & 0xf, bld); (ver >> 12) & 0xf, (ver >> 8) & 0xf, ver & 0xf, bld);
} }
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#ifndef __MT76x02_MCU_H #ifndef __MT76x02_MCU_H
#define __MT76x02_MCU_H #define __MT76x02_MCU_H
#include "mt76x02.h"
#define MT_MCU_RESET_CTL 0x070C #define MT_MCU_RESET_CTL 0x070C
#define MT_MCU_INT_LEVEL 0x0718 #define MT_MCU_INT_LEVEL 0x0718
#define MT_MCU_COM_REG0 0x0730 #define MT_MCU_COM_REG0 0x0730
...@@ -94,18 +96,18 @@ struct mt76x02_patch_header { ...@@ -94,18 +96,18 @@ struct mt76x02_patch_header {
u8 pad[2]; u8 pad[2];
}; };
int mt76x02_mcu_cleanup(struct mt76_dev *dev); int mt76x02_mcu_cleanup(struct mt76x02_dev *dev);
int mt76x02_mcu_calibrate(struct mt76_dev *dev, int type, int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type,
u32 param, bool wait); u32 param, bool wait);
struct sk_buff *mt76x02_mcu_msg_alloc(const void *data, int len); struct sk_buff *mt76x02_mcu_msg_alloc(const void *data, int len);
int mt76x02_mcu_msg_send(struct mt76_dev *dev, struct sk_buff *skb, int mt76x02_mcu_msg_send(struct mt76_dev *mdev, struct sk_buff *skb,
int cmd, bool wait_resp); int cmd, bool wait_resp);
int mt76x02_mcu_function_select(struct mt76_dev *dev, int mt76x02_mcu_function_select(struct mt76x02_dev *dev,
enum mcu_function func, enum mcu_function func,
u32 val, bool wait_resp); u32 val, bool wait_resp);
int mt76x02_mcu_set_radio_state(struct mt76_dev *dev, bool on, int mt76x02_mcu_set_radio_state(struct mt76x02_dev *dev, bool on,
bool wait_resp); bool wait_resp);
void mt76x02_set_ethtool_fwver(struct mt76_dev *dev, void mt76x02_set_ethtool_fwver(struct mt76x02_dev *dev,
const struct mt76x02_fw_header *h); const struct mt76x02_fw_header *h);
#endif /* __MT76x02_MCU_H */ #endif /* __MT76x02_MCU_H */
...@@ -337,7 +337,7 @@ void mt76x2_stop_hardware(struct mt76x02_dev *dev) ...@@ -337,7 +337,7 @@ void mt76x2_stop_hardware(struct mt76x02_dev *dev)
{ {
cancel_delayed_work_sync(&dev->cal_work); cancel_delayed_work_sync(&dev->cal_work);
cancel_delayed_work_sync(&dev->mac_work); cancel_delayed_work_sync(&dev->mac_work);
mt76x02_mcu_set_radio_state(&dev->mt76, false, true); mt76x02_mcu_set_radio_state(dev, false, true);
mt76x2_mac_stop(dev, false); mt76x2_mac_stop(dev, false);
} }
...@@ -347,7 +347,7 @@ void mt76x2_cleanup(struct mt76x02_dev *dev) ...@@ -347,7 +347,7 @@ void mt76x2_cleanup(struct mt76x02_dev *dev)
tasklet_disable(&dev->pre_tbtt_tasklet); tasklet_disable(&dev->pre_tbtt_tasklet);
mt76x2_stop_hardware(dev); mt76x2_stop_hardware(dev);
mt76x02_dma_cleanup(dev); mt76x02_dma_cleanup(dev);
mt76x02_mcu_cleanup(&dev->mt76); mt76x02_mcu_cleanup(dev);
} }
struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev) struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev)
......
...@@ -152,8 +152,8 @@ mt76pci_load_firmware(struct mt76x02_dev *dev) ...@@ -152,8 +152,8 @@ mt76pci_load_firmware(struct mt76x02_dev *dev)
return -ETIMEDOUT; return -ETIMEDOUT;
} }
mt76x02_set_ethtool_fwver(dev, hdr);
dev_info(dev->mt76.dev, "Firmware running!\n"); dev_info(dev->mt76.dev, "Firmware running!\n");
mt76x02_set_ethtool_fwver(&dev->mt76, hdr);
release_firmware(fw); release_firmware(fw);
...@@ -183,6 +183,6 @@ int mt76x2_mcu_init(struct mt76x02_dev *dev) ...@@ -183,6 +183,6 @@ int mt76x2_mcu_init(struct mt76x02_dev *dev)
if (ret) if (ret)
return ret; return ret;
mt76x02_mcu_function_select(&dev->mt76, Q_SELECT, 1, true); mt76x02_mcu_function_select(dev, Q_SELECT, 1, true);
return 0; return 0;
} }
...@@ -38,7 +38,7 @@ mt76x2_phy_tssi_init_cal(struct mt76x02_dev *dev) ...@@ -38,7 +38,7 @@ mt76x2_phy_tssi_init_cal(struct mt76x02_dev *dev)
if (mt76x02_ext_pa_enabled(&dev->mt76, chan->band)) if (mt76x02_ext_pa_enabled(&dev->mt76, chan->band))
flag |= BIT(8); flag |= BIT(8);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TSSI, flag, true); mt76x02_mcu_calibrate(dev, MCU_CAL_TSSI, flag, true);
dev->cal.tssi_cal_done = true; dev->cal.tssi_cal_done = true;
return true; return true;
} }
...@@ -62,13 +62,13 @@ mt76x2_phy_channel_calibrate(struct mt76x02_dev *dev, bool mac_stopped) ...@@ -62,13 +62,13 @@ mt76x2_phy_channel_calibrate(struct mt76x02_dev *dev, bool mac_stopped)
mt76x2_mac_stop(dev, false); mt76x2_mac_stop(dev, false);
if (is_5ghz) if (is_5ghz)
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_LC, 0, true); mt76x02_mcu_calibrate(dev, MCU_CAL_LC, 0, true);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TX_LOFT, is_5ghz, true); mt76x02_mcu_calibrate(dev, MCU_CAL_TX_LOFT, is_5ghz, true);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TXIQ, is_5ghz, true); mt76x02_mcu_calibrate(dev, MCU_CAL_TXIQ, is_5ghz, true);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RXIQC_FI, is_5ghz, true); mt76x02_mcu_calibrate(dev, MCU_CAL_RXIQC_FI, is_5ghz, true);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TEMP_SENSOR, 0, true); mt76x02_mcu_calibrate(dev, MCU_CAL_TEMP_SENSOR, 0, true);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TX_SHAPING, 0, true); mt76x02_mcu_calibrate(dev, MCU_CAL_TX_SHAPING, 0, true);
if (!mac_stopped) if (!mac_stopped)
mt76x2_mac_resume(dev); mt76x2_mac_resume(dev);
...@@ -364,14 +364,14 @@ int mt76x2_phy_set_channel(struct mt76x02_dev *dev, ...@@ -364,14 +364,14 @@ int mt76x2_phy_set_channel(struct mt76x02_dev *dev,
u8 val = mt76x02_eeprom_get(&dev->mt76, MT_EE_BT_RCAL_RESULT); u8 val = mt76x02_eeprom_get(&dev->mt76, MT_EE_BT_RCAL_RESULT);
if (val != 0xff) if (val != 0xff)
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_R, 0, true); mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0, true);
} }
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RXDCOC, channel, true); mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, channel, true);
/* Rx LPF calibration */ /* Rx LPF calibration */
if (!dev->cal.init_cal_done) if (!dev->cal.init_cal_done)
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RC, 0, true); mt76x02_mcu_calibrate(dev, MCU_CAL_RC, 0, true);
dev->cal.init_cal_done = true; dev->cal.init_cal_done = true;
...@@ -449,7 +449,7 @@ int mt76x2_phy_start(struct mt76x02_dev *dev) ...@@ -449,7 +449,7 @@ int mt76x2_phy_start(struct mt76x02_dev *dev)
{ {
int ret; int ret;
ret = mt76x02_mcu_set_radio_state(&dev->mt76, true, true); ret = mt76x02_mcu_set_radio_state(dev, true, true);
if (ret) if (ret)
return ret; return ret;
......
...@@ -289,8 +289,7 @@ void mt76x2_phy_tssi_compensate(struct mt76x02_dev *dev, bool wait) ...@@ -289,8 +289,7 @@ void mt76x2_phy_tssi_compensate(struct mt76x02_dev *dev, bool wait)
return; return;
usleep_range(10000, 20000); usleep_range(10000, 20000);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_DPD, mt76x02_mcu_calibrate(dev, MCU_CAL_DPD, chan->hw_value, wait);
chan->hw_value, wait);
dev->cal.dpd_cal_done = true; dev->cal.dpd_cal_done = true;
} }
} }
......
...@@ -303,7 +303,7 @@ void mt76x2u_stop_hw(struct mt76x02_dev *dev) ...@@ -303,7 +303,7 @@ void mt76x2u_stop_hw(struct mt76x02_dev *dev)
void mt76x2u_cleanup(struct mt76x02_dev *dev) void mt76x2u_cleanup(struct mt76x02_dev *dev)
{ {
mt76x02_mcu_set_radio_state(&dev->mt76, false, false); mt76x02_mcu_set_radio_state(dev, false, false);
mt76x2u_stop_hw(dev); mt76x2u_stop_hw(dev);
mt76u_queues_deinit(&dev->mt76); mt76u_queues_deinit(&dev->mt76);
mt76u_mcu_deinit(&dev->mt76); mt76u_mcu_deinit(&dev->mt76);
......
...@@ -260,8 +260,8 @@ static int mt76x2u_mcu_load_firmware(struct mt76x02_dev *dev) ...@@ -260,8 +260,8 @@ static int mt76x2u_mcu_load_firmware(struct mt76x02_dev *dev)
mt76_set(dev, MT_MCU_COM_REG0, BIT(1)); mt76_set(dev, MT_MCU_COM_REG0, BIT(1));
/* enable FCE to send in-band cmd */ /* enable FCE to send in-band cmd */
mt76_wr(dev, MT_FCE_PSE_CTRL, 0x1); mt76_wr(dev, MT_FCE_PSE_CTRL, 0x1);
mt76x02_set_ethtool_fwver(dev, hdr);
dev_dbg(dev->mt76.dev, "firmware running\n"); dev_dbg(dev->mt76.dev, "firmware running\n");
mt76x02_set_ethtool_fwver(&dev->mt76, hdr);
out: out:
release_firmware(fw); release_firmware(fw);
...@@ -283,10 +283,9 @@ int mt76x2u_mcu_init(struct mt76x02_dev *dev) ...@@ -283,10 +283,9 @@ int mt76x2u_mcu_init(struct mt76x02_dev *dev)
{ {
int err; int err;
err = mt76x02_mcu_function_select(&dev->mt76, Q_SELECT, err = mt76x02_mcu_function_select(dev, Q_SELECT, 1, false);
1, false);
if (err < 0) if (err < 0)
return err; return err;
return mt76x02_mcu_set_radio_state(&dev->mt76, true, false); return mt76x02_mcu_set_radio_state(dev, true, false);
} }
...@@ -29,12 +29,12 @@ void mt76x2u_phy_channel_calibrate(struct mt76x02_dev *dev) ...@@ -29,12 +29,12 @@ void mt76x2u_phy_channel_calibrate(struct mt76x02_dev *dev)
mt76x2u_mac_stop(dev); mt76x2u_mac_stop(dev);
if (is_5ghz) if (is_5ghz)
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_LC, 0, false); mt76x02_mcu_calibrate(dev, MCU_CAL_LC, 0, false);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TX_LOFT, is_5ghz, false); mt76x02_mcu_calibrate(dev, MCU_CAL_TX_LOFT, is_5ghz, false);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TXIQ, is_5ghz, false); mt76x02_mcu_calibrate(dev, MCU_CAL_TXIQ, is_5ghz, false);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RXIQC_FI, is_5ghz, false); mt76x02_mcu_calibrate(dev, MCU_CAL_RXIQC_FI, is_5ghz, false);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TEMP_SENSOR, 0, false); mt76x02_mcu_calibrate(dev, MCU_CAL_TEMP_SENSOR, 0, false);
mt76x2u_mac_resume(dev); mt76x2u_mac_resume(dev);
} }
...@@ -180,15 +180,14 @@ int mt76x2u_phy_set_channel(struct mt76x02_dev *dev, ...@@ -180,15 +180,14 @@ int mt76x2u_phy_set_channel(struct mt76x02_dev *dev,
u8 val = mt76x02_eeprom_get(&dev->mt76, MT_EE_BT_RCAL_RESULT); u8 val = mt76x02_eeprom_get(&dev->mt76, MT_EE_BT_RCAL_RESULT);
if (val != 0xff) if (val != 0xff)
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_R, mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0, false);
0, false);
} }
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RXDCOC, channel, false); mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, channel, false);
/* Rx LPF calibration */ /* Rx LPF calibration */
if (!dev->cal.init_cal_done) if (!dev->cal.init_cal_done)
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RC, 0, false); mt76x02_mcu_calibrate(dev, MCU_CAL_RC, 0, false);
dev->cal.init_cal_done = true; dev->cal.init_cal_done = true;
mt76_wr(dev, MT_BBP(AGC, 61), 0xff64a4e2); mt76_wr(dev, MT_BBP(AGC, 61), 0xff64a4e2);
...@@ -220,8 +219,7 @@ int mt76x2u_phy_set_channel(struct mt76x02_dev *dev, ...@@ -220,8 +219,7 @@ int mt76x2u_phy_set_channel(struct mt76x02_dev *dev,
flag |= BIT(0); flag |= BIT(0);
if (mt76x02_ext_pa_enabled(&dev->mt76, chan->band)) if (mt76x02_ext_pa_enabled(&dev->mt76, chan->band))
flag |= BIT(8); flag |= BIT(8);
mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TSSI, mt76x02_mcu_calibrate(dev, MCU_CAL_TSSI, flag, false);
flag, false);
dev->cal.tssi_cal_done = true; dev->cal.tssi_cal_done = true;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment