1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 *
4 * Bluetooth support for Broadcom devices
5 *
6 * Copyright (C) 2015 Intel Corporation
7 */
8
9 #ifndef __GENKSYMS__ // ANDROID CRC kabi preservation hack due to commit 76dd7893bd10
10 #include <linux/efi.h>
11 #endif
12 #include <linux/module.h>
13 #include <linux/firmware.h>
14 #include <asm/unaligned.h>
15
16 #include <net/bluetooth/bluetooth.h>
17 #include <net/bluetooth/hci_core.h>
18
19 #include "btbcm.h"
20
21 #define VERSION "0.1"
22
23 #define BDADDR_BCM20702A0 (&(bdaddr_t) {{0x00, 0xa0, 0x02, 0x70, 0x20, 0x00}})
24 #define BDADDR_BCM20702A1 (&(bdaddr_t) {{0x00, 0x00, 0xa0, 0x02, 0x70, 0x20}})
25 #define BDADDR_BCM2076B1 (&(bdaddr_t) {{0x79, 0x56, 0x00, 0xa0, 0x76, 0x20}})
26 #define BDADDR_BCM43430A0 (&(bdaddr_t) {{0xac, 0x1f, 0x12, 0xa0, 0x43, 0x43}})
27 #define BDADDR_BCM4324B3 (&(bdaddr_t) {{0x00, 0x00, 0x00, 0xb3, 0x24, 0x43}})
28 #define BDADDR_BCM4330B1 (&(bdaddr_t) {{0x00, 0x00, 0x00, 0xb1, 0x30, 0x43}})
29 #define BDADDR_BCM4334B0 (&(bdaddr_t) {{0x00, 0x00, 0x00, 0xb0, 0x34, 0x43}})
30 #define BDADDR_BCM4345C5 (&(bdaddr_t) {{0xac, 0x1f, 0x00, 0xc5, 0x45, 0x43}})
31 #define BDADDR_BCM43341B (&(bdaddr_t) {{0xac, 0x1f, 0x00, 0x1b, 0x34, 0x43}})
32
33 #define BCM_FW_NAME_LEN 64
34 #define BCM_FW_NAME_COUNT_MAX 2
35 /* For kmalloc-ing the fw-name array instead of putting it on the stack */
36 typedef char bcm_fw_name[BCM_FW_NAME_LEN];
37
38 #ifdef CONFIG_EFI
btbcm_set_bdaddr_from_efi(struct hci_dev * hdev)39 static int btbcm_set_bdaddr_from_efi(struct hci_dev *hdev)
40 {
41 efi_guid_t guid = EFI_GUID(0x74b00bd9, 0x805a, 0x4d61, 0xb5, 0x1f,
42 0x43, 0x26, 0x81, 0x23, 0xd1, 0x13);
43 bdaddr_t efi_bdaddr, bdaddr;
44 efi_status_t status;
45 unsigned long len;
46 int ret;
47
48 if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE))
49 return -EOPNOTSUPP;
50
51 len = sizeof(efi_bdaddr);
52 status = efi.get_variable(L"BDADDR", &guid, NULL, &len, &efi_bdaddr);
53 if (status != EFI_SUCCESS)
54 return -ENXIO;
55
56 if (len != sizeof(efi_bdaddr))
57 return -EIO;
58
59 baswap(&bdaddr, &efi_bdaddr);
60
61 ret = btbcm_set_bdaddr(hdev, &bdaddr);
62 if (ret)
63 return ret;
64
65 bt_dev_info(hdev, "BCM: Using EFI device address (%pMR)", &bdaddr);
66 return 0;
67 }
68 #else
btbcm_set_bdaddr_from_efi(struct hci_dev * hdev)69 static int btbcm_set_bdaddr_from_efi(struct hci_dev *hdev)
70 {
71 return -EOPNOTSUPP;
72 }
73 #endif
74
btbcm_check_bdaddr(struct hci_dev * hdev)75 int btbcm_check_bdaddr(struct hci_dev *hdev)
76 {
77 struct hci_rp_read_bd_addr *bda;
78 struct sk_buff *skb;
79
80 skb = __hci_cmd_sync(hdev, HCI_OP_READ_BD_ADDR, 0, NULL,
81 HCI_INIT_TIMEOUT);
82 if (IS_ERR(skb)) {
83 int err = PTR_ERR(skb);
84
85 bt_dev_err(hdev, "BCM: Reading device address failed (%d)", err);
86 return err;
87 }
88
89 if (skb->len != sizeof(*bda)) {
90 bt_dev_err(hdev, "BCM: Device address length mismatch");
91 kfree_skb(skb);
92 return -EIO;
93 }
94
95 bda = (struct hci_rp_read_bd_addr *)skb->data;
96
97 /* Check if the address indicates a controller with either an
98 * invalid or default address. In both cases the device needs
99 * to be marked as not having a valid address.
100 *
101 * The address 00:20:70:02:A0:00 indicates a BCM20702A0 controller
102 * with no configured address.
103 *
104 * The address 20:70:02:A0:00:00 indicates a BCM20702A1 controller
105 * with no configured address.
106 *
107 * The address 20:76:A0:00:56:79 indicates a BCM2076B1 controller
108 * with no configured address.
109 *
110 * The address 43:24:B3:00:00:00 indicates a BCM4324B3 controller
111 * with waiting for configuration state.
112 *
113 * The address 43:30:B1:00:00:00 indicates a BCM4330B1 controller
114 * with waiting for configuration state.
115 *
116 * The address 43:43:A0:12:1F:AC indicates a BCM43430A0 controller
117 * with no configured address.
118 */
119 if (!bacmp(&bda->bdaddr, BDADDR_BCM20702A0) ||
120 !bacmp(&bda->bdaddr, BDADDR_BCM20702A1) ||
121 !bacmp(&bda->bdaddr, BDADDR_BCM2076B1) ||
122 !bacmp(&bda->bdaddr, BDADDR_BCM4324B3) ||
123 !bacmp(&bda->bdaddr, BDADDR_BCM4330B1) ||
124 !bacmp(&bda->bdaddr, BDADDR_BCM4334B0) ||
125 !bacmp(&bda->bdaddr, BDADDR_BCM4345C5) ||
126 !bacmp(&bda->bdaddr, BDADDR_BCM43430A0) ||
127 !bacmp(&bda->bdaddr, BDADDR_BCM43341B)) {
128 /* Try falling back to BDADDR EFI variable */
129 if (btbcm_set_bdaddr_from_efi(hdev) != 0) {
130 bt_dev_info(hdev, "BCM: Using default device address (%pMR)",
131 &bda->bdaddr);
132 set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
133 }
134 }
135
136 kfree_skb(skb);
137
138 return 0;
139 }
140 EXPORT_SYMBOL_GPL(btbcm_check_bdaddr);
141
btbcm_set_bdaddr(struct hci_dev * hdev,const bdaddr_t * bdaddr)142 int btbcm_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
143 {
144 struct sk_buff *skb;
145 int err;
146
147 skb = __hci_cmd_sync(hdev, 0xfc01, 6, bdaddr, HCI_INIT_TIMEOUT);
148 if (IS_ERR(skb)) {
149 err = PTR_ERR(skb);
150 bt_dev_err(hdev, "BCM: Change address command failed (%d)", err);
151 return err;
152 }
153 kfree_skb(skb);
154
155 return 0;
156 }
157 EXPORT_SYMBOL_GPL(btbcm_set_bdaddr);
158
btbcm_read_pcm_int_params(struct hci_dev * hdev,struct bcm_set_pcm_int_params * params)159 int btbcm_read_pcm_int_params(struct hci_dev *hdev,
160 struct bcm_set_pcm_int_params *params)
161 {
162 struct sk_buff *skb;
163 int err = 0;
164
165 skb = __hci_cmd_sync(hdev, 0xfc1d, 0, NULL, HCI_INIT_TIMEOUT);
166 if (IS_ERR(skb)) {
167 err = PTR_ERR(skb);
168 bt_dev_err(hdev, "BCM: Read PCM int params failed (%d)", err);
169 return err;
170 }
171
172 if (skb->len != 6 || skb->data[0]) {
173 bt_dev_err(hdev, "BCM: Read PCM int params length mismatch");
174 kfree_skb(skb);
175 return -EIO;
176 }
177
178 if (params)
179 memcpy(params, skb->data + 1, 5);
180
181 kfree_skb(skb);
182
183 return 0;
184 }
185 EXPORT_SYMBOL_GPL(btbcm_read_pcm_int_params);
186
btbcm_write_pcm_int_params(struct hci_dev * hdev,const struct bcm_set_pcm_int_params * params)187 int btbcm_write_pcm_int_params(struct hci_dev *hdev,
188 const struct bcm_set_pcm_int_params *params)
189 {
190 struct sk_buff *skb;
191 int err;
192
193 skb = __hci_cmd_sync(hdev, 0xfc1c, 5, params, HCI_INIT_TIMEOUT);
194 if (IS_ERR(skb)) {
195 err = PTR_ERR(skb);
196 bt_dev_err(hdev, "BCM: Write PCM int params failed (%d)", err);
197 return err;
198 }
199 kfree_skb(skb);
200
201 return 0;
202 }
203 EXPORT_SYMBOL_GPL(btbcm_write_pcm_int_params);
204
btbcm_patchram(struct hci_dev * hdev,const struct firmware * fw)205 int btbcm_patchram(struct hci_dev *hdev, const struct firmware *fw)
206 {
207 const struct hci_command_hdr *cmd;
208 const u8 *fw_ptr;
209 size_t fw_size;
210 struct sk_buff *skb;
211 u16 opcode;
212 int err = 0;
213
214 /* Start Download */
215 skb = __hci_cmd_sync(hdev, 0xfc2e, 0, NULL, HCI_INIT_TIMEOUT);
216 if (IS_ERR(skb)) {
217 err = PTR_ERR(skb);
218 bt_dev_err(hdev, "BCM: Download Minidrv command failed (%d)",
219 err);
220 goto done;
221 }
222 kfree_skb(skb);
223
224 /* 50 msec delay after Download Minidrv completes */
225 msleep(50);
226
227 fw_ptr = fw->data;
228 fw_size = fw->size;
229
230 while (fw_size >= sizeof(*cmd)) {
231 const u8 *cmd_param;
232
233 cmd = (struct hci_command_hdr *)fw_ptr;
234 fw_ptr += sizeof(*cmd);
235 fw_size -= sizeof(*cmd);
236
237 if (fw_size < cmd->plen) {
238 bt_dev_err(hdev, "BCM: Patch is corrupted");
239 err = -EINVAL;
240 goto done;
241 }
242
243 cmd_param = fw_ptr;
244 fw_ptr += cmd->plen;
245 fw_size -= cmd->plen;
246
247 opcode = le16_to_cpu(cmd->opcode);
248
249 skb = __hci_cmd_sync(hdev, opcode, cmd->plen, cmd_param,
250 HCI_INIT_TIMEOUT);
251 if (IS_ERR(skb)) {
252 err = PTR_ERR(skb);
253 bt_dev_err(hdev, "BCM: Patch command %04x failed (%d)",
254 opcode, err);
255 goto done;
256 }
257 kfree_skb(skb);
258 }
259
260 /* 250 msec delay after Launch Ram completes */
261 msleep(250);
262
263 done:
264 return err;
265 }
266 EXPORT_SYMBOL(btbcm_patchram);
267
btbcm_reset(struct hci_dev * hdev)268 static int btbcm_reset(struct hci_dev *hdev)
269 {
270 struct sk_buff *skb;
271
272 skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
273 if (IS_ERR(skb)) {
274 int err = PTR_ERR(skb);
275
276 bt_dev_err(hdev, "BCM: Reset failed (%d)", err);
277 return err;
278 }
279 kfree_skb(skb);
280
281 /* 100 msec delay for module to complete reset process */
282 msleep(100);
283
284 return 0;
285 }
286
btbcm_read_local_name(struct hci_dev * hdev)287 static struct sk_buff *btbcm_read_local_name(struct hci_dev *hdev)
288 {
289 struct sk_buff *skb;
290
291 skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_NAME, 0, NULL,
292 HCI_INIT_TIMEOUT);
293 if (IS_ERR(skb)) {
294 bt_dev_err(hdev, "BCM: Reading local name failed (%ld)",
295 PTR_ERR(skb));
296 return skb;
297 }
298
299 if (skb->len != sizeof(struct hci_rp_read_local_name)) {
300 bt_dev_err(hdev, "BCM: Local name length mismatch");
301 kfree_skb(skb);
302 return ERR_PTR(-EIO);
303 }
304
305 return skb;
306 }
307
btbcm_read_local_version(struct hci_dev * hdev)308 static struct sk_buff *btbcm_read_local_version(struct hci_dev *hdev)
309 {
310 struct sk_buff *skb;
311
312 skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL,
313 HCI_INIT_TIMEOUT);
314 if (IS_ERR(skb)) {
315 bt_dev_err(hdev, "BCM: Reading local version info failed (%ld)",
316 PTR_ERR(skb));
317 return skb;
318 }
319
320 if (skb->len != sizeof(struct hci_rp_read_local_version)) {
321 bt_dev_err(hdev, "BCM: Local version length mismatch");
322 kfree_skb(skb);
323 return ERR_PTR(-EIO);
324 }
325
326 return skb;
327 }
328
btbcm_read_verbose_config(struct hci_dev * hdev)329 static struct sk_buff *btbcm_read_verbose_config(struct hci_dev *hdev)
330 {
331 struct sk_buff *skb;
332
333 skb = __hci_cmd_sync(hdev, 0xfc79, 0, NULL, HCI_INIT_TIMEOUT);
334 if (IS_ERR(skb)) {
335 bt_dev_err(hdev, "BCM: Read verbose config info failed (%ld)",
336 PTR_ERR(skb));
337 return skb;
338 }
339
340 if (skb->len != 7) {
341 bt_dev_err(hdev, "BCM: Verbose config length mismatch");
342 kfree_skb(skb);
343 return ERR_PTR(-EIO);
344 }
345
346 return skb;
347 }
348
btbcm_read_controller_features(struct hci_dev * hdev)349 static struct sk_buff *btbcm_read_controller_features(struct hci_dev *hdev)
350 {
351 struct sk_buff *skb;
352
353 skb = __hci_cmd_sync(hdev, 0xfc6e, 0, NULL, HCI_INIT_TIMEOUT);
354 if (IS_ERR(skb)) {
355 bt_dev_err(hdev, "BCM: Read controller features failed (%ld)",
356 PTR_ERR(skb));
357 return skb;
358 }
359
360 if (skb->len != 9) {
361 bt_dev_err(hdev, "BCM: Controller features length mismatch");
362 kfree_skb(skb);
363 return ERR_PTR(-EIO);
364 }
365
366 return skb;
367 }
368
btbcm_read_usb_product(struct hci_dev * hdev)369 static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
370 {
371 struct sk_buff *skb;
372
373 skb = __hci_cmd_sync(hdev, 0xfc5a, 0, NULL, HCI_INIT_TIMEOUT);
374 if (IS_ERR(skb)) {
375 bt_dev_err(hdev, "BCM: Read USB product info failed (%ld)",
376 PTR_ERR(skb));
377 return skb;
378 }
379
380 if (skb->len != 5) {
381 bt_dev_err(hdev, "BCM: USB product length mismatch");
382 kfree_skb(skb);
383 return ERR_PTR(-EIO);
384 }
385
386 return skb;
387 }
388
btbcm_read_info(struct hci_dev * hdev)389 static int btbcm_read_info(struct hci_dev *hdev)
390 {
391 struct sk_buff *skb;
392
393 /* Read Verbose Config Version Info */
394 skb = btbcm_read_verbose_config(hdev);
395 if (IS_ERR(skb))
396 return PTR_ERR(skb);
397
398 bt_dev_info(hdev, "BCM: chip id %u", skb->data[1]);
399 kfree_skb(skb);
400
401 /* Read Controller Features */
402 skb = btbcm_read_controller_features(hdev);
403 if (IS_ERR(skb))
404 return PTR_ERR(skb);
405
406 bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
407 kfree_skb(skb);
408
409 return 0;
410 }
411
btbcm_print_local_name(struct hci_dev * hdev)412 static int btbcm_print_local_name(struct hci_dev *hdev)
413 {
414 struct sk_buff *skb;
415
416 /* Read Local Name */
417 skb = btbcm_read_local_name(hdev);
418 if (IS_ERR(skb))
419 return PTR_ERR(skb);
420
421 bt_dev_info(hdev, "%s", (char *)(skb->data + 1));
422 kfree_skb(skb);
423
424 return 0;
425 }
426
427 struct bcm_subver_table {
428 u16 subver;
429 const char *name;
430 };
431
432 static const struct bcm_subver_table bcm_uart_subver_table[] = {
433 { 0x4103, "BCM4330B1" }, /* 002.001.003 */
434 { 0x410d, "BCM4334B0" }, /* 002.001.013 */
435 { 0x410e, "BCM43341B0" }, /* 002.001.014 */
436 { 0x4204, "BCM2076B1" }, /* 002.002.004 */
437 { 0x4406, "BCM4324B3" }, /* 002.004.006 */
438 { 0x4606, "BCM4324B5" }, /* 002.006.006 */
439 { 0x6109, "BCM4335C0" }, /* 003.001.009 */
440 { 0x610c, "BCM4354" }, /* 003.001.012 */
441 { 0x2122, "BCM4343A0" }, /* 001.001.034 */
442 { 0x2209, "BCM43430A1" }, /* 001.002.009 */
443 { 0x6119, "BCM4345C0" }, /* 003.001.025 */
444 { 0x6606, "BCM4345C5" }, /* 003.006.006 */
445 { 0x230f, "BCM4356A2" }, /* 001.003.015 */
446 { 0x220e, "BCM20702A1" }, /* 001.002.014 */
447 { 0x420d, "BCM4349B1" }, /* 002.002.013 */
448 { 0x420e, "BCM4349B1" }, /* 002.002.014 */
449 { 0x4217, "BCM4329B1" }, /* 002.002.023 */
450 { 0x6106, "BCM4359C0" }, /* 003.001.006 */
451 { 0x4106, "BCM4335A0" }, /* 002.001.006 */
452 { }
453 };
454
455 static const struct bcm_subver_table bcm_usb_subver_table[] = {
456 { 0x2105, "BCM20703A1" }, /* 001.001.005 */
457 { 0x210b, "BCM43142A0" }, /* 001.001.011 */
458 { 0x2112, "BCM4314A0" }, /* 001.001.018 */
459 { 0x2118, "BCM20702A0" }, /* 001.001.024 */
460 { 0x2126, "BCM4335A0" }, /* 001.001.038 */
461 { 0x220e, "BCM20702A1" }, /* 001.002.014 */
462 { 0x230f, "BCM4356A2" }, /* 001.003.015 */
463 { 0x4106, "BCM4335B0" }, /* 002.001.006 */
464 { 0x410e, "BCM20702B0" }, /* 002.001.014 */
465 { 0x6109, "BCM4335C0" }, /* 003.001.009 */
466 { 0x610c, "BCM4354" }, /* 003.001.012 */
467 { 0x6607, "BCM4350C5" }, /* 003.006.007 */
468 { }
469 };
470
btbcm_initialize(struct hci_dev * hdev,bool * fw_load_done)471 int btbcm_initialize(struct hci_dev *hdev, bool *fw_load_done)
472 {
473 u16 subver, rev, pid, vid;
474 struct sk_buff *skb;
475 struct hci_rp_read_local_version *ver;
476 const struct bcm_subver_table *bcm_subver_table;
477 const char *hw_name = NULL;
478 char postfix[16] = "";
479 int fw_name_count = 0;
480 bcm_fw_name *fw_name;
481 const struct firmware *fw;
482 int i, err;
483
484 /* Reset */
485 err = btbcm_reset(hdev);
486 if (err)
487 return err;
488
489 /* Read Local Version Info */
490 skb = btbcm_read_local_version(hdev);
491 if (IS_ERR(skb))
492 return PTR_ERR(skb);
493
494 ver = (struct hci_rp_read_local_version *)skb->data;
495 rev = le16_to_cpu(ver->hci_rev);
496 subver = le16_to_cpu(ver->lmp_subver);
497 kfree_skb(skb);
498
499 /* Read controller information */
500 if (!(*fw_load_done)) {
501 err = btbcm_read_info(hdev);
502 if (err)
503 return err;
504 }
505 err = btbcm_print_local_name(hdev);
506 if (err)
507 return err;
508
509 bcm_subver_table = (hdev->bus == HCI_USB) ? bcm_usb_subver_table :
510 bcm_uart_subver_table;
511
512 for (i = 0; bcm_subver_table[i].name; i++) {
513 if (subver == bcm_subver_table[i].subver) {
514 hw_name = bcm_subver_table[i].name;
515 break;
516 }
517 }
518
519 bt_dev_info(hdev, "%s (%3.3u.%3.3u.%3.3u) build %4.4u",
520 hw_name ? hw_name : "BCM", (subver & 0xe000) >> 13,
521 (subver & 0x1f00) >> 8, (subver & 0x00ff), rev & 0x0fff);
522
523 if (*fw_load_done)
524 return 0;
525
526 if (hdev->bus == HCI_USB) {
527 /* Read USB Product Info */
528 skb = btbcm_read_usb_product(hdev);
529 if (IS_ERR(skb))
530 return PTR_ERR(skb);
531
532 vid = get_unaligned_le16(skb->data + 1);
533 pid = get_unaligned_le16(skb->data + 3);
534 kfree_skb(skb);
535
536 snprintf(postfix, sizeof(postfix), "-%4.4x-%4.4x", vid, pid);
537 }
538
539 fw_name = kmalloc(BCM_FW_NAME_COUNT_MAX * BCM_FW_NAME_LEN, GFP_KERNEL);
540 if (!fw_name)
541 return -ENOMEM;
542
543 if (hw_name) {
544 snprintf(fw_name[fw_name_count], BCM_FW_NAME_LEN,
545 "brcm/%s%s.hcd", hw_name, postfix);
546 fw_name_count++;
547 }
548
549 snprintf(fw_name[fw_name_count], BCM_FW_NAME_LEN,
550 "brcm/BCM%s.hcd", postfix);
551 fw_name_count++;
552
553 for (i = 0; i < fw_name_count; i++) {
554 err = firmware_request_nowarn(&fw, fw_name[i], &hdev->dev);
555 if (err == 0) {
556 bt_dev_info(hdev, "%s '%s' Patch",
557 hw_name ? hw_name : "BCM", fw_name[i]);
558 *fw_load_done = true;
559 break;
560 }
561 }
562
563 if (*fw_load_done) {
564 err = btbcm_patchram(hdev, fw);
565 if (err)
566 bt_dev_info(hdev, "BCM: Patch failed (%d)", err);
567
568 release_firmware(fw);
569 } else {
570 bt_dev_err(hdev, "BCM: firmware Patch file not found, tried:");
571 for (i = 0; i < fw_name_count; i++)
572 bt_dev_err(hdev, "BCM: '%s'", fw_name[i]);
573 }
574
575 kfree(fw_name);
576 return 0;
577 }
578 EXPORT_SYMBOL_GPL(btbcm_initialize);
579
btbcm_finalize(struct hci_dev * hdev,bool * fw_load_done)580 int btbcm_finalize(struct hci_dev *hdev, bool *fw_load_done)
581 {
582 int err;
583
584 /* Re-initialize if necessary */
585 if (*fw_load_done) {
586 err = btbcm_initialize(hdev, fw_load_done);
587 if (err)
588 return err;
589 }
590
591 btbcm_check_bdaddr(hdev);
592
593 set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
594
595 return 0;
596 }
597 EXPORT_SYMBOL_GPL(btbcm_finalize);
598
btbcm_setup_patchram(struct hci_dev * hdev)599 int btbcm_setup_patchram(struct hci_dev *hdev)
600 {
601 bool fw_load_done = false;
602 int err;
603
604 /* Initialize */
605 err = btbcm_initialize(hdev, &fw_load_done);
606 if (err)
607 return err;
608
609 /* Re-initialize after loading Patch */
610 return btbcm_finalize(hdev, &fw_load_done);
611 }
612 EXPORT_SYMBOL_GPL(btbcm_setup_patchram);
613
btbcm_setup_apple(struct hci_dev * hdev)614 int btbcm_setup_apple(struct hci_dev *hdev)
615 {
616 struct sk_buff *skb;
617 int err;
618
619 /* Reset */
620 err = btbcm_reset(hdev);
621 if (err)
622 return err;
623
624 /* Read Verbose Config Version Info */
625 skb = btbcm_read_verbose_config(hdev);
626 if (!IS_ERR(skb)) {
627 bt_dev_info(hdev, "BCM: chip id %u build %4.4u",
628 skb->data[1], get_unaligned_le16(skb->data + 5));
629 kfree_skb(skb);
630 }
631
632 /* Read USB Product Info */
633 skb = btbcm_read_usb_product(hdev);
634 if (!IS_ERR(skb)) {
635 bt_dev_info(hdev, "BCM: product %4.4x:%4.4x",
636 get_unaligned_le16(skb->data + 1),
637 get_unaligned_le16(skb->data + 3));
638 kfree_skb(skb);
639 }
640
641 /* Read Controller Features */
642 skb = btbcm_read_controller_features(hdev);
643 if (!IS_ERR(skb)) {
644 bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
645 kfree_skb(skb);
646 }
647
648 /* Read Local Name */
649 skb = btbcm_read_local_name(hdev);
650 if (!IS_ERR(skb)) {
651 bt_dev_info(hdev, "%s", (char *)(skb->data + 1));
652 kfree_skb(skb);
653 }
654
655 set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
656
657 return 0;
658 }
659 EXPORT_SYMBOL_GPL(btbcm_setup_apple);
660
661 MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
662 MODULE_DESCRIPTION("Bluetooth support for Broadcom devices ver " VERSION);
663 MODULE_VERSION(VERSION);
664 MODULE_LICENSE("GPL");
665