1 From 6f9ff24645f55ffae12ef717b4f221c3e7dfe115 Mon Sep 17 00:00:00 2001
2 From: Max Chou <max.chou@realtek.com>
3 Date: Wed, 4 Nov 2020 20:04:14 +0800
4 Subject: [PATCH] Bluetooth: btrtl: Refine the ic_id_table for clearer and more
7 Enhance the ic_id_table that it's able to maintain regularly.
8 To judge which chip should be initialized by LMP subversion, HCI revision,
9 HCI version and HCI bus which were given in the ic_id_table.
10 Also, refine the incorrect LMP subversion of ROM for RTL8723D and
13 Suggested-by: Alex Lu <alex_lu@realsil.com.cn>
14 Signed-off-by: Max Chou <max.chou@realtek.com>
15 Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
17 drivers/bluetooth/btrtl.c | 65 ++++++++++++---------------------------
18 1 file changed, 19 insertions(+), 46 deletions(-)
20 --- a/drivers/bluetooth/btrtl.c
21 +++ b/drivers/bluetooth/btrtl.c
25 #define RTL_EPATCH_SIGNATURE "Realtech"
26 -#define RTL_ROM_LMP_3499 0x3499
27 #define RTL_ROM_LMP_8723A 0x1200
28 #define RTL_ROM_LMP_8723B 0x8723
29 -#define RTL_ROM_LMP_8723D 0x8873
30 #define RTL_ROM_LMP_8821A 0x8821
31 #define RTL_ROM_LMP_8761A 0x8761
32 #define RTL_ROM_LMP_8822B 0x8822
34 #define IC_MATCH_FL_HCIREV (1 << 1)
35 #define IC_MATCH_FL_HCIVER (1 << 2)
36 #define IC_MATCH_FL_HCIBUS (1 << 3)
37 -#define IC_INFO(lmps, hcir) \
38 - .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_HCIREV, \
39 +#define IC_INFO(lmps, hcir, hciv, bus) \
40 + .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_HCIREV | \
41 + IC_MATCH_FL_HCIVER | IC_MATCH_FL_HCIBUS, \
42 .lmp_subver = (lmps), \
44 + .hci_rev = (hcir), \
45 + .hci_ver = (hciv), \
50 @@ -58,112 +59,85 @@ struct btrtl_device_info {
53 static const struct id_table ic_id_table[] = {
54 - { IC_MATCH_FL_LMPSUBV, RTL_ROM_LMP_8723A, 0x0,
55 - .config_needed = false,
56 - .has_rom_version = false,
57 - .fw_name = "rtl_bt/rtl8723a_fw.bin",
60 - { IC_MATCH_FL_LMPSUBV, RTL_ROM_LMP_3499, 0x0,
62 + { IC_INFO(RTL_ROM_LMP_8723A, 0xb, 0x6, HCI_USB),
63 .config_needed = false,
64 .has_rom_version = false,
65 .fw_name = "rtl_bt/rtl8723a_fw.bin",
69 - { .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_HCIREV |
70 - IC_MATCH_FL_HCIVER | IC_MATCH_FL_HCIBUS,
71 - .lmp_subver = RTL_ROM_LMP_8723B,
74 - .hci_bus = HCI_UART,
75 + { IC_INFO(RTL_ROM_LMP_8723B, 0xb, 0x6, HCI_UART),
76 .config_needed = true,
77 .has_rom_version = true,
78 .fw_name = "rtl_bt/rtl8723bs_fw.bin",
79 .cfg_name = "rtl_bt/rtl8723bs_config" },
82 - { IC_INFO(RTL_ROM_LMP_8723B, 0xb),
83 + { IC_INFO(RTL_ROM_LMP_8723B, 0xb, 0x6, HCI_USB),
84 .config_needed = false,
85 .has_rom_version = true,
86 .fw_name = "rtl_bt/rtl8723b_fw.bin",
87 .cfg_name = "rtl_bt/rtl8723b_config" },
90 - { IC_INFO(RTL_ROM_LMP_8723B, 0xd),
91 + { IC_INFO(RTL_ROM_LMP_8723B, 0xd, 0x8, HCI_USB),
92 .config_needed = true,
93 .has_rom_version = true,
94 .fw_name = "rtl_bt/rtl8723d_fw.bin",
95 .cfg_name = "rtl_bt/rtl8723d_config" },
98 - { .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_HCIREV |
99 - IC_MATCH_FL_HCIVER | IC_MATCH_FL_HCIBUS,
100 - .lmp_subver = RTL_ROM_LMP_8723B,
103 - .hci_bus = HCI_UART,
104 + { IC_INFO(RTL_ROM_LMP_8723B, 0xd, 0x8, HCI_UART),
105 .config_needed = true,
106 .has_rom_version = true,
107 .fw_name = "rtl_bt/rtl8723ds_fw.bin",
108 .cfg_name = "rtl_bt/rtl8723ds_config" },
111 - { IC_INFO(RTL_ROM_LMP_8723D, 0x826C),
112 - .config_needed = true,
113 - .has_rom_version = true,
114 - .fw_name = "rtl_bt/rtl8723d_fw.bin",
115 - .cfg_name = "rtl_bt/rtl8723d_config" },
118 - { IC_INFO(RTL_ROM_LMP_8821A, 0xa),
119 + { IC_INFO(RTL_ROM_LMP_8821A, 0xa, 0x6, HCI_USB),
120 .config_needed = false,
121 .has_rom_version = true,
122 .fw_name = "rtl_bt/rtl8821a_fw.bin",
123 .cfg_name = "rtl_bt/rtl8821a_config" },
126 - { IC_INFO(RTL_ROM_LMP_8821A, 0xc),
127 + { IC_INFO(RTL_ROM_LMP_8821A, 0xc, 0x8, HCI_USB),
128 .config_needed = false,
129 .has_rom_version = true,
130 .fw_name = "rtl_bt/rtl8821c_fw.bin",
131 .cfg_name = "rtl_bt/rtl8821c_config" },
134 - { IC_INFO(RTL_ROM_LMP_8761A, 0xa),
135 + { IC_INFO(RTL_ROM_LMP_8761A, 0xa, 0x6, HCI_USB),
136 .config_needed = false,
137 .has_rom_version = true,
138 .fw_name = "rtl_bt/rtl8761a_fw.bin",
139 .cfg_name = "rtl_bt/rtl8761a_config" },
142 - { IC_INFO(RTL_ROM_LMP_8761A, 0xb),
143 + { IC_INFO(RTL_ROM_LMP_8761A, 0xb, 0xa, HCI_USB),
144 .config_needed = false,
145 .has_rom_version = true,
146 .fw_name = "rtl_bt/rtl8761b_fw.bin",
147 .cfg_name = "rtl_bt/rtl8761b_config" },
149 /* 8822C with UART interface */
150 - { .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_HCIREV |
151 - IC_MATCH_FL_HCIBUS,
152 - .lmp_subver = RTL_ROM_LMP_8822B,
155 - .hci_bus = HCI_UART,
156 + { IC_INFO(RTL_ROM_LMP_8822B, 0xc, 0xa, HCI_UART),
157 .config_needed = true,
158 .has_rom_version = true,
159 .fw_name = "rtl_bt/rtl8822cs_fw.bin",
160 .cfg_name = "rtl_bt/rtl8822cs_config" },
162 /* 8822C with USB interface */
163 - { IC_INFO(RTL_ROM_LMP_8822B, 0xc),
164 + { IC_INFO(RTL_ROM_LMP_8822B, 0xc, 0xa, HCI_USB),
165 .config_needed = false,
166 .has_rom_version = true,
167 .fw_name = "rtl_bt/rtl8822cu_fw.bin",
168 .cfg_name = "rtl_bt/rtl8822cu_config" },
171 - { IC_INFO(RTL_ROM_LMP_8822B, 0xb),
172 + { IC_INFO(RTL_ROM_LMP_8822B, 0xb, 0x7, HCI_USB),
173 .config_needed = true,
174 .has_rom_version = true,
175 .fw_name = "rtl_bt/rtl8822b_fw.bin",
176 @@ -654,7 +628,6 @@ int btrtl_download_firmware(struct hci_d
178 switch (btrtl_dev->ic_info->lmp_subver) {
179 case RTL_ROM_LMP_8723A:
180 - case RTL_ROM_LMP_3499:
181 return btrtl_setup_rtl8723a(hdev, btrtl_dev);
182 case RTL_ROM_LMP_8723B:
183 case RTL_ROM_LMP_8821A: