[PATCH] Bluetooth: btusb: Fix MT7925 fail to send download patch command

Peter Tsao
2023-12-28T09:20:59Z

Write the register 0x18011100[1] = 1 to avoid the device enter sleep
state during download patch flow on specific platform.

Error log:
Bluetooth: hci0: Execution of wmt command timed out
Bluetooth: hci0: Failed to send wmt patch dwnld (-110)
Bluetooth: hci0: Failed to set up firmware (-110)

Signed-off-by: Peter Tsao <peter.tsao@mediatek.com>
---
drivers/bluetooth/btmtk.h | 3 +++
drivers/bluetooth/btusb.c | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btmtk.h b/drivers/bluetooth/btmtk.h
index 56f5502baadf..8b582077a01f 100644
--- a/drivers/bluetooth/btmtk.h
+++ b/drivers/bluetooth/btmtk.h
@@ -22,6 +22,9 @@
#define MT7921_DLSTATUS 0x7c053c10
#define BT_DL_STATE BIT(1)

+#define MT7925_SLPPROT 0x18011100
+#define SLPPROT_BYPASS BIT(1)
+
#define MTK_COREDUMP_SIZE (1024 * 1000)
#define MTK_COREDUMP_END "coredump end"
#define MTK_COREDUMP_END_LEN (sizeof(MTK_COREDUMP_END))
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 7835170b1d66..842fda0527db 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3120,9 +3120,13 @@ static int btusb_mtk_setup(struct hci_dev *hdev)
case 0x7668:
fwname = FIRMWARE_MT7668;
break;
+ case 0x7925:
+ btusb_mtk_uhw_reg_read(data, MT7925_SLPPROT, &val);
+ val |= SLPPROT_BYPASS;
+ btusb_mtk_uhw_reg_write(data, MT7925_SLPPROT, val);
+ fallthrough;
case 0x7922:
case 0x7961:
- case 0x7925:
if (dev_id == 0x7925)
snprintf(fw_bin_name, sizeof(fw_bin_name),
"mediatek/mt%04x/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
--
2.18.0