Commit 4c0c28f2 authored by Hao Qin's avatar Hao Qin Committed by Luiz Augusto von Dentz

Bluetooth: btusb: mediatek: refactor the function btusb_mtk_reset

Extract the function btusb_mtk_subsys_reset from the btusb_mtk_reset
for the future handling of resetting bluetooth controller without
the USB reset.
Co-developed-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarHao Qin <hao.qin@mediatek.com>
Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
parent 7f935b21
...@@ -3033,28 +3033,13 @@ static u32 btusb_mtk_reset_done(struct hci_dev *hdev) ...@@ -3033,28 +3033,13 @@ static u32 btusb_mtk_reset_done(struct hci_dev *hdev)
return val & MTK_BT_RST_DONE; return val & MTK_BT_RST_DONE;
} }
static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data) static int btusb_mtk_subsys_reset(struct hci_dev *hdev, u32 dev_id)
{ {
struct btusb_data *data = hci_get_drvdata(hdev); struct btusb_data *data = hci_get_drvdata(hdev);
struct btmediatek_data *mediatek;
u32 val; u32 val;
int err; int err;
/* It's MediaTek specific bluetooth reset mechanism via USB */ if (dev_id == 0x7925) {
if (test_and_set_bit(BTUSB_HW_RESET_ACTIVE, &data->flags)) {
bt_dev_err(hdev, "last reset failed? Not resetting again");
return -EBUSY;
}
err = usb_autopm_get_interface(data->intf);
if (err < 0)
return err;
btusb_stop_traffic(data);
usb_kill_anchored_urbs(&data->tx_anchor);
mediatek = hci_get_priv(hdev);
if (mediatek->dev_id == 0x7925) {
btusb_mtk_uhw_reg_read(data, MTK_BT_RESET_REG_CONNV3, &val); btusb_mtk_uhw_reg_read(data, MTK_BT_RESET_REG_CONNV3, &val);
val |= (1 << 5); val |= (1 << 5);
btusb_mtk_uhw_reg_write(data, MTK_BT_RESET_REG_CONNV3, val); btusb_mtk_uhw_reg_write(data, MTK_BT_RESET_REG_CONNV3, val);
...@@ -3098,8 +3083,32 @@ static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data) ...@@ -3098,8 +3083,32 @@ static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data)
if (!val) if (!val)
bt_dev_err(hdev, "Can't get device id, subsys reset fail."); bt_dev_err(hdev, "Can't get device id, subsys reset fail.");
usb_queue_reset_device(data->intf); return err;
}
static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data)
{
struct btusb_data *data = hci_get_drvdata(hdev);
struct btmediatek_data *mtk_data;
int err;
/* It's MediaTek specific bluetooth reset mechanism via USB */
if (test_and_set_bit(BTUSB_HW_RESET_ACTIVE, &data->flags)) {
bt_dev_err(hdev, "last reset failed? Not resetting again");
return -EBUSY;
}
err = usb_autopm_get_interface(data->intf);
if (err < 0)
return err;
btusb_stop_traffic(data);
usb_kill_anchored_urbs(&data->tx_anchor);
mtk_data = hci_get_priv(hdev);
err = btusb_mtk_subsys_reset(hdev, mtk_data->dev_id);
usb_queue_reset_device(data->intf);
clear_bit(BTUSB_HW_RESET_ACTIVE, &data->flags); clear_bit(BTUSB_HW_RESET_ACTIVE, &data->flags);
return err; return err;
......
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