1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Bluetooth support for Intel devices
6 * Copyright (C) 2015 Intel Corporation
9 #include <linux/module.h>
10 #include <linux/firmware.h>
11 #include <linux/regmap.h>
12 #include <asm/unaligned.h>
14 #include <net/bluetooth/bluetooth.h>
15 #include <net/bluetooth/hci_core.h>
21 #define BDADDR_INTEL (&(bdaddr_t){{0x00, 0x8b, 0x9e, 0x19, 0x03, 0x00}})
22 #define RSA_HEADER_LEN 644
23 #define CSS_HEADER_OFFSET 8
24 #define ECDSA_OFFSET 644
25 #define ECDSA_HEADER_LEN 320
27 int btintel_check_bdaddr(struct hci_dev *hdev)
29 struct hci_rp_read_bd_addr *bda;
32 skb = __hci_cmd_sync(hdev, HCI_OP_READ_BD_ADDR, 0, NULL,
35 int err = PTR_ERR(skb);
36 bt_dev_err(hdev, "Reading Intel device address failed (%d)",
41 if (skb->len != sizeof(*bda)) {
42 bt_dev_err(hdev, "Intel device address length mismatch");
47 bda = (struct hci_rp_read_bd_addr *)skb->data;
49 /* For some Intel based controllers, the default Bluetooth device
50 * address 00:03:19:9E:8B:00 can be found. These controllers are
51 * fully operational, but have the danger of duplicate addresses
52 * and that in turn can cause problems with Bluetooth operation.
54 if (!bacmp(&bda->bdaddr, BDADDR_INTEL)) {
55 bt_dev_err(hdev, "Found Intel default device address (%pMR)",
57 set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
64 EXPORT_SYMBOL_GPL(btintel_check_bdaddr);
66 int btintel_enter_mfg(struct hci_dev *hdev)
68 static const u8 param[] = { 0x01, 0x00 };
71 skb = __hci_cmd_sync(hdev, 0xfc11, 2, param, HCI_CMD_TIMEOUT);
73 bt_dev_err(hdev, "Entering manufacturer mode failed (%ld)",
81 EXPORT_SYMBOL_GPL(btintel_enter_mfg);
83 int btintel_exit_mfg(struct hci_dev *hdev, bool reset, bool patched)
85 u8 param[] = { 0x00, 0x00 };
88 /* The 2nd command parameter specifies the manufacturing exit method:
89 * 0x00: Just disable the manufacturing mode (0x00).
90 * 0x01: Disable manufacturing mode and reset with patches deactivated.
91 * 0x02: Disable manufacturing mode and reset with patches activated.
94 param[1] |= patched ? 0x02 : 0x01;
96 skb = __hci_cmd_sync(hdev, 0xfc11, 2, param, HCI_CMD_TIMEOUT);
98 bt_dev_err(hdev, "Exiting manufacturer mode failed (%ld)",
106 EXPORT_SYMBOL_GPL(btintel_exit_mfg);
108 int btintel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
113 skb = __hci_cmd_sync(hdev, 0xfc31, 6, bdaddr, HCI_INIT_TIMEOUT);
116 bt_dev_err(hdev, "Changing Intel device address failed (%d)",
124 EXPORT_SYMBOL_GPL(btintel_set_bdaddr);
126 int btintel_set_diag(struct hci_dev *hdev, bool enable)
142 skb = __hci_cmd_sync(hdev, 0xfc43, 3, param, HCI_INIT_TIMEOUT);
147 bt_dev_err(hdev, "Changing Intel diagnostic mode failed (%d)",
154 btintel_set_event_mask(hdev, enable);
157 EXPORT_SYMBOL_GPL(btintel_set_diag);
159 int btintel_set_diag_mfg(struct hci_dev *hdev, bool enable)
163 err = btintel_enter_mfg(hdev);
167 ret = btintel_set_diag(hdev, enable);
169 err = btintel_exit_mfg(hdev, false, false);
175 EXPORT_SYMBOL_GPL(btintel_set_diag_mfg);
177 void btintel_hw_error(struct hci_dev *hdev, u8 code)
182 bt_dev_err(hdev, "Hardware error 0x%2.2x", code);
184 skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
186 bt_dev_err(hdev, "Reset after hardware error failed (%ld)",
192 skb = __hci_cmd_sync(hdev, 0xfc22, 1, &type, HCI_INIT_TIMEOUT);
194 bt_dev_err(hdev, "Retrieving Intel exception info failed (%ld)",
199 if (skb->len != 13) {
200 bt_dev_err(hdev, "Exception info size mismatch");
205 bt_dev_err(hdev, "Exception info %s", (char *)(skb->data + 1));
209 EXPORT_SYMBOL_GPL(btintel_hw_error);
211 void btintel_version_info(struct hci_dev *hdev, struct intel_version *ver)
215 switch (ver->fw_variant) {
217 variant = "Bootloader";
220 variant = "Firmware";
226 bt_dev_info(hdev, "%s revision %u.%u build %u week %u %u",
227 variant, ver->fw_revision >> 4, ver->fw_revision & 0x0f,
228 ver->fw_build_num, ver->fw_build_ww,
229 2000 + ver->fw_build_yy);
231 EXPORT_SYMBOL_GPL(btintel_version_info);
233 int btintel_secure_send(struct hci_dev *hdev, u8 fragment_type, u32 plen,
238 u8 cmd_param[253], fragment_len = (plen > 252) ? 252 : plen;
240 cmd_param[0] = fragment_type;
241 memcpy(cmd_param + 1, param, fragment_len);
243 skb = __hci_cmd_sync(hdev, 0xfc09, fragment_len + 1,
244 cmd_param, HCI_INIT_TIMEOUT);
250 plen -= fragment_len;
251 param += fragment_len;
256 EXPORT_SYMBOL_GPL(btintel_secure_send);
258 int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name)
260 const struct firmware *fw;
265 err = request_firmware_direct(&fw, ddc_name, &hdev->dev);
267 bt_dev_err(hdev, "Failed to load Intel DDC file %s (%d)",
272 bt_dev_info(hdev, "Found Intel DDC parameters: %s", ddc_name);
276 /* DDC file contains one or more DDC structure which has
277 * Length (1 byte), DDC ID (2 bytes), and DDC value (Length - 2).
279 while (fw->size > fw_ptr - fw->data) {
280 u8 cmd_plen = fw_ptr[0] + sizeof(u8);
282 skb = __hci_cmd_sync(hdev, 0xfc8b, cmd_plen, fw_ptr,
285 bt_dev_err(hdev, "Failed to send Intel_Write_DDC (%ld)",
287 release_firmware(fw);
295 release_firmware(fw);
297 bt_dev_info(hdev, "Applying Intel DDC parameters completed");
301 EXPORT_SYMBOL_GPL(btintel_load_ddc_config);
303 int btintel_set_event_mask(struct hci_dev *hdev, bool debug)
305 u8 mask[8] = { 0x87, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
312 skb = __hci_cmd_sync(hdev, 0xfc52, 8, mask, HCI_INIT_TIMEOUT);
315 bt_dev_err(hdev, "Setting Intel event mask failed (%d)", err);
322 EXPORT_SYMBOL_GPL(btintel_set_event_mask);
324 int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug)
328 err = btintel_enter_mfg(hdev);
332 ret = btintel_set_event_mask(hdev, debug);
334 err = btintel_exit_mfg(hdev, false, false);
340 EXPORT_SYMBOL_GPL(btintel_set_event_mask_mfg);
342 int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver)
346 skb = __hci_cmd_sync(hdev, 0xfc05, 0, NULL, HCI_CMD_TIMEOUT);
348 bt_dev_err(hdev, "Reading Intel version information failed (%ld)",
353 if (skb->len != sizeof(*ver)) {
354 bt_dev_err(hdev, "Intel version event size mismatch");
359 memcpy(ver, skb->data, sizeof(*ver));
365 EXPORT_SYMBOL_GPL(btintel_read_version);
367 void btintel_version_info_tlv(struct hci_dev *hdev, struct intel_version_tlv *version)
371 switch (version->img_type) {
373 variant = "Bootloader";
374 bt_dev_info(hdev, "Device revision is %u", version->dev_rev_id);
375 bt_dev_info(hdev, "Secure boot is %s",
376 version->secure_boot ? "enabled" : "disabled");
377 bt_dev_info(hdev, "OTP lock is %s",
378 version->otp_lock ? "enabled" : "disabled");
379 bt_dev_info(hdev, "API lock is %s",
380 version->api_lock ? "enabled" : "disabled");
381 bt_dev_info(hdev, "Debug lock is %s",
382 version->debug_lock ? "enabled" : "disabled");
383 bt_dev_info(hdev, "Minimum firmware build %u week %u %u",
384 version->min_fw_build_nn, version->min_fw_build_cw,
385 2000 + version->min_fw_build_yy);
388 variant = "Firmware";
391 bt_dev_err(hdev, "Unsupported image type(%02x)", version->img_type);
395 bt_dev_info(hdev, "%s timestamp %u.%u buildtype %u build %u", variant,
396 2000 + (version->timestamp >> 8), version->timestamp & 0xff,
397 version->build_type, version->build_num);
402 EXPORT_SYMBOL_GPL(btintel_version_info_tlv);
404 int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *version)
407 const u8 param[1] = { 0xFF };
412 skb = __hci_cmd_sync(hdev, 0xfc05, 1, param, HCI_CMD_TIMEOUT);
414 bt_dev_err(hdev, "Reading Intel version information failed (%ld)",
420 bt_dev_err(hdev, "Intel Read Version command failed (%02x)",
426 /* Consume Command Complete Status field */
429 /* Event parameters contatin multiple TLVs. Read each of them
430 * and only keep the required data. Also, it use existing legacy
431 * version field like hw_platform, hw_variant, and fw_variant
432 * to keep the existing setup flow
435 struct intel_tlv *tlv;
437 tlv = (struct intel_tlv *)skb->data;
439 case INTEL_TLV_CNVI_TOP:
440 version->cnvi_top = get_unaligned_le32(tlv->val);
442 case INTEL_TLV_CNVR_TOP:
443 version->cnvr_top = get_unaligned_le32(tlv->val);
445 case INTEL_TLV_CNVI_BT:
446 version->cnvi_bt = get_unaligned_le32(tlv->val);
448 case INTEL_TLV_CNVR_BT:
449 version->cnvr_bt = get_unaligned_le32(tlv->val);
451 case INTEL_TLV_DEV_REV_ID:
452 version->dev_rev_id = get_unaligned_le16(tlv->val);
454 case INTEL_TLV_IMAGE_TYPE:
455 version->img_type = tlv->val[0];
457 case INTEL_TLV_TIME_STAMP:
458 version->timestamp = get_unaligned_le16(tlv->val);
460 case INTEL_TLV_BUILD_TYPE:
461 version->build_type = tlv->val[0];
463 case INTEL_TLV_BUILD_NUM:
464 version->build_num = get_unaligned_le32(tlv->val);
466 case INTEL_TLV_SECURE_BOOT:
467 version->secure_boot = tlv->val[0];
469 case INTEL_TLV_OTP_LOCK:
470 version->otp_lock = tlv->val[0];
472 case INTEL_TLV_API_LOCK:
473 version->api_lock = tlv->val[0];
475 case INTEL_TLV_DEBUG_LOCK:
476 version->debug_lock = tlv->val[0];
478 case INTEL_TLV_MIN_FW:
479 version->min_fw_build_nn = tlv->val[0];
480 version->min_fw_build_cw = tlv->val[1];
481 version->min_fw_build_yy = tlv->val[2];
483 case INTEL_TLV_LIMITED_CCE:
484 version->limited_cce = tlv->val[0];
486 case INTEL_TLV_SBE_TYPE:
487 version->sbe_type = tlv->val[0];
489 case INTEL_TLV_OTP_BDADDR:
490 memcpy(&version->otp_bd_addr, tlv->val, tlv->len);
493 /* Ignore rest of information */
496 /* consume the current tlv and move to next*/
497 skb_pull(skb, tlv->len + sizeof(*tlv));
503 EXPORT_SYMBOL_GPL(btintel_read_version_tlv);
505 /* ------- REGMAP IBT SUPPORT ------- */
507 #define IBT_REG_MODE_8BIT 0x00
508 #define IBT_REG_MODE_16BIT 0x01
509 #define IBT_REG_MODE_32BIT 0x02
511 struct regmap_ibt_context {
512 struct hci_dev *hdev;
517 struct ibt_cp_reg_access {
524 struct ibt_rp_reg_access {
530 static int regmap_ibt_read(void *context, const void *addr, size_t reg_size,
531 void *val, size_t val_size)
533 struct regmap_ibt_context *ctx = context;
534 struct ibt_cp_reg_access cp;
535 struct ibt_rp_reg_access *rp;
539 if (reg_size != sizeof(__le32))
544 cp.mode = IBT_REG_MODE_8BIT;
547 cp.mode = IBT_REG_MODE_16BIT;
550 cp.mode = IBT_REG_MODE_32BIT;
556 /* regmap provides a little-endian formatted addr */
557 cp.addr = *(__le32 *)addr;
560 bt_dev_dbg(ctx->hdev, "Register (0x%x) read", le32_to_cpu(cp.addr));
562 skb = hci_cmd_sync(ctx->hdev, ctx->op_read, sizeof(cp), &cp,
566 bt_dev_err(ctx->hdev, "regmap: Register (0x%x) read error (%d)",
567 le32_to_cpu(cp.addr), err);
571 if (skb->len != sizeof(*rp) + val_size) {
572 bt_dev_err(ctx->hdev, "regmap: Register (0x%x) read error, bad len",
573 le32_to_cpu(cp.addr));
578 rp = (struct ibt_rp_reg_access *)skb->data;
580 if (rp->addr != cp.addr) {
581 bt_dev_err(ctx->hdev, "regmap: Register (0x%x) read error, bad addr",
582 le32_to_cpu(rp->addr));
587 memcpy(val, rp->data, val_size);
594 static int regmap_ibt_gather_write(void *context,
595 const void *addr, size_t reg_size,
596 const void *val, size_t val_size)
598 struct regmap_ibt_context *ctx = context;
599 struct ibt_cp_reg_access *cp;
601 int plen = sizeof(*cp) + val_size;
605 if (reg_size != sizeof(__le32))
610 mode = IBT_REG_MODE_8BIT;
613 mode = IBT_REG_MODE_16BIT;
616 mode = IBT_REG_MODE_32BIT;
622 cp = kmalloc(plen, GFP_KERNEL);
626 /* regmap provides a little-endian formatted addr/value */
627 cp->addr = *(__le32 *)addr;
630 memcpy(&cp->data, val, val_size);
632 bt_dev_dbg(ctx->hdev, "Register (0x%x) write", le32_to_cpu(cp->addr));
634 skb = hci_cmd_sync(ctx->hdev, ctx->op_write, plen, cp, HCI_CMD_TIMEOUT);
637 bt_dev_err(ctx->hdev, "regmap: Register (0x%x) write error (%d)",
638 le32_to_cpu(cp->addr), err);
648 static int regmap_ibt_write(void *context, const void *data, size_t count)
650 /* data contains register+value, since we only support 32bit addr,
651 * minimum data size is 4 bytes.
653 if (WARN_ONCE(count < 4, "Invalid register access"))
656 return regmap_ibt_gather_write(context, data, 4, data + 4, count - 4);
659 static void regmap_ibt_free_context(void *context)
664 static struct regmap_bus regmap_ibt = {
665 .read = regmap_ibt_read,
666 .write = regmap_ibt_write,
667 .gather_write = regmap_ibt_gather_write,
668 .free_context = regmap_ibt_free_context,
669 .reg_format_endian_default = REGMAP_ENDIAN_LITTLE,
670 .val_format_endian_default = REGMAP_ENDIAN_LITTLE,
673 /* Config is the same for all register regions */
674 static const struct regmap_config regmap_ibt_cfg = {
675 .name = "btintel_regmap",
680 struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read,
683 struct regmap_ibt_context *ctx;
685 bt_dev_info(hdev, "regmap: Init R%x-W%x region", opcode_read,
688 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
690 return ERR_PTR(-ENOMEM);
692 ctx->op_read = opcode_read;
693 ctx->op_write = opcode_write;
696 return regmap_init(&hdev->dev, ®map_ibt, ctx, ®map_ibt_cfg);
698 EXPORT_SYMBOL_GPL(btintel_regmap_init);
700 int btintel_send_intel_reset(struct hci_dev *hdev, u32 boot_param)
702 struct intel_reset params = { 0x00, 0x01, 0x00, 0x01, 0x00000000 };
705 params.boot_param = cpu_to_le32(boot_param);
707 skb = __hci_cmd_sync(hdev, 0xfc01, sizeof(params), ¶ms,
710 bt_dev_err(hdev, "Failed to send Intel Reset command");
718 EXPORT_SYMBOL_GPL(btintel_send_intel_reset);
720 int btintel_read_boot_params(struct hci_dev *hdev,
721 struct intel_boot_params *params)
725 skb = __hci_cmd_sync(hdev, 0xfc0d, 0, NULL, HCI_INIT_TIMEOUT);
727 bt_dev_err(hdev, "Reading Intel boot parameters failed (%ld)",
732 if (skb->len != sizeof(*params)) {
733 bt_dev_err(hdev, "Intel boot parameters size mismatch");
738 memcpy(params, skb->data, sizeof(*params));
742 if (params->status) {
743 bt_dev_err(hdev, "Intel boot parameters command failed (%02x)",
745 return -bt_to_errno(params->status);
748 bt_dev_info(hdev, "Device revision is %u",
749 le16_to_cpu(params->dev_revid));
751 bt_dev_info(hdev, "Secure boot is %s",
752 params->secure_boot ? "enabled" : "disabled");
754 bt_dev_info(hdev, "OTP lock is %s",
755 params->otp_lock ? "enabled" : "disabled");
757 bt_dev_info(hdev, "API lock is %s",
758 params->api_lock ? "enabled" : "disabled");
760 bt_dev_info(hdev, "Debug lock is %s",
761 params->debug_lock ? "enabled" : "disabled");
763 bt_dev_info(hdev, "Minimum firmware build %u week %u %u",
764 params->min_fw_build_nn, params->min_fw_build_cw,
765 2000 + params->min_fw_build_yy);
769 EXPORT_SYMBOL_GPL(btintel_read_boot_params);
771 static int btintel_sfi_rsa_header_secure_send(struct hci_dev *hdev,
772 const struct firmware *fw)
776 /* Start the firmware download transaction with the Init fragment
777 * represented by the 128 bytes of CSS header.
779 err = btintel_secure_send(hdev, 0x00, 128, fw->data);
781 bt_dev_err(hdev, "Failed to send firmware header (%d)", err);
785 /* Send the 256 bytes of public key information from the firmware
786 * as the PKey fragment.
788 err = btintel_secure_send(hdev, 0x03, 256, fw->data + 128);
790 bt_dev_err(hdev, "Failed to send firmware pkey (%d)", err);
794 /* Send the 256 bytes of signature information from the firmware
795 * as the Sign fragment.
797 err = btintel_secure_send(hdev, 0x02, 256, fw->data + 388);
799 bt_dev_err(hdev, "Failed to send firmware signature (%d)", err);
807 static int btintel_sfi_ecdsa_header_secure_send(struct hci_dev *hdev,
808 const struct firmware *fw)
812 /* Start the firmware download transaction with the Init fragment
813 * represented by the 128 bytes of CSS header.
815 err = btintel_secure_send(hdev, 0x00, 128, fw->data + 644);
817 bt_dev_err(hdev, "Failed to send firmware header (%d)", err);
821 /* Send the 96 bytes of public key information from the firmware
822 * as the PKey fragment.
824 err = btintel_secure_send(hdev, 0x03, 96, fw->data + 644 + 128);
826 bt_dev_err(hdev, "Failed to send firmware pkey (%d)", err);
830 /* Send the 96 bytes of signature information from the firmware
831 * as the Sign fragment
833 err = btintel_secure_send(hdev, 0x02, 96, fw->data + 644 + 224);
835 bt_dev_err(hdev, "Failed to send firmware signature (%d)",
842 static int btintel_download_firmware_payload(struct hci_dev *hdev,
843 const struct firmware *fw,
844 u32 *boot_param, size_t offset)
850 fw_ptr = fw->data + offset;
854 while (fw_ptr - fw->data < fw->size) {
855 struct hci_command_hdr *cmd = (void *)(fw_ptr + frag_len);
857 /* Each SKU has a different reset parameter to use in the
858 * HCI_Intel_Reset command and it is embedded in the firmware
859 * data. So, instead of using static value per SKU, check
860 * the firmware data and save it for later use.
862 if (le16_to_cpu(cmd->opcode) == 0xfc0e) {
863 /* The boot parameter is the first 32-bit value
864 * and rest of 3 octets are reserved.
866 *boot_param = get_unaligned_le32(fw_ptr + sizeof(*cmd));
868 bt_dev_dbg(hdev, "boot_param=0x%x", *boot_param);
871 frag_len += sizeof(*cmd) + cmd->plen;
873 /* The parameter length of the secure send command requires
874 * a 4 byte alignment. It happens so that the firmware file
875 * contains proper Intel_NOP commands to align the fragments
878 * Send set of commands with 4 byte alignment from the
879 * firmware data buffer as a single Data fragement.
881 if (!(frag_len % 4)) {
882 err = btintel_secure_send(hdev, 0x01, frag_len, fw_ptr);
885 "Failed to send firmware data (%d)",
899 int btintel_download_firmware(struct hci_dev *hdev,
900 const struct firmware *fw,
905 err = btintel_sfi_rsa_header_secure_send(hdev, fw);
909 return btintel_download_firmware_payload(hdev, fw, boot_param,
912 EXPORT_SYMBOL_GPL(btintel_download_firmware);
914 int btintel_download_firmware_newgen(struct hci_dev *hdev,
915 const struct firmware *fw, u32 *boot_param,
916 u8 hw_variant, u8 sbe_type)
921 /* iBT hardware variants 0x0b, 0x0c, 0x11, 0x12, 0x13, 0x14 support
922 * only RSA secure boot engine. Hence, the corresponding sfi file will
923 * have RSA header of 644 bytes followed by Command Buffer.
925 * iBT hardware variants 0x17, 0x18 onwards support both RSA and ECDSA
926 * secure boot engine. As a result, the corresponding sfi file will
927 * have RSA header of 644, ECDSA header of 320 bytes followed by
930 * CSS Header byte positions 0x08 to 0x0B represent the CSS Header
931 * version: RSA(0x00010000) , ECDSA (0x00020000)
933 css_header_ver = get_unaligned_le32(fw->data + CSS_HEADER_OFFSET);
934 if (css_header_ver != 0x00010000) {
935 bt_dev_err(hdev, "Invalid CSS Header version");
939 if (hw_variant <= 0x14) {
940 if (sbe_type != 0x00) {
941 bt_dev_err(hdev, "Invalid SBE type for hardware variant (%d)",
946 err = btintel_sfi_rsa_header_secure_send(hdev, fw);
950 err = btintel_download_firmware_payload(hdev, fw, boot_param, RSA_HEADER_LEN);
953 } else if (hw_variant >= 0x17) {
954 /* Check if CSS header for ECDSA follows the RSA header */
955 if (fw->data[ECDSA_OFFSET] != 0x06)
958 /* Check if the CSS Header version is ECDSA(0x00020000) */
959 css_header_ver = get_unaligned_le32(fw->data + ECDSA_OFFSET + CSS_HEADER_OFFSET);
960 if (css_header_ver != 0x00020000) {
961 bt_dev_err(hdev, "Invalid CSS Header version");
965 if (sbe_type == 0x00) {
966 err = btintel_sfi_rsa_header_secure_send(hdev, fw);
970 err = btintel_download_firmware_payload(hdev, fw,
972 RSA_HEADER_LEN + ECDSA_HEADER_LEN);
975 } else if (sbe_type == 0x01) {
976 err = btintel_sfi_ecdsa_header_secure_send(hdev, fw);
980 err = btintel_download_firmware_payload(hdev, fw,
982 RSA_HEADER_LEN + ECDSA_HEADER_LEN);
989 EXPORT_SYMBOL_GPL(btintel_download_firmware_newgen);
991 void btintel_reset_to_bootloader(struct hci_dev *hdev)
993 struct intel_reset params;
996 /* Send Intel Reset command. This will result in
997 * re-enumeration of BT controller.
999 * Intel Reset parameter description:
1000 * reset_type : 0x00 (Soft reset),
1002 * patch_enable : 0x00 (Do not enable),
1004 * ddc_reload : 0x00 (Do not reload),
1006 * boot_option: 0x00 (Current image),
1007 * 0x01 (Specified boot address)
1008 * boot_param: Boot address
1011 params.reset_type = 0x01;
1012 params.patch_enable = 0x01;
1013 params.ddc_reload = 0x01;
1014 params.boot_option = 0x00;
1015 params.boot_param = cpu_to_le32(0x00000000);
1017 skb = __hci_cmd_sync(hdev, 0xfc01, sizeof(params),
1018 ¶ms, HCI_INIT_TIMEOUT);
1020 bt_dev_err(hdev, "FW download error recovery failed (%ld)",
1024 bt_dev_info(hdev, "Intel reset sent to retry FW download");
1027 /* Current Intel BT controllers(ThP/JfP) hold the USB reset
1028 * lines for 2ms when it receives Intel Reset in bootloader mode.
1029 * Whereas, the upcoming Intel BT controllers will hold USB reset
1030 * for 150ms. To keep the delay generic, 150ms is chosen here.
1034 EXPORT_SYMBOL_GPL(btintel_reset_to_bootloader);
1036 int btintel_read_debug_features(struct hci_dev *hdev,
1037 struct intel_debug_features *features)
1039 struct sk_buff *skb;
1042 /* Intel controller supports two pages, each page is of 128-bit
1043 * feature bit mask. And each bit defines specific feature support
1045 skb = __hci_cmd_sync(hdev, 0xfca6, sizeof(page_no), &page_no,
1048 bt_dev_err(hdev, "Reading supported features failed (%ld)",
1050 return PTR_ERR(skb);
1053 if (skb->len != (sizeof(features->page1) + 3)) {
1054 bt_dev_err(hdev, "Supported features event size mismatch");
1059 memcpy(features->page1, skb->data + 3, sizeof(features->page1));
1061 /* Read the supported features page2 if required in future.
1066 EXPORT_SYMBOL_GPL(btintel_read_debug_features);
1068 int btintel_set_debug_features(struct hci_dev *hdev,
1069 const struct intel_debug_features *features)
1071 u8 mask[11] = { 0x0a, 0x92, 0x02, 0x07, 0x00, 0x00, 0x00, 0x00,
1073 struct sk_buff *skb;
1078 if (!(features->page1[0] & 0x3f)) {
1079 bt_dev_info(hdev, "Telemetry exception format not supported");
1083 skb = __hci_cmd_sync(hdev, 0xfc8b, 11, mask, HCI_INIT_TIMEOUT);
1085 bt_dev_err(hdev, "Setting Intel telemetry ddc write event mask failed (%ld)",
1087 return PTR_ERR(skb);
1093 EXPORT_SYMBOL_GPL(btintel_set_debug_features);
1096 MODULE_DESCRIPTION("Bluetooth support for Intel devices ver " VERSION);
1097 MODULE_VERSION(VERSION);
1098 MODULE_LICENSE("GPL");
1099 MODULE_FIRMWARE("intel/ibt-11-5.sfi");
1100 MODULE_FIRMWARE("intel/ibt-11-5.ddc");
1101 MODULE_FIRMWARE("intel/ibt-12-16.sfi");
1102 MODULE_FIRMWARE("intel/ibt-12-16.ddc");