Lines Matching refs:hdev
56 int btintel_check_bdaddr(struct hci_dev *hdev)
61 skb = __hci_cmd_sync(hdev, HCI_OP_READ_BD_ADDR, 0, NULL,
65 bt_dev_err(hdev, "Reading Intel device address failed (%d)",
71 bt_dev_err(hdev, "Intel device address length mismatch");
84 bt_dev_err(hdev, "Found Intel default device address (%pMR)",
86 set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
95 int btintel_enter_mfg(struct hci_dev *hdev)
100 skb = __hci_cmd_sync(hdev, 0xfc11, 2, param, HCI_CMD_TIMEOUT);
102 bt_dev_err(hdev, "Entering manufacturer mode failed (%ld)",
112 int btintel_exit_mfg(struct hci_dev *hdev, bool reset, bool patched)
125 skb = __hci_cmd_sync(hdev, 0xfc11, 2, param, HCI_CMD_TIMEOUT);
127 bt_dev_err(hdev, "Exiting manufacturer mode failed (%ld)",
137 int btintel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
142 skb = __hci_cmd_sync(hdev, 0xfc31, 6, bdaddr, HCI_INIT_TIMEOUT);
145 bt_dev_err(hdev, "Changing Intel device address failed (%d)",
155 static int btintel_set_event_mask(struct hci_dev *hdev, bool debug)
164 skb = __hci_cmd_sync(hdev, 0xfc52, 8, mask, HCI_INIT_TIMEOUT);
167 bt_dev_err(hdev, "Setting Intel event mask failed (%d)", err);
175 int btintel_set_diag(struct hci_dev *hdev, bool enable)
191 skb = __hci_cmd_sync(hdev, 0xfc43, 3, param, HCI_INIT_TIMEOUT);
196 bt_dev_err(hdev, "Changing Intel diagnostic mode failed (%d)",
203 btintel_set_event_mask(hdev, enable);
208 static int btintel_set_diag_mfg(struct hci_dev *hdev, bool enable)
212 err = btintel_enter_mfg(hdev);
216 ret = btintel_set_diag(hdev, enable);
218 err = btintel_exit_mfg(hdev, false, false);
225 static int btintel_set_diag_combined(struct hci_dev *hdev, bool enable)
234 if (btintel_test_flag(hdev, INTEL_ROM_LEGACY))
235 ret = btintel_set_diag_mfg(hdev, enable);
237 ret = btintel_set_diag(hdev, enable);
242 void btintel_hw_error(struct hci_dev *hdev, u8 code)
247 bt_dev_err(hdev, "Hardware error 0x%2.2x", code);
249 skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
251 bt_dev_err(hdev, "Reset after hardware error failed (%ld)",
257 skb = __hci_cmd_sync(hdev, 0xfc22, 1, &type, HCI_INIT_TIMEOUT);
259 bt_dev_err(hdev, "Retrieving Intel exception info failed (%ld)",
265 bt_dev_err(hdev, "Exception info size mismatch");
270 bt_dev_err(hdev, "Exception info %s", (char *)(skb->data + 1));
276 int btintel_version_info(struct hci_dev *hdev, struct intel_version *ver)
284 bt_dev_err(hdev, "Unsupported Intel hardware platform (%u)",
306 bt_dev_err(hdev, "Unsupported Intel hardware variant (%u)",
325 bt_dev_err(hdev, "Unsupported firmware variant(%02x)", ver->fw_variant);
332 bt_dev_info(hdev, "%s revision %u.%u build %u week %u %u",
341 static int btintel_secure_send(struct hci_dev *hdev, u8 fragment_type, u32 plen,
351 skb = __hci_cmd_sync(hdev, 0xfc09, fragment_len + 1,
365 int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name)
372 err = request_firmware_direct(&fw, ddc_name, &hdev->dev);
374 bt_dev_err(hdev, "Failed to load Intel DDC file %s (%d)",
379 bt_dev_info(hdev, "Found Intel DDC parameters: %s", ddc_name);
389 skb = __hci_cmd_sync(hdev, 0xfc8b, cmd_plen, fw_ptr,
392 bt_dev_err(hdev, "Failed to send Intel_Write_DDC (%ld)",
404 bt_dev_info(hdev, "Applying Intel DDC parameters completed");
410 int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug)
414 err = btintel_enter_mfg(hdev);
418 ret = btintel_set_event_mask(hdev, debug);
420 err = btintel_exit_mfg(hdev, false, false);
428 int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver)
432 skb = __hci_cmd_sync(hdev, 0xfc05, 0, NULL, HCI_CMD_TIMEOUT);
434 bt_dev_err(hdev, "Reading Intel version information failed (%ld)",
440 bt_dev_err(hdev, "Intel version event size mismatch");
453 int btintel_version_info_tlv(struct hci_dev *hdev,
462 bt_dev_err(hdev, "Unsupported Intel hardware platform (0x%2x)",
483 bt_dev_err(hdev, "Unsupported Intel hardware variant (0x%x)",
496 bt_dev_err(hdev, "Unsupported Intel firmware loading method (0x%x)",
503 bt_dev_err(hdev, "Unsupported Intel secure boot engine type (0x%x)",
508 bt_dev_info(hdev, "Device revision is %u", version->dev_rev_id);
509 bt_dev_info(hdev, "Secure boot is %s",
511 bt_dev_info(hdev, "OTP lock is %s",
513 bt_dev_info(hdev, "API lock is %s",
515 bt_dev_info(hdev, "Debug lock is %s",
517 bt_dev_info(hdev, "Minimum firmware build %u week %u %u",
528 bt_dev_err(hdev, "Unsupported image type(%02x)", version->img_type);
535 bt_dev_info(hdev, "%s timestamp %u.%u buildtype %u build %u", variant,
539 bt_dev_info(hdev, "Firmware SHA1: 0x%8.8x", version->git_sha1);
545 int btintel_parse_version_tlv(struct hci_dev *hdev,
655 static int btintel_read_version_tlv(struct hci_dev *hdev,
664 skb = __hci_cmd_sync(hdev, 0xfc05, 1, param, HCI_CMD_TIMEOUT);
666 bt_dev_err(hdev, "Reading Intel version information failed (%ld)",
672 bt_dev_err(hdev, "Intel Read Version command failed (%02x)",
678 btintel_parse_version_tlv(hdev, version, skb);
691 struct hci_dev *hdev;
739 bt_dev_dbg(ctx->hdev, "Register (0x%x) read", le32_to_cpu(cp.addr));
741 skb = hci_cmd_sync(ctx->hdev, ctx->op_read, sizeof(cp), &cp,
745 bt_dev_err(ctx->hdev, "regmap: Register (0x%x) read error (%d)",
751 bt_dev_err(ctx->hdev, "regmap: Register (0x%x) read error, bad len",
760 bt_dev_err(ctx->hdev, "regmap: Register (0x%x) read error, bad addr",
811 bt_dev_dbg(ctx->hdev, "Register (0x%x) write", le32_to_cpu(cp->addr));
813 skb = hci_cmd_sync(ctx->hdev, ctx->op_write, plen, cp, HCI_CMD_TIMEOUT);
816 bt_dev_err(ctx->hdev, "regmap: Register (0x%x) write error (%d)",
859 struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read,
864 bt_dev_info(hdev, "regmap: Init R%x-W%x region", opcode_read,
873 ctx->hdev = hdev;
875 return regmap_init(&hdev->dev, ®map_ibt, ctx, ®map_ibt_cfg);
879 int btintel_send_intel_reset(struct hci_dev *hdev, u32 boot_param)
886 skb = __hci_cmd_sync(hdev, 0xfc01, sizeof(params), ¶ms,
889 bt_dev_err(hdev, "Failed to send Intel Reset command");
899 int btintel_read_boot_params(struct hci_dev *hdev,
904 skb = __hci_cmd_sync(hdev, 0xfc0d, 0, NULL, HCI_INIT_TIMEOUT);
906 bt_dev_err(hdev, "Reading Intel boot parameters failed (%ld)",
912 bt_dev_err(hdev, "Intel boot parameters size mismatch");
922 bt_dev_err(hdev, "Intel boot parameters command failed (%02x)",
927 bt_dev_info(hdev, "Device revision is %u",
930 bt_dev_info(hdev, "Secure boot is %s",
933 bt_dev_info(hdev, "OTP lock is %s",
936 bt_dev_info(hdev, "API lock is %s",
939 bt_dev_info(hdev, "Debug lock is %s",
942 bt_dev_info(hdev, "Minimum firmware build %u week %u %u",
950 static int btintel_sfi_rsa_header_secure_send(struct hci_dev *hdev,
958 err = btintel_secure_send(hdev, 0x00, 128, fw->data);
960 bt_dev_err(hdev, "Failed to send firmware header (%d)", err);
967 err = btintel_secure_send(hdev, 0x03, 256, fw->data + 128);
969 bt_dev_err(hdev, "Failed to send firmware pkey (%d)", err);
976 err = btintel_secure_send(hdev, 0x02, 256, fw->data + 388);
978 bt_dev_err(hdev, "Failed to send firmware signature (%d)", err);
986 static int btintel_sfi_ecdsa_header_secure_send(struct hci_dev *hdev,
994 err = btintel_secure_send(hdev, 0x00, 128, fw->data + 644);
996 bt_dev_err(hdev, "Failed to send firmware header (%d)", err);
1003 err = btintel_secure_send(hdev, 0x03, 96, fw->data + 644 + 128);
1005 bt_dev_err(hdev, "Failed to send firmware pkey (%d)", err);
1012 err = btintel_secure_send(hdev, 0x02, 96, fw->data + 644 + 224);
1014 bt_dev_err(hdev, "Failed to send firmware signature (%d)",
1021 static int btintel_download_firmware_payload(struct hci_dev *hdev,
1047 err = btintel_secure_send(hdev, 0x01, frag_len, fw_ptr);
1049 bt_dev_err(hdev,
1064 static bool btintel_firmware_version(struct hci_dev *hdev,
1088 bt_dev_info(hdev, "Boot Address: 0x%x", *boot_addr);
1090 bt_dev_info(hdev, "Firmware Version: %u-%u.%u",
1105 int btintel_download_firmware(struct hci_dev *hdev,
1123 if (btintel_firmware_version(hdev, ver->fw_build_num,
1126 bt_dev_info(hdev, "Firmware already loaded");
1145 err = btintel_sfi_rsa_header_secure_send(hdev, fw);
1149 return btintel_download_firmware_payload(hdev, fw, RSA_HEADER_LEN);
1153 static int btintel_download_fw_tlv(struct hci_dev *hdev,
1162 if (btintel_firmware_version(hdev, ver->min_fw_build_nn,
1166 bt_dev_info(hdev, "Firmware already loaded");
1198 bt_dev_err(hdev, "Invalid CSS Header version");
1204 bt_dev_err(hdev, "Invalid SBE type for hardware variant (%d)",
1209 err = btintel_sfi_rsa_header_secure_send(hdev, fw);
1213 err = btintel_download_firmware_payload(hdev, fw, RSA_HEADER_LEN);
1224 bt_dev_err(hdev, "Invalid CSS Header version");
1229 err = btintel_sfi_rsa_header_secure_send(hdev, fw);
1233 err = btintel_download_firmware_payload(hdev, fw,
1238 err = btintel_sfi_ecdsa_header_secure_send(hdev, fw);
1242 err = btintel_download_firmware_payload(hdev, fw,
1251 static void btintel_reset_to_bootloader(struct hci_dev *hdev)
1259 if (hdev->bus == HCI_PCI)
1284 skb = __hci_cmd_sync(hdev, 0xfc01, sizeof(params),
1287 bt_dev_err(hdev, "FW download error recovery failed (%ld)",
1291 bt_dev_info(hdev, "Intel reset sent to retry FW download");
1302 static int btintel_read_debug_features(struct hci_dev *hdev,
1311 skb = __hci_cmd_sync(hdev, 0xfca6, sizeof(page_no), &page_no,
1314 bt_dev_err(hdev, "Reading supported features failed (%ld)",
1320 bt_dev_err(hdev, "Supported features event size mismatch");
1333 static int btintel_set_debug_features(struct hci_dev *hdev,
1343 bt_dev_warn(hdev, "Debug features not read");
1348 bt_dev_info(hdev, "Telemetry exception format not supported");
1352 skb = __hci_cmd_sync(hdev, 0xfc8b, 11, mask, HCI_INIT_TIMEOUT);
1354 bt_dev_err(hdev, "Setting Intel telemetry ddc write event mask failed (%ld)",
1360 skb = __hci_cmd_sync(hdev, 0xfc8b, 5, period, HCI_INIT_TIMEOUT);
1362 bt_dev_err(hdev, "Setting periodicity for link statistics traces failed (%ld)",
1368 skb = __hci_cmd_sync(hdev, 0xfca1, 1, &trace_enable, HCI_INIT_TIMEOUT);
1370 bt_dev_err(hdev, "Enable tracing of link statistics events failed (%ld)",
1376 bt_dev_info(hdev, "set debug features: trace_enable 0x%02x mask 0x%02x",
1382 static int btintel_reset_debug_features(struct hci_dev *hdev,
1391 bt_dev_warn(hdev, "Debug features not read");
1396 bt_dev_info(hdev, "Telemetry exception format not supported");
1401 skb = __hci_cmd_sync(hdev, 0xfca1, 1, &trace_enable, HCI_INIT_TIMEOUT);
1403 bt_dev_err(hdev, "Stop tracing of link statistics events failed (%ld)",
1409 skb = __hci_cmd_sync(hdev, 0xfc8b, 11, mask, HCI_INIT_TIMEOUT);
1411 bt_dev_err(hdev, "Setting Intel telemetry ddc write event mask failed (%ld)",
1417 bt_dev_info(hdev, "reset debug features: trace_enable 0x%02x mask 0x%02x",
1423 int btintel_set_quality_report(struct hci_dev *hdev, bool enable)
1428 bt_dev_dbg(hdev, "enable %d", enable);
1433 err = btintel_read_debug_features(hdev, &features);
1439 err = btintel_set_debug_features(hdev, &features);
1441 err = btintel_reset_debug_features(hdev, &features);
1447 static void btintel_coredump(struct hci_dev *hdev)
1451 skb = __hci_cmd_sync(hdev, 0xfc4e, 0, NULL, HCI_CMD_TIMEOUT);
1453 bt_dev_err(hdev, "Coredump failed (%ld)", PTR_ERR(skb));
1460 static void btintel_dmp_hdr(struct hci_dev *hdev, struct sk_buff *skb)
1479 static int btintel_register_devcoredump_support(struct hci_dev *hdev)
1484 err = btintel_read_debug_features(hdev, &features);
1486 bt_dev_info(hdev, "Error reading debug features");
1491 bt_dev_dbg(hdev, "Telemetry exception format not supported");
1495 hci_devcd_register(hdev, btintel_coredump, btintel_dmp_hdr, NULL);
1500 static const struct firmware *btintel_legacy_rom_get_fw(struct hci_dev *hdev,
1513 ret = request_firmware(&fw, fwname, &hdev->dev);
1516 bt_dev_err(hdev, "Intel firmware file request failed (%d)",
1521 bt_dev_err(hdev, "failed to open Intel firmware file: %s (%d)",
1529 if (request_firmware(&fw, fwname, &hdev->dev) < 0) {
1530 bt_dev_err(hdev, "failed to open default fw file: %s",
1536 bt_dev_info(hdev, "Intel Bluetooth firmware file: %s", fwname);
1541 static int btintel_legacy_rom_patching(struct hci_dev *hdev,
1560 bt_dev_err(hdev, "Intel fw corrupted: invalid cmd read");
1574 bt_dev_err(hdev, "Intel fw corrupted: invalid cmd len");
1607 bt_dev_err(hdev, "Intel fw corrupted: invalid evt len");
1621 bt_dev_err(hdev, "Intel fw corrupted: invalid evt read");
1625 skb = __hci_cmd_sync_ev(hdev, le16_to_cpu(cmd->opcode), cmd->plen,
1628 bt_dev_err(hdev, "sending Intel patch command (0x%4.4x) failed (%ld)",
1638 bt_dev_err(hdev, "mismatch event length (opcode 0x%4.4x)",
1645 bt_dev_err(hdev, "mismatch event parameter (opcode 0x%4.4x)",
1655 static int btintel_legacy_rom_setup(struct hci_dev *hdev,
1663 BT_DBG("%s", hdev->name);
1670 bt_dev_info(hdev,
1682 fw = btintel_legacy_rom_get_fw(hdev, ver);
1691 err = btintel_enter_mfg(hdev);
1722 ret = btintel_legacy_rom_patching(hdev, fw, &fw_ptr,
1736 err = btintel_exit_mfg(hdev, true, true);
1743 err = btintel_read_version(hdev, &new_ver);
1747 bt_dev_info(hdev, "Intel BT fw patch 0x%02x completed & activated",
1754 err = btintel_exit_mfg(hdev, false, false);
1758 bt_dev_info(hdev, "Intel firmware patch completed");
1768 err = btintel_exit_mfg(hdev, true, false);
1772 bt_dev_info(hdev, "Intel firmware patch completed and deactivated");
1778 btintel_set_event_mask_mfg(hdev, false);
1780 btintel_check_bdaddr(hdev);
1785 static int btintel_download_wait(struct hci_dev *hdev, ktime_t calltime, int msec)
1791 btintel_set_flag(hdev, INTEL_FIRMWARE_LOADED);
1793 bt_dev_info(hdev, "Waiting for firmware download to complete");
1795 err = btintel_wait_on_flag_timeout(hdev, INTEL_DOWNLOADING,
1799 bt_dev_err(hdev, "Firmware loading interrupted");
1804 bt_dev_err(hdev, "Firmware loading timeout");
1808 if (btintel_test_flag(hdev, INTEL_FIRMWARE_FAILED)) {
1809 bt_dev_err(hdev, "Firmware loading failed");
1817 bt_dev_info(hdev, "Firmware loaded in %llu usecs", duration);
1822 static int btintel_boot_wait(struct hci_dev *hdev, ktime_t calltime, int msec)
1828 bt_dev_info(hdev, "Waiting for device to boot");
1830 err = btintel_wait_on_flag_timeout(hdev, INTEL_BOOTING,
1834 bt_dev_err(hdev, "Device boot interrupted");
1839 bt_dev_err(hdev, "Device boot timeout");
1847 bt_dev_info(hdev, "Device booted in %llu usecs", duration);
1852 static int btintel_boot_wait_d0(struct hci_dev *hdev, ktime_t calltime,
1859 bt_dev_info(hdev, "Waiting for device transition to d0");
1861 err = btintel_wait_on_flag_timeout(hdev, INTEL_WAIT_FOR_D0,
1865 bt_dev_err(hdev, "Device d0 move interrupted");
1870 bt_dev_err(hdev, "Device d0 move timeout");
1878 bt_dev_info(hdev, "Device moved to D0 in %llu usecs", duration);
1883 static int btintel_boot(struct hci_dev *hdev, u32 boot_addr)
1890 btintel_set_flag(hdev, INTEL_BOOTING);
1891 btintel_set_flag(hdev, INTEL_WAIT_FOR_D0);
1893 err = btintel_send_intel_reset(hdev, boot_addr);
1895 bt_dev_err(hdev, "Intel Soft Reset failed (%d)", err);
1896 btintel_reset_to_bootloader(hdev);
1907 err = btintel_boot_wait(hdev, calltime, 5000);
1909 btintel_reset_to_bootloader(hdev);
1913 if (hdev->bus == HCI_PCI) {
1922 err = btintel_boot_wait_d0(hdev, calltime, 2000);
1959 static int btintel_download_fw(struct hci_dev *hdev,
1986 btintel_clear_flag(hdev, INTEL_BOOTLOADER);
1987 btintel_check_bdaddr(hdev);
2005 err = btintel_read_boot_params(hdev, params);
2014 bt_dev_err(hdev, "Unsupported Intel firmware loading method (%u)",
2023 bt_dev_info(hdev, "No device address configured");
2024 set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
2051 if (!btintel_test_flag(hdev, INTEL_BOOTLOADER)) {
2053 btintel_set_flag(hdev, INTEL_FIRMWARE_LOADED);
2057 bt_dev_err(hdev, "Unsupported Intel firmware naming");
2061 err = firmware_request_nowarn(&fw, fwname, &hdev->dev);
2063 if (!btintel_test_flag(hdev, INTEL_BOOTLOADER)) {
2065 btintel_set_flag(hdev, INTEL_FIRMWARE_LOADED);
2069 bt_dev_err(hdev, "Failed to load Intel firmware file %s (%d)",
2074 bt_dev_info(hdev, "Found device firmware: %s", fwname);
2077 bt_dev_err(hdev, "Invalid size of firmware file (%zu)",
2085 btintel_set_flag(hdev, INTEL_DOWNLOADING);
2088 err = btintel_download_firmware(hdev, ver, fw, boot_param);
2092 btintel_set_flag(hdev, INTEL_FIRMWARE_LOADED);
2100 btintel_reset_to_bootloader(hdev);
2115 err = btintel_download_wait(hdev, calltime, 5000);
2117 btintel_reset_to_bootloader(hdev);
2124 static int btintel_bootloader_setup(struct hci_dev *hdev,
2133 BT_DBG("%s", hdev->name);
2141 btintel_set_flag(hdev, INTEL_BOOTLOADER);
2143 err = btintel_download_fw(hdev, ver, ¶ms, &boot_param);
2151 err = btintel_boot(hdev, boot_param);
2155 btintel_clear_flag(hdev, INTEL_BOOTLOADER);
2161 bt_dev_err(hdev, "Unsupported Intel firmware naming");
2169 btintel_load_ddc_config(hdev, ddcname);
2172 hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT);
2175 err = btintel_read_version(hdev, &new_ver);
2179 btintel_version_info(hdev, &new_ver);
2189 btintel_set_event_mask(hdev, false);
2256 static int btintel_prepare_fw_download_tlv(struct hci_dev *hdev,
2282 btintel_clear_flag(hdev, INTEL_BOOTLOADER);
2283 btintel_check_bdaddr(hdev);
2291 bt_dev_info(hdev, "No device address configured");
2292 set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
2310 err = firmware_request_nowarn(&fw, fwname, &hdev->dev);
2312 if (!btintel_test_flag(hdev, INTEL_BOOTLOADER)) {
2314 btintel_set_flag(hdev, INTEL_FIRMWARE_LOADED);
2318 bt_dev_err(hdev, "Failed to load Intel firmware file %s (%d)",
2324 bt_dev_info(hdev, "Found device firmware: %s", fwname);
2327 bt_dev_err(hdev, "Invalid size of firmware file (%zu)",
2335 btintel_set_flag(hdev, INTEL_DOWNLOADING);
2338 err = btintel_download_fw_tlv(hdev, ver, fw, boot_param,
2344 btintel_set_flag(hdev, INTEL_FIRMWARE_LOADED);
2352 btintel_reset_to_bootloader(hdev);
2367 err = btintel_download_wait(hdev, calltime, 5000);
2369 btintel_reset_to_bootloader(hdev);
2376 static int btintel_get_codec_config_data(struct hci_dev *hdev,
2389 bt_dev_err(hdev, "Invalid link type(%u)", link);
2409 bt_dev_err(hdev, "Invalid codec id(%u)", codec->id);
2425 static int btintel_get_data_path_id(struct hci_dev *hdev, __u8 *data_path_id)
2432 static int btintel_configure_offload(struct hci_dev *hdev)
2438 skb = __hci_cmd_sync(hdev, 0xfc86, 0, NULL, HCI_INIT_TIMEOUT);
2440 bt_dev_err(hdev, "Reading offload use cases failed (%ld)",
2458 hdev->get_data_path_id = btintel_get_data_path_id;
2459 hdev->get_codec_config_data = btintel_get_codec_config_data;
2466 static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver)
2481 bt_dev_dbg(hdev, "PPAG not supported for Intel CNVr (0x%3x)",
2486 handle = ACPI_HANDLE(GET_HCIDEV_DEV(hdev));
2488 bt_dev_info(hdev, "No support for BT device in ACPI firmware");
2495 bt_dev_dbg(hdev, "PPAG-BT: ACPI entry not found");
2498 bt_dev_warn(hdev, "PPAG-BT: ACPI Failure: %s", acpi_format_exception(status));
2504 bt_dev_warn(hdev, "PPAG-BT: Invalid object type: %d or package count: %d",
2520 bt_dev_dbg(hdev, "PPAG-BT: Bluetooth domain is disabled in ACPI firmware");
2533 bt_dev_dbg(hdev, "PPAG-BT: EU, China mode are disabled in BIOS");
2539 skb = __hci_cmd_sync(hdev, INTEL_OP_PPAG_CMD, sizeof(ppag_cmd),
2542 bt_dev_warn(hdev, "Failed to send PPAG Enable (%ld)", PTR_ERR(skb));
2545 bt_dev_info(hdev, "PPAG-BT: Enabled (Mode %d)", mode);
2549 static int btintel_acpi_reset_method(struct hci_dev *hdev)
2556 status = acpi_evaluate_object(ACPI_HANDLE(GET_HCIDEV_DEV(hdev)), "_PRR", NULL, &buffer);
2558 bt_dev_err(hdev, "Failed to run _PRR method");
2565 bt_dev_err(hdev, "Invalid arguments");
2572 bt_dev_err(hdev, "Invalid object type: 0x%x", ref->type);
2579 bt_dev_err(hdev, "Failed to run_RST method");
2589 static void btintel_set_dsm_reset_method(struct hci_dev *hdev,
2592 struct btintel_data *data = hci_get_priv(hdev);
2593 acpi_handle handle = ACPI_HANDLE(GET_HCIDEV_DEV(hdev));
2601 handle = ACPI_HANDLE(GET_HCIDEV_DEV(hdev));
2604 bt_dev_dbg(hdev, "No support for bluetooth device in ACPI firmware");
2609 bt_dev_err(hdev, "No support for _PRR ACPI method");
2623 bt_dev_err(hdev, "No dsm support to set reset delay");
2632 bt_dev_err(hdev, "Failed to call dsm to set reset delay");
2638 bt_dev_info(hdev, "DSM reset method type: 0x%02x", reset_payload[2]);
2642 bt_dev_warn(hdev, "No support for dsm to set reset method");
2652 bt_dev_err(hdev, "Failed to call dsm to set reset method");
2661 static u8 btintel_classify_pkt_type(struct hci_dev *hdev, struct sk_buff *skb)
2742 static int btintel_set_dsbr(struct hci_dev *hdev, struct intel_version_tlv *ver)
2771 hdev->bus == HCI_USB)
2781 bt_dev_dbg(hdev, "Error reading efi: %ls (%d)",
2787 bt_dev_info(hdev, "dsbr: enable: 0x%2.2x value: 0x%2.2x", cmd.enable,
2790 skb = __hci_cmd_sync(hdev, 0xfc0a, sizeof(cmd), &cmd, HCI_CMD_TIMEOUT);
2803 int btintel_bootloader_setup_tlv(struct hci_dev *hdev,
2811 bt_dev_dbg(hdev, "");
2820 * same hdev instance if there is any error on firmware download.
2824 btintel_clear_flag(hdev, i);
2826 btintel_set_flag(hdev, INTEL_BOOTLOADER);
2828 err = btintel_prepare_fw_download_tlv(hdev, ver, &boot_param);
2836 err = btintel_boot(hdev, boot_param);
2840 err = btintel_read_version_tlv(hdev, ver);
2845 err = btintel_set_dsbr(hdev, ver);
2847 bt_dev_err(hdev, "Failed to send dsbr command (%d)", err);
2855 err = btintel_prepare_fw_download_tlv(hdev, ver, &boot_param);
2859 err = btintel_boot(hdev, boot_param);
2864 btintel_clear_flag(hdev, INTEL_BOOTLOADER);
2873 btintel_load_ddc_config(hdev, ddcname);
2876 btintel_configure_offload(hdev);
2878 hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT);
2881 btintel_set_ppag(hdev, ver);
2884 err = btintel_read_version_tlv(hdev, &new_ver);
2888 btintel_version_info_tlv(hdev, &new_ver);
2898 btintel_set_event_mask(hdev, false);
2904 void btintel_set_msft_opcode(struct hci_dev *hdev, u8 hw_variant)
2922 hci_set_msft_opcode(hdev, 0xFC1E);
2931 void btintel_print_fseq_info(struct hci_dev *hdev)
2938 skb = __hci_cmd_sync(hdev, 0xfcb3, 0, NULL, HCI_CMD_TIMEOUT);
2940 bt_dev_dbg(hdev, "Reading fseq status command failed (%ld)",
2946 bt_dev_dbg(hdev, "Malformed packet of length %u received",
2954 bt_dev_dbg(hdev, "Failed to get fseq status (0x%2.2x)", *p);
2976 bt_dev_err(hdev, "Fseq status: %s (0x%2.2x)", str, *p);
2981 bt_dev_info(hdev, "Fseq status: %s (0x%2.2x)", str, *p);
2984 bt_dev_dbg(hdev, "Reason: 0x%8.8x", val);
2987 bt_dev_dbg(hdev, "Global version: 0x%8.8x", val);
2990 bt_dev_dbg(hdev, "Installed version: 0x%8.8x", val);
2994 bt_dev_info(hdev, "Fseq executed: %2.2u.%2.2u.%2.2u.%2.2u", p[0], p[1],
2999 bt_dev_info(hdev, "Fseq BT Top: %2.2u.%2.2u.%2.2u.%2.2u", p[0], p[1],
3003 bt_dev_dbg(hdev, "Fseq Top init version: 0x%8.8x", val);
3006 bt_dev_dbg(hdev, "Fseq Cnvio init version: 0x%8.8x", val);
3009 bt_dev_dbg(hdev, "Fseq MBX Wifi file version: 0x%8.8x", val);
3012 bt_dev_dbg(hdev, "Fseq BT version: 0x%8.8x", val);
3015 bt_dev_dbg(hdev, "Fseq Top reset address: 0x%8.8x", val);
3018 bt_dev_dbg(hdev, "Fseq MBX timeout: 0x%8.8x", val);
3021 bt_dev_dbg(hdev, "Fseq MBX ack: 0x%8.8x", val);
3024 bt_dev_dbg(hdev, "Fseq CNVi id: 0x%8.8x", val);
3027 bt_dev_dbg(hdev, "Fseq CNVr id: 0x%8.8x", val);
3030 bt_dev_dbg(hdev, "Fseq Error handle: 0x%8.8x", val);
3033 bt_dev_dbg(hdev, "Fseq Magic noalive indication: 0x%8.8x", val);
3036 bt_dev_dbg(hdev, "Fseq OTP version: 0x%8.8x", val);
3039 bt_dev_dbg(hdev, "Fseq MBX otp version: 0x%8.8x", val);
3045 static int btintel_setup_combined(struct hci_dev *hdev)
3053 BT_DBG("%s", hdev->name);
3069 if (btintel_test_flag(hdev, INTEL_BROKEN_INITIAL_NCMD) ||
3070 btintel_test_flag(hdev, INTEL_BROKEN_SHUTDOWN_LED)) {
3071 skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL,
3074 bt_dev_err(hdev,
3088 skb = __hci_cmd_sync(hdev, 0xfc05, 1, param, HCI_CMD_TIMEOUT);
3090 bt_dev_err(hdev, "Reading Intel version command failed (%ld)",
3097 bt_dev_err(hdev, "Intel Read Version command failed (%02x)",
3104 set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
3105 set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
3106 set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks);
3109 hdev->set_quality_report = btintel_set_quality_report;
3113 bt_dev_dbg(hdev, "Read the legacy Intel version information");
3118 btintel_version_info(hdev, &ver);
3131 btintel_set_flag(hdev, INTEL_ROM_LEGACY);
3142 if (!btintel_test_flag(hdev,
3145 &hdev->quirks);
3147 err = btintel_legacy_rom_setup(hdev, &ver);
3161 &hdev->quirks);
3164 set_bit(HCI_QUIRK_BROKEN_LE_CODED, &hdev->quirks);
3167 btintel_set_msft_opcode(hdev, ver.hw_variant);
3169 err = btintel_bootloader_setup(hdev, &ver);
3170 btintel_register_devcoredump_support(hdev);
3173 bt_dev_err(hdev, "Unsupported Intel hw variant (%u)",
3178 hci_set_hw_info(hdev,
3191 err = btintel_parse_version_tlv(hdev, &ver_tlv, skb);
3193 bt_dev_err(hdev, "Failed to parse TLV version information");
3198 bt_dev_err(hdev, "Unsupported Intel hardware platform (0x%2x)",
3232 err = btintel_read_version(hdev, &ver);
3240 set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
3243 set_bit(HCI_QUIRK_BROKEN_LE_CODED, &hdev->quirks);
3246 btintel_set_msft_opcode(hdev, ver.hw_variant);
3248 err = btintel_bootloader_setup(hdev, &ver);
3249 btintel_register_devcoredump_support(hdev);
3254 hdev->classify_pkt_type = btintel_classify_pkt_type;
3262 btintel_version_info_tlv(hdev, &ver_tlv);
3268 set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
3271 btintel_set_msft_opcode(hdev,
3273 btintel_set_dsm_reset_method(hdev, &ver_tlv);
3275 err = btintel_bootloader_setup_tlv(hdev, &ver_tlv);
3279 btintel_register_devcoredump_support(hdev);
3280 btintel_print_fseq_info(hdev);
3283 bt_dev_err(hdev, "Unsupported Intel hw variant (%u)",
3289 hci_set_hw_info(hdev, "INTEL platform=%u variant=%u",
3299 int btintel_shutdown_combined(struct hci_dev *hdev)
3308 skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
3310 bt_dev_err(hdev, "HCI reset during shutdown failed");
3321 if (btintel_test_flag(hdev, INTEL_BROKEN_SHUTDOWN_LED)) {
3322 skb = __hci_cmd_sync(hdev, 0xfc3f, 0, NULL, HCI_INIT_TIMEOUT);
3325 bt_dev_err(hdev, "turning off Intel device LED failed");
3335 int btintel_configure_setup(struct hci_dev *hdev, const char *driver_name)
3337 hdev->manufacturer = 2;
3338 hdev->setup = btintel_setup_combined;
3339 hdev->shutdown = btintel_shutdown_combined;
3340 hdev->hw_error = btintel_hw_error;
3341 hdev->set_diag = btintel_set_diag_combined;
3342 hdev->set_bdaddr = btintel_set_bdaddr;
3350 int btintel_diagnostics(struct hci_dev *hdev, struct sk_buff *skb)
3364 if (!hci_devcd_init(hdev, skb->len)) {
3365 hci_devcd_append(hdev, skb_clone(skb, GFP_ATOMIC));
3366 hci_devcd_complete(hdev);
3368 bt_dev_err(hdev, "Failed to generate devcoredump");
3372 bt_dev_err(hdev, "Invalid exception type %02X", tlv->val[0]);
3376 return hci_recv_frame(hdev, skb);
3380 int btintel_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
3390 if (btintel_test_flag(hdev, INTEL_BOOTLOADER)) {
3397 btintel_bootup(hdev, ptr, len);
3406 btintel_secure_send_result(hdev, ptr, len);
3418 return btintel_diagnostics(hdev, skb);
3422 return hci_recv_frame(hdev, skb);
3426 void btintel_bootup(struct hci_dev *hdev, const void *ptr, unsigned int len)
3433 if (btintel_test_and_clear_flag(hdev, INTEL_BOOTING))
3434 btintel_wake_up_flag(hdev, INTEL_BOOTING);
3438 void btintel_secure_send_result(struct hci_dev *hdev,
3447 btintel_set_flag(hdev, INTEL_FIRMWARE_FAILED);
3449 if (btintel_test_and_clear_flag(hdev, INTEL_DOWNLOADING) &&
3450 btintel_test_flag(hdev, INTEL_FIRMWARE_LOADED))
3451 btintel_wake_up_flag(hdev, INTEL_DOWNLOADING);