From patchwork Sat Sep 26 05:48:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiran K X-Patchwork-Id: 11801145 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D689B6CB for ; Sat, 26 Sep 2020 05:49:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B01732080A for ; Sat, 26 Sep 2020 05:49:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hC2pq64M" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726239AbgIZFtL (ORCPT ); Sat, 26 Sep 2020 01:49:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725208AbgIZFtK (ORCPT ); Sat, 26 Sep 2020 01:49:10 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAE3EC0613CE for ; Fri, 25 Sep 2020 22:49:10 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id x123so5131469pfc.7 for ; Fri, 25 Sep 2020 22:49:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=BvoTEVYkirbmMSAQKfzYTuw6KhnohE8oJHAW9J3LLlE=; b=hC2pq64MKCZQzDg7cIizOZEPcUU2SexdW6AXbnMysMmvvHwtRCf7d8PMIQgN8C1pB/ ByPADMVfSr1mAx2vvwTJwuSSGVnENflDrPsjqsChL9fK0VnWBQVfqEVWGMarJehiBddG XFKZS9/LQ+bOhKcanhJcg7gMVuM+b3/DO+iY4mYBLY82KuGY1agqchJIIMJtlFrvjtCT IaFuJCoZw0WJZNDX9asD0Z/G9avvuDhOQksmXH4kEp16LazSuc8fR4k1r1C2Dc7WI5Jn i8G1RDCYSxqidUECdSQ5dzQWLqf8Us1Kcdyhx2SR0V5IDj7Angh+BmjDdofjSdmZcGQb kmjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BvoTEVYkirbmMSAQKfzYTuw6KhnohE8oJHAW9J3LLlE=; b=rGk4L5wmtdzLOUtSbIisylBY6On/f66wPBwJ4/BQDmzpejtRWEkhCUbk4zdsw914kh vgKP6vQdiqVj6VGUzFScAPNLSF4TFYicJnuZ7P/eTmrso6RlOjxDgzbBcwYdMZtIpDg0 6jOwhOAeGZpKQDFAVSlvUtzvGH3vGjcrNipzdOXRrXA0UxPDcfe/DBEjWI1RZZtnzboS iFzgQfFRkmfVaL8IHUsEtHVKUGo/JU529waAELhbXJ0YLqEw9qOgXwQdi5lUt1pGriHb tn0+p156rZpLIQrow5RzYqeJWebak6f2VhV74ekypajVaHmctIQ3TTUdJdmfpIsrX94F s2og== X-Gm-Message-State: AOAM5310TZCFbt3nAvHsqAix9VcGEb6g7WUaS6s7HMw88flxN0NILTyG pKq1Hi/u+KqhGbETnJ6+b0NbZoLYo/VFTg== X-Google-Smtp-Source: ABdhPJy8SK27w7qZ773GU/glUEOVXIO7JsnfdH68iDqGBgBQtCrrisDyLlYnnFeNYQtp2ibHvSvcAA== X-Received: by 2002:a63:c54a:: with SMTP id g10mr1133804pgd.316.1601099349733; Fri, 25 Sep 2020 22:49:09 -0700 (PDT) Received: from localhost.localdomain ([122.172.180.132]) by smtp.gmail.com with ESMTPSA id 64sm4293367pfg.98.2020.09.25.22.49.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Sep 2020 22:49:09 -0700 (PDT) From: Kiran K X-Google-Original-From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: sathish.narasimman@intel.com, chethan.tumkur.narayan@intel.com, ravishankar.srivatsa@intel.com, kiraank@gmail.com, Kiran K , Amit K Bag , Raghuram Hegde Subject: [PATCH v2 1/2] Bluetooth: btintel: Add helper function to download firmware Date: Sat, 26 Sep 2020 11:18:41 +0530 Message-Id: <1601099322-9415-1-git-send-email-kiran.k@intel.com> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 1) add a helper function to download firmware for new generation Intel controllers 2) add a function to construct firmware / ddc file name for new generation Intel controllers Signed-off-by: Kiran K Signed-off-by: Amit K Bag Signed-off-by: Raghuram Hegde Reviewed-by: Sathish Narasimman Reviewed-by: Chethan T N Reviewed-by: Srivatsa Ravishankar Reported-by: kernel test robot --- Changes in v2: - Fix typo in commit message drivers/bluetooth/btintel.h | 6 ++ drivers/bluetooth/btusb.c | 183 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+) diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index 09346ae..f5c26dc 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -132,6 +132,12 @@ struct intel_debug_features { __u8 page1[16]; } __packed; +#define INTEL_HW_PLATFORM(cnvx_bt) ((u8)(((cnvx_bt) & 0x0000ff00) >> 8)) +#define INTEL_HW_VARIANT(cnvx_bt) ((u8)(((cnvx_bt) & 0x003f0000) >> 16)) +#define INTEL_CNVX_TOP_TYPE(cnvx_top) ((cnvx_top) & 0x00000fff) +#define INTEL_CNVX_TOP_STEP(cnvx_top) (((cnvx_top) & 0x0f000000) >> 24) +#define INTEL_CNVX_TOP_PACK_SWAB(t, s) __swab16(((__u16)(((t) << 4) | (s)))) + #if IS_ENABLED(CONFIG_BT_INTEL) int btintel_check_bdaddr(struct hci_dev *hdev); diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 9f294b9..ab3d890 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2354,6 +2354,189 @@ static bool btusb_setup_intel_new_get_fw_name(struct intel_version *ver, return true; } +static bool btusb_setup_intel_newgen_get_fw_name(const struct intel_version_tlv *ver_tlv, + char *fw_name, size_t len, + const char *suffix) +{ + /* + * The firmware file name for new generation controllers will be + * ibt-- + */ + snprintf(fw_name, len, "intel/ibt-%04x-%04x.%s", + INTEL_CNVX_TOP_PACK_SWAB(INTEL_CNVX_TOP_TYPE(ver_tlv->cnvi_top), + INTEL_CNVX_TOP_STEP(ver_tlv->cnvi_top)), + INTEL_CNVX_TOP_PACK_SWAB(INTEL_CNVX_TOP_TYPE(ver_tlv->cnvr_top), + INTEL_CNVX_TOP_STEP(ver_tlv->cnvr_top)), + suffix); + return true; +} + +int btusb_intel_download_firmware_newgen(struct hci_dev *hdev, + struct intel_version_tlv *ver, + u32 *boot_param) +{ + const struct firmware *fw; + char fwname[64]; + int err; + struct btusb_data *data = hci_get_drvdata(hdev); + + if (!ver || !boot_param) + return -EINVAL; + + /* The hardware platform number has a fixed value of 0x37 and + * for now only accept this single value. + */ + if (INTEL_HW_PLATFORM(ver->cnvi_bt) != 0x37) { + bt_dev_err(hdev, "Unsupported Intel hardware platform (0x%2x)", + INTEL_HW_PLATFORM(ver->cnvi_bt)); + return -EINVAL; + } + + /* The firmware variant determines if the device is in bootloader + * mode or is running operational firmware. The value 0x03 identifies + * the bootloader and the value 0x23 identifies the operational + * firmware. + * + * When the operational firmware is already present, then only + * the check for valid Bluetooth device address is needed. This + * determines if the device will be added as configured or + * unconfigured controller. + * + * It is not possible to use the Secure Boot Parameters in this + * case since that command is only available in bootloader mode. + */ + if (ver->img_type == 0x03) { + clear_bit(BTUSB_BOOTLOADER, &data->flags); + btintel_check_bdaddr(hdev); + return 0; + } + + /* Check for supported iBT hardware variants of this firmware + * loading method. + * + * This check has been put in place to ensure correct forward + * compatibility options when newer hardware variants come along. + */ + switch (INTEL_HW_VARIANT(ver->cnvi_bt)) { + case 0x17: /* TyP */ + case 0x18: /* Slr */ + case 0x19: /* Slr-F */ + break; + default: + bt_dev_err(hdev, "Unsupported Intel hardware variant (0x%x)", + INTEL_HW_VARIANT(ver->cnvi_bt)); + return -EINVAL; + } + + /* If the device is not in bootloader mode, then the only possible + * choice is to return an error and abort the device initialization. + */ + if (ver->img_type != 0x01) { + bt_dev_err(hdev, "Unsupported Intel firmware variant (0x%x)", + ver->img_type); + return -ENODEV; + } + + /* It is required that every single firmware fragment is acknowledged + * with a command complete event. If the boot parameters indicate + * that this bootloader does not send them, then abort the setup. + */ + if (ver->limited_cce != 0x00) { + bt_dev_err(hdev, "Unsupported Intel firmware loading method (0x%x)", + ver->limited_cce); + return -EINVAL; + } + + /* Secure boot engine type should be either 1 (ECDSA) or 0 (RSA) */ + if (ver->sbe_type > 0x01) { + bt_dev_err(hdev, "Unsupported Intel secure boot engine type (0x%x)", + ver->sbe_type); + return -EINVAL; + } + + /* If the OTP has no valid Bluetooth device address, then there will + * also be no valid address for the operational firmware. + */ + if (!bacmp(&ver->otp_bd_addr, BDADDR_ANY)) { + bt_dev_info(hdev, "No device address configured"); + set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks); + } + + err = btusb_setup_intel_newgen_get_fw_name(ver, fwname, sizeof(fwname), + "sfi"); + if (!err) { + bt_dev_err(hdev, "Unsupported Intel firmware naming"); + return -EINVAL; + } + + err = request_firmware(&fw, fwname, &hdev->dev); + if (err < 0) { + bt_dev_err(hdev, "Failed to load Intel firmware file (%d)", err); + return err; + } + + bt_dev_info(hdev, "Found device firmware: %s", fwname); + + if (fw->size < 644) { + bt_dev_err(hdev, "Invalid size of firmware file (%zu)", + fw->size); + err = -EBADF; + goto done; + } + + set_bit(BTUSB_DOWNLOADING, &data->flags); + + /* Start firmware downloading and get boot parameter */ + err = btintel_download_firmware_newgen(hdev, fw, boot_param, + INTEL_HW_VARIANT(ver->cnvi_bt), + ver->sbe_type); + if (err < 0) { + /* When FW download fails, send Intel Reset to retry + * FW download. + */ + btintel_reset_to_bootloader(hdev); + goto done; + } + set_bit(BTUSB_FIRMWARE_LOADED, &data->flags); + + bt_dev_info(hdev, "Waiting for firmware download to complete"); + + /* Before switching the device into operational mode and with that + * booting the loaded firmware, wait for the bootloader notification + * that all fragments have been successfully received. + * + * When the event processing receives the notification, then the + * BTUSB_DOWNLOADING flag will be cleared. + * + * The firmware loading should not take longer than 5 seconds + * and thus just timeout if that happens and fail the setup + * of this device. + */ + err = wait_on_bit_timeout(&data->flags, BTUSB_DOWNLOADING, + TASK_INTERRUPTIBLE, + msecs_to_jiffies(5000)); + if (err == -EINTR) { + bt_dev_err(hdev, "Firmware loading interrupted"); + goto done; + } + + if (err) { + bt_dev_err(hdev, "Firmware loading timeout"); + err = -ETIMEDOUT; + btintel_reset_to_bootloader(hdev); + goto done; + } + + if (test_bit(BTUSB_FIRMWARE_FAILED, &data->flags)) { + bt_dev_err(hdev, "Firmware loading failed"); + err = -ENOEXEC; + goto done; + } + +done: + release_firmware(fw); + return err; +} static int btusb_intel_download_firmware(struct hci_dev *hdev, struct intel_version *ver, struct intel_boot_params *params, From patchwork Sat Sep 26 05:48:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiran K X-Patchwork-Id: 11801147 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83F4B618 for ; Sat, 26 Sep 2020 05:49:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 62E4920838 for ; Sat, 26 Sep 2020 05:49:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dNI30zWf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726348AbgIZFtO (ORCPT ); Sat, 26 Sep 2020 01:49:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725208AbgIZFtN (ORCPT ); Sat, 26 Sep 2020 01:49:13 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEADFC0613CE for ; Fri, 25 Sep 2020 22:49:13 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id t18so245188plo.1 for ; Fri, 25 Sep 2020 22:49:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=J3cSVu026nB57lq0SBV8o3h/lMYrHWr95LGOYzS4CXI=; b=dNI30zWf8ezE7FYQggTjitm6kNpg2iC2pEsZvJ8ZJXmGV18pYi4eNTu0jOCFMw5h8W GU0X7yyQqXs9IRuBbH6pLGS6j1mw1TaKsWM61vYdXr0UVK9mcYTkeyFDJ/Zhq/N8dJPr ShJt9vKKJqGvEF7yo6BEgRbSsAVR4IvihVqd2EeUZTFgcN0Gl4TzGfeArdNYKuqTNIM6 zO8LMOhNToZH7OXKZwx+RBc/SU4D5mqAOqn+yAiHcgijDKPtBhr6JV9oft/KvbZY4o/X g0bmvU5K0b2gu5hlYa6iTOXP/jDESxpbU2OCjBx7TLlH2LXWa6zt2J0pKX7a7AzAFIrE 29KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=J3cSVu026nB57lq0SBV8o3h/lMYrHWr95LGOYzS4CXI=; b=V7iilnC9NMGet3OzRCIWx+p+LoFZaEFTBPl3p5gKVpYEX0w1rCiF6R/QwwhFbrz+e9 Kr+8hhhtCwAGmwK9YROgF8qBbdPZ8cV7F3DRQUKNZ2q/B30KM9od4taHeNSSd89882M/ Tqpg3lcVRS4fWWW+qBPhj0Lg4Fi4urvL3ou34kMOqW2iDiV6Hyyj5yc8b3iA1RHPt8fk AY/sQuMRzOsW9wuobb+eFowKLOpXydomBfcGR4MM5YFVHhg4mnacJ1cyOtP6NLHkJq9+ n9pe1k1yF0Xa8k0ty7+oNs4aEaWbAKioMbKw2IUSU8kEOSBV9FJqpXrXIqEEoYfqwxhO FI5A== X-Gm-Message-State: AOAM530WPvqiTs9NYgwPHJe65QXfNoKZfl8SYE76DIaeCo3K9mzADfj5 X9BjlrGWTUM/vnbM/j+ON6FkUhbxdo2S9g== X-Google-Smtp-Source: ABdhPJx6nIrU+qfE+ng/OFVXeNKJcbhqDTwpZeXgKFPisgFFnErZLQGGbsVTG3wLhmvHvj75VjdYYQ== X-Received: by 2002:a17:90b:138a:: with SMTP id hr10mr926286pjb.8.1601099352777; Fri, 25 Sep 2020 22:49:12 -0700 (PDT) Received: from localhost.localdomain ([122.172.180.132]) by smtp.gmail.com with ESMTPSA id 64sm4293367pfg.98.2020.09.25.22.49.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Sep 2020 22:49:12 -0700 (PDT) From: Kiran K X-Google-Original-From: Kiran K To: linux-bluetooth@vger.kernel.org Cc: sathish.narasimman@intel.com, chethan.tumkur.narayan@intel.com, ravishankar.srivatsa@intel.com, kiraank@gmail.com, Kiran K , Amit K Bag , Raghuram Hegde Subject: [PATCH v2 2/2] Bluetooth: btintel: Add *setup* function for new generation Intel controllers Date: Sat, 26 Sep 2020 11:18:42 +0530 Message-Id: <1601099322-9415-2-git-send-email-kiran.k@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1601099322-9415-1-git-send-email-kiran.k@intel.com> References: <1601099322-9415-1-git-send-email-kiran.k@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 1) add a flag to identify new geneeration Intel controllers 2) define *setup* and hook it up for new genertion Intel controllers 3) map Typhoon Peak controller (PID:0x0032) to new generation controller Signed-off-by: Kiran K Signed-off-by: Amit K Bag Signed-off-by: Raghuram Hegde Reviewed-by: Sathish Narasimman Reviewed-by: Chethan T N Reviewed-by: Srivatsa Ravishankar --- Changes in v2: - None drivers/bluetooth/btusb.c | 145 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 142 insertions(+), 3 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index ab3d890..698ec95 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver; #define BTUSB_MEDIATEK 0x200000 #define BTUSB_WIDEBAND_SPEECH 0x400000 #define BTUSB_VALID_LE_STATES 0x800000 +#define BTUSB_INTEL_NEWGEN 0x1000000 static const struct usb_device_id btusb_table[] = { /* Generic Bluetooth USB device */ @@ -360,7 +361,7 @@ static const struct usb_device_id blacklist_table[] = { BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x8087, 0x0029), .driver_info = BTUSB_INTEL_NEW | BTUSB_WIDEBAND_SPEECH }, - { USB_DEVICE(0x8087, 0x0032), .driver_info = BTUSB_INTEL_NEW | + { USB_DEVICE(0x8087, 0x0032), .driver_info = BTUSB_INTEL_NEWGEN | BTUSB_WIDEBAND_SPEECH}, { USB_DEVICE(0x8087, 0x07da), .driver_info = BTUSB_CSR }, { USB_DEVICE(0x8087, 0x07dc), .driver_info = BTUSB_INTEL }, @@ -2871,6 +2872,138 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) return 0; } +static int btusb_setup_intel_newgen(struct hci_dev *hdev) +{ + struct btusb_data *data = hci_get_drvdata(hdev); + u32 boot_param; + char ddcname[64]; + ktime_t calltime, delta, rettime; + unsigned long long duration; + int err; + struct intel_debug_features features; + struct intel_version_tlv version; + + BT_DBG("%s", hdev->name); + + /* Set the default boot parameter to 0x0 and it is updated to + * SKU specific boot parameter after reading Intel_Write_Boot_Params + * command while downloading the firmware. + */ + boot_param = 0x00000000; + + calltime = ktime_get(); + + /* Read the Intel version information to determine if the device + * is in bootloader mode or if it already has operational firmware + * loaded. + */ + err = btintel_read_version_tlv(hdev, &version); + if (err) { + bt_dev_err(hdev, "Intel Read version failed (%d)", err); + btintel_reset_to_bootloader(hdev); + return err; + } + + btintel_version_info_tlv(hdev, &version); + + err = btusb_intel_download_firmware_newgen(hdev, &version, &boot_param); + if (err) + return err; + + /* check if controller is already having an operational firmware */ + if (version.img_type == 0x03) + goto finish; + + rettime = ktime_get(); + delta = ktime_sub(rettime, calltime); + duration = (unsigned long long)ktime_to_ns(delta) >> 10; + + bt_dev_info(hdev, "Firmware loaded in %llu usecs", duration); + + calltime = ktime_get(); + + set_bit(BTUSB_BOOTING, &data->flags); + + err = btintel_send_intel_reset(hdev, boot_param); + if (err) { + bt_dev_err(hdev, "Intel Soft Reset failed (%d)", err); + btintel_reset_to_bootloader(hdev); + return err; + } + + /* The bootloader will not indicate when the device is ready. This + * is done by the operational firmware sending bootup notification. + * + * Booting into operational firmware should not take longer than + * 1 second. However if that happens, then just fail the setup + * since something went wrong. + */ + bt_dev_info(hdev, "Waiting for device to boot"); + + err = wait_on_bit_timeout(&data->flags, BTUSB_BOOTING, + TASK_INTERRUPTIBLE, + msecs_to_jiffies(1000)); + + if (err == -EINTR) { + bt_dev_err(hdev, "Device boot interrupted"); + return -EINTR; + } + + if (err) { + bt_dev_err(hdev, "Device boot timeout"); + btintel_reset_to_bootloader(hdev); + return -ETIMEDOUT; + } + + rettime = ktime_get(); + delta = ktime_sub(rettime, calltime); + duration = (unsigned long long)ktime_to_ns(delta) >> 10; + + bt_dev_info(hdev, "Device booted in %llu usecs", duration); + + clear_bit(BTUSB_BOOTLOADER, &data->flags); + + err = btusb_setup_intel_newgen_get_fw_name(&version, ddcname, + sizeof(ddcname), "ddc"); + if (!err) { + bt_dev_err(hdev, "Unsupported Intel firmware naming"); + } else { + /* Once the device is running in operational mode, it needs to + * apply the device configuration (DDC) parameters. + * + * The device can work without DDC parameters, so even if it + * fails to load the file, no need to fail the setup. + */ + btintel_load_ddc_config(hdev, ddcname); + } + + /* Read the Intel supported features and if new exception formats + * supported, need to load the additional DDC config to enable. + */ + btintel_read_debug_features(hdev, &features); + + /* Set DDC mask for available debug features */ + btintel_set_debug_features(hdev, &features); + + /* Read the Intel version information after loading the FW */ + err = btintel_read_version_tlv(hdev, &version); + if (err) + return err; + + btintel_version_info_tlv(hdev, &version); + +finish: + /* Set the event mask for Intel specific vendor events. This enables + * a few extra events that are useful during general operation. It + * does not enable any debugging related events. + * + * The device will function correctly without these events enabled + * and thus no need to fail the setup. + */ + btintel_set_event_mask(hdev, false); + + return 0; +} static int btusb_shutdown_intel(struct hci_dev *hdev) { struct sk_buff *skb; @@ -4119,7 +4252,8 @@ static int btusb_probe(struct usb_interface *intf, init_usb_anchor(&data->ctrl_anchor); spin_lock_init(&data->rxlock); - if (id->driver_info & BTUSB_INTEL_NEW) { + if ((id->driver_info & BTUSB_INTEL_NEW) || + (id->driver_info & BTUSB_INTEL_NEWGEN)) { data->recv_event = btusb_recv_event_intel; data->recv_bulk = btusb_recv_bulk_intel; set_bit(BTUSB_BOOTLOADER, &data->flags); @@ -4214,7 +4348,8 @@ static int btusb_probe(struct usb_interface *intf, set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); } - if (id->driver_info & BTUSB_INTEL_NEW) { + if ((id->driver_info & BTUSB_INTEL_NEW) || + (id->driver_info & BTUSB_INTEL_NEWGEN)) { hdev->manufacturer = 2; hdev->send = btusb_send_frame_intel; hdev->setup = btusb_setup_intel_new; @@ -4228,6 +4363,10 @@ static int btusb_probe(struct usb_interface *intf, set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); } + /* Overload only setup function for new generation Intel controllers */ + if (id->driver_info & BTUSB_INTEL_NEWGEN) + hdev->setup = btusb_setup_intel_newgen; + if (id->driver_info & BTUSB_MARVELL) hdev->set_bdaddr = btusb_set_bdaddr_marvell;