summaryrefslogtreecommitdiff
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>2018-09-09 23:32:37 +0300
committerFelix Fietkau <nbd@nbd.name>2018-09-19 13:31:18 +0300
commitdb0f04f324b3a9a317af2f050397c1dfa903eefa (patch)
treeeb553f32f9e9870181c737f6317618cae6050e27 /drivers/net/wireless
parentdce9dc8d571b916bb55e08b66fb7bc4c5abd9ae5 (diff)
downloadlinux-db0f04f324b3a9a317af2f050397c1dfa903eefa.tar.xz
mt76: add mt76_mcu_ops data structure for mcu related pointers
Introduce mt76_mcu_ops data structure to contain mcu related function pointers. This is a preliminary patch to move mt76x02 usb mcu code in mt76x02-usb module Acked-by: Stanislaw Gruszka <sgruszka@redhat.com> 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/mt76.h11
-rw-r--r--drivers/net/wireless/mediatek/mt76/usb.c1
-rw-r--r--drivers/net/wireless/mediatek/mt76/usb_mcu.c10
3 files changed, 22 insertions, 0 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 2d74a2c3d93c..bff03470ccbc 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -119,6 +119,12 @@ struct mt76_queue {
struct sk_buff *rx_head;
};
+struct mt76_mcu_ops {
+ struct sk_buff *(*mcu_msg_alloc)(const void *data, int len);
+ int (*mcu_send_msg)(struct mt76_dev *dev, struct sk_buff *skb,
+ int cmd, bool wait_resp);
+};
+
struct mt76_queue_ops {
int (*init)(struct mt76_dev *dev);
@@ -336,6 +342,7 @@ struct mt76_dev {
const struct mt76_bus_ops *bus;
const struct mt76_driver_ops *drv;
+ const struct mt76_mcu_ops *mcu_ops;
void __iomem *regs;
struct device *dev;
@@ -436,6 +443,9 @@ struct mt76_rx_status {
#define mt76_rmw(dev, ...) (dev)->mt76.bus->rmw(&((dev)->mt76), __VA_ARGS__)
#define mt76_wr_copy(dev, ...) (dev)->mt76.bus->copy(&((dev)->mt76), __VA_ARGS__)
+#define mt76_mcu_msg_alloc(dev, ...) (dev)->mt76.mcu_ops->mcu_msg_alloc(__VA_ARGS__)
+#define mt76_mcu_send_msg(dev, ...) (dev)->mt76.mcu_ops->mcu_send_msg(&((dev)->mt76), __VA_ARGS__)
+
#define mt76_set(dev, offset, val) mt76_rmw(dev, offset, 0, val)
#define mt76_clear(dev, offset, val) mt76_rmw(dev, offset, val, 0)
@@ -643,5 +653,6 @@ int mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb,
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
diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
index 333b2c8ca7a4..1259a2b8e205 100644
--- a/drivers/net/wireless/mediatek/mt76/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/usb.c
@@ -836,6 +836,7 @@ int mt76u_init(struct mt76_dev *dev,
mutex_init(&usb->usb_ctrl_mtx);
dev->bus = &mt76u_ops;
dev->queue_ops = &usb_queue_ops;
+ mt76u_init_mcu_ops(dev);
return mt76u_set_endpoints(intf, usb);
}
diff --git a/drivers/net/wireless/mediatek/mt76/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/usb_mcu.c
index d80dbfafba6d..4cce807ec24e 100644
--- a/drivers/net/wireless/mediatek/mt76/usb_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/usb_mcu.c
@@ -296,3 +296,13 @@ void mt76u_mcu_deinit(struct mt76_dev *dev)
mt76u_buf_free(&usb->mcu.res);
}
EXPORT_SYMBOL_GPL(mt76u_mcu_deinit);
+
+void mt76u_init_mcu_ops(struct mt76_dev *dev)
+{
+ static const struct mt76_mcu_ops mt76u_mcu_ops = {
+ .mcu_msg_alloc = mt76u_mcu_msg_alloc,
+ .mcu_send_msg = mt76u_mcu_send_msg,
+ };
+
+ dev->mcu_ops = &mt76u_mcu_ops;
+}