Skip to content

Commit 1c770a5

Browse files
Hao Qingregkh
authored andcommitted
Bluetooth: btusb: mediatek: reset the controller before downloading the fw
[ Upstream commit ccfc894 ] 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> Stable-dep-of: 5c5e8c5 ("Bluetooth: btmtk: move btusb_mtk_[setup, shutdown] to btmtk.c") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent eae5bb7 commit 1c770a5

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

drivers/bluetooth/btusb.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2940,16 +2940,26 @@ static int btusb_mtk_setup(struct hci_dev *hdev)
29402940
case 0x7922:
29412941
case 0x7961:
29422942
case 0x7925:
2943+
/* Reset the device to ensure it's in the initial state before
2944+
* downloading the firmware to ensure.
2945+
*/
2946+
2947+
if (!test_bit(BTUSB_FIRMWARE_LOADED, &data->flags))
2948+
btusb_mtk_subsys_reset(hdev, dev_id);
2949+
29432950
btmtk_fw_get_filename(fw_bin_name, sizeof(fw_bin_name), dev_id,
29442951
fw_version, 0);
29452952

29462953
err = btmtk_setup_firmware_79xx(hdev, fw_bin_name,
29472954
btmtk_usb_hci_wmt_sync);
29482955
if (err < 0) {
29492956
bt_dev_err(hdev, "Failed to set up firmware (%d)", err);
2957+
clear_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
29502958
return err;
29512959
}
29522960

2961+
set_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
2962+
29532963
/* It's Device EndPoint Reset Option Register */
29542964
btusb_mtk_uhw_reg_write(data, MTK_EP_RST_OPT, MTK_EP_RST_IN_OUT_OPT);
29552965

0 commit comments

Comments
 (0)