Commit 905db747 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau
Browse files

mt76: usb: move mt76x02 mcu code in mt76x02-usb module



Introduce mt76x02_usb_mcu.c in order to contain mt76x02u mcu related
code. Add mt76x02-usb module as a container for mt76x02 usb code.
This is a preliminary patch to move MT_TXD_INFO, MT_MCU_MSG and
MT_RX_FCE_INFO defs in mt76x02-lib module since other chipsets (e.g.
mt7603) use different dma definitions

Acked-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 17507157
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -9,6 +9,10 @@ config MT76x02_LIB
	tristate
	select MT76_CORE

config MT76x02_USB
	tristate
	select MT76_USB

config MT76x0_COMMON
	tristate
	select MT76x02_LIB
@@ -20,7 +24,7 @@ config MT76x2_COMMON
config MT76x0U
	tristate "MediaTek MT76x0U (USB) support"
	select MT76x0_COMMON
	select MT76_USB
	select MT76x02_USB
	depends on MAC80211
	depends on USB
	help
@@ -45,7 +49,7 @@ config MT76x2E
config MT76x2U
	tristate "MediaTek MT76x2U (USB) support"
	select MT76x2_COMMON
	select MT76_USB
	select MT76x02_USB
	depends on MAC80211
	depends on USB
	help
+3 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ obj-$(CONFIG_MT76_CORE) += mt76.o
obj-$(CONFIG_MT76_USB) += mt76-usb.o
obj-$(CONFIG_MT76x0_COMMON) += mt76x0/
obj-$(CONFIG_MT76x02_LIB) += mt76x02-lib.o
obj-$(CONFIG_MT76x02_USB) += mt76x02-usb.o
obj-$(CONFIG_MT76x2_COMMON) += mt76x2-common.o
obj-$(CONFIG_MT76x2E) += mt76x2e.o
obj-$(CONFIG_MT76x2U) += mt76x2u.o
@@ -16,6 +17,8 @@ CFLAGS_usb_trace.o := -I$(src)

mt76x02-lib-y := mt76x02_util.o mt76x02_mac.o

mt76x02-usb-y := mt76x02_usb_mcu.o

mt76x2-common-y := \
	mt76x2_eeprom.o mt76x2_tx_common.o mt76x2_mac_common.o \
	mt76x2_init_common.o mt76x2_common.o mt76x2_phy_common.o \
+0 −4
Original line number Diff line number Diff line
@@ -652,12 +652,8 @@ void mt76u_stop_stat_wk(struct mt76_dev *dev);
void mt76u_queues_deinit(struct mt76_dev *dev);
int mt76u_skb_dma_info(struct sk_buff *skb, int port, u32 flags);

int mt76u_mcu_fw_send_data(struct mt76_dev *dev, const void *data,
			   int data_len, u32 max_payload, u32 offset);
void mt76u_mcu_complete_urb(struct urb *urb);
void mt76u_mcu_fw_reset(struct mt76_dev *dev);
int mt76u_mcu_init_rx(struct mt76_dev *dev);
void mt76u_mcu_deinit(struct mt76_dev *dev);
void mt76u_init_mcu_ops(struct mt76_dev *dev);

#endif
+8 −7
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include "mcu.h"
#include "usb.h"
#include "trace.h"
#include "../mt76x02_usb.h"

#define MCU_FW_URB_MAX_PAYLOAD		0x38f8
#define MCU_FW_URB_SIZE			(MCU_FW_URB_MAX_PAYLOAD + 12)
@@ -177,7 +178,7 @@ mt76x0_upload_firmware(struct mt76x0_dev *dev, const struct mt76_fw *fw)
	ilm_len = le32_to_cpu(fw->hdr.ilm_len) - sizeof(fw->ivb);
	dev_dbg(dev->mt76.dev, "loading FW - ILM %u + IVB %zu\n",
		ilm_len, sizeof(fw->ivb));
	ret = mt76u_mcu_fw_send_data(&dev->mt76, fw->ilm, ilm_len,
	ret = mt76x02u_mcu_fw_send_data(&dev->mt76, fw->ilm, ilm_len,
					MCU_FW_URB_MAX_PAYLOAD,
					sizeof(fw->ivb));
	if (ret)
@@ -185,7 +186,7 @@ mt76x0_upload_firmware(struct mt76x0_dev *dev, const struct mt76_fw *fw)

	dlm_len = le32_to_cpu(fw->hdr.dlm_len);
	dev_dbg(dev->mt76.dev, "loading FW - DLM %u\n", dlm_len);
	ret = mt76u_mcu_fw_send_data(&dev->mt76, fw->ilm + ilm_len,
	ret = mt76x02u_mcu_fw_send_data(&dev->mt76, fw->ilm + ilm_len,
					dlm_len, MCU_FW_URB_MAX_PAYLOAD,
					MT_MCU_DLM_OFFSET);
	if (ret)
@@ -257,7 +258,7 @@ static int mt76x0_load_firmware(struct mt76x0_dev *dev)
	mt76_set(dev, MT_USB_DMA_CFG, (MT_USB_DMA_CFG_RX_BULK_EN |
				       MT_USB_DMA_CFG_TX_BULK_EN) |
				       FIELD_PREP(MT_USB_DMA_CFG_RX_BULK_AGG_TOUT, 0x20));
	mt76u_mcu_fw_reset(&dev->mt76);
	mt76x02u_mcu_fw_reset(&dev->mt76);
	msleep(5);
/*
	mt76x0_rmw(dev, MT_PBF_CFG, 0, (MT_PBF_CFG_TX0Q_EN |
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include "usb.h"
#include "trace.h"
#include "../mt76x02_util.h"
#include "../mt76x02_usb.h"

static struct usb_device_id mt76x0_device_table[] = {
	{ USB_DEVICE(0x148F, 0x7610) },	/* MT7610U */
@@ -70,6 +71,7 @@ static int mt76x0u_probe(struct usb_interface *usb_intf,

	usb_set_intfdata(usb_intf, dev);

	mt76x02u_init_mcu(&dev->mt76);
	ret = mt76u_init(&dev->mt76, usb_intf);
	if (ret)
		goto err;
Loading