Lines Matching defs:hdev

41 	struct hci_dev *hdev;
62 int btintel_check_bdaddr(struct hci_dev *hdev)
67 skb = __hci_cmd_sync(hdev, HCI_OP_READ_BD_ADDR, 0, NULL,
71 bt_dev_err(hdev, "Reading Intel device address failed (%d)",
77 bt_dev_err(hdev, "Intel device address length mismatch");
90 bt_dev_err(hdev, "Found Intel default device address (%pMR)",
92 set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
101 int btintel_enter_mfg(struct hci_dev *hdev)
106 skb = __hci_cmd_sync(hdev, 0xfc11, 2, param, HCI_CMD_TIMEOUT);
108 bt_dev_err(hdev, "Entering manufacturer mode failed (%ld)",
118 int btintel_exit_mfg(struct hci_dev *hdev, bool reset, bool patched)
131 skb = __hci_cmd_sync(hdev, 0xfc11, 2, param, HCI_CMD_TIMEOUT);
133 bt_dev_err(hdev, "Exiting manufacturer mode failed (%ld)",
143 int btintel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
148 skb = __hci_cmd_sync(hdev, 0xfc31, 6, bdaddr, HCI_INIT_TIMEOUT);
151 bt_dev_err(hdev, "Changing Intel device address failed (%d)",
161 static int btintel_set_event_mask(struct hci_dev *hdev, bool debug)
170 skb = __hci_cmd_sync(hdev, 0xfc52, 8, mask, HCI_INIT_TIMEOUT);
173 bt_dev_err(hdev, "Setting Intel event mask failed (%d)", err);
181 int btintel_set_diag(struct hci_dev *hdev, bool enable)
197 skb = __hci_cmd_sync(hdev, 0xfc43, 3, param, HCI_INIT_TIMEOUT);
202 bt_dev_err(hdev, "Changing Intel diagnostic mode failed (%d)",
209 btintel_set_event_mask(hdev, enable);
214 static int btintel_set_diag_mfg(struct hci_dev *hdev, bool enable)
218 err = btintel_enter_mfg(hdev);
222 ret = btintel_set_diag(hdev, enable);
224 err = btintel_exit_mfg(hdev, false, false);
231 static int btintel_set_diag_combined(struct hci_dev *hdev, bool enable)
240 if (btintel_test_flag(hdev, INTEL_ROM_LEGACY))
241 ret = btintel_set_diag_mfg(hdev, enable);
243 ret = btintel_set_diag(hdev, enable);
248 static void btintel_hw_error(struct hci_dev *hdev, u8 code)
253 bt_dev_err(hdev, "Hardware error 0x%2.2x", code);
255 skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
257 bt_dev_err(hdev, "Reset after hardware error failed (%ld)",
263 skb = __hci_cmd_sync(hdev, 0xfc22, 1, &type, HCI_INIT_TIMEOUT);
265 bt_dev_err(hdev, "Retrieving Intel exception info failed (%ld)",
271 bt_dev_err(hdev, "Exception info size mismatch");
276 bt_dev_err(hdev, "Exception info %s", (char *)(skb->data + 1));
281 int btintel_version_info(struct hci_dev *hdev, struct intel_version *ver)
289 bt_dev_err(hdev, "Unsupported Intel hardware platform (%u)",
311 bt_dev_err(hdev, "Unsupported Intel hardware variant (%u)",
330 bt_dev_err(hdev, "Unsupported firmware variant(%02x)", ver->fw_variant);
337 bt_dev_info(hdev, "%s revision %u.%u build %u week %u %u",
346 static int btintel_secure_send(struct hci_dev *hdev, u8 fragment_type, u32 plen,
356 skb = __hci_cmd_sync(hdev, 0xfc09, fragment_len + 1,
370 int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name)
377 err = request_firmware_direct(&fw, ddc_name, &hdev->dev);
379 bt_dev_err(hdev, "Failed to load Intel DDC file %s (%d)",
384 bt_dev_info(hdev, "Found Intel DDC parameters: %s", ddc_name);
394 skb = __hci_cmd_sync(hdev, 0xfc8b, cmd_plen, fw_ptr,
397 bt_dev_err(hdev, "Failed to send Intel_Write_DDC (%ld)",
409 bt_dev_info(hdev, "Applying Intel DDC parameters completed");
415 int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug)
419 err = btintel_enter_mfg(hdev);
423 ret = btintel_set_event_mask(hdev, debug);
425 err = btintel_exit_mfg(hdev, false, false);
433 int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver)
437 skb = __hci_cmd_sync(hdev, 0xfc05, 0, NULL, HCI_CMD_TIMEOUT);
439 bt_dev_err(hdev, "Reading Intel version information failed (%ld)",
445 bt_dev_err(hdev, "Intel version event size mismatch");
458 static int btintel_version_info_tlv(struct hci_dev *hdev,
467 bt_dev_err(hdev, "Unsupported Intel hardware platform (0x%2x)",
486 bt_dev_err(hdev, "Unsupported Intel hardware variant (0x%x)",
499 bt_dev_err(hdev, "Unsupported Intel firmware loading method (0x%x)",
506 bt_dev_err(hdev, "Unsupported Intel secure boot engine type (0x%x)",
511 bt_dev_info(hdev, "Device revision is %u", version->dev_rev_id);
512 bt_dev_info(hdev, "Secure boot is %s",
514 bt_dev_info(hdev, "OTP lock is %s",
516 bt_dev_info(hdev, "API lock is %s",
518 bt_dev_info(hdev, "Debug lock is %s",
520 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,
542 static int btintel_parse_version_tlv(struct hci_dev *hdev,
644 static int btintel_read_version_tlv(struct hci_dev *hdev,
653 skb = __hci_cmd_sync(hdev, 0xfc05, 1, param, HCI_CMD_TIMEOUT);
655 bt_dev_err(hdev, "Reading Intel version information failed (%ld)",
661 bt_dev_err(hdev, "Intel Read Version command failed (%02x)",
667 btintel_parse_version_tlv(hdev, version, skb);
680 struct hci_dev *hdev;
728 bt_dev_dbg(ctx->hdev, "Register (0x%x) read", le32_to_cpu(cp.addr));
730 skb = hci_cmd_sync(ctx->hdev, ctx->op_read, sizeof(cp), &cp,
734 bt_dev_err(ctx->hdev, "regmap: Register (0x%x) read error (%d)",
740 bt_dev_err(ctx->hdev, "regmap: Register (0x%x) read error, bad len",
749 bt_dev_err(ctx->hdev, "regmap: Register (0x%x) read error, bad addr",
800 bt_dev_dbg(ctx->hdev, "Register (0x%x) write", le32_to_cpu(cp->addr));
802 skb = hci_cmd_sync(ctx->hdev, ctx->op_write, plen, cp, HCI_CMD_TIMEOUT);
805 bt_dev_err(ctx->hdev, "regmap: Register (0x%x) write error (%d)",
848 struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read,
853 bt_dev_info(hdev, "regmap: Init R%x-W%x region", opcode_read,
862 ctx->hdev = hdev;
864 return regmap_init(&hdev->dev, &regmap_ibt, ctx, &regmap_ibt_cfg);
868 int btintel_send_intel_reset(struct hci_dev *hdev, u32 boot_param)
875 skb = __hci_cmd_sync(hdev, 0xfc01, sizeof(params), &params,
878 bt_dev_err(hdev, "Failed to send Intel Reset command");
888 int btintel_read_boot_params(struct hci_dev *hdev,
893 skb = __hci_cmd_sync(hdev, 0xfc0d, 0, NULL, HCI_INIT_TIMEOUT);
895 bt_dev_err(hdev, "Reading Intel boot parameters failed (%ld)",
901 bt_dev_err(hdev, "Intel boot parameters size mismatch");
911 bt_dev_err(hdev, "Intel boot parameters command failed (%02x)",
916 bt_dev_info(hdev, "Device revision is %u",
919 bt_dev_info(hdev, "Secure boot is %s",
922 bt_dev_info(hdev, "OTP lock is %s",
925 bt_dev_info(hdev, "API lock is %s",
928 bt_dev_info(hdev, "Debug lock is %s",
931 bt_dev_info(hdev, "Minimum firmware build %u week %u %u",
939 static int btintel_sfi_rsa_header_secure_send(struct hci_dev *hdev,
947 err = btintel_secure_send(hdev, 0x00, 128, fw->data);
949 bt_dev_err(hdev, "Failed to send firmware header (%d)", err);
956 err = btintel_secure_send(hdev, 0x03, 256, fw->data + 128);
958 bt_dev_err(hdev, "Failed to send firmware pkey (%d)", err);
965 err = btintel_secure_send(hdev, 0x02, 256, fw->data + 388);
967 bt_dev_err(hdev, "Failed to send firmware signature (%d)", err);
975 static int btintel_sfi_ecdsa_header_secure_send(struct hci_dev *hdev,
983 err = btintel_secure_send(hdev, 0x00, 128, fw->data + 644);
985 bt_dev_err(hdev, "Failed to send firmware header (%d)", err);
992 err = btintel_secure_send(hdev, 0x03, 96, fw->data + 644 + 128);
994 bt_dev_err(hdev, "Failed to send firmware pkey (%d)", err);
1001 err = btintel_secure_send(hdev, 0x02, 96, fw->data + 644 + 224);
1003 bt_dev_err(hdev, "Failed to send firmware signature (%d)",
1010 static int btintel_download_firmware_payload(struct hci_dev *hdev,
1036 err = btintel_secure_send(hdev, 0x01, frag_len, fw_ptr);
1038 bt_dev_err(hdev,
1053 static bool btintel_firmware_version(struct hci_dev *hdev,
1077 bt_dev_info(hdev, "Boot Address: 0x%x", *boot_addr);
1079 bt_dev_info(hdev, "Firmware Version: %u-%u.%u",
1094 int btintel_download_firmware(struct hci_dev *hdev,
1112 if (btintel_firmware_version(hdev, ver->fw_build_num,
1115 bt_dev_info(hdev, "Firmware already loaded");
1134 err = btintel_sfi_rsa_header_secure_send(hdev, fw);
1138 return btintel_download_firmware_payload(hdev, fw, RSA_HEADER_LEN);
1142 static int btintel_download_fw_tlv(struct hci_dev *hdev,
1151 if (btintel_firmware_version(hdev, ver->min_fw_build_nn,
1155 bt_dev_info(hdev, "Firmware already loaded");
1187 bt_dev_err(hdev, "Invalid CSS Header version");
1193 bt_dev_err(hdev, "Invalid SBE type for hardware variant (%d)",
1198 err = btintel_sfi_rsa_header_secure_send(hdev, fw);
1202 err = btintel_download_firmware_payload(hdev, fw, RSA_HEADER_LEN);
1213 bt_dev_err(hdev, "Invalid CSS Header version");
1218 err = btintel_sfi_rsa_header_secure_send(hdev, fw);
1222 err = btintel_download_firmware_payload(hdev, fw,
1227 err = btintel_sfi_ecdsa_header_secure_send(hdev, fw);
1231 err = btintel_download_firmware_payload(hdev, fw,
1240 static void btintel_reset_to_bootloader(struct hci_dev *hdev)
1266 skb = __hci_cmd_sync(hdev, 0xfc01, sizeof(params),
1269 bt_dev_err(hdev, "FW download error recovery failed (%ld)",
1273 bt_dev_info(hdev, "Intel reset sent to retry FW download");
1284 static int btintel_read_debug_features(struct hci_dev *hdev,
1293 skb = __hci_cmd_sync(hdev, 0xfca6, sizeof(page_no), &page_no,
1296 bt_dev_err(hdev, "Reading supported features failed (%ld)",
1302 bt_dev_err(hdev, "Supported features event size mismatch");
1324 struct hci_dev *hdev = ppag->hdev;
1328 bt_dev_warn(hdev, "PPAG-BT: ACPI Failure: %s", acpi_format_exception(status));
1347 bt_dev_warn(hdev, "PPAG-BT: ACPI Failure: %s", acpi_format_exception(status));
1356 bt_dev_warn(hdev, "PPAG-BT: Invalid object type: %d or package count: %d",
1374 static int btintel_set_debug_features(struct hci_dev *hdev,
1384 bt_dev_warn(hdev, "Debug features not read");
1389 bt_dev_info(hdev, "Telemetry exception format not supported");
1393 skb = __hci_cmd_sync(hdev, 0xfc8b, 11, mask, HCI_INIT_TIMEOUT);
1395 bt_dev_err(hdev, "Setting Intel telemetry ddc write event mask failed (%ld)",
1401 skb = __hci_cmd_sync(hdev, 0xfc8b, 5, period, HCI_INIT_TIMEOUT);
1403 bt_dev_err(hdev, "Setting periodicity for link statistics traces failed (%ld)",
1409 skb = __hci_cmd_sync(hdev, 0xfca1, 1, &trace_enable, HCI_INIT_TIMEOUT);
1411 bt_dev_err(hdev, "Enable tracing of link statistics events failed (%ld)",
1417 bt_dev_info(hdev, "set debug features: trace_enable 0x%02x mask 0x%02x",
1423 static int btintel_reset_debug_features(struct hci_dev *hdev,
1432 bt_dev_warn(hdev, "Debug features not read");
1437 bt_dev_info(hdev, "Telemetry exception format not supported");
1442 skb = __hci_cmd_sync(hdev, 0xfca1, 1, &trace_enable, HCI_INIT_TIMEOUT);
1444 bt_dev_err(hdev, "Stop tracing of link statistics events failed (%ld)",
1450 skb = __hci_cmd_sync(hdev, 0xfc8b, 11, mask, HCI_INIT_TIMEOUT);
1452 bt_dev_err(hdev, "Setting Intel telemetry ddc write event mask failed (%ld)",
1458 bt_dev_info(hdev, "reset debug features: trace_enable 0x%02x mask 0x%02x",
1464 int btintel_set_quality_report(struct hci_dev *hdev, bool enable)
1469 bt_dev_dbg(hdev, "enable %d", enable);
1474 err = btintel_read_debug_features(hdev, &features);
1480 err = btintel_set_debug_features(hdev, &features);
1482 err = btintel_reset_debug_features(hdev, &features);
1488 static void btintel_coredump(struct hci_dev *hdev)
1492 skb = __hci_cmd_sync(hdev, 0xfc4e, 0, NULL, HCI_CMD_TIMEOUT);
1494 bt_dev_err(hdev, "Coredump failed (%ld)", PTR_ERR(skb));
1501 static void btintel_dmp_hdr(struct hci_dev *hdev, struct sk_buff *skb)
1520 static int btintel_register_devcoredump_support(struct hci_dev *hdev)
1525 err = btintel_read_debug_features(hdev, &features);
1527 bt_dev_info(hdev, "Error reading debug features");
1532 bt_dev_dbg(hdev, "Telemetry exception format not supported");
1536 hci_devcd_register(hdev, btintel_coredump, btintel_dmp_hdr, NULL);
1541 static const struct firmware *btintel_legacy_rom_get_fw(struct hci_dev *hdev,
1554 ret = request_firmware(&fw, fwname, &hdev->dev);
1557 bt_dev_err(hdev, "Intel firmware file request failed (%d)",
1562 bt_dev_err(hdev, "failed to open Intel firmware file: %s (%d)",
1570 if (request_firmware(&fw, fwname, &hdev->dev) < 0) {
1571 bt_dev_err(hdev, "failed to open default fw file: %s",
1577 bt_dev_info(hdev, "Intel Bluetooth firmware file: %s", fwname);
1582 static int btintel_legacy_rom_patching(struct hci_dev *hdev,
1601 bt_dev_err(hdev, "Intel fw corrupted: invalid cmd read");
1615 bt_dev_err(hdev, "Intel fw corrupted: invalid cmd len");
1648 bt_dev_err(hdev, "Intel fw corrupted: invalid evt len");
1662 bt_dev_err(hdev, "Intel fw corrupted: invalid evt read");
1666 skb = __hci_cmd_sync_ev(hdev, le16_to_cpu(cmd->opcode), cmd->plen,
1669 bt_dev_err(hdev, "sending Intel patch command (0x%4.4x) failed (%ld)",
1679 bt_dev_err(hdev, "mismatch event length (opcode 0x%4.4x)",
1686 bt_dev_err(hdev, "mismatch event parameter (opcode 0x%4.4x)",
1696 static int btintel_legacy_rom_setup(struct hci_dev *hdev,
1704 BT_DBG("%s", hdev->name);
1711 bt_dev_info(hdev,
1723 fw = btintel_legacy_rom_get_fw(hdev, ver);
1732 err = btintel_enter_mfg(hdev);
1763 ret = btintel_legacy_rom_patching(hdev, fw, &fw_ptr,
1777 err = btintel_exit_mfg(hdev, true, true);
1784 err = btintel_read_version(hdev, &new_ver);
1788 bt_dev_info(hdev, "Intel BT fw patch 0x%02x completed & activated",
1795 err = btintel_exit_mfg(hdev, false, false);
1799 bt_dev_info(hdev, "Intel firmware patch completed");
1809 err = btintel_exit_mfg(hdev, true, false);
1813 bt_dev_info(hdev, "Intel firmware patch completed and deactivated");
1819 btintel_set_event_mask_mfg(hdev, false);
1821 btintel_check_bdaddr(hdev);
1826 static int btintel_download_wait(struct hci_dev *hdev, ktime_t calltime, int msec)
1832 btintel_set_flag(hdev, INTEL_FIRMWARE_LOADED);
1834 bt_dev_info(hdev, "Waiting for firmware download to complete");
1836 err = btintel_wait_on_flag_timeout(hdev, INTEL_DOWNLOADING,
1840 bt_dev_err(hdev, "Firmware loading interrupted");
1845 bt_dev_err(hdev, "Firmware loading timeout");
1849 if (btintel_test_flag(hdev, INTEL_FIRMWARE_FAILED)) {
1850 bt_dev_err(hdev, "Firmware loading failed");
1858 bt_dev_info(hdev, "Firmware loaded in %llu usecs", duration);
1863 static int btintel_boot_wait(struct hci_dev *hdev, ktime_t calltime, int msec)
1869 bt_dev_info(hdev, "Waiting for device to boot");
1871 err = btintel_wait_on_flag_timeout(hdev, INTEL_BOOTING,
1875 bt_dev_err(hdev, "Device boot interrupted");
1880 bt_dev_err(hdev, "Device boot timeout");
1888 bt_dev_info(hdev, "Device booted in %llu usecs", duration);
1893 static int btintel_boot(struct hci_dev *hdev, u32 boot_addr)
1900 btintel_set_flag(hdev, INTEL_BOOTING);
1902 err = btintel_send_intel_reset(hdev, boot_addr);
1904 bt_dev_err(hdev, "Intel Soft Reset failed (%d)", err);
1905 btintel_reset_to_bootloader(hdev);
1916 err = btintel_boot_wait(hdev, calltime, 1000);
1918 btintel_reset_to_bootloader(hdev);
1953 static int btintel_download_fw(struct hci_dev *hdev,
1980 btintel_clear_flag(hdev, INTEL_BOOTLOADER);
1981 btintel_check_bdaddr(hdev);
1999 err = btintel_read_boot_params(hdev, params);
2008 bt_dev_err(hdev, "Unsupported Intel firmware loading method (%u)",
2017 bt_dev_info(hdev, "No device address configured");
2018 set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
2045 if (!btintel_test_flag(hdev, INTEL_BOOTLOADER)) {
2047 btintel_set_flag(hdev, INTEL_FIRMWARE_LOADED);
2051 bt_dev_err(hdev, "Unsupported Intel firmware naming");
2055 err = firmware_request_nowarn(&fw, fwname, &hdev->dev);
2057 if (!btintel_test_flag(hdev, INTEL_BOOTLOADER)) {
2059 btintel_set_flag(hdev, INTEL_FIRMWARE_LOADED);
2063 bt_dev_err(hdev, "Failed to load Intel firmware file %s (%d)",
2068 bt_dev_info(hdev, "Found device firmware: %s", fwname);
2071 bt_dev_err(hdev, "Invalid size of firmware file (%zu)",
2079 btintel_set_flag(hdev, INTEL_DOWNLOADING);
2082 err = btintel_download_firmware(hdev, ver, fw, boot_param);
2086 btintel_set_flag(hdev, INTEL_FIRMWARE_LOADED);
2094 btintel_reset_to_bootloader(hdev);
2109 err = btintel_download_wait(hdev, calltime, 5000);
2111 btintel_reset_to_bootloader(hdev);
2118 static int btintel_bootloader_setup(struct hci_dev *hdev,
2127 BT_DBG("%s", hdev->name);
2135 btintel_set_flag(hdev, INTEL_BOOTLOADER);
2137 err = btintel_download_fw(hdev, ver, &params, &boot_param);
2145 err = btintel_boot(hdev, boot_param);
2149 btintel_clear_flag(hdev, INTEL_BOOTLOADER);
2155 bt_dev_err(hdev, "Unsupported Intel firmware naming");
2163 btintel_load_ddc_config(hdev, ddcname);
2166 hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT);
2169 err = btintel_read_version(hdev, &new_ver);
2173 btintel_version_info(hdev, &new_ver);
2183 btintel_set_event_mask(hdev, false);
2203 static int btintel_prepare_fw_download_tlv(struct hci_dev *hdev,
2229 btintel_clear_flag(hdev, INTEL_BOOTLOADER);
2230 btintel_check_bdaddr(hdev);
2238 bt_dev_info(hdev, "No device address configured");
2239 set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
2244 err = firmware_request_nowarn(&fw, fwname, &hdev->dev);
2246 if (!btintel_test_flag(hdev, INTEL_BOOTLOADER)) {
2248 btintel_set_flag(hdev, INTEL_FIRMWARE_LOADED);
2252 bt_dev_err(hdev, "Failed to load Intel firmware file %s (%d)",
2258 bt_dev_info(hdev, "Found device firmware: %s", fwname);
2261 bt_dev_err(hdev, "Invalid size of firmware file (%zu)",
2269 btintel_set_flag(hdev, INTEL_DOWNLOADING);
2272 err = btintel_download_fw_tlv(hdev, ver, fw, boot_param,
2278 btintel_set_flag(hdev, INTEL_FIRMWARE_LOADED);
2286 btintel_reset_to_bootloader(hdev);
2301 err = btintel_download_wait(hdev, calltime, 5000);
2303 btintel_reset_to_bootloader(hdev);
2310 static int btintel_get_codec_config_data(struct hci_dev *hdev,
2323 bt_dev_err(hdev, "Invalid link type(%u)", link);
2343 bt_dev_err(hdev, "Invalid codec id(%u)", codec->id);
2359 static int btintel_get_data_path_id(struct hci_dev *hdev, __u8 *data_path_id)
2366 static int btintel_configure_offload(struct hci_dev *hdev)
2372 skb = __hci_cmd_sync(hdev, 0xfc86, 0, NULL, HCI_INIT_TIMEOUT);
2374 bt_dev_err(hdev, "Reading offload use cases failed (%ld)",
2392 hdev->get_data_path_id = btintel_get_data_path_id;
2393 hdev->get_codec_config_data = btintel_get_codec_config_data;
2400 static void btintel_set_ppag(struct hci_dev *hdev, struct intel_version_tlv *ver)
2412 bt_dev_dbg(hdev, "PPAG not supported for Intel CNVr (0x%3x)",
2417 handle = ACPI_HANDLE(GET_HCIDEV_DEV(hdev));
2419 bt_dev_info(hdev, "No support for BT device in ACPI firmware");
2425 ppag.hdev = hdev;
2432 bt_dev_dbg(hdev, "PPAG-BT: ACPI entry not found");
2439 bt_dev_dbg(hdev, "PPAG-BT: Bluetooth domain is disabled in ACPI firmware");
2450 bt_dev_dbg(hdev, "PPAG-BT: EU, China mode are disabled in CB/BIOS");
2456 skb = __hci_cmd_sync(hdev, INTEL_OP_PPAG_CMD, sizeof(ppag_cmd), &ppag_cmd, HCI_CMD_TIMEOUT);
2458 bt_dev_warn(hdev, "Failed to send PPAG Enable (%ld)", PTR_ERR(skb));
2461 bt_dev_info(hdev, "PPAG-BT: Enabled (Mode %d)", ppag.mode);
2465 static int btintel_acpi_reset_method(struct hci_dev *hdev)
2472 status = acpi_evaluate_object(ACPI_HANDLE(GET_HCIDEV_DEV(hdev)), "_PRR", NULL, &buffer);
2474 bt_dev_err(hdev, "Failed to run _PRR method");
2481 bt_dev_err(hdev, "Invalid arguments");
2488 bt_dev_err(hdev, "Invalid object type: 0x%x", ref->type);
2495 bt_dev_err(hdev, "Failed to run_RST method");
2505 static void btintel_set_dsm_reset_method(struct hci_dev *hdev,
2508 struct btintel_data *data = hci_get_priv(hdev);
2509 acpi_handle handle = ACPI_HANDLE(GET_HCIDEV_DEV(hdev));
2517 handle = ACPI_HANDLE(GET_HCIDEV_DEV(hdev));
2520 bt_dev_dbg(hdev, "No support for bluetooth device in ACPI firmware");
2525 bt_dev_err(hdev, "No support for _PRR ACPI method");
2539 bt_dev_err(hdev, "No dsm support to set reset delay");
2548 bt_dev_err(hdev, "Failed to call dsm to set reset delay");
2554 bt_dev_info(hdev, "DSM reset method type: 0x%02x", reset_payload[2]);
2558 bt_dev_warn(hdev, "No support for dsm to set reset method");
2568 bt_dev_err(hdev, "Failed to call dsm to set reset method");
2575 static int btintel_bootloader_setup_tlv(struct hci_dev *hdev,
2583 bt_dev_dbg(hdev, "");
2591 btintel_set_flag(hdev, INTEL_BOOTLOADER);
2593 err = btintel_prepare_fw_download_tlv(hdev, ver, &boot_param);
2601 err = btintel_boot(hdev, boot_param);
2605 btintel_clear_flag(hdev, INTEL_BOOTLOADER);
2614 btintel_load_ddc_config(hdev, ddcname);
2617 btintel_configure_offload(hdev);
2619 hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT);
2622 btintel_set_ppag(hdev, ver);
2625 err = btintel_read_version_tlv(hdev, &new_ver);
2629 btintel_version_info_tlv(hdev, &new_ver);
2639 btintel_set_event_mask(hdev, false);
2644 static void btintel_set_msft_opcode(struct hci_dev *hdev, u8 hw_variant)
2660 hci_set_msft_opcode(hdev, 0xFC1E);
2668 static int btintel_setup_combined(struct hci_dev *hdev)
2676 BT_DBG("%s", hdev->name);
2692 if (btintel_test_flag(hdev, INTEL_BROKEN_INITIAL_NCMD) ||
2693 btintel_test_flag(hdev, INTEL_BROKEN_SHUTDOWN_LED)) {
2694 skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL,
2697 bt_dev_err(hdev,
2711 skb = __hci_cmd_sync(hdev, 0xfc05, 1, param, HCI_CMD_TIMEOUT);
2713 bt_dev_err(hdev, "Reading Intel version command failed (%ld)",
2720 bt_dev_err(hdev, "Intel Read Version command failed (%02x)",
2727 set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
2728 set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
2729 set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks);
2732 hdev->set_quality_report = btintel_set_quality_report;
2736 bt_dev_dbg(hdev, "Read the legacy Intel version information");
2741 btintel_version_info(hdev, &ver);
2754 btintel_set_flag(hdev, INTEL_ROM_LEGACY);
2765 if (!btintel_test_flag(hdev,
2768 &hdev->quirks);
2771 &hdev->quirks);
2773 err = btintel_legacy_rom_setup(hdev, &ver);
2780 set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
2788 &hdev->quirks);
2791 set_bit(HCI_QUIRK_BROKEN_LE_CODED, &hdev->quirks);
2794 btintel_set_msft_opcode(hdev, ver.hw_variant);
2796 err = btintel_bootloader_setup(hdev, &ver);
2797 btintel_register_devcoredump_support(hdev);
2800 bt_dev_err(hdev, "Unsupported Intel hw variant (%u)",
2813 err = btintel_parse_version_tlv(hdev, &ver_tlv, skb);
2815 bt_dev_err(hdev, "Failed to parse TLV version information");
2820 bt_dev_err(hdev, "Unsupported Intel hardware platform (0x%2x)",
2854 err = btintel_read_version(hdev, &ver);
2862 set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
2865 set_bit(HCI_QUIRK_BROKEN_LE_CODED, &hdev->quirks);
2868 set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
2871 btintel_set_msft_opcode(hdev, ver.hw_variant);
2873 err = btintel_bootloader_setup(hdev, &ver);
2874 btintel_register_devcoredump_support(hdev);
2882 btintel_version_info_tlv(hdev, &ver_tlv);
2888 set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
2891 set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
2894 btintel_set_msft_opcode(hdev,
2896 btintel_set_dsm_reset_method(hdev, &ver_tlv);
2898 err = btintel_bootloader_setup_tlv(hdev, &ver_tlv);
2899 btintel_register_devcoredump_support(hdev);
2902 bt_dev_err(hdev, "Unsupported Intel hw variant (%u)",
2914 static int btintel_shutdown_combined(struct hci_dev *hdev)
2923 skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
2925 bt_dev_err(hdev, "HCI reset during shutdown failed");
2936 if (btintel_test_flag(hdev, INTEL_BROKEN_SHUTDOWN_LED)) {
2937 skb = __hci_cmd_sync(hdev, 0xfc3f, 0, NULL, HCI_INIT_TIMEOUT);
2940 bt_dev_err(hdev, "turning off Intel device LED failed");
2949 int btintel_configure_setup(struct hci_dev *hdev, const char *driver_name)
2951 hdev->manufacturer = 2;
2952 hdev->setup = btintel_setup_combined;
2953 hdev->shutdown = btintel_shutdown_combined;
2954 hdev->hw_error = btintel_hw_error;
2955 hdev->set_diag = btintel_set_diag_combined;
2956 hdev->set_bdaddr = btintel_set_bdaddr;
2964 static int btintel_diagnostics(struct hci_dev *hdev, struct sk_buff *skb)
2978 if (!hci_devcd_init(hdev, skb->len)) {
2979 hci_devcd_append(hdev, skb);
2980 hci_devcd_complete(hdev);
2982 bt_dev_err(hdev, "Failed to generate devcoredump");
2987 bt_dev_err(hdev, "Invalid exception type %02X", tlv->val[0]);
2991 return hci_recv_frame(hdev, skb);
2994 int btintel_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
3004 if (btintel_test_flag(hdev, INTEL_BOOTLOADER)) {
3011 btintel_bootup(hdev, ptr, len);
3019 btintel_secure_send_result(hdev, ptr, len);
3030 return btintel_diagnostics(hdev, skb);
3034 return hci_recv_frame(hdev, skb);
3038 void btintel_bootup(struct hci_dev *hdev, const void *ptr, unsigned int len)
3045 if (btintel_test_and_clear_flag(hdev, INTEL_BOOTING))
3046 btintel_wake_up_flag(hdev, INTEL_BOOTING);
3050 void btintel_secure_send_result(struct hci_dev *hdev,
3059 btintel_set_flag(hdev, INTEL_FIRMWARE_FAILED);
3061 if (btintel_test_and_clear_flag(hdev, INTEL_DOWNLOADING) &&
3062 btintel_test_flag(hdev, INTEL_FIRMWARE_LOADED))
3063 btintel_wake_up_flag(hdev, INTEL_DOWNLOADING);