0975033d83378ffccff0e14dfa123ff7e806b31a
[openwrt/staging/pepe2k.git] /
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
5 regular
6
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
11 RTL8723A.
12
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>
16 ---
17 drivers/bluetooth/btrtl.c | 65 ++++++++++++---------------------------
18 1 file changed, 19 insertions(+), 46 deletions(-)
19
20 --- a/drivers/bluetooth/btrtl.c
21 +++ b/drivers/bluetooth/btrtl.c
22 @@ -18,10 +18,8 @@
23 #define VERSION "0.1"
24
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
33 @@ -31,10 +29,13 @@
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), \
43 - .hci_rev = (hcir)
44 + .hci_rev = (hcir), \
45 + .hci_ver = (hciv), \
46 + .hci_bus = (bus)
47
48 struct id_table {
49 __u16 match_flags;
50 @@ -58,112 +59,85 @@ struct btrtl_device_info {
51 };
52
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",
58 - .cfg_name = NULL },
59 -
60 - { IC_MATCH_FL_LMPSUBV, RTL_ROM_LMP_3499, 0x0,
61 + /* 8723A */
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",
66 .cfg_name = NULL },
67
68 /* 8723BS */
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,
72 - .hci_rev = 0xb,
73 - .hci_ver = 6,
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" },
80
81 /* 8723B */
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" },
88
89 /* 8723D */
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" },
96
97 /* 8723DS */
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,
101 - .hci_rev = 0xd,
102 - .hci_ver = 8,
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" },
109
110 - /* 8723DU */
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" },
116 -
117 /* 8821A */
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" },
124
125 /* 8821C */
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" },
132
133 /* 8761A */
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" },
140
141 /* 8761B */
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" },
148
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,
153 - .hci_rev = 0x000c,
154 - .hci_ver = 0x0a,
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" },
161
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" },
169
170 /* 8822B */
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
177
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: