diff options
author | Lorenzo Bianconi <lorenzo.bianconi@redhat.com> | 2018-10-07 05:45:18 -0400 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2018-10-13 11:39:16 -0400 |
commit | 499cd0aa3ba60e202abf233d7a7b5e8a4b725d37 (patch) | |
tree | 057918dcd1a6f0105189b2667fcf37149a056a63 /drivers/net/wireless | |
parent | a14054ce0b8ada03a7ddea14e51812e2fd583c94 (diff) |
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: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless')
12 files changed, 86 insertions, 92 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/init.c b/drivers/net/wireless/mediatek/mt76/mt76x0/init.c index ee2b8e885608..abd8313f22e7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/init.c | |||
@@ -280,7 +280,7 @@ int mt76x0_init_hardware(struct mt76x02_dev *dev) | |||
280 | return -ETIMEDOUT; | 280 | return -ETIMEDOUT; |
281 | 281 | ||
282 | mt76x0_reset_csr_bbp(dev); | 282 | mt76x0_reset_csr_bbp(dev); |
283 | ret = mt76x02_mcu_function_select(&dev->mt76, Q_SELECT, 1, false); | 283 | ret = mt76x02_mcu_function_select(dev, Q_SELECT, 1, false); |
284 | if (ret) | 284 | if (ret) |
285 | return ret; | 285 | return ret; |
286 | 286 | ||
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c index 87997cddf0d6..4b29cd52aa44 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c | |||
@@ -167,7 +167,7 @@ static void mt76x0e_cleanup(struct mt76x02_dev *dev) | |||
167 | mt76x0_chip_onoff(dev, false, false); | 167 | mt76x0_chip_onoff(dev, false, false); |
168 | mt76x0e_stop_hw(dev); | 168 | mt76x0e_stop_hw(dev); |
169 | mt76x02_dma_cleanup(dev); | 169 | mt76x02_dma_cleanup(dev); |
170 | mt76x02_mcu_cleanup(&dev->mt76); | 170 | mt76x02_mcu_cleanup(dev); |
171 | } | 171 | } |
172 | 172 | ||
173 | static void | 173 | static void |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c index 4419c0078a6f..d5fe248e7839 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | |||
@@ -602,7 +602,7 @@ mt76x0_bbp_set_bw(struct mt76x02_dev *dev, enum nl80211_chan_width width) | |||
602 | return ; | 602 | return ; |
603 | } | 603 | } |
604 | 604 | ||
605 | mt76x02_mcu_function_select(&dev->mt76, BW_SETTING, bw, false); | 605 | mt76x02_mcu_function_select(dev, BW_SETTING, bw, false); |
606 | } | 606 | } |
607 | 607 | ||
608 | void mt76x0_phy_set_txpower(struct mt76x02_dev *dev) | 608 | void mt76x0_phy_set_txpower(struct mt76x02_dev *dev) |
@@ -712,7 +712,7 @@ int mt76x0_phy_set_channel(struct mt76x02_dev *dev, | |||
712 | 712 | ||
713 | mt76x0_vco_cal(dev, channel); | 713 | mt76x0_vco_cal(dev, channel); |
714 | if (scan) | 714 | if (scan) |
715 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RXDCOC, 1, false); | 715 | mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, 1, false); |
716 | 716 | ||
717 | mt76x0_phy_set_txpower(dev); | 717 | mt76x0_phy_set_txpower(dev); |
718 | 718 | ||
@@ -725,7 +725,7 @@ void mt76x0_phy_recalibrate_after_assoc(struct mt76x02_dev *dev) | |||
725 | u8 channel = dev->mt76.chandef.chan->hw_value; | 725 | u8 channel = dev->mt76.chandef.chan->hw_value; |
726 | int is_5ghz = (dev->mt76.chandef.chan->band == NL80211_BAND_5GHZ) ? 1 : 0; | 726 | int is_5ghz = (dev->mt76.chandef.chan->band == NL80211_BAND_5GHZ) ? 1 : 0; |
727 | 727 | ||
728 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_R, 0, false); | 728 | mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0, false); |
729 | 729 | ||
730 | mt76x0_vco_cal(dev, channel); | 730 | mt76x0_vco_cal(dev, channel); |
731 | 731 | ||
@@ -737,22 +737,20 @@ void mt76x0_phy_recalibrate_after_assoc(struct mt76x02_dev *dev) | |||
737 | reg_val &= 0xffffff7e; | 737 | reg_val &= 0xffffff7e; |
738 | mt76_wr(dev, 0x2124, reg_val); | 738 | mt76_wr(dev, 0x2124, reg_val); |
739 | 739 | ||
740 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RXDCOC, 0, false); | 740 | mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, 0, false); |
741 | 741 | ||
742 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_LC, is_5ghz, false); | 742 | mt76x02_mcu_calibrate(dev, MCU_CAL_LC, is_5ghz, false); |
743 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_LOFT, is_5ghz, false); | 743 | mt76x02_mcu_calibrate(dev, MCU_CAL_LOFT, is_5ghz, false); |
744 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TXIQ, is_5ghz, false); | 744 | mt76x02_mcu_calibrate(dev, MCU_CAL_TXIQ, is_5ghz, false); |
745 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TX_GROUP_DELAY, | 745 | mt76x02_mcu_calibrate(dev, MCU_CAL_TX_GROUP_DELAY, is_5ghz, false); |
746 | is_5ghz, false); | 746 | mt76x02_mcu_calibrate(dev, MCU_CAL_RXIQ, is_5ghz, false); |
747 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RXIQ, is_5ghz, false); | 747 | mt76x02_mcu_calibrate(dev, MCU_CAL_RX_GROUP_DELAY, is_5ghz, false); |
748 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RX_GROUP_DELAY, | ||
749 | is_5ghz, false); | ||
750 | 748 | ||
751 | mt76_wr(dev, 0x2124, reg_val); | 749 | mt76_wr(dev, 0x2124, reg_val); |
752 | mt76_wr(dev, MT_TX_ALC_CFG_0, tx_alc); | 750 | mt76_wr(dev, MT_TX_ALC_CFG_0, tx_alc); |
753 | msleep(100); | 751 | msleep(100); |
754 | 752 | ||
755 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RXDCOC, 1, false); | 753 | mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, 1, false); |
756 | } | 754 | } |
757 | 755 | ||
758 | void mt76x0_agc_save(struct mt76x02_dev *dev) | 756 | void mt76x0_agc_save(struct mt76x02_dev *dev) |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x02_mcu.c index 6d565133b7af..1b853bb723fb 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mcu.c | |||
@@ -19,9 +19,7 @@ | |||
19 | #include <linux/firmware.h> | 19 | #include <linux/firmware.h> |
20 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
21 | 21 | ||
22 | #include "mt76.h" | ||
23 | #include "mt76x02_mcu.h" | 22 | #include "mt76x02_mcu.h" |
24 | #include "mt76x02_dma.h" | ||
25 | 23 | ||
26 | struct sk_buff *mt76x02_mcu_msg_alloc(const void *data, int len) | 24 | struct sk_buff *mt76x02_mcu_msg_alloc(const void *data, int len) |
27 | { | 25 | { |
@@ -37,7 +35,7 @@ struct sk_buff *mt76x02_mcu_msg_alloc(const void *data, int len) | |||
37 | EXPORT_SYMBOL_GPL(mt76x02_mcu_msg_alloc); | 35 | EXPORT_SYMBOL_GPL(mt76x02_mcu_msg_alloc); |
38 | 36 | ||
39 | static struct sk_buff * | 37 | static struct sk_buff * |
40 | mt76x02_mcu_get_response(struct mt76_dev *dev, unsigned long expires) | 38 | mt76x02_mcu_get_response(struct mt76x02_dev *dev, unsigned long expires) |
41 | { | 39 | { |
42 | unsigned long timeout; | 40 | unsigned long timeout; |
43 | 41 | ||
@@ -45,17 +43,17 @@ mt76x02_mcu_get_response(struct mt76_dev *dev, unsigned long expires) | |||
45 | return NULL; | 43 | return NULL; |
46 | 44 | ||
47 | timeout = expires - jiffies; | 45 | timeout = expires - jiffies; |
48 | wait_event_timeout(dev->mmio.mcu.wait, | 46 | wait_event_timeout(dev->mt76.mmio.mcu.wait, |
49 | !skb_queue_empty(&dev->mmio.mcu.res_q), | 47 | !skb_queue_empty(&dev->mt76.mmio.mcu.res_q), |
50 | timeout); | 48 | timeout); |
51 | return skb_dequeue(&dev->mmio.mcu.res_q); | 49 | return skb_dequeue(&dev->mt76.mmio.mcu.res_q); |
52 | } | 50 | } |
53 | 51 | ||
54 | static int | 52 | static int |
55 | mt76x02_tx_queue_mcu(struct mt76_dev *dev, enum mt76_txq_id qid, | 53 | mt76x02_tx_queue_mcu(struct mt76x02_dev *dev, enum mt76_txq_id qid, |
56 | struct sk_buff *skb, int cmd, int seq) | 54 | struct sk_buff *skb, int cmd, int seq) |
57 | { | 55 | { |
58 | struct mt76_queue *q = &dev->q_tx[qid]; | 56 | struct mt76_queue *q = &dev->mt76.q_tx[qid]; |
59 | struct mt76_queue_buf buf; | 57 | struct mt76_queue_buf buf; |
60 | dma_addr_t addr; | 58 | dma_addr_t addr; |
61 | u32 tx_info; | 59 | u32 tx_info; |
@@ -66,24 +64,26 @@ mt76x02_tx_queue_mcu(struct mt76_dev *dev, enum mt76_txq_id qid, | |||
66 | FIELD_PREP(MT_MCU_MSG_PORT, CPU_TX_PORT) | | 64 | FIELD_PREP(MT_MCU_MSG_PORT, CPU_TX_PORT) | |
67 | FIELD_PREP(MT_MCU_MSG_LEN, skb->len); | 65 | FIELD_PREP(MT_MCU_MSG_LEN, skb->len); |
68 | 66 | ||
69 | addr = dma_map_single(dev->dev, skb->data, skb->len, | 67 | addr = dma_map_single(dev->mt76.dev, skb->data, skb->len, |
70 | DMA_TO_DEVICE); | 68 | DMA_TO_DEVICE); |
71 | if (dma_mapping_error(dev->dev, addr)) | 69 | if (dma_mapping_error(dev->mt76.dev, addr)) |
72 | return -ENOMEM; | 70 | return -ENOMEM; |
73 | 71 | ||
74 | buf.addr = addr; | 72 | buf.addr = addr; |
75 | buf.len = skb->len; | 73 | buf.len = skb->len; |
74 | |||
76 | spin_lock_bh(&q->lock); | 75 | spin_lock_bh(&q->lock); |
77 | dev->queue_ops->add_buf(dev, q, &buf, 1, tx_info, skb, NULL); | 76 | mt76_queue_add_buf(dev, q, &buf, 1, tx_info, skb, NULL); |
78 | dev->queue_ops->kick(dev, q); | 77 | mt76_queue_kick(dev, q); |
79 | spin_unlock_bh(&q->lock); | 78 | spin_unlock_bh(&q->lock); |
80 | 79 | ||
81 | return 0; | 80 | return 0; |
82 | } | 81 | } |
83 | 82 | ||
84 | int mt76x02_mcu_msg_send(struct mt76_dev *dev, struct sk_buff *skb, | 83 | int mt76x02_mcu_msg_send(struct mt76_dev *mdev, struct sk_buff *skb, |
85 | int cmd, bool wait_resp) | 84 | int cmd, bool wait_resp) |
86 | { | 85 | { |
86 | struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76); | ||
87 | unsigned long expires = jiffies + HZ; | 87 | unsigned long expires = jiffies + HZ; |
88 | int ret; | 88 | int ret; |
89 | u8 seq; | 89 | u8 seq; |
@@ -91,11 +91,11 @@ int mt76x02_mcu_msg_send(struct mt76_dev *dev, struct sk_buff *skb, | |||
91 | if (!skb) | 91 | if (!skb) |
92 | return -EINVAL; | 92 | return -EINVAL; |
93 | 93 | ||
94 | mutex_lock(&dev->mmio.mcu.mutex); | 94 | mutex_lock(&mdev->mmio.mcu.mutex); |
95 | 95 | ||
96 | seq = ++dev->mmio.mcu.msg_seq & 0xf; | 96 | seq = ++mdev->mmio.mcu.msg_seq & 0xf; |
97 | if (!seq) | 97 | if (!seq) |
98 | seq = ++dev->mmio.mcu.msg_seq & 0xf; | 98 | seq = ++mdev->mmio.mcu.msg_seq & 0xf; |
99 | 99 | ||
100 | ret = mt76x02_tx_queue_mcu(dev, MT_TXQ_MCU, skb, cmd, seq); | 100 | ret = mt76x02_tx_queue_mcu(dev, MT_TXQ_MCU, skb, cmd, seq); |
101 | if (ret) | 101 | if (ret) |
@@ -107,7 +107,7 @@ int mt76x02_mcu_msg_send(struct mt76_dev *dev, struct sk_buff *skb, | |||
107 | 107 | ||
108 | skb = mt76x02_mcu_get_response(dev, expires); | 108 | skb = mt76x02_mcu_get_response(dev, expires); |
109 | if (!skb) { | 109 | if (!skb) { |
110 | dev_err(dev->dev, | 110 | dev_err(mdev->dev, |
111 | "MCU message %d (seq %d) timed out\n", cmd, | 111 | "MCU message %d (seq %d) timed out\n", cmd, |
112 | seq); | 112 | seq); |
113 | ret = -ETIMEDOUT; | 113 | ret = -ETIMEDOUT; |
@@ -125,13 +125,13 @@ int mt76x02_mcu_msg_send(struct mt76_dev *dev, struct sk_buff *skb, | |||
125 | } | 125 | } |
126 | 126 | ||
127 | out: | 127 | out: |
128 | mutex_unlock(&dev->mmio.mcu.mutex); | 128 | mutex_unlock(&mdev->mmio.mcu.mutex); |
129 | 129 | ||
130 | return ret; | 130 | return ret; |
131 | } | 131 | } |
132 | EXPORT_SYMBOL_GPL(mt76x02_mcu_msg_send); | 132 | EXPORT_SYMBOL_GPL(mt76x02_mcu_msg_send); |
133 | 133 | ||
134 | int mt76x02_mcu_function_select(struct mt76_dev *dev, | 134 | int mt76x02_mcu_function_select(struct mt76x02_dev *dev, |
135 | enum mcu_function func, | 135 | enum mcu_function func, |
136 | u32 val, bool wait_resp) | 136 | u32 val, bool wait_resp) |
137 | { | 137 | { |
@@ -144,13 +144,12 @@ int mt76x02_mcu_function_select(struct mt76_dev *dev, | |||
144 | .value = cpu_to_le32(val), | 144 | .value = cpu_to_le32(val), |
145 | }; | 145 | }; |
146 | 146 | ||
147 | skb = dev->mcu_ops->mcu_msg_alloc(&msg, sizeof(msg)); | 147 | skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg)); |
148 | return dev->mcu_ops->mcu_send_msg(dev, skb, CMD_FUN_SET_OP, | 148 | return mt76_mcu_send_msg(dev, skb, CMD_FUN_SET_OP, wait_resp); |
149 | wait_resp); | ||
150 | } | 149 | } |
151 | EXPORT_SYMBOL_GPL(mt76x02_mcu_function_select); | 150 | EXPORT_SYMBOL_GPL(mt76x02_mcu_function_select); |
152 | 151 | ||
153 | int mt76x02_mcu_set_radio_state(struct mt76_dev *dev, bool on, | 152 | int mt76x02_mcu_set_radio_state(struct mt76x02_dev *dev, bool on, |
154 | bool wait_resp) | 153 | bool wait_resp) |
155 | { | 154 | { |
156 | struct sk_buff *skb; | 155 | struct sk_buff *skb; |
@@ -162,13 +161,12 @@ int mt76x02_mcu_set_radio_state(struct mt76_dev *dev, bool on, | |||
162 | .level = cpu_to_le32(0), | 161 | .level = cpu_to_le32(0), |
163 | }; | 162 | }; |
164 | 163 | ||
165 | skb = dev->mcu_ops->mcu_msg_alloc(&msg, sizeof(msg)); | 164 | skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg)); |
166 | return dev->mcu_ops->mcu_send_msg(dev, skb, CMD_POWER_SAVING_OP, | 165 | return mt76_mcu_send_msg(dev, skb, CMD_POWER_SAVING_OP, wait_resp); |
167 | wait_resp); | ||
168 | } | 166 | } |
169 | EXPORT_SYMBOL_GPL(mt76x02_mcu_set_radio_state); | 167 | EXPORT_SYMBOL_GPL(mt76x02_mcu_set_radio_state); |
170 | 168 | ||
171 | int mt76x02_mcu_calibrate(struct mt76_dev *dev, int type, | 169 | int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type, |
172 | u32 param, bool wait) | 170 | u32 param, bool wait) |
173 | { | 171 | { |
174 | struct sk_buff *skb; | 172 | struct sk_buff *skb; |
@@ -182,44 +180,44 @@ int mt76x02_mcu_calibrate(struct mt76_dev *dev, int type, | |||
182 | int ret; | 180 | int ret; |
183 | 181 | ||
184 | if (wait) | 182 | if (wait) |
185 | dev->bus->rmw(dev, MT_MCU_COM_REG0, BIT(31), 0); | 183 | mt76_rmw(dev, MT_MCU_COM_REG0, BIT(31), 0); |
186 | 184 | ||
187 | skb = dev->mcu_ops->mcu_msg_alloc(&msg, sizeof(msg)); | 185 | skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg)); |
188 | ret = dev->mcu_ops->mcu_send_msg(dev, skb, CMD_CALIBRATION_OP, true); | 186 | ret = mt76_mcu_send_msg(dev, skb, CMD_CALIBRATION_OP, true); |
189 | if (ret) | 187 | if (ret) |
190 | return ret; | 188 | return ret; |
191 | 189 | ||
192 | if (wait && | 190 | if (wait && |
193 | WARN_ON(!__mt76_poll_msec(dev, MT_MCU_COM_REG0, | 191 | WARN_ON(!mt76_poll_msec(dev, MT_MCU_COM_REG0, |
194 | BIT(31), BIT(31), 100))) | 192 | BIT(31), BIT(31), 100))) |
195 | return -ETIMEDOUT; | 193 | return -ETIMEDOUT; |
196 | 194 | ||
197 | return 0; | 195 | return 0; |
198 | } | 196 | } |
199 | EXPORT_SYMBOL_GPL(mt76x02_mcu_calibrate); | 197 | EXPORT_SYMBOL_GPL(mt76x02_mcu_calibrate); |
200 | 198 | ||
201 | int mt76x02_mcu_cleanup(struct mt76_dev *dev) | 199 | int mt76x02_mcu_cleanup(struct mt76x02_dev *dev) |
202 | { | 200 | { |
203 | struct sk_buff *skb; | 201 | struct sk_buff *skb; |
204 | 202 | ||
205 | dev->bus->wr(dev, MT_MCU_INT_LEVEL, 1); | 203 | mt76_wr(dev, MT_MCU_INT_LEVEL, 1); |
206 | usleep_range(20000, 30000); | 204 | usleep_range(20000, 30000); |
207 | 205 | ||
208 | while ((skb = skb_dequeue(&dev->mmio.mcu.res_q)) != NULL) | 206 | while ((skb = skb_dequeue(&dev->mt76.mmio.mcu.res_q)) != NULL) |
209 | dev_kfree_skb(skb); | 207 | dev_kfree_skb(skb); |
210 | 208 | ||
211 | return 0; | 209 | return 0; |
212 | } | 210 | } |
213 | EXPORT_SYMBOL_GPL(mt76x02_mcu_cleanup); | 211 | EXPORT_SYMBOL_GPL(mt76x02_mcu_cleanup); |
214 | 212 | ||
215 | void mt76x02_set_ethtool_fwver(struct mt76_dev *dev, | 213 | void mt76x02_set_ethtool_fwver(struct mt76x02_dev *dev, |
216 | const struct mt76x02_fw_header *h) | 214 | const struct mt76x02_fw_header *h) |
217 | { | 215 | { |
218 | u16 bld = le16_to_cpu(h->build_ver); | 216 | u16 bld = le16_to_cpu(h->build_ver); |
219 | u16 ver = le16_to_cpu(h->fw_ver); | 217 | u16 ver = le16_to_cpu(h->fw_ver); |
220 | 218 | ||
221 | snprintf(dev->hw->wiphy->fw_version, | 219 | snprintf(dev->mt76.hw->wiphy->fw_version, |
222 | sizeof(dev->hw->wiphy->fw_version), | 220 | sizeof(dev->mt76.hw->wiphy->fw_version), |
223 | "%d.%d.%02d-b%x", | 221 | "%d.%d.%02d-b%x", |
224 | (ver >> 12) & 0xf, (ver >> 8) & 0xf, ver & 0xf, bld); | 222 | (ver >> 12) & 0xf, (ver >> 8) & 0xf, ver & 0xf, bld); |
225 | } | 223 | } |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76x02_mcu.h index ce664f8b1c94..2d8fd2514570 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mcu.h | |||
@@ -17,6 +17,8 @@ | |||
17 | #ifndef __MT76x02_MCU_H | 17 | #ifndef __MT76x02_MCU_H |
18 | #define __MT76x02_MCU_H | 18 | #define __MT76x02_MCU_H |
19 | 19 | ||
20 | #include "mt76x02.h" | ||
21 | |||
20 | #define MT_MCU_RESET_CTL 0x070C | 22 | #define MT_MCU_RESET_CTL 0x070C |
21 | #define MT_MCU_INT_LEVEL 0x0718 | 23 | #define MT_MCU_INT_LEVEL 0x0718 |
22 | #define MT_MCU_COM_REG0 0x0730 | 24 | #define MT_MCU_COM_REG0 0x0730 |
@@ -94,18 +96,18 @@ struct mt76x02_patch_header { | |||
94 | u8 pad[2]; | 96 | u8 pad[2]; |
95 | }; | 97 | }; |
96 | 98 | ||
97 | int mt76x02_mcu_cleanup(struct mt76_dev *dev); | 99 | int mt76x02_mcu_cleanup(struct mt76x02_dev *dev); |
98 | int mt76x02_mcu_calibrate(struct mt76_dev *dev, int type, | 100 | int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type, |
99 | u32 param, bool wait); | 101 | u32 param, bool wait); |
100 | struct sk_buff *mt76x02_mcu_msg_alloc(const void *data, int len); | 102 | struct sk_buff *mt76x02_mcu_msg_alloc(const void *data, int len); |
101 | int mt76x02_mcu_msg_send(struct mt76_dev *dev, struct sk_buff *skb, | 103 | int mt76x02_mcu_msg_send(struct mt76_dev *mdev, struct sk_buff *skb, |
102 | int cmd, bool wait_resp); | 104 | int cmd, bool wait_resp); |
103 | int mt76x02_mcu_function_select(struct mt76_dev *dev, | 105 | int mt76x02_mcu_function_select(struct mt76x02_dev *dev, |
104 | enum mcu_function func, | 106 | enum mcu_function func, |
105 | u32 val, bool wait_resp); | 107 | u32 val, bool wait_resp); |
106 | int mt76x02_mcu_set_radio_state(struct mt76_dev *dev, bool on, | 108 | int mt76x02_mcu_set_radio_state(struct mt76x02_dev *dev, bool on, |
107 | bool wait_resp); | 109 | bool wait_resp); |
108 | void mt76x02_set_ethtool_fwver(struct mt76_dev *dev, | 110 | void mt76x02_set_ethtool_fwver(struct mt76x02_dev *dev, |
109 | const struct mt76x02_fw_header *h); | 111 | const struct mt76x02_fw_header *h); |
110 | 112 | ||
111 | #endif /* __MT76x02_MCU_H */ | 113 | #endif /* __MT76x02_MCU_H */ |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c index f229c6eb65dc..620a8c93c222 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c | |||
@@ -337,7 +337,7 @@ void mt76x2_stop_hardware(struct mt76x02_dev *dev) | |||
337 | { | 337 | { |
338 | cancel_delayed_work_sync(&dev->cal_work); | 338 | cancel_delayed_work_sync(&dev->cal_work); |
339 | cancel_delayed_work_sync(&dev->mac_work); | 339 | cancel_delayed_work_sync(&dev->mac_work); |
340 | mt76x02_mcu_set_radio_state(&dev->mt76, false, true); | 340 | mt76x02_mcu_set_radio_state(dev, false, true); |
341 | mt76x2_mac_stop(dev, false); | 341 | mt76x2_mac_stop(dev, false); |
342 | } | 342 | } |
343 | 343 | ||
@@ -347,7 +347,7 @@ void mt76x2_cleanup(struct mt76x02_dev *dev) | |||
347 | tasklet_disable(&dev->pre_tbtt_tasklet); | 347 | tasklet_disable(&dev->pre_tbtt_tasklet); |
348 | mt76x2_stop_hardware(dev); | 348 | mt76x2_stop_hardware(dev); |
349 | mt76x02_dma_cleanup(dev); | 349 | mt76x02_dma_cleanup(dev); |
350 | mt76x02_mcu_cleanup(&dev->mt76); | 350 | mt76x02_mcu_cleanup(dev); |
351 | } | 351 | } |
352 | 352 | ||
353 | struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev) | 353 | struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev) |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c index 898aa229671c..563e2c459409 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c | |||
@@ -152,8 +152,8 @@ mt76pci_load_firmware(struct mt76x02_dev *dev) | |||
152 | return -ETIMEDOUT; | 152 | return -ETIMEDOUT; |
153 | } | 153 | } |
154 | 154 | ||
155 | mt76x02_set_ethtool_fwver(dev, hdr); | ||
155 | dev_info(dev->mt76.dev, "Firmware running!\n"); | 156 | dev_info(dev->mt76.dev, "Firmware running!\n"); |
156 | mt76x02_set_ethtool_fwver(&dev->mt76, hdr); | ||
157 | 157 | ||
158 | release_firmware(fw); | 158 | release_firmware(fw); |
159 | 159 | ||
@@ -183,6 +183,6 @@ int mt76x2_mcu_init(struct mt76x02_dev *dev) | |||
183 | if (ret) | 183 | if (ret) |
184 | return ret; | 184 | return ret; |
185 | 185 | ||
186 | mt76x02_mcu_function_select(&dev->mt76, Q_SELECT, 1, true); | 186 | mt76x02_mcu_function_select(dev, Q_SELECT, 1, true); |
187 | return 0; | 187 | return 0; |
188 | } | 188 | } |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c index 40ea5f7480fb..bdc6fba217b1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c | |||
@@ -38,7 +38,7 @@ mt76x2_phy_tssi_init_cal(struct mt76x02_dev *dev) | |||
38 | if (mt76x02_ext_pa_enabled(&dev->mt76, chan->band)) | 38 | if (mt76x02_ext_pa_enabled(&dev->mt76, chan->band)) |
39 | flag |= BIT(8); | 39 | flag |= BIT(8); |
40 | 40 | ||
41 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TSSI, flag, true); | 41 | mt76x02_mcu_calibrate(dev, MCU_CAL_TSSI, flag, true); |
42 | dev->cal.tssi_cal_done = true; | 42 | dev->cal.tssi_cal_done = true; |
43 | return true; | 43 | return true; |
44 | } | 44 | } |
@@ -62,13 +62,13 @@ mt76x2_phy_channel_calibrate(struct mt76x02_dev *dev, bool mac_stopped) | |||
62 | mt76x2_mac_stop(dev, false); | 62 | mt76x2_mac_stop(dev, false); |
63 | 63 | ||
64 | if (is_5ghz) | 64 | if (is_5ghz) |
65 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_LC, 0, true); | 65 | mt76x02_mcu_calibrate(dev, MCU_CAL_LC, 0, true); |
66 | 66 | ||
67 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TX_LOFT, is_5ghz, true); | 67 | mt76x02_mcu_calibrate(dev, MCU_CAL_TX_LOFT, is_5ghz, true); |
68 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TXIQ, is_5ghz, true); | 68 | mt76x02_mcu_calibrate(dev, MCU_CAL_TXIQ, is_5ghz, true); |
69 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RXIQC_FI, is_5ghz, true); | 69 | mt76x02_mcu_calibrate(dev, MCU_CAL_RXIQC_FI, is_5ghz, true); |
70 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TEMP_SENSOR, 0, true); | 70 | mt76x02_mcu_calibrate(dev, MCU_CAL_TEMP_SENSOR, 0, true); |
71 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TX_SHAPING, 0, true); | 71 | mt76x02_mcu_calibrate(dev, MCU_CAL_TX_SHAPING, 0, true); |
72 | 72 | ||
73 | if (!mac_stopped) | 73 | if (!mac_stopped) |
74 | mt76x2_mac_resume(dev); | 74 | mt76x2_mac_resume(dev); |
@@ -364,14 +364,14 @@ int mt76x2_phy_set_channel(struct mt76x02_dev *dev, | |||
364 | u8 val = mt76x02_eeprom_get(&dev->mt76, MT_EE_BT_RCAL_RESULT); | 364 | u8 val = mt76x02_eeprom_get(&dev->mt76, MT_EE_BT_RCAL_RESULT); |
365 | 365 | ||
366 | if (val != 0xff) | 366 | if (val != 0xff) |
367 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_R, 0, true); | 367 | mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0, true); |
368 | } | 368 | } |
369 | 369 | ||
370 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RXDCOC, channel, true); | 370 | mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, channel, true); |
371 | 371 | ||
372 | /* Rx LPF calibration */ | 372 | /* Rx LPF calibration */ |
373 | if (!dev->cal.init_cal_done) | 373 | if (!dev->cal.init_cal_done) |
374 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RC, 0, true); | 374 | mt76x02_mcu_calibrate(dev, MCU_CAL_RC, 0, true); |
375 | 375 | ||
376 | dev->cal.init_cal_done = true; | 376 | dev->cal.init_cal_done = true; |
377 | 377 | ||
@@ -449,7 +449,7 @@ int mt76x2_phy_start(struct mt76x02_dev *dev) | |||
449 | { | 449 | { |
450 | int ret; | 450 | int ret; |
451 | 451 | ||
452 | ret = mt76x02_mcu_set_radio_state(&dev->mt76, true, true); | 452 | ret = mt76x02_mcu_set_radio_state(dev, true, true); |
453 | if (ret) | 453 | if (ret) |
454 | return ret; | 454 | return ret; |
455 | 455 | ||
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c index f00aed915ee8..31bf0f891028 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c | |||
@@ -289,8 +289,7 @@ void mt76x2_phy_tssi_compensate(struct mt76x02_dev *dev, bool wait) | |||
289 | return; | 289 | return; |
290 | 290 | ||
291 | usleep_range(10000, 20000); | 291 | usleep_range(10000, 20000); |
292 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_DPD, | 292 | mt76x02_mcu_calibrate(dev, MCU_CAL_DPD, chan->hw_value, wait); |
293 | chan->hw_value, wait); | ||
294 | dev->cal.dpd_cal_done = true; | 293 | dev->cal.dpd_cal_done = true; |
295 | } | 294 | } |
296 | } | 295 | } |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c index c82f16efa327..7578c7dcd62a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c | |||
@@ -303,7 +303,7 @@ void mt76x2u_stop_hw(struct mt76x02_dev *dev) | |||
303 | 303 | ||
304 | void mt76x2u_cleanup(struct mt76x02_dev *dev) | 304 | void mt76x2u_cleanup(struct mt76x02_dev *dev) |
305 | { | 305 | { |
306 | mt76x02_mcu_set_radio_state(&dev->mt76, false, false); | 306 | mt76x02_mcu_set_radio_state(dev, false, false); |
307 | mt76x2u_stop_hw(dev); | 307 | mt76x2u_stop_hw(dev); |
308 | mt76u_queues_deinit(&dev->mt76); | 308 | mt76u_queues_deinit(&dev->mt76); |
309 | mt76u_mcu_deinit(&dev->mt76); | 309 | mt76u_mcu_deinit(&dev->mt76); |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c index 259ceae2a3a9..0475bff454c0 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c | |||
@@ -260,8 +260,8 @@ static int mt76x2u_mcu_load_firmware(struct mt76x02_dev *dev) | |||
260 | mt76_set(dev, MT_MCU_COM_REG0, BIT(1)); | 260 | mt76_set(dev, MT_MCU_COM_REG0, BIT(1)); |
261 | /* enable FCE to send in-band cmd */ | 261 | /* enable FCE to send in-band cmd */ |
262 | mt76_wr(dev, MT_FCE_PSE_CTRL, 0x1); | 262 | mt76_wr(dev, MT_FCE_PSE_CTRL, 0x1); |
263 | mt76x02_set_ethtool_fwver(dev, hdr); | ||
263 | dev_dbg(dev->mt76.dev, "firmware running\n"); | 264 | dev_dbg(dev->mt76.dev, "firmware running\n"); |
264 | mt76x02_set_ethtool_fwver(&dev->mt76, hdr); | ||
265 | 265 | ||
266 | out: | 266 | out: |
267 | release_firmware(fw); | 267 | release_firmware(fw); |
@@ -283,10 +283,9 @@ int mt76x2u_mcu_init(struct mt76x02_dev *dev) | |||
283 | { | 283 | { |
284 | int err; | 284 | int err; |
285 | 285 | ||
286 | err = mt76x02_mcu_function_select(&dev->mt76, Q_SELECT, | 286 | err = mt76x02_mcu_function_select(dev, Q_SELECT, 1, false); |
287 | 1, false); | ||
288 | if (err < 0) | 287 | if (err < 0) |
289 | return err; | 288 | return err; |
290 | 289 | ||
291 | return mt76x02_mcu_set_radio_state(&dev->mt76, true, false); | 290 | return mt76x02_mcu_set_radio_state(dev, true, false); |
292 | } | 291 | } |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c index b11f8a6a6254..e0ffdd51dced 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c | |||
@@ -29,12 +29,12 @@ void mt76x2u_phy_channel_calibrate(struct mt76x02_dev *dev) | |||
29 | mt76x2u_mac_stop(dev); | 29 | mt76x2u_mac_stop(dev); |
30 | 30 | ||
31 | if (is_5ghz) | 31 | if (is_5ghz) |
32 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_LC, 0, false); | 32 | mt76x02_mcu_calibrate(dev, MCU_CAL_LC, 0, false); |
33 | 33 | ||
34 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TX_LOFT, is_5ghz, false); | 34 | mt76x02_mcu_calibrate(dev, MCU_CAL_TX_LOFT, is_5ghz, false); |
35 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TXIQ, is_5ghz, false); | 35 | mt76x02_mcu_calibrate(dev, MCU_CAL_TXIQ, is_5ghz, false); |
36 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RXIQC_FI, is_5ghz, false); | 36 | mt76x02_mcu_calibrate(dev, MCU_CAL_RXIQC_FI, is_5ghz, false); |
37 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TEMP_SENSOR, 0, false); | 37 | mt76x02_mcu_calibrate(dev, MCU_CAL_TEMP_SENSOR, 0, false); |
38 | 38 | ||
39 | mt76x2u_mac_resume(dev); | 39 | mt76x2u_mac_resume(dev); |
40 | } | 40 | } |
@@ -180,15 +180,14 @@ int mt76x2u_phy_set_channel(struct mt76x02_dev *dev, | |||
180 | u8 val = mt76x02_eeprom_get(&dev->mt76, MT_EE_BT_RCAL_RESULT); | 180 | u8 val = mt76x02_eeprom_get(&dev->mt76, MT_EE_BT_RCAL_RESULT); |
181 | 181 | ||
182 | if (val != 0xff) | 182 | if (val != 0xff) |
183 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_R, | 183 | mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0, false); |
184 | 0, false); | ||
185 | } | 184 | } |
186 | 185 | ||
187 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RXDCOC, channel, false); | 186 | mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, channel, false); |
188 | 187 | ||
189 | /* Rx LPF calibration */ | 188 | /* Rx LPF calibration */ |
190 | if (!dev->cal.init_cal_done) | 189 | if (!dev->cal.init_cal_done) |
191 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_RC, 0, false); | 190 | mt76x02_mcu_calibrate(dev, MCU_CAL_RC, 0, false); |
192 | dev->cal.init_cal_done = true; | 191 | dev->cal.init_cal_done = true; |
193 | 192 | ||
194 | mt76_wr(dev, MT_BBP(AGC, 61), 0xff64a4e2); | 193 | mt76_wr(dev, MT_BBP(AGC, 61), 0xff64a4e2); |
@@ -220,8 +219,7 @@ int mt76x2u_phy_set_channel(struct mt76x02_dev *dev, | |||
220 | flag |= BIT(0); | 219 | flag |= BIT(0); |
221 | if (mt76x02_ext_pa_enabled(&dev->mt76, chan->band)) | 220 | if (mt76x02_ext_pa_enabled(&dev->mt76, chan->band)) |
222 | flag |= BIT(8); | 221 | flag |= BIT(8); |
223 | mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_TSSI, | 222 | mt76x02_mcu_calibrate(dev, MCU_CAL_TSSI, flag, false); |
224 | flag, false); | ||
225 | dev->cal.tssi_cal_done = true; | 223 | dev->cal.tssi_cal_done = true; |
226 | } | 224 | } |
227 | } | 225 | } |