From patchwork Thu Oct 22 08:24:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11850499 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3537C4363A for ; Thu, 22 Oct 2020 08:19:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 55E92223BF for ; Thu, 22 Oct 2020 08:19:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ckfR5Pes" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2894828AbgJVITL (ORCPT ); Thu, 22 Oct 2020 04:19:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2443979AbgJVITK (ORCPT ); Thu, 22 Oct 2020 04:19:10 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 504EAC0613CE for ; Thu, 22 Oct 2020 01:19:10 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id e15so673526pfh.6 for ; Thu, 22 Oct 2020 01:19: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:in-reply-to:references; bh=8KtUk2kpQBYZMeYj1ttnbvvxz0iE7tmEcQp0BtrQMwE=; b=ckfR5Pes2q9avYh0mft+9TKeu11CRpJQrxPnAJmAft2gx37eVFn+i+rA3dWrw+llZY BuypZ8kt8XjUWUwaEbk6EcIVeDFw5zz6tNoosUIMwivOcaUzOTS4OTsO7vLDj4U1Ovs7 +8QT4eZco7716tBtlQ6kwCwjBHIfR05cFL7dWSkI74a3+SIahVT29im8PHB0XFeb59x0 gkqlkgg/hcA4NV7ZPG8h0dCNRnc39waB8GmeEsKWGPLtuHJipcsKiNOpKadCRX93XIV+ wbZPaULQ0vT/9MDZG19l/JCwH5BhK1FhaUEe9626rIHdYExIGMuPiX/+/vzHfKBF9Qrt 2EVA== 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=8KtUk2kpQBYZMeYj1ttnbvvxz0iE7tmEcQp0BtrQMwE=; b=B5McAXODpqrXe2iBmFy8qaDAnCkT5u/7oASUs+2RfmDuXhaSQWX52i8s9Km2hH7zRy 6BJgwlN4Wv6yWMBwae1J/HcJVI6mA9LE29+al0t2nx6H2G4AOwOO/SEyhmZ0YMZnP2V6 PyRv+MpN0h1dw1oBLXHa5hMBdQB2gCoX69nA9JF7Oy1bZPJ8FqXILMtaGqtnf3Ujmxv9 Nngin30XSBo3mT/btEkY64z6CIV9KHVFJiCQvbfAAG74cy6edrHClGui3OGZRTlLem2U X8iCxSjNacN9/OhEI/lq2+rNsrqd6Yy4f+9HywoNf9uPx1GulDcgB+sK5Cb3VK59ryQK r6rQ== X-Gm-Message-State: AOAM530IkLRHpetHLrk/iRE2rJ0VYU9kOEQjAZG0DSoiQSnZNwO1YJN3 KDUrhylAjrkMzjIwMWP2wJwVj/4UJqLChcaI X-Google-Smtp-Source: ABdhPJz2X+Q1N6t4fYJq8EYCcy0ZGhHrnY+mM2YLesoIQdGxQt/1xnUelGdoq9xzc0UyMry7nZsSuw== X-Received: by 2002:a62:b417:0:b029:142:2501:35dc with SMTP id h23-20020a62b4170000b0290142250135dcmr1519045pfn.60.1603354749670; Thu, 22 Oct 2020 01:19:09 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([134.134.137.79]) by smtp.gmail.com with ESMTPSA id j5sm1179514pjb.56.2020.10.22.01.19.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2020 01:19:09 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: chethan.tumkur.narayan@intel.com, ravishankar.srivatsa@intel.com, kiran.k@intel.com, Sathish Narasimman Subject: [PATCH 1/3] Bluetooth: btintel: seperated TLV parsing as new function Date: Thu, 22 Oct 2020 13:54:33 +0530 Message-Id: <20201022082435.31831-2-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201022082435.31831-1-sathish.narasimman@intel.com> References: <20201022082435.31831-1-sathish.narasimman@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Create a seperate TLV parse function to read btintel TLV structure. Signed-off-by: Sathish Narasimman --- drivers/bluetooth/btintel.c | 54 ++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index 88ce5f0ffc4b..cc8e6c4e3205 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -401,31 +401,9 @@ void btintel_version_info_tlv(struct hci_dev *hdev, struct intel_version_tlv *ve } EXPORT_SYMBOL_GPL(btintel_version_info_tlv); -int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *version) +static void btintel_parse_tlv(struct sk_buff *skb, + struct intel_version_tlv *version) { - struct sk_buff *skb; - const u8 param[1] = { 0xFF }; - - if (!version) - return -EINVAL; - - skb = __hci_cmd_sync(hdev, 0xfc05, 1, param, HCI_CMD_TIMEOUT); - if (IS_ERR(skb)) { - bt_dev_err(hdev, "Reading Intel version information failed (%ld)", - PTR_ERR(skb)); - return PTR_ERR(skb); - } - - if (skb->data[0]) { - bt_dev_err(hdev, "Intel Read Version command failed (%02x)", - skb->data[0]); - kfree_skb(skb); - return -EIO; - } - - /* Consume Command Complete Status field */ - skb_pull(skb, 1); - /* Event parameters contatin multiple TLVs. Read each of them * and only keep the required data. Also, it use existing legacy * version field like hw_platform, hw_variant, and fw_variant @@ -496,6 +474,34 @@ int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *ver /* consume the current tlv and move to next*/ skb_pull(skb, tlv->len + sizeof(*tlv)); } +} + +int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *version) +{ + struct sk_buff *skb; + const u8 param[1] = { 0xFF }; + + if (!version) + return -EINVAL; + + skb = __hci_cmd_sync(hdev, 0xfc05, 1, param, HCI_CMD_TIMEOUT); + if (IS_ERR(skb)) { + bt_dev_err(hdev, "Reading Intel version information failed (%ld)", + PTR_ERR(skb)); + return PTR_ERR(skb); + } + + if (skb->data[0]) { + bt_dev_err(hdev, "Intel Read Version command failed (%02x)", + skb->data[0]); + kfree_skb(skb); + return -EIO; + } + + /* Consume Command Complete Status field */ + skb_pull(skb, 1); + + btintel_parse_tlv(skb, version); kfree_skb(skb); return 0; From patchwork Thu Oct 22 08:24:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11850493 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF235C4363A for ; Thu, 22 Oct 2020 08:19:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D11A21481 for ; Thu, 22 Oct 2020 08:19:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U/uHaqjv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2894831AbgJVITQ (ORCPT ); Thu, 22 Oct 2020 04:19:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2443979AbgJVITP (ORCPT ); Thu, 22 Oct 2020 04:19:15 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3167FC0613CE for ; Thu, 22 Oct 2020 01:19:14 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id t22so549243plr.9 for ; Thu, 22 Oct 2020 01:19:14 -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=wiNgrnZtCuvQcb5zEd4xakXVaM2f+04392e0eDjTsuY=; b=U/uHaqjvtQ5GugBE0/xgJv0UnnDKE24y/giRqg6kYooOXfTj80ZIUmj/EwlymUBKi/ 59fUBl2qscvvb3UhmbudDuSXF69ZxmFDg9Js7KOnggHRu0rribzitnVp+ovmkd6IzPGp tbDDiKKmA+fWraRMO3LDqNzTP6jMbWUaii7yB4jMhuqYFvUOpsyTBaM6QfEswK9RLZYm kYoRDwrW9L7hrpEeCG5ifCYqang3KGbSAu6oorIlHzAiHEZIgkkG9ud4kSWJOij0xNtP 7w4qtwLfMc8ARUtZkU7UtuK+bumCE1isJXNU5RPP+UluHTQZKOk9W0MzpFtL5ky5FChX 7Z+Q== 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=wiNgrnZtCuvQcb5zEd4xakXVaM2f+04392e0eDjTsuY=; b=KsdVkv91U49RWsr6c+MjbUSW8XSLYYLyEjsJtXFEOhwBpBwhaLeg5gflcR++wByuot KND2ePmUPES8PIHF8iz1vJ9hnFPrZudsoQixSNwT7BFSUZLloHVrC/sKhC1HFbnSTPsg V7SCKfySXdJ6EZeQlMuOFoxNZ39Xak8o+4DyBEIHoh66nbhpu52PRsxyFzZxPrSS8Q+6 sJPdMm15cl2zCbw9uAtJgMaB4Pvx7NedjoioyW8DhAEDzMuDa7uA0cGmQgZW228/mlWy kWnk2JYsdDGqANDg11mmVnElZ4pqlL8nDbvuI+izmdAk0x5h7cs2vWk6Zeg6iRVTimO3 qhsQ== X-Gm-Message-State: AOAM530lqNeOnnySKWAZGyn/63QSPe6HS7Vr8SR6HA8yFPYtgnlPewWi fFwdm+oHRDdl4RusLAderMpDsFpgE+8ixl+8 X-Google-Smtp-Source: ABdhPJyxPIOTEwBQ8HbDdM/2S+AcYUZJrbXS97h4pd9HLdDItjeItwPhuVsEacKP+yWL4GryMGJtWA== X-Received: by 2002:a17:902:5581:b029:d5:ff8e:18e5 with SMTP id g1-20020a1709025581b02900d5ff8e18e5mr1442718pli.36.1603354753485; Thu, 22 Oct 2020 01:19:13 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([134.134.137.79]) by smtp.gmail.com with ESMTPSA id j5sm1179514pjb.56.2020.10.22.01.19.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2020 01:19:13 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: chethan.tumkur.narayan@intel.com, ravishankar.srivatsa@intel.com, kiran.k@intel.com, Sathish Narasimman Subject: [PATCH 2/3] Bluetooth: btintel: Introducing new btintel read version Date: Thu, 22 Oct 2020 13:54:34 +0530 Message-Id: <20201022082435.31831-3-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201022082435.31831-1-sathish.narasimman@intel.com> References: <20201022082435.31831-1-sathish.narasimman@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org The new btintel read version supports the latest intel read version command and also supports the TLV structure parsing. It still handles the legacy read version Signed-off-by: Sathish Narasimman --- drivers/bluetooth/btintel.c | 51 +++++++++++++++++++++++++++++++++++++ drivers/bluetooth/btintel.h | 15 +++++++++++ 2 files changed, 66 insertions(+) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index cc8e6c4e3205..ddd3c4bbdd6f 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -476,6 +476,57 @@ static void btintel_parse_tlv(struct sk_buff *skb, } } +int btintel_read_version_new(struct hci_dev *hdev, struct btintel_version *ver) +{ + struct sk_buff *skb; + struct intel_version *version = &ver->ver; + const u8 param[1] = { 0xFF }; + + skb = __hci_cmd_sync(hdev, 0xfc05, 1, param, HCI_CMD_TIMEOUT); + if (IS_ERR(skb)) { + bt_dev_err(hdev, "Reading Intel version info failed (%ld)", + PTR_ERR(skb)); + return PTR_ERR(skb); + } + + if (skb->data[0]) { + bt_dev_err(hdev, "Intel Read Version command failed (%02x)", + skb->data[0]); + kfree_skb(skb); + return -EIO; + } + + /* The new Intel read version is backward compatible for Thp and CcP + * type cards. when the controller is in bootloader mode the controller + * response remains same as old intel_read version. For ThP/CcP cards + * TLV stucture supports only during the Operation Mode. The best way + * to differentiate the read_version response is to check the length + * parameter and first byte of the payload, which is a fixed value. + * After the status parameter if the payload starts with 0x37(This is + * a fixed value) and length of the payload is 10 then it is identified + * as legacy struct intel_version. In the latest firmweare the support + * of TLV structure is added during Operational Firmware. + */ + if (skb->len == sizeof(*version) && skb->data[1] == 0x37) { + memcpy(version, skb->data, sizeof(*version)); + ver->tlv_format = false; + goto finish; + } + + /* Consume Command Complete Status field */ + skb_pull(skb, 1); + + ver->tlv_format = true; + + bt_dev_info(hdev, "Parsing TLV Supported intel read version"); + btintel_parse_tlv(skb, &ver->ver_tlv); + +finish: + kfree_skb(skb); + return 0; +} +EXPORT_SYMBOL_GPL(btintel_read_version_new); + int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *version) { struct sk_buff *skb; diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index 09346ae308eb..08406ef935a3 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -132,6 +132,14 @@ struct intel_debug_features { __u8 page1[16]; } __packed; +struct btintel_version { + bool tlv_format; + union { + struct intel_version ver; /*Legacy Intel read version*/ + struct intel_version_tlv ver_tlv; + }; +}; + #if IS_ENABLED(CONFIG_BT_INTEL) int btintel_check_bdaddr(struct hci_dev *hdev); @@ -151,6 +159,7 @@ int btintel_set_event_mask(struct hci_dev *hdev, bool debug); int btintel_set_event_mask_mfg(struct hci_dev *hdev, bool debug); int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver); int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *ver); +int btintel_read_version_new(struct hci_dev *hdev, struct btintel_version *ver); struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read, u16 opcode_write); @@ -248,6 +257,12 @@ static inline int btintel_read_version_tlv(struct hci_dev *hdev, return -EOPNOTSUPP; } +static inline int btintel_read_version_new(struct hci_dev *hdev, + struct btintel_version *ver) +{ + return -EOPNOTSUPP; +} + static inline struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read, u16 opcode_write) From patchwork Thu Oct 22 08:24:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11850495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3F12C4363A for ; Thu, 22 Oct 2020 08:19:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 43B4A223BF for ; Thu, 22 Oct 2020 08:19:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Vwxk6Byi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2894837AbgJVITU (ORCPT ); Thu, 22 Oct 2020 04:19:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2443979AbgJVITT (ORCPT ); Thu, 22 Oct 2020 04:19:19 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08DB0C0613CE for ; Thu, 22 Oct 2020 01:19:18 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id r10so561255plx.3 for ; Thu, 22 Oct 2020 01:19:18 -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=mPrFcnY4OFxADSgpq9DDcI2iUS/rN/5Cba2JCqz3PLU=; b=Vwxk6ByiaSn8Y/nuQ6oX4QZXW/Hld7GHrghKiA1Zp03NKO2hhIxFHR6pjjbTyceeAf 8qbicWms5atfmDLnmQuQUAE5Tm2a1OmO2qzhExJrqDRZVdv2CNEO5XJSIdzclepucdB4 GmJkORM55gYGYXEckMbUJjPNv19HqF6fpOP+FJmahPOcFyMnqeLxuU7wa1OsPAshFGVl cn4fmUv9vE7hhuJ1zbhim/RgSkx6a+SWQvhysjkxvjwRz3J+s8ESXWzJTfZptMQOkiZc QWkDl4u+AiVnPmGItHsNaYgLXgubY16zgtNdb33rLfGdgMDHD8V/9FZQ8IQGpKBOwL5y GZ0w== 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=mPrFcnY4OFxADSgpq9DDcI2iUS/rN/5Cba2JCqz3PLU=; b=oDrtIhNjwcYzjdQKRlRAnQMSWZ+ltlsumkY+r2YomO+gBPK8PftAtTNQYLk0+KHVep YfNnauSyXmaBNu/92xK0gK6IosuHe92knwgVhYGZuilmbqp1b4I5wnIOI3OBawoOzxZd gBtbfpQnxpBZ4/rfgpbBZPlc952URVSWhFJm0BPM0Cj9yjdqdvOXvmqxZhwMrXUcdA74 otOPQvhT331M3HYSCbl64anAPCHBF0F4JyDgr4ykKtzX5gzK5/lmvkRRVlIkG3Ei1qFZ AVK9FSgCX5lkIFgELdOSpM1W7p467DRMSgRqoM9m3d+x8yoQyr8vKzu/AN7LYxJF1v5x 940Q== X-Gm-Message-State: AOAM532OJe5BY2P5wpTto9y3Twi+gSaaUxAhP3YdPj5iKiIyydIFtTjn M3urPLJZYKkWrx8Bmzf15I2r31GYQdyi++Hf X-Google-Smtp-Source: ABdhPJx4qGRWZSms2pYFv99NB0fzDFSvPlLQHblpSvNbr3ek3NoU59qKmWwGm5OR/ectGTft2cjjDw== X-Received: by 2002:a17:902:7042:b029:d5:c0e6:8e35 with SMTP id h2-20020a1709027042b02900d5c0e68e35mr1594531plt.9.1603354757281; Thu, 22 Oct 2020 01:19:17 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([134.134.137.79]) by smtp.gmail.com with ESMTPSA id j5sm1179514pjb.56.2020.10.22.01.19.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2020 01:19:16 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: chethan.tumkur.narayan@intel.com, ravishankar.srivatsa@intel.com, kiran.k@intel.com, Sathish Narasimman Subject: [PATCH 3/3] Bluetooth: btusb: Use the new btintel read version Date: Thu, 22 Oct 2020 13:54:35 +0530 Message-Id: <20201022082435.31831-4-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201022082435.31831-1-sathish.narasimman@intel.com> References: <20201022082435.31831-1-sathish.narasimman@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Replace the legacy btintel_read_version to btintel_read_verison_new. The new intel firmware has the support to parse TLV structure during operational mode. The patch takes care of both legacy and tlv structure. Signed-off-by: Sathish Narasimman --- drivers/bluetooth/btintel.h | 1 + drivers/bluetooth/btusb.c | 41 +++++++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index 08406ef935a3..e3025b90eda5 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -140,6 +140,7 @@ struct btintel_version { }; }; +#define INTEL_HW_VARIANT(cnvx_bt) ((u8)(((cnvx_bt) & 0x003f0000) >> 16)) #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 1005b6e8ff74..c63bc8a0c84f 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2554,7 +2554,8 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev, static int btusb_setup_intel_new(struct hci_dev *hdev) { struct btusb_data *data = hci_get_drvdata(hdev); - struct intel_version ver; + struct btintel_version bt_ver; + u8 hw_variant; struct intel_boot_params params; u32 boot_param; char ddcname[64]; @@ -2577,19 +2578,33 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) * is in bootloader mode or if it already has operational firmware * loaded. */ - err = btintel_read_version(hdev, &ver); + err = btintel_read_version_new(hdev, &bt_ver); if (err) { bt_dev_err(hdev, "Intel Read version failed (%d)", err); btintel_reset_to_bootloader(hdev); return err; } - err = btusb_intel_download_firmware(hdev, &ver, ¶ms, &boot_param); + /* If TLV format is supported then it is in Operational Firmware. TLV + * structure is supported only in operational mode in latest Firmware. + */ + if (bt_ver.tlv_format && bt_ver.ver_tlv.img_type == 0x03) { + btintel_version_info_tlv(hdev, &bt_ver.ver_tlv); + clear_bit(BTUSB_BOOTLOADER, &data->flags); + goto finish; + } + + err = btusb_intel_download_firmware(hdev, &bt_ver.ver, ¶ms, + &boot_param); if (err) return err; - /* controller is already having an operational firmware */ - if (ver.fw_variant == 0x23) + /* In case if old firmware is used, it should be backward compatible + * to check for operational firmware. only on latest firmware the + * support for TLV structure is added. so check for tlv is not + * required here. + */ + if (bt_ver.ver.fw_variant == 0x23) goto finish; rettime = ktime_get(); @@ -2641,7 +2656,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) clear_bit(BTUSB_BOOTLOADER, &data->flags); - err = btusb_setup_intel_new_get_fw_name(&ver, ¶ms, ddcname, + err = btusb_setup_intel_new_get_fw_name(&bt_ver.ver, ¶ms, ddcname, sizeof(ddcname), "ddc"); if (!err) { @@ -2665,17 +2680,25 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) btintel_set_debug_features(hdev, &features); /* Read the Intel version information after loading the FW */ - err = btintel_read_version(hdev, &ver); + err = btintel_read_version_new(hdev, &bt_ver); if (err) return err; - btintel_version_info(hdev, &ver); + if (bt_ver.tlv_format) + btintel_version_info_tlv(hdev, &bt_ver.ver_tlv); + else + btintel_version_info(hdev, &bt_ver.ver); finish: /* All Intel controllers that support the Microsoft vendor * extension are using 0xFC1E for VsMsftOpCode. */ - switch (ver.hw_variant) { + if (!bt_ver.tlv_format) + hw_variant = bt_ver.ver.hw_variant; + else + hw_variant = INTEL_HW_VARIANT(bt_ver.ver_tlv.cnvi_bt); + + switch (hw_variant) { case 0x12: /* ThP */ hci_set_msft_opcode(hdev, 0xFC1E); break;