Commit 4dd4ad44 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt7663u: introduce mt7663u_mcu_power_on routine

Introduce mt7663u_mcu_power_on utility routine since the code is shared
between mt7663u_mcu_init() and mt7663u_probe().
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent e809904f
...@@ -559,6 +559,7 @@ void mt7663_usb_sdio_tx_complete_skb(struct mt76_dev *mdev, ...@@ -559,6 +559,7 @@ void mt7663_usb_sdio_tx_complete_skb(struct mt76_dev *mdev,
struct mt76_queue_entry *e); struct mt76_queue_entry *e);
int mt7663_usb_sdio_register_device(struct mt7615_dev *dev); int mt7663_usb_sdio_register_device(struct mt7615_dev *dev);
int mt7663u_mcu_init(struct mt7615_dev *dev); int mt7663u_mcu_init(struct mt7615_dev *dev);
int mt7663u_mcu_power_on(struct mt7615_dev *dev);
/* sdio */ /* sdio */
int mt7663s_mcu_init(struct mt7615_dev *dev); int mt7663s_mcu_init(struct mt7615_dev *dev);
......
...@@ -100,27 +100,15 @@ static int mt7663u_probe(struct usb_interface *usb_intf, ...@@ -100,27 +100,15 @@ static int mt7663u_probe(struct usb_interface *usb_intf,
(mt76_rr(dev, MT_HW_REV) & 0xff); (mt76_rr(dev, MT_HW_REV) & 0xff);
dev_dbg(mdev->dev, "ASIC revision: %04x\n", mdev->rev); dev_dbg(mdev->dev, "ASIC revision: %04x\n", mdev->rev);
if (mt76_poll_msec(dev, MT_CONN_ON_MISC, MT_TOP_MISC2_FW_PWR_ON,
FW_STATE_PWR_ON << 1, 500)) {
dev_dbg(dev->mt76.dev, "Usb device already powered on\n");
set_bit(MT76_STATE_POWER_OFF, &dev->mphy.state);
goto alloc_queues;
}
ret = mt76u_vendor_request(&dev->mt76, MT_VEND_POWER_ON,
USB_DIR_OUT | USB_TYPE_VENDOR,
0x0, 0x1, NULL, 0);
if (ret)
goto error;
if (!mt76_poll_msec(dev, MT_CONN_ON_MISC, MT_TOP_MISC2_FW_PWR_ON, if (!mt76_poll_msec(dev, MT_CONN_ON_MISC, MT_TOP_MISC2_FW_PWR_ON,
FW_STATE_PWR_ON << 1, 500)) { FW_STATE_PWR_ON << 1, 500)) {
dev_err(dev->mt76.dev, "Timeout for power on\n"); ret = mt7663u_mcu_power_on(dev);
ret = -EIO; if (ret)
goto error; goto error;
} else {
set_bit(MT76_STATE_POWER_OFF, &dev->mphy.state);
} }
alloc_queues:
ret = mt76u_alloc_mcu_queue(&dev->mt76); ret = mt76u_alloc_mcu_queue(&dev->mt76);
if (ret) if (ret)
goto error; goto error;
......
...@@ -42,6 +42,26 @@ mt7663u_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, ...@@ -42,6 +42,26 @@ mt7663u_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
return ret; return ret;
} }
int mt7663u_mcu_power_on(struct mt7615_dev *dev)
{
int ret;
ret = mt76u_vendor_request(&dev->mt76, MT_VEND_POWER_ON,
USB_DIR_OUT | USB_TYPE_VENDOR,
0x0, 0x1, NULL, 0);
if (ret)
return ret;
if (!mt76_poll_msec(dev, MT_CONN_ON_MISC,
MT_TOP_MISC2_FW_PWR_ON,
FW_STATE_PWR_ON << 1, 500)) {
dev_err(dev->mt76.dev, "Timeout for power on\n");
ret = -EIO;
}
return 0;
}
int mt7663u_mcu_init(struct mt7615_dev *dev) int mt7663u_mcu_init(struct mt7615_dev *dev)
{ {
static const struct mt76_mcu_ops mt7663u_mcu_ops = { static const struct mt76_mcu_ops mt7663u_mcu_ops = {
...@@ -65,18 +85,9 @@ int mt7663u_mcu_init(struct mt7615_dev *dev) ...@@ -65,18 +85,9 @@ int mt7663u_mcu_init(struct mt7615_dev *dev)
MT_TOP_MISC2_FW_PWR_ON, 0, 500)) MT_TOP_MISC2_FW_PWR_ON, 0, 500))
return -EIO; return -EIO;
ret = mt76u_vendor_request(&dev->mt76, MT_VEND_POWER_ON, ret = mt7663u_mcu_power_on(dev);
USB_DIR_OUT | USB_TYPE_VENDOR,
0x0, 0x1, NULL, 0);
if (ret) if (ret)
return ret; return ret;
if (!mt76_poll_msec(dev, MT_CONN_ON_MISC,
MT_TOP_MISC2_FW_PWR_ON,
FW_STATE_PWR_ON << 1, 500)) {
dev_err(dev->mt76.dev, "Timeout for power on\n");
return -EIO;
}
} }
ret = __mt7663_load_firmware(dev); ret = __mt7663_load_firmware(dev);
......
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