Skip to content

Commit 7d0095d

Browse files
committed
bluetooth: Refine MT6639 CHIPID workaround and firmware path
The initial MT6639 support used an overly broad workaround for boards that return 0x0000 from the CHIPID register: it forced dev_id to 0x6639 unconditionally whenever a zero was read. This risks misidentifying future chips that may also return zero from the same register. Similarly, the firmware path used the mt6639 directory name rather than following the established WiFi firmware naming convention. Scope the zero-CHIPID workaround to a known list of MT6639 USB VID/PID pairs, extracted into a module-level table so it can be referenced from both the detection and any future matching sites. Update the firmware directory to mt7927 to align with the WiFi-side convention. These changes also update the patch commit IDs to reflect the revised implementation, keeping the applied tree consistent with the reworked patch series. Signed-off-by: Javier Tia <floss@jetm.me>
1 parent 6507951 commit 7d0095d

8 files changed

+46
-39
lines changed

mt6639-bt-01-add-mt6639-mt7927-bluetooth-support.patch

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ Three changes are needed to support MT6639:
99

1010
1. CHIPID workaround: On some boards the BT USB MMIO register reads
1111
0x0000 for dev_id, causing the driver to skip the 0x6639 init path.
12-
Force dev_id to 0x6639 when it reads zero, matching the equivalent
13-
WiFi-side workaround that forces chip=0x7927.
12+
Force dev_id to 0x6639 only when the USB VID/PID matches a known
13+
MT6639 device, avoiding misdetection if a future chip also reads
14+
zero. This follows the WiFi-side pattern that uses PCI device IDs
15+
to scope the same workaround.
1416

1517
2. Firmware naming: MT6639 uses firmware version prefix "2_1" instead of
1618
"1_1" used by MT7925 and other variants. The firmware path is
17-
mediatek/mt6639/BT_RAM_CODE_MT6639_2_1_hdr.bin.
19+
mediatek/mt7927/BT_RAM_CODE_MT6639_2_1_hdr.bin, using the mt7927
20+
directory to match the WiFi firmware convention.
1821

1922
3. Section filtering: The MT6639 firmware binary contains 9 sections, but
2023
only sections with (dlmodecrctype & 0xff) == 0x01 are Bluetooth-related.
@@ -30,12 +33,31 @@ Link: https://github.com/openwrt/mt76/issues/927
3033
Reported-by: Ryan Gilbert <xelnaga@gmail.com>
3134
Signed-off-by: Javier Tia <floss@jetm.me>
3235

33-
519527132da41202bab85679ef03319e3aa8763a
36+
4a0bc7139c3406b228e12f0e14963cdb59f908b6
3437
diff --git a/btmtk.c b/btmtk.c
35-
index a8c520d..e1193f9 100644
38+
index a8c520d..4df28a2 100644
3639
--- a/btmtk.c
3740
+++ b/btmtk.c
38-
@@ -114,3 +114,7 @@ void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id, u32 fw_ver,
41+
@@ -27,2 +27,18 @@
42+
43+
+/* Known MT6639 (MT7927) Bluetooth USB devices.
44+
+ * Used to scope the zero-CHIPID workaround to real MT6639 hardware,
45+
+ * since some boards return 0x0000 from the MMIO chip ID register.
46+
+ */
47+
+static const struct {
48+
+ u16 vendor;
49+
+ u16 product;
50+
+} btmtk_mt6639_devs[] = {
51+
+ { 0x0489, 0xe13a }, /* ASUS ROG Crosshair X870E Hero */
52+
+ { 0x0489, 0xe0fa }, /* Lenovo Legion Pro 7 16ARX9 */
53+
+ { 0x0489, 0xe10f }, /* Gigabyte Z790 AORUS MASTER X */
54+
+ { 0x0489, 0xe110 }, /* MSI X870E Ace Max */
55+
+ { 0x0489, 0xe116 }, /* TP-Link Archer TBE550E */
56+
+ { 0x13d3, 0x3588 }, /* ASUS ROG STRIX X870E-E */
57+
+};
58+
+
59+
struct btmtk_patch_header {
60+
@@ -114,3 +130,7 @@ void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id, u32 fw_ver,
3961
{
4062
- if (dev_id == 0x7925)
4163
+ if (dev_id == 0x6639)
@@ -44,11 +66,11 @@ index a8c520d..e1193f9 100644
4466
+ dev_id & 0xffff, (fw_ver & 0xff) + 1);
4567
+ else if (dev_id == 0x7925)
4668
snprintf(buf, size,
47-
@@ -132,2 +136,3 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,
69+
@@ -132,2 +152,3 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,
4870
{
4971
+ struct btmtk_data *data = hci_get_priv(hdev);
5072
struct btmtk_hci_wmt_params wmt_params;
51-
@@ -168,2 +173,10 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,
73+
@@ -168,2 +189,10 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,
5274

5375
+ /* MT6639: only download sections where dlmode byte0 == 0x01,
5476
+ * matching the Windows driver behavior which skips WiFi/other
@@ -59,36 +81,21 @@ index a8c520d..e1193f9 100644
5981
+ continue;
6082
+
6183
if (dl_size > 0) {
62-
@@ -842,3 +855,3 @@ int btmtk_usb_subsys_reset(struct hci_dev *hdev, u32 dev_id)
84+
@@ -842,3 +871,3 @@ int btmtk_usb_subsys_reset(struct hci_dev *hdev, u32 dev_id)
6385
msleep(100);
6486
- } else if (dev_id == 0x7925) {
6587
+ } else if (dev_id == 0x7925 || dev_id == 0x6639) {
6688
err = btmtk_usb_uhw_reg_read(hdev, MTK_BT_RESET_REG_CONNV3, &val);
67-
@@ -1312,2 +1325,35 @@ int btmtk_usb_setup(struct hci_dev *hdev)
89+
@@ -1312,2 +1341,20 @@ int btmtk_usb_setup(struct hci_dev *hdev)
6890

69-
+ /* MT6639: some boards return CHIPID=0x0000 from the register read.
70-
+ * Only force dev_id for known MT6639 USB devices to avoid
71-
+ * misdetecting future chips that may also read zero.
72-
+ */
7391
+ if (!dev_id) {
74-
+ static const struct {
75-
+ u16 vendor;
76-
+ u16 product;
77-
+ } mt6639_devs[] = {
78-
+ { 0x0489, 0xe13a },
79-
+ { 0x0489, 0xe0fa },
80-
+ { 0x0489, 0xe10f },
81-
+ { 0x0489, 0xe110 },
82-
+ { 0x0489, 0xe116 },
83-
+ { 0x13d3, 0x3588 },
84-
+ };
8592
+ u16 vid = le16_to_cpu(btmtk_data->udev->descriptor.idVendor);
8693
+ u16 pid = le16_to_cpu(btmtk_data->udev->descriptor.idProduct);
8794
+ int i;
8895
+
89-
+ for (i = 0; i < ARRAY_SIZE(mt6639_devs); i++) {
90-
+ if (vid == mt6639_devs[i].vendor &&
91-
+ pid == mt6639_devs[i].product) {
96+
+ for (i = 0; i < ARRAY_SIZE(btmtk_mt6639_devs); i++) {
97+
+ if (vid == btmtk_mt6639_devs[i].vendor &&
98+
+ pid == btmtk_mt6639_devs[i].product) {
9299
+ dev_id = 0x6639;
93100
+ break;
94101
+ }
@@ -100,11 +107,11 @@ index a8c520d..e1193f9 100644
100107
+ }
101108
+
102109
btmtk_data->dev_id = dev_id;
103-
@@ -1328,2 +1374,3 @@ int btmtk_usb_setup(struct hci_dev *hdev)
110+
@@ -1328,2 +1375,3 @@ int btmtk_usb_setup(struct hci_dev *hdev)
104111
case 0x7961:
105112
+ case 0x6639:
106113
btmtk_fw_get_filename(fw_bin_name, sizeof(fw_bin_name), dev_id,
107-
@@ -1499 +1546,2 @@ MODULE_FIRMWARE(FIRMWARE_MT7961);
114+
@@ -1499 +1547,2 @@ MODULE_FIRMWARE(FIRMWARE_MT7961);
108115
MODULE_FIRMWARE(FIRMWARE_MT7925);
109116
+MODULE_FIRMWARE(FIRMWARE_MT7927);
110117
diff --git a/btmtk.h b/btmtk.h

mt6639-bt-02-fix-iso-interface-setup-for-single-alt-s.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ Signed-off-by: Javier Tia <floss@jetm.me>
1515
Reported-by: Ryan Gilbert <xelnaga@gmail.com>
1616
Tested-by: Ryan Gilbert <xelnaga@gmail.com>
1717

18-
665a4b1e7b530d8a7b06dc6b735464210698863c
18+
5d7f0fce6c25f7a82ebf62528cb249dac874ffde
1919
diff --git a/btmtk.c b/btmtk.c
20-
index e1193f9..8f63708 100644
20+
index 4df28a2..32e0636 100644
2121
--- a/btmtk.c
2222
+++ b/btmtk.c
23-
@@ -1003,3 +1003,4 @@ static int __set_mtk_intr_interface(struct hci_dev *hdev)
23+
@@ -1019,3 +1019,4 @@ static int __set_mtk_intr_interface(struct hci_dev *hdev)
2424

2525
- err = usb_set_interface(btmtk_data->udev, MTK_ISO_IFNUM, 1);
2626
+ err = usb_set_interface(btmtk_data->udev, MTK_ISO_IFNUM,

mt6639-bt-03-add-mt7927-id-for-asus-rog-crosshair-x87.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Link: https://github.com/openwrt/mt76/issues/927
3333
Signed-off-by: Javier Tia <floss@jetm.me>
3434
Tested-by: Jose Tiburcio Ribeiro Netto <jnetto@mineiro.io>
3535

36-
65b6987921fa9d94cd78710546270361642eac87
36+
dce5b6b1963aed382878ab0ac1e826faba5272c1
3737
diff --git a/btusb.c b/btusb.c
3838
index a41bb1e..336d6e0 100644
3939
--- a/btusb.c

mt6639-bt-04-add-mt7927-id-for-lenovo-legion-pro-7-16.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Link: https://github.com/openwrt/mt76/issues/927
3333
Signed-off-by: Javier Tia <floss@jetm.me>
3434
Tested-by: Llewellyn Curran <melinko2003@gmail.com>
3535

36-
633fed7d50d56701d4fdbd565fa42b8cc2395df5
36+
b25f9ab3a3a2ab18147c5930b0e5b3d3ea8b59dc
3737
diff --git a/btusb.c b/btusb.c
3838
index 336d6e0..83064d2 100644
3939
--- a/btusb.c

mt6639-bt-05-add-mt7927-id-for-gigabyte-z790-aorus-ma.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Signed-off-by: Javier Tia <floss@jetm.me>
3434
Tested-by: Chapuis Dario <chapuisdario4@gmail.com>
3535
Tested-by: Evgeny Kapusta <3193631@gmail.com>
3636

37-
42436173fc0c4398107a701ebfab1f6dfa9b772a
37+
7d15cc964cda5b8ed039df62ebf1b5c0cd32fd03
3838
diff --git a/btusb.c b/btusb.c
3939
index 83064d2..3e920ca 100644
4040
--- a/btusb.c

mt6639-bt-06-add-mt7927-id-for-msi-x870e-ace-max.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Link: https://github.com/openwrt/mt76/issues/927
3333
Signed-off-by: Javier Tia <floss@jetm.me>
3434
Tested-by: Nitin Gurram <nitin.reddy88@gmail.com>
3535

36-
fdd3d37a62febc50fab15d22701105d124dd9e59
36+
66f5cccbc1f44b29d12ab8a649404d9c24fc7355
3737
diff --git a/btusb.c b/btusb.c
3838
index 3e920ca..3e97603 100644
3939
--- a/btusb.c

mt6639-bt-07-add-mt7927-id-for-tp-link-archer-tbe550e.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Link: https://github.com/openwrt/mt76/issues/927
3333
Signed-off-by: Javier Tia <floss@jetm.me>
3434
Tested-by: Thibaut FRANCOIS <tibo@humeurlibre.fr>
3535

36-
3053cf761b0092cbe2d3ea06fd3f3a8cedd1f291
36+
7b3811cf04d2ed6bf30ecde571586f43117e5fd3
3737
diff --git a/btusb.c b/btusb.c
3838
index 3e97603..de9c3bf 100644
3939
--- a/btusb.c

mt6639-bt-08-add-mt7927-id-for-asus-x870e--proart-x87.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Signed-off-by: Javier Tia <floss@jetm.me>
3737
Tested-by: Jose Tiburcio Ribeiro Netto <jnetto@mineiro.io>
3838
Tested-by: Ivan Lubnin <lubnin.ivan@gmail.com>
3939

40-
275ad6a62a0141e49e904e0168f6a00c20d177a7
40+
6037e5bb844c21d5e9a9c33236a4b8a6d7031eec
4141
diff --git a/btusb.c b/btusb.c
4242
index de9c3bf..e15695f 100644
4343
--- a/btusb.c

0 commit comments

Comments
 (0)