aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>2018-10-07 05:45:21 -0400
committerFelix Fietkau <nbd@nbd.name>2018-10-13 11:39:20 -0400
commit95c3e451e6277462790b56aac568414c067a11f8 (patch)
treed181c7d3d7dfb53ce7f84432212dda590200e8a7 /drivers/net/wireless
parentd87cf75f11118367f2e85dd049be9cab22ae0138 (diff)
mt76: use mt76x02_dev instead of mt76_dev in mt76x02_usb_mcu.c
Use mt76x02_dev data structure as reference in mt76x02_usb_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')
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x0/usb_mcu.c7
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x02_usb.h6
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x02_usb_mcu.c27
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c11
4 files changed, 24 insertions, 27 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb_mcu.c
index fb6fa1fa5548..a9f14d5149d1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb_mcu.c
@@ -40,8 +40,7 @@ mt76x0u_upload_firmware(struct mt76x02_dev *dev,
40 ilm_len = le32_to_cpu(hdr->ilm_len) - MT_MCU_IVB_SIZE; 40 ilm_len = le32_to_cpu(hdr->ilm_len) - MT_MCU_IVB_SIZE;
41 dev_dbg(dev->mt76.dev, "loading FW - ILM %u + IVB %u\n", 41 dev_dbg(dev->mt76.dev, "loading FW - ILM %u + IVB %u\n",
42 ilm_len, MT_MCU_IVB_SIZE); 42 ilm_len, MT_MCU_IVB_SIZE);
43 err = mt76x02u_mcu_fw_send_data(&dev->mt76, 43 err = mt76x02u_mcu_fw_send_data(dev, fw_payload + MT_MCU_IVB_SIZE,
44 fw_payload + MT_MCU_IVB_SIZE,
45 ilm_len, MCU_FW_URB_MAX_PAYLOAD, 44 ilm_len, MCU_FW_URB_MAX_PAYLOAD,
46 MT_MCU_IVB_SIZE); 45 MT_MCU_IVB_SIZE);
47 if (err) 46 if (err)
@@ -49,7 +48,7 @@ mt76x0u_upload_firmware(struct mt76x02_dev *dev,
49 48
50 dlm_len = le32_to_cpu(hdr->dlm_len); 49 dlm_len = le32_to_cpu(hdr->dlm_len);
51 dev_dbg(dev->mt76.dev, "loading FW - DLM %u\n", dlm_len); 50 dev_dbg(dev->mt76.dev, "loading FW - DLM %u\n", dlm_len);
52 err = mt76x02u_mcu_fw_send_data(&dev->mt76, 51 err = mt76x02u_mcu_fw_send_data(dev,
53 fw_payload + le32_to_cpu(hdr->ilm_len), 52 fw_payload + le32_to_cpu(hdr->ilm_len),
54 dlm_len, MCU_FW_URB_MAX_PAYLOAD, 53 dlm_len, MCU_FW_URB_MAX_PAYLOAD,
55 MT_MCU_DLM_OFFSET); 54 MT_MCU_DLM_OFFSET);
@@ -121,7 +120,7 @@ static int mt76x0u_load_firmware(struct mt76x02_dev *dev)
121 mt76_set(dev, MT_USB_DMA_CFG, 120 mt76_set(dev, MT_USB_DMA_CFG,
122 (MT_USB_DMA_CFG_RX_BULK_EN | MT_USB_DMA_CFG_TX_BULK_EN) | 121 (MT_USB_DMA_CFG_RX_BULK_EN | MT_USB_DMA_CFG_TX_BULK_EN) |
123 FIELD_PREP(MT_USB_DMA_CFG_RX_BULK_AGG_TOUT, 0x20)); 122 FIELD_PREP(MT_USB_DMA_CFG_RX_BULK_AGG_TOUT, 0x20));
124 mt76x02u_mcu_fw_reset(&dev->mt76); 123 mt76x02u_mcu_fw_reset(dev);
125 usleep_range(5000, 6000); 124 usleep_range(5000, 6000);
126/* 125/*
127 mt76x0_rmw(dev, MT_PBF_CFG, 0, (MT_PBF_CFG_TX0Q_EN | 126 mt76x0_rmw(dev, MT_PBF_CFG, 0, (MT_PBF_CFG_TX0Q_EN |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_usb.h b/drivers/net/wireless/mediatek/mt76/mt76x02_usb.h
index 6b2138328eb2..28aabcfd1195 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_usb.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_usb.h
@@ -17,11 +17,11 @@
17#ifndef __MT76x02_USB_H 17#ifndef __MT76x02_USB_H
18#define __MT76x02_USB_H 18#define __MT76x02_USB_H
19 19
20#include "mt76.h" 20#include "mt76x02.h"
21 21
22void mt76x02u_init_mcu(struct mt76_dev *dev); 22void mt76x02u_init_mcu(struct mt76_dev *dev);
23void mt76x02u_mcu_fw_reset(struct mt76_dev *dev); 23void mt76x02u_mcu_fw_reset(struct mt76x02_dev *dev);
24int mt76x02u_mcu_fw_send_data(struct mt76_dev *dev, const void *data, 24int mt76x02u_mcu_fw_send_data(struct mt76x02_dev *dev, const void *data,
25 int data_len, u32 max_payload, u32 offset); 25 int data_len, u32 max_payload, u32 offset);
26 26
27int mt76x02u_skb_dma_info(struct sk_buff *skb, int port, u32 flags); 27int mt76x02u_skb_dma_info(struct sk_buff *skb, int port, u32 flags);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_mcu.c
index cb5f073f08af..da299b8a1334 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_mcu.c
@@ -17,8 +17,7 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/firmware.h> 18#include <linux/firmware.h>
19 19
20#include "mt76.h" 20#include "mt76x02.h"
21#include "mt76x02_dma.h"
22#include "mt76x02_mcu.h" 21#include "mt76x02_mcu.h"
23#include "mt76x02_usb.h" 22#include "mt76x02_usb.h"
24 23
@@ -255,16 +254,16 @@ mt76x02u_mcu_rd_rp(struct mt76_dev *dev, u32 base,
255 return ret; 254 return ret;
256} 255}
257 256
258void mt76x02u_mcu_fw_reset(struct mt76_dev *dev) 257void mt76x02u_mcu_fw_reset(struct mt76x02_dev *dev)
259{ 258{
260 mt76u_vendor_request(dev, MT_VEND_DEV_MODE, 259 mt76u_vendor_request(&dev->mt76, MT_VEND_DEV_MODE,
261 USB_DIR_OUT | USB_TYPE_VENDOR, 260 USB_DIR_OUT | USB_TYPE_VENDOR,
262 0x1, 0, NULL, 0); 261 0x1, 0, NULL, 0);
263} 262}
264EXPORT_SYMBOL_GPL(mt76x02u_mcu_fw_reset); 263EXPORT_SYMBOL_GPL(mt76x02u_mcu_fw_reset);
265 264
266static int 265static int
267__mt76x02u_mcu_fw_send_data(struct mt76_dev *dev, struct mt76u_buf *buf, 266__mt76x02u_mcu_fw_send_data(struct mt76x02_dev *dev, struct mt76u_buf *buf,
268 const void *fw_data, int len, u32 dst_addr) 267 const void *fw_data, int len, u32 dst_addr)
269{ 268{
270 u8 *data = sg_virt(&buf->urb->sg[0]); 269 u8 *data = sg_virt(&buf->urb->sg[0]);
@@ -281,14 +280,14 @@ __mt76x02u_mcu_fw_send_data(struct mt76_dev *dev, struct mt76u_buf *buf,
281 memcpy(data + sizeof(info), fw_data, len); 280 memcpy(data + sizeof(info), fw_data, len);
282 memset(data + sizeof(info) + len, 0, 4); 281 memset(data + sizeof(info) + len, 0, 4);
283 282
284 mt76u_single_wr(dev, MT_VEND_WRITE_FCE, 283 mt76u_single_wr(&dev->mt76, MT_VEND_WRITE_FCE,
285 MT_FCE_DMA_ADDR, dst_addr); 284 MT_FCE_DMA_ADDR, dst_addr);
286 len = roundup(len, 4); 285 len = roundup(len, 4);
287 mt76u_single_wr(dev, MT_VEND_WRITE_FCE, 286 mt76u_single_wr(&dev->mt76, MT_VEND_WRITE_FCE,
288 MT_FCE_DMA_LEN, len << 16); 287 MT_FCE_DMA_LEN, len << 16);
289 288
290 buf->len = MT_CMD_HDR_LEN + len + sizeof(info); 289 buf->len = MT_CMD_HDR_LEN + len + sizeof(info);
291 err = mt76u_submit_buf(dev, USB_DIR_OUT, 290 err = mt76u_submit_buf(&dev->mt76, USB_DIR_OUT,
292 MT_EP_OUT_INBAND_CMD, 291 MT_EP_OUT_INBAND_CMD,
293 buf, GFP_KERNEL, 292 buf, GFP_KERNEL,
294 mt76u_mcu_complete_urb, &cmpl); 293 mt76u_mcu_complete_urb, &cmpl);
@@ -297,31 +296,31 @@ __mt76x02u_mcu_fw_send_data(struct mt76_dev *dev, struct mt76u_buf *buf,
297 296
298 if (!wait_for_completion_timeout(&cmpl, 297 if (!wait_for_completion_timeout(&cmpl,
299 msecs_to_jiffies(1000))) { 298 msecs_to_jiffies(1000))) {
300 dev_err(dev->dev, "firmware upload timed out\n"); 299 dev_err(dev->mt76.dev, "firmware upload timed out\n");
301 usb_kill_urb(buf->urb); 300 usb_kill_urb(buf->urb);
302 return -ETIMEDOUT; 301 return -ETIMEDOUT;
303 } 302 }
304 303
305 if (mt76u_urb_error(buf->urb)) { 304 if (mt76u_urb_error(buf->urb)) {
306 dev_err(dev->dev, "firmware upload failed: %d\n", 305 dev_err(dev->mt76.dev, "firmware upload failed: %d\n",
307 buf->urb->status); 306 buf->urb->status);
308 return buf->urb->status; 307 return buf->urb->status;
309 } 308 }
310 309
311 val = mt76u_rr(dev, MT_TX_CPU_FROM_FCE_CPU_DESC_IDX); 310 val = mt76_rr(dev, MT_TX_CPU_FROM_FCE_CPU_DESC_IDX);
312 val++; 311 val++;
313 mt76u_wr(dev, MT_TX_CPU_FROM_FCE_CPU_DESC_IDX, val); 312 mt76_wr(dev, MT_TX_CPU_FROM_FCE_CPU_DESC_IDX, val);
314 313
315 return 0; 314 return 0;
316} 315}
317 316
318int mt76x02u_mcu_fw_send_data(struct mt76_dev *dev, const void *data, 317int mt76x02u_mcu_fw_send_data(struct mt76x02_dev *dev, const void *data,
319 int data_len, u32 max_payload, u32 offset) 318 int data_len, u32 max_payload, u32 offset)
320{ 319{
321 int err, len, pos = 0, max_len = max_payload - 8; 320 int err, len, pos = 0, max_len = max_payload - 8;
322 struct mt76u_buf buf; 321 struct mt76u_buf buf;
323 322
324 err = mt76u_buf_alloc(dev, &buf, 1, max_payload, max_payload, 323 err = mt76u_buf_alloc(&dev->mt76, &buf, 1, max_payload, max_payload,
325 GFP_KERNEL); 324 GFP_KERNEL);
326 if (err < 0) 325 if (err < 0)
327 return err; 326 return err;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c
index 0475bff454c0..3f1e558e5e6d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c
@@ -137,7 +137,7 @@ static int mt76x2u_mcu_load_rom_patch(struct mt76x02_dev *dev)
137 mt76_wr(dev, MT_VEND_ADDR(CFG, MT_USB_U3DMA_CFG), val); 137 mt76_wr(dev, MT_VEND_ADDR(CFG, MT_USB_U3DMA_CFG), val);
138 138
139 /* vendor reset */ 139 /* vendor reset */
140 mt76x02u_mcu_fw_reset(&dev->mt76); 140 mt76x02u_mcu_fw_reset(dev);
141 usleep_range(5000, 10000); 141 usleep_range(5000, 10000);
142 142
143 /* enable FCE to send in-band cmd */ 143 /* enable FCE to send in-band cmd */
@@ -151,7 +151,7 @@ static int mt76x2u_mcu_load_rom_patch(struct mt76x02_dev *dev)
151 /* FCE skip_fs_en */ 151 /* FCE skip_fs_en */
152 mt76_wr(dev, MT_FCE_SKIP_FS, 0x3); 152 mt76_wr(dev, MT_FCE_SKIP_FS, 0x3);
153 153
154 err = mt76x02u_mcu_fw_send_data(&dev->mt76, fw->data + sizeof(*hdr), 154 err = mt76x02u_mcu_fw_send_data(dev, fw->data + sizeof(*hdr),
155 fw->size - sizeof(*hdr), 155 fw->size - sizeof(*hdr),
156 MCU_ROM_PATCH_MAX_PAYLOAD, 156 MCU_ROM_PATCH_MAX_PAYLOAD,
157 MT76U_MCU_ROM_PATCH_OFFSET); 157 MT76U_MCU_ROM_PATCH_OFFSET);
@@ -210,7 +210,7 @@ static int mt76x2u_mcu_load_firmware(struct mt76x02_dev *dev)
210 dev_info(dev->mt76.dev, "Build Time: %.16s\n", hdr->build_time); 210 dev_info(dev->mt76.dev, "Build Time: %.16s\n", hdr->build_time);
211 211
212 /* vendor reset */ 212 /* vendor reset */
213 mt76x02u_mcu_fw_reset(&dev->mt76); 213 mt76x02u_mcu_fw_reset(dev);
214 usleep_range(5000, 10000); 214 usleep_range(5000, 10000);
215 215
216 /* enable USB_DMA_CFG */ 216 /* enable USB_DMA_CFG */
@@ -230,7 +230,7 @@ static int mt76x2u_mcu_load_firmware(struct mt76x02_dev *dev)
230 mt76_wr(dev, MT_FCE_SKIP_FS, 0x3); 230 mt76_wr(dev, MT_FCE_SKIP_FS, 0x3);
231 231
232 /* load ILM */ 232 /* load ILM */
233 err = mt76x02u_mcu_fw_send_data(&dev->mt76, fw->data + sizeof(*hdr), 233 err = mt76x02u_mcu_fw_send_data(dev, fw->data + sizeof(*hdr),
234 ilm_len, MCU_FW_URB_MAX_PAYLOAD, 234 ilm_len, MCU_FW_URB_MAX_PAYLOAD,
235 MT76U_MCU_ILM_OFFSET); 235 MT76U_MCU_ILM_OFFSET);
236 if (err < 0) { 236 if (err < 0) {
@@ -241,8 +241,7 @@ static int mt76x2u_mcu_load_firmware(struct mt76x02_dev *dev)
241 /* load DLM */ 241 /* load DLM */
242 if (mt76xx_rev(dev) >= MT76XX_REV_E3) 242 if (mt76xx_rev(dev) >= MT76XX_REV_E3)
243 dlm_offset += 0x800; 243 dlm_offset += 0x800;
244 err = mt76x02u_mcu_fw_send_data(&dev->mt76, 244 err = mt76x02u_mcu_fw_send_data(dev, fw->data + sizeof(*hdr) + ilm_len,
245 fw->data + sizeof(*hdr) + ilm_len,
246 dlm_len, MCU_FW_URB_MAX_PAYLOAD, 245 dlm_len, MCU_FW_URB_MAX_PAYLOAD,
247 dlm_offset); 246 dlm_offset);
248 if (err < 0) { 247 if (err < 0) {