]> www.infradead.org Git - nvme.git/commitdiff
Bluetooth: btusb: mediatek: reset the controller before downloading the fw
authorHao Qin <hao.qin@mediatek.com>
Wed, 15 May 2024 23:15:20 +0000 (16:15 -0700)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 15 Jul 2024 01:33:27 +0000 (21:33 -0400)
Reset the controller before downloading the firmware to improve its
reliability. This includes situations like cold or warm reboots, ensuring
the controller is in its initial state before starting the firmware
download.

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Co-developed-by: Chris Lu <chris.lu@mediatek.com>
Signed-off-by: Chris Lu <chris.lu@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 602456e94fdb669c9657f6d56e4f429b3974b639..ddd5ca7596e56a7bad2ca256ffe6dd0ea59a874f 100644 (file)
@@ -3175,6 +3175,13 @@ static int btusb_mtk_setup(struct hci_dev *hdev)
        case 0x7922:
        case 0x7961:
        case 0x7925:
+               /* Reset the device to ensure it's in the initial state before
+                * downloading the firmware to ensure.
+                */
+
+               if (!test_bit(BTUSB_FIRMWARE_LOADED, &data->flags))
+                       btusb_mtk_subsys_reset(hdev, dev_id);
+
                btmtk_fw_get_filename(fw_bin_name, sizeof(fw_bin_name), dev_id,
                                      fw_version, fw_flavor);
 
@@ -3182,9 +3189,12 @@ static int btusb_mtk_setup(struct hci_dev *hdev)
                                                btusb_mtk_hci_wmt_sync);
                if (err < 0) {
                        bt_dev_err(hdev, "Failed to set up firmware (%d)", err);
+                       clear_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
                        return err;
                }
 
+               set_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
+
                /* It's Device EndPoint Reset Option Register */
                btusb_mtk_uhw_reg_write(data, MTK_EP_RST_OPT, MTK_EP_RST_IN_OUT_OPT);