]> www.infradead.org Git - nvme.git/commitdiff
Bluetooth: btusb: mediatek: add MT7922 subsystem reset
authorHao Qin <hao.qin@mediatek.com>
Wed, 15 May 2024 23:15:21 +0000 (16:15 -0700)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 15 Jul 2024 01:33:27 +0000 (21:33 -0400)
Add the support of MT7922 bluetooth subsystem reset that was called the
auto revert to self-recover from the fatal error in the controller like
the host encounters HCI cmd timeout or the controller crashes.

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Hao Qin <hao.qin@mediatek.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
drivers/bluetooth/btusb.c

index ddd5ca7596e56a7bad2ca256ffe6dd0ea59a874f..79aefdb3324d0aa4121afe02a40ebc388fc18796 100644 (file)
@@ -3039,7 +3039,16 @@ static int btusb_mtk_subsys_reset(struct hci_dev *hdev, u32 dev_id)
        u32 val;
        int err;
 
-       if (dev_id == 0x7925) {
+       if (dev_id == 0x7922) {
+               btusb_mtk_uhw_reg_read(data, MTK_BT_SUBSYS_RST, &val);
+               val |= 0x00002020;
+               btusb_mtk_uhw_reg_write(data, MTK_BT_SUBSYS_RST, val);
+               btusb_mtk_uhw_reg_write(data, MTK_EP_RST_OPT, 0x00010001);
+               btusb_mtk_uhw_reg_read(data, MTK_BT_SUBSYS_RST, &val);
+               val |= BIT(0);
+               btusb_mtk_uhw_reg_write(data, MTK_BT_SUBSYS_RST, val);
+               msleep(100);
+       } else if (dev_id == 0x7925) {
                btusb_mtk_uhw_reg_read(data, MTK_BT_RESET_REG_CONNV3, &val);
                val |= (1 << 5);
                btusb_mtk_uhw_reg_write(data, MTK_BT_RESET_REG_CONNV3, val);
@@ -3079,6 +3088,9 @@ static int btusb_mtk_subsys_reset(struct hci_dev *hdev, u32 dev_id)
        if (err < 0)
                bt_dev_err(hdev, "Reset timeout");
 
+       if (dev_id == 0x7922)
+               btusb_mtk_uhw_reg_write(data, MTK_UDMA_INT_STA_BT, 0x000000FF);
+
        btusb_mtk_id_get(data, 0x70010200, &val);
        if (!val)
                bt_dev_err(hdev, "Can't get device id, subsys reset fail.");